| 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 ); | 
|       } | 
|     } | 
|   *] | 
| } |