lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
Quintiq file version 2.0
#parent: #root
Method UnifiedProcessingOfComplementZeroLogic (
  Real unifiedProcessingTimeOfRounding,
  PeriodTaskOperation sourcePeriodTaskOperation,
  UnitPeriodTimeBase targetUnitPeriodTimeBase,
  MacroPlan macroPlan
)
{
  TextBody:
  [*
    targetPeriodTaskOperation := select( targetUnitPeriodTimeBase, PeriodTaskOperation, tempOTO, tempOTO.Operation() = sourcePeriodTaskOperation.Operation() );
        
    if ( isnull( targetPeriodTaskOperation ) ) {
      debuginfo( "目标产能周期不存在目标周期任务" );
      sourcePeriodTaskOperation.Update( sourcePeriodTaskOperation.Quantity() - ( sourcePeriodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding ), false );
      targetPeriodTaskOperation := PeriodTaskOperation::Create( sourcePeriodTaskOperation.Operation(), targetUnitPeriodTimeBase, sourcePeriodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding, false );
      Transaction::Transaction().Propagate();
          
    //  info( "新创建的周期任务有几个需求:", targetPeriodTaskOperation.DependentDemand( relsize ), "    周期任务ID为:", targetPeriodTaskOperation.Key().AsQUILL() );
      traverse ( targetPeriodTaskOperation, DependentDemand, dd, true ) {
        targetDependentDemand := select( sourcePeriodTaskOperation, DependentDemand, tempDD, tempDD.ProcessInput().astype( OperationInput ).Name() = dd.ProcessInput().astype( OperationInput ).Name() );
        targetTempDependentDemandInputGroup := select( macroPlan, TempDependentDemandInputGroup, tempTDDIG, tempTDDIG.ID() = guard( targetDependentDemand.Key().AsQUILL(), "" ) );
        if ( not isnull( targetTempDependentDemandInputGroup ) ) {
    //      info( "创建了依赖需求,ID为:", dd.Key().AsQUILL() );
          macroPlan.TempDependentDemandInputGroup( relnew, ID                    := dd.Key().AsQUILL(),
                                                           Divisor               := targetTempDependentDemandInputGroup.Divisor(),
                                                           UnitID                := targetTempDependentDemandInputGroup.UnitID(),
                                                           ProductInStockingName := targetTempDependentDemandInputGroup.ProductInStockingName() );
        }
      }
      Transaction::Transaction().Propagate();
    } else {
      debuginfo( "目标产能周期存在目标周期任务" );
      sourcePeriodTaskOperation.Update( sourcePeriodTaskOperation.Quantity() - ( sourcePeriodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding ), false );
      targetPeriodTaskOperation.Update( targetPeriodTaskOperation.Quantity() + ( targetPeriodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding ), false );
      Transaction::Transaction().Propagate();
    }
  *]
}