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

📄 resources.java

📁 APS(高级排产系统)
💻 JAVA
字号:
package com.power.pipeengine.InputData;

import java.util.*;
import java.io.*;
import com.power.pipeengine.Entity.*;
import com.power.pipe.*;

public class Resources extends InputReader
{
    private String _fileName = "Resource";
	private Hashtable _resources;
    private Hashtable groupByFacility = new Hashtable();
	private int _rscCodeLength = 3;

	public Resources() {
		_resources = new Hashtable();
	}

	private void addResource( Resource rsc, int key ) {
		/*String key = createKey( rsc.getResourceID(),
								rsc.getFacilityID() );*/


		_resources.put( new Integer( key ), rsc );

        Hashtable rscsAtFac = (Hashtable) groupByFacility.get( rsc.getFacility() );
        if( null == rscsAtFac ) {
            rscsAtFac = new Hashtable();
            groupByFacility.put( rsc.getFacility(), rscsAtFac );
        }

        rscsAtFac.put( rsc.getResourceID(), rsc );
	}

	public Resource getResource( String rscID, int facilityID ) {
		/*String key = createKey( rscID, facilityID );*/

        Facility f = DataModel.getInstance().getFacilities().getFacility( facilityID );
        Hashtable rscsAtFac = (Hashtable) groupByFacility.get( f );

        if( null == rscsAtFac ) {
            return null;
        }

		return (Resource) rscsAtFac.get( rscID );
	}

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

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

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

		return new String( key );
	}

	public Hashtable getResources() {
		return _resources;
	}

	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 rscID   = st.nextToken();
			int facilityID     = new Integer( st.nextToken() ).intValue();
			int effectiveBucket     = new Integer( st.nextToken() ).intValue();
			double hours     = 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;
            }

			Resource r = getResource( rscID, facilityID );

			if( null == r ) {
				r = new Resource( rscID, facilityID );
				addResource( r, cnt );
			}

			r.setVariableCode( cnt, 2 );

			r.addTimePhasedAvailData( effectiveBucket, hours );

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

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

		buildTimePhasedAvailData();
	}

	private void buildTimePhasedAvailData() {
		Enumeration allRscs = _resources.elements();

		while( allRscs.hasMoreElements() ){
			Resource r = (Resource) allRscs.nextElement();
			r.buildTimePhasedAvailData();
		}
	}

	public void print() {
		System.out.println( "\n\n\nResource ---------------------" );
		Enumeration allRscs = _resources.elements();

		while( allRscs.hasMoreElements() ) {
			Resource r = (Resource) allRscs.nextElement();
			r.print();
		}
	}
}

⌨️ 快捷键说明

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