RollupWorkflow:

* organized imports
* fixed indentation
This commit is contained in:
teo_sarca 2008-09-04 12:14:12 +00:00
parent f1c81b17b9
commit 0e6b5c6201
1 changed files with 156 additions and 150 deletions

View File

@ -16,16 +16,23 @@
package org.eevolution.process;
import java.util.logging.*;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.compiere.model.*;
import org.compiere.wf.*;
import org.compiere.util.*;
import org.compiere.process.*;
import org.compiere.model.MCost;
import org.compiere.model.MCostElement;
import org.compiere.model.MProduct;
import org.compiere.model.MResource;
import org.compiere.model.MUOM;
import org.compiere.model.Query;
import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.wf.MWFNode;
import org.compiere.wf.MWorkflow;
import org.eevolution.model.MPPProductPlanning;
/**
@ -87,21 +94,23 @@ public class RollupWorkflow extends SvrProcess
List<Object> params = new ArrayList<Object>();
params.add(getAD_Client_ID());
if (p_M_Product_ID > 0) {
whereClause.append(" AND p.M_Product_ID=?");
whereClause.append(" AND M_Product_ID=?");
params.add(p_M_Product_ID);
}
if (p_M_Product_Category_ID > 0){
whereClause.append(" AND p.M_Product_Category_ID=?");
params.add(p_M_Product_ID);
whereClause.append(" AND M_Product_Category_ID=?");
params.add(p_M_Product_Category_ID);
}
List<MProduct> products = new Query(getCtx(),MProduct.Table_Name, whereClause.toString(), get_TrxName())
.setOrderBy(MProduct.COLUMNNAME_LowLevel).setParameters(params).list();
.setOrderBy(MProduct.COLUMNNAME_LowLevel)
.setParameters(params)
.list();
for (MProduct product : products)
{
MCost[] costs = MCost.getCosts(getCtx() , getAD_Client_ID(), p_AD_Org_ID , product.getM_Product_ID() , p_M_CostType_ID , p_C_AcctSchema_ID , get_TrxName());
for (MCost cost : costs )
MCost[] costs = MCost.getCosts(getCtx(), getAD_Client_ID(), p_AD_Org_ID, product.getM_Product_ID(), p_M_CostType_ID, p_C_AcctSchema_ID , get_TrxName());
for (MCost cost : costs)
{
MCostElement element = new MCostElement(getCtx(), cost.getM_CostElement_ID(), get_TrxName());
// check if element cost is of type Labor
@ -144,14 +153,12 @@ public class RollupWorkflow extends SvrProcess
AD_Workflow_ID = pp.getAD_Workflow_ID();
else
AD_Workflow_ID = MWorkflow.getWorkflowSearchKey(getCtx(), product);
if(AD_Workflow_ID <= 0)
return Env.ZERO;
MWorkflow Workflow = new MWorkflow(getCtx(),AD_Workflow_ID,get_TrxName());
MWFNode[] nodes = Workflow.getNodes(false,getAD_Client_ID());
for (MWFNode node : nodes )
for (MWFNode node : nodes)
{
BigDecimal rate = getRate(CostElementType, node.getS_Resource_ID(), AD_Org_ID , C_AcctSchema_ID , M_CostType_ID);
String sql = "SELECT CASE WHEN ow.DurationUnit = 's' THEN 1 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'm' THEN 60 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'h' THEN 3600 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'Y' THEN 31536000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'M' THEN 2592000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'D' THEN 86400 * ((onode.SetupTime/ow.QtyBatchSize) + onode.Duration) END AS load FROM AD_WF_Node onode INNER JOIN AD_Workflow ow ON (ow.AD_Workflow_ID = onode.AD_Workflow_ID) WHERE onode.AD_WF_Node_ID = ? AND onode.AD_Client_ID = ?" ;
@ -160,7 +167,6 @@ public class RollupWorkflow extends SvrProcess
MUOM uom = MUOM.get(getCtx(), C_UOM_ID);
if (uom.isHour())
{
BigDecimal time = new BigDecimal(seconds);
cost = cost.add(time.multiply(rate).divide(new BigDecimal(3600),BigDecimal.ROUND_HALF_UP,12));
log.info("Yes isHour" + seconds);