| | |
| | | // 创建行 |
| | | 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, g.ToUpper() = "EVO5" or g.ToUpper() = "GEN3" ) { |
| | | traverse ( mqbmlbs, Elements, m, m.ToUpper() = "MLB" or m.ToUpper() = "MQB" ) { |
| | | traverse ( genrations, Elements, g ) { |
| | | traverse ( mqbmlbs, Elements, m ) { |
| | | macroPlan.CC_EngineRackRow( relnew, Generation := g, MLB_MQB := m ); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // 创建单元格 |
| | | traverse ( macroPlan, CC_EngineRackRow, ccerr ) { |
| | | |
| | | // 发动机成本参数 |
| | | lce := select( macroPlan, LogisticsCostEngine, tempLCE, tempLCE.Generation() = ccerr.Generation() and tempLCE.MLB_MQB() = ccerr.MLB_MQB() and tempLCE.Factory() = "长春工厂" ); |
| | | |
| | | // 料架成本参数 |
| | | lcmr := select( macroPlan, LogisticsCostMaterialRack, tempLCMR, tempLCMR.Factory() = "长春工厂" ); |
| | | |
| | | traverse ( macroPlan, CC_EngineRackColumn, ccerc ) { |
| | | traverse ( macroPlan, CC_EngineRackRow, ccerr ) { // 循环行 |
| | | info( "当前遍历的行:", ccerr.Generation(), " ", ccerr.MLB_MQB() ); |
| | | traverse ( macroPlan, CC_EngineRackColumn, ccerc ) { // 循环列 |
| | | // 发动机成本参数 |
| | | lce := select( macroPlan, LogisticsCostEngine, tempLCE, tempLCE.Generation() = ccerr.Generation() and tempLCE.MLB_MQB() = ccerr.MLB_MQB() and tempLCE.Factory() = "长春工厂" |
| | | and tempLCE.StartDate() <= ccerc.StartDate() and tempLCE.EndDate() >= ccerc.StartDate().StartOfNextMonth() ); |
| | | |
| | | // 料架成本参数 |
| | | lcmr := select( macroPlan, LogisticsCostMaterialRack, tempLCMR, tempLCMR.Factory() = "长春工厂" |
| | | and tempLCMR.StartDate() <= ccerc.StartDate() and tempLCMR.EndDate() >= ccerc.StartDate().StartOfNextMonth() ); |
| | | |
| | | // 运输成本参数 |
| | | lct := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = "发动机" and tempLCT.Origin() = "CC 厂内库" and tempLCT.Destination() = "长春外租库" ); |
| | | |
| | | // 当前月末最后一天日期 |
| | | lastDayOfThisMonth := ccerc.StartDate().StartOfNextMonth() - 1; |
| | | |
| | | cell := ccerr.CC_EngineRackCell( relnew ); |
| | | |
| | | // 空料架数量(长春厂该产品的料架总数量 - 发动机库存 / 包装容量 ) |
| | | lastDayOfThisMonth := ccerc.StartDate().StartOfNextMonth() - 1; |
| | | plannedInventory := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, tempPISPIP, |
| | | tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf() and |
| | | tempPISPIP.ProductInStockingPoint_MP().Product_MP().ParentID() = "产成品" and |
| | | tempPISPIP.ProductInStockingPoint_MP().StockingPointID() = "长春外租库" and |
| | | tempPISPIP.ProductInStockingPoint_MP().Product_MP().Generation() = ccerr.Generation() and |
| | | tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB() = ccerr.MLB_MQB() and |
| | | tempPISPIP.Start().Date() = lastDayOfThisMonth, |
| | | 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() = ccerr.Generation() and |
| | | tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB() = ccerr.MLB_MQB() and |
| | | tempPISPIP.Start().Date() = lastDayOfThisMonth, |
| | | tempPISPIP.PlannedInventoryLevelEnd() ); |
| | | cell.PackagingCapacity( guard( lce.PackagingCapacity(), 0 ) ); |
| | | cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) ); |
| | | cell.PlannedInventory( plannedInventory ); |
| | | |
| | | // 外租库入库费用(发动机销量 / 包装容量[向上取整] * 料架入库单价) |
| | | engineSales := sum( macroPlan, FSImportData, tempFSID, |
| | | tempFSID.Unit() = "长春工厂" and |
| | | tempFSID.Generation() = ccerr.Generation() and |
| | | tempFSID.MqbMlb() = ccerr.MLB_MQB() and |
| | | tempFSID.StartDate().Year() = ccerc.StartDate().Year() and |
| | | tempFSID.Unit() = FinancialProductionReport::GetDefaultCCUnit() and |
| | | tempFSID.Generation() = ccerr.Generation() and |
| | | tempFSID.MqbMlb() = ccerr.MLB_MQB() and |
| | | tempFSID.StartDate().Year() = ccerc.StartDate().Year() and |
| | | tempFSID.StartDate().Month() = ccerc.StartDate().Month(), |
| | | tempFSID.Quantity() ); |
| | | cell.StorageFeesForRentedWarehouses( guard( [Number] ( engineSales / guard( lce.PackagingCapacity(), 0 ) ) * guard( lcmr.WarehousingPrice(), 0 ), 0 ) ); |
| | | cell.StorageFeesForRentedWarehouses( [Number] ( engineSales / guard( lce.PackagingCapacity(), 1 ) * guard( lcmr.WarehousingPrice(), 1 ) ) ); |
| | | |
| | | // 外租库出库费用(发动机产量 / 包装容量[向上取整] * 料架出库单价) |
| | | engineProductions := sum( macroPlan, FPImportData, tempFPID, |
| | | tempFPID.Unit() = "长春工厂" and |
| | | tempFPID.Generation() = ccerr.Generation() and |
| | | tempFPID.MqbMlb() = ccerr.MLB_MQB() and |
| | | tempFPID.StartDate().Year() = ccerc.StartDate().Year() and |
| | | tempFPID.Unit() = FinancialProductionReport::GetDefaultCCUnit() and |
| | | tempFPID.Generation() = ccerr.Generation() and |
| | | tempFPID.MqbMlb() = ccerr.MLB_MQB() and |
| | | tempFPID.StartDate().Year() = ccerc.StartDate().Year() and |
| | | tempFPID.StartDate().Month() = ccerc.StartDate().Month(), |
| | | tempFPID.Quantity() ); |
| | | cell.OutboundExpensesForRentedWarehouses( guard( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 0 ) ) * guard( lcmr.OutboundPrice(), 0 ), 0 ) ); |
| | | cell.OutboundExpensesForRentedWarehouses( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 1 ) ) * guard( lcmr.OutboundPrice(), 1 ) ); |
| | | |
| | | // 外租库运输费用:发动机运输量 / 包装容量 / 装载容量(向上取整) * 料架运输单价 |
| | | |
| | | |
| | | transportationQuantity := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, |
| | | tempPIT.Product_MP().Generation() = ccerr.Generation() and |
| | | tempPIT.Product_MP().MQBMLB() = ccerr.MLB_MQB() and |
| | | tempPIT.Trip().Departure().Date() >= ccerc.StartDate() and |
| | | tempPIT.Trip().Arrival().Date() <= lastDayOfThisMonth and |
| | | tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID() = "CC 厂内库" and |
| | | tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = "长春外租库", |
| | | tempPIT.Quantity() |
| | | ); |
| | | cell.ExternalRentalWarehouseTransportationCosts( transportationQuantity / guard( lce.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) ); |
| | | |
| | | // 外租库仓储费用:料架总数量 - 发动机库存 / 包装容量(向上取整),再乘以空料架仓储单价得到空料架仓储费用。发动机库存取Actual inventories里取到长春外租库该发动机的仓储量,料架总数量需要手动维护。 |
| | | cell.UnitPriceOfEmptyShelfStorage( lcmr.StoragePrice() ); |
| | | |
| | | // 清洗费用:发动机入库量 / 包装容量 * 料架清洗单价。发动机入库量取发动机销量,包装容量取自发动机成本表。料架清洗单价取料架成本表。 |
| | | cell.CleaningCost( guard( engineSales / guard( lce.PackagingCapacity(), 0 ) * lcmr.CleanPrice(), 0 ) ); |
| | | cell.CleaningCost( engineSales / guard( lce.PackagingCapacity(), 1 ) * lcmr.CleanPrice() ); |
| | | |
| | | cell.CC_EngineRackColumn( relset, ccerc ); |
| | | } |