| | |
| | | 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 |
| | |
| | | // 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() ); |
| | |
| | | tempSP.Outcome() <> "" ) and |
| | | needPackagingQuantity > 0 ) { |
| | | // 能包装的数量 |
| | | canPackagingQuantity := ifexpr( ceil( needPackagingQuantity / ppls.LotSize() ) < floor( ppnc.MaximumDailyPackagingQuantity() / ppls.LotSize() ), |
| | | canPackagingQuantity := [Number]ifexpr( ceil( needPackagingQuantity / ppls.LotSize() ) < floor( ppnc.MaximumDailyUnpackingQuantity() / 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 ); |
| | | // 改类下其他产品包装总和 |
| | | 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 ) ); |
| | | |