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

---
 _Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl       |    4 +-
 _Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl           |   64 +++++++++++++-------------------
 _Main/BL/Type_InterfaceDataset/StaticMethod_PushPlanInventoryData.qbl |   45 ++++++++++++++++++++++
 3 files changed, 73 insertions(+), 40 deletions(-)

diff --git a/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl b/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
index 8f4c851..7a0a699 100644
--- a/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_DL_EngineRackCell/StaticMethod_CreateData.qbl
@@ -12,8 +12,8 @@
     // 鍒涘缓琛�
     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 ) {
+    traverse ( genrations, Elements, g, g = "350bar" ) {
+      traverse ( mqbmlbs, Elements, m, m = "MQB" ) {
         macroPlan.DL_EngineRackRow( relnew, Generation := g, MLB_MQB := m );
       }
     }
@@ -67,13 +67,13 @@
         // 澶ц繛澶栫搴撶┖鏂欐灦鏁伴噺锛氥��350bar MQB鏂欐灦鎬绘暟閲� - 鎵�鏈�350bar MQB鎬诲簱瀛� / 鍖呰瀹归噺 - 瀹㈡埛搴撴枡鏋舵暟閲忋��* 澶ц繛澶栫搴撶┖鏂欐灦姣斾緥
         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() ) / ( lastDayOfThisMonth - dlerc.StartDate() );
+                                 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().Year()                                                                       = dlerc.StartDate().Year()  and 
+                                 tempPISPIP.Start().Date().Month()                                                                      = dlerc.StartDate().Month(),
+                                 tempPISPIP.PlannedInventoryLevelEnd() ) / ( dlerc.StartDate().StartOfNextMonth() - dlerc.StartDate() );
         cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
         cell.PlannedInventory( plannedInventory );
         cell.NumberOfEmptyShelves( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - guard( cell.PlannedInventory() / cell.PackagingCapacity(), 0 ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ), 0 ) );
@@ -107,7 +107,7 @@
                                         tempPIT.Quantity()
                                        );
     //    info( "鏁伴噺锛�", transportationQuantity2 );
-        cell.CCLineHaulCost( [Number] ( guard( transportationQuantity2 / lce.PackagingCapacity() / lct1.LoadingCapacity(), 0 ) * guard( lct1.TransportPrice(), 1 ) ) );
+        cell.CCLineHaulCost( [Number] ( guard( ceil( ceil( 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 ) ) )
@@ -120,8 +120,9 @@
                                   tempF.StartDate()                       >= ( dlerc.StartDate() - 2 )  and
                                   tempF.StartDate()                       <= ( lastDayOfThisMonth - 2 ),
                                   tempF.FulfilledQuantity() );
-    //                   info( "鏃堕棿锛�", dlerc.StartDate().Format( "Y-M2-D2" ), "    鍏ュ簱鏁伴噺锛�", inventoryQuantity, "    鍖呰瀹归噺锛�", guard( lce.PackagingCapacity(), 0 ),
-    //                         "    鍏ュ簱鍗曚环锛�", guard( lcmr.WarehousingPrice(), 0 ) ); // 娴嬭瘯杈撳嚭
+    //                   info( "鏃堕棿锛�", dlerc.StartDate().Format( "Y-M2-D2" ), "  鏃堕棿鍖哄煙锛�", ( dlerc.StartDate() - 2 ).Format( "Y-M2-D2" ), "    ", ( lastDayOfThisMonth - 2 ).Format( "Y-M2-D2" ),
+    //                         "    鍏ュ簱鏁伴噺锛�", inventoryQuantity, "    鍖呰瀹归噺锛�", guard( lce.PackagingCapacity(), 0 ),
+    //                         "    鍏ュ簱鍗曚环锛�", guard( lcmrDL.WarehousingPrice(), 0 ) ); // 娴嬭瘯杈撳嚭
         cell.DLStorageFeesForRentedWarehouses( [Number] ( guard( inventoryQuantity / lce.PackagingCapacity(), 0 ) * guard( lcmrDL.WarehousingPrice(), 1 ) ) );
         
         // DL澶栫搴撳嚭搴撹垂鐢細鍙戝姩鏈哄嚭搴撻噺 / 鏂欐灦瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦鍑哄簱鍗曚环
@@ -132,42 +133,29 @@
                                  tempPISPIPPL.Start().Date()                                        >= dlerc.StartDate()  and
                                  tempPISPIPPL.End().Date()                                          <= lastDayOfThisMonth,
                                  tempPISPIPPL.NewSupplyQuantity() );
-    //    info( "鏁伴噺锛�", outboundQuantity, "    鍖呰铻嶅垱锛�", guard( lce.PackagingCapacity(), 0 ), "    鍑哄簱鍗曚环锛�", guard( lcmr.OutboundPrice(), 0 ) );
+    //    info( "鏁伴噺锛�", outboundQuantity, "    鍖呰瀹归噺锛�", guard( lce.PackagingCapacity(), 0 ), "    鍑哄簱鍗曚环锛�", guard( lcmr.OutboundPrice(), 0 ) );
         cell.DLOutboundExpensesForRentedWarehouses( [Number] ( guard( outboundQuantity / lce.PackagingCapacity(), 0 ) * guard( lcmrDL.OutboundPrice(), 1 ) ) );
         
         // DL澶栫搴撹繍杈撹垂鐢細鍙戝姩鏈鸿繍杈撻噺 / 鍖呰瀹归噺 / 瑁呰浇瀹归噺锛堝悜涓婂彇鏁达級* 鏂欐灦杩愯緭鍗曚环
         outboundQuantity1 := 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.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().Year()                                 = dlerc.StartDate().Year()  and
+                                 tempPISPIPPL.Start().Date().Month()                                = dlerc.StartDate().Month(),
                                  tempPISPIPPL.NewSupplyQuantity() );
-        cell.DLExternalRentalWarehouseTransportationCosts( [Number] ( guard( outboundQuantity1 / lce.PackagingCapacity() / lct2.LoadingCapacity(), 0 ) * guard( lct2.TransportPrice(), 1 ) ) );
+    //    info( "鏁伴噺锛�", outboundQuantity1, "    鍖呰瀹归噺锛�", guard( lce.PackagingCapacity(), 0 ), "    瑁呰浇瀹归噺锛�", guard( lct2.LoadingCapacity(), 0 ), "    杩愯緭鍗曚环锛�", guard( lct2.TransportPrice(), 1 ) );
+        cell.DLExternalRentalWarehouseTransportationCosts( [Number] ( guard( ceil( ceil( outboundQuantity1 / lce.PackagingCapacity() ) / lct2.LoadingCapacity() ), 0 ) * guard( lct2.TransportPrice(), 1 ) ) );
         
         // 澶ц繛澶栫搴撲粨鍌ㄨ垂鐢細銆�350bar MQB鏂欐灦鎬绘暟閲�-鎵�鏈�350bar MQB鎬诲簱瀛�/鍖呰瀹归噺-瀹㈡埛搴撴枡鏋舵暟閲忋��*澶ц繛澶栫搴撶┖鏂欐灦姣斾緥
         // 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() - guard( plannedInventory1  / lce.PackagingCapacity(), 0 ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ) * guard( lcmrDL.StoragePrice(), 1 ), 0 ) );
+    //    info( "绌烘枡鏋舵暟閲忥細", cell.TotalQuantityOfMaterialRacks(), "    搴撳瓨锛�", cell.PlannedInventory(), "    澶╂暟锛�", dlerc.StartDate().StartOfNextMonth() - dlerc.StartDate(), 
+    //          "    鍖呰瀹归噺锛�", guard( lce.PackagingCapacity(), 0 ) );
+        cell.DLRentalWarehouseStorageFees( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - ceil( guard( cell.PlannedInventory() / lce.PackagingCapacity(), 0 ) ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ) * guard( lcmrDL.StoragePrice(), 1 ) * ( dlerc.StartDate().StartOfNextMonth() - dlerc.StartDate() ), 0 ) );
         
         // CC澶栫搴撴竻娲楄垂鐢細鍙戝姩鏈哄叆搴撻噺 / 鍖呰瀹归噺 * 鏂欐灦娓呮礂鍗曚环銆傚彂鍔ㄦ満鍏ュ簱閲忓彇鍙戝姩鏈洪攢閲忥紝鍖呰瀹归噺鍙栬嚜鍙戝姩鏈烘垚鏈〃銆傛枡鏋舵竻娲楀崟浠峰彇鏂欐灦鎴愭湰琛ㄣ��
-        clearnQuantity := 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.Quantity() );
-    //    info( "鏁伴噺锛�", clearnQuantity, "    鍖呰瀹归噺锛�", guard( lce.PackagingCapacity(), 0 ), "    娓呮礂鍗曚环锛�", guard( lcmr.CleanPrice(), 0 ) );
-        cell.CCCleaningCost( [Number] ( guard( clearnQuantity / lce.PackagingCapacity(), 0 ) * guard( lcmrCC.CleanPrice(), 1 ) ) );
+    //    info( "鏁伴噺锛�", transportationQuantity1, "    鍖呰瀹归噺锛�", guard( lce.PackagingCapacity(), 0 ), "    娓呮礂鍗曚环锛�", guard( lcmrCC.CleanPrice(), 0 ) );
+        cell.CCCleaningCost( [Number] ( guard( transportationQuantity1 / lce.PackagingCapacity(), 0 ) * guard( lcmrCC.CleanPrice(), 1 ) ) );
         
         // DL澶栫搴撴竻娲楄垂鐢細鍙戝姩鏈哄叆搴撻噺 / 鍖呰瀹归噺 * 鏂欐灦娓呮礂鍗曚环銆傚彂鍔ㄦ満鍏ュ簱閲忓彇鍙戝姩鏈洪攢閲忥紝鍖呰瀹归噺鍙栬嚜鍙戝姩鏈烘垚鏈〃銆傛枡鏋舵竻娲楀崟浠峰彇鏂欐灦鎴愭湰琛ㄣ��
         cell.CleaningCost( [Number] ( guard( outboundQuantity / lce.PackagingCapacity(), 0 ) * guard( lcmrDL.CleanPrice(), 1 ) ) );
diff --git a/_Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl b/_Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl
index 878b44f..ea073a7 100644
--- a/_Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl
+++ b/_Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl
@@ -26,8 +26,8 @@
     if( isassembleonlineplan ){//瑁呴厤涓婄嚎璁″垝
       AssemblyOnlinePlanPPPSPush::GenerateData( this, macroplan, executor );
     }
-    if( isinventoryplan ){//搴撳瓨璁″垝
-    //  CustomerDemandIDS::GenerateData( this, recyclebin, archive );
+    if ( isinventoryplan ) { // 璁″垝搴撳瓨鏁版嵁
+      InterfaceDataset::PushPlanInventoryData( macroplan, this );
     }
   *]
 }
diff --git a/_Main/BL/Type_InterfaceDataset/StaticMethod_PushPlanInventoryData.qbl b/_Main/BL/Type_InterfaceDataset/StaticMethod_PushPlanInventoryData.qbl
new file mode 100644
index 0000000..3853f45
--- /dev/null
+++ b/_Main/BL/Type_InterfaceDataset/StaticMethod_PushPlanInventoryData.qbl
@@ -0,0 +1,45 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod PushPlanInventoryData (
+  const MacroPlan macroPlan,
+  InterfaceDataset interfaceDataset
+)
+{
+  Description: '鍙戦�佽鍒掑簱瀛樻暟鎹帴鍙�'
+  TextBody:
+  [*
+    table         := selectobject( interfaceDataset, InventoryPlanArchiveVersion, version, not version.IsShow() );
+    
+    interfaceTime := DateTime::ActualTime().Format( "Y-M2-D2 h2:m:s" );
+    
+    jsonarray     := JSON::Array();
+    
+    traverse ( table, Row, r ){
+      traverse ( table, Column, c, c.TimeUnit() = Translations::MP_GlobalParameters_Day() ) {
+        cell := select( r, Cell, tempC, tempC.Column() = c );
+        
+        if ( not isnull( cell ) ) {
+          idsjson := JSON::Object().Add( "product", r.ProductID() )       
+                                   .Add( "inventoryDate", c.StartDate().Format( 'Y-M2-D2' ) )
+                                   .Add( "planningInventory", cell.PlanQuantity() )
+                                   .Add( "versionName", macroPlan.ScenarioName() )
+                                   .Add( "factoryName", ifexpr( r.Unit().Regex( "CC" ), "闀挎槬宸ュ巶", "澶ц繛宸ュ巶" ) )
+                                   .Add( "fac", ifexpr( r.Unit().Regex( "CC" ), "CC", "DL" ) )
+                                   .Add( "interfaceTime", interfaceTime ).Build();
+          jsonarray.Add( idsjson );
+        }
+      }
+    }
+    
+    requestbody := jsonarray.Build().AsString();
+    info(  requestbody );
+    //loginfo := owner.InterfaceLoginfo( relnew, ExecuteUser := executor
+    //                                   , Name := Translations::InterfaceDataset_CustomerDemandPPAIDS_Name()
+    //                                   , InterfaceDateTime := DateTime::ActualTime()
+    //                                   , Message := '瀹㈡埛闇�姹傦紙PPA+IDS锛�'
+    //                                   , RequestBody := requestbody);
+    ////error( '--------------------', requestbody );
+    //data     := InterfaceLoginfo::CallInterfaceForDataCenter( owner, loginfo );
+    //info( '----------------', data.AsString() );
+  *]
+}

--
Gitblit v1.9.3