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
Quintiq file version 2.0
#parent: #root
Method UnifiedProcessingOfRoundingLogic (
  Real unifiedProcessingTimeOfRounding,
  UnitPeriodTimeBase sourceUnitPeriodTimeBase,
  PeriodTaskOperation periodTaskOperation,
  MacroPlan macroPlan
)
{
  TextBody:
  [*
    sourcePeriodTaskOperation := select( sourceUnitPeriodTimeBase, PeriodTaskOperation, tempOTO, tempOTO.Operation() = periodTaskOperation.Operation() );
        
    if ( isnull( sourcePeriodTaskOperation ) ) {
      debuginfo( "源产能周期不存在目标周期任务" );
      periodTaskOperation.Update( periodTaskOperation.Quantity() - ( periodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding ), false );
      sourcePeriodTaskOperation := PeriodTaskOperation::Create( periodTaskOperation.Operation(), sourceUnitPeriodTimeBase, periodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding, false );
      Transaction::Transaction().Propagate();
          
    //  info( "新创建的周期任务有几个需求:", sourcePeriodTaskOperation.DependentDemand( relsize ), "    周期任务ID为:", sourcePeriodTaskOperation.Key().AsQUILL() );
      traverse ( sourcePeriodTaskOperation, DependentDemand, dd, true ) {
        targetDependentDemand := select( periodTaskOperation, 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( "源产能周期存在目标周期任务" );
      periodTaskOperation.Update( periodTaskOperation.Quantity() - ( periodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding ), false );
      sourcePeriodTaskOperation.Update( sourcePeriodTaskOperation.Quantity() + ( sourcePeriodTaskOperation.Operation().Throughput() * unifiedProcessingTimeOfRounding ), false );
      Transaction::Transaction().Propagate();
    }
  *]
}