From d5c074b9e2daa5030a8e730a30d2ed31c8169e7d Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期五, 25 十月 2024 17:26:52 +0800
Subject: [PATCH] 修复一些bug

---
 _Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhCheckUnits_OnDataChanged.def |   21 +++++++
 _Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhFinalUnits_OnCreated.def     |   16 +++++
 _Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_ListData.def                            |    4 +
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl                                                     |   21 ++++++
 _Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelData.def                           |   35 +++++++++++
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl                                                  |   27 ++++++--
 6 files changed, 113 insertions(+), 11 deletions(-)

diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
index b61bf36..7ed2f4f 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
@@ -30,6 +30,20 @@
       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() );
+        }
+      }
+    }
+    
     traverse( offlinePlan,NewOfflinePlanRow,row ){
       productID := row.ProductID();
       productLine := row.ProductionLine();
@@ -48,7 +62,10 @@
           factory := temp2;
         }
       }
-      traverse( row,NewOfflinePlanCell,cell ,startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){
+      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();
@@ -62,7 +79,7 @@
           }
         }
         if( shiftVolume <> 0 ){
-          shiftSchedulingInformations := DispatchShiftSchedulingInformation::SplitShifts( owner,shiftName,shiftVolume );
+          shiftSchedulingInformations := DispatchShiftSchedulingInformation::SplitShifts( owner,shiftName,shiftVolume,productLinesQuantity );
         
         traverse( shiftSchedulingInformations,Elements,shiftSchedulingInformation ){
           shiftSchedulingInformation.InterfaceTime( now );
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl
index cd068af..7a00e46 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_SplitShifts.qbl
@@ -3,7 +3,8 @@
 StaticMethod SplitShifts (
   RecycleBin owner,
   String shiftName,
-  Real shiftVolume
+  Real shiftVolume,
+  Real productLinesQuantity
 ) as owning DispatchShiftSchedulingInformations
 {
   TextBody:
@@ -11,31 +12,41 @@
     // Akari Oct-9-2024 (created)
     shiftSchedulingInformations := construct( DispatchShiftSchedulingInformations );
     if( shiftName = "3" ){
-      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume / 3 );
+      shiftQuantity := productLinesQuantity / 3 ;
+      
+      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ) );
       shiftSchedulingInformation1.SingleShiftName( "鐧界彮" );
       shiftSchedulingInformations.Add( shiftSchedulingInformation1 );
       
-      shiftSchedulingInformation2 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume / 3 );
+      shiftVolume := shiftVolume - shiftQuantity;
+      
+      shiftSchedulingInformation2 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ) );
       shiftSchedulingInformation2.SingleShiftName( "浜岀彮" );
       shiftSchedulingInformations.Add( shiftSchedulingInformation2 );
       
-      shiftSchedulingInformation3 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume / 3 );
+      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" ){
-      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume / 2 );
+      shiftQuantity := productLinesQuantity / 2 ;
+      
+      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := ifexpr( shiftVolume >= shiftQuantity, shiftQuantity, shiftVolume ));
       shiftSchedulingInformation1.SingleShiftName( "鐧界彮" );
       shiftSchedulingInformations.Add( shiftSchedulingInformation1 );
       
-      shiftSchedulingInformation2 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume / 2 );
+      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 / 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 / 1 );
+      shiftSchedulingInformation1 := owner.DispatchShiftSchedulingInformation( relnew ,ID := IDHolder::GetGUID(),ShiftName := shiftName,ShiftVolume := shiftVolume );
       shiftSchedulingInformation1.SingleShiftName( "" );
       shiftSchedulingInformations.Add( shiftSchedulingInformation1 );
     }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_ListData.def b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_ListData.def
index 85ae591..c8afd0c 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_ListData.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_ListData.def
@@ -11,7 +11,9 @@
       BaseType: 'WebDataExtractor'
       Properties:
       [
-        DataType: 'external[RecycleBin]'
+        DataType: 'RecycleBin'
+        FilterArguments: 'checkedUnits:QMacroPlanner::FormDispatchShiftSchedulingInformation.dhFinalUnits'
+        FixedFilter: 'exists( checkedUnits,Elements,unit,unit.DisplayName() = object.ProductLine())'
         Source: 'RecycleBin'
         Taborder: 0
         Transformation: 'DispatchShiftSchedulingInformation'
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelData.def b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelData.def
index 6d12fb4..712b21c 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelData.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelData.def
@@ -6,6 +6,41 @@
   Children:
   [
     #child: ListData
+    Component dhFinalUnits
+    {
+      #keys: '[414996.1.167251230]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'structured[Entity]*'
+      Properties:
+      [
+        Taborder: 1
+      ]
+    }
+    Component dhCheckUnits
+    {
+      #keys: '[414996.1.167251252]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'structured[Entity]*'
+      Children:
+      [
+        Component deCheckUnits
+        {
+          #keys: '[414996.1.167251253]'
+          BaseType: 'WebDataExtractor'
+          Properties:
+          [
+            DataType: 'structured[Entity]'
+            Source: 'ApplicationMacroPlanner.DataHolderCheckedEntities'
+            Taborder: 0
+            Transformation: 'Elements'
+          ]
+        }
+      ]
+      Properties:
+      [
+        Taborder: 2
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhCheckUnits_OnDataChanged.def b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhCheckUnits_OnDataChanged.def
new file mode 100644
index 0000000..be28ba8
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhCheckUnits_OnDataChanged.def
@@ -0,0 +1,21 @@
+Quintiq file version 2.0
+#parent: PanelData/dhCheckUnits
+Response OnDataChanged () id:Response_PanelDemandComparison_634_dhCheckUnits_OnDataChanged
+{
+  #keys: '[414996.1.167251250]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnDataChanged'
+  GroupServerCalls: true
+  QuillAction
+  {
+    Body:
+    [*
+      if( this.Data().Size() <> 0 ){
+        units := selectset( dhFinalUnits.Data(),Elements,element,exists( this.Data(),Elements,entity,entity = element ));
+        dhFinalUnits.Data( &units );
+      }else{
+        dhFinalUnits.Data( DataHolderEntities.Data().Copy() );
+      }
+    *]
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhFinalUnits_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhFinalUnits_OnCreated.def
new file mode 100644
index 0000000..0abadef
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelData_dhFinalUnits_OnCreated.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: PanelData/dhFinalUnits
+Response OnCreated () id:Response_PanelDemandComparison_634_dhFinalUnits_OnCreated
+{
+  #keys: '[414996.1.167251228]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  GroupServerCalls: true
+  QuillAction
+  {
+    Body:
+    [*
+      dhFinalUnits.Data( DataHolderEntities.Data().Copy() );
+    *]
+  }
+}

--
Gitblit v1.9.3