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

📄 routesources.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.*;
import com.power.pipeengine.*;

public class RouteSources extends InputReader
{
    static ResourceBundle res = ResourceBundle.getBundle("com.power.pipeengine.Res",
                                                          EngineConfig.getInstance().getLocale() );
    private Hashtable _routeSources;
	private String _fileName = "RouteSource";

	public RouteSources() {
		_routeSources = new Hashtable();
	}

	private void addRouteSource( RouteSource rteSrc ) {
		String key = createKey( rteSrc.getRouteID(), rteSrc.getProductID() );
        Vector rteSrcs = (Vector) _routeSources.get( key );
        if( null == rteSrcs ) {
            rteSrcs = new Vector();
        }
		_routeSources.put( key, rteSrcs );
        rteSrcs.add( rteSrc );
	}

    public Vector getRouteSources( Route r ) {
        String key = new Integer( r.getRouteID() ).toString();
        return (Vector) _routeSources.get( key );
    }

	private String createKey( int rteID, String prodID ) {
		/*char[] key = new char[30];
		String route = new Integer( rteID ).toString();

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

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

		return new String( key );*/

        return ( new Integer( rteID ) ).toString();
	}

	protected String getFileName() {
		return _fileName;
	}

	public Hashtable getRouteSources() {
		return _routeSources;
	}

	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();
		Routes routes = DataModel.getInstance().getRoutes();

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

			int rteID     = new Integer( st.nextToken() ).intValue();
			String productID = st.nextToken();
			int rank     = new Integer( st.nextToken() ).intValue();
			int numberRequired     = new Integer( st.nextToken() ).intValue();
			String sOrM = st.nextToken();

            if( null == routes.getRoute( rteID ) ) {
                reportError( "Route ID", new Integer( rteID ).toString(), aLine );
                aLine = d.readLine();
                continue;
            }

			Product prod = products.getProduct( routes.getRoute( rteID ).getSrcingFacilityID(), productID );
            if( null == prod ) {
                reportError( "Product ID", productID, aLine );
                aLine = d.readLine();
                continue;
            }

			addRouteSource( new RouteSource( rteID,
											 productID,
											 rank,
											 numberRequired,
											 sOrM ) );
			Route r = routes.getRoute( rteID );
			Product p = products.getProduct( r.getSrcingFacilityID(), productID );

			p.addSourcingRoute( r );

			aLine = d.readLine();
		}
        d.close();
		super.closeURLConnection();
        checkDataSufficiency();
	}

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

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

	public void print() {
		System.out.println( "\n\n\nRouteSource ---------------------" );
		Enumeration allRteSrcs = _routeSources.elements();

		while( allRteSrcs.hasMoreElements() ) {
			RouteSource rteSrc = (RouteSource) allRteSrcs.nextElement();
			rteSrc.print();
		}
	}
}

⌨️ 快捷键说明

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