| | |
| | | planPre := macroPlan.PackagingPlanColumn( relnew, StartDate := macroPlan.StartOfPlanning().Date() - 1 ); |
| | | |
| | | // 生成报表 |
| | | traverse ( macroPlan, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() ) { |
| | | traverse ( macroPlan, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() and |
| | | ( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "DL" ) or pisp.StockingPointID().Regex( "大连" ) or pisp.StockingPointID().Regex( "长春" ) ) ) { |
| | | // 当前pisp所处地点 |
| | | factory := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "长春" ), "长春工厂", "大连工厂" ); |
| | | factoryAbbreviation := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "长春" ), "CC", "DL" ); |
| | | |
| | | // 创建行 |
| | | ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.StockingPointID() = pisp.StockingPointID() ); |
| | | ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.Factory() = factory ); |
| | | if ( isnull( ppr ) ) { |
| | | ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Factory := "大连工厂", Category := "ZKG" ); |
| | | ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) ); |
| | | } |
| | | |
| | | // 创建计划前一天格子 |
| | | planPreCell := ppr.PackagingPlanCell( relnew, PackagingPlanColumn := planPre, InitialPackagingInventory := 200 ); |
| | | |
| | | // 出发地库存点Trip |
| | | originTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID() = pisp.StockingPointID() ); |
| | | originTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and |
| | | TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) ); |
| | | // 目的地库存点Trip |
| | | destinationTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = pisp.StockingPointID() ); |
| | | destinationTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and |
| | | TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) ); |
| | | |
| | | // 循环pispippl |
| | | traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) { |
| | | // 创建列 |
| | | ppc := select( macroPlan, PackagingPlanColumn, tempPPC, tempPPC.StartDate() = pispipl.Start().Date() ); |
| | |
| | | // 创建单元格 |
| | | cell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc ); |
| | | if ( isnull( cell ) ) { |
| | | cell := ppr.PackagingPlanCell( relnew, NetDemand := pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity(), EndingInventory := pispipl.InventoryLevelEnd() ); |
| | | cell := ppr.PackagingPlanCell( relnew ); |
| | | cell.NetDemand( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() ); |
| | | cell.EndingInventory( pispipl.InventoryLevelEnd() ); |
| | | cell.PackagingPlanColumn( relset, ppc ); |
| | | } else { |
| | | cell.NetDemand( cell.NetDemand() + ( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() ) ); |
| | | cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() ); |
| | | } |
| | | |
| | | // 设置调出&调进 |
| | | // 设置调出 |
| | | outs := selectset( originTrips, Elements, tempT, tempT.Departure().Date() = pispipl.Start().Date() ); |
| | | traverse ( outs, Elements, out ) { |
| | | cell.Out( cell.Out() + out.Quantity() ); |
| | | traverse ( outs, Elements.ProductInTrip, outPIT, outPIT.ProductID() = pisp.ProductID() ) { |
| | | cell.Out( cell.Out() + outPIT.Quantity() ); |
| | | } |
| | | |
| | | // 设置调进 |
| | | transferIns := selectset( destinationTrips, Elements, tempT, tempT.Arrival().Date() = pispipl.Start().Date() ); |
| | | traverse ( transferIns, Elements, ti ) { |
| | | cell.TransferIn( cell.TransferIn() + ti.Quantity() ); |
| | | traverse ( transferIns, Elements.ProductInTrip, tiPIT, tiPIT.ProductID() = pisp.ProductID() ) { |
| | | cell.TransferIn( cell.TransferIn() + tiPIT.Quantity() ); |
| | | } |
| | | |
| | | // 长春工厂特殊情况设置包装库存和非包装库存 |
| | | if ( factory = "长春工厂" ) { |
| | | if ( pisp.StockingPointID().Regex( "外租库" ) ) { |
| | | cell.CC_PackagingInventory( pispipl.InventoryLevelEnd() ); |
| | | } else if ( pisp.StockingPointID().Regex( "线边库" ) ) { |
| | | cell.CC_UnpackagedInventory( pispipl.InventoryLevelEnd() ); |
| | | } |
| | | } |
| | | |
| | | // 设置前一天库存 |
| | | if ( pispipl.Start().Date() = macroPlan.StartOfPlanning().Date() ) { |
| | | // prePISPIPL := pispipl.PreviousPlanningPISPIP().astype( ProductInStockingPointInPeriodPlanningLeaf ); |
| | | planPreCell.EndingInventory( 2000 ); |
| | | prePISPIPL := pispipl.PreviousPlanningPISPIP().astype( ProductInStockingPointInPeriodPlanningLeaf ); // 前一个pispippl |
| | | // 创建计划前一天格子 |
| | | preCell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = planPre ); |
| | | if ( isnull( preCell ) ) { |
| | | preCell := ppr.PackagingPlanCell( relnew ); |
| | | preCell.EndingInventory( prePISPIPL.InventoryLevelEnd() ); |
| | | preCell.PackagingPlanColumn( relset, planPre ); |
| | | } else { |
| | | preCell.EndingInventory( preCell.EndingInventory() + prePISPIPL.InventoryLevelEnd() ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | Transaction::Transaction().Propagate( relation( PackagingPlanCell, Next ) ); |
| | | |
| | | // 设置包装&拆包-数量 |
| | | traverse ( macroPlan, PackagingPlanRow, ppr, ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Bosch" ) or ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Components (Spain)" ) ) { |
| | | traverse ( ppr, PackagingPlanCell, ppc/*, ppc.StartDate() = Date::Construct( 2020, 4, 1 )*/ ) { |
| | | // 设置包装数量 |
| | | if ( ppc.PackagingInventory() < ppc.Out() ) { // 包装库存是否小于调出 |
| | | prePPC := ppc.Previous(); |
| | | needPackagingQuantity := ppc.Out() - prePPC.PackagingInventory(); |
| | | while ( not isnull( prePPC ) and needPackagingQuantity > 0.0 ) { |
| | | // 获取包装lotsize |
| | | ppls := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() = ppc.PackagingPlanRow().Factory() and |
| | | tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() ); |
| | | |
| | | // 获取最大包装数量 |
| | | maxPackageReflection := Reflection::FindAttribute( "PackagingPlanCapability", ppc.PackagingPlanRow().FactoryAbbreviation() + "_" + ppc.PackagingPlanRow().Category() + "_Package" ); |
| | | maxPackageQuantity := maxPackageReflection.GetNumber( macroPlan.PackagingPlanCapability() ); |
| | | |
| | | // 获取最终包装数量 |
| | | finalPackagingQuantity := minvalue( ceil( needPackagingQuantity / ppls.LotSize() ), ceil( ( maxPackageQuantity - prePPC.Package() ) / ppls.LotSize() ) ) * ppls.LotSize(); |
| | | needPackagingQuantity := needPackagingQuantity - finalPackagingQuantity; |
| | | |
| | | // 设置包装值 |
| | | prePPC.Package( prePPC.Package() + finalPackagingQuantity ); |
| | | |
| | | //debuginfo( "需要包装数量:", needPackagingQuantity, " lotsize: ", ppls.LotSize(), " 最大包装数量:", maxPackageQuantity, " 最终补的数量:", finalPackagingQuantity ); |
| | | PackagingPlanCell::CalculationPackagingPlanProperties(); |
| | | |
| | | prePPC := prePPC.Previous(); |
| | | } |
| | | } |
| | | |
| | | // 设置拆包数量 |
| | | if ( ppc.TransferIn() > 0.0 ) { // 有调入数量 |
| | | // 获取包装lotsize |
| | | ppls := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() = ppc.PackagingPlanRow().Factory() and |
| | | tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() ); |
| | | |
| | | // 设置拆包值 |
| | | ppc.Unpacking( ppc.TransferIn() ); |
| | | } |
| | | } |
| | | } |
| | | //traverse ( macroPlan, PackagingPlanRow, ppr, ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Bosch" ) or ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Components (Spain)" ) ) { |
| | | // traverse ( ppr, PackagingPlanCell, ppc/*, ppc.StartDate() = Date::Construct( 2020, 4, 1 )*/ ) { |
| | | // // 设置包装数量 |
| | | // if ( ppc.PackagingInventory() < ppc.Out() ) { // 包装库存是否小于调出 |
| | | // prePPC := ppc.Previous(); |
| | | // needPackagingQuantity := ppc.Out() - prePPC.PackagingInventory(); |
| | | // while ( not isnull( prePPC ) and needPackagingQuantity > 0.0 ) { |
| | | // // 获取包装lotsize |
| | | // ppls := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() = ppc.PackagingPlanRow().Factory() and |
| | | // tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() ); |
| | | // |
| | | // // 获取最大包装数量 |
| | | // maxPackageReflection := Reflection::FindAttribute( "PackagingPlanCapability", ppc.PackagingPlanRow().FactoryAbbreviation() + "_" + ppc.PackagingPlanRow().Category() + "_Package" ); |
| | | //// maxPackageQuantity := maxPackageReflection.GetNumber( macroPlan.PackagingPlanCapability() ); // 此处需要修改 |
| | | // maxPackageQuantity := 100000; |
| | | // |
| | | // // 获取最终包装数量 |
| | | // finalPackagingQuantity := minvalue( ceil( needPackagingQuantity / ppls.LotSize() ), ceil( ( maxPackageQuantity - prePPC.Package() ) / ppls.LotSize() ) ) * ppls.LotSize(); |
| | | // needPackagingQuantity := needPackagingQuantity - finalPackagingQuantity; |
| | | // |
| | | // // 设置包装值 |
| | | // prePPC.Package( prePPC.Package() + finalPackagingQuantity ); |
| | | // |
| | | // //debuginfo( "需要包装数量:", needPackagingQuantity, " lotsize: ", ppls.LotSize(), " 最大包装数量:", maxPackageQuantity, " 最终补的数量:", finalPackagingQuantity ); |
| | | // PackagingPlanCell::CalculationPackagingPlanProperties(); |
| | | // |
| | | // prePPC := prePPC.Previous(); |
| | | // } |
| | | // } |
| | | // |
| | | // // 设置拆包数量 |
| | | // if ( ppc.TransferIn() > 0.0 ) { // 有调入数量 |
| | | // // 获取包装lotsize |
| | | // ppls := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() = ppc.PackagingPlanRow().Factory() and |
| | | // tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() ); |
| | | // |
| | | // // 设置拆包值 |
| | | // ppc.Unpacking( ppc.TransferIn() ); |
| | | // } |
| | | // } |
| | | //} |
| | | *] |
| | | } |