From adfa4e3c3a15bbdfb634b49a552505d40742d046 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期四, 19 九月 2024 16:25:09 +0800
Subject: [PATCH] 财务产量/销量报表改动

---
 _Main/BL/Type_FinancialSalesReport/Method_Generate.qbl                |    4 
 _Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl        |  106 +++++++++++++++++++----------------
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl   |   21 ++++---
 _Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentTJ.qbl |    3 
 _Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentFS.qbl |    3 
 _Main/BL/Type_FinancialProductionReport/Method_Generate.qbl           |    2 
 _Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentCC.qbl |    3 
 7 files changed, 79 insertions(+), 63 deletions(-)

diff --git a/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl b/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
index d0781ad..c7c7b0d 100644
--- a/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
+++ b/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
@@ -25,7 +25,7 @@
         showrow := this.FinancialProductionRow( relnew, Name := row.Name(), Unit := row.Unit(), RowNr := row.RowNr() );
         
         traverse( row, FinancialProductionCell, cell, not cell.FinancialProductionColumn().IsDay() ){
-          column   := selectobject( this, FinancialProductionColumn, column, column.Name() = cell.FinancialProductionColumn().Name() );
+          column   := selectobject( this, FinancialProductionColumn, column, column.Name() = cell.FinancialProductionColumn().Name() and not column.IsDay() );
           
           sumcell  := selectobject( column, FinancialProductionCell, c, c.FinancialProductionRow() = sumrow );
           if( isnull( sumcell ) ){
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
index 54ffc0b..46586af 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
@@ -11,10 +11,10 @@
     owner.FPImportData( relflush );
     ccunit                    := FinancialProductionReport::GetDefaultCCUnit();
     dlunit                    := FinancialProductionReport::GetDefaultDLUnit();
-    ccalineunit               := FinancialProductionReport::GetDefaultCCALineUnit();
-    dlalienunit               := FinancialProductionReport::GetDefaultDLALineUnit()
-    ccmplineunit              := FinancialProductionReport::GetDefaultCCMPLineUnit()
-    dlmplineunit              := FinancialProductionReport::GetDefaultDLMPLineUnit();
+    //ccalineunit               := FinancialProductionReport::GetDefaultCCALineUnit();
+    //dlalienunit               := FinancialProductionReport::GetDefaultDLALineUnit()
+    //ccmplineunit              := FinancialProductionReport::GetDefaultCCMPLineUnit()
+    //dlmplineunit              := FinancialProductionReport::GetDefaultDLMPLineUnit();
     allunit                   := FinancialProductionReport::GetDefaultAllUnit();
     source                    := owner.FinancialProductionSource( relnew, IsImport := false, Name := FinancialProductionReport::GetDefaultName() );
     table                     := source.FinancialProductionReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
@@ -35,13 +35,16 @@
     //currentperiods            := table.GetCurrentPeriod( startofplanning, periods );
     table.GenerateColumn( owner );
     //鍙栧綋鍓嶇増鏈殑product planning閲宯ew supply瀛楁锛屽垎澶ц繛鍜岄暱鏄ュ伐鍘傜殑浜х嚎锛岃繘琛屽姞鎬�
-    traverse( owner, StockingPoint_MP, stockingpoint ){
-      unit                    := stockingpoint.Unit();
-      parentunits             := unit.GetAllParent();
+    //traverse( owner, StockingPoint_MP, stockingpoint ){
+    traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '鍘傚唴搴�' ) ){
+      iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '闀挎槬' );
+      isdl                    := stockingpoint.ID().StartsWith( 'DL' ) or stockingpoint.ID().StartsWith( '澶ц繛' );
+    //  unit                    := stockingpoint.Unit();
+    //  parentunits             := unit.GetAllParent();
       //鏄惁灞炰簬闀挎槬宸ュ巶
-      iscc                    := unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
+    //  iscc                    := unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
       //鏄惁灞炰簬澶ц繛宸ュ巶
-      isdl                    := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
+    //  isdl                    := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
       if( iscc or isdl ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
                   and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){
diff --git a/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl b/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl
index 767f175..4c67240 100644
--- a/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl
+++ b/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl
@@ -24,8 +24,8 @@
       if( productids.ContainsAll( productid ) ){
         showrow := this.FinancialSalesRow( relnew, Name := row.Name(), Unit := row.Unit(), RowNr := row.RowNr() );
         
-        traverse( row, FinancialSalesCell, cell ){
-          column   := selectobject( this, FinancialSalesColumn, column, column.Name() = cell.FinancialSalesColumn().Name() );
+        traverse( row, FinancialSalesCell, cell, not cell.FinancialSalesColumn().IsDay() ){
+          column   := selectobject( this, FinancialSalesColumn, column, column.Name() = cell.FinancialSalesColumn().Name() and not column.IsDay());
           
           sumcell  := selectobject( column, FinancialSalesCell, c, c.FinancialSalesRow() = sumrow );
           if( isnull( sumcell ) ){
diff --git a/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentCC.qbl b/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentCC.qbl
index 05eb2ce..09d35f1 100644
--- a/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentCC.qbl
+++ b/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentCC.qbl
@@ -5,7 +5,8 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jun-28-2024 (created)
-    return '闀挎槬';
+    //return '闀挎槬';
+    return 'Changchun';
     //return 'China';
   *]
 }
diff --git a/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentFS.qbl b/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentFS.qbl
index 70e1ce3..5c44d38 100644
--- a/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentFS.qbl
+++ b/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentFS.qbl
@@ -5,7 +5,8 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jun-28-2024 (created)
-    return '浣涘北';
+    //return '浣涘北';
+    return 'Foshan';
     //return 'Germany';
   *]
 }
diff --git a/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentTJ.qbl b/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentTJ.qbl
index 7ad4f41..73cba9b 100644
--- a/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentTJ.qbl
+++ b/_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentTJ.qbl
@@ -5,7 +5,8 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jun-28-2024 (created)
-    return '澶╂触';
+    //return '澶╂触';
+    return 'Tianjin';
     //return 'USA';
   *]
 }
diff --git a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
index 500883e..2ac9f43 100644
--- a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
@@ -16,9 +16,9 @@
     ccsalessegment            := FinancialSalesReport::GetSalesSegmentCC();
     tjsalessegment            := FinancialSalesReport::GetSalesSegmentTJ();
     fssalessegment            := FinancialSalesReport::GetSalesSegmentFS();
-    ccspline                  := FinancialSalesReport::GetStockingPointCCLine();
-    dlspline                  := FinancialSalesReport::GetStockingPointDLLine();
-    ccrent                    := FinancialSalesReport::GetStockingPointCCRent();
+    //ccspline                  := FinancialSalesReport::GetStockingPointCCLine();
+    //dlspline                  := FinancialSalesReport::GetStockingPointDLLine();
+    //ccrent                    := FinancialSalesReport::GetStockingPointCCRent();
     
     source                    := owner.FinancialSalesSource( relnew, IsImport := false, Name := FinancialSalesReport::GetDefaultName() );
     table                     := source.FinancialSalesReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
@@ -37,11 +37,15 @@
       salessegment            := forecast.SalesSegment_MP();
       parentsalessegments     := salessegment.GetAllParent();
       //鏄惁灞炰簬闀挎槬
-      iscc                    := salessegment.Name() = ccsalessegment or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = ccsalessegment );
+    //  iscc                    := salessegment.Name() = ccsalessegment or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = ccsalessegment );
+      iscc                    := salessegment.Name().StartsWith( ccsalessegment ) or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( ccsalessegment ) );
       //鏄惁灞炰簬澶ц繛, 鍗冲ぉ娲ュ拰浣涘北
-      isdl                    := salessegment.Name() = tjsalessegment or salessegment.Name() = fssalessegment 
-                                  or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = tjsalessegment ) 
-                                  or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = fssalessegment );
+    //  isdl                    := salessegment.Name() = tjsalessegment or salessegment.Name() = fssalessegment 
+    //                              or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = tjsalessegment ) 
+    //                              or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = fssalessegment );
+      isdl                    := salessegment.Name().StartsWith( tjsalessegment ) or salessegment.Name().StartsWith( fssalessegment )
+                                  or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( tjsalessegment ) ) 
+                                  or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( fssalessegment ) );
       //Forecast鐨凷ales Segment涓洪暱鏄ワ紝璇嗗埆鍑篗LB鐨勬墍鏈変骇鍝佹眹鎬�
       //澶ц繛璐㈠姟閿�閲忥細棣栧厛鍦╢orecast鐣岄潰鏌ユ壘Sales Segment鏄ぉ娲ュ拰浣涘北鐨勬墍鏈夐渶姹傦紝姣忎釜浜у搧鎸夋湀姹囨�婚渶姹傛暟閲�
       if( ( iscc and forecast.Product_MP().MQBMLB() = 'MLB' ) or isdl ){
@@ -69,70 +73,76 @@
         }
       }
     }
-    //浠嶱roduct planning鏌ユ壘搴撳瓨鐐逛负闀挎槬瑁呴厤绾胯竟搴撶殑鎵�鏈塎QB浜у搧锛屽彇Total Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲�
-    traverse( owner, StockingPoint_MP, stockingpoint ){
+    //浠嶱roduct planning鏌ユ壘搴撳瓨鐐逛负闀挎槬瑁呴厤绾胯竟搴�(CC鍘傚唴搴�)鐨勬墍鏈塎QB浜у搧锛屽彇Total Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲�
+    //浠嶱roduct planning鏌ユ壘搴撳瓨鐐逛负澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴擄紝鍙朜ew supply瀛楁鎸夋湀姹囨�婚渶姹傛暟閲�
+    //traverse( owner, StockingPoint_MP, stockingpoint ){
+    traverse( owner, StockingPoint_MP, stockingpoint, ( stockingpoint.ID().StartsWith( 'CC' ) and stockingpoint.ID().EndsWith( '鍘傚唴搴�' ) ) or stockingpoint.ID() = '澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�' ){
+      isdl                  := stockingpoint.ID() = '澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�';
     //  unit                  := stockingpoint.Unit();
     //  parentunits           := unit.GetAllParent();
       //鏄惁灞炰簬闀挎槬瑁呴厤绾�
     //  iscc                  := unit.ID() = ccspline or exists( parentunits, Elements, punit, punit.ID() = ccspline );
-      if( table.IsInUnit( stockingpoint, ccspline ) ){
+    //  if( table.IsInUnit( stockingpoint, ccspline ) ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and pisp.Product_MP().MQBMLB() = 'MQB' 
-                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ) ){//浜у搧涓篗QB
+                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear 
+                              and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ) ){//浜у搧涓篗QB
           product           := pisp.Product_MP();
           allrow            := table.GetRow( allunit, product );
           ccrow             := table.GetRow( ccunit, product );
           products.Add( product );
-          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ){
+          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() 
+                    and pispip.Period_MP().StartDate() < startofnextyear 
+                    and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ){
             dayperiodtime   := pispip.Start().Date();
             dayperiodname   := dayperiodtime.Format( "M2/D2/Y" );
             periodtime      := pispip.Start().StartOfMonth().Date();
             periodname      := periodtime.Format( "M2/D2/Y" );
             daycolumn       := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
             column          := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
-            quantity        := [Number]pispip.DependentDemandAndSalesDemandQuantity();//鍥涜垗浜斿叆
+            quantity        := ifexpr( isdl, [Number]pispip.NewSupplyQuantity(), [Number]pispip.DependentDemandAndSalesDemandQuantity() );//鍥涜垗浜斿叆
             
             ccrow.Initialize( column, quantity );//鍙朤otal Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲�
             ccrow.Initialize( daycolumn, quantity );
             allrow.Initialize( column, quantity );
           }
         }
-      }
+    //  }
     }
-    startofnextyearlead       := startofplanning.StartOfNextYear() + FinancialSalesReport::GetDefaultTripLeadingTime();
+    //startofnextyearlead       := startofplanning.StartOfNextYear() + FinancialSalesReport::GetDefaultTripLeadingTime();
     //澶ц繛璐㈠姟閿�閲忥細闀挎槬鐨勯渶姹傞渶瑕佸湪trip plan閲岄潰鎵惧埌璧峰搴撳瓨鐐逛负澶ц繛瑁呴厤绾胯竟搴擄紝鐩殑鍦颁负闀挎槬澶栫搴撶殑浜у搧锛岀敱浜庨渶瑕佽�冭檻浜у搧杩愯緭lead time锛屾瘡涓湀鐨勬眹鎬绘暟鎹渶瑕佹帹杩熶袱澶╄繘琛岃绠�
-    traverse( owner, Unit.Lane.LaneLeg, laneleg ){
-      //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛瑁呴厤绾胯竟搴�
-      originsp              := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.OriginStockingPointID() );
-      isdlspline            := table.IsInUnit( originsp, dlspline );
-      //鐩殑鍦版槸鍚︽槸闀挎槬澶栫搴�
-      destisp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() );
-      isccrent              := table.IsInUnit( destisp, ccrent );
-      if( isdlspline and isccrent ){
-        traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead and exists( trip, ProductInTrip, pit, pit.Quantity() <> 0 ) ){
-    //      periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
-          dayperiodtime     := trip.Departure().Date();
-          dayperiodname     := dayperiodtime.Format( "M2/D2/Y" );
-          periodtime        := trip.Departure().StartOfMonth().Date();
-          periodname        := periodtime.Format( "M2/D2/Y" );
-          
-          daycolumn         := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
-          column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
-          if( not isnull( column ) ){
-            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
-              product       := pit.Product_MP();
-              products.Add( product );
-              quantity      := [Number]pit.Quantity();//鍥涜垗浜斿叆
-              dlrow         := table.GetRow( dlunit, pit.Product_MP() );
-              dlrow.Initialize( column, quantity );//姹囨�绘暟閲�
-              dlrow.Initialize( daycolumn, quantity );
-              
-              allrow        := table.GetRow( allunit, pit.Product_MP() );
-              allrow.Initialize( column, quantity );
-            }
-          }
-        }
-      }
-    }
+    //traverse( owner, Unit.Lane.LaneLeg, laneleg ){
+    //  //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛瑁呴厤绾胯竟搴�
+    //  originsp              := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.OriginStockingPointID() );
+    //  isdlspline            := table.IsInUnit( originsp, dlspline );
+    //  //鐩殑鍦版槸鍚︽槸闀挎槬澶栫搴�
+    //  destisp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() );
+    //  isccrent              := table.IsInUnit( destisp, ccrent );
+    //  if( isdlspline and isccrent ){
+    //    traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead and exists( trip, ProductInTrip, pit, pit.Quantity() <> 0 ) ){
+    ////      periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
+    //      dayperiodtime     := trip.Departure().Date();
+    //      dayperiodname     := dayperiodtime.Format( "M2/D2/Y" );
+    //      periodtime        := trip.Departure().StartOfMonth().Date();
+    //      periodname        := periodtime.Format( "M2/D2/Y" );
+    //      
+    //      daycolumn         := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
+    //      column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
+    //      if( not isnull( column ) ){
+    //        traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
+    //          product       := pit.Product_MP();
+    //          products.Add( product );
+    //          quantity      := [Number]pit.Quantity();//鍥涜垗浜斿叆
+    //          dlrow         := table.GetRow( dlunit, pit.Product_MP() );
+    //          dlrow.Initialize( column, quantity );//姹囨�绘暟閲�
+    //          dlrow.Initialize( daycolumn, quantity );
+    //          
+    //          allrow        := table.GetRow( allunit, pit.Product_MP() );
+    //          allrow.Initialize( column, quantity );
+    //        }
+    //      }
+    //    }
+    //  }
+    //}
     
     rows := selectsortedset( table, FinancialSalesRow, row, row.Name() );
     i    := 0;

--
Gitblit v1.9.3