From d729cf0951344771245befd9ae8b0b97d133c7f7 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期一, 25 十一月 2024 20:41:57 +0800
Subject: [PATCH] 班次计划下发添加保养班次剔除

---
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl |   51 ++++++++++++++++++++++---
 _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_Remark.qbl                  |    7 +++
 _Main/BL/Type_ShiftPlan/StaticMethod_CalculateRemark.qbl                               |   33 ++++++++++++++++
 _Main/BL/Type_LocalTool/StaticMethod_IsAnyDurationContained.qbl                        |    4 +
 4 files changed, 87 insertions(+), 8 deletions(-)

diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_Remark.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_Remark.qbl
new file mode 100644
index 0000000..8c7c831
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_Remark.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute Remark
+{
+  #keys: '3[414996.1.248479382][414996.1.248479381][414996.1.248479383]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl
index 9da63db..b5c8382 100644
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl
@@ -41,6 +41,7 @@
     traverse( offlinePlan,NewOfflinePlanRow,row ,not row.ProductionLine().ToUpper().LikeUserLocale( "MOMO" )){
       line := null( DispatchShiftSchedulingLine );
       factory := constnull( Unit );
+      unit := constnull( Unit );
       {
         unitHandle := unitIndexTree.GetHandle( row.ProductionLine() );
         unitIndex := guard( unitIndexTree.Root().Child( unitHandle ), null( NamedValue ));
@@ -52,12 +53,16 @@
       
       traverse( row,NewOfflinePlanCell,cell, startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){
         product := null( DispatchShiftSchedulingProduct );
+        remark := "";
+        if( not isnull( unit )){
+          remark := ShiftPlan::CalculateRemark( unit,cell.NewOfflinePlanColumn().StartDate(),cell.NewOfflinePlanColumn().EndDate() );
+        }
         {
           lineKey := row.ProductionLine() + cell.NewOfflinePlanColumn().StartDate().AsQUILL();
           lineHandle := lineIndexTree.GetHandle( lineKey );
           lineIndex := guard( lineIndexTree.Root().Child( lineHandle ),null( NamedValue ));
           if( isnull( lineIndex )){
-            line := owner.DispatchShiftSchedulingLine( relnew,ID := IDHolder::GetGUID(),LineName := row.ProductionLine(),ShiftDate := cell.NewOfflinePlanColumn().StartDate() );
+            line := owner.DispatchShiftSchedulingLine( relnew,ID := IDHolder::GetGUID(),LineName := row.ProductionLine(),ShiftDate := cell.NewOfflinePlanColumn().StartDate(),Remark := remark );
             line.FactoryName( factory.Name() );
             line.InterfaceTime( now );
             line.VersionName( macroPlan.MDSMacroPlan().Description() );
@@ -85,6 +90,7 @@
     traverse( macroPlan,NewAssemblyOnlinePlanRow,row , row.ProductionLine().ToUpper().LikeUserLocale( "MOMO" )){
       line := null( DispatchShiftSchedulingLine );
       factory := constnull( Unit );
+      unit := constnull( Unit );
       {
         unitHandle := unitIndexTree.GetHandle( row.ProductionLine() );
         unitIndex := guard( unitIndexTree.Root().Child( unitHandle ), null( NamedValue ));
@@ -102,12 +108,16 @@
       
       traverse( row,NewAssemblyOnlinePlanCell,cell, startDate <= cell.NewAssemblyOnlinePlanColumn().StartDate() and endDate >= cell.NewAssemblyOnlinePlanColumn().EndDate()){
         product := null( DispatchShiftSchedulingProduct );
+        remark := "";
+        if( not isnull( unit )){
+          remark := ShiftPlan::CalculateRemark( unit,cell.NewAssemblyOnlinePlanColumn().StartDate(),cell.NewAssemblyOnlinePlanColumn().EndDate() );
+        }
         {
           lineKey := row.ProductionLine() + cell.NewAssemblyOnlinePlanColumn().StartDate().AsQUILL();
           lineHandle := lineIndexTree.GetHandle( lineKey );
           lineIndex := guard( lineIndexTree.Root().Child( lineHandle ),null( NamedValue ));
           if( isnull( lineIndex )){
-            line := owner.DispatchShiftSchedulingLine( relnew,ID := IDHolder::GetGUID(),LineName := row.ProductionLine(),ShiftDate := cell.NewAssemblyOnlinePlanColumn().StartDate() );
+            line := owner.DispatchShiftSchedulingLine( relnew,ID := IDHolder::GetGUID(),LineName := row.ProductionLine(),ShiftDate := cell.NewAssemblyOnlinePlanColumn().StartDate(),Remark := remark );
             line.FactoryName( factory.Name() );
             line.InterfaceTime( now );
             line.VersionName( macroPlan.MDSMacroPlan().Description() );
@@ -141,9 +151,21 @@
       tempProducts := selectsortedset( line,DispatchShiftSchedulingProduct,object,object.ProductionQuantity() );
       
       if( line.ShiftName() = "3" ){
-        singleShiftVolume1 := lineQuantity / 3;
-        singleShiftVolume2 := lineQuantity / 3;
-        singleShiftVolume3 := lineQuantity / 3;
+        
+        singleShiftVolume1 := 0.0;
+        singleShiftVolume2 := 0.0;
+        singleShiftVolume3 := 0.0;
+        
+        if( line.Remark().LikeUserLocale( "淇濆吇" )){
+          singleShiftVolume1 := 0.0;
+          singleShiftVolume2 := lineQuantity / 2;
+          singleShiftVolume3 := lineQuantity / 2;
+        }else{
+          singleShiftVolume1 := lineQuantity / 3;
+          singleShiftVolume2 := lineQuantity / 3;
+          singleShiftVolume3 := lineQuantity / 3;
+        }
+        
         for( i := tempProducts.Size() - 1;i >= 0; i-- ){
           product := tempProducts.Element( i );
           productionQuantity := product.ProductionQuantity();
@@ -168,8 +190,16 @@
         
       }else if( line.ShiftName() = "2" ){    
         // 240.5
-        singleShiftVolume1 := lineQuantity / 2;
-        singleShiftVolume2 := lineQuantity / 2;
+        singleShiftVolume1 := 0.0;
+        singleShiftVolume2 := 0.0;
+        if( line.Remark().LikeUserLocale( "淇濆吇" )){
+          singleShiftVolume1 := 0.0;
+          singleShiftVolume2 := lineQuantity;
+        }else{
+          singleShiftVolume1 := lineQuantity / 2;
+          singleShiftVolume2 := lineQuantity / 2;
+        }
+    
         for( i := tempProducts.Size() - 1;i >= 0; i-- ){
           product := tempProducts.Element( i );
           // 288
@@ -192,6 +222,13 @@
         
       }else if( line.ShiftName() = "1" ){
         singleShiftVolume1 := lineQuantity / 1;
+        
+        if( line.Remark().LikeUserLocale( "淇濆吇" )){
+          singleShiftVolume1 := lineQuantity / 1;
+        }else{
+          singleShiftVolume1 := lineQuantity / 1;
+        }
+        
         for( i := tempProducts.Size() - 1;i >= 0; i-- ){
           product := tempProducts.Element( i );
           productionQuantity := product.ProductionQuantity();
diff --git a/_Main/BL/Type_LocalTool/StaticMethod_IsAnyDurationContained.qbl b/_Main/BL/Type_LocalTool/StaticMethod_IsAnyDurationContained.qbl
index 19b7ed7..849c745 100644
--- a/_Main/BL/Type_LocalTool/StaticMethod_IsAnyDurationContained.qbl
+++ b/_Main/BL/Type_LocalTool/StaticMethod_IsAnyDurationContained.qbl
@@ -10,6 +10,8 @@
   TextBody:
   [*
     // rislai Jun-19-2024 (created)
-    return ( start1 <= start2 and end1 >= end2 ) or ( start2 <= start1 and end2 >= end1 );
+    //return ( start1 <= start2 and end1 >= end2 ) or ( start2 <= start1 and end2 >= end1 );
+    
+    return not (end1 < start2 or end2 < start1)
   *]
 }
diff --git a/_Main/BL/Type_ShiftPlan/StaticMethod_CalculateRemark.qbl b/_Main/BL/Type_ShiftPlan/StaticMethod_CalculateRemark.qbl
new file mode 100644
index 0000000..84ea433
--- /dev/null
+++ b/_Main/BL/Type_ShiftPlan/StaticMethod_CalculateRemark.qbl
@@ -0,0 +1,33 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CalculateRemark (
+  const Unit unit,
+  Date startDate,
+  Date endDate
+) as String
+{
+  TextBody:
+  [*
+    // Akari Nov-25-2024 (created)
+    values := construct( Strings );
+    
+    traverse( unit.UnitCalendar(),Participation,participation,participation.Event().Type() = LibCal_Event::TYPE_UNAVAILABLE()){
+        event := participation.Event();
+        
+        if( startDate >= event.EarliestStart() and endDate <= event.LatestEnd() ){
+          intervals := selectset( event,LeadingParticipation.ExplicitTimeInterval,interval,LocalTool::IsAnyDurationContained( interval.Start(),interval.End(),startDate.DateTime(),endDate.DateTime() ));
+          traverse( intervals,Elements,interval){
+            values.Add( interval.Participation().Event().Subject() );
+          }
+        }
+    }
+    values := selectuniquevalues( values,Elements,value,true,value );
+    
+    result := "";
+    traverse( values,Elements,value ){
+      result := result + value + ";";
+    }
+    
+    return ifexpr( result = "",result,result.SubString( 0,result.Length() - 1 ) );
+  *]
+}

--
Gitblit v1.9.3