From 52bd9a90e6e31eb2c458447fd7fec4e8f99a0fe7 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期一, 28 十月 2024 11:36:35 +0800
Subject: [PATCH] 修改班次信息的计算逻辑

---
 _Main/BL/Type_DispatchShiftSchedulingInformation/Method_CalculateLineQuantity.qbl                   |   11 +
 _Main/BL/Type_DispatchShiftSchedulingInformation/_ROOT_Type_DispatchShiftSchedulingLine.qbl         |   10 +
 _Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductID.qbl                            |    8 +
 _Main/BL/Relations/Relation_DispatchShiftSchedulingProduct_DispatchShiftSchedulingLine_Dispatch.qbl |   23 +++
 _Main/BL/Type_DispatchShiftSchedulingInformation/Function_CalcLineQuantity.qbl                      |   13 +
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl                          |  220 +++++++++++++++++++++++-------
 _Main/BL/Type_DispatchShiftSchedulingInformationDetail/_ROOT_Type_DispatchShiftSchedulingDetail.qbl |    9 +
 _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineID.qbl                               |    2 
 _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftStartDate.qbl                 |    2 
 _Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductionQuantity.qbl                   |    8 +
 /dev/null                                                                                           |   10 -
 _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl                            |    2 
 _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftVolume.qbl                    |    2 
 _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineQuantity.qbl                         |    8 +
 _Main/BL/Relations/Relation_DispatchShiftSchedulingDetail_DispatchShiftSchedulingProduct_Dispat.qbl |   23 +++
 _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl                            |    2 
 _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftEndDate.qbl                   |    2 
 _Main/BL/Type_DispatchShiftProductionInformation/_ROOT_Type_DispatchShiftSchedulingProduct.qbl      |   10 +
 _Main/BL/Relations/Relation_DispatchShiftSchedulingLine_RecycleBin_RecycleBin_DispatchShiftSche.qbl |    6 
 _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_SingleShiftName.qbl                |    2 
 _Main/BL/Type_DispatchShiftSchedulingInformationDetail/DefaultValue_SingleShiftName.qbl             |    2 
 _Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ShiftName.qbl                         |    2 
 22 files changed, 302 insertions(+), 75 deletions(-)

diff --git a/_Main/BL/Relations/Relation_DispatchShiftSchedulingDetail_DispatchShiftSchedulingProduct_Dispat.qbl b/_Main/BL/Relations/Relation_DispatchShiftSchedulingDetail_DispatchShiftSchedulingProduct_Dispat.qbl
new file mode 100644
index 0000000..a6bd2e2
--- /dev/null
+++ b/_Main/BL/Relations/Relation_DispatchShiftSchedulingDetail_DispatchShiftSchedulingProduct_Dispat.qbl
@@ -0,0 +1,23 @@
+Quintiq file version 2.0
+#parent: #root
+Relation DispatchShiftSchedulingDetail_DispatchShiftSchedulingProduct_DispatchShiftSchedulingProduct_DispatchShiftSchedulingDetail
+{
+  #keys: '1[414996.1.172754837]'
+  DefaultRelationStrategy
+  {
+  }
+  RelationSide.LeftSide DispatchShiftSchedulingProduct
+  {
+    #keys: '3[414996.1.172754839][414996.1.172754838][414996.1.172754840]'
+    Cardinality: '0to1'
+    ObjectDefinition: DispatchShiftSchedulingDetail
+    OwningSide: 'Reference'
+  }
+  RelationSide.RightSide DispatchShiftSchedulingDetail
+  {
+    #keys: '3[414996.1.172754842][414996.1.172754841][414996.1.172754843]'
+    Cardinality: '1toN'
+    ObjectDefinition: DispatchShiftSchedulingProduct
+    OwningSide: 'Owned'
+  }
+}
diff --git a/_Main/BL/Relations/Relation_DispatchShiftSchedulingInformation_RecycleBin_RecycleBin_DispatchSh.qbl b/_Main/BL/Relations/Relation_DispatchShiftSchedulingLine_RecycleBin_RecycleBin_DispatchShiftSche.qbl
similarity index 66%
rename from _Main/BL/Relations/Relation_DispatchShiftSchedulingInformation_RecycleBin_RecycleBin_DispatchSh.qbl
rename to _Main/BL/Relations/Relation_DispatchShiftSchedulingLine_RecycleBin_RecycleBin_DispatchShiftSche.qbl
index 6b167c2..96361e5 100644
--- a/_Main/BL/Relations/Relation_DispatchShiftSchedulingInformation_RecycleBin_RecycleBin_DispatchSh.qbl
+++ b/_Main/BL/Relations/Relation_DispatchShiftSchedulingLine_RecycleBin_RecycleBin_DispatchShiftSche.qbl
@@ -1,6 +1,6 @@
 Quintiq file version 2.0
 #parent: #root
-Relation DispatchShiftSchedulingInformation_RecycleBin_RecycleBin_DispatchShiftSchedulingInformation
+Relation DispatchShiftSchedulingLine_RecycleBin_RecycleBin_DispatchShiftSchedulingLine
 {
   #keys: '1[414996.1.67010175]'
   DefaultRelationStrategy
@@ -10,10 +10,10 @@
   {
     #keys: '3[414996.1.67010177][414996.1.67010176][414996.1.67010178]'
     Cardinality: '0to1'
-    ObjectDefinition: DispatchShiftSchedulingInformation
+    ObjectDefinition: DispatchShiftSchedulingLine
     OwningSide: 'Reference'
   }
-  RelationSide.RightSide DispatchShiftSchedulingInformation
+  RelationSide.RightSide DispatchShiftSchedulingLine
   {
     #keys: '3[414996.1.67010180][414996.1.67010179][414996.1.67010181]'
     Cardinality: '1toN'
diff --git a/_Main/BL/Relations/Relation_DispatchShiftSchedulingProduct_DispatchShiftSchedulingLine_Dispatch.qbl b/_Main/BL/Relations/Relation_DispatchShiftSchedulingProduct_DispatchShiftSchedulingLine_Dispatch.qbl
new file mode 100644
index 0000000..f940f60
--- /dev/null
+++ b/_Main/BL/Relations/Relation_DispatchShiftSchedulingProduct_DispatchShiftSchedulingLine_Dispatch.qbl
@@ -0,0 +1,23 @@
+Quintiq file version 2.0
+#parent: #root
+Relation DispatchShiftSchedulingProduct_DispatchShiftSchedulingLine_DispatchShiftSchedulingLine_DispatchShiftSchedulingProduct
+{
+  #keys: '1[414996.1.172754796]'
+  DefaultRelationStrategy
+  {
+  }
+  RelationSide.LeftSide DispatchShiftSchedulingLine
+  {
+    #keys: '3[414996.1.172754798][414996.1.172754797][414996.1.172754799]'
+    Cardinality: '0to1'
+    ObjectDefinition: DispatchShiftSchedulingProduct
+    OwningSide: 'Reference'
+  }
+  RelationSide.RightSide DispatchShiftSchedulingProduct
+  {
+    #keys: '3[414996.1.172754801][414996.1.172754800][414996.1.172754802]'
+    Cardinality: '1toN'
+    ObjectDefinition: DispatchShiftSchedulingLine
+    OwningSide: 'Owned'
+  }
+}
diff --git a/_Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductID.qbl b/_Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductID.qbl
new file mode 100644
index 0000000..a50e866
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductID.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ProductID
+{
+  #keys: '3[414996.1.172754823][414996.1.172754822][414996.1.172754824]'
+  Description: '鐗╂枡鍙�'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductionQuantity.qbl b/_Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductionQuantity.qbl
new file mode 100644
index 0000000..5a0f9e3
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftProductionInformation/Attribute_ProductionQuantity.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ProductionQuantity
+{
+  #keys: '3[414996.1.172754827][414996.1.172754826][414996.1.172754828]'
+  Description: '浜у搧浜ч噺'
+  ValueType: Real
+}
diff --git a/_Main/BL/Type_DispatchShiftProductionInformation/_ROOT_Type_DispatchShiftSchedulingProduct.qbl b/_Main/BL/Type_DispatchShiftProductionInformation/_ROOT_Type_DispatchShiftSchedulingProduct.qbl
new file mode 100644
index 0000000..602ae0f
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftProductionInformation/_ROOT_Type_DispatchShiftSchedulingProduct.qbl
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+#root
+#parent: #DomainModel
+Type DispatchShiftSchedulingProduct
+{
+  #keys: '5[414996.1.172754790][414996.1.172754788][0.0.0][414996.1.172754789][414996.1.172754791]'
+  BaseType: Object
+  Description: '涓嬪彂鐝鎺掍骇淇℃伅 -- 浜у搧'
+  StructuredName: 'DispatchShiftSchedulingProducts'
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ProductLine.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineID.qbl
similarity index 87%
rename from _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ProductLine.qbl
rename to _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineID.qbl
index 979ff60..0917dd7 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ProductLine.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineID.qbl
@@ -1,6 +1,6 @@
 Quintiq file version 2.0
 #parent: #root
-Attribute ProductLine
+Attribute LineID
 {
   #keys: '3[414996.1.67010068][414996.1.67010067][414996.1.67010069]'
   Description: '浜х嚎'
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineQuantity.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineQuantity.qbl
new file mode 100644
index 0000000..d2008b4
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_LineQuantity.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute LineQuantity
+{
+  #keys: '3[414996.1.172754776][414996.1.172754775][414996.1.172754777]'
+  Description: '浜х嚎浜ч噺'
+  ValueType: Real
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_Product.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_Product.qbl
deleted file mode 100644
index 526f3b4..0000000
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_Product.qbl
+++ /dev/null
@@ -1,8 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Attribute Product
-{
-  #keys: '3[414996.1.67010096][414996.1.67010095][414996.1.67010097]'
-  Description: '鐗╂枡鍙�'
-  ValueType: String
-}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl
index 534f432..329dde9 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl
@@ -2,7 +2,7 @@
 #parent: #root
 Attribute ShiftDate
 {
-  #keys: '3[414996.1.67010092][414996.1.67010091][414996.1.67010093]'
+  #keys: '3[414996.1.172754933][414996.1.172754932][414996.1.172754934]'
   Description: '鐝鏃ユ湡'
   ValueType: Date
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl
index 547534f..a3f2670 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl
@@ -2,7 +2,7 @@
 #parent: #root
 Attribute ShiftName
 {
-  #keys: '3[414996.1.67010106][414996.1.67010105][414996.1.67010107]'
+  #keys: '3[414996.1.172754938][414996.1.172754937][414996.1.172754939]'
   Description: '鐝鍚嶇О'
   ValueType: String
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ProductLine.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ShiftName.qbl
similarity index 64%
rename from _Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ProductLine.qbl
rename to _Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ShiftName.qbl
index 498dbce..ae6b93a 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ProductLine.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ShiftName.qbl
@@ -2,5 +2,5 @@
 #parent: #root
 DefaultValue
 {
-  TargetAttribute: ProductLine
+  TargetAttribute: ShiftName
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Function_CalcLineQuantity.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Function_CalcLineQuantity.qbl
new file mode 100644
index 0000000..7a16f2c
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/Function_CalcLineQuantity.qbl
@@ -0,0 +1,13 @@
+Quintiq file version 2.0
+#parent: #root
+Function CalcLineQuantity
+{
+  TextBody:
+  [*
+    // Akari Oct-27-2024 (created)
+    
+    value := this.CalculateLineQuantity();
+    
+    this.LineQuantity( value );
+  *]
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Method_CalculateLineQuantity.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Method_CalculateLineQuantity.qbl
new file mode 100644
index 0000000..c5dde4a
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/Method_CalculateLineQuantity.qbl
@@ -0,0 +1,11 @@
+Quintiq file version 2.0
+#parent: #root
+Method CalculateLineQuantity () const declarative remote as Real
+{
+  TextBody:
+  [*
+    // Akari Oct-27-2024 (created)
+    value := sum( this,DispatchShiftSchedulingProduct,object,object.ProductionQuantity() );
+    return value;
+  *]
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
index 7ed2f4f..ff4dd5e 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
@@ -10,7 +10,7 @@
   TextBody:
   [*
     // Akari Sep-4-2024 (created)
-    owner.DispatchShiftSchedulingInformation( relflush );
+    owner.DispatchShiftSchedulingLine( relflush );
     macroPlan := offlinePlan.MacroPlan();
     now := DateTime::Now();
     
@@ -30,26 +30,19 @@
       unitIndexTree.Root().AddChild( unitHandle,i );
     }
     
-    // productLines := selectuniquevalues( offlinePlan,NewOfflinePlanRow,row,row.ProductionLine() );
-    productLinesQuantityNameValueTree := NamedValueTree::Create();
-    traverse( offlinePlan,NewOfflinePlanRow,row ){
-      traverse( row,NewOfflinePlanCell,cell, startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){
-        productLinesQuantityHandle := productLinesQuantityNameValueTree.GetHandle( row.ProductionLine() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() );
-        productLinesQuantity := guard( productLinesQuantityNameValueTree.Root().Child( productLinesQuantityHandle ),null( NamedValue ));
-        if( not isnull( productLinesQuantity )){
-          productLinesQuantity.SetValue( productLinesQuantity.GetValueAsReal() + cell.Quantity() );
-        }else{
-          productLinesQuantityNameValueTree.Root().AddChild( productLinesQuantityHandle, cell.Quantity() );
-        }
-      }
-    }
+    lines := construct( DispatchShiftSchedulingLines );
+    lineIndexTree := NamedValueTree::Create();
     
+    products := construct( DispatchShiftSchedulingProducts );
+    productIndexTree := NamedValueTree::Create();
+    
+    //productionDetails := construct( DispatchShiftSchedulingDetails );
+    //productionDetailIndexTree := NamedValueTree::Create();
     traverse( offlinePlan,NewOfflinePlanRow,row ){
-      productID := row.ProductID();
-      productLine := row.ProductionLine();
+      line := null( DispatchShiftSchedulingLine );
       factory := constnull( Unit );
       {
-        unitHandle := unitIndexTree.GetHandle( productLine );
+        unitHandle := unitIndexTree.GetHandle( row.ProductionLine() );
         unitIndex := guard( unitIndexTree.Root().Child( unitHandle ), null( NamedValue ));
         if( not isnull( unitIndex )){
           unit := units.Element( unitIndex.GetValueAsNumber() );
@@ -61,48 +54,169 @@
           }
           factory := temp2;
         }
+        
+        lineHandle := lineIndexTree.GetHandle( row.ProductionLine() );
+        lineIndex := guard( lineIndexTree.Root().Child( lineHandle ),null( NamedValue ));
+        if( isnull( lineIndex )){
+          line := owner.DispatchShiftSchedulingLine( relnew,ID := IDHolder::GetGUID(),LineID := row.ProductionLine() );
+          line.FactoryName( factory.Name() );
+          line.InterfaceTime( now );
+          line.VersionName( macroPlan.MDSMacroPlan().Description() );
+          lines.Add( line );
+          lineIndexTree.Root().AddChild( lineHandle,lines.Size() - 1 );
+        }else{
+          line := lines.Element( lineIndex.GetValueAsNumber() ); 
+        }
       }
+      
       traverse( row,NewOfflinePlanCell,cell, startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){
-        productLinesQuantityHandle := productLinesQuantityNameValueTree.GetHandle( row.ProductionLine() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() );
-        productLinesQuantity := guard( productLinesQuantityNameValueTree.Root().Child( productLinesQuantityHandle ).GetValueAsReal(),0.0 );
-        
-        shiftDate := cell.NewOfflinePlanColumn().StartDate();
-        shiftName := cell.ShiftPatternName();
-        shiftVolume := cell.Quantity();
-        shiftDayTime := constnull( ShiftDayTime );
+        product := null( DispatchShiftSchedulingProduct );
         {
-          shiftPatternHandle := shiftPatternIndexTree.GetHandle( shiftName );
-          shiftPatternIndex := guard( shiftPatternIndexTree.Root().Child( shiftPatternHandle ),null( NamedValue ));
-          if( not isnull( shiftPatternIndex )){
-            shiftPattern := shiftPatterns.Element( shiftPatternIndex.GetValueAsNumber() );
-            shiftDayTime := select( shiftPattern,ShiftDayTime,object,true );
+          productHandle := productIndexTree.GetHandle( row.ProductionLine() + row.ProductID() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() );
+          productIndex := guard( productIndexTree.Root().Child( productHandle ),null( NamedValue ));
+          if( isnull( productIndex )){
+            product := line.DispatchShiftSchedulingProduct( relnew,ProductID := row.ProductID() );
+            product.ProductionQuantity( cell.Quantity() );
+            line.ShiftDate( cell.NewOfflinePlanColumn().StartDate() );
+            line.ShiftName( cell.ShiftPatternName() );
+            products.Add( product );
+            productIndexTree.Root().AddChild( productHandle,products.Size() - 1 );
+          }else{
+            product := products.Element( productIndex.GetValueAsNumber() ); 
           }
-        }
-        if( shiftVolume <> 0 ){
-          shiftSchedulingInformations := DispatchShiftSchedulingInformation::SplitShifts( owner,shiftName,shiftVolume,productLinesQuantity );
-        
-        traverse( shiftSchedulingInformations,Elements,shiftSchedulingInformation ){
-          shiftSchedulingInformation.InterfaceTime( now );
-          shiftSchedulingInformation.VersionName( macroPlan.MDSMacroPlan().Description() );
-          shiftSchedulingInformation.Product( productID );
-          shiftSchedulingInformation.ProductLine( productLine );
-          shiftSchedulingInformation.ShiftDate( shiftDate );
-    //      shiftSchedulingInformation.InterfaceTime( now );
-    //      shiftSchedulingInformation.InterfaceTime( now );
-    //      shiftSchedulingInformation.InterfaceTime( now );
-    //      shiftSchedulingInformation.InterfaceTime( now );
-          
-          
-          if( not isnull( shiftDayTime )){
-            shiftSchedulingInformation.ShiftStartDate( shiftDayTime.StartDateTime() );
-            shiftSchedulingInformation.ShiftEndDate( shiftDayTime.EndDateTIme() );
-          }
-          if( not isnull( factory )){
-            shiftSchedulingInformation.FactoryName( factory.Name() );
-          }
-        }
         }
       }
     }
+    
+    traverse( lines,Elements,line ){
+      line.CalculateLineQuantity();
+      
+      // 1000
+      lineQuantity := line.LineQuantity();
+      
+      tempProducts := selectsortedset( line,DispatchShiftSchedulingProduct,object,object.ProductionQuantity() );
+      
+      if( line.ShiftName() = "3" ){
+        singleShiftVolume1 := lineQuantity / 3;
+        singleShiftVolume2 := lineQuantity / 3;
+        singleShiftVolume3 := lineQuantity / 3;
+        traverse( tempProducts,Elements,product ){
+          productionQuantity := product.ProductionQuantity();
+          
+          if( singleShiftVolume1 > 0 and productionQuantity > 0){
+            tempProductQuantity := singleShiftVolume1 - productionQuantity;
+            detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "鐧界彮");
+            singleShiftVolume1 := singleShiftVolume1 - productionQuantity;
+            productionQuantity := productionQuantity - detail.ShiftVolume();
+          }else if(singleShiftVolume2 > 0 and productionQuantity > 0){
+            tempProductQuantity := singleShiftVolume2 - productionQuantity;
+            detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume2 ) ,SingleShiftName := "浜岀彮");
+            singleShiftVolume2 := singleShiftVolume2 - productionQuantity;
+            productionQuantity := productionQuantity - detail.ShiftVolume();
+          }else if(singleShiftVolume3 > 0 and productionQuantity > 0){
+            tempProductQuantity := singleShiftVolume3 - productionQuantity;
+            detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume3 ) ,SingleShiftName := "浜岀彮");
+            singleShiftVolume3 := singleShiftVolume3 - productionQuantity;
+            productionQuantity := productionQuantity - detail.ShiftVolume();
+          }
+        }
+        
+      }else if( line.ShiftName() = "2" ){
+        // 500
+        singleShiftVolume1 := lineQuantity / 2;
+        singleShiftVolume2 := lineQuantity / 2;
+        traverse( tempProducts,Elements,product ){
+          productionQuantity := product.ProductionQuantity();
+          
+          if( singleShiftVolume1 > 0 and productionQuantity > 0){
+            tempProductQuantity := singleShiftVolume1 - productionQuantity;
+            detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "鐧界彮");
+            singleShiftVolume1 := singleShiftVolume1 - productionQuantity;
+            productionQuantity := productionQuantity - detail.ShiftVolume();
+          }else if(singleShiftVolume2 > 0 and productionQuantity > 0){
+            tempProductQuantity := singleShiftVolume2 - productionQuantity;
+            detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "浜岀彮");
+            singleShiftVolume2 := singleShiftVolume2 - productionQuantity;
+            productionQuantity := productionQuantity - detail.ShiftVolume();
+          }
+        }
+        
+      }else if( line.ShiftName() = "1" ){
+        singleShiftVolume1 := lineQuantity / 1;
+        traverse( tempProducts,Elements,product ){
+          productionQuantity := product.ProductionQuantity();
+          if( singleShiftVolume1 > 0 and productionQuantity > 0){
+            tempProductQuantity := singleShiftVolume1 - productionQuantity;
+            detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "鐧界彮");
+            singleShiftVolume1 := singleShiftVolume1 - productionQuantity;
+            productionQuantity := productionQuantity - detail.ShiftVolume();
+          }
+        }
+        
+      }else{
+        // singleShiftVolume := lineQuantity / 1;
+      }
+    }
+    
+    //traverse( offlinePlan,NewOfflinePlanRow,row ){
+    //  productID := row.ProductID();
+    //  productLine := row.ProductionLine();
+    //  factory := constnull( Unit );
+    //  {
+    //    unitHandle := unitIndexTree.GetHandle( productLine );
+    //    unitIndex := guard( unitIndexTree.Root().Child( unitHandle ), null( NamedValue ));
+    //    if( not isnull( unitIndex )){
+    //      unit := units.Element( unitIndex.GetValueAsNumber() );
+    //      temp1 := unit;
+    //      temp2 := unit.Parent();
+    //      while( not isnull( temp1.Parent())){
+    //        temp2 := temp1;
+    //        temp1 := temp1.Parent();
+    //      }
+    //      factory := temp2;
+    //    }
+    //  }
+    //  traverse( row,NewOfflinePlanCell,cell, startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){
+    //    productLinesQuantityHandle := productLinesQuantityNameValueTree.GetHandle( row.ProductionLine() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() );
+    //    productLinesQuantity := guard( productLinesQuantityNameValueTree.Root().Child( productLinesQuantityHandle ).GetValueAsReal(),0.0 );
+    //    
+    //    shiftDate := cell.NewOfflinePlanColumn().StartDate();
+    //    shiftName := cell.ShiftPatternName();
+    //    shiftVolume := cell.Quantity();
+    //    shiftDayTime := constnull( ShiftDayTime );
+    //    {
+    //      shiftPatternHandle := shiftPatternIndexTree.GetHandle( shiftName );
+    //      shiftPatternIndex := guard( shiftPatternIndexTree.Root().Child( shiftPatternHandle ),null( NamedValue ));
+    //      if( not isnull( shiftPatternIndex )){
+    //        shiftPattern := shiftPatterns.Element( shiftPatternIndex.GetValueAsNumber() );
+    //        shiftDayTime := select( shiftPattern,ShiftDayTime,object,true );
+    //      }
+    //    }
+    //    if( shiftVolume <> 0 ){
+    //      shiftSchedulingInformations := DispatchShiftSchedulingLine::SplitShifts( owner,shiftName,shiftVolume,productLinesQuantity );
+    //    
+    //    traverse( shiftSchedulingInformations,Elements,shiftSchedulingInformation ){
+    //      shiftSchedulingInformation.InterfaceTime( now );
+    //      shiftSchedulingInformation.VersionName( macroPlan.MDSMacroPlan().Description() );
+    //      shiftSchedulingInformation.Product( productID );
+    //      shiftSchedulingInformation.ProductLine( productLine );
+    //      shiftSchedulingInformation.ShiftDate( shiftDate );
+    ////      shiftSchedulingInformation.InterfaceTime( now );
+    ////      shiftSchedulingInformation.InterfaceTime( now );
+    ////      shiftSchedulingInformation.InterfaceTime( now );
+    ////      shiftSchedulingInformation.InterfaceTime( now );
+    //      
+    //      
+    //      if( not isnull( shiftDayTime )){
+    //        shiftSchedulingInformation.ShiftStartDate( shiftDayTime.StartDateTime() );
+    //        shiftSchedulingInformation.ShiftEndDate( shiftDayTime.EndDateTIme() );
+    //      }
+    //      if( not isnull( factory )){
+    //        shiftSchedulingInformation.FactoryName( factory.Name() );
+    //      }
+    //    }
+    //    }
+    //  }
+    //}
   *]
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl
deleted file mode 100644
index 7a00e46..0000000
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl
+++ /dev/null
@@ -1,57 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-StaticMethod SplitShifts (
-  RecycleBin owner,
-  String shiftName,
-  Real shiftVolume,
-  Real productLinesQuantity
-) as owning DispatchShiftSchedulingInformations
-{
-  TextBody:
-  [*
-    // Akari Oct-9-2024 (created)
-    shiftSchedulingInformations := construct( DispatchShiftSchedulingInformations );
-    if( shiftName = "3" ){
-      shiftQuantity := productLinesQuantity / 3 ;
-      
-      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ) );
-      shiftSchedulingInformation1.SingleShiftName( "鐧界彮" );
-      shiftSchedulingInformations.Add( shiftSchedulingInformation1 );
-      
-      shiftVolume := shiftVolume - shiftQuantity;
-      
-      shiftSchedulingInformation2 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ) );
-      shiftSchedulingInformation2.SingleShiftName( "浜岀彮" );
-      shiftSchedulingInformations.Add( shiftSchedulingInformation2 );
-      
-      shiftVolume := shiftVolume - shiftQuantity;
-      
-      shiftSchedulingInformation3 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ) );
-      shiftSchedulingInformation3.SingleShiftName( "涓夌彮" );
-      shiftSchedulingInformations.Add( shiftSchedulingInformation3 );
-    }else if( shiftName = "2" ){
-      shiftQuantity := productLinesQuantity / 2 ;
-      
-      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ));
-      shiftSchedulingInformation1.SingleShiftName( "鐧界彮" );
-      shiftSchedulingInformations.Add( shiftSchedulingInformation1 );
-      
-      shiftVolume := shiftVolume - shiftQuantity;
-      
-      shiftSchedulingInformation2 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ) );
-      shiftSchedulingInformation2.SingleShiftName( "浜岀彮" );
-      shiftSchedulingInformations.Add( shiftSchedulingInformation2 );
-    }else if( shiftName = "1" ){
-      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume );
-      shiftSchedulingInformation1.SingleShiftName( "鐧界彮" );
-      shiftSchedulingInformations.Add( shiftSchedulingInformation1 );
-    }else{
-      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume );
-      shiftSchedulingInformation1.SingleShiftName( "" );
-      shiftSchedulingInformations.Add( shiftSchedulingInformation1 );
-    }
-    
-    
-    return &shiftSchedulingInformations;
-  *]
-}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/_ROOT_Type_DispatchShiftSchedulingInformation.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/_ROOT_Type_DispatchShiftSchedulingInformation.qbl
deleted file mode 100644
index 34cb1a1..0000000
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/_ROOT_Type_DispatchShiftSchedulingInformation.qbl
+++ /dev/null
@@ -1,10 +0,0 @@
-Quintiq file version 2.0
-#root
-#parent: #DomainModel
-Type DispatchShiftSchedulingInformation
-{
-  #keys: '5[414996.1.67010064][414996.1.67010062][0.0.0][414996.1.67010063][414996.1.67010065]'
-  BaseType: Object
-  Description: '涓嬪彂鐝鎺掍骇淇℃伅'
-  StructuredName: 'DispatchShiftSchedulingInformations'
-}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/_ROOT_Type_DispatchShiftSchedulingLine.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/_ROOT_Type_DispatchShiftSchedulingLine.qbl
new file mode 100644
index 0000000..a66ae04
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/_ROOT_Type_DispatchShiftSchedulingLine.qbl
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+#root
+#parent: #DomainModel
+Type DispatchShiftSchedulingLine
+{
+  #keys: '5[414996.1.67010064][414996.1.67010062][0.0.0][414996.1.67010063][414996.1.67010065]'
+  BaseType: Object
+  Description: '涓嬪彂鐝鎺掍骇淇℃伅 -- 浜х嚎'
+  StructuredName: 'DispatchShiftSchedulingLines'
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftEndDate.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftEndDate.qbl
similarity index 63%
rename from _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftEndDate.qbl
rename to _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftEndDate.qbl
index f1bdbde..ca9bb90 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftEndDate.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftEndDate.qbl
@@ -2,7 +2,7 @@
 #parent: #root
 Attribute ShiftEndDate
 {
-  #keys: '3[414996.1.67010149][414996.1.67010148][414996.1.67010150]'
+  #keys: '3[414996.1.172754762][414996.1.172754761][414996.1.172754763]'
   Description: '鐝鐨勭粨鏉熸椂闂�'
   ValueType: DateTime
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftStartDate.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftStartDate.qbl
similarity index 63%
rename from _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftStartDate.qbl
rename to _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftStartDate.qbl
index 6ee07d4..db79566 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftStartDate.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftStartDate.qbl
@@ -2,7 +2,7 @@
 #parent: #root
 Attribute ShiftStartDate
 {
-  #keys: '3[414996.1.67010139][414996.1.67010138][414996.1.67010140]'
+  #keys: '3[414996.1.172754767][414996.1.172754766][414996.1.172754768]'
   Description: '鐝璧峰鏃堕棿'
   ValueType: DateTime
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftVolume.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftVolume.qbl
similarity index 61%
rename from _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftVolume.qbl
rename to _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftVolume.qbl
index 520c3d9..bbff2f4 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftVolume.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_ShiftVolume.qbl
@@ -2,7 +2,7 @@
 #parent: #root
 Attribute ShiftVolume
 {
-  #keys: '3[414996.1.67010126][414996.1.67010125][414996.1.67010127]'
+  #keys: '3[414996.1.172754772][414996.1.172754771][414996.1.172754773]'
   Description: '鍗曠彮娆′骇閲�'
   ValueType: Real
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_SingleShiftName.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_SingleShiftName.qbl
similarity index 62%
rename from _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_SingleShiftName.qbl
rename to _Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_SingleShiftName.qbl
index a426d36..bed9e5e 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_SingleShiftName.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/Attribute_SingleShiftName.qbl
@@ -2,7 +2,7 @@
 #parent: #root
 Attribute SingleShiftName
 {
-  #keys: '3[414996.1.67010116][414996.1.67010115][414996.1.67010117]'
+  #keys: '3[414996.1.172754757][414996.1.172754756][414996.1.172754758]'
   Description: '鍗曠彮娆″悕绉�'
   ValueType: String
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ProductLine.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/DefaultValue_SingleShiftName.qbl
similarity index 61%
copy from _Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ProductLine.qbl
copy to _Main/BL/Type_DispatchShiftSchedulingInformationDetail/DefaultValue_SingleShiftName.qbl
index 498dbce..4542472 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/DefaultValue_ProductLine.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/DefaultValue_SingleShiftName.qbl
@@ -2,5 +2,5 @@
 #parent: #root
 DefaultValue
 {
-  TargetAttribute: ProductLine
+  TargetAttribute: SingleShiftName
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/_ROOT_Type_DispatchShiftSchedulingDetail.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/_ROOT_Type_DispatchShiftSchedulingDetail.qbl
new file mode 100644
index 0000000..b488d17
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformationDetail/_ROOT_Type_DispatchShiftSchedulingDetail.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#root
+#parent: #DomainModel
+Type DispatchShiftSchedulingDetail
+{
+  #keys: '5[414996.1.172754720][414996.1.172754718][0.0.0][414996.1.172754719][414996.1.172754721]'
+  BaseType: Object
+  StructuredName: 'DispatchShiftSchedulingDetails'
+}

--
Gitblit v1.9.3