Quintiq file version 2.0
|
#parent: #root
|
StaticMethod SetPackagingAndUnpackingValues (
|
MacroPlan macroPlan
|
)
|
{
|
TextBody:
|
[*
|
// 设置包装值(符合lotsize和一日最大包装量)
|
traverse ( macroPlan, PackagingPlanRow, ppr, ppr.Factory() = "大连工厂" and ppr.ProductID() = "06K103011CM" ) {
|
traverse ( ppr, PackagingPlanCell, ppcell, ppcell.StartDate() <= Date::Construct( 2025, 1, 3 ) ) {
|
// Product_MP
|
pmp := select( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf() and tempPMP.ID() = ppr.ProductID() );
|
// 包装lotsize
|
ppls := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() = ppr.Factory() and
|
tempPPLS.ProductID() = ifexpr( exists( macroPlan, PackagingPlanLotSize, tempPPLS1, tempPPLS1.ProductID() = pmp.ID() ),
|
pmp.ID(),
|
pmp.ParentID() ) );
|
// 一日包装容量
|
ppnc := select( macroPlan, PackagingPlanNewCapability, tempPPNC, tempPPNC.Factory() = ppr.Factory() and
|
tempPPNC.ProductID() = ifexpr( exists( macroPlan, PackagingPlanNewCapability, tempPPNC1, tempPPNC1.ProductID() = pmp.ID() ),
|
pmp.ID(),
|
pmp.ParentID() ) );
|
// Unit
|
u := select( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) );
|
|
// 包装库存出现负值,需要设置包装量
|
if ( ppcell.PackagingInventory() < 0 and not isnull( ppls ) and not isnull( ppnc ) ) {
|
// 需要包装的数量
|
needPackagingQuantity := abs( ppcell.PackagingInventory() ).Round( 0 );
|
// 包装开始的索引
|
indexPPCell := ppcell.Previous();
|
|
info( "产线名:", u.ID(), " 开始时间:", ppcell.StartDate().Format( "Y-M2-D2" ), " 包装库存数量:", ppcell.PackagingInventory(), " 需要包装的数量:", needPackagingQuantity,
|
" 包装lotsize:",guard( ppls.LotSize(), 0 ), " 最大包装容量:", ppnc.MaximumDailyPackagingQuantity() );
|
|
while ( not isnull( indexPPCell ) 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();
|
info( "开始包装的日期:", indexPPCell.StartDate().Format( "Y-M2-D2" ), " 能包装的数量:", canPackagingQuantity );
|
|
indexPPCell.Package( canPackagingQuantity );
|
|
needPackagingQuantity := needPackagingQuantity - canPackagingQuantity;
|
indexPPCell := indexPPCell.Previous();
|
}
|
}
|
}
|
}
|
|
// 设置包装值(符合大类下所有产品包装量加和不能大于最大包装量)
|
*]
|
}
|