lihongji
2024-12-12 5ad37285137cfcf072c0e7b38dd4fb562bc83f5c
包装计划优化
已修改4个文件
52 ■■■■■ 文件已修改
_Main/BL/Type_PackagingPlanCell/Function_CalcPackagingInventory.qbl 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_PackagingPlanCell/StaticMethod_CreateData.qbl 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_PackagingPlanCell/StaticMethod_SetInitialPackagingInventory.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_PackagingPlanCell/StaticMethod_SetUnpackage_Lotsize.qbl 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_PackagingPlanCell/Function_CalcPackagingInventory.qbl
@@ -10,11 +10,11 @@
                     this.InitialPackagingInventory() + guard( this.Previous().PackagingInventory()                 + 
                                                               this.TransferIn()                                    +
                                                               guard( this.Package(), 0.0 )                         -  
                                                               ifexpr( this.TransferIn() > 0.0, 0, this.Unpacking() ),
                                                               guard( this.Unpacking(), 0.0 ),
                                                               0.0 )
                                                      - this.Out()
                    );
    
    this.PackagingInventory( value );
    this.PackagingInventory( [Number]value );
  *]
}
_Main/BL/Type_PackagingPlanCell/StaticMethod_CreateData.qbl
@@ -65,13 +65,13 @@
        if ( factory = "大连工厂" ) {
          // 净需求&剩余库存&供应量
          cell.NetDemand( cell.NetDemand() + pispipl.DependentDemandAndSalesDemandQuantity() );
          cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
          cell.EndingInventory( [Number] ( cell.EndingInventory() + pispipl.InventoryLevelEnd() ) );
        }
        
        // 长春工厂设置值
        if ( factory = "长春工厂" ) {
          // 剩余库存&供应量
          cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
          cell.EndingInventory( [Number] ( cell.EndingInventory() + pispipl.InventoryLevelEnd() ) );
          
          // 净需求【只取线边库】&包装库存&非包装库存
          if ( pisp.StockingPointID().Regex( "外租库" ) ) {
@@ -94,10 +94,10 @@
          preCell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = planPre );
          if ( isnull( preCell ) ) {
            preCell := ppr.PackagingPlanCell( relnew );
            preCell.EndingInventory( prePISPIPL.InventoryLevelEnd() );
            preCell.EndingInventory( [Number]prePISPIPL.InventoryLevelEnd() );
            preCell.PackagingPlanColumn( relset, planPre );
          } else {
            preCell.EndingInventory( preCell.EndingInventory() + prePISPIPL.InventoryLevelEnd() );
            preCell.EndingInventory( [Number] ( preCell.EndingInventory() + prePISPIPL.InventoryLevelEnd() ) );
          }
        }
      }
_Main/BL/Type_PackagingPlanCell/StaticMethod_SetInitialPackagingInventory.qbl
@@ -17,7 +17,7 @@
                           tempPPCell.PackagingPlanRow().ProductID()    = iidd.PartNumber()                          and
                           tempPPCell.PackagingPlanColumn().StartDate() = ( macroPlan.StartOfPlanning().Date() - 1 ) and
                           tempPPCell.PackagingPlanRow().Factory()      =  factory );
        ppcell.PackagingInventory( iidd.Quantity() );
        ppcell.InitialPackagingInventory( iidd.Quantity() );
      }
    }
  *]
_Main/BL/Type_PackagingPlanCell/StaticMethod_SetUnpackage_Lotsize.qbl
@@ -10,8 +10,12 @@
    plannedStartDate := macroPlan.StartOfPlanning().Date();
    
    // 设置拆包值(符合lotsize和一日最大包装量)
    traverse ( macroPlan, PackagingPlanRow, ppr, ppr.Factory() = "大连工厂" /*and ppr.ProductID() = "06K103011CM"*/ ) {
      traverse ( ppr, PackagingPlanCell, ppcell/*, ppcell.StartDate() <= Date::Construct( 2025, 1, 4 )*/ ) {
    traverse ( macroPlan, PackagingPlanRow, ppr
    //           , ppr.Factory() = "大连工厂" and ppr.ProductID() = "06K103011CM"
               ) {
      traverse ( ppr, PackagingPlanCell, ppcell
    //             , ppcell.StartDate() <= Date::Construct( 2025, 1, 8 )
                 ) {
        // Product_MP
        pmp                     := select( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf() and tempPMP.ID() = ppr.ProductID() );
        // 包装lotsize
@@ -27,12 +31,12 @@
        // Unit
        us                      := selectset( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) );
         
        // 当前非包装库存 + 下一天的NewSupply < 下一天的净需求
        if ( ppcell.UnpackagedInventory() < guard( ppcell.Next().NetDemand(), 0 ) and not isnull( ppls ) and not isnull( ppnc ) ) {
        // 非包装库存出现负值,需要设置拆包量
        if ( ppcell.UnpackagedInventory() < 0 and not isnull( ppls ) and not isnull( ppnc ) ) {
          // 需要包装的数量
          needPackagingQuantity := abs( ppcell.PackagingInventory() ).Round( 0 );
          // 包装开始的索引
          indexPPCell           := ppcell.Previous();
          needPackagingQuantity := abs( ppcell.UnpackagedInventory() ).Round( 0 );
          // 拆包开始的索引
          indexPPCell           := ppcell;
          
    //      info( "产线个数:", us.Size(), "    开始时间:", ppcell.StartDate().Format( "Y-M2-D2" ), "    包装库存数量:", ppcell.PackagingInventory(), "    需要包装的数量:", needPackagingQuantity, 
    //            "    包装lotsize:",guard( ppls.LotSize(), 0 ), "    最大包装容量:", ppnc.MaximumDailyPackagingQuantity() );
@@ -44,13 +48,21 @@
                          tempSP.Outcome() <> "" )                                            and
                  needPackagingQuantity > 0 ) {
            // 能包装的数量
            canPackagingQuantity := ifexpr( ceil( needPackagingQuantity / ppls.LotSize() ) < floor( ppnc.MaximumDailyPackagingQuantity() / ppls.LotSize() ),
                                            ceil( needPackagingQuantity / ppls.LotSize() ),
                                            floor( ppnc.MaximumDailyPackagingQuantity() / ppls.LotSize() ) ) * ppls.LotSize();
            canPackagingQuantity := minvalue( canPackagingQuantity, [Number]indexPPCell.PackagingInventory() );
    //        info( "开始包装的日期:", indexPPCell.StartDate().Format( "Y-M2-D2" ), "    能包装的数量:", canPackagingQuantity );
            canPackagingQuantity    := [Number]ifexpr( ceil( needPackagingQuantity / ppls.LotSize() ) < floor( ppnc.MaximumDailyUnpackingQuantity() / ppls.LotSize() ), // 最大包装量
                                                       ceil( needPackagingQuantity / ppls.LotSize() ),
                                                       floor( ppnc.MaximumDailyPackagingQuantity() / ppls.LotSize() ) ) * ppls.LotSize();
            // 改类下其他产品包装总和
            categoryPackageQuantity := sum( indexPPCell, PackagingPlanColumn.PackagingPlanCell, tempPPCell,
                                            tempPPCell <> indexPPCell                                                            and
                                            tempPPCell.PackagingPlanRow().Factory() = indexPPCell.PackagingPlanRow().Factory()   and
                                            tempPPCell.PackagingPlanRow().Category() = indexPPCell.PackagingPlanRow().Category(),
                                            tempPPCell.Unpacking() );
            canPackagingQuantity    := minvalue( [Number] ( ppnc.MaximumDailyPackagingQuantity() - categoryPackageQuantity ),
                                                 canPackagingQuantity,
                                                 ifexpr( floor( indexPPCell.PackagingInventory() / ppls.LotSize() ) * ppls.LotSize() > 0, floor( indexPPCell.PackagingInventory() / ppls.LotSize() ) * ppls.LotSize(), 0 ) );
    //        info( "开始包装的日期:", indexPPCell.StartDate().Format( "Y-M2-D2" ), "    能包装的数量:", canPackagingQuantity, "    原拆包值:", indexPPCell.Unpacking() );
            
            indexPPCell.Next().Unpacking( canPackagingQuantity );
            indexPPCell.Unpacking( ifexpr( indexPPCell.Unpacking() > 0.0 and canPackagingQuantity = 0, indexPPCell.Unpacking(), canPackagingQuantity ) );
            Transaction::Transaction().Propagate( attribute( PackagingPlanCell, PackagingInventory ) );
            Transaction::Transaction().Propagate( attribute( PackagingPlanCell, UnpackagedInventory ) );