?? equipmentcapabilitytable.java
字號:
package com.power.pipeengine.DispatchReportMap;
import java.util.*;
import java.io.*;
import java.text.*;
import java.net.*;
import com.power.util.Message.*;
import com.power.pipeengine.Entity.*;
import com.power.pipe.*;
import com.power.util.Message.*;
import com.power.pipeengine.*;
import com.power.pipeengine.InputData.*;
import com.power.pipeengine.DispatchReport.*;
public class EquipmentCapabilityTable extends InputReader
{
static ResourceBundle res = ResourceBundle.getBundle("com.power.pipeengine.Res",
EngineConfig.getInstance().getLocale() );
private String _fileName = "operationequipmentmap";
private Hashtable operEquipTable = new Hashtable();
private Hashtable allEquipment = new Hashtable();
private static final EquipmentCapabilityTable INSTANCE =
new EquipmentCapabilityTable();
// Private constructor supresses
// default public constructor
private EquipmentCapabilityTable( ) {
}
public static EquipmentCapabilityTable getInstance( ) {
return INSTANCE;
}
protected String getFileName() {
return _fileName;
}
public void printTimeWindow() {
Enumeration allEquip = allEquipment.elements();
while( allEquip.hasMoreElements() ) {
EquipmentCapability ec = (EquipmentCapability) allEquip.nextElement();
ec.print();
System.out.println( "\n\n" );
}
}
public void getEquipment2( StartsSchedule aSchedule ) {
Vector oet = (Vector) operEquipTable.get( new Integer( aSchedule.getRouteID() ) );
if( null == oet ) {
return;
}
for( int i=0; i<oet.size(); i++ ) {
EquipmentCapability aEquipCap = (EquipmentCapability) oet.elementAt( i );
if( aEquipCap.ableToInsertWindow( aSchedule.getStartTime(),
aSchedule.getEndTime() ) ) {
aEquipCap.insertAWindow( aSchedule.getStartTime(),
aSchedule.getEndTime() );
aSchedule.setEquipment( aEquipCap.getEquipmentID() );
return;
}
}
}
public void markUnavailable( String equipID, int bucketID ) {
ProcessCapability pc = (ProcessCapability) allEquipment.get( equipID );
pc.turnOffBucket( bucketID );
}
public int getEquipmentSimple( StartsSchedule aSchedule ) {
Vector oet = (Vector) operEquipTable.get( new Integer( aSchedule.getRouteID() ) );
if( null == oet ) {
aSchedule.setEquipment( "-1" );
return -1;
}
for( int i=0; i<oet.size(); i++ ) {
EquipmentCapability aEquipCap = (EquipmentCapability) oet.elementAt(i);
if( aEquipCap.getAssignedEmployee() < 0 ) {
aEquipCap.setAssignedEmployee( aSchedule.getEmployee() );
aSchedule.setEquipment( aEquipCap.getEquipmentID() );
return 0;
}
}
aSchedule.setEquipment( "-1" );
return -1;
}
public int getEquipment( StartsSchedule aSchedule ) {
Vector oet = (Vector) operEquipTable.get( new Integer( aSchedule.getRouteID() ) );
if( null == oet ) {
return -1;
}
double minWastedCap = 10000000;
EquipmentCapability chosenEC = null;
for( int i=0; i<oet.size(); i++ ) {
EquipmentCapability aEquipCap = (EquipmentCapability) oet.elementAt( i );
double wastedCap = aEquipCap.mayAssignToSchedule( aSchedule );
if( wastedCap < 0 ) {
continue;
} else {
if( wastedCap < minWastedCap ) {
minWastedCap = wastedCap;
chosenEC = aEquipCap;
}
}
}
if( null != chosenEC ) {
chosenEC.assignToSchedule( aSchedule );
return 0;
}
return -1;
}
public void readData() throws Exception {
BufferedReader d = super.getReader();
if( null == d ) {
return;
}
String token = GlobalConfig.getInstance().getSeparator();
String aLine = d.readLine();
while( aLine != null ) {
if( aLine.length() <= 1 ) {
aLine = d.readLine();
continue;
}
StringTokenizer st = new StringTokenizer( aLine, token );
Integer rteID = new Integer( st.nextToken() );
String equipType = st.nextToken();
String equipID = st.nextToken();
EquipmentCapability ec = (EquipmentCapability) allEquipment.get( equipID );
if( null == ec ) {
ec = new EquipmentCapability( equipID );
allEquipment.put( equipID, ec );
ec.setCapInBuckets( PeriodDateMap.getInstance().getCopyOfHoursInBuckets() );
}
Vector tmpVec = (Vector) operEquipTable.get( rteID );
if( null == tmpVec ) {
tmpVec = new Vector();
operEquipTable.put( rteID, tmpVec );
}
tmpVec.add( ec );
aLine = d.readLine();
}
d.close();
super.closeURLConnection();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -