排产系统

源代码在线查看: materials.java

软件大小: 4136 K
上传用户: zhou28
关键词:
下载地址: 免注册下载 普通下载 VIP

相关代码

				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() 				                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();
						}
					}
				
				
				}
							

相关资源