Search in sources :

Example 1 with I_AD_WF_Node

use of org.compiere.model.I_AD_WF_Node in project adempiere by adempiere.

the class DefaultRoutingServiceImplTest method assertEstimateWorkingTime.

/**
	 * @see RoutingService#estimateWorkingTime(I_AD_WF_Node)
	 */
protected void assertEstimateWorkingTime(double expectedDuration, int duration, int unitsCycles) {
    // not relevant
    int qtyBatchSize = 1;
    // not relevant
    int setupTime = 0;
    // not relevant
    int overlapUnits = 0;
    MWorkflow wf = createWorkflow(qtyBatchSize);
    I_AD_WF_Node node = createNode(wf, "10", setupTime, duration, unitsCycles, overlapUnits);
    BigDecimal durationActual = routingService.estimateWorkingTime(node);
    assertEquals(expectedDuration, durationActual.doubleValue());
}
Also used : I_AD_WF_Node(org.compiere.model.I_AD_WF_Node) MWorkflow(org.compiere.wf.MWorkflow) BigDecimal(java.math.BigDecimal)

Example 2 with I_AD_WF_Node

use of org.compiere.model.I_AD_WF_Node in project adempiere by adempiere.

the class DefaultRoutingServiceImplTest method assertCalculateDuration.

/**
	 * @see RoutingService#calculateDuration(I_AD_WF_Node) 
	 */
protected void assertCalculateDuration(final double expectedDuration, int qtyBatchSize, int setupTime, int duration, int unitsCycles, int overlapUnits) {
    MWorkflow wf = createWorkflow(qtyBatchSize);
    I_AD_WF_Node node = createNode(wf, "10", setupTime, duration, unitsCycles, overlapUnits);
    BigDecimal actualDuration = routingService.calculateDuration(node);
    assertEquals(expectedDuration, actualDuration.doubleValue());
}
Also used : I_AD_WF_Node(org.compiere.model.I_AD_WF_Node) MWorkflow(org.compiere.wf.MWorkflow) BigDecimal(java.math.BigDecimal)

Example 3 with I_AD_WF_Node

use of org.compiere.model.I_AD_WF_Node in project adempiere by adempiere.

the class DefaultRoutingServiceImpl method calculateDuration.

public BigDecimal calculateDuration(I_AD_Workflow wf, I_S_Resource plant, BigDecimal qty) {
    if (plant == null)
        return Env.ZERO;
    final Properties ctx = ((PO) wf).getCtx();
    final MResourceType S_ResourceType = MResourceType.get(ctx, plant.getS_ResourceType_ID());
    BigDecimal AvailableDayTime = new BigDecimal(S_ResourceType.getTimeSlotHours());
    int AvailableDays = S_ResourceType.getAvailableDaysWeek();
    double durationBaseSec = getDurationBaseSec(wf.getDurationUnit());
    double durationTotal = 0.0;
    MWFNode[] nodes = ((MWorkflow) wf).getNodes(false, Env.getAD_Client_ID(ctx));
    for (I_AD_WF_Node node : nodes) {
        // Qty independent times:
        durationTotal += node.getQueuingTime();
        durationTotal += node.getSetupTime();
        durationTotal += node.getWaitingTime();
        durationTotal += node.getMovingTime();
        // Get OverlapUnits - number of units that must be completed before they are moved the next activity 
        double overlapUnits = qty.doubleValue();
        if (node.getOverlapUnits() > 0 && node.getOverlapUnits() < overlapUnits) {
            overlapUnits = node.getOverlapUnits();
        }
        double durationBeforeOverlap = node.getDuration() * overlapUnits;
        durationTotal += durationBeforeOverlap;
    }
    BigDecimal requiredTime = BigDecimal.valueOf(durationTotal * durationBaseSec / 60 / 60);
    // TODO: implement here, Victor's suggestion - https://sourceforge.net/forum/message.php?msg_id=5179460
    // Weekly Factor  	
    BigDecimal WeeklyFactor = new BigDecimal(7).divide(new BigDecimal(AvailableDays), 8, RoundingMode.UP);
    return (requiredTime.multiply(WeeklyFactor)).divide(AvailableDayTime, 0, RoundingMode.UP);
}
Also used : I_AD_WF_Node(org.compiere.model.I_AD_WF_Node) MWorkflow(org.compiere.wf.MWorkflow) MWFNode(org.compiere.wf.MWFNode) Properties(java.util.Properties) MResourceType(org.compiere.model.MResourceType) BigDecimal(java.math.BigDecimal) PO(org.compiere.model.PO)

Aggregations

BigDecimal (java.math.BigDecimal)3 I_AD_WF_Node (org.compiere.model.I_AD_WF_Node)3 MWorkflow (org.compiere.wf.MWorkflow)3 Properties (java.util.Properties)1 MResourceType (org.compiere.model.MResourceType)1 PO (org.compiere.model.PO)1 MWFNode (org.compiere.wf.MWFNode)1