From 9ec7864874be51f0458408e17f51873b5443e76c Mon Sep 17 00:00:00 2001 From: 涂煌豪 <tuhuanghao@prec-tech.com> Date: 星期一, 23 五月 2022 19:06:21 +0800 Subject: [PATCH] 客户人员重复逻辑修改 --- force-app/main/default/classes/NFM624Rest.cls-meta.xml | 5 force-app/main/default/classes/NFM624RestAboutTest.cls | 102 +++ force-app/main/default/classes/NFM624RestTest.cls-meta.xml | 5 force-app/main/default/classes/ContactTriggerHandlerTest.cls | 5 force-app/main/default/classes/NFM624RestTest.cls | 387 +++++++++++++ force-app/main/default/classes/ContactTriggerHandler.cls | 115 ++- force-app/main/default/classes/NFM624RestAbout.cls | 322 +++++++++++ force-app/main/default/classes/NFM624Rest.cls | 741 +++++++++++++++++++++++++ force-app/main/default/classes/NFM624RestAboutTest.cls-meta.xml | 5 force-app/main/default/classes/NFM624RestAbout.cls-meta.xml | 5 force-app/main/default/classes/ContactTriggerHandler.cls-meta.xml | 2 11 files changed, 1,656 insertions(+), 38 deletions(-) diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls b/force-app/main/default/classes/ContactTriggerHandler.cls index 3885c2c..2a374e0 100644 --- a/force-app/main/default/classes/ContactTriggerHandler.cls +++ b/force-app/main/default/classes/ContactTriggerHandler.cls @@ -140,13 +140,41 @@ // ) ) ) { - 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 } } @@ -227,7 +255,7 @@ // 鎵嬫満鍙峰幓閲嶅強瑙勫垯楠岃瘉 鍙婃柊澧炲鎴蜂汉鍛橀噸鍚嶉獙璇� 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>(); //鐢ㄦ埛瀵硅薄涓婃壘瀵瑰簲鐨勮仈绯讳汉 @@ -265,18 +293,20 @@ // 鎵嬫満鍙锋湁鍊煎苟涓旇仈绯讳汉鏈夋晥锛岃仈绯讳汉鐨勫鎴锋湁鏁堬紝杩涜鎵嬫満鍙风爜楠岃瘉 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; @@ -285,24 +315,26 @@ } } } - 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; } @@ -317,30 +349,37 @@ } } - 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>(); @@ -380,6 +419,8 @@ ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); ID AgencyRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); //鑾峰彇瀹㈡埛浜哄憳鐨勮褰曠被鍨婭D 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)) { diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls-meta.xml b/force-app/main/default/classes/ContactTriggerHandler.cls-meta.xml index 9aeda45..541584f 100644 --- a/force-app/main/default/classes/ContactTriggerHandler.cls-meta.xml +++ b/force-app/main/default/classes/ContactTriggerHandler.cls-meta.xml @@ -1,5 +1,5 @@ <?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> diff --git a/force-app/main/default/classes/ContactTriggerHandlerTest.cls b/force-app/main/default/classes/ContactTriggerHandlerTest.cls index 0f3665c..5f26f37 100644 --- a/force-app/main/default/classes/ContactTriggerHandlerTest.cls +++ b/force-app/main/default/classes/ContactTriggerHandlerTest.cls @@ -6,6 +6,11 @@ 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']; diff --git a/force-app/main/default/classes/NFM624Rest.cls b/force-app/main/default/classes/NFM624Rest.cls new file mode 100644 index 0000000..6af9655 --- /dev/null +++ b/force-app/main/default/classes/NFM624Rest.cls @@ -0,0 +1,741 @@ +/********************************************************************** + * + * + * @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 瀛樺偍鐨凙WSContactId 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鏂规硶锛屾垚鍔熻皟鐢╡xecutefuture'); + 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鍖婚櫌銆佺瀹ist + List < String > ManagementList = new List < String > (); //鍖婚櫌銆佺瀹ゅ钩鍙扮紪鐮丩ist + 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 > (); //鐪丮ap + 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 > (); //甯侻ap + 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 > (); + //鑱旂郴浜篖ist锛堟洿鏂扮敤锛� + 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缁忛攢鍟唗rue + 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 { //缁忛攢鍟唂lase + 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锛歅ersonManagementCode 浜哄憳绠$悊缂栫爜涓虹┖\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瀛楳ap + 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鐨刱-v鏀归�� thh 20220517 start + inquiryMap.put(inquiryInfo.Id, inquiryInfo.ContactId__c); + // map鐨刱-v鏀归�� thh 20220517 end + } + // map鐨刱-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鐨刱-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 + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/NFM624Rest.cls-meta.xml b/force-app/main/default/classes/NFM624Rest.cls-meta.xml new file mode 100644 index 0000000..91b23b8 --- /dev/null +++ b/force-app/main/default/classes/NFM624Rest.cls-meta.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> + <apiVersion>46.0</apiVersion> + <status>Active</status> +</ApexClass> diff --git a/force-app/main/default/classes/NFM624RestAbout.cls b/force-app/main/default/classes/NFM624RestAbout.cls new file mode 100644 index 0000000..fed64f7 --- /dev/null +++ b/force-app/main/default/classes/NFM624RestAbout.cls @@ -0,0 +1,322 @@ +/********************************************************************** + * + * + * @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鏂规硶锛屾垚鍔熻皟鐢╡xecutefuture'); + 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 > (); //鍖婚櫌銆佺瀹ゅ钩鍙扮紪鐮丩ist + List < String > NameList = new List < String >(); + Response responseList = new Response();//杩斿洖浣揕ist + 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; + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/NFM624RestAbout.cls-meta.xml b/force-app/main/default/classes/NFM624RestAbout.cls-meta.xml new file mode 100644 index 0000000..40d6793 --- /dev/null +++ b/force-app/main/default/classes/NFM624RestAbout.cls-meta.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> + <apiVersion>54.0</apiVersion> + <status>Active</status> +</ApexClass> diff --git a/force-app/main/default/classes/NFM624RestAboutTest.cls b/force-app/main/default/classes/NFM624RestAboutTest.cls new file mode 100644 index 0000000..f4b563c --- /dev/null +++ b/force-app/main/default/classes/NFM624RestAboutTest.cls @@ -0,0 +1,102 @@ +@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); + } + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/NFM624RestAboutTest.cls-meta.xml b/force-app/main/default/classes/NFM624RestAboutTest.cls-meta.xml new file mode 100644 index 0000000..40d6793 --- /dev/null +++ b/force-app/main/default/classes/NFM624RestAboutTest.cls-meta.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> + <apiVersion>54.0</apiVersion> + <status>Active</status> +</ApexClass> diff --git a/force-app/main/default/classes/NFM624RestTest.cls b/force-app/main/default/classes/NFM624RestTest.cls new file mode 100644 index 0000000..3643d61 --- /dev/null +++ b/force-app/main/default/classes/NFM624RestTest.cls @@ -0,0 +1,387 @@ +@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 = '瓒呭0'; + 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 = '瓒呭0'; + 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); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/NFM624RestTest.cls-meta.xml b/force-app/main/default/classes/NFM624RestTest.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/NFM624RestTest.cls-meta.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> + <apiVersion>52.0</apiVersion> + <status>Active</status> +</ApexClass> -- Gitblit v1.9.1