排产系统
源代码在线查看: productreceipt.java
软件大小: |
4136 K |
上传用户: |
zhou28 |
|
|
关键词: |
|
下载地址: |
免注册下载 普通下载
|
|
package com.power.pipeengine.Report;
import java.util.*;
import java.io.*;
import java.text.*;
import com.power.pipeengine.Variable.*;
import com.power.pipeengine.Constraint.*;
import com.power.pipeengine.InputData.*;
import com.power.pipeengine.LPModel.*;
import com.power.pipeengine.Entity.*;
import com.power.pipeengine.*;
import com.power.pipe.*;
public class ProductReceipt extends Report
{
private static final ProductReceipt INSTANCE =
new ProductReceipt();
// Private constructor supresses
// default public constructor
private ProductReceipt( ) {
_fileName = "ProductReceipt";
//initFileWriter();
}
public static ProductReceipt getInstance( ) {
return INSTANCE;
}
private StringBuffer content = new StringBuffer();
public void createReport() throws IOException {
Vector invFacilities = DataModel.getInstance().getFacilities().getInvFacilities();
for( int i=0; i Facility f = (Facility) invFacilities.elementAt( i );
//System.out.println( "Facility = " + f.getDescription() );
Vector products = f.getProducts();
for( int j=0; j Product p = (Product) products.elementAt( j );
createReport( f, p );
}
}
//_myFileWriter.close();
super.flush( content.toString() );
content = null;
System.gc();
}
public void createReport( Facility f, Product p )
throws IOException
{
Vector buckets = DataModel.getInstance().getCalendar().getBuckets();
Vector producingRoutes = p.getProducingRoutes();
Vector sourcingRoutes = p.getSourcingRoutes();
ReceivingVariable rcvVar = ReceivingVariable.getInstance();
Solution sol = Solution.getInstance();
String separator = GlobalConfig.getInstance().getSeparator();
for( int i=0; i Bucket b = (Bucket) buckets.elementAt( i );
Bucket prevBucket = null;
//Products shipped in from other inventory points
//-- need to consider shipment delay time for "b"
Enumeration origFacilities = f.getOrignatingFacilities().elements();
while( origFacilities.hasMoreElements() ) {
Vector shipments = (Vector) origFacilities.nextElement();
for( int idx = 0; idx < shipments.size(); idx++ ) {
Shipment s = (Shipment) shipments.elementAt( idx );
if( EngineConfig.getInstance().getCollator().compare(
s.getToProduct().getProductID(),
p.getProductID() ) == 0 ) {
Bucket shipStartBucket = rcvVar.getShippingStartBucket( s, b );
if( shipStartBucket != null ) {
String var = rcvVar.getVariable( s.getFromFacility(),
f,
p,
b );
int value = (int) ( sol.getValue( var ) +
EngineConfig.getInstance().PRECISION );
if( value == 0 ) continue;
String lineOut = s.getFromFacilityID() + separator +
s.getFromProductID() + separator +
f.getFacilityID() + separator +
p.getProductID() + separator +
shipStartBucket.getBucketID() + separator +
b.getBucketID() + separator +
value + "\n";
content.append( lineOut );
}
}
}
}
}
}
public void reset() {
content = new StringBuffer();
}
}