| 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(); | 
|     } | 
|   *] | 
| } |