use of org.compiere.model.I_AD_Workflow in project adempiere by adempiere.
the class DefaultRoutingServiceImpl method calculateDuration.
/**
* Calculate node duration in DurationUnit UOM (see AD_Workflow.DurationUnit)
* @param node
* @param cc
* @reeturn duration
*/
protected BigDecimal calculateDuration(I_AD_WF_Node node, I_PP_Cost_Collector cc) {
if (node == null) {
node = cc.getPP_Order_Node().getAD_WF_Node();
}
final I_AD_Workflow workflow = node.getAD_Workflow();
final double batchSize = workflow.getQtyBatchSize().doubleValue();
final double setupTime;
final double duration;
if (cc != null) {
setupTime = cc.getSetupTimeReal().doubleValue();
duration = cc.getDurationReal().doubleValue();
} else {
setupTime = node.getSetupTime();
// Estimate total duration for 1 unit of final product as duration / units cycles
duration = estimateWorkingTime(node).doubleValue();
}
double totalDuration;
if (batchSize > 0)
totalDuration = ((setupTime / batchSize) + duration);
else
totalDuration = setupTime + duration;
return BigDecimal.valueOf(totalDuration);
}
use of org.compiere.model.I_AD_Workflow in project adempiere by adempiere.
the class DefaultRoutingServiceImpl method convertDurationToResourceUOM.
protected BigDecimal convertDurationToResourceUOM(BigDecimal duration, int S_Resource_ID, I_AD_WF_Node node) {
MResource resource = MResource.get(Env.getCtx(), S_Resource_ID);
I_AD_Workflow wf = MWorkflow.get(Env.getCtx(), node.getAD_Workflow_ID());
I_C_UOM resourceUOM = MUOM.get(Env.getCtx(), resource.getC_UOM_ID());
return convertDuration(duration, wf.getDurationUnit(), resourceUOM);
}
use of org.compiere.model.I_AD_Workflow in project adempiere by adempiere.
the class DefaultRoutingServiceImpl method getResourceBaseValue.
protected BigDecimal getResourceBaseValue(int S_Resource_ID, I_AD_WF_Node node, I_PP_Cost_Collector cc) {
if (node == null)
node = cc.getPP_Order_Node().getAD_WF_Node();
final Properties ctx = (node instanceof PO ? ((PO) node).getCtx() : Env.getCtx());
final MResource resource = MResource.get(ctx, S_Resource_ID);
final MUOM resourceUOM = MUOM.get(ctx, resource.getC_UOM_ID());
//
if (isTime(resourceUOM)) {
BigDecimal duration = calculateDuration(node, cc);
I_AD_Workflow wf = MWorkflow.get(ctx, node.getAD_Workflow_ID());
BigDecimal convertedDuration = convertDuration(duration, wf.getDurationUnit(), resourceUOM);
return convertedDuration;
} else {
throw new AdempiereException("@NotSupported@ @C_UOM_ID@ - " + resourceUOM);
}
}
Aggregations