From 5e5f64f57af3862ebf7c9241dc848f97572f96b2 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期五, 01 十一月 2024 12:39:21 +0800
Subject: [PATCH] 机加管线报表库存计算bug

---
 _Main/BL/Type_InventorySummarySource/StaticMethod_InitiateSearch.qbl       |    2 
 _Main/Sys/Repr/Global/MachiningPipelineCell.qrp                            |   33 ++++
 /dev/null                                                                  |  129 ------------------
 _Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitiateSearch.qbl |    2 
 _Main/BL/Type_EnginePipelineSource/StaticMethod_InitiateSearch.qbl         |    2 
 _Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl                  |    8 +
 _Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_InitiateSearch.qbl  |    2 
 _Main/BL/Type_MachiningPipelineSource0/StaticMethod_InitiateSearch.qbl     |    2 
 _Main/BL/Type_FinancialProductionSource/StaticMethod_InitiateSearch.qbl    |    2 
 _Main/BL/Type_FinancialSalesSource/StaticMethod_InitiateSearch.qbl         |    2 
 _Main/BL/Type_EnginePipelineReport/Method_Generate.qbl                     |  174 +++++++++---------------
 _Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl         |   12 +
 12 files changed, 119 insertions(+), 251 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_InitiateSearch.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_InitiateSearch.qbl
index a6cdcd8..ffa8a1f 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_InitiateSearch.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_InitiateSearch.qbl
@@ -10,7 +10,7 @@
     allunit                   := DLEngineLogisticsCostReport::GetDefaultAllUnit();
     search                    := owner.CCEngineLogisticsCostSearch();
     if( isnull( search ) ){
-      owner.CCEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit );
+      search                  := owner.CCEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit );
     }else{
       search                  := owner.CCEngineLogisticsCostSearch();
       search.Generation( allunit );
diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitiateSearch.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitiateSearch.qbl
index 997f6ba..d951643 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitiateSearch.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitiateSearch.qbl
@@ -10,7 +10,7 @@
     allunit                   := DLEngineLogisticsCostReport::GetDefaultAllUnit();
     search                    := owner.DLEngineLogisticsCostSearch();
     if( isnull( search ) ){
-      owner.DLEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit );
+      search                  := owner.DLEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit );
     }else{
       search                  := owner.DLEngineLogisticsCostSearch();
       search.Generation( allunit );
diff --git a/_Main/BL/Type_EnginePipelineReport/Method_Generate.qbl b/_Main/BL/Type_EnginePipelineReport/Method_Generate.qbl
index 5a7b2b7..cf500dd 100644
--- a/_Main/BL/Type_EnginePipelineReport/Method_Generate.qbl
+++ b/_Main/BL/Type_EnginePipelineReport/Method_Generate.qbl
@@ -24,11 +24,12 @@
     sumstr                  := sumname.Format( 'S(Len(10))' );
     sumrowproduction        := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '鎬讳骇閲�' ), sumname, '', rows.Size() * cellnr );
     sumrowdlproduction      := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '澶ц繛浜ч噺' ), sumname, '', sumrowproduction.RowNr() + 1 );
-    sumrowccproduction      := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '闀挎槬浜ч噺' ), sumname, '', sumrowproduction.RowNr() + 2  );
-    sumrowdemand            := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '鎬婚渶姹�' ), sumname, '', sumrowproduction.RowNr() + 3 );
-    rowno                   := sumrowproduction.RowNr() + 4;
+    sumrowccproduction      := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '闀挎槬浜ч噺' ), sumname, '', sumrowdlproduction.RowNr() + 1  );
+    sumrowdemand            := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '鎬婚渶姹�' ), sumname, '', sumrowccproduction.RowNr() + 1 );
+    sumdemandrows           := construct( EnginePipelineRows );
+    rowno                   := sumrowdemand.RowNr() + 1;
     traverse( models, Elements, model ){
-      EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( model.Concat( '闇�姹�' ) ), sumname, model, rowno ); 
+      sumdemandrows.Add( EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( model.Concat( '闇�姹�' ) ), sumname, model, rowno ) ); 
       rowno                 := rowno + 1;
     }
     sumrowinventory         := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '搴撳瓨' ), sumname, '', rowno );
@@ -36,138 +37,93 @@
     //琛岃鏁�
     rownr                   := 0;
     traverse( rows, Elements, row, productids.Find( row.Name() ) >= 0 ){
-      rowname             := row.Name().Format( 'S(Len(10))' );
-      showrowproduction   := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '鎬讳骇閲�' ), row.Name(), '', rownr );
-      showrowdlproduction := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '澶ц繛浜ч噺' ), row.Name(), '', rownr + 1 );
-      showrowccproduction := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '闀挎槬浜ч噺' ), row.Name(), '', rownr + 2 );
-      showrowdemand       := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '鎬婚渶姹�' ), row.Name(), '', rownr + 3 );
-      rownr               := rownr + 4;
-      modelsnr            := rownr + 3;
-      models              := construct( Strings );
-      uniquemodels        := selectuniquevalues( row, Cell.Demand, demand, true, demand.Model() );
-    
+      rowname               := row.Name().Format( 'S(Len(10))' );
+      showrowproduction     := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '鎬讳骇閲�' ), row.Name(), '', rownr );
+      showrowdlproduction   := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '澶ц繛浜ч噺' ), row.Name(), '', showrowproduction.RowNr() + 1 );
+      showrowccproduction   := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '闀挎槬浜ч噺' ), row.Name(), '', showrowdlproduction.RowNr() + 1 );
+      showrowdemand         := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '鎬婚渶姹�' ), row.Name(), '', showrowccproduction.RowNr() + 1 );
+      rownr                 := showrowdemand.RowNr() + 1;
+      modelsnr              := showrowdemand.RowNr() + 4;
+      uniquemodels          := selectuniquevalues( row, Cell.Demand, demand, true, demand.Model() );
+      demandrows            := construct( EnginePipelineRows );
       traverse( uniquemodels, Elements, e ){
     
         if( rownr < modelsnr ){
-          EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( e.Concat( '闇�姹�' ) ), row.Name(), e, rownr ); 
-          models.Add( e );
+          demandrows.Add( EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( e.Concat( '闇�姹�' ) ), row.Name(), e, rownr ) ); 
           rownr             := rownr + 1;
         }
       }
     
       for( rownr := rownr; rownr < modelsnr; rownr ++ ){
     
-        EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '' ), row.Name(), '', rownr ); 
+        demandrows.Add( EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '' ), row.Name(), '', rownr ) ); 
       }
-      showrowinventory    :=  EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '搴撳瓨' ), row.Name(), '', rownr );
+      showrowinventory      :=  EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '搴撳瓨' ), row.Name(), '', rownr );
     
-      traverse( row, Cell, cell, cell.Column().TimeUnit() = search.TimeUnit() ){
-    
-        column            := selectobject( this, Column, column, column.StartDate() = cell.Column().StartDate() and column.TimeUnit() = search.TimeUnit() );
+      traverse( this, Column, column ){
+        daycells            := selectset( row, Cell, cell, cell.Column().TimeUnit() = Translations::MP_GlobalParameters_Day() and
+                                            cell.Column().StartDate() >= column.StartDate() and 
+                                            cell.Column().StartDate() <= column.EndDate() );
         
-        if( not isnull( column ) ){
-          
-          //鐢熶骇
-          production              := column.CellValue( relnew, Value := [String]cell.ProductionQuantity() );
-          showrowproduction.CellValue( relinsert, production );
-          sumproduction           := selectobject( column, CellValue, c, c.Row() = sumrowproduction );
-    
-          if( isnull( sumproduction ) ){
-            sumproduction         := column.CellValue( relnew, Value := [String]0 );
-            sumrowproduction.CellValue( relinsert, sumproduction );
+        //鐢熶骇
+        productionqty       := [Number]sum( daycells, Elements, cell, cell.ProductionQuantity() );
+        production          := selectobject( column, CellValue, c, c.Row() = showrowproduction );
+        production.Value( [String]productionqty );
+        sumproduction       := selectobject( column, CellValue, c, c.Row() = sumrowproduction );
+        sumproduction.Value( [String]( [Real]sumproduction.Value() + productionqty ) );
+        //澶ц繛浜ч噺
+        dlproductionqty     := [Number]sum( daycells, Elements.Production, cellproduction, cellproduction.DLProduction() );
+        dlproduction        := selectobject( column, CellValue, c, c.Row() = showrowdlproduction );
+        dlproduction.Value( [String]dlproductionqty );
+        sumdlproduction     := selectobject( column, CellValue, c, c.Row() = sumrowdlproduction );
+        sumdlproduction.Value( [String]( [Real]sumdlproduction.Value() + dlproductionqty ) );
+        //闀挎槬浜ч噺
+        ccproductionqty     := [Number]sum( daycells, Elements.Production, cellproduction, cellproduction.CCProduction() );
+        ccproduction        := selectobject( column, CellValue, c, c.Row() = showrowccproduction );
+        ccproduction.Value( [String]ccproductionqty );
+        sumccproduction     := selectobject( column, CellValue, c, c.Row() = sumrowccproduction );
+        sumccproduction.Value( [String]( [Real]sumccproduction.Value() + ccproductionqty ) );
+        //闇�姹�
+        totaldemandqty      := [Number]sum( daycells, Elements, cell, cell.DemandQuantity() );
+        totaldemand         := selectobject( column, CellValue, c, c.Row() = showrowdemand );
+        totaldemand.Value( [String]totaldemandqty );
+        sumdemand           := selectobject( column, CellValue, c, c.Row() = sumrowdemand );
+        sumdemand.Value( [String]( [Real]sumdemand.Value() + totaldemandqty ) );
+        //鍏蜂綋闇�姹�
+        traverse( demandrows, Elements, demandrow ){
+          demandqty         :=  [Number]sum( daycells, Elements.Demand, celldemand, celldemand.Model() = demandrow.Demand(), celldemand.Quantity() );
+          demandcell        := selectobject( column, CellValue, c, c.Row() = demandrow );
+          demandcell.Value( [String]demandqty );
+          sumdemandrow      := selectobject( sumdemandrows, Elements, r, r.Demand() = demandrow.Demand() );
+          if( not isnull( sumdemandrow ) ){
+            sumdemandcell   := selectobject( column, CellValue, c, c.Row() = sumdemandrow );
+            sumdemandcell.Value( [String]( [Real]sumdemandcell.Value() + demandqty ) );
           }
-          sumproduction.Value( [String]( [Real]sumproduction.Value() + cell.ProductionQuantity() ) );
-    
-          //澶ц繛浜ч噺
-          dlproductionquantity     := guard( cell.Production().DLProduction(), 0 );
-          dlproduction             := column.CellValue( relnew, Value := [String]dlproductionquantity );
-          showrowdlproduction.CellValue( relinsert, dlproduction );
-          sumdlproduction          := selectobject( column, CellValue, c, c.Row() = sumrowdlproduction );
-    
-          if( isnull( sumdlproduction ) ){
-            sumdlproduction        := column.CellValue( relnew, Value := [String]0 );
-            sumrowdlproduction.CellValue( relinsert, sumdlproduction );
-          }
-          sumdlproduction.Value( [String]( [Real]sumdlproduction.Value() + dlproductionquantity ) );
-          
-          //闀挎槬浜ч噺
-          ccproductionquantity     := guard( cell.Production().CCProduction(), 0 );
-          ccproduction             := column.CellValue( relnew, Value := [String]ccproductionquantity );
-          showrowccproduction.CellValue( relinsert, ccproduction );
-          sumccproduction          := selectobject( column, CellValue, c, c.Row() = sumrowccproduction );
-    
-          if( isnull( sumccproduction ) ){
-            sumccproduction        := column.CellValue( relnew, Value := [String]0 );
-            sumrowccproduction.CellValue( relinsert, sumccproduction );
-          }
-          sumccproduction.Value( [String]( [Real]sumccproduction.Value() + ccproductionquantity ) );
-          
-          //闇�姹�
-          totaldemand              := column.CellValue( relnew, Value := [String]cell.DemandQuantity() );
-          showrowdemand.CellValue( relinsert, totaldemand );
-          sumdemand                := selectobject( column, CellValue, c, c.Row() = sumrowdemand );
-          if( isnull( sumdemand ) ){
-            sumdemand              := column.CellValue( relnew, Value := [String]0 );
-            sumrowdemand.CellValue( relinsert, sumdemand );
-          }
-          sumdemand.Value( [String]( [Real]sumdemand.Value() + cell.DemandQuantity() ) );
-          
-          traverse( cell, Demand, demand, exists( models, Elements, model, model = demand.Model() ) ){
-            demandrow              := selectobject( this, Row, r, r.Product() = row.Name() and r.Demand() = demand.Model() );
-            sumdemandrow           := selectobject( this, Row, r, r.Product() = sumname and r.Demand() = demand.Model() );
-    
-            if( not isnull( demandrow ) ){
-              demandcell             := column.CellValue( relnew, Value := [String]demand.Quantity() );
-              demandrow.CellValue( relinsert, demandcell );
-            }
-            if( not isnull( sumdemandrow ) ){
-            sumdemandcell          := selectobject( column, CellValue, c, c.Row() = sumdemandrow );
-            if( isnull( sumdemandcell ) ){
-              sumdemandcell        := column.CellValue( relnew, Value := [String]0 );
-              sumdemandrow.CellValue( relinsert, sumdemandcell );
-            }
-            sumdemandcell.Value( [String]( [Real]sumdemandcell.Value() + demand.Quantity() ) );
-            }
-          }
-    
-          for( demandr := showrowdemand.RowNr() + 1; demandr < showrowinventory.RowNr(); demandr := demandr + 1 ){
-            demandrow              := selectobject( this, Row, r, r.RowNr() = demandr and r.Name() = row.Name() );
-            if( not isnull( demandrow ) and not exists( demandrow, CellValue, cv, cv.Column() = column ) ){
-              demandcell           := column.CellValue( relnew, Value := '' );
-              demandrow.CellValue( relinsert, demandcell );
-            }
-          }
-    
-          
-          //搴撳瓨
-          inventory                := column.CellValue( relnew, Value := [String]cell.InventoryQuantity() );
-          showrowinventory.CellValue( relinsert, inventory );
-          suminventory             := selectobject( column, CellValue, c, c.Row() = sumrowinventory );
-          if( isnull( suminventory ) ){
-            suminventory           := column.CellValue( relnew, Value := [String]0 );
-            sumrowinventory.CellValue( relinsert, suminventory );
-          }
-          suminventory.Value( [String]( [Real]suminventory.Value() + cell.InventoryQuantity() ) );
-    
         }
+        //搴撳瓨
+        inventroyqty        := [Number]maxobject( daycells, Elements, e, e.Column().StartDate() ).InventoryQuantity();
+        inventory           := selectobject( column, CellValue, c, c.Row() = showrowinventory );
+        inventory.Value( [String]inventroyqty );
+        suminventory        := selectobject( column, CellValue, c, c.Row() = sumrowinventory );
+        suminventory.Value( [String]( [Real]suminventory.Value() + inventroyqty ) );
       }
     }
     traverse( this, Column, column ){
       for( demandr := sumrowdemand.RowNr() + 1; demandr < sumrowinventory.RowNr(); demandr := demandr + 1 ){
-        demandrow              := selectobject( this, Row, r, r.RowNr() = demandr and r.Name() = sumname );
+        demandrow           := selectobject( this, Row, r, r.RowNr() = demandr and r.Name() = sumname );
     //    info( '------------------14----------------' );
         if( not isnull( demandrow ) and not exists( demandrow, CellValue, cv, cv.Column() = column ) ){
-          demandcell           := column.CellValue( relnew, Value := '' );
+          demandcell        := column.CellValue( relnew, Value := '' );
           demandrow.CellValue( relinsert, demandcell );
         }
       }
     }
     
-    rows := selectsortedset( this, Row, row, row.Name(), row.RowNr() );
-    i    := 0;
+    rows                    := selectsortedset( this, Row, row, row.Name(), row.RowNr() );
+    i                       := 0;
     traverse( rows, Elements, e ){
       e.RowNr( i );
-      i := i + 1;
+      i                     := i + 1;
     }
   *]
 }
diff --git a/_Main/BL/Type_EnginePipelineReport/Method_Generate0.qbl b/_Main/BL/Type_EnginePipelineReport/Method_Generate0.qbl
deleted file mode 100644
index 61f7d47..0000000
--- a/_Main/BL/Type_EnginePipelineReport/Method_Generate0.qbl
+++ /dev/null
@@ -1,129 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Method Generate0 (
-  EnginePipelineSearch search,
-  Product_MPs products
-)
-{
-  TextBody:
-  [*
-    // 鐢勫叞楦� Jun-25-2024 (created)
-    table                   := selectobject( this, Source.Report, report, not report.IsShow() );
-    //娓呯┖涔嬪墠瀛樺偍鐨勬樉绀烘暟鎹�
-    this.Clear( search.TimeUnit(), search.StartDate(), search.EndDate() );
-    Transaction::Transaction().Propagate( attribute( EnginePipelineColumn, Index ) );
-    Transaction::Transaction().Propagate( attribute( EnginePipelineCell, ProductionQuantity ) );
-    Transaction::Transaction().Propagate( attribute( EnginePipelineCell, DemandQuantity ) );
-    //杩囨护鍚庣殑浜у搧id
-    productids              := selectuniquevalues( products, Elements, product, true, product.ID() );
-    rows                    := selectsortedset( table, Row, row, row.RowNr() );
-    models                  := selectuniquevalues( table, Column.Cell.Demand, demand, demand.Model() );
-    cellnr                  := 5 + models.Size();
-    //鍚堣琛�
-    sumname                 := 'SUM';
-    sumstr                  := sumname.Format( 'S(Len(10))' );
-    sumrowproduction        := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '鎬讳骇閲�' ), sumname, '', rows.Size() * cellnr );
-    sumrowdlproduction      := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '澶ц繛浜ч噺' ), sumname, '', sumrowproduction.RowNr() + 1 );
-    sumrowccproduction      := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '闀挎槬浜ч噺' ), sumname, '', sumrowdlproduction.RowNr() + 1  );
-    sumrowdemand            := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '鎬婚渶姹�' ), sumname, '', sumrowccproduction.RowNr() + 1 );
-    sumdemandrows           := construct( EnginePipelineRows );
-    rowno                   := sumrowdemand.RowNr() + 1;
-    traverse( models, Elements, model ){
-      sumdemandrows.Add( EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( model.Concat( '闇�姹�' ) ), sumname, model, rowno ) ); 
-      rowno                 := rowno + 1;
-    }
-    sumrowinventory         := EnginePipelineRow::CraeteCellValueForRow( this, sumstr.Concat( '搴撳瓨' ), sumname, '', rowno );
-    
-    //琛岃鏁�
-    rownr                   := 0;
-    traverse( rows, Elements, row, productids.Find( row.Name() ) >= 0 ){
-      rowname               := row.Name().Format( 'S(Len(10))' );
-      showrowproduction     := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '鎬讳骇閲�' ), row.Name(), '', rownr );
-      showrowdlproduction   := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '澶ц繛浜ч噺' ), row.Name(), '', showrowproduction.RowNr() + 1 );
-      showrowccproduction   := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '闀挎槬浜ч噺' ), row.Name(), '', showrowdlproduction.RowNr() + 1 );
-      showrowdemand         := EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '鎬婚渶姹�' ), row.Name(), '', showrowccproduction.RowNr() + 1 );
-      rownr                 := showrowdemand.RowNr() + 1;
-      modelsnr              := showrowdemand.RowNr() + 4;
-      uniquemodels          := selectuniquevalues( row, Cell.Demand, demand, true, demand.Model() );
-      demandrows            := construct( EnginePipelineRows );
-      traverse( uniquemodels, Elements, e ){
-    
-        if( rownr < modelsnr ){
-          demandrows.Add( EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( e.Concat( '闇�姹�' ) ), row.Name(), e, rownr ) ); 
-          rownr             := rownr + 1;
-        }
-      }
-    
-      for( rownr := rownr; rownr < modelsnr; rownr ++ ){
-    
-        demandrows.Add( EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '' ), row.Name(), '', rownr ) ); 
-      }
-      showrowinventory      :=  EnginePipelineRow::CraeteCellValueForRow( this, rowname.Concat( '搴撳瓨' ), row.Name(), '', rownr );
-    
-      traverse( this, Column, column ){
-        daycells            := selectset( row, Cell, cell, cell.Column().TimeUnit() = Translations::MP_GlobalParameters_Day() and
-                                            cell.Column().StartDate() >= column.StartDate() and 
-                                            cell.Column().StartDate() <= column.EndDate() );
-        
-        //鐢熶骇
-        productionqty       := sum( daycells, Elements, cell, cell.ProductionQuantity() );
-        production          := selectobject( column, CellValue, c, c.Row() = showrowproduction );
-        production.Value( [String]productionqty );
-        sumproduction       := selectobject( column, CellValue, c, c.Row() = sumrowproduction );
-        sumproduction.Value( [String]( [Real]sumproduction.Value() + productionqty ) );
-        //澶ц繛浜ч噺
-        dlproductionqty     := sum( daycells, Elements.Production, cellproduction, cellproduction.DLProduction() );
-        dlproduction        := selectobject( column, CellValue, c, c.Row() = showrowdlproduction );
-        dlproduction.Value( [String]dlproductionqty );
-        sumdlproduction     := selectobject( column, CellValue, c, c.Row() = sumrowdlproduction );
-        sumdlproduction.Value( [String]( [Real]sumdlproduction.Value() + dlproductionqty ) );
-        //闀挎槬浜ч噺
-        ccproductionqty     := sum( daycells, Elements.Production, cellproduction, cellproduction.CCProduction() );
-        ccproduction        := selectobject( column, CellValue, c, c.Row() = showrowccproduction );
-        ccproduction.Value( [String]ccproductionqty );
-        sumccproduction     := selectobject( column, CellValue, c, c.Row() = sumrowccproduction );
-        sumccproduction.Value( [String]( [Real]sumccproduction.Value() + ccproductionqty ) );
-        //闇�姹�
-        totaldemandqty      := sum( daycells, Elements, cell, cell.DemandQuantity() );
-        totaldemand         := selectobject( column, CellValue, c, c.Row() = showrowdemand );
-        totaldemand.Value( [String]totaldemandqty );
-        sumdemand           := selectobject( column, CellValue, c, c.Row() = sumrowdemand );
-        sumdemand.Value( [String]( [Real]sumdemand.Value() + totaldemandqty ) );
-        //鍏蜂綋闇�姹�
-        traverse( demandrows, Elements, demandrow ){
-          demandqty         :=  sum( daycells, Elements.Demand, celldemand, celldemand.Model() = demandrow.Demand(), celldemand.Quantity() );
-          demandcell        := selectobject( column, CellValue, c, c.Row() = demandrow );
-          demandcell.Value( [String]demandqty );
-          sumdemandrow      := selectobject( sumdemandrows, Elements, r, r.Demand() = demandrow.Demand() );
-          if( not isnull( sumdemandrow ) ){
-            sumdemandcell   := selectobject( column, CellValue, c, c.Row() = sumdemandrow );
-            sumdemandcell.Value( [String]( [Real]sumdemandcell.Value() + demandqty ) );
-          }
-        }
-        //搴撳瓨
-        inventroyqty        := maxobject( daycells, Elements, e, e.Column().StartDate() ).InventoryQuantity();
-        inventory           := selectobject( column, CellValue, c, c.Row() = showrowinventory );
-        inventory.Value( [String]inventroyqty );
-        suminventory        := selectobject( column, CellValue, c, c.Row() = sumrowinventory );
-        suminventory.Value( [String]( [Real]suminventory.Value() + inventroyqty ) );
-      }
-    }
-    traverse( this, Column, column ){
-      for( demandr := sumrowdemand.RowNr() + 1; demandr < sumrowinventory.RowNr(); demandr := demandr + 1 ){
-        demandrow           := selectobject( this, Row, r, r.RowNr() = demandr and r.Name() = sumname );
-    //    info( '------------------14----------------' );
-        if( not isnull( demandrow ) and not exists( demandrow, CellValue, cv, cv.Column() = column ) ){
-          demandcell        := column.CellValue( relnew, Value := '' );
-          demandrow.CellValue( relinsert, demandcell );
-        }
-      }
-    }
-    
-    rows                    := selectsortedset( this, Row, row, row.Name(), row.RowNr() );
-    i                       := 0;
-    traverse( rows, Elements, e ){
-      e.RowNr( i );
-      i                     := i + 1;
-    }
-  *]
-}
diff --git a/_Main/BL/Type_EnginePipelineSource/StaticMethod_InitiateSearch.qbl b/_Main/BL/Type_EnginePipelineSource/StaticMethod_InitiateSearch.qbl
index 2c3837f..3c906c5 100644
--- a/_Main/BL/Type_EnginePipelineSource/StaticMethod_InitiateSearch.qbl
+++ b/_Main/BL/Type_EnginePipelineSource/StaticMethod_InitiateSearch.qbl
@@ -9,7 +9,7 @@
     // 鐢勫叞楦� Sep-29-2024 (created)
     search                    := owner.EnginePipelineSearch();
     if( isnull( search ) ){
-      owner.EnginePipelineSearch( relnew, StartDate := Date::MinDate(), EndDate := Date::MaxDate(), TimeUnit := Translations::MP_GlobalParameters_Day() );
+      search                  := owner.EnginePipelineSearch( relnew, StartDate := Date::MinDate(), EndDate := Date::MaxDate(), TimeUnit := Translations::MP_GlobalParameters_Day() );
     }else{
       search                  := owner.EnginePipelineSearch();
       search.TimeUnit( Translations::MP_GlobalParameters_Day() );
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_InitiateSearch.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_InitiateSearch.qbl
index f0d93bb..c1f1167 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_InitiateSearch.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_InitiateSearch.qbl
@@ -10,7 +10,7 @@
     allunit                   := FinancialProductionReport::GetDefaultAllUnit();
     search                    := owner.FinancialProductionSearch();
     if( isnull( owner.FinancialProductionSearch() ) ){
-      owner.FinancialProductionSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
+      search                  := owner.FinancialProductionSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
     }else{
       search                  := owner.FinancialProductionSearch();
       search.Unit( allunit );
diff --git a/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitiateSearch.qbl b/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitiateSearch.qbl
index 4fa422b..2596cee 100644
--- a/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitiateSearch.qbl
+++ b/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitiateSearch.qbl
@@ -10,7 +10,7 @@
     allunit                   := FinancialSalesReport::GetDefaultAllUnit();
     search                    := owner.FinancialSalesSearch();
     if( isnull( search ) ){
-      owner.FinancialSalesSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
+      search                  := owner.FinancialSalesSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
     }else{
       search                  := owner.FinancialSalesSearch();
       search.Unit( allunit );
diff --git a/_Main/BL/Type_InventorySummarySource/StaticMethod_InitiateSearch.qbl b/_Main/BL/Type_InventorySummarySource/StaticMethod_InitiateSearch.qbl
index 61350de..aa4e4dd 100644
--- a/_Main/BL/Type_InventorySummarySource/StaticMethod_InitiateSearch.qbl
+++ b/_Main/BL/Type_InventorySummarySource/StaticMethod_InitiateSearch.qbl
@@ -10,7 +10,7 @@
     allunit                   := InventorySummaryReport::GetDefaultAllUnit();
     search                    := owner.InventorySummarySearch();
     if( isnull( search ) ){
-      owner.InventorySummarySearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit, Category := Translations::MP_GlobalParameters_Day(), StartDate := Date::MinDate(), EndDate := Date::MaxDate() );
+      search                  := owner.InventorySummarySearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit, Category := Translations::MP_GlobalParameters_Day(), StartDate := Date::MinDate(), EndDate := Date::MaxDate() );
     }else{
       search                  := owner.InventorySummarySearch();
       search.Unit( allunit );
diff --git a/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl b/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
index 9822d5e..353f594 100644
--- a/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
+++ b/_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
@@ -37,7 +37,7 @@
           beforecolumn      := column.PreviousColumn();
           beforeinventory   := selectobject( showrow, Cell, c, c.Column() = beforecolumn );
           ccinventoryqty    := beforeinventory.CCInventoryQty() + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
-          ccinventoryqty    := beforeinventory.DLInventoryQty() + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.DLToCCDepartureQty() - maxinventory.DLAssemblyPlanQty();
+          dlinventoryqty    := beforeinventory.DLInventoryQty() + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.DLToCCDepartureQty() - maxinventory.DLAssemblyPlanQty();
         }
         sumcell  := selectobject( column, Cell, c, c.Row() = sumrow );
         if( isnull( sumcell ) ){
@@ -64,5 +64,11 @@
         sumcell.Add( showcell );
       }
     }
+    rows                    := selectsortedset( this, Row, row, row.Name(), row.RowNr() );
+    i                       := 0;
+    traverse( rows, Elements, e ){
+      e.RowNr( i );
+      i                     := i + 1;
+    }
   *]
 }
diff --git a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
index 40fb9c9..392964d 100644
--- a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -40,10 +40,12 @@
           products.Add( pisp.Product_MP() );
           row               := table.GetRow( pisp.ProductID() );
           inventoryqty      := sum( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() = startinventorydate and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and pispip.ActualInventoryLevelEnd() <> 0, pispip.ActualInventoryLevelEnd() );
-          if( iscc ){
-            row.CCInventoryQty( inventoryqty );
-          }else{
-            row.DLInventoryQty( inventoryqty );
+          if( isccassemnly ){
+            row.CCInventoryQty( row.CCInventoryQty() + inventoryqty );
+          }
+          if( isdlassemnly ){
+            row.DLInventoryQty( row.DLInventoryQty() + inventoryqty );
+          }
           traverse( pispips, Elements, pispip){//, pispip.Start().Month() = 1 and pispip.Start().Day() = 2
     
             //澶�
@@ -70,7 +72,7 @@
     //          if( weekcolumn.EndDate() = pispip.Start().Date() or pispip.Period_MP() = endperiod ){
     //            row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryqty );
     //          }
-            }
+    //        }
           }
         }
       }
diff --git a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_InitiateSearch.qbl b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_InitiateSearch.qbl
index 2f69e1e..5115534 100644
--- a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_InitiateSearch.qbl
+++ b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_InitiateSearch.qbl
@@ -9,7 +9,7 @@
     // 鐢勫叞楦� Sep-29-2024 (created)
     search                    := owner.MachiningPipelineSearch();
     if( isnull( search ) ){
-      owner.MachiningPipelineSearch( relnew, StartDate := Date::MinDate(), EndDate := Date::MaxDate(), TimeUnit := Translations::MP_GlobalParameters_Day() );
+      search                  := owner.MachiningPipelineSearch( relnew, StartDate := Date::MinDate(), EndDate := Date::MaxDate(), TimeUnit := Translations::MP_GlobalParameters_Day() );
     }else{
       search                  := owner.MachiningPipelineSearch();
       search.TimeUnit( Translations::MP_GlobalParameters_Day() );
diff --git a/_Main/Sys/Repr/Global/MachiningPipelineCell.qrp b/_Main/Sys/Repr/Global/MachiningPipelineCell.qrp
index 77a9570..c4b4d1e 100644
--- a/_Main/Sys/Repr/Global/MachiningPipelineCell.qrp
+++ b/_Main/Sys/Repr/Global/MachiningPipelineCell.qrp
@@ -11,6 +11,17 @@
   {
     AttributeKey: '[415136.0.886711533]'
     Synonym: 'CC搴撳瓨'
+    Conditional:
+    [
+      DataRepresentation.Conditional
+      {
+        BackgroundColor: '$FF9999'
+        ConditionBody: 'object.CCInventoryQty() < 0'
+        ConversionBody: ''
+        DefaultBackgroundColor: false
+        InheritConversion: false
+      }
+    ]
   }
   AttributeRepresentation CCProductionQty
   {
@@ -31,6 +42,17 @@
   {
     AttributeKey: '[415136.0.894481161]'
     Synonym: 'DL搴撳瓨'
+    Conditional:
+    [
+      DataRepresentation.Conditional
+      {
+        BackgroundColor: '$FF9999'
+        ConditionBody: 'object.DLInventoryQty() < 0'
+        ConversionBody: ''
+        DefaultBackgroundColor: false
+        InheritConversion: false
+      }
+    ]
   }
   AttributeRepresentation DLProductionQty
   {
@@ -46,6 +68,17 @@
   {
     AttributeKey: '[415136.0.894481168]'
     Synonym: 'CC+DL鎬诲簱瀛�'
+    Conditional:
+    [
+      DataRepresentation.Conditional
+      {
+        BackgroundColor: '$FF9999'
+        ConditionBody: 'object.TotalInventoryQty() < 0'
+        ConversionBody: ''
+        DefaultBackgroundColor: false
+        InheritConversion: false
+      }
+    ]
   }
   RelationRepresentation AsFirstCellInColumn { RelationKey: '[415136.0.894469842]' Visibility: 'Normal' }
 }

--
Gitblit v1.9.3