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

📄 productbounds.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.*;

public class ProductBounds extends InputReader
{
    private Hashtable _productBounds = new Hashtable();
	private String _fileName = "ProductBounds";

	public ProductBounds() {
	}

	private void addProductBound( int fID,
								  String prodID,
								  int bucketID,
								  String bndType,
								  double qty,
								  double cost ) {
		String key = createKey( fID, prodID );
		ProductBound pb = (ProductBound) _productBounds.get( key );

		if( null == pb ) {
			pb = new ProductBound( fID, prodID );
			_productBounds.put( key, pb );
		}

		pb.addBound( bucketID, bndType, qty, cost );
	}

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

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

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

		return new String( key );
	}

	public Hashtable getProductBounds() {
		return _productBounds;
	}

	protected String getFileName() {
		return _fileName;
	}

	public void readData() throws Exception {
		BufferedReader d = super.getReader();

        if( null == d ) {
          return;
        }

		String token = GlobalConfig.getInstance().getSeparator();
		String aLine = d.readLine();
		Facilities facilities = DataModel.getInstance().getFacilities();

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

			int facilityID     = new Integer( st.nextToken() ).intValue();
			String productID   = st.nextToken();
			int effectiveBucket     = new Integer( st.nextToken() ).intValue();
			String bndType   = st.nextToken();
			double qty     = new Double( st.nextToken() ).doubleValue();
			double cost     = new Double( st.nextToken() ).doubleValue();

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

            Product p = DataModel.getInstance().getProducts().getProduct( facilityID, productID );
            if( null == p ) {
                reportError( "Product ID", productID, aLine );
                aLine = d.readLine();
                continue;
            }

			addProductBound( facilityID,
							 productID,
							 effectiveBucket,
							 bndType,
							 qty,
							 cost );
			aLine = d.readLine();
		}

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

	}

	public void print() {
		System.out.println( "\n\n\nProductBound ---------------------" );
		Enumeration allBnds = _productBounds.elements();

		while( allBnds.hasMoreElements() ) {
			ProductBound prodBnd = (ProductBound) allBnds.nextElement();
			prodBnd.print();
		}
	}
}

⌨️ 快捷键说明

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