From 5e5e6dea172b0b92ae397eeb0d9824ee9bda8b0c Mon Sep 17 00:00:00 2001
From: admin <admin@admin.com>
Date: 星期四, 17 十月 2024 11:14:25 +0800
Subject: [PATCH] 包装计划优化
---
_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl | 48 ++++++++++++
_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl | 174 +++++++++++++++++++++---------------------
2 files changed, 135 insertions(+), 87 deletions(-)
diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
index 0629582..78add67 100644
--- a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
@@ -6,93 +6,93 @@
{
TextBody:
[*
- //macroPlan.PackagingPlanRow( relflush );
- //macroPlan.PackagingPlanColumn( relflush );
- //
- //// 鍒涘缓璁″垝鍓嶄竴澶╁垪
- //planPre := macroPlan.PackagingPlanColumn( relnew, StartDate := macroPlan.StartOfPlanning().Date() - 1 );
- //
- //// 鐢熸垚鎶ヨ〃
- //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.Factory() = factory );
- // if ( isnull( ppr ) ) {
- // ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
- // }
- //
- // // 寰幆pispippl
- // traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) {
- // // 鍒涘缓鍒�
- // ppc := select( macroPlan, PackagingPlanColumn, tempPPC, tempPPC.StartDate() = pispipl.Start().Date() );
- // if ( isnull( ppc ) ) {
- // ppc := macroPlan.PackagingPlanColumn( relnew, StartDate := pispipl.Start().Date() );
- // }
- //
- // // 鍒涘缓鍗曞厓鏍�
- // cell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc );
- // if ( isnull( cell ) ) {
- // cell := ppr.PackagingPlanCell( relnew );
- // cell.NetDemand( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() );
- // cell.EndingInventory( pispipl.InventoryLevelEnd() );
- // cell.PackagingPlanColumn( relset, ppc );
- // } else {
- // cell.NetDemand( cell.NetDemand() + ( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() ) );
- // cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
- // }
- //
- // // 璁剧疆璋冨嚭
- // traverse ( pispipl, AsDeparturePISPIP, pit,
- // pit.Quantity() > 0 and
- // pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
- // TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
- // )
- // {
- // cell.Out( cell.Out() + pit.Quantity() );
- // }
- //
- // // 璁剧疆璋冭繘
- // traverse ( pispipl, AsArrivalPISPIP, pit,
- // pit.Quantity() > 0 and
- // pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
- // TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
- // )
- // {
- // cell.TransferIn( cell.TransferIn() + pit.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 ); // 鍓嶄竴涓猵ispippl
- // // 鍒涘缓璁″垝鍓嶄竴澶╂牸瀛�
- // 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( attribute( PackagingPlanRow, FactoryAbbreviation ) );
- //PackagingPlanCell::CalculationPackagingPlanProperties();
- //Transaction::Transaction().Propagate( relation( PackagingPlanCell, Next ) );
+ macroPlan.PackagingPlanRow( relflush );
+ macroPlan.PackagingPlanColumn( relflush );
+
+ // 鍒涘缓璁″垝鍓嶄竴澶╁垪
+ planPre := macroPlan.PackagingPlanColumn( relnew, StartDate := macroPlan.StartOfPlanning().Date() - 1 );
+
+ // 鐢熸垚鎶ヨ〃
+ 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.Factory() = factory );
+ if ( isnull( ppr ) ) {
+ ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
+ }
+
+ // 寰幆pispippl
+ traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) {
+ // 鍒涘缓鍒�
+ ppc := select( macroPlan, PackagingPlanColumn, tempPPC, tempPPC.StartDate() = pispipl.Start().Date() );
+ if ( isnull( ppc ) ) {
+ ppc := macroPlan.PackagingPlanColumn( relnew, StartDate := pispipl.Start().Date() );
+ }
+
+ // 鍒涘缓鍗曞厓鏍�
+ cell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc );
+ if ( isnull( cell ) ) {
+ cell := ppr.PackagingPlanCell( relnew );
+ cell.NetDemand( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() );
+ cell.EndingInventory( pispipl.InventoryLevelEnd() );
+ cell.PackagingPlanColumn( relset, ppc );
+ } else {
+ cell.NetDemand( cell.NetDemand() + ( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() ) );
+ cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
+ }
+
+ // 璁剧疆璋冨嚭
+ traverse ( pispipl, AsDeparturePISPIP, pit,
+ pit.Quantity() > 0 and
+ pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
+ TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
+ )
+ {
+ cell.Out( cell.Out() + pit.Quantity() );
+ }
+
+ // 璁剧疆璋冭繘
+ traverse ( pispipl, AsArrivalPISPIP, pit,
+ pit.Quantity() > 0 and
+ pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
+ TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
+ )
+ {
+ cell.TransferIn( cell.TransferIn() + pit.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 ); // 鍓嶄竴涓猵ispippl
+ // 鍒涘缓璁″垝鍓嶄竴澶╂牸瀛�
+ 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( attribute( PackagingPlanRow, FactoryAbbreviation ) );
+ PackagingPlanCell::CalculationPackagingPlanProperties();
+ Transaction::Transaction().Propagate( relation( PackagingPlanCell, Next ) );
// 璁剧疆鍖呰&鎷嗗寘-鏁伴噺
PackagingPlanCell::SetPackagingAndUnpackingValues( macroPlan );
diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl
index 83e5917..6bbd1c1 100644
--- a/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl
@@ -4,4 +4,52 @@
MacroPlan macroPlan
)
{
+ TextBody:
+ [*
+ // 璁剧疆鍖呰鍊硷紙绗﹀悎lotsize鍜屼竴鏃ユ渶澶у寘瑁呴噺锛�
+ traverse ( macroPlan, PackagingPlanRow, ppr, ppr.Factory() = "澶ц繛宸ュ巶" and ppr.ProductID() = "06K103011CM" ) {
+ traverse ( ppr, PackagingPlanCell, ppcell, ppcell.StartDate() <= Date::Construct( 2025, 1, 3 ) ) {
+ // Product_MP
+ pmp := select( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf() and tempPMP.ID() = ppr.ProductID() );
+ // 鍖呰lotsize
+ ppls := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() = ppr.Factory() and
+ tempPPLS.ProductID() = ifexpr( exists( macroPlan, PackagingPlanLotSize, tempPPLS1, tempPPLS1.ProductID() = pmp.ID() ),
+ pmp.ID(),
+ pmp.ParentID() ) );
+ // 涓�鏃ュ寘瑁呭閲�
+ ppnc := select( macroPlan, PackagingPlanNewCapability, tempPPNC, tempPPNC.Factory() = ppr.Factory() and
+ tempPPNC.ProductID() = ifexpr( exists( macroPlan, PackagingPlanNewCapability, tempPPNC1, tempPPNC1.ProductID() = pmp.ID() ),
+ pmp.ID(),
+ pmp.ParentID() ) );
+ // Unit
+ u := select( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) );
+
+ // 鍖呰搴撳瓨鍑虹幇璐熷�硷紝闇�瑕佽缃寘瑁呴噺
+ if ( ppcell.PackagingInventory() < 0 and not isnull( ppls ) and not isnull( ppnc ) ) {
+ // 闇�瑕佸寘瑁呯殑鏁伴噺
+ needPackagingQuantity := abs( ppcell.PackagingInventory() ).Round( 0 );
+ // 鍖呰寮�濮嬬殑绱㈠紩
+ indexPPCell := ppcell.Previous();
+
+ info( "浜х嚎鍚嶏細", u.ID(), " 寮�濮嬫椂闂达細", ppcell.StartDate().Format( "Y-M2-D2" ), " 鍖呰搴撳瓨鏁伴噺锛�", ppcell.PackagingInventory(), " 闇�瑕佸寘瑁呯殑鏁伴噺锛�", needPackagingQuantity,
+ " 鍖呰lotsize锛�",guard( ppls.LotSize(), 0 ), " 鏈�澶у寘瑁呭閲忥細", ppnc.MaximumDailyPackagingQuantity() );
+
+ while ( not isnull( indexPPCell ) and needPackagingQuantity > 0 ) {
+ // 鑳藉寘瑁呯殑鏁伴噺
+ canPackagingQuantity := ifexpr( ceil( needPackagingQuantity / ppls.LotSize() ) < floor( ppnc.MaximumDailyPackagingQuantity() / ppls.LotSize() ),
+ ceil( needPackagingQuantity / ppls.LotSize() ),
+ floor( ppnc.MaximumDailyPackagingQuantity() / ppls.LotSize() ) ) * ppls.LotSize();
+ info( "寮�濮嬪寘瑁呯殑鏃ユ湡锛�", indexPPCell.StartDate().Format( "Y-M2-D2" ), " 鑳藉寘瑁呯殑鏁伴噺:", canPackagingQuantity );
+
+ indexPPCell.Package( canPackagingQuantity );
+
+ needPackagingQuantity := needPackagingQuantity - canPackagingQuantity;
+ indexPPCell := indexPPCell.Previous();
+ }
+ }
+ }
+ }
+
+ // 璁剧疆鍖呰鍊硷紙绗﹀悎澶х被涓嬫墍鏈変骇鍝佸寘瑁呴噺鍔犲拰涓嶈兘澶т簬鏈�澶у寘瑁呴噺锛�
+ *]
}
--
Gitblit v1.9.3