From aa3b3abf43b390284c316a89ba91539b081bf544 Mon Sep 17 00:00:00 2001
From: Tianma21 <Administrator@TOTDQAE01.tianmame.cn>
Date: 星期一, 09 十月 2023 11:30:53 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/TIANMA_JITUAN into dev
---
 /dev/null                                                                                                                  |   19 ------
 _Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl                                          |    3 
 _Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityOrder/Response_PanelFillingCapacityOrder_ButtonDeduct_OnClick.def |    6 +
 _Main/BL/Type_FillingCapacityOrder/StaticMethod_OrderOffset.qbl                                                            |   58 +++++++++++++++++++
 _Main/BL/Type_FillingCapacityOrder/StaticMethod_CreateCustomOrder.qbl                                                      |   36 ++++++++++++
 _Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl                                                                |    7 +-
 6 files changed, 104 insertions(+), 25 deletions(-)
diff --git a/_Main/BL/Type_FillingCapacityOrder/StaticMethod_CreateCustomOrder.qbl b/_Main/BL/Type_FillingCapacityOrder/StaticMethod_CreateCustomOrder.qbl
new file mode 100644
index 0000000..c40a89b
--- /dev/null
+++ b/_Main/BL/Type_FillingCapacityOrder/StaticMethod_CreateCustomOrder.qbl
@@ -0,0 +1,36 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateCustomOrder (
+  MacroPlan macroPlan,
+  FillingCapacityOrder fillingCapacityOrder,
+  Real quantity
+) as CustomerOrder
+{
+  TextBody:
+  [*
+    targetProduct_MP := select( macroPlan, Product_MP, tempPMP, tempPMP.ID() = fillingCapacityOrder.ProductID() );
+    targetStockingPoint_MP := select( macroPlan, StockingPoint_MP, tempSPMP, tempSPMP.ID() = fillingCapacityOrder.StockingPointID() );
+    
+    targetCustomerOrder := CustomerOrder::Create( targetProduct_MP,
+                                                  targetStockingPoint_MP,
+                                                  OS::GenerateGUIDAsString(),
+                                                  fillingCapacityOrder.OrderDate(),
+                                                  quantity,
+                                                  0.0,
+                                                  "Normal",
+                                                  fillingCapacityOrder.SalesSegmentName(),
+                                                  fillingCapacityOrder.CurrencyID(),
+                                                  fillingCapacityOrder.UnitOfMeasureName(),
+                                                  false,
+                                                  fillingCapacityOrder.Customer(),
+                                                  fillingCapacityOrder.CustomerID(),
+                                                  "",
+                                                  "",
+                                                  true,
+                                                  true,
+                                                  false
+                                                 );
+    
+    return targetCustomerOrder;
+  *]
+}
diff --git a/_Main/BL/Type_FillingCapacityOrder/StaticMethod_OrderOffset.qbl b/_Main/BL/Type_FillingCapacityOrder/StaticMethod_OrderOffset.qbl
new file mode 100644
index 0000000..9dfb713
--- /dev/null
+++ b/_Main/BL/Type_FillingCapacityOrder/StaticMethod_OrderOffset.qbl
@@ -0,0 +1,58 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod OrderOffset (
+  MacroPlan macroPlan
+)
+{
+  TextBody:
+  [*
+    needOffsetFillingCapacityOrders := selectset( macroPlan, FillingCapacityOrder, tempFCO, tempFCO.State() = "鏈啿鍑�" or tempFCO.State() ="" );
+    
+    traverse ( needOffsetFillingCapacityOrders, Elements, fco, fco.Quantity() > 0 ) {
+      originalCounterSignedOrder := select( macroPlan, SalesDemand.astype( CustomerOrder ), tempCO, tempCO.CustomerName() = fco.Customer()  and 
+                                                                                                    tempCO.ProductID()    = fco.ProductID() and 
+                                                                                                    tempCO.OrderTag()     = "鍙嶇"
+                                           );
+      if ( fco.OrderType() = "鍙嶇" ) {
+        if ( isnull( originalCounterSignedOrder ) ) {
+          customerOrder := FillingCapacityOrder::CreateCustomOrder( macroPlan, fco, fco.Quantity() );
+          customerOrder.OrderTag( "鍙嶇" );
+        } else {
+          originalCounterSignedOrder.Quantity( originalCounterSignedOrder.Quantity() + fco.Quantity() );
+        }
+      } else if ( fco.OrderType() = "鎺堟潈" ) {
+        originalAuthorizedOrder := select( macroPlan, SalesDemand.astype( CustomerOrder ), tempCO, tempCO.CustomerName() = fco.Customer()  and 
+                                                                                                   tempCO.ProductID()    = fco.ProductID() and 
+                                                                                                   tempCO.OrderTag()     = "鎺堟潈"
+                                          );
+        if ( isnull( originalCounterSignedOrder ) ) {
+          if ( isnull( originalAuthorizedOrder ) ) {
+            customOrder := FillingCapacityOrder::CreateCustomOrder( macroPlan, fco, fco.Quantity() );
+            customOrder.OrderTag( "鎺堟潈" );
+          } else {
+            originalAuthorizedOrder.Quantity( originalAuthorizedOrder.Quantity() + fco.Quantity() );
+          }
+        } else {
+          numberOfReverseSignatures := originalCounterSignedOrder.Quantity();
+          newNumberOfAuthorizations := ifexpr( ( fco.Quantity() - numberOfReverseSignatures ) >= 0, fco.Quantity() - numberOfReverseSignatures, 0 );
+          numberOfReverseSignatures := ifexpr( ( fco.Quantity() - numberOfReverseSignatures ) >= 0, 0, numberOfReverseSignatures - fco.Quantity() );
+          
+          if ( numberOfReverseSignatures >= 0 ) {
+            originalCounterSignedOrder.Quantity( numberOfReverseSignatures );
+          } else {
+            originalCounterSignedOrder.Delete();
+          }
+          
+          if ( newNumberOfAuthorizations > 0 ) {
+            if ( isnull( originalAuthorizedOrder ) ) {
+              customerOrder := FillingCapacityOrder::CreateCustomOrder( macroPlan, fco, newNumberOfAuthorizations );
+              customerOrder.OrderTag( "鎺堟潈" );
+            } else {
+              originalAuthorizedOrder.Quantity( originalAuthorizedOrder.Quantity() + newNumberOfAuthorizations );
+            }
+          }
+        }
+      }
+    }
+  *]
+}
diff --git a/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl b/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
index 5365af6..9a69cf5 100644
--- a/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
+++ b/_Main/BL/Type_Global_MappingCustomOrder/StaticMethod_SynchronizeMacroPlanData.qbl
@@ -14,8 +14,9 @@
                                                                        ExecuteUser := executionUser
                                                                       );
                                             
-      Global_MappingCustomOrder::CreateCustomOrder( globalOTDTable, macroPlan );
+      
     try {
+      Global_MappingCustomOrder::CreateCustomOrder( globalOTDTable, macroPlan );
       
       global_BrokerExecuteLog.ExecutionStatus( "Complete" );
       global_BrokerExecuteLog.SuccessDateTime( DateTime::ActualTime().Format( "Y-M-D H2:m:s" ) );
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
index 080565d..e6907cc 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
@@ -51,7 +51,7 @@
         }
       operation := Operation::FindOperationTypeIndex( id );
       if(not isnull(operation)){
-            account := Account_MP::FindByName( this, "Operation cost" );
+            account := Account_MP::FindByName( this, "Operating cost" );
             isfromdb := false;
             existoperationcost := OperationCost::FindOperationCostTypeIndex( id );
             if( isnull( existoperationcost ) ){
@@ -67,10 +67,9 @@
                   timeunit := connecteditem.TimeUnit();
                   OperationCost::Create( id, operation, account, "Volume", start, timeunit, lengthoftime, cost, isfromdb );
                 }
-
+    
               }
       }
-
-      }
+    }
   *]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityOrder/Response_PanelFillingCapacityOrder_ButtonDeduct_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityOrder/Response_PanelFillingCapacityOrder_ButtonDeduct_OnClick.def
index 1ea13f8..12efac1 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityOrder/Response_PanelFillingCapacityOrder_ButtonDeduct_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityOrder/Response_PanelFillingCapacityOrder_ButtonDeduct_OnClick.def
@@ -13,7 +13,11 @@
   {
     Body:
     [*
-      H_FunctionClass::SM_OrderHedgingEx( MacroPlan, ApplicationMacroPlanner.GetUserName() );
+      //H_FunctionClass::SM_OrderHedgingEx( MacroPlan, ApplicationMacroPlanner.GetUserName() );
+      
+      FillingCapacityOrder::OrderOffset( MacroPlan );
+      
+      WebMessageBox::Success( "鍐插噺鎴愬姛锛侊紒锛�", true );
     *]
     GroupServerCalls: false
   }
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick\043144.def" "b/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick\043144.def"
deleted file mode 100644
index 69b8b43..0000000
--- "a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick\043144.def"
+++ /dev/null
@@ -1,19 +0,0 @@
-Quintiq file version 2.0
-#parent: ListPriorityFactor
-Response OnClick (
-  PriorityFactor selection
-) id:Response_ListPriorityFactor_MenuEdit_OnClick
-{
-  #keys: '[414382.0.485894605]'
-  CanBindMultiple: false
-  DefinitionID => /ListPriorityFactor/Responsedef_ListPriorityFactor_WebMenu_OnClick
-  QuillAction
-  {
-    Body:
-    [*
-      dlg := construct( DialogEditPriorityFactor );
-      dlg.Edit( selection);
-    *]
-    GroupServerCalls: false
-  }
-}
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick\043582.def" "b/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick\043582.def"
deleted file mode 100644
index 4244d64..0000000
--- "a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick\043582.def"
+++ /dev/null
@@ -1,18 +0,0 @@
-Quintiq file version 2.0
-#parent: ListPriorityFactor
-Response OnClick () id:Response_ListPriorityFactor_MenuNew_OnClick
-{
-  #keys: '[414382.0.593002709]'
-  CanBindMultiple: false
-  DefinitionID => /ListPriorityFactor/Responsedef_ListPriorityFactor_WebMenu_OnClick
-  QuillAction
-  {
-    Body:
-    [*
-      dlg := construct( DialogEditPriorityFactor );
-      businessType := DropDownStringListBusinessType.Text();
-      dlg.New( MacroPlan, businessType);
-    *]
-    GroupServerCalls: false
-  }
-}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick.def
deleted file mode 100644
index 58990a6..0000000
--- a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactor/Response_ListPriorityFactor_OnClick.def
+++ /dev/null
@@ -1,18 +0,0 @@
-Quintiq file version 2.0
-#parent: ListPriorityFactor
-Response OnClick (
-  PriorityFactor selection
-) id:Response_ListPriorityFactor_MenuDel_OnClick
-{
-  #keys: '[414382.0.593002800]'
-  CanBindMultiple: false
-  DefinitionID => /ListPriorityFactor/Responsedef_ListPriorityFactor_WebMenu_OnClick
-  QuillAction
-  {
-    Body:
-    [*
-      selection.Delete();
-    *]
-    GroupServerCalls: false
-  }
-}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactorGrading/Response_ListPriorityFactorGrading_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactorGrading/Response_ListPriorityFactorGrading_OnClick.def
deleted file mode 100644
index c1003b6..0000000
--- a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityFactorGrading/Response_ListPriorityFactorGrading_OnClick.def
+++ /dev/null
@@ -1,19 +0,0 @@
-Quintiq file version 2.0
-#parent: ListPriorityFactorGrading
-Response OnClick (
-  PriorityFactorDetails selction
-) id:Response_ListPriorityFactorGrading_MenuEdit_OnClick
-{
-  #keys: '[414382.0.479531766]'
-  CanBindMultiple: false
-  DefinitionID => /ListPriorityFactorGrading/Responsedef_ListPriorityFactorGrading_WebMenu_OnClick
-  QuillAction
-  {
-    Body:
-    [*
-      dlg := construct( DialogEditPriorityFactorDetails);
-      dlg.Edit( selction);
-    *]
-    GroupServerCalls: false
-  }
-}
--
Gitblit v1.9.3