Quintiq file version 2.0
|
#parent: #root
|
Method MappingOperationData (
|
Strings businessTypes
|
)
|
{
|
TextBody:
|
[*
|
// 获取有序的待处理记录
|
toDealList := construct( MappingOperations );
|
if( not isnull( businessTypes ) and businessTypes.Size() > 0 ) {
|
toDealList := selectsortedset( this, MappingOperation, item,
|
businessTypes.Find( item.BusinessType() ) >= 0,
|
item.SequenceNumber() );
|
} else {
|
toDealList := selectsortedset( this, MappingOperation, item,
|
true,
|
item.SequenceNumber() );
|
}
|
// 删除原有routing
|
this.IORouting( relflush );
|
// 新routing
|
routingIdList := selectuniquevalues( toDealList, Elements, item, item.OrganCode() + "_" + item.ProductID() );
|
traverse( routingIdList, Elements, routingId ) {
|
this.IORouting( relnew,
|
ID := routingId, Name := routingId, IsEnabled := true );
|
}
|
// 删除原有routingStep
|
this.IORoutingStep( relflush );
|
// 新routingStep
|
traverse( toDealList, Elements, op ) {
|
routingId := op.OrganCode() + "_" + op.ProductID();
|
routingStepName := op.ProcessSection() + "_" + [String]op.SequenceNumber();
|
IORoutingStep::CreateIfNotExist( this,
|
routingId,
|
routingStepName,
|
op.SequenceNumber() );
|
}
|
// 新operation
|
traverse( toDealList, Elements, op ) {
|
// 汇总数据
|
routingId := op.OrganCode() + "_" + op.ProductID();
|
routingStepName := op.ProcessSection() + "_" + [String]op.SequenceNumber();
|
opId := op.OrganCode() + "_" + op.ProductID() + "_" + op.ProcessSection();
|
unitId := op.OrganCode() + "_" + op.PlantName() + "_" + op.ProcessSection();
|
if( op.Line() <> "" ) {
|
opId := opId + "_" + op.Line();
|
unitId := unitId + "_" + op.Line();
|
}
|
opName := opId;
|
// 新建
|
ioOp := IOOperation::CreateIfNotExist( this, opId );
|
ioOp.UnitID( unitId );
|
ioOp.RoutingID( routingId );
|
ioOp.RoutingStepName( routingStepName );
|
ioOp.Name( opName );
|
ioOp.UserLeadTime( Duration::Hours( op.UserLeadTime() ) );
|
ioOp.Throughput( op.ActualCapacity() );
|
ioOp.UserMinimumQuantity( op.MinimumQuantity() );
|
ioOp.UserMaximumQuantity( op.MaximumQuantity() );
|
ioOp.HasUserMaximumQuantity( op.MaximumQuantity() <> 0.0 );
|
}
|
// 按 OrganCode + ProductID 分组 + 排序
|
keyList := selectuniquevalues( toDealList, Elements, op,
|
op.OrganCode() + "_" + op.ProductID() );
|
keyList := selectsortedset( keyList, Elements, str, str );
|
traverse( keyList, Elements, key ) {
|
previousList := construct( MappingOperations );
|
// 按 SequenceNumber 分组 + 排序
|
subKeyList := selectuniquevalues( toDealList, Elements, op,
|
key = op.OrganCode() + "_" + op.ProductID(),
|
op.SequenceNumber() );
|
subKeyList := selectsortedset( subKeyList, Elements, seq, seq );
|
// 遍历每个Seq,与前一个list进行连接,同时创建group
|
traverse( subKeyList, Elements, seq ) {
|
elementList := selectset( this, MappingOperation, op,
|
op.OrganCode() + "_" + op.ProductID() = key and op.SequenceNumber() = seq );
|
if( not isnull( previousList ) and previousList.Size() > 0 ) {
|
// 对每个目标创建inputGroup
|
if( previousList.Size() > 1 ) {
|
traverse( elementList, Elements, targetOp ) {
|
targetOpId := targetOp.OrganCode() + "_" + targetOp.ProductID() + "_" + targetOp.ProcessSection();
|
this.IOOperationInputGroup( relnew, InputGroupID := 1, OperationID := targetOpId, InputGroupQuantity := 1 );
|
}
|
}
|
// 源与目标两两创建operationLink
|
traverse( elementList, Elements, targetOp ) {
|
traverse( previousList, Elements, sourceOp ) {
|
sourceOpId := sourceOp.OrganCode() + "_" + sourceOp.ProductID() + "_" + sourceOp.ProcessSection();
|
targetOpId := targetOp.OrganCode() + "_" + targetOp.ProductID() + "_" + targetOp.ProcessSection();
|
this.IOOperationLink( relnew,
|
SourceOperationID := sourceOpId, DestOperationID := targetOpId,
|
SourceGroupID := 1, DestGroupID := 1, SourceQuantity := 1, DestQuantity := 1 / previousList.Size(),
|
DestHasUserQuantity := false, DestMinQuantity := 0, DestMaxQuantity := 1 );
|
}
|
}
|
}
|
previousList := elementList;
|
}
|
}
|
*]
|
}
|