| | |
| | | string namekey; |
| | | string nameKey2; |
| | | string nameKey3; |
| | | string nameKey4; |
| | | if(String.isBlank(ct.MobilePhone_Encrypted__c)){ |
| | | namekey = ct.Account.Name + ' ' + ct.LastName_Encrypted__c.trim(); |
| | | nameKey2 = ct.Account.Management_Code__c + ' ' + ct.LastName_Encrypted__c.trim(); |
| | | nameKey3 = ct.Account.Department_Class__r.Name + ' ' + ct.LastName_Encrypted__c.trim(); |
| | | nameKey4 = ct.LastName_Encrypted__c.trim(); |
| | | } else{ |
| | | namekey = ct.Account.Name + ' ' + ct.LastName_Encrypted__c.trim() + ' ' + ct.MobilePhone_Encrypted__c.trim(); |
| | | nameKey2 = ct.Account.Management_Code__c + ' ' + ct.LastName_Encrypted__c.trim() + ' ' + ct.MobilePhone_Encrypted__c.trim(); |
| | | nameKey3 = ct.Account.Department_Class__r.Name + ' ' + ct.LastName_Encrypted__c.trim() + ' ' + ct.MobilePhone_Encrypted__c.trim(); |
| | | nameKey4 = ct.LastName_Encrypted__c.trim() + ' ' + ct.MobilePhone_Encrypted__c.trim(); |
| | | } |
| | | // snameMap.put(namekey,ct); |
| | | if (nameMap.containsKey(ct.Account.parent.Name)) { |
| | |
| | | snameMap.put(namekey, ct); |
| | | snameMap.put(nameKey2,ct); |
| | | snameMap.put(nameKey3,ct); |
| | | snameMap.put(nameKey4,ct); |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | // if(String.isBlank(ct.MobilePhone_Encrypted__c)){ |
| | | // snameMap.put(ct.LastName_Encrypted__c.trim(), ct); |
| | |
| | | System.debug('人员管理编码不存在'); |
| | | string namekey = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted + ' ' + gedata.MobileEncrypted; |
| | | string namekey1 = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted; |
| | | string namekey2 = gedata.NameEncrypted + ' ' + gedata.MobileEncrypted; |
| | | string namekey3 = gedata.NameEncrypted; |
| | | system.debug('DepartmentClasskey = '+DepartmentClasskey); |
| | | system.debug('nameMap22222222 '+nameMap); |
| | | if (nameMap.containskey(DepartmentClasskey)) { // 6 完成 更新操作 |
| | |
| | | System.debug('sMap'+sMap); |
| | | System.debug('sMap.containsKey(namekey)'+sMap.containsKey(namekey)); |
| | | System.debug('sMap.containsKey(gedata.NameEncrypted)'+sMap.containsKey(gedata.NameEncrypted)); |
| | | if (sMap.containsKey(namekey)) { |
| | | if (sMap.containsKey(namekey) && sMap.get(namekey).UnifiedI_Contact_ID__c == null) { |
| | | system.debug('Id赋值'+sMap); |
| | | ct.id = sMap.get(namekey).id; |
| | | } else if (sMap.containsKey(namekey1) && sMap.get(namekey1).UnifiedI_Contact_ID__c == null) { |
| | | ct.id = sMap.get(namekey1).id; |
| | | |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | // } else if(sMap.containsKey(gedata.NameEncrypted + gedata.MobileEncrypted) && sMap.get(gedata.NameEncrypted + gedata.MobileEncrypted).UnifiedI_Contact_ID__c == null){ |
| | | // ct.id = sMap.get(gedata.NameEncrypted + gedata.MobileEncrypted).id; |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | } else if(sMap.containsKey(namekey2) && sMap.get(namekey2).UnifiedI_Contact_ID__c == null){ |
| | | system.debug('战略科室存在科室为空电话有值'); |
| | | ct.id = sMap.get(namekey2).id; |
| | | }else if(sMap.containsKey(namekey3) && sMap.get(namekey3).MobilePhone_Encrypted__c == null){ |
| | | system.debug('战略科室存在科室为空电话无值'); |
| | | ct.id = sMap.get(namekey3).id; |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | }else { // 7 完成 |
| | | system.debug('7逻辑 无人员管理编码 有医院 有科室 人名查找无 动作:新建联系人 '); |
| | | for ( Integer i = 0; i < peopleList.size(); i++) { |
| | | if (peopleList[i].Account.parent.Name !=DepartmentClasskey && (peopleList[i].MobilePhone_Encrypted__c ==null || peopleList[i].MobilePhone_Encrypted__c ==gedata.MobileEncrypted)) { |
| | | ct.id = peopleList[i].id; |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | //战略科室不存在,找手机号为空或相等的客户人员 |
| | | for ( Integer i = 0; i < peopleList.size(); i++) { |
| | | if (peopleList[i].MobilePhone_Encrypted__c ==null || peopleList[i].MobilePhone_Encrypted__c ==gedata.MobileEncrypted) { |
| | | ct.id = peopleList[i].ID; |
| | | } |
| | | } |
| | | } |
| | | upsertContactList.add(ct); |
| | |
| | | system.debug('nameMap.get(DepartmentClasskey)'+nameMap.get(DepartmentClasskey)); |
| | | if (nameMap.containsKey(DepartmentClasskey)) { //查找是否存在该战略科室 |
| | | System.debug('人员管理编码不存在的情况下战略科室存在'); |
| | | system.debug('战略科室存在' + nameMap.get(DepartmentClasskey)); |
| | | System.debug('战略科室存在' + nameMap.get(DepartmentClasskey)); |
| | | Map < String, Contact > sMap = nameMap.get(DepartmentClasskey); |
| | | system.debug('namekey'+namekey); |
| | | system.debug('sMap.keySet'+sMap.keySet()); |
| | |
| | | }else{ |
| | | system.debug('创建联系人和科室'); |
| | | //system.debug('peopleList[0]'+peopleList[0]); |
| | | if (peopleList.size()>0) { |
| | | ct.id = peopleList[0].ID; |
| | | for ( Integer i = 0; i < peopleList.size(); i++) { |
| | | if (peopleList[i].MobilePhone_Encrypted__c ==null) { |
| | | ct.id = peopleList[i].ID; |
| | | } |
| | | } |
| | | |
| | | // dpt.Department_Name__c = gedata.DepartmentName; |
| | | // upsertAccountList.add(dpt); |
| | | contactMap.put(Gedata.DepartmentManagementCode2, ct); |
| | | system.debug('122222222222222222222contactMap'+contactMap); |
| | | upsertContactList.add(ct); |
| | | system.debug('122222222222222222222upsertContactList'+upsertContactList); |
| | | |
| | | } |
| | | dpt.Department_Name__c = gedata.DepartmentName; |
| | |
| | | c.Accountid = ac.id; |
| | | } |
| | | c.OwnerId = ac.OwnerId; |
| | | upsertContactList1.add(c); |
| | | system.debug('联系人信息'+c); |
| | | system.debug('upsertContactList'+upsertContactList); |
| | | //upsertContactList.add(c); |
| | | system.debug('OwnerId'+ac.OwnerId); |
| | | system.debug('upsertContactList1'+upsertContactList1); |
| | | system.debug('upsertContactList'+upsertContactList); |
| | | } |
| | | |
| | | if(ac.RecordTypeId == '01210000000QemGAAS' && ac.Is_Active__c == '草案中' && string.isNotBlank( OCSMMap.get(ac.OCM_man_province_HP__c))){ |
| | |
| | | // Database.executeBatch(new NFM620RestBatch(), 1); |
| | | // Database.executeBatch(new NFM623RestBatch(), 1); |
| | | supplement(gedata.ContactId); |
| | | } |
| | | if(upsertContactList1.size()>0){ |
| | | upsert upsertContactList1; |
| | | |
| | | } |
| | | } |
| | | } |