📄 inventorygroups.java
字号:
package com.power.pipeengine.InputData;
import java.util.*;
import java.io.*;
import com.power.pipeengine.Entity.*;
import com.power.pipe.*;
import com.power.pipeengine.*;
public class InventoryGroups extends InputReader
{
static ResourceBundle res = ResourceBundle.getBundle("com.power.pipeengine.Res",
EngineConfig.getInstance().getLocale() );
private Hashtable _invGroups = new Hashtable();
String _fileName = "InventoryGroup";
public InventoryGroups() {
}
public void addInvGroup( int grpID, String prodID, int facilityID ) {
String key = new Integer( grpID ).toString();
InventoryGroup invGrp = (InventoryGroup) _invGroups.get( key );
Products products = DataModel.getInstance().getProducts();
if( null == invGrp ) {
invGrp = new InventoryGroup( grpID );
_invGroups.put( key, invGrp );
}
invGrp.addProduct( products.getProduct( facilityID, prodID ) );
}
public Hashtable getInvGroups() {
return _invGroups;
}
public InventoryGroup getInventoryGroup( int grpID ) {
String key = new Integer( grpID ).toString();
return (InventoryGroup) _invGroups.get( key );
}
public int getGroupID( Product p ) {
Enumeration invGrps = _invGroups.elements();
while( invGrps.hasMoreElements() ) {
InventoryGroup invGrp = (InventoryGroup) invGrps.nextElement();
if( invGrp.contains( p ) ) {
return invGrp.getGroupID();
}
}
return -1;
}
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();
Facilities facilities = DataModel.getInstance().getFacilities();
while( aLine != null ) {
if( aLine.length() <= 1 ) {
aLine = d.readLine();
continue;
}
StringTokenizer st = new StringTokenizer( aLine, token );
int grpID = new Integer( st.nextToken() ).intValue();
String productID = st.nextToken();
int facilityID = new Integer( st.nextToken() ).intValue();
Product p = DataModel.getInstance().getProducts().getProduct( facilityID, productID );
if( null == p ) {
reportError( "Product ID", productID, aLine );
aLine = d.readLine();
continue;
}
Facility aFacility = facilities.getFacility( facilityID );
if( null == aFacility ) {
reportError( "Facility ID", new Integer( facilityID ).toString(), aLine );
aLine = d.readLine();
continue;
}
addInvGroup( grpID, productID, facilityID );
aLine = d.readLine();
}
d.close();
super.closeURLConnection();
}
public void print() {
System.out.println( "\n\n\nInventoryGroup ---------------------" );
Enumeration invGrps = _invGroups.elements();
while( invGrps.hasMoreElements() ) {
InventoryGroup invGrp = (InventoryGroup) invGrps.nextElement();
invGrp.print();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -