From f7e27cb24f4cdbe6a25af74549867dbd49b1b401 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期四, 17 十月 2024 19:21:11 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl                                              |   56 ++++++-
 _Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_bRefresh_OnClick.def                   |    2 
 _Main/Sys/Repr/Global/MachineLogisticsCostReportCell.qrp                                                                     |   71 ++++++++++
 _Main/BL/Type_MachineLogisticsCostReportCell/Attribute_WoodenCratePriceReal.qbl                                              |    8 +
 _Main/UI/MacroPlannerWebApp/Views/NewAssemblyOnlinePlan.vw                                                                   |    4 
 _Main/BL/Type_PackagingPlanCell/StaticMethod_Package.qbl                                                                     |   61 ++++++++
 _Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnCreated.def              |   16 ++
 _Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnUserSelectionChanged.def |   16 ++
 /dev/null                                                                                                                    |   13 -
 _Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl                                                         |   21 ++
 _Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl                                                     |   78 +++++-----
 _Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/_ROOT_Component_ApplicationMacroPlanner.def                    |   11 +
 _Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/_ROOT_Component_FormMachineLogisticsCostReport.def      |    1 
 _Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_dhSelectedFactoryMCRR_OnCreated.def      |   16 ++
 _Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw                                                                          |    4 
 15 files changed, 311 insertions(+), 67 deletions(-)

diff --git a/_Main/BL/Type_MachineLogisticsCostReportCell/Attribute_WoodenCratePriceReal.qbl b/_Main/BL/Type_MachineLogisticsCostReportCell/Attribute_WoodenCratePriceReal.qbl
new file mode 100644
index 0000000..ebc9df7
--- /dev/null
+++ b/_Main/BL/Type_MachineLogisticsCostReportCell/Attribute_WoodenCratePriceReal.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute WoodenCratePriceReal
+{
+  #keys: '3[415754.0.434001070][415754.0.434001069][415754.0.434001071]'
+  Description: '鏈ㄧ鍗曚环锛圧eal锛�'
+  ValueType: Real
+}
diff --git a/_Main/BL/Type_MachineLogisticsCostReportCell/Function_CalcWoodenCrateCost.qbl b/_Main/BL/Type_MachineLogisticsCostReportCell/Function_CalcWoodenCrateCost.qbl
deleted file mode 100644
index b31a8d5..0000000
--- a/_Main/BL/Type_MachineLogisticsCostReportCell/Function_CalcWoodenCrateCost.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcWoodenCrateCost
-{
-  TextBody:
-  [*
-    // lihongji Aug-7-2024 (created)
-    
-    value := guard( this.QuantityOfWoodenCrates() * this.UnitPriceOfWoodenCrate(), 0.0 );
-    
-    this.WoodenCrateCost( value );
-  *]
-}
diff --git a/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
index 038ccac..a347a1c 100644
--- a/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
@@ -10,72 +10,76 @@
     macroPlan.MachineLogisticsCostReportRow( relflush );
     macroPlan.MachineLogisticsCostReportColumn( relflush );
     
-    // 鍒濆鍖栦竴骞存暟鎹垪
+    // 鍒涘缓琛�
+    categories := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf()                           and
+                                      exists( tempPMP, AllParent.AsParent, tempPMP1, tempPMP1.ID() = "鏈哄姞浠�" ),  
+                                      tempPMP.ParentID() );
+    traverse ( categories, Elements, c ) {
+      macroPlan.MachineLogisticsCostReportRow( relnew, Factory := "澶ц繛宸ュ巶", Category := c  );
+      macroPlan.MachineLogisticsCostReportRow( relnew, Factory := "闀挎槬宸ュ巶", Category := c );
+    }
+    
+    // 鍒涘缓鍒�
     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 ) {
+    // 鍒涘缓鍗曞厓鏍�
+    traverse ( macroPlan, MachineLogisticsCostReportRow, mlcrr ) { // 寰幆琛�
+      info( "褰撳墠閬嶅巻鐨勮锛�", mlcrr.Factory(), " ", mlcrr.Category() );
+      traverse ( macroPlan, MachineLogisticsCostReportColumn, mlcrc ) { // 寰幆鍒�
       
-      // 鏈哄姞鎴愭湰鍙傛暟
-      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 );
+        // 鏈哄姞鎴愭湰鍙傛暟
+        lcm  := select( macroPlan, LogisticsCostMachining, tempLCM, tempLCM.Factory() = mlcrr.Factory() and tempLCM.Product() = mlcrr.Category()
+                        and tempLCM.StartDate() <= mlcrc.StartDate() and tempLCM.EndDate() >= mlcrc.StartDate().StartOfNextMonth() );
         
+        // 杩愯緭鎴愭湰鍙傛暟
+        lct  := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Product() = mlcrr.Category() and 
+                        tempLCT.Origin() = "闀挎槬澶栫搴�" and tempLCT.Destination() = "CC 鍘傚唴搴�" );
+        
+        cell := mlcrr.MachineLogisticsCostReportCell( relnew );
+          
         // 璁剧疆鍖呰璐圭敤锛堝寘瑁呴噺 * 鍖呰鍗曚环锛�
         packageQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
-                                tempPPC.PackagingPlanRow().Category()             = c                         and
+                                tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          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 ) );
-        
+        cell.PackingCharges( packageQuantity * guard( lcm.PackagePrice(), 1 ) );
+          
         // 璁剧疆鎷嗗寘璐圭敤锛堟媶鍖呴噺 * 鎷嗗寘鍗曚环锛�
         unpackingQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
-                                  tempPPC.PackagingPlanRow().Category()             = c                         and
+                                  tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          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.UnpackingCost( unpackingQuantity * guard( lcm.UnpackingPrice(), 1 ) );
+          
         // 璁剧疆缂撳啿绾歌垂鐢紙鍖呰绫� * 缂撳啿绾稿崟浠凤級
-    //    cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
-        
-        // 璁剧疆鏈ㄧ鍗曚环
-    //    cell.UnitPriceOfWoodenCrate( guard( lcm.WoodenCratePrice(), 1 ) );
-        
+        cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
+          
+          // 璁剧疆鏈ㄧ鍗曚环
+        cell.WoodenCratePriceReal( guard( lcm.WoodenCratePrice(), 1 ) );
+          
         // 璁剧疆璋冩嫧璐圭敤锛堣皟鎷ㄦ暟閲� / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 杩愯緭鍗曚环锛�
         transferQuantity := sum( macroPlan, TransferPlanRow.TransferPlanCell, tempTPC,
-                                 tempTPC.TransferPlanRow().Category()              = c                                                      and
+                                 tempTPC.TransferPlanRow().Category()              = mlcrr.Category()                                       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.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.StorageFeesForRentedWarehouses( packageQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.WarehousingPrice(), 1 ) );
+          
         // 澶栫搴撳嚭搴撹垂鐢紙鍑哄簱閲廩鎷嗗寘閲廬 / 鍖呰瀹归噺 * 鍑哄簱鍗曚环锛�
-    //    cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
-        
+      //  cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
+          
         // 澶栫搴撹繍杈撹垂鐢紙杩愯緭鏁伴噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺 * 杩愯緭鍗曚环锛�
         
         cell.MachineLogisticsCostReportColumn( relset, mlcrc );
diff --git a/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl b/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl
index fad645a..b4505ca 100644
--- a/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl
+++ b/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl
@@ -61,7 +61,7 @@
                                );
       
       u           := select( macroPlan, Unit, tempU, tempU.ID() = pl );
-      drainPs     := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "鎷夌┖" ), false ) );
+      drainPs     := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "鎷夌┖" ) or tempP.Event().Subject().Regex( "鎺掔┖" ), false ) );
       lineLyingPs := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "閾虹嚎" ), false ) );
       
       // 澶勭悊鎷夌┖
@@ -69,13 +69,24 @@
       traverse ( drainPs, Elements, p ) {
         traverse ( p, ExplicitTimeInterval, eti ) {
     //      info( "寮�濮嬫椂闂达細", eti.Start().Format( "Y-M2-D2" ), "    缁撴潫鏃堕棿锛�", eti.End().Format( "Y-M2-D2" ) );
+          naopc := select( macroPlan, NewAssemblyOnlinePlanColumn, tempNAOPC, tempNAOPC.StartDate() = ( eti.Start().Date() - 1 ) );
           
           cell  := maxselect( macroPlan, NewAssemblyOnlinePlanRow.NewAssemblyOnlinePlanCell, tempNAOPCell, 
-                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl                         and 
-                              tempNAOPCell.NewAssemblyOnlinePlanColumn().StartDate()   = ( eti.Start().Date() - 1 ) and
-                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1",
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl    and 
+                              tempNAOPCell.NewAssemblyOnlinePlanColumn()               = naopc and
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1"   and
+                              tempNAOPCell.Quantity()                                  > 0,
                               tempNAOPCell.OrderNr() ); 
-          
+          while ( isnull( cell ) and not isnull( naopc ) ){
+            naopc := naopc.PreviousNAOPColumn();
+            
+            cell  := maxselect( macroPlan, NewAssemblyOnlinePlanRow.NewAssemblyOnlinePlanCell, tempNAOPCell, 
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl    and 
+                              tempNAOPCell.NewAssemblyOnlinePlanColumn()               = naopc and
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1"   and
+                              tempNAOPCell.Quantity()                                  > 0,
+                              tempNAOPCell.OrderNr() );
+          }
           if ( not isnull( cell ) ) {
             cell.Quantity( cell.Quantity() - targetQuantity );
           }
diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_Package.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_Package.qbl
new file mode 100644
index 0000000..7e0d597
--- /dev/null
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_Package.qbl
@@ -0,0 +1,61 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod Package (
+  MacroPlan macroPlan,
+  PackagingPlanRow ppr,
+  PackagingPlanColumn ppc,
+  output Number needPackagingQuantity
+)
+{
+  TextBody:
+  [*
+    // 璁″垝寮�濮嬫椂闂�
+    plannedStartDate := macroPlan.StartOfPlanning().Date();
+    
+    traverse ( ppr, PackagingPlanCell, ppcell, ppcell.PackagingPlanColumn() = ppc ) {
+      // 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
+      us                      := selectset( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) );
+       
+      // 鍖呰搴撳瓨鍑虹幇璐熷�硷紝闇�瑕佽缃寘瑁呴噺
+      if ( not isnull( ppls ) and not isnull( ppnc ) ) {
+        // 鍖呰寮�濮嬬殑绱㈠紩
+        indexPPCell           := ppcell.Previous();
+        
+    //      info( "浜х嚎涓暟锛�", us.Size(), "    寮�濮嬫椂闂达細", ppcell.StartDate().Format( "Y-M2-D2" ), "    鍖呰搴撳瓨鏁伴噺锛�", ppcell.PackagingInventory(), "    闇�瑕佸寘瑁呯殑鏁伴噺锛�", needPackagingQuantity, 
+    //            "    鍖呰lotsize锛�",guard( ppls.LotSize(), 0 ), "    鏈�澶у寘瑁呭閲忥細", ppnc.MaximumDailyPackagingQuantity() );
+          
+        while ( not isnull( indexPPCell )                                                   and 
+                indexPPCell.StartDate() >= plannedStartDate                                 and 
+                exists( us, Elements.UnitPeriod.astype( UnitPeriodTime ).ShiftPlan, tempSP, 
+                        tempSP.UnitPeriodTime().StartDate() = indexPPCell.StartDate(),
+                        tempSP.Outcome() <> "" )                                            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 );
+          Transaction::Transaction().Propagate( attribute( PackagingPlanCell, PackagingInventory ) );
+          Transaction::Transaction().Propagate( attribute( PackagingPlanCell, UnpackagedInventory ) );
+            
+          needPackagingQuantity := needPackagingQuantity - canPackagingQuantity;
+          indexPPCell           := indexPPCell.Previous();
+        }
+      }
+    }
+  *]
+}
diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl
index 6bbd1c1..72ed702 100644
--- a/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_SetPackagingAndUnpackingValues.qbl
@@ -6,9 +6,12 @@
 {
   TextBody:
   [*
+    // 璁″垝寮�濮嬫椂闂�
+    plannedStartDate := macroPlan.StartOfPlanning().Date();
+    
     // 璁剧疆鍖呰鍊硷紙绗﹀悎lotsize鍜屼竴鏃ユ渶澶у寘瑁呴噺锛�
-    traverse ( macroPlan, PackagingPlanRow, ppr, ppr.Factory() = "澶ц繛宸ュ巶" and ppr.ProductID() = "06K103011CM" ) {
-      traverse ( ppr, PackagingPlanCell, ppcell, ppcell.StartDate() <= Date::Construct( 2025, 1, 3 ) ) {
+    traverse ( macroPlan, PackagingPlanRow, ppr/*, ppr.Factory() = "澶ц繛宸ュ巶" and ppr.ProductID() = "06K103011CM"*/ ) {
+      traverse ( ppr, PackagingPlanCell, ppcell/*, ppcell.StartDate() <= Date::Construct( 2025, 1, 4 )*/ ) {
         // Product_MP
         pmp                     := select( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf() and tempPMP.ID() = ppr.ProductID() );
         // 鍖呰lotsize
@@ -22,7 +25,7 @@
                                                                           pmp.ID(),
                                                                           pmp.ParentID() ) );
         // Unit
-        u                       := select( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) );
+        us                      := selectset( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) );
          
         // 鍖呰搴撳瓨鍑虹幇璐熷�硷紝闇�瑕佽缃寘瑁呴噺
         if ( ppcell.PackagingInventory() < 0 and not isnull( ppls ) and not isnull( ppnc ) ) {
@@ -31,17 +34,24 @@
           // 鍖呰寮�濮嬬殑绱㈠紩
           indexPPCell           := ppcell.Previous();
           
-          info( "浜х嚎鍚嶏細", u.ID(), "    寮�濮嬫椂闂达細", ppcell.StartDate().Format( "Y-M2-D2" ), "    鍖呰搴撳瓨鏁伴噺锛�", ppcell.PackagingInventory(), "    闇�瑕佸寘瑁呯殑鏁伴噺锛�", needPackagingQuantity, 
-                "    鍖呰lotsize锛�",guard( ppls.LotSize(), 0 ), "    鏈�澶у寘瑁呭閲忥細", ppnc.MaximumDailyPackagingQuantity() );
+    //      info( "浜х嚎涓暟锛�", us.Size(), "    寮�濮嬫椂闂达細", ppcell.StartDate().Format( "Y-M2-D2" ), "    鍖呰搴撳瓨鏁伴噺锛�", ppcell.PackagingInventory(), "    闇�瑕佸寘瑁呯殑鏁伴噺锛�", needPackagingQuantity, 
+    //            "    鍖呰lotsize锛�",guard( ppls.LotSize(), 0 ), "    鏈�澶у寘瑁呭閲忥細", ppnc.MaximumDailyPackagingQuantity() );
           
-          while ( not isnull( indexPPCell ) and needPackagingQuantity > 0 ) {
+          while ( not isnull( indexPPCell )                                                   and 
+                  indexPPCell.StartDate() >= plannedStartDate                                 and 
+                  exists( us, Elements.UnitPeriod.astype( UnitPeriodTime ).ShiftPlan, tempSP, 
+                          tempSP.UnitPeriodTime().StartDate() = indexPPCell.StartDate(),
+                          tempSP.Outcome() <> "" )                                            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 );
+    //        info( "寮�濮嬪寘瑁呯殑鏃ユ湡锛�", indexPPCell.StartDate().Format( "Y-M2-D2" ), "    鑳藉寘瑁呯殑鏁伴噺:", canPackagingQuantity );
             
             indexPPCell.Package( canPackagingQuantity );
+            Transaction::Transaction().Propagate( attribute( PackagingPlanCell, PackagingInventory ) );
+            Transaction::Transaction().Propagate( attribute( PackagingPlanCell, UnpackagedInventory ) );
             
             needPackagingQuantity := needPackagingQuantity - canPackagingQuantity;
             indexPPCell           := indexPPCell.Previous();
@@ -50,6 +60,36 @@
       }
     }
     
-    // 璁剧疆鍖呰鍊硷紙绗﹀悎澶х被涓嬫墍鏈変骇鍝佸寘瑁呴噺鍔犲拰涓嶈兘澶т簬鏈�澶у寘瑁呴噺锛�
+    // 璁剧疆鍖呰鍊硷紙绗﹀悎澶х被涓嬫墍鏈変骇鍝侀潪鍖呰閲忓簱瀛樺姞鍜屼笉鑳藉ぇ浜庣郴缁熷�硷級
+    factorys               := selectuniquevalues( macroPlan, PackagingPlanRow, tempPPR, true, tempPPR.FactoryAbbreviation() );
+    categorys              := selectuniquevalues( macroPlan, PackagingPlanRow, tempPPR, true, tempPPR.Category() );
+    traverse ( factorys, Elements, f/*, f = "DL"*/ ) {
+      traverse ( categorys, Elements, c/*, c = "ZKG"*/ ) {
+        // 绯荤粺瑙勫畾鐨勬渶澶ч潪鍖呰搴撳瓨鏁伴噺
+        ppmqReflection     := Reflection::FindAttribute( "PackagingPlanMaximumQuantity", f + "_" + c );
+        maxPackageQuantity := guard( ppmqReflection.GetNumber( macroPlan.PackagingPlanMaximumQuantity() ), 0 );
+        // 褰撳墠宸ュ巶涓嬩竴绫讳骇鍝佽
+        pprs               := selectset( macroPlan, PackagingPlanRow, tempPPR, tempPPR.FactoryAbbreviation() = f and tempPPR.Category() = c );
+         
+    //    info( "褰撳墠宸ュ巶锛�", f, "    褰撳墠澶х被锛�", c, "    澶х被涓嬬殑鏈�澶у寘瑁呮暟閲忥細", maxPackageQuantity );
+        traverse ( macroPlan, PackagingPlanColumn, ppc, ppc.StartDate() > plannedStartDate and maxPackageQuantity > 0 ) {
+          sumUnpackagedInventoryQuantity := sum( pprs, Elements.PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc, tempPPCell.UnpackagedInventory() ).Round( 0 );
+          
+          // 闇�瑕佸寘瑁�
+          if ( sumUnpackagedInventoryQuantity > maxPackageQuantity ) {
+            // 闇�瑕佸寘瑁呯殑鏁伴噺
+            needPackagingQuantity := [Number] ( sumUnpackagedInventoryQuantity - maxPackageQuantity );
+            // 鎸夐潪鍖呰搴撳瓨鎺掑簭鍚庣殑琛�
+            itemPPRs              := selectsortedset( pprs, Elements, tempPPR, true, 
+                                                      -select( tempPPR, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc ).UnpackagedInventory() );
+            
+    //        info( "闇�瑕佸寘瑁呮椂闂达細", ppc.StartDate().Format( "Y-M2-D2" ), "    闇�瑕佸寘瑁呯殑鏁伴噺锛�", needPackagingQuantity );
+            traverse ( itemPPRs, Elements, ppr, needPackagingQuantity > 0 ) {
+              PackagingPlanCell::Package( macroPlan, ppr, ppc, needPackagingQuantity );
+            }
+          }
+        }
+      }
+    }
   *]
 }
diff --git a/_Main/Sys/Repr/Global/MachineLogisticsCostReportCell.qrp b/_Main/Sys/Repr/Global/MachineLogisticsCostReportCell.qrp
new file mode 100644
index 0000000..6e211a7
--- /dev/null
+++ b/_Main/Sys/Repr/Global/MachineLogisticsCostReportCell.qrp
@@ -0,0 +1,71 @@
+Quintiq file version 2.0
+#parent: #root
+TypeRepresentation MachineLogisticsCostReportCell
+{
+  AttributeRepresentation BufferPaperCost
+  {
+    AttributeKey: '[413988.0.1462991459]'
+    Synonym: '缂撳啿绾歌垂鐢�'
+  }
+  AttributeRepresentation Coefficient
+  {
+    AttributeKey: '[413988.0.1462991559]'
+    Synonym: '绯绘暟'
+  }
+  AttributeRepresentation EstimatedTotalCost
+  {
+    AttributeKey: '[413988.0.1462991539]'
+    Synonym: '棰勮鎬昏垂鐢�'
+  }
+  AttributeRepresentation ExternalRentalWarehouseTransportationCosts
+  {
+    AttributeKey: '[413988.0.1462991519]'
+    Synonym: '澶栫搴撹繍杈撹垂鐢�'
+  }
+  AttributeRepresentation OutboundExpensesForRentedWarehouses
+  {
+    AttributeKey: '[413988.0.1462991509]'
+    Synonym: '澶栫搴撳嚭搴撹垂鐢�'
+  }
+  AttributeRepresentation PackingCharges
+  {
+    AttributeKey: '[413988.0.1462991439]'
+    Synonym: '鍖呰璐圭敤'
+  }
+  AttributeRepresentation QuantityOfWoodenCrates
+  {
+    AttributeKey: '[413988.0.1462991469]'
+    Synonym: '鏈ㄧ鏁伴噺'
+  }
+  AttributeRepresentation RentalWarehouseStorageFees
+  {
+    AttributeKey: '[413988.0.1462991529]'
+    Synonym: '澶栫搴撲粨鍌ㄨ垂鐢�'
+  }
+  AttributeRepresentation StorageFeesForRentedWarehouses
+  {
+    AttributeKey: '[413988.0.1462991499]'
+    Synonym: '澶栫搴撳叆搴撹垂鐢�'
+  }
+  AttributeRepresentation TotalCost
+  {
+    AttributeKey: '[413988.0.1462991549]'
+    Synonym: '鎬昏垂鐢�'
+  }
+  AttributeRepresentation TransferCost
+  {
+    AttributeKey: '[413988.0.1462991489]'
+    Synonym: '璋冩嫧璐圭敤'
+  }
+  AttributeRepresentation UnpackingCost
+  {
+    AttributeKey: '[413988.0.1462991449]'
+    Synonym: '鎷嗗寘璐圭敤'
+  }
+  AttributeRepresentation WoodenCrateCost
+  {
+    AttributeKey: '[413988.0.1462991479]'
+    Synonym: '鏈ㄧ璐圭敤'
+  }
+  RelationRepresentation MachineLogisticsCostReportColumn { RelationKey: '[413988.0.1462991383]' Visibility: 'Normal' }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_dhSelectedFactoryMCRR_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_dhSelectedFactoryMCRR_OnCreated.def
new file mode 100644
index 0000000..cfa50ae
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_dhSelectedFactoryMCRR_OnCreated.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: dhSelectedFactoryMCRR
+Response OnCreated () id:Response_MacroPlanner_ApplicationMacroPlanner_dhSelectedFactoryMCRR_OnCreated
+{
+  #keys: '[415754.0.430191699]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  QuillAction
+  {
+    Body:
+    [*
+      this.Data( "澶ц繛宸ュ巶" );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/_ROOT_Component_ApplicationMacroPlanner.def b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/_ROOT_Component_ApplicationMacroPlanner.def
index e834e94..ae398df 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/_ROOT_Component_ApplicationMacroPlanner.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/_ROOT_Component_ApplicationMacroPlanner.def
@@ -223,5 +223,16 @@
         Taborder: 59
       ]
     }
+    Component dhSelectedFactoryMCRR
+    {
+      #keys: '[415754.0.434272020]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'String*'
+      Properties:
+      [
+        Description: '鏈哄姞鐗╂祦鎴愭湰鎶ヨ〃宸ュ巶鍙傛暟'
+        Taborder: 60
+      ]
+    }
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_bRefresh_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_bRefresh_OnClick.def
index 6cef4ca..c02e5b9 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_bRefresh_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_bRefresh_OnClick.def
@@ -14,6 +14,8 @@
     Body:
     [*
       MachineLogisticsCostReportCell::CreateData( MacroPlan, ddslFactory.Text() );
+      
+      WebMessageBox::Success( Translations::A_VWED_Success() );
     *]
     GroupServerCalls: false
   }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnCreated.def
new file mode 100644
index 0000000..0c95da9
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnCreated.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: pHeader/ddslFactory
+Response OnCreated () id:Response_pHeader_ddslFactory_OnCreated
+{
+  #keys: '[415754.0.425324701]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  QuillAction
+  {
+    Body:
+    [*
+      this.Text( dhSelectedFactoryMCRR.Data() );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnUserSelectionChanged.def b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnUserSelectionChanged.def
new file mode 100644
index 0000000..fcd5be2
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/Response_pHeader_ddslFactory_OnUserSelectionChanged.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: pHeader/ddslFactory
+Response OnUserSelectionChanged () id:Response_pHeader_ddslFactory_OnUserSelectionChanged
+{
+  #keys: '[415754.0.425324931]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebDropDownStringList_OnUserSelectionChanged'
+  QuillAction
+  {
+    Body:
+    [*
+      dhSelectedFactoryMCRR.Data( this.Text() );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/_ROOT_Component_FormMachineLogisticsCostReport.def b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/_ROOT_Component_FormMachineLogisticsCostReport.def
index c5e5780..dbab742 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/_ROOT_Component_FormMachineLogisticsCostReport.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormMachineLogisticsCostReport/_ROOT_Component_FormMachineLogisticsCostReport.def
@@ -12,6 +12,7 @@
   ]
   Properties:
   [
+    Description: '鏈哄姞鐗╂祦鎴愭湰鎶ヨ〃'
     Title: 'MachineLogisticsCostReport'
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Views/NewAssemblyOnlinePlan.vw b/_Main/UI/MacroPlannerWebApp/Views/NewAssemblyOnlinePlan.vw
index 422e55c..60242ae 100644
--- a/_Main/UI/MacroPlannerWebApp/Views/NewAssemblyOnlinePlan.vw
+++ b/_Main/UI/MacroPlannerWebApp/Views/NewAssemblyOnlinePlan.vw
@@ -30,7 +30,7 @@
           FormNewAssemblyOnlinePlan_MatrixEditor515
           {
             gridColor: '#c4c4c4'
-            totalHeaderWidth: 530
+            totalHeaderWidth: 335
             attributeHeaderWidthRatio: 0.6
             nameHeaderWidthRatio: 0.4
             columnWidth: 100
@@ -87,7 +87,7 @@
           FormNewAssemblyOnlinePlan_MatrixEditor583
           {
             gridColor: '#c4c4c4'
-            totalHeaderWidth: 532
+            totalHeaderWidth: 340
             attributeHeaderWidthRatio: 0.6
             nameHeaderWidthRatio: 0.4
             columnWidth: 100
diff --git a/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw b/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw
index 31f8d84..ae2b965 100644
--- a/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw
+++ b/_Main/UI/MacroPlannerWebApp/Views/NewOfflinePlan.vw
@@ -30,7 +30,7 @@
           FormNewOfflinePlan_MatrixEditor515
           {
             gridColor: '#c4c4c4'
-            totalHeaderWidth: 507
+            totalHeaderWidth: 342
             attributeHeaderWidthRatio: 0.6
             nameHeaderWidthRatio: 0.4
             columnWidth: 100
@@ -87,7 +87,7 @@
           FormNewOfflinePlan_MatrixEditor583
           {
             gridColor: '#c4c4c4'
-            totalHeaderWidth: 509
+            totalHeaderWidth: 342
             attributeHeaderWidthRatio: 0.6
             nameHeaderWidthRatio: 0.4
             columnWidth: 100

--
Gitblit v1.9.3