From 1a5a8be205641f5f79dd809f6c7e59fc84d76243 Mon Sep 17 00:00:00 2001
From: yunchai <yunying.chai@capgemini.com>
Date: 星期日, 08 十月 2023 09:11:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev'

---
 _Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl |   90 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 83 insertions(+), 7 deletions(-)

diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
index b807827..663464c 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
@@ -3,22 +3,24 @@
 Method MappingOperationBOMData (
   Strings businessTypes,
   Boolean isKeyProduct,
-  Boolean createPurchaseSupplyMaterial
+  Boolean createPurchaseSupplyMaterial,
+  GlobalOTDTable globalOTDTable
 )
 {
   TextBody:
   [*
     // yypsybs Aug-21-2023 (created)
-    
     keyProductList := construct( Strings );
     if( isKeyProduct ) {
-        keyProductList := selectuniquevalues( this, MappingProduct, item, item.ProductMajorType()="鎴愬搧" or item.ProductMajorType()="鍗婃垚鍝�", item.ID() );
+        keyProductList := selectuniquevalues( globalOTDTable, Global_MappingProduct_MP, item, item.ProductMajorType()="鎴愬搧" or item.ProductMajorType()="鍗婃垚鍝�", item.ID() );
     }
-    bomList := selectsortedset(  this, MappingBOM, item,
+    organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() );
+    bomList := selectsortedset(  globalOTDTable, Global_MappingOperationBOM, item,
                                  ifexpr( isnull( businessTypes ) or businessTypes.Size() = 0, 
                                          true, 
     //                                     businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 )
-                                         businessTypes.Find( item.BusinessType() ) >= 0 )
+                                         ( businessTypes.Find( item.BusinessType() ) >= 0 ) and 
+                                         ( organcodelist.Find( item.OrganCode() ) >= 0 ) )
     //                             and ifexpr( isKeyProduct, 
     //                                         keyProductList.Size() > 0 and keyProductList.Find( item.ComponentCode() ) >= 0,
     //                                         true )
@@ -58,12 +60,13 @@
                   // ========鍒嗙粍澶勭悊杈撳叆========
                   
                 }
+                
                 if( not isnull( stockingPoint)){
                   if( isKeyProduct){
                       keyRows := selectset( routingRows,Elements,routingrow,keyProductList.Find( routingrow.ComponentCode())>=0);
-                      this.MappingOperationBOMDataRouting( routing,keyRows);
+                      this.MappingOperationBOMDataRouting( routing,globalOTDTable,keyRows);
                     }else{
-                      this.MappingOperationBOMDataRouting( routing,routingRows);
+                      this.MappingOperationBOMDataRouting( routing,globalOTDTable,routingRows);
                     }
                     
                 }
@@ -80,5 +83,78 @@
             this.MappingOperationBOMDataSupplyPurchase( bom.OrganCode(), bom.ComponentCode(), bom.ComponentType());
         }
     }
+    
+    
+    //
+    //keyProductList := construct( Strings );
+    //if( isKeyProduct ) {
+    //    keyProductList := selectuniquevalues( globalOTDTable, Global_MappingProduct_MP, item, item.ProductMajorType()="鎴愬搧" or item.ProductMajorType()="鍗婃垚鍝�", item.ID() );
+    //}
+    //bomList := selectsortedset(  globalOTDTable, Global_MappingOperationBOM, item,
+    //                             ifexpr( isnull( businessTypes ) or businessTypes.Size() = 0, 
+    //                                     true, 
+    ////                                     businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 )
+    //                                     businessTypes.Find( item.BusinessType() ) >= 0 )
+    ////                             and ifexpr( isKeyProduct, 
+    ////                                         keyProductList.Size() > 0 and keyProductList.Find( item.ComponentCode() ) >= 0,
+    ////                                         true )
+    //                             ,
+    //                             item.OrganCode() + "_" + item.ProductCode() + "_" + item.ProcessSection() );
+    //// 鎸塺outing鍙妑outingStep鍒嗙粍
+    //routingIds := selectuniquevalues( bomList, Elements, item, true, item.OrganCode() + "_" + item.ProductCode() );
+    //traverse( routingIds, Elements, routingId ) {
+    //    routingRows := selectset( bomList, Elements, item, true, routingId = item.OrganCode() + "_" + item.ProductCode() );
+    //    if( routingRows.Size() > 0 ) {
+    //        firstRow := routingRows.Element( 0 );
+    ////        stockingPointId := firstRow.OrganCode()  + "_" + firstRow.ProductType() + "_Stock";
+    ////        inputStockingPointId := firstRow.OrganCode()  + "_" + firstRow.ComponentType() + "_Stock";
+    //        stockingPointId := firstRow.OrganCode()  + "_Stock";
+    //
+    //        // ========妫�鏌�========
+    //        product := Product_MP::FindProductTypeIndex( firstRow.ProductCode() );
+    //        if( not isnull( product ) ) {
+    ////              error( "product : " + firstRow.ProductCode() + " not found" );
+    //          stockingPoint := StockingPoint_MP::FindStockingPointTypeIndex( stockingPointId );
+    //
+    ////          info( stockingPointId.AsQUILL() );
+    //  //        if( isnull( stockingPoint ) ) {
+    //  //            error( "stockingPoint : " + stockingPointId + " not found" );
+    //  //        }
+    //          routing := Routing::FindRoutingTypeIndex(  routingId );
+    //          if( not isnull( routing ) ) {
+    ////              error( "routing : " + routingId + " not found" );
+    //            // ========澶勭悊杈撳嚭========
+    //            if( not isnull( stockingPoint ) ) {
+    ////              info( 1 );
+    //              operationsInLastSteps := Operation::FindFinalOperationsByRoutingId( this, routingId );
+    //              traverse( operationsInLastSteps, Elements, operationsInLastStep ) {
+    //                  operationsInLastStep.CreateOperationBOM( product, stockingPoint, false, true );
+    //                  operationsInLastStep.GetOperationBOM( product.ID(), stockingPoint.ID(), false ).Quantity( 1 );
+    //              }
+    //              // ========鍒嗙粍澶勭悊杈撳叆========
+    //              
+    //            }
+    //            if( not isnull( stockingPoint)){
+    //              if( isKeyProduct){
+    //                  keyRows := selectset( routingRows,Elements,routingrow,keyProductList.Find( routingrow.ComponentCode())>=0);
+    //                  this.MappingOperationBOMDataRouting( routing,globalOTDTable,keyRows);
+    //                }else{
+    //                  this.MappingOperationBOMDataRouting( routing,globalOTDTable,routingRows);
+    //                }
+    //                
+    //            }
+    //          }
+    //       }
+    //    }
+    //}
+    //if( createPurchaseSupplyMaterial ) {
+    //    toCreateBomList := selectuniquevalues( bomList, Elements, item, 
+    //                                           item.ComponentType() = "P", item.OrganCode() + item.ComponentCode());
+    //    traverse( toCreateBomList, Elements, key ) {
+    //        boms := selectset( bomList, Elements, item, item.ComponentType() = "P" and item.OrganCode() + item.ComponentCode() = key );
+    //        bom := boms.First();
+    //        this.MappingOperationBOMDataSupplyPurchase( bom.OrganCode(), bom.ComponentCode(), bom.ComponentType());
+    //    }
+    //}
   *]
 }

--
Gitblit v1.9.3