⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productdemands.java

📁 著名IT公司ILog的APS高级排产优化引擎
💻 JAVA
字号:
package com.power.pipeengine.InputData;

import java.util.*;
import java.io.*;
import com.power.pipeengine.Entity.*;
import com.power.pipe.*;
import com.power.util.Message.*;
import com.power.pipeengine.*;

public class ProductDemands extends InputReader
{
    static ResourceBundle res = ResourceBundle.getBundle("com.power.pipeengine.Res",
                                                          EngineConfig.getInstance().getLocale() );
    private Hashtable _productDemands;
	private String _fileName = "ProductDemand";

	public ProductDemands() {
		_productDemands = new Hashtable();
	}

    public Hashtable getAllDemands() {
        return _productDemands;
    }

	private void addProductDemand( ProductDemand pd, int key ) {
		//String key = createKey( pd );
		_productDemands.put( new Integer( key ), pd );
	}

	private String createKey( ProductDemand pd ) {
		char[] key = new char[40];
		String fID = new Integer( pd.getFacilityID() ).toString();

		int idx = 39;
		for( int i=fID.length()-1; i>=0; i-- ) {
			key[idx] = fID.charAt(i);
			idx--;
		}

		String bucketID = new Integer( pd.getBucketID() ).toString();

		idx = 34;
		for( int i=bucketID.length()-1; i>=0; i-- ) {
			key[idx] = bucketID.charAt(i);
			idx--;
		}

		/*String priority = new Integer( pd.getPriority() ).toString();

		idx = 29;
		for( int i=priority.length()-1; i>=0; i-- ) {
			key[idx] = priority.charAt(i);
			idx--;
		}*/

		idx = 29;

		String prodID = pd.getProduct().getProductID();
		for( int i=prodID.length()-1; i>=0; i-- ) {
			key[idx] = prodID.charAt(i);
			idx--;
		}

		return new String( key );
	}

	protected String getFileName() {
		return _fileName;
	}

	public void readData() throws Exception {
		String token = GlobalConfig.getInstance().getSeparator();
		BufferedReader d = super.getReader();

        if( null == d ) {
          return;
        }

		String aLine = d.readLine();
		Products products = DataModel.getInstance().getProducts();
		Facilities facilities = DataModel.getInstance().getFacilities();
        int cnt = 0;

		while( aLine != null ) {
            if( aLine.length() <= 1 ) {
                aLine = d.readLine();
                continue;
            }
			StringTokenizer st = new StringTokenizer( aLine, token );

			String productID = st.nextToken();

			int bucketID = new Integer( st.nextToken() ).intValue();
			int priority = new Integer( st.nextToken() ).intValue();
			int facility = new Integer( st.nextToken() ).intValue();
			double qty   = new Double( st.nextToken() ).doubleValue();
			double asp   = new Double( st.nextToken() ).doubleValue();

			Product p = products.getProduct( facility, productID );
            if( null == p ) {
                reportError( "Product ID", productID, aLine );
                aLine = d.readLine();
                continue;
            }

			Facility aFacility = facilities.getFacility( facility );
            if( null == aFacility ) {
                reportError( "Facility ID", new Integer( facility ).toString(), aLine );
                aLine = d.readLine();
                continue;
            }

            if( null == DataModel.getInstance().getCalendar().getBucket( bucketID ) ) {
                reportError( "Bucket ID", new Integer( bucketID ).toString(), aLine );
                aLine = d.readLine();
                continue;
            }

            if( priority == 2 && !EngineConfig.getInstance().isATPScheduling() ) {
                //skip
            } else {
                ProductDemand prodDmd = new ProductDemand( p,
                        bucketID,
                        priority,
                        facility,
                        qty,
                        asp );

                addProductDemand( prodDmd, cnt );

                p.addDemand( prodDmd );
            }

			aLine = d.readLine();
            cnt++;
		}

        d.close();
		super.closeURLConnection();
        checkDataSufficiency();
	}

    private void checkDataSufficiency() {
      if( _productDemands.size() < 1  ) {
          MessageArea.getInstance().addMessage(
            res.getString("Engine17002") +
            res.getString("required_to_create_a") );

        EngineConfig.getInstance().setDataSufficiency( false );
      }
    }


	public void print() {
		System.out.println( "\n\n\nProductDemand ---------------------" );
		Enumeration allDemand = _productDemands.elements();

		while( allDemand.hasMoreElements() ) {
			ProductDemand prodDmd = (ProductDemand) allDemand.nextElement();
			prodDmd.print();
		}
	}

    private Hashtable lastRoutes = new Hashtable();
    public void genLastRoutes() {
            Hashtable allDmds = DataModel.getInstance().getProductDemands().getAllDemands();
            Enumeration dmds = allDmds.elements();

            while( dmds.hasMoreElements() ) {
                ProductDemand aDmd = (ProductDemand) dmds.nextElement();
                Vector producingRoutes = aDmd.getProduct().getProducingRoutes();
                for( int i=0; i<producingRoutes.size(); i++ ) {
                    Route aRoute = ( Route) producingRoutes.elementAt( i );
                    lastRoutes.put( new Integer( aRoute.getRouteID() ), aRoute );
                }
            }
    }

    public boolean isLastRoute( Integer rteID ) {
        if( null == lastRoutes.get(  rteID ) ) {
            return false;
        }
        return true;
    }

    public Hashtable getLastRoutes() {
        return lastRoutes;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -