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

📄 inventorycosts.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 InventoryCosts extends InputReader
{
    private String _fileName = "InventoryCosts";
	private Hashtable _inventoryCosts = new Hashtable();

	public InventoryCosts() {
	}

	private void addInventoryCost( String prodID, int facilityID, int bucketID, double cost ) {
		//String key = createKey( prodID, facilityID );
        Product p = DataModel.getInstance().getProducts().getProduct( facilityID, prodID );
		InventoryCost invCost = (InventoryCost) _inventoryCosts.get( p );

		if( null == invCost ) {
			invCost = new InventoryCost( prodID, facilityID );
			_inventoryCosts.put( p, invCost );
		}

		invCost.addCostEntry( bucketID, cost );
	}

	public InventoryCost getInventoryCost( String prodID, int facilityID ) {
        Product p = DataModel.getInstance().getProducts().getProduct( facilityID, prodID );
		//String key = createKey( prodID, facilityID );
		return (InventoryCost) _inventoryCosts.get( p );
	}

	private String createKey( String prodID, int fID ) {
		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 );
	}

	protected String getFileName() {
		return _fileName;
	}

	private void buildTimePhasedHoldingCosts() {
		Enumeration allInvCosts = _inventoryCosts.elements();

		while( allInvCosts.hasMoreElements() ){
			InventoryCost invCost = (InventoryCost) allInvCosts.nextElement();
			invCost.buildTimePhasedHoldingCosts();
		}
	}

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

        if( null == d ) {
          return;
        }

		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 );

			String prodID   = st.nextToken();
			int facilityID  = new Integer( st.nextToken() ).intValue();
			int bucketID    = new Integer( st.nextToken() ).intValue();
			double cost     = new Double( st.nextToken() ).doubleValue();

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

			Facility aFacility = facilities.getFacility( facilityID );
            if( null == aFacility ) {
                reportError( "Facility ID", new Integer( facilityID ).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;
            }

			addInventoryCost( prodID, facilityID, bucketID, cost );

			aLine = d.readLine();
		}

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

	public void print() {
		System.out.println( "\n\n\nInventoryCost ---------------------" );
		Enumeration allInvCosts = _inventoryCosts.elements();

		while( allInvCosts.hasMoreElements() ) {
			InventoryCost invCost = (InventoryCost) allInvCosts.nextElement();
			invCost.print();
		}
	}



}

⌨️ 快捷键说明

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