lazhen
2024-08-14 94ab2bd0381925ecf01a2f1a812b114d0f82d5bb
_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -8,6 +8,7 @@
  [*
    // 甄兰鸽 Jun-24-2024 (created)
    owner.FinancialProductionSource( relflush );
    productparent             := MachiningPipelineReport::GetDefaultProductParent();
    ccunit                    := MachiningPipelineReport::GetDefaultCCUnit();
    dlunit                    := MachiningPipelineReport::GetDefaultDLUnit();
    //allunit                   := EnginePipelineReport::GetDefaultAllUnit();
@@ -39,39 +40,45 @@
      //是否属于大连机加产线
      isdlproduction          := 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() ){
          row := table.GetRow( pisp.ProductID() );
          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() );
          traverse( pispips, Elements, pispip ){
            //天
            daycolumn           := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
            //周
            weekcolumn          := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
        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 ) ) ){
          product             := pisp.Product_MP();
          productparents      := product.GetAllParent();
          if( exists( productparents, Elements, e, e.ID() = productparent ) ){//查询产品类型是发动机
            row               := table.GetRow( pisp.ProductID() );
            products.Add( pisp.Product_MP() );
            weekstart         := owner.StartOfPlanning().Date();
            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() );
            
            supplyquantity      := [Number]pispip.NewSupplyQuantity();//四舍五入
            inventoryquantity   := [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
            //装配线
            if( isccassemnly or isdlassemnly ){
              row.SetCellAssemblyValue( daycolumn, isccassemnly, [Real]supplyquantity );
              row.SetCellAssemblyValue( weekcolumn, isccassemnly, [Real]supplyquantity );
            }
            //机加线
            if( isccproduction or isdlproduction ){
              row.SetCellProductionValue( daycolumn, isccproduction, [Real]supplyquantity );
              row.SetCellProductionValue( weekcolumn, isccproduction, [Real]supplyquantity );
            }
            //库存
            if( iscc or isdl ){
              row.SetCellInventoryValue( daycolumn, iscc, [Real]inventoryquantity );
              if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){
                weekstart         := ( weekstart + Duration::Days( 7 ) ).Date();
                row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryquantity );
            traverse( pispips, Elements, pispip ){
              //天
              daycolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
              //周
              weekcolumn       := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), weekstart );
              supplyquantity   := [Number]pispip.NewSupplyQuantity();//四舍五入
              inventoryquantity:= [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
              //装配线
              if( isccassemnly or isdlassemnly ){
                row.SetCellAssemblyValue( daycolumn, isccassemnly, [Real]supplyquantity );
                row.SetCellAssemblyValue( weekcolumn, isccassemnly, [Real]supplyquantity );
              }
              //机加线
              if( isccproduction or isdlproduction ){
                row.SetCellProductionValue( daycolumn, isccproduction, [Real]supplyquantity );
                row.SetCellProductionValue( weekcolumn, isccproduction, [Real]supplyquantity );
              }
              //库存
              if( iscc or isdl ){
                row.SetCellInventoryValue( daycolumn, iscc, [Real]inventoryquantity );
                if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){
                  weekstart      := ( weekstart + Duration::Days( 7 ) ).Date();
                  row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryquantity );
                }
              }
            }
          }