张宇恒
2022-12-23 b4b8a2df1f478030bb321b6ac558f13fbbffbb07
force-app/main/default/triggers/Repair.trigger
@@ -26,6 +26,9 @@
                RepairTrigger.UpdateAssert(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
            // }
        }
        if( Trigger.isBefore && Trigger.isUpdate){
        }
        // ----------------------------------------------------------------------
        // ここより、修理のサービスコントラクト項目を自動的に更新するロジック
        // ----------------------------------------------------------------------
@@ -152,8 +155,12 @@
                                //如果最大大修次数大于0,并且已经大修次数 大于或等于 最大大修次数,那么不仅不赋值维修合同信息,而且清空当前信息
                                if (middleTable.Series_MaxRepairCount_F__c > 0 && middleTable.Series_RepairCount_F__c >= middleTable.Series_MaxRepairCount_F__c) {
                                    //不赋值维修合同信息,而且清空当前信息
                                    repair.Maintenance_Contract__c = null;
                                    repair.MaintenanceContractType__c = null;
                                    //URF限次合同2期 LY 20220926 start
                                    // repair.Maintenance_Contract__c = null;
                                    // repair.MaintenanceContractType__c = null;
                                    repair.Maintenance_Contract__c = middleTable.Maintenance_Contract__c;
                                    repair.MaintenanceContractType__c = middleTable.Maintenance_Contract__r.RecordType.Name;
                                    //URF限次合同2期 LY 20220926 end
                                }
                            }
                            //限次合同产品信息维护相关 FXK 2021/03/05 END
@@ -329,6 +336,12 @@
        // これより、备品借出申请の「修理最终检测日」を更新するロジック(更新后触发WorkFlow)
        // ----------------------------------------------------------------------
        if (Trigger.isAfter && Trigger.isUpdate) {
            System.debug( '-----: sendEmailByInspectionFailureCause start');
            //【委托】【QA部门】IISE多次同步课题 WLIG-CJJDAV  start
            RepairTrigger.sendEmailByInspectionFailureCause(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
            //【委托】【QA部门】IISE多次同步课题 WLIG-CJJDAV  end
            Map<String, Date> repairDateMap = new Map<String, Date>();
            List<String> targetRepairList = new List<String>();
            for (Repair__c repair : Trigger.New) {
@@ -355,7 +368,44 @@
        // ----------------------------------------------------------------------
        // ここまで、备品借出申请の「修理最终检测日」を更新するロジック
        // ----------------------------------------------------------------------
        // 2022-12-22   zyh   add   Start
        if (Trigger.isAfter && Trigger.isUpdate) {
            List < String > rprIds = new List < String > ();
            Map < Id, Id > rprIdMap = new Map < Id, Id > ();
            for (Repair__c rpr: Trigger.new) {
                Repair__c oldrpr = Trigger.oldMap.get(rpr.Id);
                // 修理有报修子单号,并且 待发送AWS为false 发送给AWS
                if (String.isNotBlank(rpr.RepairSubOrder__c) && !rpr.AwaitToSendAWS__c) {
                    if ((rpr.DescriptionName__c != oldrpr.DescriptionName__c)
                        || (rpr.InspectionResultFlag__c != oldrpr.InspectionResultFlag__c)
                        || (rpr.RepairReasonTrigger__c != oldrpr.RepairReasonTrigger__c)) {
                        if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                            NFM603Controller.NFM603_Ids.add(rpr.Id);
                            rprIdMap.put(rpr.Id, rpr.Id);
                            System.debug('111111111111111111112222222222');
                        }
                    }
                }
            }
            rprIds = rprIdMap.values();
            if (rprIds.size() > 0) {
                BatchIF_Log__c iflog = new BatchIF_Log__c();
                iflog.Type__c = 'NFM603';
                iflog.Log__c = 'callout start\n';
                insert iflog;
                // 2022-04-29     zyh      update     start
                if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){
                    NFM603Controller.executefuture(iflog, rprIds);
                }else{
                    NFM603Controller.callout(iflog.Id, rprIds);
                }
                // 2022-04-29     zyh      update     end
            }
        }
        // 2022-12-22   zyh   add   END
        System.debug( '-----: trigger end');
    }
    public void test(){