Quintiq file version 2.0
|
#parent: #root
|
StaticMethod RefreshOfflinePlan (
|
MacroPlan macroPlan
|
)
|
{
|
TextBody:
|
[*
|
macroPlan.OfflinePlanRow( relflush );
|
macroPlan.OfflinePlanColumn( relflush );
|
|
// 生成下线计划表
|
traverse ( macroPlan, Unit, u, u.HasCapacityTypeTime() and u.Name() = "ZP4-M3" ) {
|
// 创建产线行
|
macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "", Type := "0" );
|
|
traverse ( u, Operation, o ) {
|
traverse ( o, PeriodTaskOperation.NewSupply, ns ) {
|
// 找行
|
oprQuantity := OfflinePlanRow::FindOfflinePlanRowTypeIndex( u.ID(), ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), "1" );
|
oprOrder := OfflinePlanRow::FindOfflinePlanRowTypeIndex( u.ID(), ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), "2" );
|
if ( isnull( oprQuantity ) and isnull( oprOrder ) ) {
|
oprQuantity := macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), Type := "1" );
|
oprOrder := macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), Type := "2" );
|
}
|
|
// 找列
|
opc := OfflinePlanColumn::FindOfflinePlanColumnTypeIndex( ns.Start().Date() );
|
if ( isnull( opc ) ) {
|
opc := macroPlan.OfflinePlanColumn( relnew, ColumnDate := ns.Start().Date() );
|
}
|
|
// 赋值单元格
|
cellQuantity := opc.OfflinePlanCell( relnew, Value := [String]ns.Quantity().Round( 0 ), Shift := ns.PeriodTask_MP().UnitPeriod().astype( UnitPeriodTimeBase ).ShiftPattern().Name() );
|
cellQuantity.OfflinePlanRow( relset, oprQuantity );
|
cellOrder := opc.OfflinePlanCell( relnew, Value := "单号" );
|
cellOrder.OfflinePlanRow( relset, oprOrder );
|
}
|
}
|
|
// 创建总量行
|
macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "3" );
|
// 创建班次行
|
macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "4" );
|
}
|
|
// 创建产品列&类型列
|
productOPC := macroPlan.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 2 );
|
typeOPC := macroPlan.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 1 );
|
traverse ( macroPlan, OfflinePlanRow, opr ) {
|
if ( opr.Type() = "0" ) {
|
productLineCell := productOPC.OfflinePlanCell( relnew, Value := opr.ProductionLine() );
|
productLineCell.OfflinePlanRow( relset, opr );
|
} else if( opr.Type() = "1" ) {
|
productCell := productOPC.OfflinePlanCell( relnew, Value := opr.ProductID() );
|
productCell.OfflinePlanRow( relset, opr );
|
typeCell := typeOPC.OfflinePlanCell( relnew, Value := "Quantity" );
|
typeCell.OfflinePlanRow( relset, opr );
|
} else if ( opr.Type() = "2" ) {
|
typeCell := typeOPC.OfflinePlanCell( relnew, Value := "Order" );
|
typeCell.OfflinePlanRow( relset, opr );
|
} else if ( opr.Type() = "3" ) {
|
totalCell := productOPC.OfflinePlanCell( relnew, Value := "合计" );
|
totalCell.OfflinePlanRow( relset, opr );
|
totalCell := typeOPC.OfflinePlanCell( relnew, Value := "总量" );
|
totalCell.OfflinePlanRow( relset, opr );
|
} else if ( opr.Type() = "4" ) {
|
shiftCell := typeOPC.OfflinePlanCell( relnew, Value := "班次" );
|
shiftCell.OfflinePlanRow( relset, opr );
|
}
|
}
|
|
// 补全总量和班次
|
totalOPRs := selectset( macroPlan, OfflinePlanRow, tempOPR, tempOPR.Type() = "3" );
|
shiftOPRs := selectset( macroPlan, OfflinePlanRow, tempOPR, tempOPR.Type() = "4" );
|
traverse ( macroPlan, OfflinePlanColumn, opc, opc.OfflinePlanCell( relsize ) > 0 and opc.ColumnDate() >= macroPlan.StartOfPlanning().Date() ) {
|
traverse ( totalOPRs, Elements, totalOPR ) {
|
total := sum( opc, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanRow().ProductionLine() = totalOPR.ProductionLine() and tempOPC.OfflinePlanRow().Type() = "1", [Real]tempOPC.Value() );
|
totalCell := opc.OfflinePlanCell( relnew, Value := [String]total );
|
totalCell.OfflinePlanRow( relset, totalOPR );
|
}
|
|
traverse ( shiftOPRs, Elements, shiftOPR ) {
|
shift := select( opc, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanRow().ProductionLine() = shiftOPR.ProductionLine() and tempOPC.OfflinePlanRow().Type() = "1" );
|
if ( not isnull( shift ) ) {
|
shiftCell := opc.OfflinePlanCell( relnew, Value := shift.Shift() );
|
shiftCell.OfflinePlanRow( relset, shiftOPR );
|
}
|
}
|
}
|
|
// 补全时间列
|
indexDate := macroPlan.StartOfPlanning().Date();
|
endDate := Date::Construct( indexDate.Year(), 12, 31 );
|
while ( indexDate <= endDate ) {
|
opc := OfflinePlanColumn::FindOfflinePlanColumnTypeIndex( indexDate );
|
if ( isnull( opc ) ) {
|
opc := macroPlan.OfflinePlanColumn( relnew, ColumnDate := indexDate );
|
}
|
indexDate := indexDate + 1;
|
}
|
*]
|
}
|