| | |
| | | this.oldList = (List < Contact > ) Trigger.old; |
| | | } |
| | | protected override void beforeInsert() { |
| | | mobileNumberVerification(); |
| | | sendToComPlat(); |
| | | 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() { |
| | |
| | | UpdateProcessingWork(); |
| | | // 服务技师 2018/12/24 end |
| | | mobileNumberVerification(); |
| | | sendToComPlat(); |
| | | } |
| | | |
| | | |
| | |
| | | // ) |
| | | ) |
| | | ) { |
| | | 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 + ((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) { |
| | | upsert targetContactMap.values() ContactId18__c; |
| | | 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 |
| | | } |
| | | } |
| | | |
| | |
| | | // 手机号去重及规则验证 及新增客户人员重名验证 |
| | | 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}$'); |
| | | // 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>(); |
| | | //用户对象上找对应的联系人 |
| | |
| | | } |
| | | } |
| | | //手机号唯一校验-医院下新建客户人员校验使用加密手机号,经销商使用普通手机号 thh 20220328 start |
| | | ID recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); |
| | | 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)))) { |
| | | if(contactnew.RecordTypeId.equals(recordTypeId)){ |
| | | // 经销商客户人员不进行手机号校验 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 { |
| | | // Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone); |
| | | // if (isMobilePhone.matches()) { |
| | | contactnew.UniqueNumber__c = contactnew.MobilePhone; |
| | | // } else { |
| | | // 手机号唯一字段清空 |
| | | contactnew.UniqueNumber__c = null; |
| | | } |
| | | // contactnew.UniqueNumber__c = null; |
| | | // } |
| | | } else { |
| | | contactnew.UniqueNumber__c = null; |
| | | } |
| | | } else{ |
| | | // 经销商客户人员不进行手机号校验 thh 20220517 end |
| | | } else if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){ |
| | | if(String.isNotBlank(contactnew.MobilePhone_Encrypted__c)){ |
| | | contactnew.UniqueNumber__c = contactnew.MobilePhone_Encrypted__c; |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | if (Trigger.isInsert) { |
| | | accountIdSet.add(contactnew.AccountId); |
| | | } |
| | | // if (Trigger.isInsert) { |
| | | accountIdSet.add(contactnew.AccountId); |
| | | // } |
| | | } |
| | | //手机号唯一校验-医院下新建客户人员校验使用加密手机号,经销商使用普通手机号 thh 20220328 end |
| | | // 新增联系人时, |
| | | if (accountIdSet.size() > 0) { |
| | | List<Contact> 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]; |
| | | WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet AND Id Not IN: oldMap.keyset()]; |
| | | if ( contactList.size() > 0) { |
| | | for(Contact contact :contactList){ |
| | | |
| | | String lastNameStr = String.isNotBlank(contact.LastName) ? contact.LastName:''; |
| | | String firstNameStr = String.isNotBlank(contact.FirstName) ? contact.FirstName:''; |
| | | String contactFullName = lastNameStr + firstNameStr; |
| | | contactFullName = contact.LastName_Encrypted__c;// 20220314 PI改造 by Bright |
| | | // 通过姓名+手机号判断人员是否重复 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; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | for (Contact contactnew: newList) { |
| | | |
| | | if (Trigger.isInsert) { |
| | | |
| | | String accountId = String.valueOf(contactnew.AccountId).substring(0, 15); |
| | | |
| | | if (accountContactMap.containsKey(accountId)) { |
| | | Map<String,Contact> contactFullNameMap = accountContactMap.get(accountId); |
| | | String lastNameStr = String.isNotBlank(contactnew.LastName) ? contactnew.LastName:''; |
| | | String firstNameStr = String.isNotBlank(contactnew.FirstName) ? contactnew.FirstName:''; |
| | | String contactFullName = lastNameStr + firstNameStr; |
| | | contactFullName = contactnew.LastName_Encrypted__c;// 20220314 PI改造 by Bright |
| | | 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)) { |
| | | for (Contact contactnew: newList) { |
| | | 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>(); |
| | |
| | | || old.ContactType__c != local.ContactType__c//人员类型 |
| | | |
| | | ) { |
| | | //624调用606问题修复 thh 20220328 start |
| | | if (!local.IsFromSPO__c && !'01210000000QtkyAAC'.equals(local.RecordTypeId)) { |
| | | //获取客户人员的记录类型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 ('01210000000QfWdAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) { |
| | | if (DoctorRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) { |
| | | if (!NFM606_IdMap.containsKey(local.Id)) { |
| | | // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){ |
| | | // interfaceUserUpsertContact.add(local.Id); |
| | | // } else { |
| | | // contactIdList.add(local.Id); |
| | | // } |
| | | local.trigger606Flag__c = true; |
| | | 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 ('01210000000QfWiAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.MobilePhone)) { |
| | | if (AgencyRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.MobilePhone)) { |
| | | if (!NFM606_IdMap.containsKey(local.Id)) { |
| | | // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){ |
| | | // interfaceUserUpsertContact.add(local.Id); |
| | | // } else { |
| | | // contactIdList.add(local.Id); |
| | | // } |
| | | local.trigger606Flag__c = true; |
| | | if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){ |
| | | interfaceUserUpsertContact.add(local.Id); |
| | | } else { |
| | | contactIdList.add(local.Id); |
| | | } |
| | | NFM606_IdMap.put(local.Id, local.Id); |
| | | } |
| | | } |
| | | } |
| | | //624调用606问题修复 thh 20220328 end |
| | | |
| | | } |
| | | } |
| | | //606标记 |
| | | // if(!System.Test.isRunningTest()){ |
| | | // // NFM606Controller.executeNotFuture('', contactIdList); |
| | | // //624调用606问题修复 thh 20220325 start |
| | | // 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); |
| | | 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); |
| | | // NFM606Controller.executeNotFuture('', interfaceUserUpsertContact); |
| | | // } |
| | | //添加future 判断 add for pipl sushanhu 20220316 end |
| | | |
| | | // } |
| | | //624调用606问题修复 thh 20220325 end |
| | | // } |
| | | |
| | | } |
| | | } |
| | | } |
| | | // 606接口调用问题修复 thh 20220330 end |
| | | |
| | | } |