From 5655862ec81022848c46d1862404f077b919f9fa Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期四, 12 九月 2024 12:55:32 +0800
Subject: [PATCH] 添加新增Forecast的时候可以使用Curve拆分的功能

---
 _Main/UI/MacroPlannerWebApp/Component_FormForecasts/Response_ListSalesDemands_MenuCreate_OnClick#715.def                              |   17 ++++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelGeneral.def                                             |    1 
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_pnlActions.def                                               |   32 ++++++++
 _Main/BL/Type_Archive/StaticMethod_Success.qbl                                                                                        |    2 
 _Main/BL/Type_Forecast/StaticMethod_SplitUsingCurve.qbl                                                                               |   62 +++++++++++++++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_PanelCurve_DropDownStringListCurve_OnCreated.def |   17 ++++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/_ROOT_Component_DialogCreateEditForecast.def                           |    1 
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelCurve.def                                               |   24 ++++++
 _Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_ListSalesDemands.def                                                    |    4 +
 _Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_listContextMenuSD.def                                                   |    4 +
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelOrigin.def                                              |    1 
 _Main/BL/Type_Archive/StaticMethod_GenerateForecast.qbl                                                                               |    9 +
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_pnlActions_bSplitUsingCurve_OnClick.def          |   27 ++++++
 13 files changed, 197 insertions(+), 4 deletions(-)

diff --git a/_Main/BL/Type_Archive/StaticMethod_GenerateForecast.qbl b/_Main/BL/Type_Archive/StaticMethod_GenerateForecast.qbl
index c2e0f8d..fc1beab 100644
--- a/_Main/BL/Type_Archive/StaticMethod_GenerateForecast.qbl
+++ b/_Main/BL/Type_Archive/StaticMethod_GenerateForecast.qbl
@@ -2,13 +2,16 @@
 #parent: #root
 StaticMethod GenerateForecast (
   ArchiveExecutionStatus archiveExecutionStatus,
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  Boolean isClearForecast
 )
 {
   TextBody:
   [*
-    traverse ( macroPlan, SalesDemand.astype( Forecast ), f ) {
-      f.Delete();
+    if( isClearForecast ){
+      traverse ( macroPlan, SalesDemand.astype( Forecast ), f ) {
+        f.Delete();
+      }
     }
     
     productMPs := selectset( macroPlan,Product_MP,prod,not prod.IsSystem() );
diff --git a/_Main/BL/Type_Archive/StaticMethod_Success.qbl b/_Main/BL/Type_Archive/StaticMethod_Success.qbl
index 56e0029..ccabea9 100644
--- a/_Main/BL/Type_Archive/StaticMethod_Success.qbl
+++ b/_Main/BL/Type_Archive/StaticMethod_Success.qbl
@@ -17,7 +17,7 @@
       archiveExecutionStatus.AES_TemporaryDemandData().Execute();
       
       // 鐢熸垚Forecast
-      Archive::GenerateForecast( archiveExecutionStatus, macroPlan );
+      Archive::GenerateForecast( archiveExecutionStatus, macroPlan ,true );
       
       // 娓呯┖涓存椂鏁版嵁搴�
       archiveExecutionStatus.AES_TemporaryDemandData().Source().FlatQuery( "truncate table A_Forecasts" );
diff --git a/_Main/BL/Type_Forecast/StaticMethod_SplitUsingCurve.qbl b/_Main/BL/Type_Forecast/StaticMethod_SplitUsingCurve.qbl
new file mode 100644
index 0000000..e5130b9
--- /dev/null
+++ b/_Main/BL/Type_Forecast/StaticMethod_SplitUsingCurve.qbl
@@ -0,0 +1,62 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod SplitUsingCurve (
+  SalesSegment_MP salesSegment,
+  Product_MP product,
+  StockingPoint_MP stockingPoint,
+  Date startDate,
+  Date endDate,
+  Real quantity,
+  String curve,
+  const Archive archive,
+  ArchiveExecutionStatus archiveExecutionStatus
+)
+{
+  TextBody:
+  [*
+    // Akari Sep-11-2024 (created)
+    // 璇锋眰鍙傛暟
+    macroPlan := salesSegment.MacroPlan();
+    ac := select( archive, ArchiveCurve, tempAC, true );
+    json          := JSON::Object()
+                     .Add( "salesSegment", salesSegment.Name() )
+                     .Add( "productID", product.ID() )
+                     .Add( "stockingPointID", stockingPoint.ID() )
+                     .Add( "startDate", startDate.Format( "Y-M2-D2") )
+                     .Add( "endDate", endDate.Format( "Y-M2-D2") )
+                     .Add( "quantity", quantity )
+                     .Add( "curve", curve )
+                     .Add( "pathCurve", ac.FilePath() ).Build().AsString();
+    
+    // 璋冪敤鎺ュ彛
+    url := "/IDSPPACurve/ImportCurveIncremental";
+    
+    i := HTTPInterface::Create( archive.JavaInterfaceAddress(), archive.JavaInterfacePort() );
+    i.URL( url );
+    i.PostMethod( true );
+    i.MediaType( "application/json" );
+    i.TimeOut( Duration::Minutes( 5 ) );
+    
+    i.Call( json );
+      
+    htmlresult := i.Result();
+    
+    respJSON   := JSON::Parse( htmlresult );
+    
+    code    := respJSON.Get( "code" ).GetNumber();
+    message := respJSON.Get( "message" ).GetString();
+    
+    if( code = 200 ){
+        // 鑾峰彇闇�姹�
+      archiveExecutionStatus.AES_TemporaryDemandData().Execute();
+      
+      // 鐢熸垚Forecast
+      Archive::GenerateForecast( archiveExecutionStatus, macroPlan ,false );
+      
+      // 娓呯┖涓存椂鏁版嵁搴�
+      archiveExecutionStatus.AES_TemporaryDemandData().Source().FlatQuery( "truncate table A_Forecasts" );
+    }else{
+      error( message ); 
+    }
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelCurve.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelCurve.def
new file mode 100644
index 0000000..48a8a79
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelCurve.def
@@ -0,0 +1,24 @@
+Quintiq file version 2.0
+Component PanelCurve
+{
+  #keys: '[414996.1.77261280]'
+  BaseType: 'WebPanel'
+  Children:
+  [
+    Component DropDownStringListCurve
+    {
+      #keys: '[414996.1.79651031]'
+      BaseType: 'WebDropDownStringList'
+      Properties:
+      [
+        Label: 'Curve'
+        Taborder: 0
+      ]
+    }
+  ]
+  Properties:
+  [
+    Taborder: 9
+    Visible: false
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelGeneral.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelGeneral.def
index 675e436..df8b96b 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelGeneral.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelGeneral.def
@@ -4,5 +4,6 @@
   Children:
   [
     #child: PanelOrigin
+    #child: PanelCurve
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelOrigin.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelOrigin.def
index 796aea5..36444d4 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelOrigin.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_PanelOrigin.def
@@ -21,6 +21,7 @@
   ]
   Properties:
   [
+    FixedSize: true
     Taborder: 8
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_pnlActions.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_pnlActions.def
new file mode 100644
index 0000000..140aa8e
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Component_pnlActions.def
@@ -0,0 +1,32 @@
+Quintiq file version 2.0
+Component pnlActions #extension
+{
+  Children:
+  [
+    Component btnOk #extension
+    {
+      Properties:
+      [
+        Taborder: 1
+      ]
+    }
+    Component btnCancel #extension
+    {
+      Properties:
+      [
+        Taborder: 2
+      ]
+    }
+    Component bSplitUsingCurve
+    {
+      #keys: '[414996.1.79889444]'
+      BaseType: 'WebButton'
+      Properties:
+      [
+        Label: 'Split using Curve'
+        Taborder: 0
+        Visible: false
+      ]
+    }
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_PanelCurve_DropDownStringListCurve_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_PanelCurve_DropDownStringListCurve_OnCreated.def
new file mode 100644
index 0000000..d790417
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_PanelCurve_DropDownStringListCurve_OnCreated.def
@@ -0,0 +1,17 @@
+Quintiq file version 2.0
+#parent: PanelCurve/DropDownStringListCurve
+Response OnCreated () id:Response_MacroPlanner_PanelCurve_DropDownStringListCurve_OnCreated
+{
+  #keys: '[414996.1.77271766]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  GroupServerCalls: true
+  QuillAction
+  {
+    Body:
+    [*
+      curves := selectuniquevalues( MacroPlan,SixDigitCode,code,code.Curve());
+      this.Strings( curves.Concatenate( ";"));
+    *]
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_pnlActions_bSplitUsingCurve_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_pnlActions_bSplitUsingCurve_OnClick.def
new file mode 100644
index 0000000..1995cc8
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/Response_MacroPlanner_pnlActions_bSplitUsingCurve_OnClick.def
@@ -0,0 +1,27 @@
+Quintiq file version 2.0
+#parent: pnlActions/bSplitUsingCurve
+Response OnClick () id:Response_MacroPlanner_pnlActions_bSplitUsingCurve_OnClick
+{
+  #keys: '[414996.1.77291489]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebButton_OnClick'
+  GroupServerCalls: true
+  QuillAction
+  {
+    Body:
+    [*
+      Forecast::SplitUsingCurve( DropDownListSalesSegment.Data(),
+                                 DropDownListProduct.Data(),
+                                 DropDownListStockingPoint.Data(),
+                                 DateSelectorStart.Date(),
+                                 DateSelectorEnd.Date(),
+                                 [Real]EditFieldQuantityUom.Text(),
+                                 DropDownStringListCurve.Text(),
+                                 Archive,
+                                 ArchiveExecutionStatus );
+      
+      WebMessageBox::Success( "Success" );
+      Form.Close();
+    *]
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/_ROOT_Component_DialogCreateEditForecast.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/_ROOT_Component_DialogCreateEditForecast.def
index dbf76ef..cda7f23 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/_ROOT_Component_DialogCreateEditForecast.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditForecast/_ROOT_Component_DialogCreateEditForecast.def
@@ -6,5 +6,6 @@
   Children:
   [
     #child: pnlContent
+    #child: pnlActions
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_ListSalesDemands.def b/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_ListSalesDemands.def
index 8fc3953..b2c78ed 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_ListSalesDemands.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_ListSalesDemands.def
@@ -5,6 +5,10 @@
   [
     Component DataSetLevelSalesDemands #extension
     {
+      Children:
+      [
+        #child: listContextMenuSD
+      ]
       Properties:
       [
         Columns: '[{"attribute":{"classtype":"WebApiDefinitionAttributeAllConstraint","columnid":"All constraints","title":"All constraints","subtotals":"","tooltip":"","width":1,"display":"shown"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ImgNotLinkedToPeriod","title":"ImgNotLinkedToPeriod","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ImgNotLinkedToPeriod"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ImgIsPostponed","title":"ImgIsPostponed","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ImgIsPostponed"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"StockingPoint_MP.ID","title":"Stocking point","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"StockingPoint_MP.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"SalesSegment_MP.Name","title":"Sales segment","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"SalesSegment_MP.Name"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Product_MP.ID","title":"Product","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"Product_MP.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"StartDate","title":"Start","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"StartDate"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"EndDate","title":"End","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"EndDate"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"UnitOfMeasure_MP.Name","title":"Quantity UoM","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"UnitOfMeasure_MP.Name"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Quantity","title":"Original Qty","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"Quantity"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"NettedQuantity","title":"Quantity","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"NettedQuantity"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"FulfilledQuantity","title":"Fulfilled","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"FulfilledQuantity"}},{"attribute":{"classtype":"WebApiDefinitionAttributeChart","columnid":"Fulfillment Illustration","title":"Fulfillment","subtotals":"","tooltip":"","width":-1,"display":"shown","type":"stackbar","relative":true,"attributes":[{"name":"Fulfilled demand","color":"rgb(87,184,71)","expression":{"classtype":"WebApiDefinitionAttributeExpression","columnid":"Fulfillment","title":"Fulfilled demand","subtotals":"","tooltip":"","width":-1,"display":"shown","expressionbody":"object.FulfilledQuantity().Round(2)"}},{"name":"Unfulfilled demand","color":"rgb(232,123,0)","expression":{"classtype":"WebApiDefinitionAttributeExpression","columnid":"Unfulfilled demand","title":"Unfulfilled demand","subtotals":"","tooltip":"","width":-1,"display":"shown","expressionbody":"maxvalue(object.NettedQuantity()-object.FulfilledQuantity(),0.0).Round(2)"}}]}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Price","title":"Price","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"Price"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"PriceUoM","title":"PriceUoM","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"PriceUoM"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Priority.Name","title":"Priority","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"Priority.Name"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"DemandUncertaintyPercentage","title":"Uncertainty","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"DemandUncertaintyPercentage"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Origin","title":"Origin","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"Origin"}}]'
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_listContextMenuSD.def b/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_listContextMenuSD.def
new file mode 100644
index 0000000..c7f3361
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_listContextMenuSD.def
@@ -0,0 +1,4 @@
+Quintiq file version 2.0
+Component listContextMenuSD #extension
+{
+}
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Response_ListSalesDemands_MenuCreate_OnClick\043715.def" "b/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Response_ListSalesDemands_MenuCreate_OnClick\043715.def"
new file mode 100644
index 0000000..7041dcb
--- /dev/null
+++ "b/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Response_ListSalesDemands_MenuCreate_OnClick\043715.def"
@@ -0,0 +1,17 @@
+Quintiq file version 2.0
+#parent: ListSalesDemands
+Response OnClick () inherited id:Response_ListSalesDemands_MenuCreate_OnClick_715 #extension
+{
+  QuillAction #extension
+  {
+    Body:
+    [*
+      //Create new sales demand
+      dlg := construct( DialogCreateEditForecast );
+      dlg.New();
+      
+      dlg.bSplitUsingCurve().Visible( true );
+      dlg.PanelCurve().Visible( true );
+    *]
+  }
+}

--
Gitblit v1.9.3