涂煌豪
2022-05-27 301bc0fb85cb5cd417830e26b2de139456d90839
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
/**
 * Select Id From Contact Where RecordTypeId = '01210000000QfWdAAK' and Strategic_dept_Class__c != null
 */
public without sharing class ContactTriggerHandler extends Oly_TriggerHandler {
    private Map < Id, Contact > newMap;
    private Map < Id, Contact > oldMap;
    private List < Contact > newList;
    private List < Contact > oldList;
    public ContactTriggerHandler() {
        this.newMap = (Map < Id, Contact > ) Trigger.newMap;
        this.oldMap = (Map < Id, Contact > ) Trigger.oldMap;
        this.newList = (List < Contact > ) Trigger.new;
        this.oldList = (List < Contact > ) Trigger.old;
    }
    protected override void beforeInsert() {
        if(Test.isRunningTest()||UserInfo.getUserId()!=System.Label.ByPassTrigger){ //Add by Li Jun for PIPL 20220331
            mobileNumberVerification();
        }
    }
 
    protected override void afterInsert() {
        syncToAgencyContact();
        updateDealerNum();
        sendToComPlat();
    }
 
    protected override void afterUpdate() {
        syncToAgencyContact();
        updateDealerNum();
        sendToComPlat();
    }
 
    protected override void beforeUpdate() {
        // 服务技师 2018/12/24  Start
        UpdateProcessingWork();
        // 服务技师 2018/12/24  end
        mobileNumberVerification();
    }
 
 
    protected override void afterDelete() {
        syncToAgencyContactDelete();
        updateDealerNum();
    }
 
    //
    /**
     * @author 张玉山
     * @DateTime 2019-03-11T13:49:10+0800
     * 根据服务技师填写情况更新客户人员上的开展工作字段
     */
    private void UpdateProcessingWork() {
        for (Contact temContact: newList) {
            if (System.label.UpdateServiceHistory.equals('true')) {
 
                string ProcessingWork = '';
                string ProcessingWorkWithoutNumber = '';
                if (temContact.ServiceBookInput__c != 0) {
                    ProcessingWork += '维修委托书填写' + temContact.ServiceBookInput__c + '次';
                    ProcessingWorkWithoutNumber += '维修委托书填写';
 
                }
                if (temContact.InspectTime__c != 0) {
                    if (String.isBlank(ProcessingWork)) {
                        ProcessingWork += '点检' + temContact.InspectTime__c + '次';
                        ProcessingWorkWithoutNumber += '点检';
                    } else {
                        ProcessingWork += ',点检' + temContact.InspectTime__c + '次';
                        ProcessingWorkWithoutNumber += ',点检';
 
                    }
                }
                if (temContact.InspectEquipmentTime__c != 0) {
                    if (String.isBlank(ProcessingWork)) {
                        ProcessingWork += '点检设备' + temContact.InspectEquipmentTime__c + '个';
                        ProcessingWorkWithoutNumber += '点检设备';
                    } else {
                        ProcessingWork += ',点检设备' + temContact.InspectEquipmentTime__c + '个';
                        ProcessingWorkWithoutNumber += ',点检设备';
                    }
 
                }
                if (temContact.VisitTime__c != 0) {
                    if (String.isBlank(ProcessingWork)) {
                        ProcessingWork += '上门' + temContact.VisitTime__c + '次';
                        ProcessingWorkWithoutNumber += '上门';
                    } else {
                        ProcessingWork += ',上门' + temContact.VisitTime__c + '次';
                        ProcessingWorkWithoutNumber += ',上门';
                    }
 
                }
                if (temContact.pollingTime__c != 0) {
                    if (String.isBlank(ProcessingWork)) {
                        ProcessingWork += '巡检' + temContact.pollingTime__c + '次';
                        ProcessingWorkWithoutNumber += '巡检';
                    } else {
                        ProcessingWork += ',巡检' + temContact.pollingTime__c + '次';
                        ProcessingWorkWithoutNumber += ',巡检';
                    }
 
                }
                if (temContact.TeachingTime__c != 0) {
                    if (String.isBlank(ProcessingWork)) {
                        ProcessingWork += '培训次数' + temContact.TeachingTime__c + '次';
                        ProcessingWorkWithoutNumber += '培训次数';
                    } else {
                        ProcessingWork += ',培训次数' + temContact.TeachingTime__c + '次';
                        ProcessingWorkWithoutNumber += ',培训次数';
                    }
                }
                //if (!String.isBlank(ProcessingWork)) {
                //    ProcessingWork += '。';
                //    ProcessingWorkWithoutNumber += '。';
                //}
                temContact.ProcessingWork__c = ProcessingWork;
                temContact.ProcessingWorkWithoutNumber__c = ProcessingWorkWithoutNumber;
 
 
            }
        }
 
    }
    // 服务技师 2018/12/24  end
    private void syncToAgencyContact() {
        Map < Id, Agency_Contact__c > targetContactMap = new Map < Id, Agency_Contact__c > ();
        for (Contact nObj: newList) {
            if (nObj.RecordTypeId == '01210000000QfWdAAK' // Doctor
                &&
                String.isBlank(nObj.Strategic_dept_Class__c) == false
            ) {
                if (Trigger.isInsert ||
                    (Trigger.isUpdate
                        //                        && (
                        //                            oldMap.get(nObj.Id).LastName                != nObj.LastName
                        //                         || oldMap.get(nObj.Id).FirstName               != nObj.FirstName
                        //                         || oldMap.get(nObj.Id).Strategic_dept_Class__c != nObj.Strategic_dept_Class__c
                        //                         || oldMap.get(nObj.Id).Type__c                 != nObj.Type__c
                        //                         || oldMap.get(nObj.Id).Doctor_Division1__c     != nObj.Doctor_Division1__c
                        //                        )
                    )
                ) {
                    //Agency_Contact__c acObj = new Agency_Contact__c(Agency_ID__c = '000000000000000', Contact__c = nObj.Id, ContactId18__c = nObj.Id, Agency_Hospital__c = null, Name = nObj.LastName + ((String.isBlank(nObj.FirstName) == false) ? ' ' + nObj.FirstName : ''), Department_Class__c = nObj.Strategic_dept_Class__c, Type__c = nObj.Type__c, Doctor_Division1__c = nObj.Doctor_Division1__c);
                    Agency_Contact__c acObj = new Agency_Contact__c(
                        Agency_ID__c = '000000000000000', 
                        Contact__c = nObj.Id, 
                        ContactId18__c = nObj.Id, 
                        Agency_Hospital__c = null, 
                        Name = nObj.LastName,
                        Name_Encrypted__c = nObj.LastName_Encrypted__c,
                        Department_Class__c = nObj.Strategic_dept_Class__c, 
                        Type__c = nObj.Type__c,
                        Type_Encrypted__c = nObj.Type_Encrypted__c,
                        Doctor_Division1__c = nObj.Doctor_Division1__c,
                        Doctor_Division1_Encrypted__c = nObj.Doctor_Division1_Encrypted__c
                    );
                    targetContactMap.put(nObj.Id, acObj);
                }
            }
        }
        if (targetContactMap.size() > 0) {
            List<Agency_Contact__c> temp = targetContactMap.values();
            upsert temp ContactId18__c;
            system.debug('temp='+temp);
            EncryptInsert(temp);
        }
    }
    
    static void EncryptInsert(List<Agency_Contact__c> aclist){
        if(!(system.isFuture() || system.isBatch())){
            AwsServiceTool2.EncryptPushFuture(Json.serialize(aclist), 'Agency_Contact__c');
        }else{
            //Add By Li Jun for sync agency contact to aws 20220424 start
            if(!Test.isRunningTest()){
                SyncAccountContactToAWS.assignOnceOneMinuteLater(aclist);
            }
            //Add By Li Jun for sync agency contact to aws 20220424 end
        }
    }
 
    private void syncToAgencyContactDelete() {
        List < Id > cIdList = new List < Id > ();
        for (Contact oObj: oldList) {
            cIdList.add(oObj.Id);
        }
        if (cIdList.size() > 0) {
            List < Agency_Contact__c > acList = [Select Id From Agency_Contact__c
                Where Contact__c =: null and Agency_ID__c = '000000000000000'
            ];
            if (acList.size() > 0) {
                delete acList;
            }
        }
    }
 
    //更新经销商用户人数字段 精琢技术 pk 2021-08-26 start
    private void updateDealerNum() {
        Set < Id > accountSet = new Set < Id > ();
        Map < Id, Account > acMap = new Map < Id, Account > ();
        if (Trigger.isUpdate) {
            for (Contact contactnew: newList) {
                if (contactnew.Agency_User__c != oldMap.get(contactnew.Id).Agency_User__c || (System.Label.onlyUpdate == '1' && UserInfo.getUserId() == '00510000005sEEMAA2')) {
                    accountSet.add(contactnew.AccountId);
                }
            }
        }
 
        if (Trigger.isInsert) {
            for (Contact contactnew: newList) {
                if (contactnew.Agency_User__c) {
                    accountSet.add(contactnew.AccountId);
                }
            }
        }
 
 
        if (Trigger.isDelete) {
            for (Contact contactold: oldList) {
                if (contactold.Agency_User__c) {
                    accountSet.add(contactold.AccountId);
                }
            }
        }
 
        if (accountSet.size() > 0) {
            List < AggregateResult > contactList = [select count(id) ctn, AccountId accid from Contact where Agency_User__c = true and AccountId =: accountSet and RecordTypeId = '01210000000QfWi'
                group by AccountId
            ];
            for (AggregateResult ar: contactList) {
                String accid = (String) ar.get('accid');
                Account account = new Account();
                account.id = accid;
                account.Dealer_Num__c = (Integer) ar.get('ctn');
                acMap.put(accid, account);
            }
 
            for (Id accountId: accountSet) {
                if (!acMap.containsKey(accountId)) {
                    Account account = new Account();
                    account.id = accountId;
                    account.Dealer_Num__c = 0;
                    acMap.put(accountId, account);
                }
            }
 
            if (acMap.size() > 0) {
                update acMap.values();
            }
        }
 
 
    }
    //更新经销商用户人数字段 精琢技术 pk 2021-08-26 end
    
    // 手机号去重及规则验证 及新增客户人员重名验证
    public void mobileNumberVerification(){
 
        // Pattern pattern = Pattern.compile('^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$');
        Map<String, Map<String,Contact>> accountContactMap = new Map<String, Map<String,Contact>>();
        Set<Id> accountIdSet = new Set<Id>();
        //用户对象上找对应的联系人
        // List<User> userList=[select ID,ContactID from User where ContactID != null];
        // Map<String,User> userMap= new Map<String,User>();
        // if (userList.size()>0){
        //     for(User us1: userList){
        //         userMap.put(us1.ContactId, us1);
        //     }
        // }
        //查找联系人对象上对应的有效客户;医院直接使用有效/无效字段、经销商使用有效/无效公式字段
        List<String> accIdList = new List<String>();
        Map<String,String> accMap= new Map<String,String>();
        for (Contact contact1: newList) {
            accIdList.add(contact1.AccountId);
        }
        if (accIdList.size()>0){
            List<Account> accList=[select ID,Is_Active__c,Is_Active_Formula__c from Account where ID in:accIdList];
            if(accList.size()>0){
                for(Account acc:accList){
                    if (String.isNotBlank(acc.Is_Active__c)){
                        accMap.put(acc.Id, acc.Is_Active__c);
                        continue;
                    }
                    if (String.isNotBlank(acc.Is_Active_Formula__c)){
                        accMap.put(acc.Id, acc.Is_Active_Formula__c);
                    }
                }
            }
        }
        //手机号唯一校验-医院下新建客户人员校验使用加密手机号,经销商使用普通手机号 thh 20220328 start
        ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId();
        ID AgencyRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        for (Contact contactnew : newList) {
            // 手机号有值并且联系人有效,联系人的客户有效,进行手机号码验证
            if (('有效'.equals(contactnew.Isactive__c) || '有効'.equals(contactnew.Isactive__c))
                && ('有効'.equals(accMap.get(contactnew.AccountId)) || '有效'.equals(accMap.get(contactnew.AccountId)))) {
                // 经销商客户人员不进行手机号校验 thh 20220517 start
                if(AgencyRecordTypeId.equals(contactnew.RecordTypeId)){
                    if(String.isNotBlank(contactnew.MobilePhone)){
                        // Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone);
                        // if (isMobilePhone.matches()) {
                        contactnew.UniqueNumber__c = contactnew.MobilePhone;
                        // } else {
                            // 手机号唯一字段清空
                            // contactnew.UniqueNumber__c = null;
                        // }
                    } else {
                        contactnew.UniqueNumber__c = null;
                    }
                // 经销商客户人员不进行手机号校验 thh 20220517 end
                } else if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){
                    if(String.isNotBlank(contactnew.MobilePhone_Encrypted__c)){
                        contactnew.UniqueNumber__c = contactnew.MobilePhone_Encrypted__c;
                    } else {
                        contactnew.UniqueNumber__c = null;
                    }
                }
            }
            // if (Trigger.isInsert) {
            if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){
                accountIdSet.add(contactnew.AccountId);  
            }
            // }   
        }
        //手机号唯一校验-医院下新建客户人员校验使用加密手机号,经销商使用普通手机号 thh 20220328 end
        // 新增医院联系人时
        if (accountIdSet.size() > 0) {
            List<Contact> contactList = new List<Contact>();
            if(Trigger.isInsert){
                contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c,
                                                LastName_Encrypted__c// 20220314 PI改造 by Bright
                                                , MobilePhone_Encrypted__c // 通过姓名+手机号判断人员是否重复 thh 20220518
                                                FROM Contact 
                                                WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet];
            }
            if(Trigger.isUpdate){
                contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c,
                                             LastName_Encrypted__c// 20220314 PI改造 by Bright
                                             , MobilePhone_Encrypted__c // 通过姓名+手机号判断人员是否重复 thh 20220518
                                            FROM Contact 
                                            WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet AND Id Not IN: oldMap.keyset()];
            }
            System.debug('contactList:' + contactList);
            if (contactList.size() > 0) {
                for(Contact contact :contactList){
                    // 通过姓名+手机号判断人员是否重复 thh 20220518 start
                    // String lastNameStr = String.isNotBlank(contact.LastName) ? contact.LastName:'';
                    // String firstNameStr = String.isNotBlank(contact.FirstName) ? contact.FirstName:'';
                    // String contactFullName = lastNameStr + firstNameStr + MobilePhoneStr; 
                    String contactFullName = contact.LastName_Encrypted__c + contact.MobilePhone_Encrypted__c;// 20220314 PI改造 by Bright
                    // 通过姓名+手机号判断人员是否重复 thh 20220518 end
                    if(string.isBlank(contactFullName)){
                        continue;
                    }      
                    String accountId = String.valueOf(contact.AccountId).SubString(0,15);
                    Map<String,Contact> contactFullNameMap = new  Map<String,Contact>();
                    if (accountContactMap.containsKey(accountId)) {
                        contactFullNameMap = accountContactMap.get(accountId);
                    }
                    contactFullNameMap.put(contactFullName, contact);
                    accountContactMap.put(accountId, contactFullNameMap);
                }
            }
        }
 
        for (Contact contactnew: newList) {
            if(AgencyRecordTypeId.equals(contactnew.RecordTypeId) || (Trigger.isUpdate && !oldMap.isEmpty() && oldMap.get(contactnew.Id) != null 
                && String.isBlank(oldMap.get(contactnew.Id).MobilePhone_Encrypted__c) 
                && String.isBlank(contactnew.MobilePhone_Encrypted__c))){
                continue;
            }
            String accountId = String.valueOf(contactnew.AccountId).substring(0, 15);
            if (accountContactMap.containsKey(accountId)) {
                Map<String,Contact> contactFullNameMap =  accountContactMap.get(accountId);
                // 通过姓名+手机号判断人员是否重复 thh 20220518 start
                // String lastNameStr = String.isNotBlank(contactnew.LastName) ? contactnew.LastName:'';
                // String firstNameStr = String.isNotBlank(contactnew.FirstName) ? contactnew.FirstName:'';
                // String contactFullName = lastNameStr + firstNameStr + MobilePhoneStr;
                String contactFullName = contactnew.LastName_Encrypted__c + contactnew.MobilePhone_Encrypted__c;// 20220314 PI改造 by Bright
                // 通过姓名+手机号判断人员是否重复 thh 20220518 end
                if (contactFullNameMap.containsKey(contactFullName)) {
                    String accountName = contactFullNameMap.get(contactFullName).Account.Name;
                    String cManageCode = contactFullNameMap.get(contactFullName).CManageCode__c;
                    // 跳过测试程序 和 SPO通过203接口创建的联系人
                    if (!(Test.isRunningTest() || contactnew.IsFromSPO__c)) {
                        // if(Trigger.isInsert) {
                            contactnew.LastName.addError('客户 [ '+accountName+ ' ],已存在相同名字的联系人 人员管理编码 ['+cManageCode+' ] ,不能重复创建,请了解');     
                        // } 
                        // 客户人员删除手机号时,进行判断是否存在同名且手机号为空的客户人员 thh 20220523 start
                        // if(Trigger.isUpdate && !UserInfo.getUserId().equals(System.Label.interfaceUserID)) {
                        //     if (String.isNotBlank(oldMap.get(contactnew.Id).MobilePhone_Encrypted__c) && String.isBlank(contactnew.MobilePhone_Encrypted__c)){
                        //         contactnew.LastName.addError('相同名字的联系人 人员管理编码 ['+cManageCode+' ] 手机号为空已经存在,不能重复创建,请了解');
                        //     } 
                        //     if (oldMap.get(contactnew.Id).CManageCode__c != contactnew.CManageCode__c){
                        //         contactnew.LastName.addError('客户 [ '+accountName+ ' ],已存在相同名字的联系人 人员管理编码 ['+cManageCode+' ] ,不能重复创建,请了解'); 
                        //     }
                        // }
                        // 客户人员删除手机号时,进行判断是否存在同名且手机号为空的客户人员 thh 20220523 end
                    } 
                }
            }
        }
    }
    public static Map<Id,Id> NFM606_IdMap = new Map<Id,Id>();
    // 606接口调用问题修复 thh 20220330 start
    private void sendToComPlat() {
        List<Id> contactIdList = new List<Id>();
        List<String> interfaceUserUpsertContact = new List<String>();
        for (Contact local: newList) {
            Contact old = null;
            if (Trigger.isUpdate) {
                old = oldMap.get(local.Id);
            }
            if (Trigger.isInsert
                        || old.LastName != local.LastName
                        || old.FirstName != local.FirstName
                        || old.Email != local.Email  //メール Email
                        || old.MobilePhone != local.MobilePhone  //手机号码 Mobile_Phone__c
                        || old.Employee_No_manual__c != local.Employee_No_manual__c  //员工号码 Employee_No__c
                        || old.Work_Location_manual__c != local.Work_Location_manual__c  //工作地 Work_Location__c
                        || old.Post_picklist__c != local.Post_picklist__c  //职位 post__c
                        || old.Job_Category_picklist__c != local.Job_Category_picklist__c  //职种 Job_Category__c
                        || old.Hire_date_text__c != local.Hire_date_text__c  //入职日 Hire_date__c
                        || old.Gender_text__c != local.Gender_text__c  //性别 Gender__c
                        || old.dept__c != local.dept__c  //本部 dept__c
                        || old.Pregnant_Rest__c != local.Pregnant_Rest__c // 是否产假 Pregnant_Rest__c
                        || old.Stay_or_not__c != local.Stay_or_not__c // 在职/离职 Stay_or_not__c
                        //|| old.Salesdepartment_Text__c != local.Salesdepartment_Text__c // 销售本部 Salesdepartment__c
                        || old.AccountId != local.AccountId//客户人员换客户
                        || old.Isactive__c != local.Isactive__c//状态变更
                        || old.ServicePlatformCode__c != local.ServicePlatformCode__c//服务平台编码
                        || old.UnifiedI_Contact_ID__c != local.UnifiedI_Contact_ID__c//智慧医疗编码
                        || old.ContactType__c != local.ContactType__c//人员类型
                        
                        ) {
                //获取客户人员的记录类型ID thh 20220330 start
                ID InternalStaffRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Internal_staff').getRecordTypeId();
                ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId();
                ID AgencyRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
                //获取客户人员的记录类型ID thh 20220330 end
                System.debug('local.UnifiedI_Contact_ID__c1:' + local.UnifiedI_Contact_ID__c);
                System.debug('local.MobilePhone1:' + local.MobilePhone);
                if (!local.IsFromSPO__c && !InternalStaffRecordTypeId.equals(local.RecordTypeId)) {
                    // 医院 客户人员 统一平台编码有值 发送 PO
                    if (DoctorRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) {
                        if (!NFM606_IdMap.containsKey(local.Id)) {
                            if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){
                                interfaceUserUpsertContact.add(local.Id);
                            } else {
                                contactIdList.add(local.Id);
                            }
                            NFM606_IdMap.put(local.Id, local.Id);
                        }
                    }
                    // 经销商 客户人员 手机号码有值 发送 PO
                    if (AgencyRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.MobilePhone)) {
                        if (!NFM606_IdMap.containsKey(local.Id)) {
                            if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){
                                interfaceUserUpsertContact.add(local.Id);
                            } else {
                                contactIdList.add(local.Id);
                            }
                            NFM606_IdMap.put(local.Id, local.Id);
                        }
                    }
                }
                
            }
        }
        //606标记
        if(!System.Test.isRunningTest()){
            // NFM606Controller.executeNotFuture('', contactIdList);
            if (contactIdList.size() > 0) {
                // NFM606Controller.callout('', contactIdList);
                 //添加future 判断 add for pipl  sushanhu 20220317 start
                // if (!(System.isFuture()||System.isBatch())) {
                NFM606Controller.callout('', contactIdList);
                // } else{
                    // NFM606Controller.executeNotFuture('', contactIdList);
                // }
               //添加future 判断 add for pipl  sushanhu 20220317 end 
            }
            if (interfaceUserUpsertContact.size() > 0) {
                NFM606Controller.executeNotFuture('', interfaceUserUpsertContact);
                //添加future 判断 add for pipl  sushanhu 20220316 start
                // if (!(System.isFuture()||System.isBatch())) {
                    // NFM606Controller.executeNotFuture('', interfaceUserUpsertContact);
                // }
               //添加future 判断 add for pipl  sushanhu 20220316 end 
            }
        } 
    }
    // 606接口调用问题修复 thh 20220330 end
 
}