From 42bc9d737ef67ac298062a01854b0faa438c84ac Mon Sep 17 00:00:00 2001
From: limj <limj@taizhitech.com>
Date: 星期二, 26 九月 2023 23:27:20 +0800
Subject: [PATCH] 优先级因子计算

---
 _Main/BL/Type_PriorityResult/StaticMethod_calculatePriorityResult.qbl                                                                |   72 ++++++++
 _Main/UI/MacroPlannerWebApp/Component_FormPriorityPolicy/Response_ListPriorityPolicy_MenuDelete_OnClick.def                          |    2 
 _Main/BL/Type_CustomerOrder/Attribute_ProductGrade.qbl                                                                               |    8 
 _Main/BL/Type_CustomerAndForecastOrder/Attribute_CustomerOrderID.qbl                                                                 |    7 
 _Main/BL/Type_CustomerAndForecastOrder/Attribute_ForecastID.qbl                                                                      |    7 
 _Main/BL/Type_CustomerOrder/Attribute_OrderType.qbl                                                                                  |    8 
 _Main/BL/Type_PriorityResult/StaticMethod_CalculateBracketScore.qbl                                                                  |   18 ++
 _Main/BL/Type_PriorityFactorDetails/StaticMethod_InitData.qbl                                                                        |   49 ++++-
 _Main/BL/Type_CustomerOrder/Attribute_CustomerPolicy.qbl                                                                             |    8 
 _Main/BL/Type_CustomerOrder/Attribute_IsAvailable.qbl                                                                                |    8 
 _Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Response_ListCustomerAndFillingCapacityOrder_MenuRefresh_OnClick.def |    8 
 _Main/BL/Type_BusinessType/StaticMethod_CreateData.qbl                                                                               |    3 
 _Main/BL/Type_CustomerOrder/Attribute_OrderTime.qbl                                                                                  |    8 
 _Main/BL/Type_CustomerAndForecastOrder/StaticMethod_RefreshData.qbl                                                                  |   46 +++++
 _Main/BL/Type_PriorityFactor/Attribute_ReflectionType.qbl                                                                            |    7 
 _Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Component_listContextMenuCustomerAndFillingCapacityOrder.def         |    4 
 _Main/BL/KnowledgeBaseDomain_MacroPlanner/KnowledgeBase_Knowledge_MP/_ROOT_KnowledgeBase_Knowledge_MP.qbl                            |    6 
 _Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl                                                                         |   88 +++++++++
 _Main/BL/Type_CustomerOrder/Attribute_SheetProfitability.qbl                                                                         |    8 
 _Main/BL/Type_CustomerOrder/Attribute_SegmentPriority.qbl                                                                            |    8 
 _Main/BL/Type_PriorityFactor/Attribute_ReflectionAttribute.qbl                                                                       |    7 
 _Main/BL/Type_PriorityResult/StaticMethod_GetDetailsValue.qbl                                                                        |   79 ++++++++
 _Main/BL/Type_PriorityResult/StaticMethod_GetRemindFormula.qbl                                                                       |   24 ++
 _Main/BL/Type_FilllingCapacityOrderScheme/StaticMethod_CreateFillingCapacityOrderScheme.qbl                                          |    3 
 _Main/BL/Type_PriorityResult/Attribute_CustomerOrderID.qbl                                                                           |    7 
 _Main/UI/MacroPlannerWebApp/Component_DialogBusinessType/Method_ClickBtnOk.def                                                       |    3 
 _Main/BL/Type_CustomerOrder/Attribute_BusinessType.qbl                                                                               |    8 
 27 files changed, 483 insertions(+), 21 deletions(-)

diff --git a/_Main/BL/KnowledgeBaseDomain_MacroPlanner/KnowledgeBase_Knowledge_MP/_ROOT_KnowledgeBase_Knowledge_MP.qbl b/_Main/BL/KnowledgeBaseDomain_MacroPlanner/KnowledgeBase_Knowledge_MP/_ROOT_KnowledgeBase_Knowledge_MP.qbl
new file mode 100644
index 0000000..ea0a67e
--- /dev/null
+++ b/_Main/BL/KnowledgeBaseDomain_MacroPlanner/KnowledgeBase_Knowledge_MP/_ROOT_KnowledgeBase_Knowledge_MP.qbl
@@ -0,0 +1,6 @@
+Quintiq file version 2.0
+#root
+#parent: #root
+KnowledgeBase Knowledge_MP #extension
+{
+}
diff --git a/_Main/BL/Type_BusinessType/StaticMethod_CreateData.qbl b/_Main/BL/Type_BusinessType/StaticMethod_CreateData.qbl
index f82bfcb..afab52f 100644
--- a/_Main/BL/Type_BusinessType/StaticMethod_CreateData.qbl
+++ b/_Main/BL/Type_BusinessType/StaticMethod_CreateData.qbl
@@ -21,6 +21,9 @@
     // 濡傛灉涓嶅瓨鍦ㄥ垯娣诲姞
     if( not checkExist ){
       owner.BusinessType(relnew,BusinessTypeName := businessName);
+      
+      // 鍒濆鍖栦紭鍏堢骇鍥犲瓙鏁版嵁
+      PriorityFactor::InitData( macroPlan,businessName);
     }
   *]
 }
diff --git a/_Main/BL/Type_CustomerAndForecastOrder/Attribute_CustomerOrderID.qbl b/_Main/BL/Type_CustomerAndForecastOrder/Attribute_CustomerOrderID.qbl
new file mode 100644
index 0000000..19d7605
--- /dev/null
+++ b/_Main/BL/Type_CustomerAndForecastOrder/Attribute_CustomerOrderID.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute CustomerOrderID
+{
+  #keys: '3[414382.0.554303146][414382.0.554303145][414382.0.554303147]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerAndForecastOrder/Attribute_ForecastID.qbl b/_Main/BL/Type_CustomerAndForecastOrder/Attribute_ForecastID.qbl
new file mode 100644
index 0000000..d3d12e5
--- /dev/null
+++ b/_Main/BL/Type_CustomerAndForecastOrder/Attribute_ForecastID.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ForecastID
+{
+  #keys: '3[414382.0.554303156][414382.0.554303155][414382.0.554303157]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerAndForecastOrder/StaticMethod_RefreshData.qbl b/_Main/BL/Type_CustomerAndForecastOrder/StaticMethod_RefreshData.qbl
new file mode 100644
index 0000000..f3c1564
--- /dev/null
+++ b/_Main/BL/Type_CustomerAndForecastOrder/StaticMethod_RefreshData.qbl
@@ -0,0 +1,46 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod RefreshData (
+  MacroPlan owner,
+  GlobalOTDTable globalOTDTable
+)
+{
+  TextBody:
+  [*
+    // NBoTk Sep-26-2023 (created)
+    
+    // 鑾峰彇宸茬粡瀛樺湪 customerOrderID 鍜宖orecastID
+    customerOrderIDs := selectvalues( owner,CustomerAndForecastOrder,c,
+                                      c.CustomerOrderID() <> '',
+                                      c.CustomerID()
+                                      );
+    
+    forecastIDs := selectvalues( owner,CustomerAndForecastOrder,c,
+                                      c.ForecastID() <> '',
+                                      c.ForecastID()
+                                      );
+    
+    
+    // 浠庢暟鎹箹 Global_MappingCustomerOrder Global_MappingForecast 涓幏鍙栨柊鐨勮鍗曟暟鎹�
+    
+    traverse( globalOTDTable,Global_MappingCustomOrder,cus)
+    {
+        if(customerOrderIDs.Find( cus.ID()) = -1 )
+        {
+             owner.CustomerAndForecastOrder(relnew,OrderID := cus.OrderID(),ProductID := cus.ProductID(),BusinessType := cus.BusinessType(),Customer := cus.Customer(),CustomerID := cus.CustomerID(),
+                                    Quantity := cus.Quantity(),UnitOfMeasureName := cus.UnitOfMeasureName(),DemandDate := cus.OrderDate()
+                                    );
+        }    
+    }
+    
+    traverse( globalOTDTable,Global_MappingForecast,forecast)
+    {
+        if(forecastIDs.Find( forecast.ID()) = -1 )
+        {
+             owner.CustomerAndForecastOrder(relnew,ProductID := forecast.ProductID(),BusinessType := forecast.BusinessType(),
+                                    Quantity := forecast.Quantity(),UnitOfMeasureName := forecast.UnitOfMeasureName(),DemandDate := forecast.EndDate()
+                                    );
+        }    
+    }
+  *]
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_BusinessType.qbl b/_Main/BL/Type_CustomerOrder/Attribute_BusinessType.qbl
new file mode 100644
index 0000000..a39b026
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_BusinessType.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute BusinessType
+{
+  #keys: '3[414382.0.554303217][414382.0.554303216][414382.0.554303218]'
+  Description: '浜嬩笟閮�'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_CustomerPolicy.qbl b/_Main/BL/Type_CustomerOrder/Attribute_CustomerPolicy.qbl
new file mode 100644
index 0000000..6647d7a
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_CustomerPolicy.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute CustomerPolicy
+{
+  #keys: '3[414382.0.554014841][414382.0.554014840][414382.0.554014842]'
+  Description: '瀹㈡埛绛栫暐'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_IsAvailable.qbl b/_Main/BL/Type_CustomerOrder/Attribute_IsAvailable.qbl
new file mode 100644
index 0000000..1a6ca55
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_IsAvailable.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute IsAvailable
+{
+  #keys: '3[414382.0.554303237][414382.0.554303236][414382.0.554303238]'
+  Description: '璁㈠崟鏄惁鍙備笌璁″垝'
+  ValueType: Boolean
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_OrderTime.qbl b/_Main/BL/Type_CustomerOrder/Attribute_OrderTime.qbl
new file mode 100644
index 0000000..e89a41d
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_OrderTime.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute OrderTime
+{
+  #keys: '3[414382.0.554303277][414382.0.554303276][414382.0.554303278]'
+  Description: '璁㈠崟涓嬪崟鏃堕棿'
+  ValueType: Date
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_OrderType.qbl b/_Main/BL/Type_CustomerOrder/Attribute_OrderType.qbl
new file mode 100644
index 0000000..4efd905
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_OrderType.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute OrderType
+{
+  #keys: '3[414382.0.554303227][414382.0.554303226][414382.0.554303228]'
+  Description: '璁㈠崟绫诲瀷'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_ProductGrade.qbl b/_Main/BL/Type_CustomerOrder/Attribute_ProductGrade.qbl
new file mode 100644
index 0000000..76e256b
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_ProductGrade.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ProductGrade
+{
+  #keys: '3[414382.0.554303247][414382.0.554303246][414382.0.554303248]'
+  Description: '浜у搧绛夌骇'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_SegmentPriority.qbl b/_Main/BL/Type_CustomerOrder/Attribute_SegmentPriority.qbl
new file mode 100644
index 0000000..6f488d6
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_SegmentPriority.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute SegmentPriority
+{
+  #keys: '3[414382.0.554303257][414382.0.554303256][414382.0.554303258]'
+  Description: '缁嗗垎甯傚満浼樺厛绾�'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerOrder/Attribute_SheetProfitability.qbl b/_Main/BL/Type_CustomerOrder/Attribute_SheetProfitability.qbl
new file mode 100644
index 0000000..726b8ab
--- /dev/null
+++ b/_Main/BL/Type_CustomerOrder/Attribute_SheetProfitability.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute SheetProfitability
+{
+  #keys: '3[414382.0.554303267][414382.0.554303266][414382.0.554303268]'
+  Description: '澶у紶鐩堝埄姘村钩'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_FilllingCapacityOrderScheme/StaticMethod_CreateFillingCapacityOrderScheme.qbl b/_Main/BL/Type_FilllingCapacityOrderScheme/StaticMethod_CreateFillingCapacityOrderScheme.qbl
index e0aa42b..3f0ea88 100644
--- a/_Main/BL/Type_FilllingCapacityOrderScheme/StaticMethod_CreateFillingCapacityOrderScheme.qbl
+++ b/_Main/BL/Type_FilllingCapacityOrderScheme/StaticMethod_CreateFillingCapacityOrderScheme.qbl
@@ -34,8 +34,7 @@
     salesSegmentName := salesSegmentNameList.Concatenate( ",")
     
     schemeDate := Date::Today();
-    
-    filllingCapacityOrderScheme := owner.FilllingCapacityOrderScheme(relnew,SchemeName := schemeName,SchemeDate := schemeDate,BusinessType := businessType,Customer := customer,CustomerID := customerID,
+    owner.FilllingCapacityOrderScheme(relnew,SchemeName := schemeName,SchemeDate := schemeDate,BusinessType := businessType,Customer := customer,CustomerID := customerID,
                                                                       SalesSegmentName := salesSegmentName);
     
     
diff --git a/_Main/BL/Type_PriorityFactor/Attribute_ReflectionAttribute.qbl b/_Main/BL/Type_PriorityFactor/Attribute_ReflectionAttribute.qbl
new file mode 100644
index 0000000..3f5a69d
--- /dev/null
+++ b/_Main/BL/Type_PriorityFactor/Attribute_ReflectionAttribute.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ReflectionAttribute
+{
+  #keys: '3[414382.0.554303396][414382.0.554303395][414382.0.554303397]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_PriorityFactor/Attribute_ReflectionType.qbl b/_Main/BL/Type_PriorityFactor/Attribute_ReflectionType.qbl
new file mode 100644
index 0000000..49b163b
--- /dev/null
+++ b/_Main/BL/Type_PriorityFactor/Attribute_ReflectionType.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ReflectionType
+{
+  #keys: '3[414382.0.554014806][414382.0.554014805][414382.0.554014807]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_PriorityFactorDetails/StaticMethod_InitData.qbl b/_Main/BL/Type_PriorityFactorDetails/StaticMethod_InitData.qbl
index c6c69c4..01917f6 100644
--- a/_Main/BL/Type_PriorityFactorDetails/StaticMethod_InitData.qbl
+++ b/_Main/BL/Type_PriorityFactorDetails/StaticMethod_InitData.qbl
@@ -15,15 +15,46 @@
         isBusinessType := true; 
     }
     
-    priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 5,
+    if( priorityFactor.Name() = "澶у紶鐩堝埄姘村钩" )
+    {
+          priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 5,
                                             IsRange := false,GradingName := "澶х泩",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
-    priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 3,
-                                            IsRange := false,GradingName := "灏忕泩",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
-    priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 0,
-                                            IsRange := false,GradingName := "鎸佸钩",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
-    priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := -3,
-                                            IsRange := false,GradingName := "灏忎簭",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
-    priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := -5,
-                                            IsRange := false,GradingName := "澶т簭",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 3,
+                                                IsRange := false,GradingName := "灏忕泩",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 0,
+                                                IsRange := false,GradingName := "鎸佸钩",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := -3,
+                                                IsRange := false,GradingName := "灏忎簭",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := -5,
+                                                IsRange := false,GradingName := "澶т簭",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+    }
+    
+    if( priorityFactor.Name() = "瀹㈡埛绛栫暐" )
+    {
+          priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 5,
+                                            IsRange := false,GradingName := "81%鈮鈮�100%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 4,
+                                                IsRange := false,GradingName := "61%鈮鈮�80%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 3,
+                                                IsRange := false,GradingName := "41%鈮鈮�60%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 2,
+                                                IsRange := false,GradingName := "21%鈮鈮�40%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 1,
+                                                IsRange := false,GradingName := "1%鈮鈮�20%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+    }
+    
+    if( priorityFactor.Name() = "瀹㈡埛绛夌骇" )
+    {
+          priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 5,
+                                            IsRange := false,GradingName := "81%鈮鈮�100%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 4,
+                                                IsRange := false,GradingName := "61%鈮鈮�80%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 3,
+                                                IsRange := false,GradingName := "41%鈮鈮�60%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 2,
+                                                IsRange := false,GradingName := "21%鈮鈮�40%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+        priorityFactor.PriorityFactorDetails(relnew,BusinessType := priorityFactor.BusinessType(), IsBusinessType := isBusinessType,GradeTarget := 1,
+                                                IsRange := false,GradingName := "1%鈮鈮�20%",RangeMin := 0.0,RangeMax := 0.0,PriorityFactorName := priorityFactor.Name());
+    }
   *]
 }
diff --git a/_Main/BL/Type_PriorityResult/Attribute_CustomerOrderID.qbl b/_Main/BL/Type_PriorityResult/Attribute_CustomerOrderID.qbl
new file mode 100644
index 0000000..f65a510
--- /dev/null
+++ b/_Main/BL/Type_PriorityResult/Attribute_CustomerOrderID.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute CustomerOrderID
+{
+  #keys: '3[414382.0.554015006][414382.0.554015005][414382.0.554015007]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_PriorityResult/StaticMethod_CalculateBracketScore.qbl b/_Main/BL/Type_PriorityResult/StaticMethod_CalculateBracketScore.qbl
new file mode 100644
index 0000000..90f1891
--- /dev/null
+++ b/_Main/BL/Type_PriorityResult/StaticMethod_CalculateBracketScore.qbl
@@ -0,0 +1,18 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CalculateBracketScore (
+  String calcStr,
+  CustomerOrder customerOrder,
+  String businessType,
+  MacroPlan macroPlan
+) as Real
+{
+  Description: '璁$畻鍏紡涓嫭鍙峰唴鐨勬暟鎹�'
+  TextBody:
+  [*
+    // NBoTk Sep-26-2023 (created)
+    
+    
+    return PriorityResult::CalculateScore( calcStr,customerOrder,businessType,macroPlan,0.0);
+  *]
+}
diff --git a/_Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl b/_Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl
new file mode 100644
index 0000000..22b6924
--- /dev/null
+++ b/_Main/BL/Type_PriorityResult/StaticMethod_CalculateScore.qbl
@@ -0,0 +1,88 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CalculateScore (
+  String formula,
+  CustomerOrder customerOrder,
+  String businessType,
+  MacroPlan macroPlan,
+  Real lastScore
+) as Real
+{
+  TextBody:
+  [*
+    // NBoTk Sep-26-2023 (created)
+    
+    score := 0.0;
+    remindFormula := formula;
+    
+    // 閬嶅巻浼樺厛绾у洜瀛愰厤缃�
+    
+    if( not remindFormula = '' )
+    {
+            // 浠庤捣濮嬩綅缃紑濮嬪尮閰� 
+            if(remindFormula.StartsWith( "+" ))
+            {
+                remindFormula := remindFormula.SubString( 1,remindFormula.Length());
+                score := PriorityResult::GetDetailsValue( customerOrder,remindFormula,macroPlan);
+                score := lastScore + score;
+                
+                // 鎴彇鎺夊凡缁忚绠楃殑浼樺厛绾у洜瀛� 閫掑綊璁$畻
+                remindFormula := PriorityResult::GetRemindFormula( remindFormula,macroPlan);
+                PriorityResult::CalculateScore( remindFormula,customerOrder,businessType,macroPlan,score);
+            }
+            else if( remindFormula.StartsWith( "-" ))
+            {
+                remindFormula := remindFormula.SubString( 1,remindFormula.Length());
+                score := PriorityResult::GetDetailsValue( customerOrder,remindFormula,macroPlan);
+                score := lastScore - score;
+                
+                // 鎴彇鎺夊凡缁忚绠楃殑浼樺厛绾у洜瀛� 閫掑綊璁$畻
+                remindFormula := PriorityResult::GetRemindFormula( remindFormula,macroPlan);
+                PriorityResult::CalculateScore( remindFormula,customerOrder,businessType,macroPlan,score);
+            }
+            else if( remindFormula.StartsWith( "*" ) )
+            {
+                remindFormula := remindFormula.SubString( 1,remindFormula.Length());
+                score := PriorityResult::GetDetailsValue( customerOrder,remindFormula,macroPlan);
+                score := lastScore * score;
+                
+                // 鎴彇鎺夊凡缁忚绠楃殑浼樺厛绾у洜瀛� 閫掑綊璁$畻
+                remindFormula := PriorityResult::GetRemindFormula( remindFormula,macroPlan);
+                PriorityResult::CalculateScore( remindFormula,customerOrder,businessType,macroPlan,score);
+            }
+            else if( remindFormula.StartsWith( "/" ) )
+            {
+                remindFormula := remindFormula.SubString( 1,remindFormula.Length());
+                score := PriorityResult::GetDetailsValue( customerOrder,remindFormula,macroPlan);
+                score := lastScore / score;
+                
+                // 鎴彇鎺夊凡缁忚绠楃殑浼樺厛绾у洜瀛� 閫掑綊璁$畻
+                remindFormula := PriorityResult::GetRemindFormula( remindFormula,macroPlan);
+                PriorityResult::CalculateScore( remindFormula,customerOrder,businessType,macroPlan,score);
+            }
+            else if( remindFormula.StartsWith( "(" ) )
+            {
+                // 鎵惧埌绗竴涓粨鏉熺殑 )
+                // 璁$畻鎷彿涓殑鍐呭
+                rightBracket := remindFormula.FindString( ")",0);
+                calcStr := remindFormula.SubString( 1,rightBracket);
+                PriorityResult::CalculateBracketScore(calcStr,customerOrder,businessType,macroPlan);
+                
+                // 鎴彇 ) 鍚庣殑瀛楃缁х画杩涜璁$畻
+                remindFormula := remindFormula.SubString( rightBracket,remindFormula.Length());
+            }
+            else
+            {
+                // 涓嶆槸绗﹀彿 鐩存帴鑾峰彇璁$畻鍚庣殑鏁板��
+                score := PriorityResult::GetDetailsValue( customerOrder,remindFormula,macroPlan);
+              
+                // 鎴彇鎺夊凡缁忚绠楃殑浼樺厛绾у洜瀛� 閫掑綊璁$畻
+                remindFormula := PriorityResult::GetRemindFormula( remindFormula,macroPlan);
+                PriorityResult::CalculateScore( remindFormula,customerOrder,businessType,macroPlan,score);
+            }
+    }
+    
+    // 娌℃湁鍖归厤 鍏紡璁$畻瀹屾垚
+    return lastScore;
+  *]
+}
diff --git a/_Main/BL/Type_PriorityResult/StaticMethod_GetDetailsValue.qbl b/_Main/BL/Type_PriorityResult/StaticMethod_GetDetailsValue.qbl
new file mode 100644
index 0000000..ba8486e
--- /dev/null
+++ b/_Main/BL/Type_PriorityResult/StaticMethod_GetDetailsValue.qbl
@@ -0,0 +1,79 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod GetDetailsValue (
+  CustomerOrder customerOrder,
+  String formula,
+  MacroPlan macroPlan
+) as Real
+{
+  TextBody:
+  [*
+    // NBoTk Sep-26-2023 (created)
+    
+    value := 0.0;
+    
+    priorityFactor := null( PriorityFactor);
+    
+    traverse( macroPlan,PriorityFactor,p)
+    {   
+         if( formula.StartsWith( p.Name()) )
+         {
+            priorityFactor := p;
+         }
+    }
+    
+    if( "瀹㈡埛绛栫暐" =  priorityFactor.Name())
+    {
+         obj := selectobject( priorityFactor,PriorityFactorDetails,p , p.PriorityFactorName() = "瀹㈡埛绛栫暐" and p.GradingName() = customerOrder.CustomerPolicy());
+         value := priorityFactor.Coefficient() * obj.GradeTarget();
+    }
+    
+    if( "澶у紶鐩堝埄姘村钩" =  priorityFactor.Name())
+    {
+         obj := selectobject( priorityFactor,PriorityFactorDetails,p , p.PriorityFactorName() = "澶у紶鐩堝埄姘村钩" and  p.GradingName() = customerOrder.SheetProfitability());
+         value := priorityFactor.Coefficient() * obj.GradeTarget();
+    }
+    
+    if( "DOI" =  priorityFactor.Name())
+    {
+         // DOI鏁版嵁鏆傛椂缂哄皯
+         value := 1;
+    }
+    
+    if( "DSI" =  priorityFactor.Name())
+    {
+         // DOI鏁版嵁鏆傛椂缂哄皯
+         value := 1;
+    }
+    
+    if( "缁嗗垎甯傚満绛夌骇" =  priorityFactor.Name())
+    {
+         obj := selectobject( priorityFactor,PriorityFactorDetails,p , p.PriorityFactorName() = "缁嗗垎甯傚満绛夌骇" and p.GradingName() = customerOrder.SegmentPriority());
+         value := priorityFactor.Coefficient() * obj.GradeTarget();
+    }
+    
+    if( "闇�姹傜被鍨�" =  priorityFactor.Name())
+    {     
+        // 鏈夐娴� 鏃犻娴� 绾娴�
+         obj := selectobject( priorityFactor,PriorityFactorDetails,p,p.GradingName() = customerOrder.OrderType());
+         value := priorityFactor.Coefficient() * obj.GradeTarget();
+    }
+    
+    if( "瀹㈡埛绛夌骇" =  priorityFactor.Name())
+    {
+         // 閫氳繃鏁版嵁婀栬绠楀鎴风瓑绾�
+         value := 1;
+    }
+    
+    if( "璁㈠崟涓嬪崟鏃堕棿" =  priorityFactor.Name())
+    {
+         // 涓嬪崟鏃堕棿
+         orderTime := customerOrder.OrderTime();
+         days := orderTime.TotalInDays() - customerOrder.EndDate().TotalInDays();
+         obj := selectobject( priorityFactor,PriorityFactorDetails,p , p.PriorityFactorName() = "璁㈠崟涓嬪崟鏃堕棿" and days >= [Number]p.GradingName());
+         value := priorityFactor.Coefficient() * obj.GradeTarget();
+    }
+    
+    return value;
+  *]
+}
diff --git a/_Main/BL/Type_PriorityResult/StaticMethod_GetRemindFormula.qbl b/_Main/BL/Type_PriorityResult/StaticMethod_GetRemindFormula.qbl
new file mode 100644
index 0000000..7c211d6
--- /dev/null
+++ b/_Main/BL/Type_PriorityResult/StaticMethod_GetRemindFormula.qbl
@@ -0,0 +1,24 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod GetRemindFormula (
+  String formula,
+  MacroPlan macroPlan
+) as String
+{
+  TextBody:
+  [*
+    // NBoTk Sep-26-2023 (created)
+    
+    str := "";
+    
+    traverse( macroPlan,PriorityFactor,p)
+    {  
+         if( formula.StartsWith( p.Name()) )
+         {
+              str := formula.SubString( 0 + p.Name().Length(),formula.Length());
+         }
+    }
+    
+    return str;
+  *]
+}
diff --git a/_Main/BL/Type_PriorityResult/StaticMethod_calculatePriorityResult.qbl b/_Main/BL/Type_PriorityResult/StaticMethod_calculatePriorityResult.qbl
new file mode 100644
index 0000000..4021601
--- /dev/null
+++ b/_Main/BL/Type_PriorityResult/StaticMethod_calculatePriorityResult.qbl
@@ -0,0 +1,72 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CalculatePriorityResult (
+  CustomerOrders customerOrders,
+  String priorityPolicyName,
+  String businessType,
+  MacroPlan macroPlan
+)
+{
+  TextBody:
+  [*
+    // NBoTk Sep-26-2023 (created)
+    
+    // 璁$畻瀹㈡埛璁㈠崟鐨勪紭鍏堢骇寰楀垎 鍥炲~鏉冮噸鏁版嵁 鐢熸垚鏂扮殑Priority鏄庣粏鏁版嵁
+    
+    traverse( customerOrders,Elements,e)
+    {
+         // 浜嬩笟閮ㄤ俊鎭�
+         businessType := e.BusinessType();
+         
+         // 鑾峰彇瀵瑰簲浜嬩笟閮ㄨ绠楀叕寮�
+         priorityPolicys := selectobject( macroPlan,PriorityPolicy,p,p.BusinessType() = businessType and p.Name() = priorityPolicyName);
+         formula := priorityPolicys.Formula();
+         
+         // 閫掑綊澶勭悊璁$畻鍏紡 鑾峰彇褰撳墠璁㈠崟鐨勫緱鍒�
+         value := PriorityResult::CalculateScore( formula,e,businessType,macroPlan,0.0);
+         
+         // 鐢熸垚浼樺厛绾у洜瀛愯窇鍒嗙粨鏋�
+         priorityResult := macroPlan.PriorityResult(relnew,CustomerOrderID := e.ID(),BusinessType := businessType,Customer := e.CustomerName(),CustomerID := e.CustomerID(),
+                                                     DemandDate := e.EndDate(),ProductID := e.ProductID(),Quantity := e.Quantity(),SalesSegmentName := e.SalesSegmentName(),
+                                                     StockingPointID := e.StockingPointID(),UnitOfMeasureName := e.UnitOfMeasureName()
+                                                     );
+          
+         // 鍒ゆ柇鏄泦鍥� 杩樻槸浜嬩笟閮�
+         if( businessType.FindString( "闆嗗洟",0 ) <> -1)
+         {
+              priorityResult.PriorityResultGroupDetail( relnew,BusinessType := businessType,Customer := e.CustomerName(),CustomerID := e.CustomerID(),
+                                                        DemandDate := e.EndDate(),PriorityPolicyName := priorityPolicyName,PriorityResultScore := value,
+                                                        Quantity := e.Quantity(),SalesSegmentName := e.SalesSegmentName(),StockingPointID := e.StockingPointID(),
+                                                        UnitOfMeasureName := e.UnitOfMeasureName(),PriorityTotalScore := value
+                                                        );
+         }
+         else
+         {
+               priorityResult.PriorityResultBusinessTypeDetail( relnew,BusinessType := businessType,Customer := e.CustomerName(),CustomerID := e.CustomerID(),
+                                                                DemandDate := e.EndDate(),PriorityPolicyName := priorityPolicyName,PriorityResultScore := value,
+                                                                Quantity := e.Quantity(),SalesSegmentName := e.SalesSegmentName(),StockingPointID := e.StockingPointID(),
+                                                                UnitOfMeasureName := e.UnitOfMeasureName(),PriorityTotalScore := value 
+                                                                );      
+         }                                                                                                                                       
+    }
+    
+    // 浼樺厛绾у洜瀛愬鐞嗗畬鎴愬悗 鎺掑簭鍥炲~鏁版嵁
+    resultList := selectsortedset( macroPlan,PriorityResult,result,
+                                   true,
+                                   result.PriorityResultScore()
+                                   )
+    
+    priorityValue := 1;
+    traverse( resultList,Elements,e)
+    {
+        obj := selectobject( customerOrders,Elements,order,
+                             order.ID() = e.CustomerOrderID()
+                             );
+        obj.PriorityName([String]priorityValue);
+        
+        // 鍒涘缓浼樺厛绾ф暟鎹�
+        macroPlan.Priority(relnew,Weight := priorityValue,Name := [String]priorityValue);
+        priorityValue := priorityValue + 1;
+    }
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogBusinessType/Method_ClickBtnOk.def b/_Main/UI/MacroPlannerWebApp/Component_DialogBusinessType/Method_ClickBtnOk.def
index 7c1b15d..4172fa3 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogBusinessType/Method_ClickBtnOk.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogBusinessType/Method_ClickBtnOk.def
@@ -15,9 +15,6 @@
     businessType := DataHolderBusinessType.Data().BusinessTypeName();
     DataHolderBusinessType.Data().Commit();
     
-    // PriorityFactor
-    PriorityFactor::InitData( MacroPlan,businessType);
-    
     this.Close();
   *]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Component_listContextMenuCustomerAndFillingCapacityOrder.def b/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Component_listContextMenuCustomerAndFillingCapacityOrder.def
index 01848c5..8ba1423 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Component_listContextMenuCustomerAndFillingCapacityOrder.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Component_listContextMenuCustomerAndFillingCapacityOrder.def
@@ -16,7 +16,7 @@
         Title: 'Filling'
       ]
     }
-    Component MenuTest
+    Component MenuRefresh
     {
       #keys: '[414382.0.415603149]'
       BaseType: 'WebMenu'
@@ -24,7 +24,7 @@
       [
         Image: 'ADD2'
         Taborder: 4
-        Title: 'Test'
+        Title: '鍒锋柊'
       ]
     }
   ]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Response_ListCustomerAndFillingCapacityOrder_MenuTest_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Response_ListCustomerAndFillingCapacityOrder_MenuRefresh_OnClick.def
similarity index 70%
rename from _Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Response_ListCustomerAndFillingCapacityOrder_MenuTest_OnClick.def
rename to _Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Response_ListCustomerAndFillingCapacityOrder_MenuRefresh_OnClick.def
index f292299..aba413a 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Response_ListCustomerAndFillingCapacityOrder_MenuTest_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFillingCapacityScheme/Response_ListCustomerAndFillingCapacityOrder_MenuRefresh_OnClick.def
@@ -1,17 +1,17 @@
 Quintiq file version 2.0
 #parent: ListCustomerAndFillingCapacityOrder
-Response OnClick () id:Response_ListCustomerAndFillingCapacityOrder_MenuTest_OnClick
+Response OnClick () id:Response_ListCustomerAndFillingCapacityOrder_MenuRefresh_OnClick
 {
   #keys: '[414382.0.415724061]'
   CanBindMultiple: false
   DefinitionID => /ListCustomerAndFillingCapacityOrder/Responsedef_ListCustomerAndFillingCapacityOrder_WebMenu_OnClick
-  GroupServerCalls: true
-  Initiator: 'MenuTest'
+  Initiator: 'MenuRefresh'
   QuillAction
   {
     Body:
     [*
-      CustomerAndForecastOrder::CreateTestData( MacroPlan);
+      CustomerAndForecastOrder::RefreshData(  MacroPlan,GlobalOTDTable);
     *]
+    GroupServerCalls: false
   }
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityPolicy/Response_ListPriorityPolicy_MenuDelete_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormPriorityPolicy/Response_ListPriorityPolicy_MenuDelete_OnClick.def
index 59bd67d..96d7545 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormPriorityPolicy/Response_ListPriorityPolicy_MenuDelete_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormPriorityPolicy/Response_ListPriorityPolicy_MenuDelete_OnClick.def
@@ -13,7 +13,7 @@
     Body:
     [*
       
-          selection.Delete();
+      selection.Delete();
     *]
     GroupServerCalls: false
   }

--
Gitblit v1.9.3