yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
@@ -7,94 +7,94 @@
  Description: 'Get unit data from operation mapping'
  TextBody:
  [*
    // Administrator Aug-21-2023 (created)
    // list to deal
    listtodeal := construct( structured[MappingOperation] );
    if( isnull( businesstypes ) or businesstypes.Size() = 0 ) {
        listtodeal := selectset( this, MappingOperation, item, true );
    } else {
        listtodeal := selectset( this, MappingOperation, item,
                                 businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0
                                  );
    }
    //Set the Default values
    unitofmeasurename := "PCS";
    capacitytype := "Infinite";
    // Get the root data
    Unit::CreateOrUpdate( this,
                          "天马集团",
                          "天马集团",
                          "",
                          capacitytype,
                          unitofmeasurename );
    // Get the sub root data
    Unit::CreateOrUpdate( this,
                          "生产",
                          "生产",
                          "天马集团",
                          capacitytype,
                          unitofmeasurename );
    Unit::CreateOrUpdate( this,
                          "供应商",
                          "供应商",
                          "天马集团",
                          capacitytype,
                          unitofmeasurename );
    Unit::CreateOrUpdate( this,
                          "整车运输",
                          "整车运输",
                          "天马集团",
                          capacitytype,
                          unitofmeasurename );
    // Get the unit list
    traverse( listtodeal, Elements, item){
      OrgName := item.OrganName();
      if( OrgName = ''){
        OrgName := item.OrganCode();
      }
      //Get the first level unit
      Unit::CreateOrUpdate( this,
                            item.OrganCode(),
                            OrgName,
                            "生产",
                            capacitytype,
                            unitofmeasurename );
      //Get the second level unit
      secondlevelid := item.OrganCode() + "_" + item.PlantName();
      Unit::CreateOrUpdate( this,
                            secondlevelid,
                            secondlevelid,
                            item.OrganCode(),
                            capacitytype,
                            unitofmeasurename );
      //Get the third level unit
      thirdlevelid := secondlevelid + "_" + item.ProcessSection();
      Unit::CreateOrUpdate( this,
                            thirdlevelid,
                            thirdlevelid,
                            secondlevelid,
                            "Time",
                            item.UnitOfMeasureName() );
      //Get the last level unit
      if( item.Line()<>"" ){
        lastlevelid := thirdlevelid + "_" + item.Line();
        Unit::CreateOrUpdate( this,
                              lastlevelid,
                              lastlevelid,
                              thirdlevelid,
                              "Time",
                              item.UnitOfMeasureName() );
      }
      }
    //// Administrator Aug-21-2023 (created)
    //// list to deal
    //listtodeal := construct( structured[MappingOperation] );
    //
    //if( isnull( businesstypes ) or businesstypes.Size() = 0 ) {
    //    listtodeal := selectset( this, MappingOperation, item, true );
    //} else {
    //    listtodeal := selectset( this, MappingOperation, item,
    //                             businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0
    //                              );
    //}
    //
    ////Set the Default values
    //unitofmeasurename := "PCS";
    //capacitytype := "Infinite";
    //
    //// Get the root data
    //Unit::CreateOrUpdate( this,
    //                      "天马集团",
    //                      "天马集团",
    //                      "",
    //                      capacitytype,
    //                      unitofmeasurename );
    //
    //// Get the sub root data
    //Unit::CreateOrUpdate( this,
    //                      "生产",
    //                      "生产",
    //                      "天马集团",
    //                      capacitytype,
    //                      unitofmeasurename );
    //
    //Unit::CreateOrUpdate( this,
    //                      "供应商",
    //                      "供应商",
    //                      "天马集团",
    //                      capacitytype,
    //                      unitofmeasurename );
    //
    //Unit::CreateOrUpdate( this,
    //                      "整车运输",
    //                      "整车运输",
    //                      "天马集团",
    //                      capacitytype,
    //                      unitofmeasurename );
    //
    //// Get the unit list
    //traverse( listtodeal, Elements, item){
    //  OrgName := item.OrganName();
    //  if( OrgName = ''){
    //    OrgName := item.OrganCode();
    //  }
    //  //Get the first level unit
    //  Unit::CreateOrUpdate( this,
    //                        item.OrganCode(),
    //                        OrgName,
    //                        "生产",
    //                        capacitytype,
    //                        unitofmeasurename );
    //
    //  //Get the second level unit
    //  secondlevelid := item.OrganCode() + "_" + item.PlantName();
    //  Unit::CreateOrUpdate( this,
    //                        secondlevelid,
    //                        secondlevelid,
    //                        item.OrganCode(),
    //                        capacitytype,
    //                        unitofmeasurename );
    //
    //  //Get the third level unit
    //  thirdlevelid := secondlevelid + "_" + item.ProcessSection();
    //  Unit::CreateOrUpdate( this,
    //                        thirdlevelid,
    //                        thirdlevelid,
    //                        secondlevelid,
    //                        "Time",
    //                        item.UnitOfMeasureName() );
    //
    //  //Get the last level unit
    //  if( item.Line()<>"" ){
    //    lastlevelid := thirdlevelid + "_" + item.Line();
    //    Unit::CreateOrUpdate( this,
    //                          lastlevelid,
    //                          lastlevelid,
    //                          thirdlevelid,
    //                          "Time",
    //                          item.UnitOfMeasureName() );
    //  }
    //  }
  *]
}