⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productionoutsschedule.java

📁 简介: 今天为网友提供的是JAVA源码
💻 JAVA
字号:
package com.power.pipeengine.Report;

import java.util.*;
import com.power.pipeengine.Variable.*;
import com.power.pipeengine.Constraint.*;
import com.power.pipeengine.InputData.*;
import com.power.pipeengine.DispatchReport.*;
import com.power.pipeengine.LPModel.*;
import com.power.pipeengine.Entity.*;
import com.power.pipeengine.*;
import com.power.pipe.*;

public class ProductionOutsSchedule extends Report
{
    private static final ProductionOutsSchedule INSTANCE =
                              new ProductionOutsSchedule();

   // Private constructor supresses
   // default public constructor
    private ProductionOutsSchedule( ) {
		_fileName = "ProductionOutsSchedule";
		//initFileWriter();
    }

    public static ProductionOutsSchedule getInstance( ) {
        return INSTANCE;
    }

    private StringBuffer content = new StringBuffer();

	public void createReport() throws Exception {
		DataModel dataModel = DataModel.getInstance();
		Vector buckets = dataModel.getCalendar().getBuckets();
		Routes routes = dataModel.getRoutes();
		StartsVariable startsVar = StartsVariable.getInstance();
		OutsVariable outsVar = OutsVariable.getInstance();
		Solution sol = Solution.getInstance();
		RouteProducts rteProds = dataModel.getRouteProducts();

		Enumeration allProds = rteProds.getProducts().elements();
		String separator = GlobalConfig.getInstance().getSeparator();
        Vector allOuts = new Vector();

		while( allProds.hasMoreElements() ) {
			Product p = (Product) allProds.nextElement();

            double decimal = 0.0;
            OutsSchedule lastSchedule = null;
			for( int i=0; i<buckets.size(); i++ ) {
				Bucket b = (Bucket) buckets.elementAt( i );
				String out = outsVar.getVariable( p, b );

				double outValue = sol.getValue( out );
				//skip if no outs
				if( outValue == 0 ) continue;

                OutsSchedule aSchedule = new OutsSchedule( b, p, outValue );
                allOuts.add( aSchedule );

                if( outValue != Math.floor( outValue ) ) {
                    decimal += outValue - Math.floor( outValue );
                    aSchedule.integrizeOuts();
                    if( lastSchedule == null ) {
                        lastSchedule = aSchedule;
                    }
                }

                if( decimal >= 1.0 ) {
                    decimal -= 1.0;
                    lastSchedule.augmentOuts();
                    lastSchedule = aSchedule;
                }


				/*String lineOut =    b.getBucketID() + separator +
									b.getFormatedDate() + separator +
									p.getProductID() + separator +
									p.getFacility().getDescription() + separator +
									outValue + "\n";

				content.append( lineOut );*/
			}

            if( decimal > 0.2 ) {
                lastSchedule.augmentOuts();
            }
		}

        for( int i=0; i<allOuts.size(); i++ ) {
            OutsSchedule aSchedule = (OutsSchedule) allOuts.elementAt( i );

            if( aSchedule.getOutsValue() == 0.0 ) continue;

            Bucket aBucket = aSchedule.getBucket();
            Product aProduct = aSchedule.getProduct();

            String lineOut = aBucket.getBucketID() + separator +
                             aBucket.getFormatedDate() + separator +
                             aProduct.getProductID() + separator +
                             aProduct.getFacility().getDescription() + separator +
                             ((int) aSchedule.getOutsValue() ) + "\n";
            content.append( lineOut );
        }

		//_myFileWriter.close();
		super.flush( content.toString() );
        content = null;
        System.gc();
	}

    public void reset() {
        content = new StringBuffer();
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -