| 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( "周出现异常" ); | 
|     } | 
|   *] | 
| } |