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

📄 routes.java

📁 著名IT公司ILog的APS高级排产优化引擎
💻 JAVA
字号:
package com.power.pipeengine.InputData;

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

public class Routes extends InputReader
{
    static ResourceBundle res = ResourceBundle.getBundle("com.power.pipeengine.Res",
                                                          EngineConfig.getInstance().getLocale() );
    private String _fileName = "Route";
	private Hashtable _routes;
	private int _routeCodeLength = 3;

	public Routes() {
		_routes = new Hashtable();
	}

	private void addRoute( Route r ) {
		_routes.put( createKey( r.getRouteID() ), r );
	}

	private String createKey( int routeID ) {
		return new Integer( routeID ).toString();
	}

    public int getNumberOfRoutes() {
        return _routes.size();
    }

	public Route getRoute( int routeID ) {
		return (Route) _routes.get( createKey( routeID ) );
	}

	public Hashtable getRoutes() {
		return _routes;
	}

	protected String getFileName() {
		return _fileName;
	}

	public Vector getRoutes( int facilityID, String prodID ) {
		Vector qualifyRoutes = new Vector();
		Enumeration allRoutes = _routes.elements();

		while( allRoutes.hasMoreElements() ) {
			Route r = (Route) allRoutes.nextElement();
			if( r.getFacilityID() == facilityID &&
                ( EngineConfig.getInstance().getCollator().compare(
				r.getProductID(), prodID ) == 0 ) ) {
				qualifyRoutes.addElement( r );
			}
		}

		if( qualifyRoutes.size() == 0 ) {
			return null;
		} else {
			return qualifyRoutes;
		}
	}

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

        if( null == d ) {
          return;
        }

		String aLine = d.readLine();
        Products products = DataModel.getInstance().getProducts();
		Facilities facilities = DataModel.getInstance().getFacilities();

		while( aLine != null ) {
            if( aLine.length() <= 1 ) {
                aLine = d.readLine();
                continue;
            }
			StringTokenizer st = new StringTokenizer( aLine, token );

			int routeID     = new Integer( st.nextToken() ).intValue();
			String productID   = st.nextToken();
			int facilityID     = new Integer( st.nextToken() ).intValue();
			int srcingFacilityID     = new Integer( st.nextToken() ).intValue();
			int destFacilityID     = new Integer( st.nextToken() ).intValue();
			int effectiveBucket     = new Integer( st.nextToken() ).intValue();
			double cycleTime     = new Double( st.nextToken() ).doubleValue();
			double yield     = new Double( st.nextToken() ).doubleValue();
			double costPerStart     = new Double( st.nextToken() ).doubleValue();

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

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

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

			Product p = products.getProduct( facilityID, productID );
            if( null == p ) {
                reportError( "Product ID", productID, aLine );
                aLine = d.readLine();
                continue;
            }

			Route r = new Route( routeID,
								 productID,
								 facilityID,
								 srcingFacilityID,
								 destFacilityID,
								 effectiveBucket,
								 cycleTime,
								 yield,
								 costPerStart );

			r.setVariableCode( routeID, _routeCodeLength );

			addRoute( r );

			aLine = d.readLine();
		}

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

    private void checkDataSufficiency() {
      if( _routes.size() < 1  ) {
          MessageArea.getInstance().addMessage(
            res.getString("Engine17005") +
            res.getString("required_to_create_a") );

        EngineConfig.getInstance().setDataSufficiency( false );
      }
    }

	public void print() {
		System.out.println( "\n\n\nRoute ---------------------" );
		Enumeration allRoutes = _routes.elements();

		while( allRoutes.hasMoreElements() ) {
			Route r = (Route) allRoutes.nextElement();
			r.print();
		}
	}
}

⌨️ 快捷键说明

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