hongjli
2023-10-17 609d17f466b80466d7069871e54ec78542bcd991
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
Quintiq file version 2.0
#parent: #root
StaticMethod IterativeGeneration (
  GlobalOTDSOP globalOTDSOP,
  ProductInStockingPoint_MP pisp,
  Number numberOfLayers,
  NewSupply finaleNewSupply,
  Real finaleDependentDemand,
  Date targetDate
)
{
  TextBody:
  [*
    traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispippl, pispippl.Start().Date() = targetDate ) {
      traverse ( pispippl, NewSupply, ns, ns.Quantity() > 0 ) {
    //    info( "生成的产品:", pisp.ProductID(), "    产品在库存点:", pisp.Name(), "    层数:", numberOfLayers, "    总生产量:", ns.Quantity(), "    最终依赖物料数量:", finaleDependentDemand );
        if ( finaleDependentDemand < 0 ) {
          finaleDependentDemand := ns.Quantity();
        }
        if ( isnull( finaleNewSupply ) ) {
          finaleNewSupply := ns;
        }
        if ( guard( ns.PeriodTask_MP().astype( PeriodTaskOperation ).DependentDemand( relsize ) > 0, false ) ) {
          numberOfLayers++;
          traverse ( ns, PeriodTask_MP.astype( PeriodTaskOperation ).DependentDemand, dd ) {
            oo := ns.ProcessOutput().astype( OperationOutput );
            oi := dd.ProcessInput().astype( OperationInput );
            finaleDependentDemand := finaleDependentDemand * oo.Quantity() * oi.Quantity();
    //        info( "依赖需求产品ID:", dd.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().ProductID(), "    依赖数量:", dd.Quantity(), "    当前周期任务Key:", dd.PeriodTask_MP().astype( PeriodTaskOperation ).Key() );
            CapacityAllocationResults::IterativeGeneration( globalOTDSOP, dd.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP(), numberOfLayers, finaleNewSupply, finaleDependentDemand, targetDate );
          }
    //      info( "----------------------------------------------------" );
        } else {
    //      info( "无依赖需求,需要生成产能分配结果。。。" );
    //      info( "======" );
          pispPanel := ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP();
          pispModule := finaleNewSupply.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP();
          globalOTDSOP.CapacityAllocationResults( relnew,
                                                  PanelBase             := pispPanel.StockingPointID(),
                                                  PanelMaterialCode     := pispPanel.ProductID(),
                                                  NumberOfPanels        := finaleDependentDemand,
                                                  PanelMeasurementUnit  := pispPanel.UnitOfMeasure_MP().Name(),
                                                  ModuleMaterialCode    := pispModule.ProductID(),
                                                  NumberOfModules       := finaleNewSupply.Quantity(),
                                                  ModuleMeasurementUnit := pispModule.UnitOfMeasure_MP().Name(),
                                                  ModuleBase            := pispModule.StockingPointID(),
                                                  RequirementDate       := finaleNewSupply.Start().Date()
                                                 );
        }
        finaleNewSupply := null( NewSupply );
      }
      numberOfLayers := 1;
    }
  *]
}