buli
2023-07-10 4f200849487fc6f914e237d5af3ecefd6d802457
force-app/main/default/triggers/ConsumableOrderDetail2Trigger.trigger
@@ -333,11 +333,14 @@
      update consumableOrderlist;
    }
  }
  //Back up by DTT - Li Jun 2023-06-14 Start for reduce soql times
  // 2018年8月9日 HWAG-B3D9UV  获取所有的record ID start by 张玉山
  //List<RecordType> allrtList = [select Id,DeveloperName from RecordType where SobjectType = 'Consumable_orderdetails__c'];
  List<RecordType> allrtList = [
    SELECT Id, DeveloperName
    FROM RecordType
    WHERE SobjectType = 'Consumable_orderdetails__c'
  ];
  // 2018年8月9日 HWAG-B3D9UV  获取所有的record ID end by 张玉山
  //Back up by DTT - Li Jun 2023-06-14 Start
  //到货和返品时,生成或修改消费品订货明细
  Set<String> arrivedSet = new Set<String>();
  Set<String> returnSet = new Set<String>();
@@ -434,27 +437,22 @@
          ar.get('Asset_Model_No__c');
        keyCount.put(key, Integer.valueOf(ar.get('recordCount')));
      }
      //Back up by DTT - Li Jun 2023-06-14 Start
      // 2018年8月9日 HWAG-B3D9UV  替代下面SQL select start by 张玉山
      // List<RecordType> rtList = new List<RecordType>();
      // for(RecordType rtl : allrtList){
      //     if('Detail1_Arrival'.equals(rtl.DeveloperName)){
      //         rtList.add(rtl);
      //     }
      // }
      List<RecordType> rtList = new List<RecordType>();
      for (RecordType rtl : allrtList) {
        if ('Detail1_Arrival'.equals(rtl.DeveloperName)) {
          rtList.add(rtl);
        }
      }
      // 2018年8月9日 HWAG-B3D9UV  替代下面SQL select end by 张玉山
      //Back up by DTT - Li Jun 2023-06-14 End
      /* 2018年8月9日 HWAG-B3D9UV  原获取 recordtype start by 张玉山
            List<RecordType> rtList = [select Id from RecordType where DeveloperName = 'Detail1_Arrival' and SobjectType = 'Consumable_orderdetails__c'];
             2018年8月9日 HWAG-B3D9UV  原获取 recordtype end by 张玉山 */
      //Back up by DTT - Li Jun 2023-06-14 Start
      // Id recordTypeId = null;
      // if (rtList.size() > 0) recordTypeId = rtList[0].Id;
      //Back up by DTT - Li Jun 2023-06-14 End
      Id recordtypeId = Schema.SObjectType.Consumable_Orderdetails__c.getRecordTypeInfosByDeveloperName()
        .get('Detail1_Arrival')
        .getRecordTypeId();
      Id recordTypeId = null;
      if (rtList.size() > 0)
        recordTypeId = rtList[0].Id;
      results = [
        SELECT Consumable_order__c, count(Id) noCount
        FROM Consumable_orderdetails__c
@@ -697,24 +695,23 @@
          ar.get('Asset_Model_No__c');
        keyCount.put(key, Integer.valueOf(ar.get('recordCount')));
      }
      //Back up by DTT - Li Jun 2023-06-14 Start for reduce soql times
      // 2018年8月9日 HWAG-B3D9UV  替代下面SQL select start by 张玉山
      // List<RecordType> rtList = new List<RecordType>();
      // for(RecordType rtl : allrtList){
      //     if('Detail1_ReturnGoods'.equals(rtl.DeveloperName)){
      //         rtList.add(rtl);
      //     }
      // }
      List<RecordType> rtList = new List<RecordType>();
      for (RecordType rtl : allrtList) {
        if ('Detail1_ReturnGoods'.equals(rtl.DeveloperName)) {
          rtList.add(rtl);
        }
      }
      // 2018年8月9日 HWAG-B3D9UV  替代下面SQL select end by 张玉山
      //Back up by DTT - Li Jun 2023-06-14 End
      /* 2018年8月9日 HWAG-B3D9UV  原获取 recordtype start by 张玉山
            List<RecordType> rtList = [select Id from RecordType where DeveloperName = 'Detail1_ReturnGoods' and SobjectType = 'Consumable_orderdetails__c'];
             2018年8月9日 HWAG-B3D9UV  原获取 recordtype end by 张玉山 */
      Id recordTypeId = Schema.SObjectType.Consumable_Orderdetails__c.getRecordTypeInfosByDeveloperName()
        .get('Detail1_ReturnGoods')
        .getRecordTypeId();
      //if (rtList.size() > 0) recordTypeId = rtList[0].Id;
      Id recordTypeId = null;
      if (rtList.size() > 0)
        recordTypeId = rtList[0].Id;
      results = [
        SELECT Consumable_order__c, count(Id) noCount