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
Quintiq file version 2.0
#parent: #root
Method ProcessingTimeIntervalIsGreaterThanOneDay (
  MacroPlan macroPlan,
  UnitPeriodTimeBase uptb,
  UnitPeriodTimeBases uptbs
)
{
  Description: '处理时间区间大于1天'
  TextBody:
  [*
    if ( uptb.UsedCapacity() = uptb.TotalAvailableCapacity() ) { 
      debuginfo( "周已经是整班,无需处理" );
    } else if ( uptb.UsedCapacity() < uptb.TotalAvailableCapacity() and uptb.UsedCapacity().HoursAsReal() > 0 ) {
      roundedCapacity             := 0.0;
      capacityForZeroCompensation := 0.0;
      indexStartTime              := uptb.StartDate();
      indexEndTime                := uptb.End().Date();
      remainingCapacity           := uptb.UsedCapacity().HoursAsReal();
      debuginfo( "使用的产能:", remainingCapacity );
      while ( indexStartTime < indexEndTime and roundedCapacity = 0 and capacityForZeroCompensation = 0 ) {
        indexStartTimeAvailableCapacity := WholeShift::GenerateDailyCapacity( macroPlan, indexStartTime, uptb.UnitID() ).HoursAsReal();
        if ( ( remainingCapacity - indexStartTimeAvailableCapacity ) < 0 ) {
          roundedCapacity := abs( remainingCapacity - indexStartTimeAvailableCapacity );
          capacityForZeroCompensation := remainingCapacity;
          remainingCapacity := remainingCapacity - indexStartTimeAvailableCapacity;
        } else {
          remainingCapacity := remainingCapacity - indexStartTimeAvailableCapacity;
        }
        debuginfo( "索引开始时间:", indexStartTime, "    可用产能:", indexStartTimeAvailableCapacity, "    使用的产能-可用产能(剩余产能):", remainingCapacity );
        indexStartTime := indexStartTime + 1;
      }
          
      debuginfo( "圆整产能:", roundedCapacity, "    补零产能:", capacityForZeroCompensation );
          
      if ( roundedCapacity = 0 and capacityForZeroCompensation = 0 ) {
        debuginfo( "已到达整班效果" );
      } else {
        whetherToFillInZero := true;
        tempCapacityForZeroCompensation := capacityForZeroCompensation;
        traverse ( uptb, PeriodTaskOperation, pto, whetherToFillInZero ) { 
          quantityOfMinimumSupplyRound := Real::MaxReal();
          traverse ( pto, NewSupply, ns, whetherToFillInZero ) {
            quantityOfMinimumSupplyRound := minvalue( minvalue( ifexpr( ( ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel() ) > 0, ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel(), 0.0 ), 
                                                                        ns.Quantity()    
                                                               ) / pto.Operation().Throughput(), 
                                                      quantityOfMinimumSupplyRound 
                                                     );
          }
          tempCapacityForZeroCompensation := tempCapacityForZeroCompensation - quantityOfMinimumSupplyRound;
          if ( tempCapacityForZeroCompensation  < 0 ) {
            whetherToFillInZero := false;
          }
          debuginfo( "当前周期任务供应数量:", pto.Quantity(), "    最小补零产能:", quantityOfMinimumSupplyRound, "    补零后还剩:", tempCapacityForZeroCompensation );
        }
        
        //    whetherToFillInZero := true;
        
        if ( not whetherToFillInZero ) {
          debuginfo( "执行补零" );
          this.ZeroCapacityReplenishment( macroPlan, capacityForZeroCompensation, uptb, uptbs ); 
        } else {
          debuginfo( "执行圆整" );
          this.CapacityRounding( macroPlan, roundedCapacity, uptb, uptbs );
        }
      }
    } else {
      debuginfo( "周出现异常" );
    }
  *]
}