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

📄 materials.java

📁 排产系统
💻 JAVA
字号:
package com.power.pipeengine.InputData;

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

public class Materials extends InputReader
{
    private Hashtable _materials = new Hashtable();
	private String _fileName = "Materials";
	private int _materialCodeLength = 3;

	public Materials() {
	}

	public void addMaterial( String matID, int facilityID, int bucketID, double qty ) {
		String key = createKey( matID, facilityID );
		Material material = (Material) _materials.get( key );

		if( null == material ) {
			material = new Material( matID, facilityID );
			_materials.put( key, material );
			material.setVariableCode( _materials.size(),
									  _materialCodeLength );
		}

		material.addAvailMaterial( bucketID, qty );
	}

	public Hashtable getMaterials() {
		return _materials;
	}

	private String createKey( String matID, 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=matID.length()-1; i>=0; i-- ) {
			key[idx] = matID.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();
		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 matID = st.nextToken();
			int facilityID     = new Integer( st.nextToken() ).intValue();
			int bucketID     = new Integer( st.nextToken() ).intValue();
			double qty   = 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;
            }

            if( null == DataModel.getInstance().getCalendar().getBucket( bucketID ) ) {
                reportError( "Bucket ID", new Integer( bucketID ).toString(), aLine );
                aLine = d.readLine();
                continue;
            }

			addMaterial( matID, facilityID, bucketID, qty );

			aLine = d.readLine();
		}

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

	public void print() {
		System.out.println( "\n\n\nMaterial ---------------------" );
		Enumeration mats = _materials.elements();
		while( mats.hasMoreElements() ) {
			Material mat = (Material) mats.nextElement();
			mat.print();
		}
	}


}

⌨️ 快捷键说明

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