From da53ff7a774a54bae8248c5fb310dcdeb80c3cc7 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期三, 25 九月 2024 11:44:09 +0800
Subject: [PATCH] 新增下发班次信息报表,修复一些bug

---
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl |   77 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 1 deletions(-)

diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
index a5374a2..6d686a2 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
@@ -1,9 +1,84 @@
 Quintiq file version 2.0
 #parent: #root
-StaticMethod Dispatch
+StaticMethod Dispatch (
+  Date startDate,
+  Date endDate,
+  const OfflinePlanTable offlinePlan,
+  RecycleBin owner
+)
 {
   TextBody:
   [*
     // Akari Sep-4-2024 (created)
+    owner.DispatchShiftSchedulingInformation( relflush );
+    macroPlan := offlinePlan.MacroPlan();
+    now := DateTime::Now();
+    
+    shiftPatterns := selectset( macroPlan,ShiftPattern,object,true );
+    shiftPatternIndexTree := NamedValueTree::Create();
+    for( i := 0; i < shiftPatterns.Size(); i++){
+      shiftPattern := shiftPatterns.Element( i );
+      shiftPatternHandle := shiftPatternIndexTree.GetHandle( shiftPattern.Name() );
+      shiftPatternIndexTree.Root().AddChild( shiftPatternHandle,i );
+    }
+    
+    units := selectset( macroPlan,Unit,object, true );
+    unitIndexTree := NamedValueTree::Create();
+    for( i := 0; i < units.Size(); i++){
+      unit := units.Element( i );
+      unitHandle := unitIndexTree.GetHandle( unit.Name() );
+      unitIndexTree.Root().AddChild( unitHandle,i );
+    }
+    
+    traverse( offlinePlan,OfflinePlanRow,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,OfflinePlanCell,cell ,startDate <= cell.OfflinePlanColumn().ColumnDate() and endDate > cell.OfflinePlanColumn().ColumnDate()){
+        shiftDate := cell.OfflinePlanColumn().ColumnDate();
+        shiftName := cell.Shift();
+        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 );
+          }
+        }
+        
+        shiftSchedulingInformation := owner.DispatchShiftSchedulingInformation( relnew ,
+                                                                                ID := IDHolder::GetGUID() ,
+                                                                                InterfaceTime := now ,
+                                                                                VersionName := macroPlan.MDSMacroPlan().Description(),
+                                                                                Product := productID,
+                                                                                ProductLine := productLine,
+                                                                                ShiftDate := shiftDate,
+                                                                                ShiftName := shiftName,
+                                                                                ShiftVolume := shiftVolume );
+        if( not isnull( shiftDayTime )){
+          shiftSchedulingInformation.ShiftStartDate( shiftDayTime.StartDateTime() );
+          shiftSchedulingInformation.ShiftEndDate( shiftDayTime.EndDateTIme() );
+        }
+        if( not isnull( factory )){
+          shiftSchedulingInformation.FactoryName( factory.Name() );
+        }
+      }
+    }
   *]
 }

--
Gitblit v1.9.3