lazhen
2024-10-08 c75cd6f6eb1e06a27e28c26ca9df0324b7ed675f
库存汇总报表数据问题bug
已修改3个文件
49 ■■■■ 文件已修改
_Main/BL/Type_InventorySummaryReport/Method_Generate.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_InventorySummaryReport/Method_GenerateColumn.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_InventorySummaryReport/Method_Generate.qbl
@@ -9,7 +9,7 @@
  [*
    // 甄兰鸽 Jun-25-2024 (created)
    startofplanning           := search.MacroPlan().StartOfPlanning();
    startofyear               := startofplanning.StartOfYear();
    startofyear               := startofplanning.StartOfYear() - Duration::Days( 1 );
    startofendyear            := startofplanning.StartOfNextYear() - Duration::Days( 1 );
    //查询日期返回需要在计划日期之内
    if( search.StartDate().DateTime() < startofendyear and search.EndDate().DateTime() > startofyear ){
_Main/BL/Type_InventorySummaryReport/Method_GenerateColumn.qbl
@@ -11,7 +11,7 @@
  [*
    // 甄兰鸽 Jun-25-2024 (created)
    startofplanning           := owner.StartOfPlanning();
    startofyear               := startofplanning.StartOfYear();
    startofyear               := startofplanning.StartOfYear() - Duration::Days( 1 );
    startofendyear            := startofplanning.StartOfNextYear() - Duration::Days( 1 );
    //查询日期返回需要在计划日期之内
    if( starttime < startofendyear and endtime > startofyear ){
_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl
@@ -23,8 +23,8 @@
    table                     := source.InventorySummaryReport( relnew, ID := source.Name(), Name := source.Name() );
    showtable                 := source.InventorySummaryReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsShow := true );
    startofplanning           := owner.StartOfPlanning();
    startofyear               := startofplanning.StartOfYear();
    startofnextyear           := startofplanning.StartOfNextYear();
    startofyear               := startofplanning.StartOfYear() - Duration::Days( 1 );
    startofnextyear           := startofplanning.StartOfNextYear() - Duration::Days( 1 );
    
    search                    := owner.InventorySummarySearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit, Category := Translations::MP_GlobalParameters_Day(), StartDate := Date::MinDate(), EndDate := Date::MaxDate() );
    
@@ -33,14 +33,14 @@
    //库存数量为Actual inventories里面的点Planned inventories字段库存量加总
    traverse( owner, StockingPoint_MP, stockingpoint ){
    //traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '厂内库' ) ){
    //  unit                    := stockingpoint.Unit();
    //  parentunits             := unit.GetAllParent();
      unit                    := stockingpoint.Unit();
      parentunits             := unit.GetAllParent();
      //是否属于长春工厂
      iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID() = '长春' ;//unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
    //  iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or unit.ID().StartsWith( 'CC' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'CC' ) );
    //  iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID() = '长春' ;//unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
      iscc                    := exists( parentunits, Elements, punit, punit.ID().StartsWith( 'VWED CC' ) );
      //是否属于大连工厂
      isdl                    := stockingpoint.ID().StartsWith( '大连' );//unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
    //  isdl                    := stockingpoint.ID().StartsWith( 'DL' ) or unit.ID().StartsWith( 'DL' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'DL' ) );
    //  isdl                    := stockingpoint.ID().StartsWith( '大连' );//unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
      isdl                    := exists( parentunits, Elements, punit, punit.ID().StartsWith( 'VWED DL' ) );
      if( iscc or isdl ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() ){
          //获取工厂行
@@ -54,8 +54,7 @@
          nextweek            := startofplanning.StartOfNextWeek();
          nextmonth           := startofplanning.StartOfNextMonth();
          
          pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical()
                                                  and pispip.Start() < startofnextyear
          pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() < startofnextyear
                                                  and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() );
    
          traverse( pispips, Elements, pispip ){
@@ -66,9 +65,9 @@
            
            //天,选择日颗粒度时,期末库存,最小库存,最大库存和平均库存的数值保持一致
            daycolumn         := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Day() );
            info( daycolumn.Name(), daycolumn.Period(), daycolumn.TimeUnit() );
            factoryrow.SetCellValue( daycolumn, [Number]pispip.PlannedInventoryLevelEnd() );
            allrow.SetCellValue( daycolumn, [Number]pispip.PlannedInventoryLevelEnd() );
            quantity          := ifexpr( pispip.Period_MP().IsHistorical(), [Number]pispip.ActualInventoryLevelEnd(), [Number]pispip.PlannedInventoryLevelEnd() );
            factoryrow.SetCellValue( daycolumn, quantity );
            allrow.SetCellValue( daycolumn, quantity );
            
            //周,选择周时,期末库存为每一周最后一天的汇总库存信息,最小库存为这一周库存量最小的一天的数值,最大库存为这一周库存量最大的一天的数值,平均库存为该周的平均值
            if( period.Start() < nextweek ){
@@ -78,11 +77,11 @@
              if( period.Start() = weekend ){
                weekcolumn    := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Week() );
                
                maxinventory  := max( weekpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() );
                mininventory  := min( weekpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() );
                aveinventory  := average( weekpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() );
                factoryrow.SetCellValue( weekcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory );
                allrow.SetCellValue( weekcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory );
                maxinventory  := max( weekpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) );
                mininventory  := min( weekpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) );
                aveinventory  := average( weekpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) );
                factoryrow.SetCellValue( weekcolumn, quantity, mininventory, maxinventory, [Number]aveinventory );
                allrow.SetCellValue( weekcolumn, quantity, mininventory, maxinventory, [Number]aveinventory );
              }
            }else{
              weekpispips.Flush();
@@ -98,11 +97,11 @@
              if( period.Start() = monthend ){
                monthcolumn  := selectobject( table, InventorySummaryColumn, column, column.Name() = periodname, column.Period() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Month() );
                
                maxinventory := max( monthpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() );
                mininventory := min( monthpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() );
                aveinventory := average( monthpispips, Elements, e, [Number]e.PlannedInventoryLevelEnd() );
                factoryrow.SetCellValue( monthcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory );
                allrow.SetCellValue( monthcolumn, [Number]pispip.PlannedInventoryLevelEnd(), mininventory, maxinventory, [Number]aveinventory );
                maxinventory := max( monthpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) );
                mininventory := min( monthpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) );
                aveinventory := average( monthpispips, Elements, e, ifexpr( pispip.Period_MP().IsHistorical(), [Number]e.ActualInventoryLevelEnd(), [Number]e.PlannedInventoryLevelEnd() ) );
                factoryrow.SetCellValue( monthcolumn, quantity, mininventory, maxinventory, [Number]aveinventory );
                allrow.SetCellValue( monthcolumn, quantity, mininventory, maxinventory, [Number]aveinventory );
              }
            }else{
              monthpispips.Flush();