From 0afdd1bc9376b24ba8722b77d92e28a38862c7a5 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期三, 06 十一月 2024 18:53:41 +0800
Subject: [PATCH] 装配上线计划数据中台推送接口

---
 _Main/BL/Type_AssemblyOnlinePlanCell0/DefaultValue_Order.qbl         |    6 ++
 _Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl   |   39 +++++-------
 _Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl          |   28 ---------
 _Main/BL/Type_AssemblyOnlinePlanCell0/Attribute_Order.qbl            |    8 ++
 _Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl      |    2 
 _Main/BL/Type_AssemblyOnlinePlanVersion/Method_Generate.qbl          |    2 
 _Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateData.qbl     |    7 +-
 _Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_Publish.qbl        |   27 +++++++++
 _Main/BL/Type_AssemblyOnlinePlanVersion/StaticMethod_RefreshData.qbl |    6 -
 9 files changed, 66 insertions(+), 59 deletions(-)

diff --git a/_Main/BL/Type_AssemblyOnlinePlanCell0/Attribute_Order.qbl b/_Main/BL/Type_AssemblyOnlinePlanCell0/Attribute_Order.qbl
new file mode 100644
index 0000000..c4b8b02
--- /dev/null
+++ b/_Main/BL/Type_AssemblyOnlinePlanCell0/Attribute_Order.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute Order
+{
+  #keys: '3[415136.0.1280830135][415136.0.1280830134][415136.0.1280830136]'
+  Description: '鐢熶骇椤哄簭锛圫tring锛�'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_AssemblyOnlinePlanCell0/DefaultValue_Order.qbl b/_Main/BL/Type_AssemblyOnlinePlanCell0/DefaultValue_Order.qbl
new file mode 100644
index 0000000..9726838
--- /dev/null
+++ b/_Main/BL/Type_AssemblyOnlinePlanCell0/DefaultValue_Order.qbl
@@ -0,0 +1,6 @@
+Quintiq file version 2.0
+#parent: #root
+DefaultValue
+{
+  TargetAttribute: Order
+}
diff --git a/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl b/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl
index a06d769..b7670aa 100644
--- a/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl
+++ b/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_GenerateData.qbl
@@ -1,10 +1,9 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod GenerateData (
-  const MacroPlan macroplan,
   InterfaceDataset interfaceDataset,
-  String executor,
-  Boolean versionflag
+  const MacroPlan macroplan,
+  String executor
 )
 {
   Description: '鐢熸垚鍙互涓嬪彂鐨勫鎴烽渶姹傦紙PPA+IDS锛夋暟鎹�'
@@ -25,32 +24,28 @@
                                                                  , Name := Translations::InterfaceDataset_AssemblyOnlinePlanPPPSPush_Name()
                                                                  , InterfaceDateTime := nowdate
                                                                  , Message := '瑁呴厤涓婄嚎璁″垝-PPPS浼犺緭鑷虫暟鎹腑鍙帮紙鍖呭惈鎺掑簭锛�/SAP锛堜笉鍖呭惈鎺掑簭锛�'
-                                                                 , IsShow := false
-                                                                 , Last := true
-                                                                 , ReturnSuccess := true
-                                                                 , ReturnMsg := 'Success'
-                                                                 , Success := true
+                                                                 , Last                      := true
                                                                   );
-    traverse( macroplan, AssemblyOnlinePlanColumn, column ){
-      traverse( column, AssemblyOnlinePlanCell, cell, cell.Value() <> '' and cell.AssemblyOnlinePlanRow().Type() = '1' ){
-        quantityrow        := cell.AssemblyOnlinePlanRow();
-        ordercell          := selectobject( column, AssemblyOnlinePlanCell, ocell, ocell.AssemblyOnlinePlanRow().ProductID() = quantityrow.ProductID() 
-                                            and ocell.AssemblyOnlinePlanRow().ProductionLine() = quantityrow.ProductionLine() 
-                                            and ocell.AssemblyOnlinePlanRow().Type() = '2' );
-        product            := selectobject( macroplan, Product_MP, product, product.ID() = quantityrow.ProductID() );
-    
-        cd                  :=interfaceDataset.AssemblyOnlinePlanPPPSPush( relnew, Product           := product.ID()
-                                                                           , PlanningDate            := column.ColumnDate()
-                                                                           , PlanningQty             := [Number]cell.Value()
-                                                                           , Sequence                := ordercell.Value()
+    traverse( interfaceDataset, AssemblyOnlinePlanVersion, verison, not verison.IsShow() ){
+      traverse( verison, Column, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() ){
+        traverse( column, Cell, cell ){
+          row              := cell.Row();
+          cd               :=interfaceDataset.AssemblyOnlinePlanPPPSPush( relnew, Product            := row.ProductID()
+                                                                           , PlanningDate            := column.StartDate()
+                                                                           , PlanningQty             := [Number]cell.Quantity()
+                                                                           , Sequence                := cell.Order()
                                                                            , VersionName             := macroplan.ScenarioName()
                                                                            , InterfaceTime           := nowdate
-                                                                           , VersionFlag             := versionflag
-                                                                           , ProductFourCode         := product.Notes()
+                                                                           , FactoryName             := row.Unit()
+                                                                          , Fac                     := ifexpr( row.Unit() = FinancialProductionReport::GetDefaultCCUnit(), 'CC', 'DL' )  
+    //                                                                       , VersionFlag             := versionflag
+                                                                           , ProductFourCode         := ifexpr( row.ProductID() = row.Name(), '', row.Name() )
                                                                            );
         loginfo.AssemblyOnlinePlanPPPSPush( relinsert, cd );
+        }
       }
     }
     loginfo.TotalRow( loginfo.AssemblyOnlinePlanPPPSPush( relsize ) );
+    AssemblyOnlinePlanPPPSPush::Publish( interfaceDataset, loginfo );
   *]
 }
diff --git a/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_Publish.qbl b/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_Publish.qbl
new file mode 100644
index 0000000..8cf3ab9
--- /dev/null
+++ b/_Main/BL/Type_AssemblyOnlinePlanPush/StaticMethod_Publish.qbl
@@ -0,0 +1,27 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod Publish (
+  InterfaceDataset owner,
+  InterfaceLoginfo loginfo
+)
+{
+  TextBody:
+  [*
+    //// 鐢勫叞楦� Jul-17-2024 (created)
+    jsonarray          := JSON::Array();
+    traverse( owner, AssemblyOnlinePlanPPPSPush, aopdata ){
+      aopdatajson      := JSON::Object().Add( "product", aopdata.Product() ).Add( "planningDate", aopdata.PlanningDate().Format( 'Y-M2-D2' ) )//"2024-10-01" )
+                                    .Add( "planningQty", aopdata.PlanningQty() )
+                                    .Add( "sequence", aopdata.Sequence() )
+                                    .Add( "factoryName", aopdata.FactoryName() )
+                                    .Add( "fac", aopdata.Fac() )
+                                    .Add( "versionName", aopdata.VersionName() )
+                                    .Add( "interfaceTime", aopdata.InterfaceTime().Format( 'Y-M2-D2 H:m:s' ) ).Build();/*"2024-10-01 12:00:00" )*/
+      jsonarray.Add( aopdatajson );
+    }
+    requestbody := jsonarray.Build().AsString();
+    info(  requestbody );
+    data     := InterfaceLoginfo::CallInterfaceForDataCenter( owner, loginfo );
+    info( '----------------', data.AsString() );
+  *]
+}
diff --git a/_Main/BL/Type_AssemblyOnlinePlanVersion/Method_Generate.qbl b/_Main/BL/Type_AssemblyOnlinePlanVersion/Method_Generate.qbl
index 2509c4b..a13a3a7 100644
--- a/_Main/BL/Type_AssemblyOnlinePlanVersion/Method_Generate.qbl
+++ b/_Main/BL/Type_AssemblyOnlinePlanVersion/Method_Generate.qbl
@@ -7,6 +7,7 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jun-25-2024 (created)
+    info( '-----------Search start-------' );
     table                   := selectobject( this,InterfaceDataset.AssemblyOnlinePlanVersion, report, not report.IsShow() );
     //娓呯┖涔嬪墠瀛樺偍鐨勬樉绀烘暟鎹�
     aopcolumns              := selectuniquevalues(  table, Column, aopcolumn, aopcolumn.TimeUnit() = search.TimeUnit() and aopcolumn.StartDate() >= search.StartDate() and aopcolumn.StartDate() <= search.EndDate(), aopcolumn.StartDate() );
@@ -31,5 +32,6 @@
         }
       }
     }
+    info( '-----------Search end-------' );
   *]
 }
diff --git a/_Main/BL/Type_AssemblyOnlinePlanVersion/StaticMethod_RefreshData.qbl b/_Main/BL/Type_AssemblyOnlinePlanVersion/StaticMethod_RefreshData.qbl
index 48860cb..9d13f21 100644
--- a/_Main/BL/Type_AssemblyOnlinePlanVersion/StaticMethod_RefreshData.qbl
+++ b/_Main/BL/Type_AssemblyOnlinePlanVersion/StaticMethod_RefreshData.qbl
@@ -24,15 +24,11 @@
     table.GenerateColumn( aopcolumns, false );
     traverse( macroPlan, NewAssemblyOnlinePlanRow, aoprow, aoprow.Type() = '1' ){
       row                  := table.GetRow( aoprow );
-      info( '------------------------', row.Type() );
       traverse( aoprow, NewAssemblyOnlinePlanCell, aopcell ){
         column             := selectobject( table, Column, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.StartDate() = aopcell.NewAssemblyOnlinePlanColumn().StartDate() );
         cell               := selectobject( row, Cell, cell, cell.Column() = column );
-        cell.InventoryWeight( aopcell.InventoryWeight() );
-    //    cell.ProductionSerialNumber( aopcell.ProductionSerialNumber() );  
+    //    cell.InventoryWeight( aopcell.InventoryWeight() );
         cell.Quantity( aopcell.Quantity() );
-    //    cell.Shift( aopcell.Shift() );
-    //    cell.Value( aopcell.Value() );
       }
     }
     showtable.Generate( search );
diff --git a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateData.qbl b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateData.qbl
index 8876fdd..a9c3acf 100644
--- a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateData.qbl
+++ b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateData.qbl
@@ -25,10 +25,6 @@
                                                                  , InterfaceDateTime         := nowdate
                                                                  , Message                   := '瀹㈡埛闇�姹傦紙PPA+IDS锛夋暟鎹帹閫�'
                                                                  , Last                      := true
-                                                                 , IsShow                    := false
-                                                                 , ReturnSuccess             := true
-                                                                 , ReturnMsg                 := 'Success'
-                                                                 , Success                   := true
                                                                   );
     traverse( interfaceDataset, CustomerDemandIDS.Row, row ){
       traverse( row, Cell, cell ){
@@ -37,11 +33,14 @@
                                                                      , DemandQty               := [Number]cell.Value()
                                                                      , VersionName             := macroplan.ScenarioName()
                                                                      , InterfaceTime           := nowdate
+                                                                     , FactoryName             := row.Factory()
+                                                                     , Fac                     := ifexpr( row.Factory() = FinancialProductionReport::GetDefaultCCUnit(), 'CC', 'DL' )  
     //                                                                 , VersionFlag             := versionflag
                                                                      );
         loginfo.CustomerDemandPPAIDS( relinsert, cd );
       }
     }
     loginfo.TotalRow( loginfo.CustomerDemandPPAIDS( relsize ) );
+    CustomerDemandPPAIDS::Publish( interfaceDataset, loginfo );
   *]
 }
diff --git a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl
index 15c3ce4..e6cfe5c 100644
--- a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl
+++ b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl
@@ -2,7 +2,7 @@
 #parent: #root
 StaticMethod Publish (
   InterfaceDataset owner,
-  String executor
+  InterfaceLoginfo loginfo
 )
 {
   TextBody:
@@ -16,35 +16,9 @@
                                     .Add( "interfaceTime", ids.InterfaceTime().Format( 'Y-M2-D2 H:m:s' ) ).Build();/*"2024-10-01 12:00:00" )*/
       jsonarray.Add( idsjson );
     }
-    //jsonarray := JSON::Array().Add( JSON::Object().Add( "product", "DZ948293" )
-    //                                 ).Build();
     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() );
-    //if( not isnull( data ) ){
-    //  
-    //  cnv2 := StringToDate::StandardConverter();
-    //  cnv2.SetCustomConversion();
-    //  cnv2.CustomFormatString( 'yyyy-MM-dd' );
-    //  
-    //  sadatalist := construct( FinishedEngineInventorys );
-    //  for( seq := 0;seq < data.Size();seq++){
-    //    item := data.Get(seq);
-    //    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_InterfaceDataset/Method_PublishPlanReportData.qbl b/_Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl
index 68a5c84..878b44f 100644
--- a/_Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl
+++ b/_Main/BL/Type_InterfaceDataset/Method_PublishPlanReportData.qbl
@@ -24,7 +24,7 @@
     //  CustomerDemandIDS::GenerateData( this, recyclebin, archive );
     }
     if( isassembleonlineplan ){//瑁呴厤涓婄嚎璁″垝
-    //  AssemblyOnlinePlanVersion::RefreshData( this, macroplan );
+      AssemblyOnlinePlanPPPSPush::GenerateData( this, macroplan, executor );
     }
     if( isinventoryplan ){//搴撳瓨璁″垝
     //  CustomerDemandIDS::GenerateData( this, recyclebin, archive );

--
Gitblit v1.9.3