lazhen
2024-10-10 ae3b7f21551deb0e163eb5dbd4bea0a70bd54c50
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
Quintiq file version 2.0
#parent: #root
StaticMethod CreateData (
  MacroPlan macroPlan
)
{
  TextBody:
  [*
    macroPlan.DL_EngineRackRow( relflush );
    macroPlan.DL_EngineRackColumn( relflush );
    
    // 创建行
    genrations := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.Generation().TrimBoth() <> "", tempPMP.Generation() );
    mqbmlbs    := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.MQBMLB().TrimBoth() <> "", tempPMP.MQBMLB() );
    traverse ( genrations, Elements, g ) {
      traverse ( mqbmlbs, Elements, m ) {
        macroPlan.DL_EngineRackRow( relnew, Generation := g, MLB_MQB := m );
      }
    }
    
    // 创建列
    indexDate := macroPlan.StartOfPlanning().Date().StartOfMonth();
    for ( i := 0; i < 12; i++ ) {
      macroPlan.DL_EngineRackColumn( relnew, StartDate := indexDate );
      indexDate := indexDate.StartOfNextMonth();
    }
    
    // 创建单元格
    traverse ( macroPlan, DL_EngineRackRow, dlerr ) { // 循环行
      info( "当前遍历的行:", dlerr.Generation(), " ", dlerr.MLB_MQB() );
      traverse ( macroPlan, DL_EngineRackColumn, dlerc ) { // 循环列
        // 发动机成本参数
        lce  := select( macroPlan, LogisticsCostEngine, tempLCE, tempLCE.Generation() = dlerr.Generation() and tempLCE.MLB_MQB() = dlerr.MLB_MQB() and tempLCE.Factory() = "大连工厂" 
                        and tempLCE.StartDate() <= dlerc.StartDate() and tempLCE.EndDate() >= dlerc.StartDate().StartOfNextMonth() );
        
        // 当前月末最后一天日期                
        lastDayOfThisMonth := dlerc.StartDate().StartOfNextMonth() - 1; 
        
        cell := dlerr.DL_EngineRackCell( relnew );
        
        // 空料架数量:大连厂该产品的料架总数量 - 发动机库存 / 包装容量(向上取整)
        plannedInventory := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, tempPISPIP,
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                                                                and
                                 exists( tempPISPIP.ProductInStockingPoint_MP().Product_MP(), AllParent.AsParent, tempPMP, tempPMP.ID() = "发动机" )         and
                                 tempPISPIP.ProductInStockingPoint_MP().StockingPointID()                                               = "大连外租库"       and
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().Generation()                                       = dlerr.Generation() and
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB()                                           = dlerr.MLB_MQB()    and
                                 tempPISPIP.Start().Date()                                                                              = lastDayOfThisMonth,
                                 tempPISPIP.PlannedInventoryLevelEnd() );
        cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
        cell.PlannedInventory( plannedInventory );
        
        // CC外租库入库费用:发动机销量 / 包装容量(向上取整)* 料架入库单价
        
        // CC外租库出库费用:发动机销量 / 包装容量(向上取整)* 料架出库单价
        
        cell.DL_EngineRackColumn( relset, dlerc );
      }
    }
  *]
}