1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| Quintiq file version 2.0
| #parent: #root
| StaticMethod SetPackage_Capacity (
| MacroPlan macroPlan
| )
| {
| TextBody:
| [*
| // 计划开始时间
| plannedStartDate := macroPlan.StartOfPlanning().Date();
|
| // 设置包装值(符合大类下所有产品非包装量库存加和不能大于系统值)
| 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 );
| }
| }
| }
| }
| }
| *]
| }
|
|