| | |
| | | // ) |
| | | ) |
| | | ) { |
| | | 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>(); |
| | | //用户对象上找对应的联系人 |
| | |
| | | // 手机号有值并且联系人有效,联系人的客户有效,进行手机号码验证 |
| | | 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 { |
| | | // 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; |
| | | } |
| | | // 经销商客户人员不进行手机号校验 thh 20220517 end |
| | | } else if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){ |
| | | if(String.isNotBlank(contactnew.MobilePhone_Encrypted__c)){ |
| | | contactnew.UniqueNumber__c = contactnew.MobilePhone_Encrypted__c; |
| | |
| | | } |
| | | } |
| | | } |
| | | 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]; |
| | | 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); |
| | | for (Contact contactnew: newList) { |
| | | 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)) { |
| | | 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.isBlank(contactnew.MobilePhone_Encrypted__c)){ |
| | | contactnew.LastName.addError('相同名字的联系人 人员管理编码 ['+cManageCode+' ] 手机号为空已经存在,不能重复创建,请了解'); |
| | | } else{ |
| | | contactnew.LastName.addError('客户 [ '+accountName+ ' ],已存在相同名字的联系人 人员管理编码 ['+cManageCode+' ] ,不能重复创建,请了解'); |
| | | } |
| | | } |
| | | |
| | | } |
| | | // 客户人员删除手机号时,进行判断是否存在同名且手机号为空的客户人员 thh 20220523 end |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | public static Map<Id,Id> NFM606_IdMap = new Map<Id,Id>(); |
| | |
| | | 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)) { |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>34.0</apiVersion> |
| | | <apiVersion>50.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
| | |
| | | public static Contact contact1 = new Contact(); |
| | | public static Contact contact2 = new Contact(); |
| | | |
| | | @Testsetup |
| | | static void setup(){ |
| | | TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c'); |
| | | |
| | | } |
| | | @isTest static void test_method_one() { |
| | | List<RecordType> HPrectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | List<RecordType> GIrectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_Class_GI']; |
New file |
| | |
| | | /********************************************************************** |
| | | * |
| | | * |
| | | * @url: /services/apexrest/NFM624Rest |
| | | * @data: |
| | | * { |
| | | |
| | | } |
| | | *************************************************************************/ |
| | | |
| | | @RestResource(urlMapping = '/NFM624/*') |
| | | global with sharing class NFM624Rest { |
| | | //add to AWS 回复 start sushanhu 20220225 |
| | | static Boolean SFStatus=true; |
| | | static String SFMessage=''; |
| | | //add to AWS 回复 end sushanhu 20220225 |
| | | private static final String LOG_TYPE = 'NFM624'; |
| | | // global class GeDatasRest { |
| | | // public GeDatas GeDatas; |
| | | // } |
| | | |
| | | global class GeDatas { |
| | | public NFMUtil.Monitoring Monitoring; |
| | | public GeData[] GeData; |
| | | } |
| | | |
| | | global class GeData { |
| | | public String ContactId; //统一平台ID//Update to aws 存储的AWSContactId 20220225 SUSHANHU |
| | | public String ServiceUserId; //服务平台用户ID |
| | | public String PersonManagementCode; //人员管理编码 |
| | | public String HospitalManagementCode2; //医院平台编码 平台编码 PlatformCode__c |
| | | public String DepartmentManagementCode2; //科室平台编码 平台编码 PlatformCode__c |
| | | public String Name; //姓名 |
| | | public String NameEncrypted;//姓名密文 add 20220215 |
| | | public String Mobile; //手机号码 |
| | | public String MobileEncrypted;//手机号码密文 add 20220215 |
| | | public String State; //单位所在省份 |
| | | public String City; //市 |
| | | public String AccountName; //医院名 |
| | | public String RelatedHospital; //关联SFDC医院 客户管理编码(手写) AgentCode_Ext__c |
| | | public String DepartmentClass; //战略科室 |
| | | public String DepartmentName; //所属科室 |
| | | public String RelatedDepartment; //关联SFDC科室 客户管理编码(手写) AgentCode_Ext__c |
| | | public String Type; //职种 |
| | | public String TypeEncrypted;//职种Hash add for pipl 20220316 sushanhu |
| | | public String ContactAddress; //联系地址 |
| | | public String ContactAddressEncrypted;//联系地址密文 |
| | | public Boolean ForbiddenStatus; //平台用户禁用标识 |
| | | public String RegSource; //注册平台来源 |
| | | public Boolean AgentFlag; //经销商标识 |
| | | public String ApproverID; //审核人员员工编码 |
| | | public String DataId;//aws存储凭据 |
| | | } |
| | | |
| | | @HttpPost |
| | | global static void execute() { |
| | | |
| | | // 取得接口传输内容 |
| | | String strData = RestContext.request.requestBody.toString(); |
| | | GeDatas ges = (GeDatas) JSON.deserializeStrict(strData, GeDatas.class); |
| | | system.debug('ges---'+ges); |
| | | |
| | | if (ges == null) { |
| | | return; |
| | | } |
| | | |
| | | NFMUtil.Monitoring Monitoring = ges.Monitoring; |
| | | if (Monitoring == null) { |
| | | return; |
| | | } |
| | | |
| | | BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, LOG_TYPE, ges.GeData); |
| | | system.debug('String.isBlank(rowData.Log__c) == false?'); |
| | | if (String.isBlank(rowData.Log__c) == false) { |
| | | System.debug('进入if方法,成功调用executefuture'); |
| | | executefuture(rowData.Id); |
| | | } |
| | | |
| | | // JSONを戻す |
| | | RestResponse res = RestContext.response; |
| | | res.addHeader('Content-Type', 'application/json'); |
| | | res.statusCode = 200; |
| | | // String jsonResponse = '{"status": "Success", "Message":""}'; |
| | | // res.responseBody = blob.valueOf(jsonResponse); |
| | | //updata response toAWS 20220225 sushanhu start |
| | | NFMUtil.NFMResponse result = NFMUtil.getNFMResponse(); |
| | | result.SFStatus=SFStatus; |
| | | result.SFMessage=SFMessage; |
| | | String jsonResponse =JSON.serialize(result); |
| | | system.debug('result---'+jsonResponse); |
| | | res.responseBody = blob.valueOf(jsonResponse); |
| | | //updata response toAWS 20220225 sushanhu end |
| | | return; |
| | | } |
| | | |
| | | |
| | | @future |
| | | global static void executefuture(String rowData_Id) { |
| | | system.debug('进入executefuture方法' + rowData_Id); |
| | | main(rowData_Id); |
| | | } |
| | | |
| | | global static void main(String rowData_Id) { |
| | | // 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'); |
| | | RecordTypeMap.put('普外科', '01210000000QfmH'); |
| | | RecordTypeMap.put('泌尿科', '01210000000QfmC'); |
| | | RecordTypeMap.put('消化科', '01210000000Qfm7'); |
| | | RecordTypeMap.put('耳鼻喉科', '01210000000Qfm2'); |
| | | RecordTypeMap.put('ET', '01210000000QemQ'); |
| | | Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt); |
| | | BatchIF_Log__c rowData = [Select Id, Name, Log__c,Is_Error__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]; |
| | | String logstr = rowData.MessageGroupNumber__c + ' start\n'; |
| | | BatchIF_Log__c iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = LOG_TYPE; |
| | | iflog.MessageGroupNumber__c = rowData.MessageGroupNumber__c; |
| | | iflog.Log__c = logstr; |
| | | iflog.ErrorLog__c = ''; |
| | | insert iflog; |
| | | |
| | | String rowDataStr = NFMUtil.getRowDataStr(rowData); |
| | | List < GeData > GeDataList = (List < GeData > ) JSON.deserialize(rowDataStr, List < GeData > .class); |
| | | if (GeDataList == null || GeDataList.size() == 0) { |
| | | return; |
| | | } |
| | | //判空 |
| | | // for(GeData gda : GeDataList){ |
| | | // string dataComplete = verify(gda); |
| | | // if(!String.isBlank(dataComplete)){ |
| | | // logstr += dataComplete; |
| | | // continue; |
| | | // } |
| | | // } |
| | | |
| | | Savepoint sp = Database.setSavepoint(); |
| | | List<string> ApproverIDList = new List <string>();// |
| | | List < string > PersonManagementCodeList = new List < String > (); //人员管理编码List |
| | | List < String > SFDCCodeList = new List < String > (); //关联SFDC医院、科室List |
| | | 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) { |
| | | string dataComplete = verify(gedata); |
| | | |
| | | if (!String.isBlank(dataComplete)) { |
| | | logstr += dataComplete; |
| | | rowData.Is_Error__c = 1; |
| | | rowData.retry_cnt__c = 0; |
| | | continue; |
| | | } |
| | | if (!gedata.AgentFlag) { |
| | | StateList.add(gedata.State); |
| | | CityList.add(gedata.City); |
| | | ApproverIDList.add(gedata.ApproverID); |
| | | if(string.isnotblank(gedata.HospitalManagementCode2)){ |
| | | ManagementList.add(gedata.HospitalManagementCode2); |
| | | } |
| | | if(string.isnotblank(gedata.DepartmentManagementCode2)){ |
| | | ManagementList.add(gedata.DepartmentManagementCode2); |
| | | } |
| | | //system.debug('AccountCodeList'+AccountCodeList); |
| | | if (string.isnotblank(gedata.RelatedHospital)) { |
| | | SFDCCodeList.add(gedata.RelatedHospital); |
| | | } |
| | | if (string.isnotblank(gedata.RelatedDepartment)) { |
| | | SFDCCodeList.add(gedata.RelatedDepartment); |
| | | } |
| | | } |
| | | 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); |
| | | System.debug('SFDCCodeList'+SFDCCodeList); |
| | | |
| | | } |
| | | if (newGeDataList.size() > 0) { |
| | | //查询省份Id |
| | | Map < String, String > StateMap = new Map < String, String > (); //省Map |
| | | List < Address_Level__c > statetempList = [select Id, Name from Address_Level__c where Name IN: StateList]; |
| | | for (Address_Level__c temp: statetempList) { |
| | | StateMap.put(temp.Name, temp.Id); |
| | | } |
| | | //查询市区Id |
| | | Map < String, String > CityMap = new Map < String, String > (); //市Map |
| | | List < Address_Level2__c > citytempList = [select Id, Name from Address_Level2__c where Name IN: CityList]; |
| | | for (Address_Level2__c temp: citytempList) { |
| | | CityMap.put(temp.Name, temp.Id); |
| | | } |
| | | |
| | | //查询医院所有人 |
| | | Map<string,String> ownerMap = new Map<string,String>(); |
| | | List<User> ownerList = [select Id,Employee_No__c from User where Employee_No__c IN:ApproverIDList]; |
| | | for(User temp : ownerList){ |
| | | ownerMap.put(temp.Employee_No__c,temp.Id); |
| | | } |
| | | |
| | | //查询OCSM营业窗口 |
| | | Map<string,Id> OCSMMap = new Map<string,Id>(); |
| | | List<OCM_Management_Province__c> OCSMList = [select Id,Name,Window1__c from OCM_Management_Province__c]; |
| | | for(OCM_Management_Province__c ocsm : OCSMList){ |
| | | OCSMMap.put(ocsm.name,ocsm.Window1__c); |
| | | } |
| | | |
| | | //查询联系人 |
| | | Map < String, Map < String, Contact >> nameMap = new Map < String, Map < String, Contact >> (); //外层战略科室,内层科室名+联系人名 |
| | | List < Contact > peopleList = [select Id, |
| | | Account.Name, |
| | | Department__c, |
| | | UnifiedI_Contact_ID__c, |
| | | Account.parent.Name, |
| | | Account.PlatformCode__c, |
| | | Account.Management_Code__c, |
| | | Account.parent.Department_Class_Label__c, |
| | | Name,LastName_Encrypted__c, |
| | | Account.Parent_Management_Code__c, |
| | | Account.Parent_PlatformCode__c, |
| | | CManageCode__c, |
| | | AccountId, |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | MobilePhone_Encrypted__c |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | from Contact |
| | | where CManageCode__c IN: PersonManagementCodeList |
| | | 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 namekey; |
| | | string nameKey2; |
| | | 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(); |
| | | } 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(); |
| | | } |
| | | // snameMap.put(namekey,ct); |
| | | if (nameMap.containsKey(ct.Account.parent.Name)) { |
| | | snameMap = nameMap.get(ct.Account.parent.Name); |
| | | } |
| | | snameMap.put(namekey, ct); |
| | | snameMap.put(nameKey2,ct); |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | // if(String.isBlank(ct.MobilePhone_Encrypted__c)){ |
| | | // snameMap.put(ct.LastName_Encrypted__c.trim(), ct); |
| | | // } else{ |
| | | // snameMap.put(ct.LastName_Encrypted__c.trim() + ct.MobilePhone_Encrypted__c.trim(), ct); |
| | | // } |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | nameMap.put(ct.Account.parent.Name, snameMap); |
| | | system.debug('snameMap'+snameMap); |
| | | } |
| | | peopleMap.put(ct.CManageCode__c, ct); |
| | | System.debug('peopleMap'+peopleMap); |
| | | // peopleMap.put(ct.Name, ct); |
| | | //string temp = ct.Name + ct.Account.parent.Department_Class_Label__c; |
| | | // peopleMap.put(temp, ct); |
| | | } |
| | | |
| | | //查询医院科室 |
| | | //List<Account> AccountList = [select Id,PlatformCode__c,PlatformCode__c,Department_Class_Label__c,Name,Management_Code__c,Is_Active__c,AgentCode_Ext__c,ParentId,Parent.ParentId from Account where PlatformCode__c IN :HpCodeList OR parent.PlatformCode__c IN :HpCodeList OR PlatformCode__c IN :HpCodeList OR Management_Code__c IN :RelatedHospitalList OR Parent_Management_Code__c IN :RelatedHospitalList]; |
| | | //List < Account > AccountList = [select Id, PlatformCode__c, Department_Class_Label__c, Name, Management_Code__c, Is_Active__c, AgentCode_Ext__c, ParentId, Parent.ParentId from Account where Management_Code__c IN :AccountCodeList OR Parent_Management_Code__c IN :AccountCodeList OR PlatformCode__c IN :AccountCodeList OR Parent.Parent.PlatformCode__c IN :AccountCodeList]; |
| | | List < Account > AccountList = [select Id, |
| | | PlatformCode__c, |
| | | Is_Active_Formula__c, |
| | | Department_Class_Label__c, |
| | | OCM_man_province_HP__c, |
| | | Name, Management_Code__c, |
| | | Is_Active__c, AgentCode_Ext__c, |
| | | ParentId, |
| | | Parent.ParentId, |
| | | OwnerId |
| | | from Account |
| | | where Parent_PlatformCode__c IN: ManagementList |
| | | OR Parent_Management_Code__c IN: SFDCCodeList]; |
| | | Map <String,Account> DepartmentClassMap = new Map <String,Account>();//战略科室Map |
| | | Map < String, Account > AccountMap = new Map < String, Account > (); //医院科室 |
| | | for (Account ac: AccountList) { |
| | | AccountMap.put(ac.Management_Code__c, ac); |
| | | if(string.isNotBlank(ac.Department_Class_Label__c)){ |
| | | DepartmentClassMap.put(ac.Department_Class_Label__c,ac); |
| | | } |
| | | if (string.isNotBlank(ac.PlatformCode__c)) { |
| | | AccountMap.put(ac.PlatformCode__c, ac); |
| | | } |
| | | } |
| | | system.debug('AccountMap '+AccountMap); |
| | | System.debug('DepartmentClassMap '+DepartmentClassMap); |
| | | |
| | | |
| | | //客户List(更新用) |
| | | List < Account > upsertAccountList = new List < Account > (); |
| | | //联系人List(更新用) |
| | | List < Contact > upsertContactList = new List < Contact > (); |
| | | |
| | | for (Gedata gedata: newGeDataList) { |
| | | logstr += gedata.Name; |
| | | logstr += gedata.AccountName; |
| | | logstr += gedata.DepartmentClass; |
| | | logstr += gedata.DepartmentName; |
| | | |
| | | |
| | | string comefrom = gedata.RegSource == '1' ? '智慧医疗' : (gedata.RegSource == '2' ? '服务客户端' :'医拓网'); //平台来源 |
| | | |
| | | //新建医院 |
| | | Account hp = new Account(); |
| | | |
| | | //新建联系人 |
| | | Contact ct = new Contact(); |
| | | 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; |
| | | |
| | | Map < String, Contact > contactMap = new Map < String, Contact > ();//用于暂存更新联系人 |
| | | //1经销商true |
| | | if (gedata.AgentFlag == true) { |
| | | //更新经销商联系人 |
| | | if (!peopleMap.containsKey(personCode)) { |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | | ct.id = peopleMap.get(personCode).id; |
| | | upsertContactList.add(ct); |
| | | } else { //经销商flase |
| | | string HospitalCode = string.isNotBlank(gedata.RelatedHospital) ? gedata.RelatedHospital : gedata.HospitalManagementCode2; //RelatedHospital有值用RelatedHospital,否则用HospitalManagementCode2 |
| | | //医院存在 |
| | | System.debug('AccountMap.containsKey(HospitalCode )'+AccountMap.containsKey(HospitalCode)); |
| | | if (AccountMap.containsKey(HospitalCode)) { |
| | | //新建科室 |
| | | Account dpt = new Account(); |
| | | Account hospital = AccountMap.get(HospitalCode); |
| | | dpt.PlatformCode__c = gedata.DepartmentManagementCode2; |
| | | dpt.Hospital__c = hospital.Id; |
| | | |
| | | //判断医院是否有效 |
| | | 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)) { |
| | | //人员管理编码存在 |
| | | ct.AccountId = AccountMap.get(DepartmentCode).id;//科室确定,将联系人挂在该科室下 |
| | | ct.OwnerId = AccountMap.get(DepartmentCode).OwnerId;//可是确定,将将联系人所有人的值赋为科室所有人 |
| | | system.debug('personCode' + personCode); |
| | | if (string.isnotblank(personCode)) { |
| | | system.debug('人员管理编码存在'); |
| | | //联系人存在 1 完成 |
| | | if (peopleMap.containsKey(personCode)) { |
| | | system.debug('1逻辑 有医院 有科室 有人员管理编码且查找有此人 动作:更新'); |
| | | ct.Id = peopleMap.get(personCode).Id; |
| | | upsertContactList.add(ct); |
| | | } else { //联系人不存在 2 完成 |
| | | system.debug('2逻辑 有医院 有科室 有人员管理编码但查找无此人 动作:报错'); |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | | } else { //人员管理编码不存在 |
| | | //搜索人名/且在当前战略科室科室下 |
| | | System.debug('人员管理编码不存在'); |
| | | string namekey = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted + ' ' + gedata.MobileEncrypted; |
| | | string namekey1 = 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)); |
| | | System.debug('sMap.containsKey(gedata.NameEncrypted)'+sMap.containsKey(gedata.NameEncrypted)); |
| | | if (sMap.containsKey(namekey)) { |
| | | 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 |
| | | }else { // 7 完成 |
| | | system.debug('7逻辑 无人员管理编码 有医院 有科室 人名查找无 动作:新建联系人 '); |
| | | } |
| | | } |
| | | upsertContactList.add(ct); |
| | | } |
| | | dpt.Id = AccountMap.get(DepartmentCode).Id; |
| | | upsertAccountList.add(dpt); |
| | | } else { //科室不存在 |
| | | //为科室赋值 |
| | | dpt.Name = gedata.DepartmentName; |
| | | dpt.RecordTypeId = RecordTypeMap.get(gedata.DepartmentClass); |
| | | dpt.Department_Class__c = DepartmentClassMap.get(gedata.DepartmentClass).Id; |
| | | dpt.ParentId = DepartmentClassMap.get(gedata.DepartmentClass).Id; |
| | | if (string.isnotblank(personCode)) { //人员管理编码存在 |
| | | if (peopleMap.containsKey(personCode)) { //人员管理编码查找有值 3 完成 |
| | | System.debug('3逻辑'); |
| | | //新建科室+新建联系人, |
| | | ct.id = peopleMap.get(personCode).id; |
| | | contactMap.put(Gedata.DepartmentManagementCode2, ct); |
| | | system.debug('contactMap ' + contactMap); |
| | | dpt.Department_Name__c = gedata.DepartmentName; |
| | | upsertAccountList.add(dpt); |
| | | //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.NameEncrypted + ' ' + gedata.MobileEncrypted; |
| | | //string namekey = gedata.AccountName + ' ' + gedata.DepartmentName + ' ' + gedata.DepartmentClass + ' ' + gedata.Name; |
| | | system.debug('DepartmentClasskey'+DepartmentClasskey); |
| | | system.debug('351nameMap '+nameMap); |
| | | if (nameMap.containsKey(DepartmentClasskey)) { //查找是否存在该战略科室 |
| | | 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);//可以注释 |
| | | upsertContactList.add(ct); |
| | | // if(sMap.containsKey(gedata.Name)){ |
| | | // ct.Id = sMap.get(gedata.Name).Id; |
| | | // } |
| | | } |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | // else if(sMap.containsKey(gedata.NameEncrypted + gedata.MobileEncrypted) && sMap.get(gedata.NameEncrypted + gedata.MobileEncrypted).UnifiedI_Contact_ID__c == null){ |
| | | // system.debug('1234567890'); |
| | | // ct.Id = sMap.get(gedata.NameEncrypted + gedata.MobileEncrypted).Id; |
| | | // //upsertAccountList.add(dpt); |
| | | // upsertContactList.add(ct); |
| | | // } |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | 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; |
| | | upsertAccountList.add(dpt); |
| | | contactMap.put(Gedata.DepartmentManagementCode2, ct); |
| | | } |
| | | } |
| | | }else if('无效'.equals(hospital.Is_Active_Formula__c)){ |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:该医院无效,此条数据跳过'; |
| | | continue; |
| | | }else{ |
| | | logstr += '该医院处于草案中,请等待审批完成'; |
| | | rowData.NFM624_Secondary_processing__c = false; |
| | | continue; |
| | | } |
| | | } else { //医院不存在 |
| | | system.debug('新建医院 逻辑5逻辑10 无论人员管理编码是否有值都需要新建医院'); |
| | | hp.Name = gedata.AccountName; //医院名赋值 |
| | | if(ownerMap.containsKey(gedata.ApproverID)){ |
| | | hp.OwnerId = ownerMap.get(gedata.ApproverID);//审核人员员工编码赋值给用户所有人 |
| | | } |
| | | hp.RecordTypeId = '01210000000QemG'; |
| | | hp.OCM_Category__c = 'L'; |
| | | hp.PlatformCode__c = gedata.HospitalManagementCode2; |
| | | hp.State_Master__c = StateMap.get(gedata.State); // 省 |
| | | hp.City_Master__c = CityMap.get(gedata.City); // 市 |
| | | hp.Hospital_Source__c = '智慧医疗'; |
| | | upsertAccountList.add(hp); |
| | | System.debug('upsertAccountList'+upsertAccountList); |
| | | rowData.NFM624_Secondary_processing__c = false;//数据需要二次处理标记 |
| | | } |
| | | } |
| | | system.debug('upsertContactList ' + upsertContactList); |
| | | system.debug('upsertAccountList ' + upsertAccountList); |
| | | if (upsertAccountList.size() > 0) { |
| | | ControllerUtil.EscapeNFM001Trigger = true; |
| | | 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){ |
| | | c.Accountid = ac.id; |
| | | } |
| | | c.OwnerId = ac.OwnerId; |
| | | upsertContactList.add(c); |
| | | system.debug('OwnerId'+ac.OwnerId); |
| | | system.debug('upsertContactList'+upsertContactList); |
| | | } |
| | | |
| | | if(ac.RecordTypeId == '01210000000QemGAAS' && ac.Is_Active__c == '草案中' && string.isNotBlank( OCSMMap.get(ac.OCM_man_province_HP__c))){ |
| | | ac.OwnerId = OCSMMap.get(ac.OCM_man_province_HP__c); |
| | | updateHPList.add(ac); |
| | | } |
| | | if(updateHPList.size()>0){ |
| | | update updateHPList; |
| | | } |
| | | } |
| | | } |
| | | |
| | | upsert upsertAccountList; |
| | | system.debug('upsertContactList11111111111 '+upsertContactList); |
| | | if(upsertContactList.size()>0){ |
| | | upsert upsertContactList; |
| | | rowData.NFM624_Secondary_processing__c = true;//执行完之后修改为true,不需要再次执行 |
| | | //2022/2/10 修改 在新建联系人之后手动执行NFM620RestBatch NFM623RestBatch |
| | | // Database.executeBatch(new NFM620RestBatch(), 1); |
| | | // Database.executeBatch(new NFM623RestBatch(), 1); |
| | | supplement(gedata.ContactId); |
| | | } |
| | | } |
| | | } |
| | | rowData.retry_cnt__c = 0; |
| | | |
| | | logstr += '\nend'; |
| | | } catch (Exception ex) { |
| | | // エラーが発生した場合 |
| | | Database.rollback(sp); |
| | | System.debug(Logginglevel.ERROR, LOG_TYPE + '_' + rowData.MessageGroupNumber__c + ':' + ex.getMessage()); |
| | | System.debug(Logginglevel.ERROR, LOG_TYPE + '_' + rowData.MessageGroupNumber__c + ':' + ex.getStackTraceString()); |
| | | logstr += '\n' + ex.getMessage(); |
| | | iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c; |
| | | if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0; |
| | | if (rowData.retry_cnt__c < batch_retry_max_cnt) { |
| | | rowData.retry_cnt__c++; |
| | | LogAutoSendSchedule.assignOneMinute(); |
| | | } |
| | | if (rowData.retry_cnt__c >= batch_retry_max_cnt) { |
| | | rowData.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowData.ErrorLog__c + '错误次数已经超过自动收信设定的最大次数,请手动收信'; |
| | | } |
| | | } |
| | | update rowData; |
| | | iflog.Log__c = logstr; |
| | | if (iflog.Log__c.length() > 131072) { |
| | | iflog.Log__c = iflog.Log__c.subString(0, 131065) + ' ...'; |
| | | } |
| | | if (iflog.ErrorLog__c.length() > 32768) { |
| | | iflog.ErrorLog__c = iflog.ErrorLog__c.subString(0, 32760) + ' ...'; |
| | | } |
| | | update iflog; |
| | | } |
| | | |
| | | private static String verify(GeData gda) { |
| | | String result = ''; |
| | | if (gda.AgentFlag) { |
| | | if (string.isblank(gda.ContactId)) { |
| | | result += 'DataError: ContactId 统一平台ID为空\n'; |
| | | } |
| | | if (string.isblank(gda.PersonManagementCode)) { |
| | | result += 'DataError:PersonManagementCode 人员管理编码为空\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'; |
| | | } |
| | | if (string.isblank(gda.DepartmentManagementCode2)) { |
| | | result += 'DataError:科室平台编码为空\n'; |
| | | } |
| | | if (string.isblank(gda.State)) { |
| | | result += 'DataError:省字段为空\n'; |
| | | } |
| | | if (string.isblank(gda.City)) { |
| | | result += 'DataError:市字段为空\n'; |
| | | } |
| | | if (string.isblank(gda.AccountName)) { |
| | | result += 'DataError:医院名为空\n'; |
| | | } |
| | | if (string.isblank(gda.DepartmentName)) { |
| | | result += 'DataError:所属科室为空\n'; |
| | | } |
| | | if (string.isblank(gda.Type)) { |
| | | result += 'DataError:职种分类为空\n'; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private static void supplement (String ContactId){ |
| | | //把620Batch 和 623Batch 搬过来 |
| | | //补充询问单部分 start |
| | | //更新用 |
| | | List<CampaignMember__c> campaignMemberList = new List<CampaignMember__c>(); |
| | | List<Inquiry_form__c> inquiryFormList = new List<Inquiry_form__c>(); |
| | | //根据统一用户Id查询询问单 |
| | | List<Inquiry_form__c> InquiryList = [select Id,Inquiry_No__c,ContactId__c,Hospital_Name__c,Department_Class__c,Contact_Name__c from Inquiry_form__c where ContactId__c = :ContactId]; |
| | | system.debug('InquiryList'+InquiryList); |
| | | //根据统一用户Id查询联系人 |
| | | List<Contact> contactList = [select Id,Name,UnifiedI_Contact_ID__c,Account.Id,Strategic_dept_Class__c,AccountId,Account.Name,Strategic_dept_Class__r.OwnerId from Contact where UnifiedI_Contact_ID__c = :ContactId]; |
| | | system.debug('contactList' + contactList); |
| | | |
| | | if(InquiryList.size()>0){ |
| | | //统一用户ID存入List、询问单ID存Map |
| | | Map<String, String> inquiryMap = new Map<String, String>(); |
| | | //List<String> contactIdList = new List<String>(); |
| | | for (Inquiry_form__c inquiryInfo : inquiryList) { |
| | | //contactIdList.add(inquiryInfo.ContactId__c); |
| | | // map的k-v改造 thh 20220517 start |
| | | inquiryMap.put(inquiryInfo.Id, inquiryInfo.ContactId__c); |
| | | // map的k-v改造 thh 20220517 end |
| | | } |
| | | // map的k-v改造 thh 20220517 start |
| | | if (contactList.size() >0 && inquiryMap.size() > 0) { |
| | | for(String Id : inquiryMap.keySet()){ |
| | | Inquiry_form__c inquiry = new Inquiry_form__c(); |
| | | for (Contact contactInfo : contactList) { |
| | | if(inquiryMap.get(Id) == contactInfo.UnifiedI_Contact_ID__c){ |
| | | inquiry.Id = Id; //ID |
| | | inquiry.Hospital_Name__c = contactInfo.Account.Id; //科室名 |
| | | inquiry.Department_Class__c = contactInfo.Strategic_dept_Class__c; //战略科室分类 |
| | | inquiry.Contact_Name__c = contactInfo.Id; //客户姓名 |
| | | inquiry.OwnerId = contactInfo.Strategic_dept_Class__r.OwnerId; //所有人 |
| | | inquiryFormList.add(inquiry); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // map的k-v改造 thh 20220517 end |
| | | system.debug('inquiryFormList=========>'+inquiryFormList); |
| | | if(inquiryFormList.size()>0){ |
| | | update inquiryFormList; |
| | | } |
| | | } |
| | | //补充询问单部分 end |
| | | |
| | | //补充学会部分 start |
| | | //List<CampaignMember__c> campaignMemberList = new List<CampaignMember__c>(); |
| | | List<CampaignMember__c> capMemList = [select Id,Contact_ID__c,Campaign__c,Campaign__r.Num__c,ViewContactId__c from CampaignMember__c where Contact_ID__c = :ContactId]; |
| | | if(capMemList.size() > 0){ |
| | | system.debug('capMemList=================>'+capMemList); |
| | | Map<String, String> capMemMap = new Map<String, String>(); |
| | | //统一用户ID存入List,参会人员记录ID存入MAP |
| | | //List<String> contactIdList = new List<String>(); |
| | | for (CampaignMember__c capMemInfo : capMemList) { |
| | | //contactIdList.add(capMemInfo.ViewContactId__c); |
| | | capMemMap.put(capMemInfo.ViewContactId__c,capMemInfo.Id); |
| | | } |
| | | system.debug('capMemMap======>'+capMemMap); |
| | | //List<Contact> contactList = [select Id,Name,UnifiedI_Contact_ID__c,Account.Id,Strategic_dept_Class__c,AccountId,Account.Name,Strategic_dept_Class__r.OwnerId,Id from Contact where UnifiedI_Contact_ID__c = ContactId]; |
| | | if (contactList.size() > 0) { |
| | | for (Contact contactInfo : contactList) { |
| | | CampaignMember__c camMemberInfo = new CampaignMember__c(); |
| | | camMemberInfo.Id = capMemMap.get(contactInfo.UnifiedI_Contact_ID__c); |
| | | camMemberInfo.Contact_ID__c = contactInfo.Id; //参会人员ID |
| | | camMemberInfo.Department_ID__c = contactInfo.AccountId; //医院科室 |
| | | camMemberInfo.Department__c = contactInfo.Account.Name; //医院科室(文本) |
| | | camMemberInfo.Contact__c = contactInfo.Name; //客户人员姓名 |
| | | campaignMemberList.add(camMemberInfo); |
| | | } |
| | | } |
| | | system.debug('campaignMemberList================>'+campaignMemberList); |
| | | if (campaignMemberList.size() > 0) { |
| | | System.debug('--------1-------'); |
| | | update campaignMemberList; |
| | | } |
| | | } |
| | | //补充学会部分 end |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>46.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
New file |
| | |
| | | /********************************************************************** |
| | | * |
| | | * |
| | | * @url: /services/apexrest/NFM624RestAbout |
| | | * @data: |
| | | * { |
| | | |
| | | } |
| | | *************************************************************************/ |
| | | |
| | | @RestResource(urlMapping = '/NFM624About/*') |
| | | global with sharing class NFM624RestAbout { |
| | | |
| | | private static final String LOG_TYPE = 'NFM624About'; |
| | | |
| | | global class GeDatas { |
| | | public NFMUtil.Monitoring Monitoring; |
| | | public GeData[] GeData; |
| | | } |
| | | global class GeData{ |
| | | |
| | | public String PersonManagementCode; //人员管理编码 |
| | | public String HospitalManagementCode2; //医院平台编码 平台编码 PlatformCode__c |
| | | public String DepartmentManagementCode2; //科室平台编码 平台编码 PlatformCode__c |
| | | //public String Name; //姓名 |
| | | public String NameEncrypted;//姓名密文 add 20220215 |
| | | public String RelatedHospital; //关联SFDC医院 客户管理编码(手写) AgentCode_Ext__c |
| | | public String DepartmentClass; //战略科室 |
| | | public String DepartmentName; //所属科室 |
| | | public String RelatedDepartment; //关联SFDC科室 客户管理编码(手写) AgentCode_Ext__c |
| | | //public Boolean AgentFlag; //经销商标识 |
| | | public String dataId; |
| | | public String AccountName; //医院名 |
| | | public String MobileEncrypted; //电话密文 add 20220519 thh |
| | | } |
| | | |
| | | |
| | | |
| | | global class Response { |
| | | public List<ResponseDetail> ResponseDetails {get;set;} |
| | | } |
| | | |
| | | global class ResponseDetail{ |
| | | public String dataId; |
| | | public String awsDataId; //=CONTACT.AWS_Data_Id__c |
| | | public String sfId; |
| | | } |
| | | |
| | | @HttpPost |
| | | global static void execute() { |
| | | |
| | | // 取得接口传输内容 |
| | | String strData = RestContext.request.requestBody.toString(); |
| | | GeDatas ges = (GeDatas) JSON.deserializeStrict(strData, GeDatas.class); |
| | | system.debug('ges---'+JSON.serialize(ges) ); |
| | | |
| | | if (ges == null) { |
| | | return; |
| | | } |
| | | |
| | | NFMUtil.Monitoring Monitoring = ges.Monitoring; |
| | | if (Monitoring == null) { |
| | | system.debug('monitoring62'); |
| | | return; |
| | | } |
| | | |
| | | String result; |
| | | try { |
| | | BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, LOG_TYPE, ges.GeData); |
| | | system.debug('rowData = '+rowData); |
| | | system.debug('String.isBlank(rowData.Log__c) == false?'); |
| | | if (String.isBlank(rowData.Log__c) == false) { |
| | | System.debug('进入if方法,成功调用executefuture'); |
| | | result = JSON.serialize(main(rowData.Id)); |
| | | system.debug('result'+result); |
| | | // result main(rowData.Id); |
| | | } |
| | | } catch (Exception ex) { |
| | | System.debug(Logginglevel.ERROR, LOG_TYPE + ':' + ex.getMessage()); |
| | | System.debug(Logginglevel.ERROR, LOG_TYPE + ':' + ex.getStackTraceString()); |
| | | } |
| | | // BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, LOG_TYPE, ges.GeData); |
| | | |
| | | |
| | | // JSONを戻す |
| | | RestResponse res = RestContext.response; |
| | | res.addHeader('Content-Type', 'application/json'); |
| | | res.statusCode = 200; |
| | | // NFMUtil.NFMResponse result = NFMUtil.getNFMResponse(); |
| | | // result.SFStatus=SFStatus; |
| | | // result.SFMessage=SFMessage; |
| | | String jsonResponse = result; |
| | | //for test sushanhu 20220401 start |
| | | //ResponseDetail red =new ResponseDetail(); |
| | | // red.dataId =ges.[0].dataId; |
| | | //red.awsDataId ='959174215334887424'; |
| | | //red.sfId ='0031m00000N7leyAAB'; |
| | | // Response resp =new Response(); |
| | | // List<ResponseDetail> listName = new List<ResponseDetail>(); |
| | | // listName.add(red); |
| | | // resp= (Response)listName; |
| | | //for test sushanhu 20220401 end |
| | | //String jsonResponse = '{"dataID": ""}'; |
| | | //system.debug('result---'+jsonResponse); |
| | | res.responseBody = blob.valueOf(jsonResponse);//need |
| | | //String resp ='{"ResponseDetails":[{"dataId":"959573117074669568","awsDataId":"959174215334887424","sfId":"0031m00000N7leyAAB"}]}'; |
| | | //res.responseBody = blob.valueOf(resp); |
| | | |
| | | |
| | | //updata response toAWS 20220225 sushanhu end |
| | | return; |
| | | } |
| | | |
| | | |
| | | @future |
| | | global static void executefuture(String rowData_Id) { |
| | | system.debug('进入executefuture方法' + rowData_Id); |
| | | main(rowData_Id); |
| | | } |
| | | |
| | | global static Response main(String rowData_Id) { |
| | | Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt); |
| | | BatchIF_Log__c rowData = [Select Id, Name, Log__c,Is_Error__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]; |
| | | String logstr = rowData.MessageGroupNumber__c + ' start\n'; |
| | | BatchIF_Log__c iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = LOG_TYPE; |
| | | iflog.MessageGroupNumber__c = rowData.MessageGroupNumber__c; |
| | | iflog.Log__c = logstr; |
| | | iflog.ErrorLog__c = ''; |
| | | insert iflog; |
| | | String rowDataStr = NFMUtil.getRowDataStr(rowData); |
| | | List < GeData > GeDataList = (List < GeData > ) JSON.deserialize(rowDataStr, List < GeData > .class); |
| | | // if (GeDataList == null || GeDataList.size() == 0) { |
| | | // return null; |
| | | // } |
| | | Savepoint sp = Database.setSavepoint(); |
| | | List < string > PersonManagementCodeList = new List < String > (); //人员管理编码List |
| | | List < String > SFDCCodeList = new List < String > (); |
| | | List < String > ManagementList = new List < String > (); //医院、科室平台编码List |
| | | List < String > NameList = new List < String >(); |
| | | Response responseList = new Response();//返回体List |
| | | ResponseDetail red = new ResponseDetail(); |
| | | responseList.ResponseDetails = new List<ResponseDetail>(); |
| | | try { |
| | | //根据传过来的管理编码查询如果可以查询得到结果则更新,查询不到则新增 |
| | | // for(GeData gedata : GeDataList){ |
| | | // ResponseDetail temp = new ResponseDetail(); |
| | | // temp.dataID = gedata.dataID; |
| | | // temp.awsDataId = null; |
| | | // temp.sfId = null; |
| | | // responseList.ResponseDetails.add(temp); |
| | | // } |
| | | //根据传过来的管理编码查询如果可以查询得到结果则更新,查询不到则新增 |
| | | List < Gedata > newGeDataList = new List < Gedata > (); |
| | | for (Gedata gedata: GeDataList) { |
| | | system.debug('gedata.NameEncrypted'+gedata.NameEncrypted); |
| | | red.dataID = gedata.dataID; |
| | | red.awsDataId = null; |
| | | red.sfid = null; |
| | | if(string.isnotblank(gedata.HospitalManagementCode2)){ |
| | | ManagementList.add(gedata.HospitalManagementCode2); |
| | | } |
| | | if(string.isnotblank(gedata.DepartmentManagementCode2)){ |
| | | ManagementList.add(gedata.DepartmentManagementCode2); |
| | | } |
| | | if (string.isnotblank(gedata.RelatedHospital)) { |
| | | SFDCCodeList.add(gedata.RelatedHospital); |
| | | } |
| | | if (string.isnotblank(gedata.RelatedDepartment)) { |
| | | SFDCCodeList.add(gedata.RelatedDepartment); |
| | | } |
| | | 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); |
| | | System.debug('SFDCCodeList'+SFDCCodeList); |
| | | } |
| | | if (newGeDataList.size() > 0){ |
| | | system.debug('newGeDataList.size()'+newGeDataList.size()); |
| | | //查询联系人 |
| | | Map < String, Map < String, Contact >> nameMap = new Map < String, Map < String, Contact >> (); //外层战略科室,内层科室名+联系人名 |
| | | List < Contact > peopleList = [select Id, |
| | | Account.Name, |
| | | //Department__c, |
| | | Account.parent.Name, |
| | | UnifiedI_Contact_ID__c, |
| | | //Account.PlatformCode__c, |
| | | Account.Management_Code__c, |
| | | //Account.parent.Department_Class_Label__c, |
| | | Name,LastName_Encrypted__c, |
| | | //Account.Parent_Management_Code__c, |
| | | //Account.Parent_PlatformCode__c, |
| | | CManageCode__c,AWS_Data_Id__c, |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | MobilePhone_Encrypted__c |
| | | // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | //AccountId |
| | | from Contact |
| | | where CManageCode__c IN: PersonManagementCodeList |
| | | 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 namekey; |
| | | string nameKey2; |
| | | 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(); |
| | | } 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(); |
| | | } |
| | | snameMap.put(namekey,ct); |
| | | if (nameMap.containsKey(ct.Account.parent.Name)) { |
| | | snameMap = nameMap.get(ct.Account.parent.Name); |
| | | } |
| | | snameMap.put(nameKey2,ct); |
| | | snameMap.put(namekey, ct); |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 start |
| | | // System.System.debug('ct.MobilePhone_Encrypted__c1:' + ct.MobilePhone_Encrypted__c); |
| | | // if(String.isBlank(ct.MobilePhone_Encrypted__c)){ |
| | | // snameMap.put(ct.LastName_Encrypted__c.trim(), ct); |
| | | // }else{ |
| | | // snameMap.put(ct.LastName_Encrypted__c.trim() + ct.MobilePhone_Encrypted__c.trim(), ct); |
| | | // } |
| | | // System.System.debug('ct.MobilePhone_Encrypted__c2:' + ct.MobilePhone_Encrypted__c); |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | nameMap.put(ct.Account.parent.Name, snameMap); |
| | | system.debug('snameMap'+snameMap.keyset()); |
| | | } |
| | | peopleMap.put(ct.CManageCode__c, ct); |
| | | System.debug('peopleMap'+peopleMap); |
| | | } |
| | | for (Gedata gedata: newGeDataList) { |
| | | String personCode = gedata.PersonManagementCode; |
| | | string DepartmentClasskey = gedata.AccountName + ' ' + gedata.DepartmentClass; |
| | | if(string.isnotblank(personCode)){//判断有人员管理编码 |
| | | //有人员管理编码 |
| | | system.debug('有人员管理编码'); |
| | | if (peopleMap.containsKey(personCode)) { |
| | | system.debug('有人员管理编码取到值'); |
| | | peopleMap.get(personCode); |
| | | //red.dataID = gedata.dataID; |
| | | red.awsDataId = peopleMap.get(personCode).AWS_Data_Id__c; |
| | | red.sfid = peopleMap.get(personCode).id; |
| | | }else{ |
| | | system.debug('有人员管理编码未取到值'); |
| | | // red.dataID = gedata.dataID; |
| | | // red.awsDataId = null; |
| | | // red.sfid = null; |
| | | } |
| | | system.debug('red----------->'+red); |
| | | responseList.ResponseDetails.add(red); |
| | | }else{ |
| | | //无人员管理编码 |
| | | string namekey = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted + ' ' + gedata.MobileEncrypted; |
| | | string namekey1 = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted; |
| | | system.debug('DepartmentClasskey = '+DepartmentClasskey); |
| | | system.debug('nameMap22222222 '+nameMap); |
| | | if (nameMap.containskey(DepartmentClasskey)) { |
| | | system.debug('nameMap.containskey(DepartmentClasskey'+nameMap.containskey(DepartmentClasskey)); |
| | | Map < String, Contact > sMap = nameMap.get(DepartmentClasskey); |
| | | System.debug('sMap'+sMap); |
| | | System.debug('sMap.containsKey(namekey)'+sMap.containsKey(namekey)); |
| | | System.debug('Namekey'+namekey); |
| | | if (sMap.containsKey(namekey)) { |
| | | system.debug('根据名字匹配存在'); |
| | | red.awsDataId = sMap.get(namekey).AWS_Data_Id__c; |
| | | red.sfid = sMap.get(namekey).id; |
| | | } else if(sMap.containsKey(namekey1) && sMap.get(namekey1).UnifiedI_Contact_ID__c == null) { |
| | | red.awsDataId = sMap.get(namekey1).AWS_Data_Id__c; |
| | | red.sfid = 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){ |
| | | // red.awsDataId = sMap.get(gedata.NameEncrypted + gedata.MobileEncrypted).AWS_Data_Id__c; |
| | | // red.sfid = sMap.get(gedata.NameEncrypted + gedata.MobileEncrypted).id; |
| | | // // 通过姓名+手机号判断人员是否重复 thh 20220518 end |
| | | }else { // 7 完成 |
| | | system.debug('根据名字匹配不存在'); |
| | | //red.dataID = gedata.dataID; |
| | | //red.awsDataId = null; |
| | | //red.sfid = null; |
| | | } |
| | | system.debug('red----------->'+red); |
| | | responseList.ResponseDetails.add(red); |
| | | system.debug('responseList.ResponseDetails'+responseList.ResponseDetails); |
| | | }else{ |
| | | responseList.ResponseDetails.add(red); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | rowData.retry_cnt__c = 0; |
| | | if (System.Test.isRunningTest()) { |
| | | throw new ControllerUtil.myException('aaa'); |
| | | } |
| | | }catch (Exception ex) { |
| | | // エラーが発生した場合 |
| | | |
| | | logstr += ex.getMessage(); |
| | | iflog.ErrorLog__c += ex.getMessage() + '\n'; |
| | | iflog.ErrorLog__c += ex.getStackTraceString() + '\n'; |
| | | } |
| | | update rowData; |
| | | system.debug('Rowdata'+rowData); |
| | | logstr += responseList +'\n'; |
| | | logstr += 'end'; |
| | | iflog.Log__c = logstr; |
| | | update iflog; |
| | | system.debug('responseList.ResponseDetails'+responseList.ResponseDetails); |
| | | return responseList; |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>54.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
New file |
| | |
| | | @isTest |
| | | public with sharing class NFM624RestAboutTest { |
| | | static testMethod void testMethod4(){ |
| | | oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | //用户 |
| | | User hpowner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2'); |
| | | insert hpowner; |
| | | |
| | | User hpowner2 = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp1', Work_Location__c = '北京', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner1@sunbridge.com', Username = 'olympus_hpowner1@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2'); |
| | | insert hpowner2; |
| | | |
| | | //医院 |
| | | Account hp = new Account(RecordTypeId = '01210000000QemG', Name = '北京德胜门中医院', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.Advance_Payment_Identification_Approval__c = Date.today().addyears(-1); |
| | | hp.AgentCode_Ext__c = '112358'; |
| | | hp.PlatformCode__c = '1375'; |
| | | hp.Is_Active__c = '有効'; |
| | | insert hp; |
| | | |
| | | |
| | | Account hptemp = [select Id,PlatformCode__c,AgentCode_Ext__c,Is_Active_Formula__c from Account where Id = :hp.Id]; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name,Parent_PlatformCode__c,Parent_Management_Code__c, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_BF']; |
| | | |
| | | NFM624Rest.GeData GeData1 = new NFM624Rest.GeData(); |
| | | NFM624Rest.GeDatas GaDatas = new NFM624Rest.GeDatas(); |
| | | |
| | | Datetime nowDT = Datetime.now(); |
| | | String nowStr = nowDT.format('yyyyMMddHHmm'); |
| | | GaDatas.Monitoring = new NFMUtil.Monitoring(); |
| | | GaDatas.Monitoring.MessageGroupNumber = nowStr + '01'; |
| | | //有医院没有科室没有人员管理编码——>新建科室+新建联系人 |
| | | // GaDatas.GeData = new NFM624Rest.Gedata[] { GeData1 }; |
| | | // GeData1.ContactId = '958432058911227904'; |
| | | // GeData1.ServiceUserId = '958432058911227904'; |
| | | // GeData1.PersonManagementCode = ''; |
| | | // GeData1.HospitalManagementCode2 = '1375'; |
| | | // GeData1.DepartmentManagementCode2 = '1376'; |
| | | // GeData1.Name = '***'; |
| | | // GeData1.NameEncrypted = '24616254c7c7b65d985567f475b667d7'; |
| | | // GeData1.Mobile = '***********'; |
| | | // GeData1.MobileEncrypted = 'c34725fe79b3965ea9abfd7c1435cf9a'; |
| | | // GeData1.State = '北京市'; |
| | | // GeData1.City = '西城区'; |
| | | // GeData1.AccountName = '北京德胜门中医院'; |
| | | // GeData1.RelatedHospital = '112358'; |
| | | // GeData1.DepartmentClass = '消化科'; |
| | | // GeData1.DepartmentName = '北京德胜门中医院 消化科 胃镜室'; |
| | | // GeData1.RelatedDepartment = '5311053'; |
| | | // GeData1.Type = '*****'; |
| | | // GeData1.TypeEncrypted = '53173e61ac22874aab5b8d1f802515db'; |
| | | // GeData1.ContactAddress = '**********'; |
| | | // GeData1.ContactAddressEncrypted = '121a09fd9e0e9b090c4aa9c95da52810'; |
| | | // GeData1.ForbiddenStatus = false; |
| | | // GeData1.RegSource = '1'; |
| | | // GeData1.AgentFlag = false; |
| | | // GeData1.ApproverID = hpowner.Id; |
| | | // GeData1.DataId = '958432058273693696'; |
| | | |
| | | // BatchIF_Log__c rowData = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624About', GaDatas.GeData); |
| | | // if (String.isBlank(rowData.Log__c) == false) |
| | | // NFM624RestAbout.execute(rowData.Id); |
| | | |
| | | |
| | | |
| | | //有医院有有科室没有人员管理编码——>更新联系人 |
| | | NFM624Rest.GeData GeData3 = new NFM624Rest.GeData(); |
| | | GaDatas.GeData = new NFM624Rest.Gedata[] { GeData3 }; |
| | | // GeData3.ContactId = '958432058911227904'; |
| | | //GeData3.ServiceUserId = '958432058911227904'; |
| | | GeData3.PersonManagementCode = ''; |
| | | GeData3.HospitalManagementCode2 = '1375'; |
| | | GeData3.DepartmentManagementCode2 = '1376'; |
| | | //GeData3.Name = '***'; |
| | | GeData3.NameEncrypted = '24616254c7c7b65d985567f475b667d7'; |
| | | //GeData3.Mobile = '***********'; |
| | | //GeData3.MobileEncrypted = 'c34725fe79b3965ea9abfd7c1435cf9a'; |
| | | //GeData3.State = '北京市'; |
| | | //GeData3.City = '西城区'; |
| | | GeData3.AccountName = '北京德胜门中医院'; |
| | | GeData3.RelatedHospital = '112358'; |
| | | GeData3.DepartmentClass = '消化科'; |
| | | GeData3.DepartmentName = '北京德胜门中医院 消化科 胃镜室'; |
| | | GeData3.RelatedDepartment = '5311053'; |
| | | //GeData3.Type = '*****'; |
| | | //GeData3.TypeEncrypted = '53173e61ac22874aab5b8d1f802515db'; |
| | | //GeData3.ContactAddress = '**********'; |
| | | //GeData3.ContactAddressEncrypted = '121a09fd9e0e9b090c4aa9c95da52810'; |
| | | //GeData3.ForbiddenStatus = false; |
| | | //GeData3.RegSource = '1'; |
| | | //GeData3.AgentFlag = false; |
| | | //GeData3.ApproverID = hpowner.Id; |
| | | GeData3.DataId = '958432058273693696'; |
| | | |
| | | BatchIF_Log__c rowData3 = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624About', GaDatas.GeData); |
| | | if (String.isBlank(rowData3.Log__c) == false){ |
| | | NFM624RestAbout.executefuture(rowData3.Id); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>54.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
New file |
| | |
| | | @isTest |
| | | private class NFM624RestTest { |
| | | static testMethod void testMethod1(){ |
| | | oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | BatchIF_Log__c testLog = new BatchIF_Log__c(); |
| | | testLog.CurrencyIsoCode = 'CNY'; |
| | | testLog.Type__c = 'NFM624'; |
| | | testLog.MessageGroupNumber__c = '123456789987'; |
| | | // testLog.Name = '20211207'; |
| | | testLog.ErrorLog__c = ''; |
| | | testLog.MessageGroupNumber__c = '20211207'; |
| | | testLog.RowDataFlg__c = true; |
| | | testLog.Log__c = '[{"TypeEncrypted":"53173e61ac22874aab5b8d1f802515db","Type":"*****","State":"北京市","ServiceUserId":"958717798199066624","RelatedHospital":"8020739","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","NameEncrypted":"d5cd51938e71eebbc0641f4e976146e7","Name":"***","MobileEncrypted":"c34725fe79b3965ea9abfd7c1435cf9a","Mobile":"***********","HospitalManagementCode2":"1377","ForbiddenStatus":false,"DepartmentName":"普外科","DepartmentManagementCode2":"1378","DepartmentClass":"普外科","DataId":"958717797737693184","ContactId":"958717798199066624","ContactAddressEncrypted":"","ContactAddress":"","City":"昌平区","ApproverID":"om003669","AgentFlag":false,"AccountName":"北京京都儿童医院"}]'; |
| | | //[Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id] |
| | | insert testLog; |
| | | NFM624Rest.main(testLog.Id); |
| | | } |
| | | static testMethod void testMethod2(){ |
| | | oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | //Test.startTest(); |
| | | //用户 |
| | | User hpowner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2'); |
| | | insert hpowner; |
| | | |
| | | User hpowner2 = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp1', Work_Location__c = '北京', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner1@sunbridge.com', Username = 'olympus_hpowner1@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2'); |
| | | insert hpowner2; |
| | | |
| | | //医院 |
| | | Account hp = new Account(RecordTypeId = '01210000000QemG', Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.Advance_Payment_Identification_Approval__c = Date.today().addyears(-1); |
| | | insert hp; |
| | | Account hptemp = [select Id,PlatformCode__c,AgentCode_Ext__c from Account where Id = :hp.Id]; |
| | | //战略科室 |
| | | Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_BF']; |
| | | |
| | | //科室 |
| | | // Account dpt = new Account(RecordTypeId = '01210000000QfmR'); |
| | | // dpt.Name = '*'; |
| | | // dpt.Department_Name__c = 'TestDepart'; |
| | | // dpt.ParentId = dc.Id; |
| | | // dpt.Department_Class__c = dc.Id; |
| | | // dpt.Hospital__c = hp.Id; |
| | | // insert dpt; |
| | | |
| | | //科室1 |
| | | Account dpt1 = new Account(); |
| | | dpt1.RecordTypeId = '01210000000QfmR'; |
| | | dpt1.Name = '123'; |
| | | dpt1.Department_Name__c = 'TestDepart1'; |
| | | dpt1.ParentId = dc.Id; |
| | | dpt1.Department_Class__c = dc.Id; |
| | | dpt1.Hospital__c = hp.Id; |
| | | insert dpt1; |
| | | |
| | | RestRequest req = new RestRequest(); |
| | | RestResponse res = new RestResponse(); |
| | | |
| | | String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"202107131529","Text":null,"Tag":null,"Sender":"OBPM","Receiver":"SFDC","NumberOfRecord":"2","MessageType":"NFM624","MessageGroupNumber":null},"GeData":[{"TypeEncrypted":"53173e61ac22874aab5b8d1f802515db","Type":"*****","State":"北京市","ServiceUserId":"958717798199066624","RelatedHospital":"8020739","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","NameEncrypted":"d5cd51938e71eebbc0641f4e976146e7","Name":"***","MobileEncrypted":"c34725fe79b3965ea9abfd7c1435cf9a","Mobile":"***********","HospitalManagementCode2":"1377","ForbiddenStatus":false,"DepartmentName":"普外科","DepartmentManagementCode2":"1378","DepartmentClass":"普外科","DataId":"958717797737693184","ContactId":"958717798199066624","ContactAddressEncrypted":"","ContactAddress":"","City":"昌平区","ApproverID":"om003669","AgentFlag":false,"AccountName":"北京京都儿童医院"}]}'; |
| | | req.requestURI = 'services/apexrest/NFM624/execute'; |
| | | req.httpMethod = 'POST'; |
| | | req.requestBody = Blob.valueof(JsonMsg); |
| | | RestContext.request = req; |
| | | RestContext.response= res; |
| | | |
| | | NFM624Rest.execute(); |
| | | |
| | | RestRequest req2 = new RestRequest(); |
| | | RestResponse res2 = new RestResponse(); |
| | | |
| | | String JsonMsg2 = '{"Monitoring":{"TransmissionDateTime":"202107131529","Text":null,"Tag":null,"Sender":"OBPM","Receiver":"SFDC","NumberOfRecord":"2","MessageType":"NFM624","MessageGroupNumber":null},"GeData":[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"'+hptemp.PlatformCode__c+'","RelatedDepartment":" ","RegSource":"2","PersonManagementCode":"C000132345","Name":"刘璐","Mobile":"13683268803","HospitalManagementCode2":"415","ForbiddenStatus":true,"DepartmentName":"北京大学第三医院 呼吸科 呼吸科","DepartmentManagementCode2":"416","DepartmentClass":"呼吸科","ContactId":"2552","ContactAddress":"","City":"海淀区","ApproverID":"","AgentFlag":false,"AccountName":"北京大学第三医院"}]}'; |
| | | req2.requestURI = 'services/apexrest/NFM624/execute'; |
| | | req2.httpMethod = 'POST'; |
| | | req2.requestBody = Blob.valueof(JsonMsg2); |
| | | RestContext.request = req2; |
| | | RestContext.response= res2; |
| | | |
| | | NFM624Rest.execute(); |
| | | |
| | | //Test.stopTest(); |
| | | } |
| | | static testMethod void testMethod3(){ |
| | | oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | BatchIF_Log__c testLog = new BatchIF_Log__c(); |
| | | testLog.CurrencyIsoCode = 'CNY'; |
| | | testLog.Type__c = 'NFM624'; |
| | | testLog.MessageGroupNumber__c = '123456789987'; |
| | | // testLog.Name = '20211207'; |
| | | testLog.ErrorLog__c = ''; |
| | | testLog.MessageGroupNumber__c = '20211207'; |
| | | testLog.RowDataFlg__c = true; |
| | | testLog.Log__c = '[{"TypeEncrypted":"53173e61ac22874aab5b8d1f802515db","Type":"*****","State":"北京市","ServiceUserId":"","RelatedHospital":"","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","NameEncrypted":"24616254c7c7b65d985567f475b667d7","Name":"***","MobileEncrypted":"c34725fe79b3965ea9abfd7c1435cf9a","Mobile":"***********","HospitalManagementCode2":"","ForbiddenStatus":false,"DepartmentName":"北京德胜门中医院 消化科 胃镜室","DepartmentManagementCode2":"","DepartmentClass":"消化科","DataId":"958432058273693696","ContactId":"958432058911227904","ContactAddressEncrypted":"121a09fd9e0e9b090c4aa9c95da52810","ContactAddress":"**********","City":"西城区","ApproverID":"om003669","AgentFlag":false,"AccountName":"北京德胜门中医院"}]'; |
| | | //[Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id] |
| | | insert testLog; |
| | | NFM624Rest.main(testLog.Id); |
| | | |
| | | // BatchIF_Log__c testLog2 = new BatchIF_Log__c(); |
| | | // testLog2.CurrencyIsoCode = 'CNY'; |
| | | // testLog2.Type__c = 'NFM624'; |
| | | // testLog2.MessageGroupNumber__c = '123456789987'; |
| | | // // testLog.Name = '20211207'; |
| | | // testLog2.ErrorLog__c = ''; |
| | | // testLog2.MessageGroupNumber__c = '20211207'; |
| | | // testLog2.RowDataFlg__c = true; |
| | | // testLog2.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"8087702","RelatedDepartment":"8087702","RegSource":"1","PersonManagementCode":"","Name":"张三","Mobile":"17734281527","HospitalManagementCode2":"1118000","ForbiddenStatus":false,"DepartmentName":"消化神经科","DepartmentManagementCode2":"1118001","DepartmentClass":"消化科","ContactId":"1118002","ContactAddress":"北京市朝阳区亮马桥","City":"朝阳区","AgentFlag":false,"AccountName":"恩惠医院"}]'; |
| | | // //[Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id] |
| | | // insert testLog2; |
| | | // NFM624Rest.main(testLog2.Id); |
| | | |
| | | // BatchIF_Log__c testLog3 = new BatchIF_Log__c(); |
| | | // testLog3.CurrencyIsoCode = 'CNY'; |
| | | // testLog3.Type__c = 'NFM624'; |
| | | // testLog3.MessageGroupNumber__c = '123456789987'; |
| | | // // testLog.Name = '20211207'; |
| | | // testLog3.ErrorLog__c = ''; |
| | | // testLog3.MessageGroupNumber__c = '20211207'; |
| | | // testLog3.RowDataFlg__c = true; |
| | | // testLog3.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","Name":"张三","Mobile":"17734281527","HospitalManagementCode2":"1118000","ForbiddenStatus":false,"DepartmentName":"消化神经科","DepartmentManagementCode2":"1118001","DepartmentClass":"消化科","ContactId":"1118002","ContactAddress":"北京市朝阳区亮马桥","City":"朝阳区","AgentFlag":false,"AccountName":"恩惠医院"}]'; |
| | | // //[Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id] |
| | | // insert testLog3; |
| | | // NFM624Rest.main(testLog3.Id); |
| | | |
| | | // BatchIF_Log__c testLog4 = new BatchIF_Log__c(); |
| | | // testLog4.CurrencyIsoCode = 'CNY'; |
| | | // testLog4.Type__c = 'NFM624'; |
| | | // testLog4.MessageGroupNumber__c = '123456789987'; |
| | | // // testLog.Name = '20211207'; |
| | | // testLog4.ErrorLog__c = ''; |
| | | // testLog4.MessageGroupNumber__c = '20211207'; |
| | | // testLog4.RowDataFlg__c = true; |
| | | // testLog4.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","Name":"胖达","Mobile":"17734281527","HospitalManagementCode2":"1118000","ForbiddenStatus":true,"DepartmentName":"消化神经混合科","DepartmentManagementCode2":"1118004","DepartmentClass":"消化科","ContactId":"1118002","ContactAddress":"北京市朝阳区亮马桥","City":"朝阳区","AgentFlag":false,"AccountName":"恩惠医院"}]'; |
| | | // //[Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id] |
| | | // insert testLog4; |
| | | // NFM624Rest.main(testLog4.Id); |
| | | |
| | | BatchIF_Log__c testLog5 = new BatchIF_Log__c(); |
| | | testLog5.CurrencyIsoCode = 'CNY'; |
| | | testLog5.Type__c = 'NFM624'; |
| | | testLog5.MessageGroupNumber__c = '123456789987'; |
| | | // testLog.Name = '20211207'; |
| | | testLog5.ErrorLog__c = ''; |
| | | testLog5.MessageGroupNumber__c = '20211207'; |
| | | testLog5.RowDataFlg__c = true; |
| | | testLog5.Log__c = '[{"TypeEncrypted":"53173e61ac22874aab5b8d1f802515db","Type":"*****","State":"北京市","ServiceUserId":"958432058911227904","RelatedHospital":"3728239","RelatedDepartment":"5311053","RegSource":"1","PersonManagementCode":"","NameEncrypted":"24616254c7c7b65d985567f475b667d7","Name":"***","MobileEncrypted":"c34725fe79b3965ea9abfd7c1435cf9a","Mobile":"***********","HospitalManagementCode2":"1375","ForbiddenStatus":false,"DepartmentName":"北京德胜门中医院 消化科 胃镜室","DepartmentManagementCode2":"1376","DepartmentClass":"消化科","DataId":"958432058273693696","ContactId":"958432058911227904","ContactAddressEncrypted":"121a09fd9e0e9b090c4aa9c95da52810","ContactAddress":"**********","City":"西城区","ApproverID":"om003669","AgentFlag":false,"AccountName":"北京德胜门中医院"}]'; |
| | | //[Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id] |
| | | upsert testLog5; |
| | | NFM624Rest.main(testLog5.Id); |
| | | } |
| | | static testMethod void testMethod4(){ |
| | | oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | //用户 |
| | | User hpowner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2'); |
| | | insert hpowner; |
| | | |
| | | User hpowner2 = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp1', Work_Location__c = '北京', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner1@sunbridge.com', Username = 'olympus_hpowner1@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2'); |
| | | insert hpowner2; |
| | | |
| | | //医院 |
| | | Account hp = new Account(RecordTypeId = '01210000000QemG', Name = '北京德胜门中医院', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.Advance_Payment_Identification_Approval__c = Date.today().addyears(-1); |
| | | hp.AgentCode_Ext__c = '112358'; |
| | | hp.PlatformCode__c = '1375'; |
| | | hp.Is_Active__c = '有効'; |
| | | insert hp; |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | inquiryform.Name = '2019102101'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.ContactId__c = '958432058911227904'; |
| | | insert inquiryform; |
| | | |
| | | Account hptemp = [select Id,PlatformCode__c,AgentCode_Ext__c,Is_Active_Formula__c from Account where Id = :hp.Id]; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name,Parent_PlatformCode__c,Parent_Management_Code__c, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_BF']; |
| | | |
| | | NFM624Rest.GeData GeData1 = new NFM624Rest.GeData(); |
| | | NFM624Rest.GeDatas GaDatas = new NFM624Rest.GeDatas(); |
| | | |
| | | Datetime nowDT = Datetime.now(); |
| | | String nowStr = nowDT.format('yyyyMMddHHmm'); |
| | | GaDatas.Monitoring = new NFMUtil.Monitoring(); |
| | | GaDatas.Monitoring.MessageGroupNumber = nowStr + '01'; |
| | | //有医院没有科室没有人员管理编码——>新建科室+新建联系人 |
| | | GaDatas.GeData = new NFM624Rest.Gedata[] { GeData1 }; |
| | | GeData1.ContactId = '958432058911227904'; |
| | | GeData1.ServiceUserId = '958432058911227904'; |
| | | GeData1.PersonManagementCode = ''; |
| | | GeData1.HospitalManagementCode2 = '1375'; |
| | | GeData1.DepartmentManagementCode2 = '1376'; |
| | | GeData1.Name = '***'; |
| | | GeData1.NameEncrypted = '24616254c7c7b65d985567f475b667d7'; |
| | | GeData1.Mobile = '***********'; |
| | | GeData1.MobileEncrypted = 'c34725fe79b3965ea9abfd7c1435cf9a'; |
| | | GeData1.State = '北京市'; |
| | | GeData1.City = '西城区'; |
| | | GeData1.AccountName = '北京德胜门中医院'; |
| | | GeData1.RelatedHospital = '112358'; |
| | | GeData1.DepartmentClass = '消化科'; |
| | | GeData1.DepartmentName = '北京德胜门中医院 消化科 胃镜室'; |
| | | GeData1.RelatedDepartment = '5311053'; |
| | | GeData1.Type = '*****'; |
| | | GeData1.TypeEncrypted = '53173e61ac22874aab5b8d1f802515db'; |
| | | GeData1.ContactAddress = '**********'; |
| | | GeData1.ContactAddressEncrypted = '121a09fd9e0e9b090c4aa9c95da52810'; |
| | | GeData1.ForbiddenStatus = false; |
| | | GeData1.RegSource = '1'; |
| | | GeData1.AgentFlag = false; |
| | | GeData1.ApproverID = hpowner.Id; |
| | | GeData1.DataId = '958432058273693696'; |
| | | |
| | | BatchIF_Log__c rowData = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624', GaDatas.GeData); |
| | | if (String.isBlank(rowData.Log__c) == false) |
| | | NFM624Rest.executefuture(rowData.Id); |
| | | |
| | | |
| | | NFM624Rest.GeData GeData2 = new NFM624Rest.GeData(); |
| | | GaDatas.GeData = new NFM624Rest.Gedata[] { GeData2 }; |
| | | GeData2.ContactId = ''; |
| | | GeData2.ServiceUserId = ''; |
| | | GeData2.PersonManagementCode = ''; |
| | | GeData2.HospitalManagementCode2 = ''; |
| | | GeData2.DepartmentManagementCode2 = ''; |
| | | GeData2.Name = ''; |
| | | GeData2.NameEncrypted = ''; |
| | | GeData2.Mobile = ''; |
| | | GeData2.MobileEncrypted = ''; |
| | | GeData2.State = ''; |
| | | GeData2.City = ''; |
| | | GeData2.AccountName = ''; |
| | | GeData2.RelatedHospital = ''; |
| | | GeData2.DepartmentClass = ''; |
| | | GeData2.DepartmentName = ''; |
| | | GeData2.RelatedDepartment = ''; |
| | | GeData2.Type = ''; |
| | | GeData2.TypeEncrypted = ''; |
| | | GeData2.ContactAddress = ''; |
| | | GeData2.ContactAddressEncrypted = ''; |
| | | GeData2.ForbiddenStatus = false; |
| | | GeData2.RegSource = ''; |
| | | GeData2.AgentFlag = false; |
| | | GeData2.ApproverID = ''; |
| | | GeData2.DataId = ''; |
| | | |
| | | |
| | | BatchIF_Log__c rowData2 = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624', GaDatas.GeData); |
| | | if (String.isBlank(rowData2.Log__c) == false){ |
| | | NFM624Rest.executefuture(rowData2.Id); |
| | | } |
| | | |
| | | NFM624Rest.GeData GeData6 = new NFM624Rest.GeData(); |
| | | GaDatas.GeData = new NFM624Rest.Gedata[] { GeData6 }; |
| | | GeData6.ContactId = ''; |
| | | GeData6.ServiceUserId = ''; |
| | | GeData6.PersonManagementCode = ''; |
| | | GeData6.HospitalManagementCode2 = ''; |
| | | GeData6.DepartmentManagementCode2 = ''; |
| | | GeData6.Name = ''; |
| | | GeData6.NameEncrypted = ''; |
| | | GeData6.Mobile = ''; |
| | | GeData6.MobileEncrypted = ''; |
| | | GeData6.State = ''; |
| | | GeData6.City = ''; |
| | | GeData6.AccountName = ''; |
| | | GeData6.RelatedHospital = ''; |
| | | GeData6.DepartmentClass = ''; |
| | | GeData6.DepartmentName = ''; |
| | | GeData6.RelatedDepartment = ''; |
| | | GeData6.Type = ''; |
| | | GeData6.TypeEncrypted = ''; |
| | | GeData6.ContactAddress = ''; |
| | | GeData6.ContactAddressEncrypted = ''; |
| | | GeData6.ForbiddenStatus = false; |
| | | GeData6.RegSource = ''; |
| | | GeData6.AgentFlag = true; |
| | | GeData6.ApproverID = ''; |
| | | GeData6.DataId = ''; |
| | | |
| | | |
| | | BatchIF_Log__c rowData6 = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624', GaDatas.GeData); |
| | | if (String.isBlank(rowData6.Log__c) == false){ |
| | | NFM624Rest.executefuture(rowData6.Id); |
| | | } |
| | | |
| | | //有医院有有科室没有人员管理编码——>更新联系人 |
| | | NFM624Rest.GeData GeData3 = new NFM624Rest.GeData(); |
| | | GaDatas.GeData = new NFM624Rest.Gedata[] { GeData3 }; |
| | | GeData3.ContactId = '958432058911227904'; |
| | | GeData3.ServiceUserId = '958432058911227904'; |
| | | GeData3.PersonManagementCode = ''; |
| | | GeData3.HospitalManagementCode2 = '1375'; |
| | | GeData3.DepartmentManagementCode2 = '1376'; |
| | | GeData3.Name = '***'; |
| | | GeData3.NameEncrypted = '24616254c7c7b65d985567f475b667d7'; |
| | | GeData3.Mobile = '***********'; |
| | | GeData3.MobileEncrypted = 'c34725fe79b3965ea9abfd7c1435cf9a'; |
| | | GeData3.State = '北京市'; |
| | | GeData3.City = '西城区'; |
| | | GeData3.AccountName = '北京德胜门中医院'; |
| | | GeData3.RelatedHospital = '112358'; |
| | | GeData3.DepartmentClass = '消化科'; |
| | | GeData3.DepartmentName = '北京德胜门中医院 消化科 胃镜室'; |
| | | GeData3.RelatedDepartment = '5311053'; |
| | | GeData3.Type = '*****'; |
| | | GeData3.TypeEncrypted = '53173e61ac22874aab5b8d1f802515db'; |
| | | GeData3.ContactAddress = '**********'; |
| | | GeData3.ContactAddressEncrypted = '121a09fd9e0e9b090c4aa9c95da52810'; |
| | | GeData3.ForbiddenStatus = false; |
| | | GeData3.RegSource = '1'; |
| | | GeData3.AgentFlag = false; |
| | | GeData3.ApproverID = hpowner.Id; |
| | | GeData3.DataId = '958432058273693696'; |
| | | |
| | | BatchIF_Log__c rowData3 = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624', GaDatas.GeData); |
| | | if (String.isBlank(rowData3.Log__c) == false){ |
| | | NFM624Rest.executefuture(rowData3.Id); |
| | | } |
| | | NFM624RestAbout.GeDatas GaDatas2 = new NFM624RestAbout.GeDatas(); |
| | | NFM624RestAbout.GeData GeData5 = new NFM624RestAbout.GeData(); |
| | | GaDatas2.GeData = new NFM624RestAbout.Gedata[] { GeData5 }; |
| | | // GeData3.ContactId = '958432058911227904'; |
| | | //GeData3.ServiceUserId = '958432058911227904'; |
| | | GeData5.PersonManagementCode = ''; |
| | | GeData5.HospitalManagementCode2 = '1375'; |
| | | GeData5.DepartmentManagementCode2 = '1376'; |
| | | //GeData3.Name = '***'; |
| | | GeData5.NameEncrypted = '24616254c7c7b65d985567f475b667d7'; |
| | | //GeData3.Mobile = '***********'; |
| | | //GeData3.MobileEncrypted = 'c34725fe79b3965ea9abfd7c1435cf9a'; |
| | | //GeData3.State = '北京市'; |
| | | //GeData3.City = '西城区'; |
| | | GeData5.AccountName = '北京德胜门中医院'; |
| | | GeData5.RelatedHospital = '112358'; |
| | | GeData5.DepartmentClass = '消化科'; |
| | | GeData5.DepartmentName = '北京德胜门中医院 消化科 胃镜室'; |
| | | GeData5.RelatedDepartment = '5311053'; |
| | | //GeData3.Type = '*****'; |
| | | //GeData3.TypeEncrypted = '53173e61ac22874aab5b8d1f802515db'; |
| | | //GeData3.ContactAddress = '**********'; |
| | | //GeData3.ContactAddressEncrypted = '121a09fd9e0e9b090c4aa9c95da52810'; |
| | | //GeData3.ForbiddenStatus = false; |
| | | //GeData3.RegSource = '1'; |
| | | //GeData3.AgentFlag = false; |
| | | //GeData3.ApproverID = hpowner.Id; |
| | | GeData5.DataId = '958432058273693696'; |
| | | |
| | | BatchIF_Log__c rowData5 = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624About', GaDatas.GeData); |
| | | if (String.isBlank(rowData5.Log__c) == false){ |
| | | NFM624RestAbout.executefuture(rowData5.Id); |
| | | } |
| | | } |
| | | static testMethod void testMethod5(){ |
| | | oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | inquiryform.Name = '2019102101'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.ContactId__c = '958432058911227904'; |
| | | insert inquiryform; |
| | | |
| | | BatchIF_Log__c testLog = new BatchIF_Log__c(); |
| | | testLog.CurrencyIsoCode = 'CNY'; |
| | | testLog.Type__c = 'NFM624'; |
| | | testLog.MessageGroupNumber__c = '123456789987'; |
| | | testLog.ErrorLog__c = ''; |
| | | testLog.MessageGroupNumber__c = '20211207'; |
| | | testLog.RowDataFlg__c = true; |
| | | testLog.Log__c = '[{"TypeEncrypted":"53173e61ac22874aab5b8d1f802515db","Type":"*****","State":"北京市","ServiceUserId":"","RelatedHospital":"","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","NameEncrypted":"24616254c7c7b65d985567f475b667d7","Name":"***","MobileEncrypted":"c34725fe79b3965ea9abfd7c1435cf9a","Mobile":"***********","HospitalManagementCode2":"","ForbiddenStatus":false,"DepartmentName":"北京德胜门中医院 消化科 胃镜室","DepartmentManagementCode2":"","DepartmentClass":"消化科","DataId":"958432058273693696","ContactId":"958432058911227904","ContactAddressEncrypted":"121a09fd9e0e9b090c4aa9c95da52810","ContactAddress":"**********","City":"西城区","ApproverID":"om003669","AgentFlag":false,"AccountName":"北京德胜门中医院"}]'; |
| | | insert testLog; |
| | | NFM624Rest.main(testLog.Id); |
| | | |
| | | BatchIF_Log__c testLog5 = new BatchIF_Log__c(); |
| | | testLog5.CurrencyIsoCode = 'CNY'; |
| | | testLog5.Type__c = 'NFM624'; |
| | | testLog5.MessageGroupNumber__c = '123456789987'; |
| | | testLog5.ErrorLog__c = ''; |
| | | testLog5.MessageGroupNumber__c = '20211207'; |
| | | testLog5.RowDataFlg__c = true; |
| | | testLog5.Log__c = '[{"TypeEncrypted":"53173e61ac22874aab5b8d1f802515db","Type":"*****","State":"北京市","ServiceUserId":"958432058911227904","RelatedHospital":"3728239","RelatedDepartment":"5311053","RegSource":"1","PersonManagementCode":"","NameEncrypted":"24616254c7c7b65d985567f475b667d7","Name":"***","MobileEncrypted":"c34725fe79b3965ea9abfd7c1435cf9a","Mobile":"***********","HospitalManagementCode2":"1375","ForbiddenStatus":false,"DepartmentName":"北京德胜门中医院 消化科 胃镜室","DepartmentManagementCode2":"1376","DepartmentClass":"消化科","DataId":"958432058273693696","ContactId":"958432058911227904","ContactAddressEncrypted":"121a09fd9e0e9b090c4aa9c95da52810","ContactAddress":"**********","City":"西城区","ApproverID":"om003669","AgentFlag":false,"AccountName":"北京德胜门中医院"}]'; |
| | | upsert testLog5; |
| | | NFM624Rest.main(testLog5.Id); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>52.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |