renhao
2023-10-13 f3dec8f5b480474c9a3b2ea0fabb0f6b9fdc0423
_Main/BL/Type_MacroPlan/Method_MappingOperationData.qbl
@@ -1,21 +1,24 @@
Quintiq file version 2.0
#parent: #root
Method MappingOperationData (
  Strings businessTypes
  Strings businessTypes,
  GlobalOTDTable globalOTDTable,
  Strings organcodelist
)
{
  TextBody:
  [*
    // yypsybs Aug-18-2023 (created)
    // 获取有序的待处理记录
    toDealList := construct( MappingOperations );
    toDealList := construct( Global_MappingOperations ) ;
    if( not isnull( businessTypes ) and businessTypes.Size() > 0 ) {
        toDealList := selectsortedset( this, MappingOperation, item,
    //                                   businessTypes.Find( item.BusinessType() ) >= 0,
                                       businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0,
        toDealList := selectsortedset( globalOTDTable, Global_MappingOperation, item,
                                       ( businessTypes.Find( item.BusinessType() ) >= 0 ) and
                                       ( organcodelist.Find( item.OrganCode() ) >= 0 ),
    //                                   businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0,
                                       item.SequenceNumber() );
    } else {
        toDealList := selectsortedset( this, MappingOperation, item,
        toDealList := selectsortedset( globalOTDTable, Global_MappingOperation, item,
                                       true, 
                                       item.SequenceNumber() );
    }
@@ -26,7 +29,7 @@
        routingId := item.OrganCode() + "_" + item.ProductID();
        unitId := item.OrganCode() + "_" + item.PlantName() + "_" + item.ProcessSection();
        routingStepName := item.ProcessSection() + "_" + [String]item.SequenceNumber();
        operationId := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection();
        operationId := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection()+"_" + [String]item.SequenceNumber();
    //    info( "========" )
    //    info( "routingId:" + routingId );
    //    info( "unitId:" + unitId );
@@ -51,15 +54,16 @@
        if( isnull( routingStep ) ) {
            routingStep := RoutingStep::Create( routing, routingStepName, "", true );
        }
        // UnitOfMeasure
        unitOfMeasure := UnitOfMeasure_MP::FindByName( this, item.UnitOfMeasureName() );
        if( isnull( unitOfMeasure ) ) {
            error( "unit of measure [" + item.UnitOfMeasureName() + "] not found for routing [" + routingId + "]" );
        }
        // Unit
        unit := Unit::FindById( this, unitId );
        if( isnull( unit ) ) {
            unit := this.Unit( relnew,
          // UnitOfMeasure
        unitOfMeasure := UnitOfMeasure_MP::FindByName( this, item.UnitOfMeasureName() );
          if( isnull( unitOfMeasure ) ) {
              info( "unit of measure [" + item.UnitOfMeasureName() + "] not found for routing [" + routingId + "]" );
          }
           unit := this.Unit( relnew,
                              ID := unitId, Name := unitId, CapacityType := "Infinite",
                              DefaultGridX := 0, DefaultGridY := 0,
                              IsManuallyConfigured := false,
@@ -70,12 +74,12 @@
        op := Operation::FindOperationTypeIndex( operationId );
        if( isnull( op)){
          op := Operation::Create( operationId, unit, operationId, routingStep, 
                                        Duration::Hours( item.UserLeadTime() ), Duration::Zero(), item.ActualCapacity(), false,
                                        Duration::Days( item.UserLeadTime() ), Duration::Zero(), item.ActualCapacity(), false,
                                        [Real]item.MinimumQuantity(), haveMaxQty, guard( [Real]item.MaximumQuantity(), Real::MaxReal() ), 
                                        0.0, 0.0, false, true );
        }
        
        ManufactureLTProcessSection::CreateOrUpdate( op );
    //    ManufactureLTProcessSection::CreateOrUpdate( op );
    }
    info( "========" )
    // 遍历routing,进行link