Kevin Kok Khah Whey
2023-11-07 5ae534ab606e6f2ba5ea60914224d665b0447d5a
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Quintiq file version 2.0
#parent: #root
StaticMethod GenerateNewSupply (
  PeggingProductInSalesDemandBase peggingProductInSalesDemandBase,
  Number numberOfPlies,
  const NewSupply ns,
  Real actualFulfillmentQuantity,
  Real fulfillmentQuantity,
  PeggingResult parentPeggingResult
)
{
  TextBody:
  [*
    //info( "供应类型(NewSupply)", "    供应量:", ns.Quantity(), "    满足:", fulfillmentQuantity );
    
    pisp := ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP();
    
    childPeggingResult := PeggingResult::Create( peggingProductInSalesDemandBase, 
                                                 pisp.ProductID(), 
                                                 pisp.StockingPointID(), 
                                                 ns.Start().Date(), 
                                                 ns.Quantity(),
                                                 actualFulfillmentQuantity, 
                                                 fulfillmentQuantity, 
                                                 "", 
                                                 numberOfPlies, 
                                                 pisp.UnitOfMeasureName() );
    PeggingResult::SetParentChildRelationship( parentPeggingResult, childPeggingResult );
    
    ontype ( ns.PeriodTask_MP() ) {
      PeriodTaskOperation as pto : {
        childPeggingResult.SupplyType( "产线供应" );
    //    info( "操作周期任务    ", "供应时间:", ns.Start().Format( "Y-M2-D2" ), "    周期任务KEY:", pto.Key(), "    ",
    //          ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().Name() );
        traverse ( pto, DependentDemand, dd, dd.Quantity() > 0 ) {
          traverse ( dd, Fulfillment, f ) {
            fulfillmentQuantity := ( dd.Quantity() / ns.Quantity() ) * fulfillmentQuantity;
            totalSupply := sum( dd, Fulfillment, tempF, tempF.Quantity() );
            orderFulfillmentQuantity := ( f.Quantity() / totalSupply ) * fulfillmentQuantity;
            actualFulfillmentQuantity := f.Quantity();
            smp1 := f.Supply_MP();
            numberOfPlies++;
    //        info( "--------------------------------------------------------------" );
            PeggingResult::GeneratePeggingResult( peggingProductInSalesDemandBase, numberOfPlies, smp1, actualFulfillmentQuantity, orderFulfillmentQuantity, childPeggingResult );
            numberOfPlies--;
          }
        }
      }
           
      PeriodTaskLaneLeg as ptll : {
        childPeggingResult.SupplyType( "车道供应" );
        targetDependentDemand := select( ptll, DependentDemand, dd, 
                                         dd.ProcessInput().ProductInStockingPoint_MP().ProductID() = ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().ProductID() and
                                         dd.Quantity() = ns.Quantity() );
    //    info( "车道周期任务    ", "供应时间:", ns.Start().Format( "Y-M2-D2" ), "    周期任务KEY:", ptll.Key(), "    ", 
    //          ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().Name() );
        traverse ( targetDependentDemand, Fulfillment, f ) {
          totalSupply := sum( targetDependentDemand, Fulfillment, tempF, tempF.Quantity() );
          orderFulfillmentQuantity := ( f.Quantity() / totalSupply ) * fulfillmentQuantity;
          actualFulfillmentQuantity := f.Quantity();
          smp1 := f.Supply_MP();
          numberOfPlies++;
    //      info( "--------------------------------------------------------------" );
          PeggingResult::GeneratePeggingResult( peggingProductInSalesDemandBase, numberOfPlies, smp1, actualFulfillmentQuantity, orderFulfillmentQuantity, childPeggingResult );
          numberOfPlies--;
        }
      }
    }
  *]
}