From f9c8e9e3438d19dc7a3ee087b631dbe593663112 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期三, 09 十月 2024 11:34:43 +0800
Subject: [PATCH] 机加管线报表的数据bug

---
 /dev/null                                                                                   |    7 --
 _Main/BL/Type_EnginePipelineReport/Method_GenerateColumn.qbl                                |   32 ++++++----
 _Main/BL/Type_InventorySummaryReport/Method_GenerateColumn.qbl                              |    8 --
 _Main/BL/Type_InterfaceInventoryReport/StaticMethod_GenerateData.qbl                        |    2 
 _Main/BL/Type_MachiningPipelineReport/Method_GenerateColumn.qbl                             |   33 +++++++----
 _Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl                              |    4 -
 _Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl                            |    6 +-
 _Main/UI/MacroPlannerWebApp/Component_FormMachiningPipelineReport/Component_PanelExport.def |    2 
 _Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl                          |   32 +++-------
 9 files changed, 59 insertions(+), 67 deletions(-)

diff --git a/_Main/BL/Type_EnginePipelineReport/Method_GenerateColumn.qbl b/_Main/BL/Type_EnginePipelineReport/Method_GenerateColumn.qbl
index c4e150b..f579568 100644
--- a/_Main/BL/Type_EnginePipelineReport/Method_GenerateColumn.qbl
+++ b/_Main/BL/Type_EnginePipelineReport/Method_GenerateColumn.qbl
@@ -10,21 +10,29 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jun-25-2024 (created)
+    startofplanning           := owner.StartOfPlanning();
+    startofyear               := startofplanning.StartOfYear().Date();
+    startofendyear            := startofplanning.StartOfNextYear().Date();
     //鏌ヨ鏃ユ湡杩斿洖闇�瑕佸湪璁″垝鏃ユ湡涔嬪唴
-    weekstart             := owner.StartOfPlanning().Date();
-    traverse( owner, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day() ){
-      if( timeunit = 'All' or timeunit = Translations::MP_GlobalParameters_Day() ){
-        periodtime          := period.StartDate();
-        periodname          := periodtime.Format( "M2/D2/Y" );
-        
-        this.Column( relnew, Name := periodname, StartDate := periodtime, EndDate := periodtime, TimeUnit := Translations::MP_GlobalParameters_Day() );
+    if( startdate < startofendyear and enddate > startofyear ){
+      if( startdate < startofyear ){
+        startdate             := startofyear;
       }
-      
+      if( enddate > startofendyear ){
+        enddate               := startofendyear;
+      }
+      if( timeunit = 'All' or timeunit = Translations::MP_GlobalParameters_Day() ){
+        for( start := startdate; start <= enddate; start := start.DateTime().StartOfNextDay().Date() ){
+          periodname          := start.Format( "M2/D2/Y" );
+          this.Column( relnew, Name := periodname, StartDate := start, EndDate := start, TimeUnit := Translations::MP_GlobalParameters_Day() );
+        }
+      }
       if( timeunit = 'All' or timeunit = Translations::MP_GlobalParameters_Week() ){
-        if( period.StartDate() = weekstart ){
-          weekperiodname    := weekstart.Format( "M2/D2/Y" );
-          this.Column( relnew, Name := weekperiodname, StartDate := weekstart, EndDate := ( weekstart + Duration::Days( 6 ) ).Date(), TimeUnit := Translations::MP_GlobalParameters_Week() );
-          weekstart         := ( weekstart + Duration::Days( 7 ) ).Date();
+        for( start := startdate; start <= enddate; start := start.StartOfNextWeek() ){
+          periodname          := start.Format( "M2/D2/Y" );
+          weekend             := ( start.StartOfNextWeek() - Duration::Days( 1 ) ).Date();
+          
+          this.Column( relnew, Name := periodname, StartDate := start, EndDate := weekend, TimeUnit := Translations::MP_GlobalParameters_Week() );
         }
       }
     }
diff --git a/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
index 871cb05..dbb23a4 100644
--- a/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
@@ -30,7 +30,6 @@
       traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem() 
                 and exists( pisp.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent ) 
                 and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.PlannedInventoryLevelEnd() <> 0 ) ) ){
-        weekstart           := owner.StartOfPlanning().Date();
         pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() 
                                                     and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() );
         row := table.GetRow( pisp.ProductID() );
@@ -50,8 +49,7 @@
           //搴撳瓨闇�瑕佸彇鏈�鍚庝竴澶�
           row.SetCellInventoryValue( daycolumn, [Real]inventoryquantity );
       
-          if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){
-            weekstart       := ( weekstart + Duration::Days( 7 ) ).Date();
+          if( pispip.Start().Date() = weekcolumn.EndDate() or pispip.Period_MP() = endperiod ){
               
             row.SetCellInventoryValue( weekcolumn, [Real]inventoryquantity );
           } 
diff --git a/_Main/BL/Type_InterfaceInventoryReport/StaticMethod_GenerateData.qbl b/_Main/BL/Type_InterfaceInventoryReport/StaticMethod_GenerateData.qbl
index 9c48e2d..3488f2f 100644
--- a/_Main/BL/Type_InterfaceInventoryReport/StaticMethod_GenerateData.qbl
+++ b/_Main/BL/Type_InterfaceInventoryReport/StaticMethod_GenerateData.qbl
@@ -39,7 +39,7 @@
                                                               , MLBMQB                  := product.MQBMLB()
                                                               , Power                   := product.Power()
                                                               , Product                 := product.ID()
-                                                              , InventoryDate           := column.Period()
+                                                              , InventoryDate           := column.StartDate()
                                                               , InventoryEndQty         := cell.EndingInventory()
                                                               , InventoryMinQty         := cell.MinimumInventory()
                                                               , InventoryMaxQty         := cell.MaximumInventory()
diff --git a/_Main/BL/Type_InventorySummaryColumn/Attribute_Period.qbl b/_Main/BL/Type_InventorySummaryColumn/Attribute_Period.qbl
deleted file mode 100644
index 5c8b136..0000000
--- a/_Main/BL/Type_InventorySummaryColumn/Attribute_Period.qbl
+++ /dev/null
@@ -1,7 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Attribute Period
-{
-  #keys: '3[415136.0.865304676][415136.0.865304675][415136.0.865304677]'
-  ValueType: Date
-}
diff --git a/_Main/BL/Type_InventorySummaryReport/Method_GenerateColumn.qbl b/_Main/BL/Type_InventorySummaryReport/Method_GenerateColumn.qbl
index 6198a96..3af1676 100644
--- a/_Main/BL/Type_InventorySummaryReport/Method_GenerateColumn.qbl
+++ b/_Main/BL/Type_InventorySummaryReport/Method_GenerateColumn.qbl
@@ -29,19 +29,15 @@
         }
       }else if( timeunit = Translations::MP_GlobalParameters_Week() ){
         for( start := starttime; start <= endtime; start := start.StartOfNextWeek() ){
-          periodtime          := start.Date();
-          periodname          := periodtime.Format( "M2/D2/Y" );
           weekend             := ( start.StartOfNextWeek() - Duration::Days( 1 ) ).Date();
           
-          this.InventorySummaryColumn( relnew, Name := periodname, StartDate := periodtime, EndaDate := weekend, TimeUnit := Translations::MP_GlobalParameters_Week() );
+          this.InventorySummaryColumn( relnew, Name := weekend.Format( "M2/D2/Y" ), StartDate := start.Date(), EndaDate := weekend, TimeUnit := Translations::MP_GlobalParameters_Week() );
         }
       }else if( timeunit = Translations::MP_GlobalParameters_Month() ){
         for( start := starttime; start <= endtime; start := start.StartOfNextMonth() ){
-          periodtime          := start.Date();
-          periodname          := periodtime.Format( "M2/D2/Y" );
           monthend            := ( start.StartOfNextMonth() - Duration::Days( 1 ) ).Date();
           
-          this.InventorySummaryColumn( relnew, Name := periodname, StartDate := periodtime, EndaDate := monthend, TimeUnit := Translations::MP_GlobalParameters_Month() );
+          this.InventorySummaryColumn( relnew, Name := monthend.Format( "M2/D2/Y" ), StartDate := start.Date(), EndaDate := monthend, TimeUnit := Translations::MP_GlobalParameters_Month() );
         }
       }
     }
diff --git a/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl b/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl
index 5238527..a1b13f7 100644
--- a/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl
@@ -50,7 +50,7 @@
             periodname        := periodtime.Format( "M2/D2/Y" );
             
             //澶╋紝閫夋嫨鏃ラ绮掑害鏃讹紝鏈熸湯搴撳瓨锛屾渶灏忓簱瀛橈紝鏈�澶у簱瀛樺拰骞冲潎搴撳瓨鐨勬暟鍊间繚鎸佷竴鑷�
-            daycolumn         := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Day() );
+            daycolumn         := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.StartDate() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Day() );
             quantity          := ifexpr( pispip.Period_MP().IsHistorical(), [Number]pispip.ActualInventoryLevelEnd(), [Number]pispip.PlannedInventoryLevelEnd() );
             factoryrow.SetCellValue( daycolumn, quantity );
             allrow.SetCellValue( daycolumn, quantity );
@@ -77,9 +77,9 @@
     selections                := selectset( interface, InventoryPointSelection, selection, allsps.Find( selection.StockpoingPoint() ) >= 0 and selection.IsIncluded() );
     productids                := selectuniquevalues( selections, Elements, selection, selection.ProductID() );
     //鏈�鍚庡皢杩欎簺搴撲綅涓浂浠跺彿鐨勬暟閲忚繘琛屽姞鎬�
-    traverse( table, InventorySummaryColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.Period() < startofplanning.Date() ){
+    traverse( table, InventorySummaryColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.StartDate() < startofplanning.Date() ){
       traverse( productids, Elements, productid ){
-        column.GenerateCell( selections, ccsps, dlsps, table, column.Period(), column.Period(), productid, allunit, ccunit, dlunit );
+        column.GenerateCell( selections, ccsps, dlsps, table, column.StartDate(), column.EndaDate(), productid, allunit, ccunit, dlunit );
       }
     }
       
diff --git a/_Main/BL/Type_MachiningPipelineReport/Method_GenerateColumn.qbl b/_Main/BL/Type_MachiningPipelineReport/Method_GenerateColumn.qbl
index c4e150b..a421f47 100644
--- a/_Main/BL/Type_MachiningPipelineReport/Method_GenerateColumn.qbl
+++ b/_Main/BL/Type_MachiningPipelineReport/Method_GenerateColumn.qbl
@@ -11,20 +11,29 @@
   [*
     // 鐢勫叞楦� Jun-25-2024 (created)
     //鏌ヨ鏃ユ湡杩斿洖闇�瑕佸湪璁″垝鏃ユ湡涔嬪唴
-    weekstart             := owner.StartOfPlanning().Date();
-    traverse( owner, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day() ){
-      if( timeunit = 'All' or timeunit = Translations::MP_GlobalParameters_Day() ){
-        periodtime          := period.StartDate();
-        periodname          := periodtime.Format( "M2/D2/Y" );
-        
-        this.Column( relnew, Name := periodname, StartDate := periodtime, EndDate := periodtime, TimeUnit := Translations::MP_GlobalParameters_Day() );
+    startofplanning           := owner.StartOfPlanning();
+    startofyear               := startofplanning.StartOfYear().Date();
+    startofendyear            := startofplanning.StartOfNextYear().Date();
+    //鏌ヨ鏃ユ湡杩斿洖闇�瑕佸湪璁″垝鏃ユ湡涔嬪唴
+    if( startdate < startofendyear and enddate > startofyear ){
+      if( startdate < startofyear ){
+        startdate             := startofyear;
       }
-      
+      if( enddate > startofendyear ){
+        enddate               := startofendyear;
+      }
+      if( timeunit = 'All' or timeunit = Translations::MP_GlobalParameters_Day() ){
+        for( start := startdate; start <= enddate; start := start.DateTime().StartOfNextDay().Date() ){
+          periodname          := start.Format( "M2/D2/Y" );
+          this.Column( relnew, Name := periodname, StartDate := start, EndDate := start, TimeUnit := Translations::MP_GlobalParameters_Day() );
+        }
+      }
       if( timeunit = 'All' or timeunit = Translations::MP_GlobalParameters_Week() ){
-        if( period.StartDate() = weekstart ){
-          weekperiodname    := weekstart.Format( "M2/D2/Y" );
-          this.Column( relnew, Name := weekperiodname, StartDate := weekstart, EndDate := ( weekstart + Duration::Days( 6 ) ).Date(), TimeUnit := Translations::MP_GlobalParameters_Week() );
-          weekstart         := ( weekstart + Duration::Days( 7 ) ).Date();
+        for( start := startdate; start <= enddate; start := start.StartOfNextWeek() ){
+          periodname          := start.Format( "M2/D2/Y" );
+          weekend             := ( start.StartOfNextWeek() - Duration::Days( 1 ) ).Date();
+          
+          this.Column( relnew, Name := periodname, StartDate := start, EndDate := weekend, TimeUnit := Translations::MP_GlobalParameters_Week() );
         }
       }
     }
diff --git a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
index 07abf2d..9d3c315 100644
--- a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -9,9 +9,6 @@
     // 鐢勫叞楦� Jun-24-2024 (created)
     owner.FinancialProductionSource( relflush );
     productparent             := MachiningPipelineReport::GetDefaultProductParent();
-    //ccunit                    := MachiningPipelineReport::GetDefaultCCUnit();
-    //dlunit                    := MachiningPipelineReport::GetDefaultDLUnit();
-    //allunit                   := EnginePipelineReport::GetDefaultAllUnit();
     source                    := owner.MachiningPipelineSource( relnew, Name := MachiningPipelineReport::GetDefaultName() );
     table                     := source.Report( relnew, ID := source.Name(), Name := source.Name() );
     showtable                 := source.Report( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsShow := true );
@@ -31,23 +28,15 @@
       iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or unit.ID().StartsWith( 'CC' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'CC' ) );//unit.ID() = ccunit or exists( parentunits, Elements, punit, punit.ID() = ccunit );
       //鏄惁灞炰簬澶ц繛宸ュ巶
       isdl                    := stockingpoint.ID().StartsWith( 'DL' ) or unit.ID().StartsWith( 'DL' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'DL' ) );//unit.ID() = dlunit or exists( parentunits, Elements, punit, punit.ID() = dlunit );
-      //鏄惁灞炰簬闀挎槬瑁呴厤绾緾C鍘傚唴搴�
-    //  isccassemnly            := stockingpoint.ID().EndsWith( '鍘傚唴搴�' ) and ( stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '闀挎槬' ) );//unit.ID() = MachiningPipelineReport::GetDefaultCCAssemnlyUnit() or exists( parentunits, Elements, punit, punit.ID() = MachiningPipelineReport::GetDefaultCCAssemnlyUnit() );
-      //鏄惁灞炰簬澶ц繛瑁呴厤绾緿L鍘傚唴搴�
-    //  isdlassemnly            := stockingpoint.ID().EndsWith( '鍘傚唴搴�' ) and ( stockingpoint.ID().StartsWith( 'DL' ) or stockingpoint.ID().StartsWith( '澶ц繛' ) );//unit.ID() = MachiningPipelineReport::GetDefaultDLAssemnlyUnit() or exists( parentunits, Elements, punit, punit.ID() = MachiningPipelineReport::GetDefaultDLAssemnlyUnit() );
-      //鏄惁灞炰簬闀挎槬鏈哄姞浜х嚎
-      isccproduction          := stockingpoint.ID().EndsWith( '绾胯竟搴�' ) and ( stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '闀挎槬' ) );//unit.ID() = MachiningPipelineReport::GetDefaultCCProductionUnit() or exists( parentunits, Elements, punit, punit.ID() = MachiningPipelineReport::GetDefaultCCProductionUnit() );
-      //鏄惁灞炰簬澶ц繛鏈哄姞浜х嚎
-      isdlproduction          := unit.ID().EndsWith( 'MoMo' ) and unit.ID().StartsWith( 'DL' );//unit.ID() = MachiningPipelineReport::GetDefaultDLProductionUnit() or exists( parentunits, Elements, punit, punit.ID() = MachiningPipelineReport::GetDefaultDLProductionUnit() );
       if( iscc or isdl ){
-        traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem() 
+        traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() and not pisp.IsSystem()// and pisp.ProductID() = '06K103011CM'
                   and exists( pisp.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent ) 
                   and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.PlannedInventoryLevelEnd() <> 0 or pispip.DependentDemandAndSalesDemandQuantity() <> 0 ) ) ){
           isccassemnly        := stockingpoint.ID().EndsWith( pisp.Product_MP().ParentID() + '绾胯竟搴�' ) and ( stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '闀挎槬' ) );
           isdlassemnly        := stockingpoint.ID().EndsWith( pisp.Product_MP().ParentID() ) and ( stockingpoint.ID().StartsWith( 'DL' ) or stockingpoint.ID().StartsWith( '澶ц繛' ) );
           pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() 
                                                   and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.PlannedInventoryLevelEnd() <> 0 or pispip.DependentDemandAndSalesDemandQuantity() <> 0 ), pispip.Start() );
-          traverse( pispips, Elements, pispip ){
+          traverse( pispips, Elements, pispip){//, pispip.Start().Month() = 1 and pispip.Start().Day() = 2
             products.Add( pisp.Product_MP() );
             
             //澶�
@@ -57,18 +46,17 @@
             
             row               := table.GetRow( pisp.ProductID() );
               
-            //瑁呴厤绾�
+            
             if( isccassemnly or isdlassemnly ){
+              //瑁呴厤绾�
               quantity        := [Number]pispip.DependentDemandAndSalesDemandQuantity();//鍥涜垗浜斿叆
-              row.SetCellProductionValue( daycolumn, isccassemnly, [Real]quantity );
-              row.SetCellProductionValue( weekcolumn, isccassemnly, [Real]quantity );
-            }
-              
-            //鏈哄姞绾�
-            if( isccproduction or isdlproduction ){
+              row.SetAssemblyPlanValue(  daycolumn, isccassemnly, [Real]quantity );
+              row.SetAssemblyPlanValue( weekcolumn, isccassemnly, [Real]quantity );
+              //鐢熶骇
               supplyqty       := [Number]pispip.NewSupplyQuantity();//鍥涜垗浜斿叆
-              row.SetCellProductionValue( daycolumn, isccproduction, [Real]supplyqty );
-              row.SetCellProductionValue( weekcolumn, isccproduction, [Real]supplyqty );
+    //          info( '****************', quantity, supplyqty );
+              row.SetCellProductionValue( daycolumn, isccassemnly, [Real]supplyqty );
+              row.SetCellProductionValue( weekcolumn, isccassemnly, [Real]supplyqty );
             }
             
             //搴撳瓨
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormMachiningPipelineReport/Component_PanelExport.def b/_Main/UI/MacroPlannerWebApp/Component_FormMachiningPipelineReport/Component_PanelExport.def
index f09e76f..42ae5a3 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormMachiningPipelineReport/Component_PanelExport.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormMachiningPipelineReport/Component_PanelExport.def
@@ -12,7 +12,7 @@
       Properties:
       [
         Image: 'EXPORT1'
-        Label: '瀵煎叆'
+        Label: '瀵煎嚭'
         Taborder: 1
       ]
     }

--
Gitblit v1.9.3