lazhen
2024-10-31 1416622ccad797dc3602b6672ca59137bab49c7e
机加管线报表库存值逻辑修改
已修改6个文件
已添加7个文件
404 ■■■■■ 文件已修改
_Main/BL/Type_EnginePipelineReport/Method_Generate0.qbl 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_EnginePipelineRow/StaticMethod_CraeteCellValueForRow.qbl 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineCell/Attribute_CCToDLArrivalQty.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineCell/Attribute_CCToDLDepartureQty.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineCell/Attribute_DLToCCArrivalQty.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineCell/Attribute_DLToCCDepartureQty.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineRow/Attribute_CCInventoryQty.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineRow/Attribute_DLInventoryQty.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineRow/Method_SetDepartureAndArrivalValue.qbl 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Download.qbl 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_EnginePipelineReport/Method_Generate0.qbl
@@ -43,7 +43,7 @@
      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() + 3;
      modelsnr              := showrowdemand.RowNr() + 4;
      uniquemodels          := selectuniquevalues( row, Cell.Demand, demand, true, demand.Model() );
      demandrows            := construct( EnginePipelineRows );
      traverse( uniquemodels, Elements, e ){
@@ -67,87 +67,63 @@
        
        //生产
        productionqty       := sum( daycells, Elements, cell, cell.ProductionQuantity() );
        production          := column.CellValue( relnew, Value := [String]productionqty );
        showrowproduction.CellValue( relinsert, production );
        production          := selectobject( column, CellValue, c, c.Row() = showrowproduction );
        production.Value( [String]productionqty );
        sumproduction       := selectobject( column, CellValue, c, c.Row() = sumrowproduction );
        if( isnull( sumproduction ) ){
          sumproduction     := column.CellValue( relnew, Value := [String]0 );
          sumrowproduction.CellValue( relinsert, sumproduction );
        }
        sumproduction.Value( [String]( [Real]sumproduction.Value() + productionqty ) );
        //大连产量
        dlproductionqty     := sum( daycells, Elements, cell, cell.Production().DLProduction() );
        dlproduction        := column.CellValue( relnew, Value := [String]dlproductionqty );
        showrowdlproduction.CellValue( relinsert, dlproduction );
        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 );
        if( isnull( sumdlproduction ) ){
          sumdlproduction   := column.CellValue( relnew, Value := [String]0 );
          sumrowdlproduction.CellValue( relinsert, sumdlproduction );
        }
        sumdlproduction.Value( [String]( [Real]sumdlproduction.Value() + dlproductionqty ) );
        //长春产量
        ccproductionqty     := sum( daycells, Elements, cell, cell.Production().CCProduction() );
        ccproduction        := column.CellValue( relnew, Value := [String]ccproductionqty );
        showrowccproduction.CellValue( relinsert, ccproduction );
        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 );
        if( isnull( sumccproduction ) ){
          sumccproduction   := column.CellValue( relnew, Value := [String]0 );
          sumrowccproduction.CellValue( relinsert, sumccproduction );
        }
        sumccproduction.Value( [String]( [Real]sumccproduction.Value() + ccproductionqty ) );
        //需求
        totaldemandqty      := sum( daycells, Elements, cell, cell.DemandQuantity() );
        totaldemand         := column.CellValue( relnew, Value := [String]totaldemandqty );
        showrowdemand.CellValue( relinsert, totaldemand );
        totaldemand         := selectobject( column, CellValue, c, c.Row() = showrowdemand );
        totaldemand.Value( [String]totaldemandqty );
        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() + totaldemandqty ) );
        //具体需求
        traverse( demandrows, Elements, demandrow ){
          demandqty         :=  sum( daycells, Elements.Demand, celldemand, celldemand.Model() = demandrow.Demand(), celldemand.Quantity() );
          demandcell        := column.CellValue( relnew, Value := [String]demandqty );
          demandrow.CellValue( relinsert, demandcell );
          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 );
            if( isnull( sumdemandcell ) ){
              sumdemandcell := column.CellValue( relnew, Value := [String]0 );
              sumdemandrow.CellValue( relinsert, sumdemandcell );
            }
            sumdemandcell.Value( [String]( [Real]sumdemandcell.Value() + demandqty ) );
          }
        }
        //库存
        inventroyqty             := maxobject( daycells, Elements, e, e.Column().StartDate() ).InventoryQuantity();
        inventory                := column.CellValue( relnew, Value := [String]inventroyqty );
        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 );
        }
        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 );
        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;
    }
  *]
}
_Main/BL/Type_EnginePipelineRow/StaticMethod_CraeteCellValueForRow.qbl
@@ -12,10 +12,10 @@
  [*
    // ç”„兰鸽 Jul-11-2024 (created)
    row           := table.Row( relnew, Name := name, RowNr := rownr, Product := product, Demand := demand );
    //traverse( table, Column, column ){
    //  cell        := column.CellValue( relnew, Value := '0' );
    //  row.CellValue( relinsert, cell );
    //}
    traverse( table, Column, column ){
      cell        := column.CellValue( relnew, Value := '0' );
      row.CellValue( relinsert, cell );
    }
    return row;
  *]
}
_Main/BL/Type_EnginePipelineSource/StaticMethod_Initialize.qbl
@@ -17,46 +17,52 @@
    
    products                  := construct( Product_MPs );
    //初始化列
    table.GenerateColumn( owner, 'All', search.StartDate(), search.EndDate() );
    table.GenerateColumn( owner, Translations::MP_GlobalParameters_Day(), search.StartDate(), search.EndDate() );
    endperiod                 := maxobject( owner, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day(), period.StartDate() );
    
    //生成生产和库存数据
    traverse( owner, StockingPoint_MP, stockingpoint ){
      unit                    := stockingpoint.Unit();
      parentunits             := unit.GetAllParent();
      //是否属于长春工厂
      iscc                    := ( stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '长春' ) ) and stockingpoint.ID().EndsWith( '厂内库' );
      iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or unit.ID().StartsWith( 'CC' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'CC' ) );
      //是否属于大连工厂
      isdl                    := ( ( stockingpoint.ID().StartsWith( 'DL' ) or stockingpoint.ID().StartsWith( '大连' ) ) and stockingpoint.ID().EndsWith( '厂内库' ) ) or  stockingpoint.ID() = '大连外租库';
      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 ) ) ){
        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() );
        products.Add( pisp.Product_MP() );
        traverse( pispips, Elements, pispip ){
          //天
          daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
          //周
          weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(),  pispip.Start().Date() );
          supplyquantity    := [Number]pispip.NewSupplyQuantity();//四舍五入
          inventoryquantity := [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
          //产量是加总
          if( iscc or isdl ){
            row.SetCellProductionValue( daycolumn, iscc, [Real]supplyquantity );
            row.SetCellProductionValue( weekcolumn, iscc, [Real]supplyquantity );
      isdl                    := stockingpoint.ID().StartsWith( 'DL' ) or unit.ID().StartsWith( 'DL' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'DL' ) );
      //是否属于长春产量
      isccproduction          := iscc and stockingpoint.ID().EndsWith( '厂内库' );
      //是否属于大连产量
      isdlproduction          := isdl and stockingpoint.ID().EndsWith( '厂内库' ) or  stockingpoint.ID() = '大连外租库';
      if( isccproduction or isdlproduction ){
        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 ) ) ){
          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 ), pispip.Start() );
          row := table.GetRow( pisp.ProductID() );
          products.Add( pisp.Product_MP() );
          traverse( pispips, Elements, pispip ){
            //天
            daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
            //周
    //        weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(),  pispip.Start().Date() );
            supplyquantity    := pispip.NewSupplyQuantity();//四舍五入
            inventoryquantity := pispip.PlannedInventoryLevelEnd();
            //产量是加总
            if( isccproduction or isdlproduction ){
              row.SetCellProductionValue( daycolumn, iscc, supplyquantity );
    //          row.SetCellProductionValue( weekcolumn, iscc, supplyquantity );
            }
            //库存需要取最后一天
            row.SetCellInventoryValue( daycolumn, [Real]inventoryquantity );
    //        if( pispip.Start().Date() = weekcolumn.EndDate() or pispip.Period_MP() = endperiod ){
    //
    //          row.SetCellInventoryValue( weekcolumn, [Real]inventoryquantity );
    //        }
          }
          //库存需要取最后一天
          row.SetCellInventoryValue( daycolumn, [Real]inventoryquantity );
          if( pispip.Start().Date() = weekcolumn.EndDate() or pispip.Period_MP() = endperiod ){
            row.SetCellInventoryValue( weekcolumn, [Real]inventoryquantity );
          }
        }
      }
    }
    //生成需求数据
    traverse( owner, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.SalesSegment_MP() ) and forecast.StartDate() < endperiod.StartDate() and forecast.Quantity() <> 0 
              and exists( forecast.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent )
@@ -68,26 +74,26 @@
        //天
        daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), psdip.StartDate() );
        //周
        weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), psdip.StartDate() );
    //    weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), psdip.StartDate() );
          
        if( not isnull( daycolumn ) ){
          row.SetCellDemandValue( daycolumn, forecast.SalesSegmentName(), forecast.Quantity() );
        }
        if( not isnull( weekcolumn ) ){
          row.SetCellDemandValue( weekcolumn, forecast.SalesSegmentName(), forecast.Quantity() );
        }
    //    if( not isnull( weekcolumn ) ){
    //      row.SetCellDemandValue( weekcolumn, forecast.SalesSegmentName(), forecast.Quantity() );
    //    }
    //    if( psdip.StartDate() = ( weekstart + Duration::Days( 6 ) ).Date() or psdip.PeriodStart() = endperiod.StartDate() ){
    //      weekstart       := ( weekstart + Duration::Days( 7 ) ).Date();
    //    } 
      }
    }
    
    rows := selectsortedset( table, Row, row, row.Name() );
    i    := 0;
    traverse( rows, Elements, e ){
      e.RowNr( i );
      i := i + 1;
    }
    //rows := selectsortedset( table, Row, row, row.Name() );
    //i    := 0;
    //traverse( rows, Elements, e ){
    //  e.RowNr( i );
    //  i := i + 1;
    //}
    showtable.Generate( search, products );
  *]
}
_Main/BL/Type_MachiningPipelineCell/Attribute_CCToDLArrivalQty.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute CCToDLArrivalQty
{
  #keys: '3[415136.0.1262801280][415136.0.1262801279][415136.0.1262801281]'
  Description: 'CC to DL åˆ°è¾¾æ•°é‡'
  ValueType: Real
}
_Main/BL/Type_MachiningPipelineCell/Attribute_CCToDLDepartureQty.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute CCToDLDepartureQty
{
  #keys: '3[415136.0.1262801270][415136.0.1262801269][415136.0.1262801271]'
  Description: 'CC to DL离场数量'
  ValueType: Real
}
_Main/BL/Type_MachiningPipelineCell/Attribute_DLToCCArrivalQty.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute DLToCCArrivalQty
{
  #keys: '3[415136.0.1262801300][415136.0.1262801299][415136.0.1262801301]'
  Description: 'DL to CC åˆ°è¾¾æ•°é‡'
  ValueType: Real
}
_Main/BL/Type_MachiningPipelineCell/Attribute_DLToCCDepartureQty.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute DLToCCDepartureQty
{
  #keys: '3[415136.0.1262801290][415136.0.1262801289][415136.0.1262801291]'
  Description: 'DL to CC离场数量'
  ValueType: Real
}
_Main/BL/Type_MachiningPipelineReport/Method_Generate.qbl
@@ -8,31 +8,60 @@
  TextBody:
  [*
    // ç”„兰鸽 Jun-25-2024 (created)
    table      := selectobject( this, Source.Report, report, not report.IsShow() );
    startyearmonth          := search.MacroPlan().StartOfPlanning().StartOfMonth().Date();
    table                   := selectobject( this, Source.Report, report, not report.IsShow() );
    //清空之前存储的显示数据
    this.Clear( search.TimeUnit(), search.StartDate(), search.EndDate() );
    //过滤后的产品id
    productids := selectuniquevalues( products, Elements, product, true, product.ID() );
    sumrow     := this.Row( relnew, Name := 'SUM', RowNr := table.Row( relsize ) );
    productids              := selectuniquevalues( products, Elements, product, true, product.ID() );
    sumrow                  := this.Row( relnew, Name := 'SUM', RowNr := table.Row( relsize ) );
    traverse( table, Row, row, productids.Find( row.Name() ) >= 0 ){
      showrow := this.Row( relnew, Name := row.Name(), RowNr := row.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() );
        if( not isnull( column ) ){
          sumcell  := selectobject( column, Cell, c, c.Row() = sumrow );
          if( isnull( sumcell ) ){
            sumcell := MachiningPipelineCell::Initialize( column );
            sumrow.Cell( relinsert, sumcell );
          }
          showcell := cell.Copy( column );
          showrow.Cell( relinsert, showcell );
          sumcell.Add( cell );
      showrow               := this.Row( relnew, Name := row.Name(), RowNr := row.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() );
        maxinventory        := maxobject( daycells, Elements, e, e.Column().StartDate() );
        ccassemblyplanqty   := sum( daycells, Elements, cell, cell.CCAssemblyPlanQty() );
        ccproductionqty     := sum( daycells, Elements, cell, cell.CCProductionQty() );
        cctransferqty       := sum( daycells, Elements, cell, cell.CCTransferQty() );
        ccinventoryqty      := 0.0;
        dlassemblyplanqty   := sum( daycells, Elements, cell, cell.DLAssemblyPlanQty() );
        dlproductionqty     := sum( daycells, Elements, cell, cell.DLProductionQty() );
        dltransferqty       := sum( daycells, Elements, cell, cell.DLTransferQty() );
        dlinventoryqty      := 0.0;
        if( column.StartDate() = startyearmonth ){//当日期是计划开始第一个月时,计算库存是实际库存
          ccinventoryqty    := row.CCInventoryQty() + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
          dlinventoryqty    := row.DLInventoryQty() + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.CCToDLArrivalQty() - maxinventory.DLAssemblyPlanQty();
        }else{
          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();
        }
        sumcell  := selectobject( column, Cell, c, c.Row() = sumrow );
        if( isnull( sumcell ) ){
          sumcell           := column.Cell( relnew, CCAssemblyPlanQty  := 0,
                                             CCProductionQty           := 0,
                                             CCTransferQty             := 0,
                                             CCInventoryQty            := 0,
                                             DLAssemblyPlanQty         := 0,
                                             DLProductionQty           := 0,
                                             DLTransferQty             := 0,
                                             DLInventoryQty            := 0 );
          sumrow.Cell( relinsert, sumcell );
        }
        showcell            := column.Cell( relnew, CCAssemblyPlanQty  := ccassemblyplanqty,
                                             CCProductionQty           := ccproductionqty,
                                             CCTransferQty             := cctransferqty,
                                             CCInventoryQty            := ccinventoryqty,
                                             DLAssemblyPlanQty         := dlassemblyplanqty,
                                             DLProductionQty           := dlproductionqty,
                                             DLTransferQty             := dltransferqty,
                                             DLInventoryQty            := dlinventoryqty );
        showrow.Cell( relinsert, showcell );
        sumcell.Add( showcell );
      }
    }
  *]
_Main/BL/Type_MachiningPipelineRow/Attribute_CCInventoryQty.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute CCInventoryQty
{
  #keys: '3[415136.0.1262801322][415136.0.1262801321][415136.0.1262801323]'
  Description: 'CC实际库存数据'
  ValueType: Real
}
_Main/BL/Type_MachiningPipelineRow/Attribute_DLInventoryQty.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute DLInventoryQty
{
  #keys: '3[415136.0.1262801338][415136.0.1262801337][415136.0.1262801339]'
  Description: 'DL实际库存数据'
  ValueType: Real
}
_Main/BL/Type_MachiningPipelineRow/Method_SetDepartureAndArrivalValue.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
Quintiq file version 2.0
#parent: #root
Method SetDepartureAndArrivalValue (
  MachiningPipelineColumn column,
  Boolean iscctodl,
  Real departureqty,
  Real arriveqty
)
{
  Description: '设置离厂到达数量'
  TextBody:
  [*
    // ç”„兰鸽 Jun-24-2024 (created)
    cell := selectobject( this, Cell, cell, cell.Column() = column );
    if( iscctodl ){
      cell.CCToDLDepartureQty( cell.CCToDLDepartureQty() + departureqty );
      cell.CCToDLArrivalQty( cell.CCToDLArrivalQty() + arriveqty );
    } else {
      cell.DLToCCDepartureQty( cell.DLToCCDepartureQty() + departureqty );
      cell.DLToCCArrivalQty( cell.DLToCCArrivalQty() + arriveqty );
    }
  *]
}
_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Download.qbl
@@ -78,39 +78,39 @@
          //Attribute
          //长春装配计划
          ccaqcellElement := xmlDOM.CreateElement( "cell" );
          ccaqcellElement.SetAttribute( "value", '长春装配计划' );//CCAssemblyPlanQty
          ccaqcellElement.SetAttribute( "value", 'CC装配计划' );//CCAssemblyPlanQty
          attricolumnelement.AppendChild( ccaqcellElement );
          //长春生产计划
          ccpqcellElement := xmlDOM.CreateElement( "cell" );
          ccpqcellElement.SetAttribute( "value", '长春生产计划' );//CCProductionQty
          ccpqcellElement.SetAttribute( "value", 'CC机加计划' );//CCProductionQty
          attricolumnelement.AppendChild( ccpqcellElement );
          //长春调拨计划
          cctqcellElement := xmlDOM.CreateElement( "cell" );
          cctqcellElement.SetAttribute( "value", '长春调拨计划' );//CCTransferQty
          cctqcellElement.SetAttribute( "value", 'CC to DL' );//CCTransferQty
          attricolumnelement.AppendChild( cctqcellElement );
          //长春库存
          cciqcellElement := xmlDOM.CreateElement( "cell" );
          cciqcellElement.SetAttribute( "value", '长春库存' );//CCInventoryQty
          cciqcellElement.SetAttribute( "value", 'CC库存' );//CCInventoryQty
          attricolumnelement.AppendChild( cciqcellElement );
          //大连装配计划
          dlaqcellElement := xmlDOM.CreateElement( "cell" );
          dlaqcellElement.SetAttribute( "value", '大连装配计划' );//DLAssemblyPlanQty
          dlaqcellElement.SetAttribute( "value", 'DL装配计划' );//DLAssemblyPlanQty
          attricolumnelement.AppendChild( dlaqcellElement );
          //大连生产计划
          dlpqcellElement := xmlDOM.CreateElement( "cell" );
          dlpqcellElement.SetAttribute( "value", '大连生产计划' );//DLProductionQty
          dlpqcellElement.SetAttribute( "value", 'DL机加计划' );//DLProductionQty
          attricolumnelement.AppendChild( dlpqcellElement );
          //大连调拨计划
          dltqcellElement := xmlDOM.CreateElement( "cell" );
          dltqcellElement.SetAttribute( "value", '大连调拨计划' );//DLTransferQty
          dltqcellElement.SetAttribute( "value", 'DL to CC' );//DLTransferQty
          attricolumnelement.AppendChild( dltqcellElement );
          //大连库存
          dliqcellElement := xmlDOM.CreateElement( "cell" );
          dliqcellElement.SetAttribute( "value", '大连库存' );//DLInventoryQty
          dliqcellElement.SetAttribute( "value", 'DL库存' );//DLInventoryQty
          attricolumnelement.AppendChild( dliqcellElement );
          //长春 + å¤§è¿ž åº“å­˜
          tiqcellElement := xmlDOM.CreateElement( "cell" );
          tiqcellElement.SetAttribute( "value", '长春 + å¤§è¿žåº“å­˜' );//TotalInventoryQty
          tiqcellElement.SetAttribute( "value", 'CC + DL库存' );//TotalInventoryQty
          attricolumnelement.AppendChild( tiqcellElement );
        }
        //长春装配计划
_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -8,6 +8,7 @@
  [*
    // ç”„兰鸽 Jun-24-2024 (created)
    owner.FinancialProductionSource( relflush );
    startinventorydate        := owner.StartOfPlanning() - Duration::Days( 1 );
    productparent             := MachiningPipelineReport::GetDefaultProductParent();
    source                    := owner.MachiningPipelineSource( relnew, Name := MachiningPipelineReport::GetDefaultName() );
    table                     := source.Report( relnew, ID := source.Name(), Name := source.Name() );
@@ -18,7 +19,7 @@
    products                  := construct( Product_MPs );
    //初始化列
    table.GenerateColumn( owner, 'All', search.StartDate(), search.EndDate() );
    endperiod                 := maxobject( owner, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day(), period.StartDate() );
    //endperiod                 := maxobject( owner, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day(), period.StartDate() );
    
    //生成装配(长内库)、生产(的DL和库存数据
    traverse( owner, StockingPoint_MP, stockingpoint ){
@@ -31,47 +32,73 @@
      if( iscc or isdl ){
        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 ) ) ){
                  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.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() );
                                                  and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.DependentDemandAndSalesDemandQuantity() <> 0 ), pispip.Start() );
          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 );
          traverse( pispips, Elements, pispip){//, pispip.Start().Month() = 1 and pispip.Start().Day() = 2
            products.Add( pisp.Product_MP() );
            //天
            daycolumn         := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
            //周
            weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), pispip.Start().Date() );
            row               := table.GetRow( pisp.ProductID() );
    //        weekcolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), pispip.Start().Date() );
            
            if( isccassemnly or isdlassemnly ){
              //装配线
              quantity        := [Number]pispip.DependentDemandAndSalesDemandQuantity();//四舍五入
              row.SetAssemblyPlanValue(  daycolumn, isccassemnly, [Real]quantity );
              row.SetAssemblyPlanValue( weekcolumn, isccassemnly, [Real]quantity );
    //          row.SetAssemblyPlanValue( weekcolumn, isccassemnly, [Real]quantity );
              //生产
              supplyqty       := [Number]pispip.NewSupplyQuantity();//四舍五入
    //          info( '****************', quantity, supplyqty );
              row.SetCellProductionValue( daycolumn, isccassemnly, [Real]supplyqty );
              row.SetCellProductionValue( weekcolumn, isccassemnly, [Real]supplyqty );
    //          row.SetCellProductionValue( weekcolumn, isccassemnly, [Real]supplyqty );
            }
            
            //库存
            if( iscc or isdl ){
              inventoryqty    := [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
              row.SetCellInventoryValue( daycolumn, iscc, [Real]inventoryqty );
              if( weekcolumn.EndDate() = pispip.Start().Date() or pispip.Period_MP() = endperiod ){
                row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryqty );
              }
    //        if( iscc or isdl ){
    //          inventoryqty    := [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
    //          row.SetCellInventoryValue( daycolumn, iscc, [Real]inventoryqty );
    //          if( weekcolumn.EndDate() = pispip.Start().Date() or pispip.Period_MP() = endperiod ){
    //            row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryqty );
    //          }
            }
          }
        }
      }
    }
    //生成调拨数据
    traverse( owner, Unit.Lane.LaneLeg, laneleg ){
      originspid             := laneleg.OriginStockingPointID();
      destinationspid        := laneleg.DestinationStockingPointID();
      //CC to DL é•¿æ˜¥åŽ‚å†…åº“åˆ°å¤§è¿žå¤–ç§Ÿåº“
      iscctodl               := originspid.EndsWith( '厂内库' ) and ( originspid.StartsWith( '长春' ) or originspid.StartsWith( 'CC' ) ) and destinationspid = '大连外租库';
      //DL to CC å¤§è¿žåŽ‚å†…åº“åˆ°å¤§è¿žå‘åŠ¨æœºçš„é•¿æ˜¥å¤–ç§Ÿåº“
      isdltocc               := originspid.EndsWith( '厂内库' ) and ( originspid.StartsWith( '大连' ) or originspid.StartsWith( 'DL' ) ) and destinationspid = '大连发动机的长春外租库';
      if( iscctodl and isdltocc ){
        traverse( table, Column, column){//, column.StartDate().Month() = 1
          alltrips           := selectset( laneleg, Trip, trip, ( trip.Arrival().Date() < column.StartDate().StartOfNextMonth() and trip.Arrival().Date() >= column.StartDate() )
                                           or ( trip.Departure().Date() < column.StartDate().StartOfNextMonth() and trip.Departure().Date() >= column.StartDate() ) );
          producttrips      := selectuniquevalues( alltrips, Elements.ProductInTrip, pit, pit.Quantity() <> 0 and exists( pit.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent ), pit.ProductID() );
          traverse( producttrips, Elements, producttrip ){//, producttrip = '6912'
            row             := table.GetRow( producttrip );
            product         := selectobject( owner, Product_MP, product, product.ID() = producttrip );
            products.Add( product );
            departureqty    := sum( alltrips, Elements.ProductInTrip, pit, ( pit.Trip().Departure().Date() < column.StartDate().StartOfNextMonth() and pit.Trip().Departure().Date() >= column.StartDate() ) and pit.Product_MP() = product, pit.Quantity() );
            arrivalqty      := sum( alltrips, Elements.ProductInTrip, pit, ( pit.Trip().Arrival().Date() < column.StartDate().StartOfNextMonth() and pit.Trip().Arrival().Date() >= column.StartDate() ) and pit.Product_MP() = product, pit.Quantity() );
            row.SetDepartureAndArrivalValue( column, iscctodl, departureqty, arrivalqty );
          }
        }
      }
    }
    //生成调拨数据
    traverse( owner, TransferPlanRow, tprow ){
      product               := selectobject( owner, Product_MP, product, product.ID() = tprow.ProductID() );
@@ -95,25 +122,25 @@
            //天
            daycolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), tpcell.TransferPlanColumn().ColumnDate() );
            //周
            weekcolumn       := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), tpcell.TransferPlanColumn().ColumnDate() );
    //        weekcolumn       := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), tpcell.TransferPlanColumn().ColumnDate() );
            quantity         := [Real]tpcell.Value();//四舍五入
            if( not isnull( daycolumn ) ){
              row.SetCellTransferValue( daycolumn, ( originiscc and destiisdl ), quantity );
            }
            if( not isnull( weekcolumn ) ){
              row.SetCellTransferValue( weekcolumn, ( originiscc and destiisdl ), quantity );
            }
    //        if( not isnull( weekcolumn ) ){
    //          row.SetCellTransferValue( weekcolumn, ( originiscc and destiisdl ), quantity );
    //        }
          }
        }
      }
    }
    
    rows := selectsortedset( table, Row, row, row.Name() );
    i    := 0;
    traverse( rows, Elements, e ){
      e.RowNr( i );
      i := i + 1;
    }
    //rows := selectsortedset( table, Row, row, row.Name() );
    //i    := 0;
    //traverse( rows, Elements, e ){
    //  e.RowNr( i );
    //  i := i + 1;
    //}
    showtable.Generate( search, products );
  *]
}