admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Quintiq file version 2.0
#parent: #root
Method ZeroCapacityReplenishment (
  MacroPlan macroPlan,
  Real timeDifference,
  UnitPeriodTimeBase uptb,
  UnitPeriodTimeBases uptbs
)
{
  TextBody:
  [*
    debuginfo( "需要补零的时间(单位:小时)", timeDifference, "    需要补零的产能周期的开始时间:", uptb.StartDate().Format( "Y-M2-D2" ) );
        
    //debuginfo( "考虑库存、lotsize" );
    //traverse ( unitPeriodTimeBase, PeriodTaskOperation, pto, timeDifference > 0 ) { 
    //  minimumQuantityThatCanBeBorrowed := Real::MaxReal();
    //  minimumCapacityThatCanBeBorrowed := Real::MaxReal();
    //  traverse ( pto, NewSupply, ns, true ) {
    //    targetBorrowSplitShiftLotsizeLimit := select( scenarioManager, SplitShiftLotsizeLimit, tempSSLL, tempSSLL.unitID() = unitPeriodTimeBase.UnitID() and
    //                                                                                                     tempSSLL.productID() = ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().ProductID() and
    //                                                                                                     tempSSLL.startTime() <= ns.Start().Date() and
    //                                                                                                     tempSSLL.endTime() >= ns.End().Date() );
    //    minimumQuantityThatCanBeBorrowed := minvalue(
    //                                                  minvalue( ifexpr( not isnull( targetBorrowSplitShiftLotsizeLimit ) and targetBorrowSplitShiftLotsizeLimit.lotsize() < ns.Quantity(), 
    //                                                                    ns.Quantity() - targetBorrowSplitShiftLotsizeLimit.lotsize(), 
    //                                                                    Real::MaxReal() ),
    //                                                            minvalue( 
    //                                                                      ifexpr( ( ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel() ) > 0, 
    //                                                                                ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel(), 
    //                                                                                0.0 
    //                                                                             ), 
    //                                                                      ns.Quantity()    
    //                                                                     ) 
    //                                                           ),
    //                                                  minimumQuantityThatCanBeBorrowed 
    //                                                 );
    //  }
    //  minimumCapacityThatCanBeBorrowed := minimumQuantityThatCanBeBorrowed / pto.Operation().Throughput();
    //  nextUnitPeriodTimeBase := ifexpr( isnull( unitPeriodTimeBase.Next().astype( UnitPeriodTimeBase ) ), select( unitPeriodTimeBases, Elements, tempUPTB, tempUPTB.Start() = unitPeriodTimeBase.End() ), unitPeriodTimeBase.Next().astype( UnitPeriodTimeBase ) );
    //  while ( timeDifference > 0 and not isnull( nextUnitPeriodTimeBase ) and minimumCapacityThatCanBeBorrowed > 0 ) {
    //    acceptableCapacity := ifexpr( ( nextUnitPeriodTimeBase.TotalAvailableCapacity().HoursAsReal() - nextUnitPeriodTimeBase.UsedCapacity().HoursAsReal() ) > 0,
    //                                    nextUnitPeriodTimeBase.TotalAvailableCapacity().HoursAsReal() - nextUnitPeriodTimeBase.UsedCapacity().HoursAsReal(),
    //                                    0.0 );
    //    unifiedProcessingTimeOfComplementZero := minvalue( timeDifference, minimumCapacityThatCanBeBorrowed, acceptableCapacity );
    //    debuginfo( "接纳的周期时间:", nextUnitPeriodTimeBase.StartDate().Format( "Y-M2-D2" ), String::Tab(), 
    //               "接纳的周期能接受的产能:", acceptableCapacity, String::Tab(),
    //               "剩余补零的产能:", timeDifference, String::Tab(),
    //               "统一转移的产能:", unifiedProcessingTimeOfComplementZero, String::Tab()
    //              );
    //    this.A_unifiedProcessingOfComplementZeroLogic( unifiedProcessingTimeOfComplementZero, pto, nextUnitPeriodTimeBase, macroPlan );
    //    minimumCapacityThatCanBeBorrowed := minimumCapacityThatCanBeBorrowed - unifiedProcessingTimeOfComplementZero;
    //    timeDifference := timeDifference - unifiedProcessingTimeOfComplementZero;
    //    if ( isnull( nextUnitPeriodTimeBase.Next() ) ) {
    //      nextUnitPeriodTimeBase := select( unitPeriodTimeBases, Elements, tempUPTB, tempUPTB.Start() = nextUnitPeriodTimeBase.End() );
    //    } else {
    //      nextUnitPeriodTimeBase := nextUnitPeriodTimeBase.Next().astype( UnitPeriodTimeBase );
    //    }
    //  }
    //}
        
    debuginfo( "不考虑库存、lotsize使其达到整班" );
    traverse ( uptb, PeriodTaskOperation, pto, timeDifference > 0 ) { 
      minimumQuantityThatCanBeBorrowed := Real::MaxReal();
      minimumCapacityThatCanBeBorrowed := Real::MaxReal();
      traverse ( pto, NewSupply, ns, true ) {
        minimumQuantityThatCanBeBorrowed := minvalue( 
                                                      minvalue( 
                                                                ifexpr( ( ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel() ) > 0, 
                                                                          ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel(), 
                                                                          0.0 
                                                                       ), 
                                                                ns.Quantity()    
                                                               ), 
                                                      minimumQuantityThatCanBeBorrowed 
                                                     );
      }
      minimumCapacityThatCanBeBorrowed := minimumQuantityThatCanBeBorrowed / pto.Operation().Throughput();
      nextUnitPeriodTimeBase := ifexpr( isnull( uptb.Next().astype( UnitPeriodTimeBase ) ), select( uptbs, Elements, tempUPTB, tempUPTB.Start() = uptb.End() ), uptb.Next().astype( UnitPeriodTimeBase ) );
      while ( timeDifference > 0 and not isnull( nextUnitPeriodTimeBase ) and minimumCapacityThatCanBeBorrowed > 0 ) {
        acceptableCapacity := /*ifexpr( ( nextUnitPeriodTimeBase.TotalAvailableCapacity().HoursAsReal() - nextUnitPeriodTimeBase.UsedCapacity().HoursAsReal() ) > 0,
                                        nextUnitPeriodTimeBase.TotalAvailableCapacity().HoursAsReal() - nextUnitPeriodTimeBase.UsedCapacity().HoursAsReal(),
                                        0.0 )*/
                              ifexpr( nextUnitPeriodTimeBase.FreeCapacity().HoursAsReal() > 0,
                                      nextUnitPeriodTimeBase.FreeCapacity().HoursAsReal(),
                                      0.0 );
        unifiedProcessingTimeOfComplementZero := minvalue( timeDifference, minimumCapacityThatCanBeBorrowed, acceptableCapacity );
        debuginfo( "接纳的周期时间:", nextUnitPeriodTimeBase.StartDate().Format( "Y-M2-D2" ), String::Tab(), 
                   "接纳的周期能接受的产能:", acceptableCapacity, String::Tab(),
                   "剩余补零的产能:", timeDifference, String::Tab(),
                   "统一转移的产能:", unifiedProcessingTimeOfComplementZero, String::Tab()
                  );
        if ( unifiedProcessingTimeOfComplementZero > 0.0 ) {
          this.UnifiedProcessingOfComplementZeroLogic( unifiedProcessingTimeOfComplementZero, pto, nextUnitPeriodTimeBase, macroPlan );
        }
        minimumCapacityThatCanBeBorrowed := minimumCapacityThatCanBeBorrowed - unifiedProcessingTimeOfComplementZero;
        timeDifference := timeDifference - unifiedProcessingTimeOfComplementZero;
        if ( isnull( nextUnitPeriodTimeBase.Next() ) ) {
          nextUnitPeriodTimeBase := select( uptbs, Elements, tempUPTB, tempUPTB.Start() = nextUnitPeriodTimeBase.End() );
        } else {
          nextUnitPeriodTimeBase := nextUnitPeriodTimeBase.Next().astype( UnitPeriodTimeBase );
        }
      }
    }
  *]
}