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

📄 materialuses.java

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

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

public class MaterialUses extends InputReader
{
    private Hashtable _matUsesByMat = new Hashtable();
	private String _fileName = "MaterialUse";

	public MaterialUses() {
	}

	private void addMaterialUse( MaterialUse matUse ) {
		String key = matUse.getMaterialID();
		Vector usesByMat = (Vector) _matUsesByMat.get( key );

		if( null == usesByMat ) {
			usesByMat = new Vector();
			_matUsesByMat.put( key, usesByMat );
		}

		usesByMat.addElement( matUse );
	}

	public Hashtable getMaterialUses() {
		return _matUsesByMat;
	}

	protected String getFileName() {
		return _fileName;
	}

	private void buildTimePhasedConsumption() {
		Enumeration allMatUses = _matUsesByMat.elements();

		while( allMatUses.hasMoreElements() ){
			Vector uses = (Vector) allMatUses.nextElement();
			for( int i=0; i<uses.size(); i++ ) {
				MaterialUse matUse = (MaterialUse) uses.elementAt(i);
				matUse.buildTimePhasedConsumption();
			}
		}
	}

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

        if( null == d ) {
          return;
        }

		String aLine = d.readLine();
        Routes routes = DataModel.getInstance().getRoutes();
		while( aLine != null ) {
            if( aLine.length() <= 1 ) {
                aLine = d.readLine();
                continue;
            }
			StringTokenizer st = new StringTokenizer( aLine, token );

			String matID = st.nextToken();
			int routeID     = new Integer( st.nextToken() ).intValue();
			int bucketID   = new Integer( st.nextToken() ).intValue();
			double rate   = new Double( st.nextToken() ).doubleValue();

            if( null == routes.getRoute( routeID ) ) {
                reportError( "Route ID", new Integer( routeID ).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;
            }

			MaterialUse matUse = new MaterialUse( matID, routeID );
			matUse.addConsumptionRate( bucketID, rate );

			addMaterialUse( matUse );

			aLine = d.readLine();
		}

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

		buildTimePhasedConsumption();

	}

	public void print() {
		System.out.println( "\n\n\nMaterialUse ---------------------" );
		Enumeration matUses = _matUsesByMat.elements();
		while( matUses.hasMoreElements() ) {
			Vector uses = (Vector) matUses.nextElement();
			for( int i=0; i<uses.size(); i++ ) {
				MaterialUse matUse = (MaterialUse) uses.elementAt(i);
				matUse.print();
			}
		}
	}
}

⌨️ 快捷键说明

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