¶Ô±ÈÐÂÎļþ |
| | |
| | | Quintiq file version 2.0 |
| | | #parent: #root |
| | | StaticMethod Package ( |
| | | MacroPlan macroPlan, |
| | | PackagingPlanRow ppr, |
| | | PackagingPlanColumn ppc, |
| | | output Number needPackagingQuantity |
| | | ) |
| | | { |
| | | TextBody: |
| | | [* |
| | | // 计åå¼å§æ¶é´ |
| | | plannedStartDate := macroPlan.StartOfPlanning().Date(); |
| | | |
| | | traverse ( ppr, PackagingPlanCell, ppcell, ppcell.PackagingPlanColumn() = ppc ) { |
| | | // 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 |
| | | us := selectset( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) ); |
| | | |
| | | // å
è£
åºååºç°è´å¼ï¼éè¦è®¾ç½®å
è£
é |
| | | if ( not isnull( ppls ) and not isnull( ppnc ) ) { |
| | | // å
è£
å¼å§çç´¢å¼ |
| | | indexPPCell := ppcell.Previous(); |
| | | |
| | | // info( "产线个æ°ï¼", us.Size(), " å¼å§æ¶é´ï¼", ppcell.StartDate().Format( "Y-M2-D2" ), " å
è£
åºåæ°éï¼", ppcell.PackagingInventory(), " éè¦å
è£
çæ°éï¼", needPackagingQuantity, |
| | | // " å
è£
lotsizeï¼",guard( ppls.LotSize(), 0 ), " æå¤§å
è£
容éï¼", ppnc.MaximumDailyPackagingQuantity() ); |
| | | |
| | | while ( not isnull( indexPPCell ) and |
| | | indexPPCell.StartDate() >= plannedStartDate and |
| | | exists( us, Elements.UnitPeriod.astype( UnitPeriodTime ).ShiftPlan, tempSP, |
| | | tempSP.UnitPeriodTime().StartDate() = indexPPCell.StartDate(), |
| | | 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(); |
| | | // info( "å¼å§å
è£
çæ¥æï¼", indexPPCell.StartDate().Format( "Y-M2-D2" ), " è½å
è£
çæ°é:", canPackagingQuantity ); |
| | | |
| | | indexPPCell.Package( canPackagingQuantity ); |
| | | Transaction::Transaction().Propagate( attribute( PackagingPlanCell, PackagingInventory ) ); |
| | | Transaction::Transaction().Propagate( attribute( PackagingPlanCell, UnpackagedInventory ) ); |
| | | |
| | | needPackagingQuantity := needPackagingQuantity - canPackagingQuantity; |
| | | indexPPCell := indexPPCell.Previous(); |
| | | } |
| | | } |
| | | } |
| | | *] |
| | | } |
| | |
| | | { |
| | | TextBody: |
| | | [* |
| | | // 计åå¼å§æ¶é´ |
| | | 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, 3 ) ) { |
| | | traverse ( macroPlan, PackagingPlanRow, ppr/*, ppr.Factory() = "大è¿å·¥å" and ppr.ProductID() = "06K103011CM"*/ ) { |
| | | traverse ( ppr, PackagingPlanCell, ppcell/*, ppcell.StartDate() <= Date::Construct( 2025, 1, 4 )*/ ) { |
| | | // Product_MP |
| | | pmp := select( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf() and tempPMP.ID() = ppr.ProductID() ); |
| | | // å
è£
lotsize |
| | |
| | | pmp.ID(), |
| | | pmp.ParentID() ) ); |
| | | // Unit |
| | | u := select( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) ); |
| | | us := selectset( macroPlan, Unit, tempU, tempU.ID().Regex( ppr.FactoryAbbreviation() + " " + ppr.Category() ) ); |
| | | |
| | | // å
è£
åºååºç°è´å¼ï¼éè¦è®¾ç½®å
è£
é |
| | | if ( ppcell.PackagingInventory() < 0 and not isnull( ppls ) and not isnull( ppnc ) ) { |
| | |
| | | // å
è£
å¼å§çç´¢å¼ |
| | | indexPPCell := ppcell.Previous(); |
| | | |
| | | info( "产线åï¼", u.ID(), " å¼å§æ¶é´ï¼", ppcell.StartDate().Format( "Y-M2-D2" ), " å
è£
åºåæ°éï¼", ppcell.PackagingInventory(), " éè¦å
è£
çæ°éï¼", needPackagingQuantity, |
| | | " å
è£
lotsizeï¼",guard( ppls.LotSize(), 0 ), " æå¤§å
è£
容éï¼", ppnc.MaximumDailyPackagingQuantity() ); |
| | | // info( "产线个æ°ï¼", us.Size(), " å¼å§æ¶é´ï¼", ppcell.StartDate().Format( "Y-M2-D2" ), " å
è£
åºåæ°éï¼", ppcell.PackagingInventory(), " éè¦å
è£
çæ°éï¼", needPackagingQuantity, |
| | | // " å
è£
lotsizeï¼",guard( ppls.LotSize(), 0 ), " æå¤§å
è£
容éï¼", ppnc.MaximumDailyPackagingQuantity() ); |
| | | |
| | | while ( not isnull( indexPPCell ) and needPackagingQuantity > 0 ) { |
| | | while ( not isnull( indexPPCell ) and |
| | | indexPPCell.StartDate() >= plannedStartDate and |
| | | exists( us, Elements.UnitPeriod.astype( UnitPeriodTime ).ShiftPlan, tempSP, |
| | | tempSP.UnitPeriodTime().StartDate() = indexPPCell.StartDate(), |
| | | 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(); |
| | | info( "å¼å§å
è£
çæ¥æï¼", indexPPCell.StartDate().Format( "Y-M2-D2" ), " è½å
è£
çæ°é:", canPackagingQuantity ); |
| | | // info( "å¼å§å
è£
çæ¥æï¼", indexPPCell.StartDate().Format( "Y-M2-D2" ), " è½å
è£
çæ°é:", canPackagingQuantity ); |
| | | |
| | | indexPPCell.Package( canPackagingQuantity ); |
| | | Transaction::Transaction().Propagate( attribute( PackagingPlanCell, PackagingInventory ) ); |
| | | Transaction::Transaction().Propagate( attribute( PackagingPlanCell, UnpackagedInventory ) ); |
| | | |
| | | needPackagingQuantity := needPackagingQuantity - canPackagingQuantity; |
| | | indexPPCell := indexPPCell.Previous(); |
| | |
| | | } |
| | | } |
| | | |
| | | // 设置å
è£
å¼ï¼ç¬¦åå¤§ç±»ä¸ææäº§åå
è£
éå åä¸è½å¤§äºæå¤§å
è£
éï¼ |
| | | // 设置å
è£
å¼ï¼ç¬¦åå¤§ç±»ä¸ææäº§åéå
è£
éåºåå åä¸è½å¤§äºç³»ç»å¼ï¼ |
| | | factorys := selectuniquevalues( macroPlan, PackagingPlanRow, tempPPR, true, tempPPR.FactoryAbbreviation() ); |
| | | categorys := selectuniquevalues( macroPlan, PackagingPlanRow, tempPPR, true, tempPPR.Category() ); |
| | | traverse ( factorys, Elements, f/*, f = "DL"*/ ) { |
| | | traverse ( categorys, Elements, c/*, c = "ZKG"*/ ) { |
| | | // ç³»ç»è§å®çæå¤§éå
è£
åºåæ°é |
| | | ppmqReflection := Reflection::FindAttribute( "PackagingPlanMaximumQuantity", f + "_" + c ); |
| | | maxPackageQuantity := guard( ppmqReflection.GetNumber( macroPlan.PackagingPlanMaximumQuantity() ), 0 ); |
| | | // å½åå·¥åä¸ä¸ç±»äº§åè¡ |
| | | pprs := selectset( macroPlan, PackagingPlanRow, tempPPR, tempPPR.FactoryAbbreviation() = f and tempPPR.Category() = c ); |
| | | |
| | | // info( "å½åå·¥åï¼", f, " å½å大类ï¼", c, " 大类ä¸çæå¤§å
è£
æ°éï¼", maxPackageQuantity ); |
| | | traverse ( macroPlan, PackagingPlanColumn, ppc, ppc.StartDate() > plannedStartDate and maxPackageQuantity > 0 ) { |
| | | sumUnpackagedInventoryQuantity := sum( pprs, Elements.PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc, tempPPCell.UnpackagedInventory() ).Round( 0 ); |
| | | |
| | | // éè¦å
è£
|
| | | if ( sumUnpackagedInventoryQuantity > maxPackageQuantity ) { |
| | | // éè¦å
è£
çæ°é |
| | | needPackagingQuantity := [Number] ( sumUnpackagedInventoryQuantity - maxPackageQuantity ); |
| | | // æéå
è£
åºåæåºåçè¡ |
| | | itemPPRs := selectsortedset( pprs, Elements, tempPPR, true, |
| | | -select( tempPPR, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc ).UnpackagedInventory() ); |
| | | |
| | | // info( "éè¦å
è£
æ¶é´ï¼", ppc.StartDate().Format( "Y-M2-D2" ), " éè¦å
è£
çæ°éï¼", needPackagingQuantity ); |
| | | traverse ( itemPPRs, Elements, ppr, needPackagingQuantity > 0 ) { |
| | | PackagingPlanCell::Package( macroPlan, ppr, ppc, needPackagingQuantity ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | *] |
| | | } |