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

📄 inventories.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 Inventories extends InputReader
{
    private Hashtable _inventories = new Hashtable();
	private String _fileName = "Inventory";

	public Inventories() {
	}

	public void addInventory( String prodID, int fID, int bucketID, double qty ) {
		//String key = createKey( fID, prodID );
        Product p = DataModel.getInstance().getProducts().getProduct( fID, prodID );
		Inventory inv = (Inventory) _inventories.get( p );

		if( null == inv ) {
			inv = new Inventory( prodID, fID );
			inv.addEntry( bucketID, qty );
			_inventories.put( p, inv );
		} else {
			inv.addEntry( bucketID, qty );
		}
	}

	public double getInventoryQty( String prodID, int facilityID, int bucketID ) {
		//String key = createKey( facilityID, prodID );
        Product p = DataModel.getInstance().getProducts().getProduct( facilityID, prodID );
		Inventory inv = (Inventory) _inventories.get( p );

		if( null == inv ) {
			return 0;
		} else {
			return inv.getInventoryQty( bucketID );
		}
	}

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



	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();
		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 qty     = 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;
            }


			addInventory( prodID, facilityID, bucketID, qty );

			aLine = d.readLine();
		}

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

	public void print() {
		System.out.println( "\n\n\nInventory ---------------------" );
		Enumeration inventories = _inventories.elements();
		while( inventories.hasMoreElements() ) {
			Inventory inv = (Inventory) inventories.nextElement();
			inv.print();
		}
	}

}

⌨️ 快捷键说明

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