admin
2024-09-23 65dfa3d300ec95e9531283d0a3fc07558c844078
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Quintiq file version 2.0
#parent: #root
StaticMethod CreateData (
  MacroPlan macroPlan,
  String factory
)
{
  TextBody:
  [*
    macroPlan.MachineLogisticsCostReportRow( relflush );
    macroPlan.MachineLogisticsCostReportColumn( relflush );
    
    // 初始化一年数据列
    indexDate := macroPlan.StartOfPlanning().Date().StartOfMonth();
    for ( i := 0; i < 12; i++ ) {
      macroPlan.MachineLogisticsCostReportColumn( relnew, StartDate := indexDate );
      indexDate := indexDate.StartOfNextMonth();
    }
    
    // 找出所有大类,创建数据
    categories := selectuniquevalues( macroPlan, PackagingPlanRow, tempPPR, true, tempPPR.Category() );
    
    traverse ( categories, Elements, c ) {
      
      // 机加成本参数
      lcm := select( macroPlan, LogisticsCostMachining, tempLCM, tempLCM.Factory() = factory and tempLCM.Product() = c );
      
      // 运输成本参数
      lct := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Origin()      = ifexpr( factory = "大连工厂", "CC", "DL" ) and
                                                                 tempLCT.Destination() = ifexpr( factory = "大连工厂", "DL", "CC" ) and
                                                                 tempLCT.Product()     = c );
       
      // 初始化机加成本参数报表行
      mlcrr := macroPlan.MachineLogisticsCostReportRow( relnew, Category := c, Factory := factory );
      
      // 循环所有时间列创建数据                                         
      traverse ( macroPlan, MachineLogisticsCostReportColumn, mlcrc ) {
        cell := mlcrr.MachineLogisticsCostReportCell( relnew );
        
        // 设置包装费用(包装量 * 包装单价)
        packageQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
                                tempPPC.PackagingPlanRow().Category()             = c                         and
                                tempPPC.PackagingPlanRow().Factory()              = factory                   and
                                tempPPC.PackagingPlanColumn().StartDate().Year()  = mlcrc.StartDate().Year()  and
                                tempPPC.PackagingPlanColumn().StartDate().Month() = mlcrc.StartDate().Month(),
                                tempPPC.Package() );
    //    cell.PackingCharges( packageQuantity * guard( lcm.PackagePrice(), 1 ) );
        
        // 设置拆包费用(拆包量 * 拆包单价)
        unpackingQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
                                  tempPPC.PackagingPlanRow().Category()             = c                         and
                                  tempPPC.PackagingPlanRow().Factory()              = factory                   and
                                  tempPPC.PackagingPlanColumn().StartDate().Year()  = mlcrc.StartDate().Year()  and
                                  tempPPC.PackagingPlanColumn().StartDate().Month() = mlcrc.StartDate().Month(),
                                  tempPPC.Unpacking() );
    //    cell.UnpackingCost( unpackingQuantity * guard( lcm.UnpackingPrice(), 1 ) );
        
        // 设置缓冲纸费用(包装类 * 缓冲纸单价)
    //    cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
        
        // 设置木箱单价
    //    cell.UnitPriceOfWoodenCrate( guard( lcm.WoodenCratePrice(), 1 ) );
        
        // 设置调拨费用(调拨数量 / 包装容量 / 装载容量 * 运输单价)
        transferQuantity := sum( macroPlan, TransferPlanRow.TransferPlanCell, tempTPC,
                                 tempTPC.TransferPlanRow().Category()              = c                                                      and
                                 tempTPC.TransferPlanRow().Name()                  = ifexpr( factory = "大连工厂", "CC to DL", "DL to CC" ) and
                                 tempTPC.TransferPlanColumn().ColumnDate().Year()  = mlcrc.StartDate().Year()                               and
                                 tempTPC.TransferPlanColumn().ColumnDate().Month() = mlcrc.StartDate().Month(),
                                 [Number]tempTPC.Value() );
    //    cell.TransferCost( transferQuantity / guard( lcm.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) );
        
        // 外租库入库费用(入库量[包装量] / 包装容量 * 入库单价)
    //    cell.StorageFeesForRentedWarehouses( packageQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.WarehousingPrice(), 1 ) );
        
        // 外租库出库费用(出库量[拆包量] / 包装容量 * 出库单价)
    //    cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
        
        // 外租库运输费用(运输数量 / 包装容量 / 装载容量 * 运输单价)
        
        cell.MachineLogisticsCostReportColumn( relset, mlcrc );
      }
    }
  *]
}