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

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

public class InterShipment extends InputReader
{
    private Hashtable _shipments = null;
	private String _fileName = "InterShipment";
	private int _shipmentCodeLength = 2;

	public InterShipment() {
		_shipments = new Hashtable();
	}

	protected String getFileName() {
		return _fileName;
	}

	public void addShipment( Shipment s, int seqNum ) {
		_shipments.put( new Integer(seqNum), s );
	}

	public Hashtable getShipments() {
		return _shipments;
	}

	private String createKey( Shipment s ) {
		char[] key = new char[35];
		String from = new Integer( s.getFromFacilityID() ).toString();
		String to = new Integer( s.getToFacilityID() ).toString();

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

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

		idx = 24;
		String fromProdID = s.getFromProductID();
		for( int i=fromProdID.length()-1; i>=0; i-- ) {
			key[idx] = fromProdID.charAt(i);
			idx--;
		}

		return new String( key );
	}


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

			int fromID    = new Integer( st.nextToken() ).intValue();
			int toID      = new Integer( st.nextToken() ).intValue();
			double time = new Double( st.nextToken() ).doubleValue();
			String fromProdID = st.nextToken();
			String toProdID  = st.nextToken();

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

			Facility to = facilities.getFacility( toID );

            if( null == to ) {
                reportError( "Facility ID", new Integer( toID ).toString(), aLine );
                aLine = d.readLine();
                continue;
            }


			Shipment s = new Shipment( fromID, toID, time, fromProdID, toProdID );
			from.addDestinationFacility( to, s );
			to.addOriginatingFacility( from, s );

			addShipment( s, cnt );

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

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

	public void print() {
		System.out.println( "\n\n\nInterShipment ---------------------" );
		Enumeration allShipments = _shipments.elements();
		while( allShipments.hasMoreElements() ) {
			Shipment s = (Shipment) allShipments.nextElement();
			s.print();
		}
	}
}

⌨️ 快捷键说明

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