From 964b4387b4b3ba025c996b1f04fa75f72ae5da09 Mon Sep 17 00:00:00 2001
From: renhao <renhui.hao@capgemini.com>
Date: 星期五, 22 九月 2023 14:28:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev'

---
 _Main/BL/Type_ScenarioManager/Method_CapacityAndSaleBudgeCompare.qbl |  109 ++++++++++++++++++++++++++----------------------------
 1 files changed, 52 insertions(+), 57 deletions(-)

diff --git a/_Main/BL/Type_ScenarioManager/Method_CapacityAndSaleBudgeCompare.qbl b/_Main/BL/Type_ScenarioManager/Method_CapacityAndSaleBudgeCompare.qbl
index a2a5dc7..a441cd3 100644
--- a/_Main/BL/Type_ScenarioManager/Method_CapacityAndSaleBudgeCompare.qbl
+++ b/_Main/BL/Type_ScenarioManager/Method_CapacityAndSaleBudgeCompare.qbl
@@ -37,71 +37,63 @@
     this.CapacityAndSaleBudgeCompareItemRow( relflush );
     this.CapacityAndSaleBudgeCompareItemColumn( relflush );
     // ====姹囨�绘墍鏈夊嚭鐜扮殑浜у搧====
-    productCodeList := construct( Strings );
     historyData := selectset( mpSync, MappingCapacityAndSaleBudge, item, true );
+    info( "historyData : " + [String]historyData.Size() )
     traverse( historyData, Elements, one ) {
-      productCodeList.Add( one.ProductCode() );
-    }
-    traverse( macroPlans, Elements, macroPlan ) {
-      traverse( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, pispip ) {
-        productCodeList.Add( pispip.ProductInStockingPoint_MP().Product_MP().ID() );
-      }
-    }
-    productCodeList := selectuniquevalues( productCodeList, Elements, item, item );
-    info( "product count : " + [String]productCodeList.Size() )
-    // ====鏍规嵁浜у搧鏌ヤ簨涓氶儴鍜岀粍缁囩紪鐮侊紝鐒跺悗鎸変簨涓氶儴鍜岀粍缁囩紪鐮佹眹鎬�====
-    traverse( productCodeList, Elements, productCode ) {
-      bom := MappingBOM::CreateTestData( mappingParent, [String](productCode.Length() mod 3), [String](productCode.Length() mod 4) );
-    //  bom := select( mappingParent, MappingBOM, bom, bom.ProductCode() = productCode );
-      if( not isnull( bom ) ) {
+      productCode := one.ProductCode();
+      MappingBOM::CreateTestData( mappingParent, "浜嬩笟閮�" + [String](productCode.Length() mod 3), [String](productCode.Length() mod 4), productCode );
+      boms := selectset( mappingParent, MappingBOM, bom, bom.ProductCode() = productCode );
+      if( boms.Size() > 0 ) {
+        bom := boms.First();
         businessType := bom.BusinessType();
-        orgCode := bom.OrganCode();
-        row := CapacityAndSaleBudgeCompareItemRow::CreateIfNotExist( this, businessType, orgCode );
+        placeOfProductionOfArray := one.PlaceOfProductionOfArray();
+        // 鐩稿悓闈㈡澘鍩哄湴鍜屼簨涓氶儴鐨勬斁涓�琛�
+        row := CapacityAndSaleBudgeCompareItemRow::CreateIfNotExist( this, businessType, placeOfProductionOfArray );
         // 璁板綍姣忚鍖呭惈鍝簺product
         CapacityAndSaleBudgeCompareItemRowProduct::CreateIfNotExist( row, productCode );
+      } else {
+        info( "no boms for product : " + productCode );
       }
     }
+    info( "CapacityAndSaleBudgeCompareItemRow : " + [String]selectset( this, CapacityAndSaleBudgeCompareItemRow, item, true ).Size() );
     // ====浠庡乏鍚戝彸鐢熸垚鍒楀ご涓庡唴瀹�====
     // 浜嬩笟閮紝缁勭粐
-    info( "dealing businessType and orgCode" )
+    info( "dealing businessType and placeOfProductionOfArray" )
     columnBusinessType := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "浜嬩笟閮�" );
-    columnOrgCode := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "缁勭粐缂栫爜" );
+    columnPlaceOfProductionOfArray := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "闈㈡澘鍩哄湴" );
     traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
       cell := columnBusinessType.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := row.BusinessType() );
       cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
-      cell := columnOrgCode.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := row.OrgCode() );
+      cell := columnPlaceOfProductionOfArray.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := row.PlaceOfProductionOfArray() );
       cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
     }
     // 闈㈡澘鍒嗛厤閲� - 骞村害棰勭畻 (sheets)
     // 鏍煎紡锛� 闈㈡澘鍒嗛厤閲� - 骞� - 鏈堬紙1-12 & total锛� - 骞村害棰勭畻/scenarioName
     info( "dealing 闈㈡澘鍒嗛厤閲�" )
     if( CapacityAndSaleBudgeFilterItem::Contains( items, "闈㈡澘鍒嗛厤閲�" ) ) {
-      // 鍘嗗彶鏁版嵁
-      traverse( months, Elements, month ) {
-        columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "闈㈡澘鍒嗛厤閲�-" + "-" + [String]month.MonthNo() + "鏈�-骞村害棰勭畻" );
+      traverse( years, Elements, year ) {
+        // 鍘嗗彶鏁版嵁
+        traverse( months, Elements, month ) {
+          columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "闈㈡澘鍒嗛厤閲�-" + [String]year.YearNo() + "骞�-" + [String]month.MonthNo() + "鏈�-骞村害棰勭畻" );
+          traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
+            cellReal := MappingCapacityAndSaleBudge::GetSheetByMonth( row.GetProductCodes(), mpSync, DateTime::Now().Year(), month.MonthNo() );
+            cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
+            cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
+          }
+        }
+        columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "闈㈡澘鍒嗛厤閲�-" + [String]year.YearNo() + "骞�-total-骞村害棰勭畻" );
         traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
-          cellReal := CapacityAndSaleBudge::GetSheetByMonth( row.GetProductCodes(), otdTable, DateTime::Now().Year(), month.MonthNo() );
-          cellReal := Real::Random( 1.0, 999.0 );
-          cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
+          cellReal := MappingCapacityAndSaleBudge::GetSheetByYear( row.GetProductCodes(), mpSync, year.YearNo() );
+          cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
           cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
         }
-      }
-      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "闈㈡澘鍒嗛厤閲�-total-骞村害棰勭畻" );
-      traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
-        cellReal := CapacityAndSaleBudge::GetSheetByYear( row.GetProductCodes(), otdTable, DateTime::Now().Year() );
-        cellReal := Real::Random( 1.0, 999.0 );
-        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
-        cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
-      }
-      // S&OP鏁版嵁
-      traverse( years, Elements, year ) {
+        // S&OP鏁版嵁
         traverse( macroPlans, Elements, macroPlan ) {
           traverse( months, Elements, month ) {
             columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, 
                                                                                     "闈㈡澘鍒嗛厤閲�-" + [String]year.YearNo() + "骞�-" + [String]month.MonthNo() + "鏈�-" + macroPlan.ScenarioName() );
             traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
               cellReal := Product_MP::GetNewSupplyByMonth( row.GetProductCodes(), macroPlan, year.YearNo(), month.MonthNo() );
-              cellReal := Real::Random( 1.0, 999.0 );
               cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
               cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
             }
@@ -110,7 +102,6 @@
                                                                                  "闈㈡澘鍒嗛厤閲�-" + [String]year.YearNo() + "骞�-total-" + macroPlan.ScenarioName() );
           traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
             cellReal := Product_MP::GetNewSupplyByYear( row.GetProductCodes(), macroPlan, year.YearNo() );
-            cellReal := Real::Random( 1.0, 999.0 );
             cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
             cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
           }
@@ -120,37 +111,36 @@
     // 骞村害閿�鍞
     info( "dealing 閿�鍞" )
     if( CapacityAndSaleBudgeFilterItem::Contains( items, "閿�鍞" ) ) {
-      // 鍘嗗彶鏁版嵁
-      traverse( months, Elements, month ) {
-        columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "瀵瑰閿�鍞-" + "-" + [String]month.MonthNo() + "鏈�-骞村害棰勭畻" );
+      traverse( years, Elements, year ) {
+        // 鍘嗗彶鏁版嵁
+        traverse( months, Elements, month ) {
+          columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "瀵瑰閿�鍞-" + [String]year.YearNo() + "骞�-" + [String]month.MonthNo() + "鏈�-骞村害棰勭畻" );
+          traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
+            cellReal := MappingCapacityAndSaleBudge::GetSaleByMonth( row.GetProductCodes(), mpSync, year.YearNo(), month.MonthNo() );
+            cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
+            cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
+          }
+        }
+        columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "瀵瑰閿�鍞-" + [String]year.YearNo() + "骞�-骞村害棰勭畻" );
         traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
-          cellReal := CapacityAndSaleBudge::GetSaleByMonth( row.GetProductCodes(), otdTable, DateTime::Now().Year(), month.MonthNo() );
-          cellReal := Real::Random( 1.0, 999.0 );
-          cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
+          cellReal := MappingCapacityAndSaleBudge::GetSaleByYear( row.GetProductCodes(), mpSync, year.YearNo() );
+          cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
           cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
         }
-      }
-      columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "瀵瑰閿�鍞-total-骞村害棰勭畻" );
-      traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
-        cellReal := CapacityAndSaleBudge::GetSaleByYear( row.GetProductCodes(), otdTable, DateTime::Now().Year() );
-        cellReal := Real::Random( 1.0, 999.0 );
-        cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
-        cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
-      }
-      // S&OP鏁版嵁
-      traverse( years, Elements, year ) {
+        // S&OP鏁版嵁
         traverse( macroPlans, Elements, macroPlan ) {
           traverse( months, Elements, month ) {
             columnMonth := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "瀵瑰閿�鍞-" + [String]year.YearNo() + "骞�-" + [String]month.MonthNo() + "鏈�-" + macroPlan.ScenarioName() );
             traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
-              cellReal := MappingForecast::GetBalanceByMonth( row.GetProductCodes(), mappingParent, year.YearNo(), month.MonthNo() );
+              cellReal := MappingAnnualBudget::GetSaleByMonth( row.GetProductCodes(), mpSync, year.YearNo(), month.MonthNo() );
               cell := columnMonth.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
               cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
             }
           }
           columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "瀵瑰閿�鍞-" + [String]year.YearNo() + "骞�-total-" + macroPlan.ScenarioName() );
           traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
-            cellReal := MappingForecast::GetBalanceByYear( row.GetProductCodes(), mappingParent, year.YearNo() );
+            // QID 23
+            cellReal := MappingAnnualBudget::GetSaleByYear( row.GetProductCodes(), mpSync, year.YearNo() );
             cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]cellReal );
             cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
           }
@@ -163,6 +153,8 @@
       // 鍘嗗彶鏁版嵁
       columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "澶у紶鐩堝埄棰�-骞村害棰勭畻" );
       traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
+        // todo 
+        // QID 23
         cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 0 ) );
         cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
       }
@@ -181,6 +173,8 @@
       // 鍘嗗彶鏁版嵁
       columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "浜у搧鐩堝埄棰�-骞村害棰勭畻" );
       traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
+        // todo
+        // QID 23
         cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 0 ) );
         cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
       }
@@ -188,6 +182,7 @@
       traverse( macroPlans, Elements, macroPlan ) {
         columnYear := CapacityAndSaleBudgeCompareItemColumn::CreateIfNotExist( this, "浜у搧鐩堝埄棰�-" + [String]year.YearNo() + "骞�" );
         traverse( this, CapacityAndSaleBudgeCompareItemRow, row ) {
+          // todo
           cell := columnYear.CapacityAndSaleBudgeCompareItemCell( relnew, CellContent := [String]Number::Random( 0, 0 ) );
           cell.CapacityAndSaleBudgeCompareItemRow( relset, row );
         }
@@ -197,7 +192,7 @@
     // 璁剧疆rowNo鍜宑olumnNo
     info( "set rowNo and columnNo" );
     rowNo := 1;
-    rowSorted := selectsortedset( this, CapacityAndSaleBudgeCompareItemRow, item, item.BusinessType() + "_" + item.OrgCode() );
+    rowSorted := selectsortedset( this, CapacityAndSaleBudgeCompareItemRow, item, item.PlaceOfProductionOfArray() + "_" + item.BusinessType() );
     traverse( rowSorted, Elements, item ) {
       item.RowNo( rowNo );
       rowNo := rowNo + 1;

--
Gitblit v1.9.3