From af6e0977dcfb89d81790d41de57d986107ece68a Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期一, 28 十月 2024 15:28:00 +0800
Subject: [PATCH] 添加班次信息下发的功能

---
 _Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bDispatch_OnClick.def           |   40 +++++
 /dev/null                                                                                                                                                     |   18 --
 _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl                                                                                      |    2 
 _Main/BL/InfoMessages.qbl                                                                                                                                     |   11 +
 _Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl                                                                                      |    2 
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl                                                                        |  218 +++++++++++++++++++++++++++
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchCC.qbl                                                                                  |   53 ++++++
 _Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bGenerateDispatchData_O#844.def |   20 ++
 _Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelDispatchShiftSchedulingInformation.def                            |   32 +++
 _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchDL.qbl                                                                                  |   53 ++++++
 10 files changed, 428 insertions(+), 21 deletions(-)

diff --git a/_Main/BL/InfoMessages.qbl b/_Main/BL/InfoMessages.qbl
index f12c34f..69c97ae 100644
--- a/_Main/BL/InfoMessages.qbl
+++ b/_Main/BL/InfoMessages.qbl
@@ -264,4 +264,15 @@
   {
     DefaultText: 'All fields Required This parameter is mandatory.'
   }
+  InfoMessage RecycleBin_DispatchShiftSchedulingDispatchCheck (
+    const String factoryNameChinese,
+    const String factoryNameEnglish
+  )
+  {
+    DefaultText:
+    [*
+      鏄惁纭涓嬪彂銆怈factoryNameChinese@銆戞暟鎹紵
+      Do you confirm the issuance of [@factoryNameEnglish@] data?
+    *]
+  }
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftDate.qbl
index 329dde9..032c774 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.172754933][414996.1.172754932][414996.1.172754934]'
+  #keys: '3[414996.1.172820109][414996.1.172820108][414996.1.172820110]'
   Description: '鐝鏃ユ湡'
   ValueType: Date
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/Attribute_ShiftName.qbl
index a3f2670..fc2f75e 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.172754938][414996.1.172754937][414996.1.172754939]'
+  #keys: '3[414996.1.172820106][414996.1.172820105][414996.1.172820107]'
   Description: '鐝鍚嶇О'
   ValueType: String
 }
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
deleted file mode 100644
index 5de7a0d..0000000
--- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl
+++ /dev/null
@@ -1,222 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-StaticMethod Dispatch (
-  Date startDate,
-  Date endDate,
-  const NewOfflinePlanTable offlinePlan,
-  RecycleBin owner
-)
-{
-  TextBody:
-  [*
-    // Akari Sep-4-2024 (created)
-    owner.DispatchShiftSchedulingLine( 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 );
-    }
-    
-    lines := construct( DispatchShiftSchedulingLines );
-    lineIndexTree := NamedValueTree::Create();
-    
-    products := construct( DispatchShiftSchedulingProducts );
-    productIndexTree := NamedValueTree::Create();
-    
-    //productionDetails := construct( DispatchShiftSchedulingDetails );
-    //productionDetailIndexTree := NamedValueTree::Create();
-    traverse( offlinePlan,NewOfflinePlanRow,row ){
-      line := null( DispatchShiftSchedulingLine );
-      factory := constnull( Unit );
-      {
-        unitHandle := unitIndexTree.GetHandle( row.ProductionLine() );
-        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;
-        }
-        
-        lineHandle := lineIndexTree.GetHandle( row.ProductionLine() );
-        lineIndex := guard( lineIndexTree.Root().Child( lineHandle ),null( NamedValue ));
-        if( isnull( lineIndex )){
-          line := owner.DispatchShiftSchedulingLine( relnew,ID := IDHolder::GetGUID(),LineName := 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()){
-        product := null( DispatchShiftSchedulingProduct );
-        {
-          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() ); 
-          }
-        }
-      }
-    }
-    
-    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_DispatchCC.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchCC.qbl
new file mode 100644
index 0000000..b516ba0
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchCC.qbl
@@ -0,0 +1,53 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod DispatchCC (
+  const RecycleBin recycleBin
+) as String
+{
+  TextBody:
+  [*
+    // Akari Oct-28-2024 (created)
+    // 鎺ュ彛鍦板潃锛�172.18.1.12/PPPS/AddPlan ---闀挎槬鍦板潃
+    url := "http://172.18.1.12/PPPS/AddPlan";
+    
+    datas := selectset( recycleBin,DispatchShiftSchedulingLine.DispatchShiftSchedulingProduct,object,object.DispatchShiftSchedulingLine().Fac() = "CC" );
+    
+    datas_Json := JSON::Array();
+    
+    traverse( datas,Elements,product ){
+      line := product.DispatchShiftSchedulingLine();
+      
+      data_Json := JSON::Object();
+      datas_Json.Add( data_Json );
+      
+      data_Json.Add( "LineName" , line.LineName() );
+      data_Json.Add( "ProductionDate",line.ShiftDate().Format( "Y-M2-D2" ));
+      data_Json.Add( "shiftCode" , line.ShiftName() );
+      details_Json := JSON::Array();
+      data_Json.Add( "planItems",details_Json );
+      traverse( product,DispatchShiftSchedulingDetail,detail ){
+        detail_Json := JSON::Object();
+        details_Json.Add( detail_Json );
+        detail_Json.Add( "ShiftName",detail.SingleShiftName() );
+        detail_Json.Add( "Quantity",detail.ShiftVolume() );
+        detail_Json.Add( "ProductNo",detail.DispatchShiftSchedulingProduct().ProductID() );
+      }
+    }
+    
+    info( datas_Json.AsString() );
+    
+    i := HTTPInterface::Create( url, 80 );
+    i.URL( url );
+    i.PostMethod( true );
+    i.MediaType( "application/json" );
+    i.TimeOut( Duration::Minutes( 5 ) );
+    
+    i.Call( datas_Json.AsString() );
+      
+    htmlresult := i.Result();
+      
+    respJSON   := JSON::Parse( htmlresult );
+    
+    return respJSON.Get( "Message" ).AsString();
+  *]
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchDL.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchDL.qbl
new file mode 100644
index 0000000..cca981f
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchDL.qbl
@@ -0,0 +1,53 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod DispatchDL (
+  const RecycleBin recycleBin
+) as String
+{
+  TextBody:
+  [*
+    // Akari Oct-28-2024 (created)
+    // 鎺ュ彛鍦板潃锛�172.30.9.10/PPPS/AddPlan鈥斿ぇ杩炲湴鍧�
+    url := "http://172.30.9.10/PPPS/AddPlan"
+    
+    datas := selectset( recycleBin,DispatchShiftSchedulingLine.DispatchShiftSchedulingProduct,object,object.DispatchShiftSchedulingLine().Fac() = "DL" );
+    
+    datas_Json := JSON::Array();
+    
+    traverse( datas,Elements,product ){
+      line := product.DispatchShiftSchedulingLine();
+      
+      data_Json := JSON::Object();
+      datas_Json.Add( data_Json );
+      
+      data_Json.Add( "LineName" , line.LineName() );
+      data_Json.Add( "ProductionDate",line.ShiftDate().Format( "Y-M2-D2" ));
+      data_Json.Add( "shiftCode" , line.ShiftName() );
+      details_Json := JSON::Array();
+      data_Json.Add( "planItems",details_Json );
+      traverse( product,DispatchShiftSchedulingDetail,detail ){
+        detail_Json := JSON::Object();
+        details_Json.Add( detail_Json );
+        detail_Json.Add( "ShiftName",detail.SingleShiftName() );
+        detail_Json.Add( "Quantity",detail.ShiftVolume() );
+        detail_Json.Add( "ProductNo",detail.DispatchShiftSchedulingProduct().ProductID() );
+      }
+    }
+    
+    info( datas_Json.AsString() );
+    
+    i := HTTPInterface::Create( url, 80 );
+    i.URL( url );
+    i.PostMethod( true );
+    i.MediaType( "application/json" );
+    i.TimeOut( Duration::Minutes( 5 ) );
+    
+    i.Call( datas_Json.AsString() );
+      
+    htmlresult := i.Result();
+      
+    respJSON   := JSON::Parse( htmlresult );
+    
+    return respJSON.Get( "Message" ).AsString();
+  *]
+}
diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl
new file mode 100644
index 0000000..4b5446f
--- /dev/null
+++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_GenerateDispatchData.qbl
@@ -0,0 +1,218 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod GenerateDispatchData (
+  Date startDate,
+  Date endDate,
+  const NewOfflinePlanTable offlinePlan,
+  RecycleBin owner
+)
+{
+  TextBody:
+  [*
+    // Akari Sep-4-2024 (created)
+    owner.DispatchShiftSchedulingLine( 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 );
+    }
+    
+    lines := construct( DispatchShiftSchedulingLines );
+    lineIndexTree := NamedValueTree::Create();
+    
+    products := construct( DispatchShiftSchedulingProducts );
+    productIndexTree := NamedValueTree::Create();
+    
+    //productionDetails := construct( DispatchShiftSchedulingDetails );
+    //productionDetailIndexTree := NamedValueTree::Create();
+    traverse( offlinePlan,NewOfflinePlanRow,row ,not row.ProductionLine().ToUpper().LikeUserLocale( "MOMO" )){
+      line := null( DispatchShiftSchedulingLine );
+      factory := constnull( Unit );
+      {
+        unitHandle := unitIndexTree.GetHandle( row.ProductionLine() );
+        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()){
+        product := null( DispatchShiftSchedulingProduct );
+        {
+          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.FactoryName( factory.Name() );
+            line.InterfaceTime( now );
+            line.VersionName( macroPlan.MDSMacroPlan().Description() );
+            line.ShiftName( cell.ShiftPatternName() );
+            lines.Add( line );
+            lineIndexTree.Root().AddChild( lineHandle,lines.Size() - 1 );
+          }else{
+            line := lines.Element( lineIndex.GetValueAsNumber() ); 
+          }
+          
+          productHandle := productIndexTree.GetHandle( lineKey + row.ProductID() );
+          productIndex := guard( productIndexTree.Root().Child( productHandle ),null( NamedValue ));
+          if( isnull( productIndex )){
+            product := line.DispatchShiftSchedulingProduct( relnew,ProductID := row.ProductID() );
+            product.ProductionQuantity( cell.Quantity() );
+            products.Add( product );
+            productIndexTree.Root().AddChild( productHandle,products.Size() - 1 );
+          }else{
+            product := products.Element( productIndex.GetValueAsNumber() ); 
+          }
+        }
+      }
+    }
+    
+    traverse( macroPlan,NewAssemblyOnlinePlanRow,row , row.ProductionLine().ToUpper().LikeUserLocale( "MOMO" )){
+      line := null( DispatchShiftSchedulingLine );
+      factory := constnull( Unit );
+      {
+        unitHandle := unitIndexTree.GetHandle( row.ProductionLine() );
+        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,NewAssemblyOnlinePlanCell,cell, startDate <= cell.NewAssemblyOnlinePlanColumn().StartDate() and endDate >= cell.NewAssemblyOnlinePlanColumn().EndDate()){
+        product := null( DispatchShiftSchedulingProduct );
+        {
+          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.FactoryName( factory.Name() );
+            line.InterfaceTime( now );
+            line.VersionName( macroPlan.MDSMacroPlan().Description() );
+            line.ShiftName( cell.ShiftPatternName() );
+            lines.Add( line );
+            lineIndexTree.Root().AddChild( lineHandle,lines.Size() - 1 );
+          }else{
+            line := lines.Element( lineIndex.GetValueAsNumber() ); 
+          }
+          
+          productHandle := productIndexTree.GetHandle( lineKey + row.ProductID() );
+          productIndex := guard( productIndexTree.Root().Child( productHandle ),null( NamedValue ));
+          if( isnull( productIndex )){
+            product := line.DispatchShiftSchedulingProduct( relnew,ProductID := row.ProductID() );
+            product.ProductionQuantity( cell.Quantity() );
+            products.Add( product );
+            productIndexTree.Root().AddChild( productHandle,products.Size() - 1 );
+          }else{
+            product := products.Element( productIndex.GetValueAsNumber() ); 
+          }
+        }
+      }
+    }
+    
+    traverse( lines,Elements,line ){
+      line.CalcLineQuantity();
+      
+      // 481
+      lineQuantity := line.LineQuantity();
+      
+      tempProducts := selectsortedset( line,DispatchShiftSchedulingProduct,object,object.ProductionQuantity() );
+      
+      if( line.ShiftName() = "3" ){
+        singleShiftVolume1 := lineQuantity / 3;
+        singleShiftVolume2 := lineQuantity / 3;
+        singleShiftVolume3 := lineQuantity / 3;
+        for( i := tempProducts.Size() - 1;i >= 0; i-- ){
+          product := tempProducts.Element( i );
+          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" ){    
+        // 240.5
+        singleShiftVolume1 := lineQuantity / 2;
+        singleShiftVolume2 := lineQuantity / 2;
+        for( i := tempProducts.Size() - 1;i >= 0; i-- ){
+          product := tempProducts.Element( i );
+          // 288
+          productionQuantity := product.ProductionQuantity();
+          
+          if( singleShiftVolume1 > 0 and productionQuantity > 0){
+            // -47.5
+            tempProductQuantity := singleShiftVolume1 - productionQuantity;
+            detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "鐧界彮");
+            singleShiftVolume1 := singleShiftVolume1 - productionQuantity;
+            productionQuantity := productionQuantity - detail.ShiftVolume();
+          }
+          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( line.ShiftName() = "1" ){
+        singleShiftVolume1 := lineQuantity / 1;
+        for( i := tempProducts.Size() - 1;i >= 0; i-- ){
+          product := tempProducts.Element( i );
+          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;
+      }
+    }
+    info( "Success" );
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelDispatchShiftSchedulingInformation.def b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelDispatchShiftSchedulingInformation.def
index 45600a3..6ec5006 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelDispatchShiftSchedulingInformation.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Component_PanelDispatchShiftSchedulingInformation.def
@@ -5,7 +5,7 @@
   BaseType: 'WebPanel'
   Children:
   [
-    Component ButtonDispatch id:ButtonDispatch_715
+    Component bGenerateDispatchData
     {
       #keys: '[414996.1.100510694]'
       BaseType: 'WebButton'
@@ -35,6 +35,36 @@
         Taborder: 1
       ]
     }
+    Component cbCC
+    {
+      #keys: '[414996.1.172950712]'
+      BaseType: 'WebCheckbox'
+      Properties:
+      [
+        Label: '闀挎槬宸ュ巶'
+        Taborder: 3
+      ]
+    }
+    Component cbDL
+    {
+      #keys: '[414996.1.172950725]'
+      BaseType: 'WebCheckbox'
+      Properties:
+      [
+        Label: '澶ц繛宸ュ巶'
+        Taborder: 4
+      ]
+    }
+    Component bDispatch
+    {
+      #keys: '[414996.1.172950741]'
+      BaseType: 'WebButton'
+      Properties:
+      [
+        Label: '涓嬪彂'
+        Taborder: 5
+      ]
+    }
   ]
   Properties:
   [
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_ButtonDispatch_OnClick\043844.def" "b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_ButtonDispatch_OnClick\043844.def"
deleted file mode 100644
index d550bc4..0000000
--- "a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_ButtonDispatch_OnClick\043844.def"
+++ /dev/null
@@ -1,18 +0,0 @@
-Quintiq file version 2.0
-#parent: PanelDispatchShiftSchedulingInformation/ButtonDispatch_715
-Response OnClick () id:Response_FormDispatchShiftSchedulingInformation_ButtonDispatch_OnClick_844
-{
-  #keys: '[414996.1.100510693]'
-  CanBindMultiple: false
-  DefinitionID: 'Responsedef_WebButton_OnClick'
-  GroupServerCalls: true
-  QuillAction
-  {
-    Body:
-    [*
-      offlineTable := select( MacroPlan,NewOfflinePlanTable,table,true );
-      
-      DispatchShiftSchedulingLine::Dispatch( dsStartDate.Date(),dsEndDate.Date(),offlineTable,RecycleBin );
-    *]
-  }
-}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bDispatch_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bDispatch_OnClick.def
new file mode 100644
index 0000000..837ac98
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bDispatch_OnClick.def
@@ -0,0 +1,40 @@
+Quintiq file version 2.0
+#parent: PanelDispatchShiftSchedulingInformation/bDispatch
+Response OnClick () id:Response_PanelDispatchShiftSchedulingInformation_bDispatch_OnClick
+{
+  #keys: '[414996.1.172931481]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebButton_OnClick'
+  Precondition:
+  [*
+    return cbCC.Checked() or cbDL.Checked();
+  *]
+  QuillAction
+  {
+    Body:
+    [*
+      factoryNameChinese := "";
+      factoryNameEnglish := "";
+      if( cbCC.Checked() ){
+        factoryNameChinese := factoryNameChinese.Concat( "闀挎槬宸ュ巶;" );
+        factoryNameEnglish := factoryNameEnglish.Concat( "CC;" );
+      }
+      if( cbDL.Checked() ){
+        factoryNameChinese := factoryNameChinese.Concat( "澶ц繛宸ュ巶;" );
+        factoryNameEnglish := factoryNameEnglish.Concat( "DL;" );
+      }
+      if( WebMessageBox::Question( Translations::RecycleBin_DispatchShiftSchedulingDispatchCheck( factoryNameChinese,factoryNameEnglish ),Translations::MessageBox_YesNo() ) = 0 ){
+        if( cbCC.Checked() ){
+          message := DispatchShiftSchedulingLine::DispatchCC( RecycleBin );
+          WebMessageBox::Information( message );
+        }
+        if( cbDL.Checked() ){
+          message := DispatchShiftSchedulingLine::DispatchDL( RecycleBin ); 
+          WebMessageBox::Information( message );
+        }
+      }
+      WebMessageBox::Success( "涓嬪彂鎴愬姛" );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bGenerateDispatchData_O\043844.def" "b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bGenerateDispatchData_O\043844.def"
new file mode 100644
index 0000000..59578d9
--- /dev/null
+++ "b/_Main/UI/MacroPlannerWebApp/Component_FormDispatchShiftSchedulingInformation/Response_PanelDispatchShiftSchedulingInformation_bGenerateDispatchData_O\043844.def"
@@ -0,0 +1,20 @@
+Quintiq file version 2.0
+#parent: PanelDispatchShiftSchedulingInformation/bGenerateDispatchData
+Response OnClick () id:Response_PanelDispatchShiftSchedulingInformation_bGenerateDispatchData_OnClick_844
+{
+  #keys: '[414996.1.100510693]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebButton_OnClick'
+  GroupServerCalls: true
+  QuillAction
+  {
+    Body:
+    [*
+      offlineTable := select( MacroPlan,NewOfflinePlanTable,table,true );
+      
+      DispatchShiftSchedulingLine::GenerateDispatchData( dsStartDate.Date(),dsEndDate.Date(),offlineTable,RecycleBin );
+      
+      WebMessageBox::Success( "Success" );
+    *]
+  }
+}

--
Gitblit v1.9.3