Search in sources :

Example 1 with I_AD_Workflow

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);
}
Also used : I_AD_Workflow(org.compiere.model.I_AD_Workflow)

Example 2 with I_AD_Workflow

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);
}
Also used : MResource(org.compiere.model.MResource) I_AD_Workflow(org.compiere.model.I_AD_Workflow) I_C_UOM(org.compiere.model.I_C_UOM)

Example 3 with I_AD_Workflow

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);
    }
}
Also used : MResource(org.compiere.model.MResource) MUOM(org.compiere.model.MUOM) AdempiereException(org.adempiere.exceptions.AdempiereException) Properties(java.util.Properties) I_AD_Workflow(org.compiere.model.I_AD_Workflow) BigDecimal(java.math.BigDecimal) PO(org.compiere.model.PO)

Aggregations

I_AD_Workflow (org.compiere.model.I_AD_Workflow)3 MResource (org.compiere.model.MResource)2 BigDecimal (java.math.BigDecimal)1 Properties (java.util.Properties)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 I_C_UOM (org.compiere.model.I_C_UOM)1 MUOM (org.compiere.model.MUOM)1 PO (org.compiere.model.PO)1