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() );
|
|
// 料架成本参数
|
lcmr := select( macroPlan, LogisticsCostMaterialRack, tempLCMR, tempLCMR.Factory() = "大连工厂"
|
and tempLCMR.StartDate() <= dlerc.StartDate() and tempLCMR.EndDate() >= dlerc.StartDate().StartOfNextMonth() );
|
|
// 运输成本参数
|
lct1 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "发动机料架" and tempLCT.Origin() = "大连发动机的长春外租库" and tempLCT.Destination() = "大连厂内库" );
|
lct2 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "发动机料架" and tempLCT.Origin() = "大连外租库" and tempLCT.Destination() = "大连厂内库" );
|
lct3 := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "发动机料架" and tempLCT.Origin() = "CC 客户库" and tempLCT.Destination() = "CC 外租库" );
|
|
// 当前月末最后一天日期
|
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() >= dlerc.StartDate() and
|
tempPISPIP.End().Date() <= lastDayOfThisMonth,
|
tempPISPIP.PlannedInventoryLevelEnd() );
|
cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
|
cell.PlannedInventory( plannedInventory );
|
|
// CC外租库入库费用:发动机销量 / 包装容量(向上取整)* 料架入库单价
|
transportationQuantity1 := sum( macroPlan, SalesDemand.astype( Forecast ), tempF,
|
tempF.Product_MP().Generation() = dlerr.Generation() and
|
tempF.Product_MP().MQBMLB() = dlerr.MLB_MQB() and
|
tempF.StockingPointID() = "大连发动机的长春外租库" and
|
tempF.StartDate() >= dlerc.StartDate() and
|
tempF.EndDate() <= lastDayOfThisMonth,
|
tempF.FulfilledQuantity() );
|
cell.CCStorageFeesForRentedWarehouses( [Number] ( guard( transportationQuantity1 / lce.PackagingCapacity(), 0 ) * lcmr.WarehousingPrice() ) );
|
|
// CC外租库出库费用:发动机销量 / 包装容量(向上取整)* 料架出库单价
|
cell.CCOutboundExpensesForRentedWarehouses( [Number] ( guard( transportationQuantity1 / lce.PackagingCapacity(), 0 ) * lcmr.OutboundPrice() ) );
|
|
// CC外租库仓储费用:料架总数量 - 发动机库存 / 包装容量(向上取整) * 料架仓储单价
|
cell.CCRentalWarehouseStorageFees( [Number] ( ( cell.TotalQuantityOfMaterialRacks() - guard( plannedInventory / lce.PackagingCapacity(), 0 ) ) * lcmr.StoragePrice() ) );
|
|
// CC长途运输费用:调拨数量 / 包装容量 / 装载容量 * 料架运输单价
|
transportationQuantity2 := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT,
|
tempPIT.Product_MP().Generation() = dlerr.Generation() and
|
tempPIT.Product_MP().MQBMLB() = dlerr.MLB_MQB() and
|
tempPIT.Trip().Departure().Date() >= dlerc.StartDate() and
|
tempPIT.Trip().Arrival().Date() <= lastDayOfThisMonth and
|
tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID() = "大连厂内库" and
|
tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "大连发动机的长春外租库",
|
tempPIT.Quantity()
|
);
|
|
cell.CCLineHaulCost( [Number] ( guard( transportationQuantity2 / lce.PackagingCapacity() / lct1.LoadingCapacity(), 0 ) * guard( lct1.TransportPrice(), 1 ) ) );
|
|
// CC短途运输费用:调拨数量 / 包装容量 / 装载容量 * 料架运输单价
|
cell.CCShortDistanceTransportationCosts( [Number] ( guard( transportationQuantity1 / lce.PackagingCapacity() / lct3.LoadingCapacity(), 0 ) * guard( lct3.TransportPrice(), 1 ) ) )
|
|
// DL外租库入库费用:发动机入库量 / 包装容量(向上取整)* 料架入库单价
|
inventoryQuantity := sum( macroPlan, SalesDemand.astype( Forecast ), tempF,
|
tempF.Product_MP().Generation() = dlerr.Generation() and
|
tempF.Product_MP().MQBMLB() = dlerr.MLB_MQB() and
|
tempF.StockingPointID() = "大连外租库" and
|
tempF.StartDate().Year() = dlerc.StartDate().Year() and
|
tempF.StartDate().Month() = dlerc.StartDate().Month(),
|
tempF.FulfilledQuantity() );
|
// info( "时间:", dlerc.StartDate().Format( "Y-M2-D2" ), " 入库数量:", inventoryQuantity, " 包装容量:", guard( lce.PackagingCapacity(), 0 ),
|
// " 装载容量:", guard( lct1.LoadingCapacity(), 0 ) ); // 测试输出
|
cell.DLStorageFeesForRentedWarehouses( [Number] ( guard( inventoryQuantity / lce.PackagingCapacity(), 0 ) * guard( lcmr.WarehousingPrice(), 1 ) ) );
|
|
// DL外租库出库费用:发动机出库量 / 料架容量(向上取整)* 料架出库单价
|
outboundQuantity := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), tempPISPIPPL,
|
tempPISPIPPL.ProductInStockingPoint_MP().Product_MP().Generation() = dlerr.Generation() and
|
tempPISPIPPL.ProductInStockingPoint_MP().Product_MP().MQBMLB() = dlerr.MLB_MQB() and
|
tempPISPIPPL.ProductInStockingPoint_MP().StockingPointID() = "大连外租库" and
|
tempPISPIPPL.Start().Date() >= dlerc.StartDate() and
|
tempPISPIPPL.End().Date() <= lastDayOfThisMonth,
|
tempPISPIPPL.NewSupplyQuantity() );
|
cell.DLOutboundExpensesForRentedWarehouses( [Number] ( guard( outboundQuantity / lce.PackagingCapacity(), 0 ) * guard( lcmr.OutboundPrice(), 1 ) ) );
|
|
// DL外租库运输费用:发动机运输量 / 包装容量 / 装载容量(向上取整)* 料架运输单价
|
cell.DLExternalRentalWarehouseTransportationCosts( [Number] ( guard( inventoryQuantity / lce.PackagingCapacity() / lct2.LoadingCapacity(), 0 ) * guard( lct2.TransportPrice(), 1 ) ) );
|
|
// DL外租库仓储费用:料架总数量 - 发动机库存 / 包装容量(向上取整)* 空料架仓储单价
|
plannedInventory1 := 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() >= dlerc.StartDate() and
|
tempPISPIP.End().Date() <= lastDayOfThisMonth,
|
tempPISPIP.PlannedInventoryLevelEnd() );
|
cell.DLRentalWarehouseStorageFees( [Number] ( guard( ( cell.TotalQuantityOfMaterialRacks() - plannedInventory1 ) / lce.PackagingCapacity(), 0 ) * guard( lcmr.StoragePrice(), 1 ) ) );
|
|
//清洗费用:发动机入库量 / 包装容量 * 料架清洗单价。发动机入库量取发动机销量,包装容量取自发动机成本表。料架清洗单价取料架成本表。
|
cell.CleaningCost( [Number] ( guard( inventoryQuantity / lce.PackagingCapacity(), 0 ) * guard( lcmr.CleanPrice(), 1 ) ) );
|
|
// 预计总费用
|
cell.EstimatedTotalCost( cell.CCStorageFeesForRentedWarehouses() + cell.CCOutboundExpensesForRentedWarehouses() + cell.CCRentalWarehouseStorageFees() + cell.CCLineHaulCost() +
|
cell.CCShortDistanceTransportationCosts() + cell.DLStorageFeesForRentedWarehouses() + cell.DLOutboundExpensesForRentedWarehouses() +
|
cell.DLExternalRentalWarehouseTransportationCosts() + cell.DLRentalWarehouseStorageFees() + cell.CleaningCost() );
|
|
// 系数
|
cell.Coefficient( 1.05 );
|
|
// 总费用
|
cell.TotalCost( cell.EstimatedTotalCost() * cell.Coefficient() );
|
|
cell.DL_EngineRackColumn( relset, dlerc );
|
}
|
}
|
*]
|
}
|