| | |
| | | |
| | | // Map<String,String> RecordTypeMap = new Map<String,String>(); |
| | | // RecordTypeMap.put('','') |
| | | //List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_OTH','Department_GI', 'Department_BF','Department_GYN','Department_GS','Department_URO','Department_ENT','Department_Class_ET') order by DeveloperName desc]; |
| | | Map < string, string > RecordTypeMap = new Map < string, string > (); //存放记录类型Id |
| | | //for(ID temp : rectDpt){ |
| | | // |
| | | //} |
| | | RecordTypeMap.put('呼吸科', '01210000000QfmR'); |
| | | RecordTypeMap.put('其他', '01210000000Qfmb'); |
| | | RecordTypeMap.put('妇科', '01210000000QfmM'); |
| | |
| | | List < String > ManagementList = new List < String > (); //医院、科室平台编码List |
| | | List < String > StateList = new List < String > (); |
| | | List < String > CityList = new List < String > (); |
| | | List < String > NameList = new List < String >(); |
| | | try { //根据传过来的管理编码查询如果可以查询得到结果则更新,查询不到则新增 |
| | | List < Gedata > newGeDataList = new List < Gedata > (); |
| | | for (Gedata gedata: GeDataList) { |
| | | //for test |
| | | gedata.AgentFlag=false; |
| | | // string dataComplete = verify(gedata); |
| | | string dataComplete =null; |
| | | // test end for pi |
| | | string dataComplete = verify(gedata); |
| | | |
| | | if (!String.isBlank(dataComplete)) { |
| | | logstr += dataComplete; |
| | | rowData.Is_Error__c = 1; |
| | | rowData.retry_cnt__c = 0; |
| | | continue; |
| | | } |
| | | if (!gedata.AgentFlag) { |
| | |
| | | } |
| | | if (string.isnotblank(gedata.PersonManagementCode)) { |
| | | PersonManagementCodeList.add(gedata.PersonManagementCode); |
| | | } |
| | | if(String.isnotBlank(gedata.NameEncrypted)){ |
| | | NameList.add(gedata.NameEncrypted); |
| | | } |
| | | newGeDataList.add(gedata); |
| | | System.debug('ManagementList'+ManagementList); |
| | |
| | | //查询联系人 |
| | | Map < String, Map < String, Contact >> nameMap = new Map < String, Map < String, Contact >> (); //外层战略科室,内层科室名+联系人名 |
| | | List < Contact > peopleList = [select Id, |
| | | Account.Name, |
| | | Account.Name, |
| | | Department__c, |
| | | Account.parent.Name, |
| | | Account.PlatformCode__c, |
| | | Account.Management_Code__c, |
| | | Account.parent.Department_Class_Label__c, |
| | | Name, |
| | | Name,LastName_Encrypted__c, |
| | | Account.Parent_Management_Code__c, |
| | | Account.Parent_PlatformCode__c, |
| | | CManageCode__c, |
| | | AccountId |
| | | from Contact |
| | | where CManageCode__c IN: PersonManagementCodeList |
| | | OR Account.Parent_PlatformCode__c IN: ManagementList |
| | | OR Account.Parent_Management_Code__c IN: SFDCCodeList]; //根据人员管理编码检索联系人 |
| | | OR (Account.Parent_PlatformCode__c IN: ManagementList AND LastName_Encrypted__c IN:NameList) |
| | | OR (Account.Parent_Management_Code__c IN: SFDCCodeList AND LastName_Encrypted__c IN:NameList ) |
| | | ORDER BY MobilePhone ASC,CManageCode__c ASC]; //根据人员管理编码检索联系人 |
| | | Map < String, Contact > peopleMap = new Map < String, Contact > (); //联系人 |
| | | system.debug('peopleList '+peopleList); |
| | | for (Contact ct: peopleList) { |
| | | if (string.isnotblank(ct.Account.parent.Name)) { |
| | | Map < String, Contact > snameMap = new Map < String, Contact > (); |
| | | string Name = ct.Name.replaceAll(' ',''); |
| | | string namekey = ct.Account.Name + ' ' + Name; |
| | | string namekey = ct.Account.Name + ' ' + ct.LastName_Encrypted__c.trim(); |
| | | string nameKey2 = ct.Account.Management_Code__c + ' ' + ct.LastName_Encrypted__c.trim(); |
| | | // snameMap.put(namekey,ct); |
| | | if (nameMap.containsKey(ct.Account.parent.Name)) { |
| | | snameMap = nameMap.get(ct.Account.parent.Name); |
| | | } |
| | | snameMap.put(namekey, ct); |
| | | snameMap.put(ct.Name, ct); |
| | | snameMap.put(nameKey2,ct); |
| | | snameMap.put(ct.LastName_Encrypted__c.trim(), ct); |
| | | nameMap.put(ct.Account.parent.Name, snameMap); |
| | | system.debug('snameMap'+snameMap); |
| | | } |
| | | peopleMap.put(ct.CManageCode__c, ct); |
| | | System.debug('peopleMap'+peopleMap); |
| | |
| | | logstr += gedata.DepartmentName; |
| | | |
| | | |
| | | string comefrom = gedata.RegSource == '1' ? '智慧医疗' : '服务客户端'; //平台来源 |
| | | string comefrom = gedata.RegSource == '1' ? '智慧医疗' : (gedata.RegSource == '2' ? '服务客户端' :'医拓网'); //平台来源 |
| | | |
| | | //新建医院 |
| | | Account hp = new Account(); |
| | | |
| | | //新建联系人 |
| | | Contact ct = new Contact(); |
| | | ct.LastName = gedata.Name; |
| | | ct.FirstName = ''; |
| | | ct.Type__c = gedata.Type; |
| | | ct.Type_Encrypted__c = gedata.TypeEncrypted;//add for pipl sushanhu 20220316 |
| | | ct.MobilePhone = gedata.Mobile; |
| | | ct.RegSource__c = comefrom; |
| | | ct.UnifiedI_Contact_ID__c = gedata.ContactId; //统一平台Id |
| | | // //UPDATE TO AWS 存储的统一平台id |
| | | // ct.AWS_UnifiedI_Contact_ID__c=gedata.ContactId; //统一平台Id |
| | | ct.ServicePlatformCode__c = gedata.ServiceUserId; //服务平台用户Id |
| | | ct.Contact_address__c = gedata.ContactAddress;//联系地址 |
| | | ct.Contact_address_Encrypted__c=gedata.ContactAddressEncrypted;//联系地址密文 add 20220215 |
| | | ct.Platform_disabled_representation__c = gedata.ForbiddenStatus;//平台禁用标识 |
| | | //ct.IsFromPlatform__c = true; //来自智慧医疗创建 |
| | | ct.Ignore_Same_Name__c = true; //不是重复的客户名 |
| | | //ct.SendToComPlat__c = true; |
| | | ct.AWS_Data_Id__c =gedata.DataId;//add 20220215 aws存储凭证 |
| | | ct.MobilePhone_Encrypted__c =gedata.MobileEncrypted;//add 20220215 手机密文 |
| | | ct.LastName_Encrypted__c =gedata.NameEncrypted;//add 20220215 姓名密文 |
| | | if(gedata.AgentFlag){ |
| | | //ct.FirstName = ''; 2022-4-7 yjk 注释掉 |
| | | ct.UnifiedI_Contact_ID__c = gedata.ContactId; //统一平台Id |
| | | ct.ServicePlatformCode__c = gedata.ServiceUserId; //服务平台用户Id |
| | | //ct.CManageCode__c = gedata.PersonManagementCode;//人员管理编码 |
| | | }else{ |
| | | ct.LastName = gedata.Name; |
| | | ct.FirstName = ''; |
| | | ct.Type__c = gedata.Type; |
| | | ct.Type_Encrypted__c = gedata.TypeEncrypted;//add for pipl sushanhu 20220316 |
| | | ct.MobilePhone = gedata.Mobile; |
| | | ct.RegSource__c = comefrom; |
| | | ct.UnifiedI_Contact_ID__c = gedata.ContactId; //统一平台Id |
| | | // //UPDATE TO AWS 存储的统一平台id |
| | | // ct.AWS_UnifiedI_Contact_ID__c=gedata.ContactId; //统一平台Id |
| | | ct.ServicePlatformCode__c = gedata.ServiceUserId; //服务平台用户Id |
| | | ct.Contact_address__c = gedata.ContactAddress;//联系地址 |
| | | ct.Contact_address_Encrypted__c=gedata.ContactAddressEncrypted;//联系地址密文 add 20220215 |
| | | ct.Platform_disabled_representation__c = gedata.ForbiddenStatus;//平台禁用标识 |
| | | //ct.IsFromPlatform__c = true; //来自智慧医疗创建 |
| | | ct.Ignore_Same_Name__c = true; //不是重复的客户名 |
| | | //ct.SendToComPlat__c = true; |
| | | ct.AWS_Data_Id__c =gedata.DataId;//add 20220215 aws存储凭证 |
| | | ct.MobilePhone_Encrypted__c =gedata.MobileEncrypted;//add 20220215 手机密文 |
| | | ct.LastName_Encrypted__c =gedata.NameEncrypted;//add 20220215 姓名密文 |
| | | } |
| | | |
| | | |
| | | String personCode = gedata.PersonManagementCode; |
| | | |
| | |
| | | if (gedata.AgentFlag == true) { |
| | | //更新经销商联系人 |
| | | if (!peopleMap.containsKey(personCode)) { |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | |
| | | if ('有效'.equals(hospital.Is_Active_Formula__c)) { |
| | | string DepartmentCode = string.isNotBlank(gedata.RelatedDepartment) ? gedata.RelatedDepartment : gedata.DepartmentManagementCode2; |
| | | string DepartmentClasskey = gedata.AccountName + ' ' + gedata.DepartmentClass; |
| | | system.debug('DepartmentClasskey------->'+DepartmentClasskey); |
| | | //科室存在 |
| | | if (AccountMap.containsKey(DepartmentCode)) { |
| | | //人员管理编码存在 |
| | |
| | | upsertContactList.add(ct); |
| | | } else { //联系人不存在 2 完成 |
| | | system.debug('2逻辑 有医院 有科室 有人员管理编码但查找无此人 动作:报错'); |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | | } else { //人员管理编码不存在 |
| | | //搜索人名/且在当前战略科室科室下 |
| | | System.debug('人员管理编码不存在'); |
| | | string namekey = gedata.Name; |
| | | string namekey = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted; |
| | | system.debug('DepartmentClasskey = '+DepartmentClasskey); |
| | | system.debug('nameMap22222222 '+nameMap); |
| | | if (nameMap.containskey(DepartmentClasskey)) { // 6 完成 更新操作 |
| | | Map < String, Contact > sMap = nameMap.get(DepartmentClasskey); |
| | | System.debug('sMap'+sMap); |
| | | System.debug('sMap.containsKey(namekey)'+sMap.containsKey(namekey)); |
| | | if (sMap.containsKey(namekey)) { |
| | | system.debug('Id赋值'+sMap); |
| | | ct.id = sMap.get(namekey).id; |
| | | } else { // 7 完成 |
| | | } else if(sMap.containsKey(gedata.NameEncrypted)){ |
| | | ct.id = sMap.get(gedata.NameEncrypted).id; |
| | | }else { // 7 完成 |
| | | system.debug('7逻辑 无人员管理编码 有医院 有科室 人名查找无 动作:新建联系人 '); |
| | | } |
| | | } |
| | |
| | | //upsertContactList.add(ct); |
| | | } else { //人员管理编码查找无值 4 完成 |
| | | system.debug('4逻辑'); |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | | } else { //人员管理编码不存在 |
| | | system.debug('人员管理编码不存在'); |
| | | string namekey = gedata.DepartmentName+ ' ' + gedata.Name; |
| | | string namekey = gedata.DepartmentName+ ' ' + gedata.NameEncrypted; |
| | | //string namekey = gedata.AccountName + ' ' + gedata.DepartmentName + ' ' + gedata.DepartmentClass + ' ' + gedata.Name; |
| | | system.debug('DepartmentClasskey'+DepartmentClasskey); |
| | | system.debug('351nameMap '+nameMap); |
| | |
| | | System.debug('人员管理编码不存在的情况下战略科室存在'); |
| | | system.debug('战略科室存在' + nameMap.get(DepartmentClasskey)); |
| | | Map < String, Contact > sMap = nameMap.get(DepartmentClasskey); |
| | | system.debug('namekey'+namekey); |
| | | system.debug('sMap.containsKey(namekey)'+sMap.containsKey(namekey)); |
| | | if (sMap.containsKey(namekey)) { //查找存在 8 完成 |
| | | system.debug('8逻辑'); |
| | | system.debug('该联系人存在'); |
| | | ct.id = sMap.get(namekey).id; |
| | | upsertAccountList.add(dpt); |
| | | //upsertAccountList.add(dpt);//可以注释 |
| | | upsertContactList.add(ct); |
| | | // if(sMap.containsKey(gedata.Name)){ |
| | | // ct.Id = sMap.get(gedata.Name).Id; |
| | | // } |
| | | }else if(sMap.containsKey(gedata.Name)){ |
| | | }else if(sMap.containsKey(gedata.NameEncrypted)){ |
| | | system.debug('1234567890'); |
| | | ct.Id = sMap.get(gedata.Name).Id; |
| | | ct.Id = sMap.get(gedata.NameEncrypted).Id; |
| | | //upsertAccountList.add(dpt); |
| | | } |
| | | system.debug('contactMap ' + contactMap); |
| | | System.debug('9逻辑'); |
| | | contactMap.put(Gedata.DepartmentManagementCode2, ct); |
| | | system.debug('contactMap ' + contactMap); |
| | | //upsertContactList.add(ct); |
| | | } |
| | | system.debug('创建联系人和科室'); |
| | | dpt.Department_Name__c = gedata.DepartmentName; |
| | |
| | | } |
| | | } |
| | | }else if('无效'.equals(hospital.Is_Active_Formula__c)){ |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:该医院无效,此条数据跳过'; |
| | | continue; |
| | | }else{ |
| | |
| | | StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; |
| | | system.debug('upsertAccountList ' + upsertAccountList); |
| | | upsert upsertAccountList; |
| | | system.debug('SFDCCodeList'+SFDCCodeList); |
| | | system.debug('SFDCCodeList'+ManagementList); |
| | | List < Account > List1 = [select Id,RecordTypeId,Is_Active__c,PlatformCode__c,OCM_man_province_HP__c,OwnerId from Account where PlatformCode__c In: SFDCCodeList OR PlatformCode__c IN: ManagementList];//客户所有人修改11.18 11.35 未完成 |
| | | system.debug('List1'+List1); |
| | | List<Account> updateHPList = new List<Account>(); |
| | | for (Account ac: List1) { |
| | | Contact c = new contact(); |
| | | system.debug('ac.PlatformCode__c'+ac.PlatformCode__c); |
| | | system.debug('ContactMap'+ContactMap); |
| | | system.debug('ContactMap.containsKey(ac.PlatformCode__c)'+ContactMap.containsKey(ac.PlatformCode__c)); |
| | | if(ContactMap.containsKey(ac.PlatformCode__c)){ |
| | | c = contactMap.get(ac.PlatformCode__c); |
| | | if(string.isblank(c.Id)|| c.AccountId != ac.Id){ |
| | |
| | | |
| | | private static String verify(GeData gda) { |
| | | String result = ''; |
| | | if (string.isblank(gda.ContactId)) { |
| | | result += 'DataError: ContactId 统一平台ID为空\n'; |
| | | } |
| | | if (gda.AgentFlag == null) { |
| | | result += 'DataError:经销商标识为空\n'; |
| | | } |
| | | if (string.isblank(gda.Name)) { |
| | | result += 'DataError:姓名为空\n'; |
| | | } |
| | | if (string.isblank(gda.NameEncrypted)) { |
| | | result += 'DataError:姓名密文为空\n'; |
| | | } |
| | | if (string.isblank(gda.Mobile)) { |
| | | result += 'DataError:手机号为空\n'; |
| | | } |
| | | if (string.isblank(gda.MobileEncrypted)) { |
| | | result += 'DataError:手机号密文为空\n'; |
| | | } |
| | | if (string.isblank(gda.RegSource)) { |
| | | result += 'DataError:注册平台来源为空\n'; |
| | | }if (string.isblank(gda.DataId)) { |
| | | result += 'DataError:AWS加密凭据为空\n'; |
| | | } |
| | | if (gda.AgentFlag) { |
| | | if (string.isblank(gda.ContactId)) { |
| | | result += 'DataError: ContactId 统一平台ID为空\n'; |
| | | } |
| | | if (string.isblank(gda.PersonManagementCode)) { |
| | | result += 'DataError:PersonManagementCode 人员管理编码为空\n'; |
| | | } |
| | | } else { |
| | | // if (string.isnotblank(gda.PersonManagementCode) && string.isBlank(gda.RelatedHospital)) { |
| | | // result += 'DataError: 关联医院编码为空\n'; |
| | | // } |
| | | if(string.isBlank(gda.RelatedDepartment) && String.isBlank(gda.ApproverID)){ |
| | | result += 'DataError: 在关联SFDC科室[RelatedDepartment]为空时,审核人员员工编码[ApproverID]必填\n'; |
| | | if (string.isblank(gda.ServiceUserId)) { |
| | | result += 'ServiceUserId 服务平台用户Id为空\n'; |
| | | } |
| | | }else{ |
| | | if (string.isblank(gda.ContactId)) { |
| | | result += 'DataError: ContactId 统一平台ID为空\n'; |
| | | } |
| | | if (gda.AgentFlag == null) { |
| | | result += 'DataError:经销商标识为空\n'; |
| | | } |
| | | if (string.isblank(gda.Name)) { |
| | | result += 'DataError:姓名为空\n'; |
| | | } |
| | | if (string.isblank(gda.Mobile)) { |
| | | result += 'DataError:手机号为空\n'; |
| | | } |
| | | if (string.isblank(gda.RegSource)) { |
| | | result += 'DataError:注册平台来源为空\n'; |
| | | } |
| | | if(string.isBlank(gda.RelatedHospital) && String.isBlank(gda.HospitalManagementCode2) && String.isBlank(gda.ApproverID)){ |
| | | result += 'DataError: 新建医院时,审核人员员工编码[ApproverID]必填\n'; |
| | | } |
| | | if (string.isblank(gda.HospitalManagementCode2)) { |
| | | result += 'DataError:医院平台编码为空\n'; |
| | |
| | | } |
| | | //补充学会部分 end |
| | | } |
| | | } |