📄 product.java
字号:
package com.power.pipeengine.Entity;
import java.util.*;
import java.text.*;
import com.power.pipeengine.InputData.*;
import com.power.pipeengine.*;
public class Product extends com.power.pipeengine.Entity.Entity
{
private String _productID = null;
private int _facilityID;
private Vector _producingRoutes = null;
private Vector _sourcingRoutes = null;
private Vector _demands = null;
private int _prodNumber;
public Product( String prodId, int facilityID ) {
_productID = prodId;
_facilityID = facilityID;
_producingRoutes = new Vector();
_sourcingRoutes = new Vector();
_demands = new Vector();
}
public String getKey() {
char[] key = new char[30];
String facility = new Integer( _facilityID ).toString();
int idx = 29;
for( int i=facility.length()-1; i>=0; i-- ) {
key[idx] = facility.charAt(i);
idx--;
}
idx = 24;
for( int i=_productID.length()-1; i>=0; i-- ) {
key[idx] = _productID.charAt(i);
idx--;
}
return new String( key );
}
public String getProductID() {
return _productID;
}
public int getFacilityID() {
return _facilityID;
}
public Facility getFacility() {
Facilities facilities = DataModel.getInstance().getFacilities();
return facilities.getFacility( _facilityID );
}
public void addProducingRoute( Route r ) {
_producingRoutes.addElement( r );
}
public Vector getProducingRoutes() {
return _producingRoutes;
}
public void addSourcingRoute( Route r ) {
_sourcingRoutes.addElement( r );
}
public Vector getSourcingRoutes() {
return _sourcingRoutes;
}
public void addDemand( ProductDemand prodDmd ) {
_demands.addElement( prodDmd );
}
public Vector getDemands() {
return _demands;
}
public double getDemand( int bucketID ) {
double dmd = 0.0;
for( int i=0; i<_demands.size(); i++ ) {
ProductDemand prodDmd = (ProductDemand) _demands.elementAt(i);
if( prodDmd.getBucketID() == bucketID ) {
dmd = prodDmd.getDmdQty();
break;
}
}
return dmd;
}
public double getASP( int bucketID ) {
for( int i=0; i<_demands.size(); i++ ) {
ProductDemand prodDmd = (ProductDemand) _demands.elementAt(i);
if( prodDmd.getBucketID() == bucketID ) {
return prodDmd.getASP();
}
}
return 0.0;
}
public boolean hasDemand() {
if( _demands.size() == 0 ) return false;
return true;
}
public boolean hasDemand( Bucket b ) {
for( int i=0; i<_demands.size(); i++ ) {
int bucket = ((ProductDemand) _demands.elementAt(i)).getBucketID();
if( bucket == b.getBucketID() ) {
return true;
}
}
return false;
}
public int getDemandPriority( Bucket b ) {
for( int i=0; i<_demands.size(); i++ ) {
int bucket = ((ProductDemand) _demands.elementAt(i)).getBucketID();
if( bucket == b.getBucketID() ) {
return ((ProductDemand) _demands.elementAt(i)).getPriority();
}
}
//No demand in the given bucket.
return 100;
}
public double getMaxCost() {
double maxCost = 0;
for( int i=0; i<_producingRoutes.size(); i++ ) {
Route rte = (Route) _producingRoutes.elementAt( i );
rte.print();
if( rte.getCostPerStart() > maxCost ) {
maxCost = rte.getCostPerStart();
}
}
InventoryCosts invCosts = DataModel.getInstance().getInventoryCosts();
maxCost += invCosts.getInventoryCost( _productID, _facilityID).getMaxHoldingCost();
return maxCost;
}
public int getFirstDemandPeriod() {
if( _demands.size() == 0 ) return -1;
int minT = ((ProductDemand) _demands.firstElement()).getBucketID();
for( int i=1; i<_demands.size(); i++ ) {
int bucket = ((ProductDemand) _demands.elementAt(i)).getBucketID();
if( bucket < minT ) {
minT = bucket;
}
}
return minT;
}
public boolean equals( Product p ) {
/*if( _facilityID == p.getFacilityID() &&
EngineConfig.getInstance().getCollator().compare(
_productID, p.getProductID() ) == 0 ) {
return true;
}*/
if( this._prodNumber == p.getProductNumber() ) {
return true;
}
return false;
}
public int getProductNumber() {
return _prodNumber;
}
public void print() {
System.out.println( _productID + "," +
_facilityID + ","
+ getVariableCode() );
}
public void setProdNumber( int anInt ) {
_prodNumber = anInt;
}
public int hashCode() {
return _prodNumber;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -