From 8048c493c1d923176351080ee697d5c9d1c640a6 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期四, 22 八月 2024 15:36:11 +0800
Subject: [PATCH] 库存接口自动同步

---
 _Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl             |   28 +++++++++-----
 _Main/BL/Type_MachineStockData/StaticMethod_Synchronize.qbl                    |    9 +++-
 _Main/BL/Type_FinishedEngineInventory/StaticMethod_Synchronize.qbl             |   11 ++++-
 _Main/BL/Type_InventoryInterfaceData/StaticMethod_SynchronizeInventory#575.qbl |   24 ++++++++++++
 4 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl b/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl
index 600da07..d33daa3 100644
--- a/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl
+++ b/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl
@@ -32,16 +32,24 @@
                                                                  , ReturnMsg := 'Success'
                                                                  , Success := true
                                                                   );
-    //traverse( macroplan, AssemblyOnlinePlanRow.AssemblyOnlinePlanCell, cell ){
-    //  cd                  :=interfaceDataset.AssemblyOnlinePlanPPPSPush( relnew, Product           := forecast.ProductID()
-    //                                                                     , PlanningDate            := forecast.StartDate()
-    //                                                                     , DemandQty               := [Number]forecast.Quantity()
-    //                                                                     , VersionName             := macroplan.ScenarioName()
-    //                                                                     , InterfaceTime           := nowdate
-    //                                                                     , VersionFlag             := versionflag
-    //                                                                     );
-    //  loginfo.CustomerDemandPPAIDS( relinsert, cd );
-    //}
+    traverse( macroplan, AssemblyOnlinePlanColumn, column ){
+      traverse( column, AssemblyOnlinePlanCell, cell, cell.Value() <> '' and cell.AssemblyOnlinePlanRow().RowNr() = '1' ){
+        quantityrow        := cell.AssemblyOnlinePlanRow();
+        ordercell          := selectobject( column, AssemblyOnlinePlanCell, ocell, ocell.AssemblyOnlinePlanRow().ProductID() = quantityrow.ProductID() 
+                                            and ocell.AssemblyOnlinePlanRow().ProductionLine() = quantityrow.ProductionLine() 
+                                            and ocell.AssemblyOnlinePlanRow().RowNr() = '2' );
+    
+        cd                  :=interfaceDataset.AssemblyOnlinePlanPPPSPush( relnew, Product           := quantityrow.ProductID()
+                                                                           , PlanningDate            := column.ColumnDate()
+                                                                           , PlanningQty             := [Number]cell.Value()
+                                                                           , Sequence                := ordercell.Value()
+                                                                           , VersionName             := macroplan.ScenarioName()
+                                                                           , InterfaceTime           := nowdate
+                                                                           , VersionFlag             := versionflag
+                                                                           );
+        loginfo.AssemblyOnlinePlanPPPSPush( relinsert, cd );
+      }
+    }
     loginfo.TotalRow( loginfo.AssemblyOnlinePlanPPPSPush( relsize ) );
   *]
 }
diff --git a/_Main/BL/Type_FinishedEngineInventory/StaticMethod_Synchronize.qbl b/_Main/BL/Type_FinishedEngineInventory/StaticMethod_Synchronize.qbl
index 0bde4d2..efe4c0f 100644
--- a/_Main/BL/Type_FinishedEngineInventory/StaticMethod_Synchronize.qbl
+++ b/_Main/BL/Type_FinishedEngineInventory/StaticMethod_Synchronize.qbl
@@ -22,12 +22,17 @@
       cnv2.SetCustomConversion();
       cnv2.CustomFormatString( 'yyyy-MM-dd' );
       
-    //  sadatalist := construct( ShippingActualDatas );
+      sadatalist := construct( FinishedEngineInventorys );
       for( seq := 0;seq < data.Size();seq++){
         item := data.Get(seq);
-        FinishedEngineInventory::GenerateData( loginfo, cnv2, item );
-    //    sadatalist.Add( sadata );
+        sadata := FinishedEngineInventory::GenerateData( loginfo, cnv2, item );
+        sadatalist.Add( sadata );
       }
+      
+      options := DatasetFindOptions::Construct( 'MacroPlan' ).IncludeOffline( true ); //to load we must search offline datasets.
+      mdskey := DatasetController::FindUnique( options );
+    
+      MDSMacroPlan::Root( mdskey ) -> InventoryInterfaceData::SynchronizeInventory( owner, sadatalist );
     }
   *]
 }
diff --git "a/_Main/BL/Type_InventoryInterfaceData/StaticMethod_SynchronizeInventory\043575.qbl" "b/_Main/BL/Type_InventoryInterfaceData/StaticMethod_SynchronizeInventory\043575.qbl"
new file mode 100644
index 0000000..b3ccbaf
--- /dev/null
+++ "b/_Main/BL/Type_InventoryInterfaceData/StaticMethod_SynchronizeInventory\043575.qbl"
@@ -0,0 +1,24 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod SynchronizeInventory (
+  MacroPlan macroplan,
+  InterfaceDataset owner,
+  const FinishedEngineInventorys inventorys
+)
+{
+  Description: '鍙戝姩鏈烘垚鍝佸簱瀛�'
+  TextBody:
+  [*
+    
+    //娓呯┖鍘熸湁鐨勫簱瀛樻洿鏂版暟鎹�
+    //traverse( interfaceDataset, InventoryInterfaceData, iid, iid.Date() = date ){
+    //  iid.Delete();
+    //}
+    // 鑾峰彇鎸囧畾鏃ユ湡搴撳瓨鎺ュ彛鏁版嵁
+    //鍙戝姩鏈烘垚鍝佸簱瀛�
+    traverse( inventorys, Elements, inventory ){
+      product    := select( macroplan, Product_MP, product, product.Notes() = inventory.FourCode() );
+      InventoryInterfaceData::Generate( owner, inventory.DDay(), product.ID(), inventory.BIPlace(), [Number]inventory.Total() );
+    }
+  *]
+}
diff --git a/_Main/BL/Type_MachineStockData/StaticMethod_Synchronize.qbl b/_Main/BL/Type_MachineStockData/StaticMethod_Synchronize.qbl
index ac78819..4a74306 100644
--- a/_Main/BL/Type_MachineStockData/StaticMethod_Synchronize.qbl
+++ b/_Main/BL/Type_MachineStockData/StaticMethod_Synchronize.qbl
@@ -24,8 +24,13 @@
       
     //  sadatalist := construct( ShippingActualDatas );
       for( seq := 0;seq < data.Size();seq++){
-        item := data.Get(seq);
-        MachineStockData::GenerateData( loginfo, cnv2, item );
+        item         := data.Get(seq);
+        inventory    :=MachineStockData::GenerateData( loginfo, cnv2, item );
+        inventoryname := inventory.Lgort();
+        if( inventory.Fac() = 'DL' and inventory.Lgort() = 'All' ){
+          inventoryname := inventory.LineType();
+        }
+        InventoryInterfaceData::Generate( owner, inventory.DDay(), inventory.MaterialNo(), inventoryname, [Number]inventory.Total() );
     //    sadatalist.Add( sadata );
       }
     }

--
Gitblit v1.9.3