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

📄 products.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 Products extends InputReader
{
    static ResourceBundle res = ResourceBundle.getBundle("com.power.pipeengine.Res",
                                                          EngineConfig.getInstance().getLocale() );
    private String _fileName = "Product";
	private Hashtable _products = null;
	private int _productCodeLength = 3;
    private int _prodCnt = 0;

	public Products() {
		_products = new Hashtable();
	}

	private void addProduct( Product p ) {
        Facility f = p.getFacility();
        Hashtable prodsAtFacility = (Hashtable) _products.get( f );
        if( null == prodsAtFacility ) {
            prodsAtFacility = new Hashtable();
            _products.put( f, prodsAtFacility );
        }

        Object status = prodsAtFacility.put( p.getProductID(), p );
        if( null == status ) {
            p.setProdNumber( _prodCnt );
            _prodCnt++;
        }
	}


	private String createKey( int fID, String prodID ) {
		char[] key = new char[30];
		String facility = new Integer( fID ).toString();

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

		idx = 24;
		for( int i=prodID.length()-1; i>=0; i-- ) {
			key[idx] = prodID.charAt(i);
			idx--;
		}
		return new String( key );
	}



	public Product getProduct( int fID, String productID ) {
        Product rtnProd = null;
        Facility f = DataModel.getInstance().getFacilities().getFacility( fID );
        Hashtable prodsAtFacility = (Hashtable) _products.get( f );
        if( null != prodsAtFacility ) {
            rtnProd = (Product) prodsAtFacility.get( productID );
        }
		return rtnProd;
	}

	public Hashtable getProducts() {
		return _products;
	}

	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();
		int cnt = 0;
		Facilities facilities = DataModel.getInstance().getFacilities();

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

			String prodID             = st.nextToken();
			int facilityID   = new Integer( st.nextToken() ).intValue();

			Product p = new Product( prodID, facilityID );

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

			p.setVariableCode( cnt, _productCodeLength );

			addProduct( p );


			f.addProduct( p );

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

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

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

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


	public void print() {
		System.out.println( "\n\n\nProduct ---------------------" );
		Enumeration allProducts = _products.elements();

		while( allProducts.hasMoreElements() ) {
			Product p = (Product) allProducts.nextElement();
			p.print();
		}
	}
}

⌨️ 快捷键说明

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