From 87dbb4ae09e5e16ff2e39199f2617f4847420ad7 Mon Sep 17 00:00:00 2001
From: 彭锟 <pengkun@prec-tech.com>
Date: 星期四, 24 三月 2022 17:38:54 +0800
Subject: [PATCH] NFM624 324 回滚
---
force-app/main/default/classes/NFM624Rest.cls | 177 ++++++++++++++++++++++++++++-------------------------------
1 files changed, 84 insertions(+), 93 deletions(-)
diff --git a/force-app/main/default/classes/NFM624Rest.cls b/force-app/main/default/classes/NFM624Rest.cls
index ad8dc2e..1be71db 100644
--- a/force-app/main/default/classes/NFM624Rest.cls
+++ b/force-app/main/default/classes/NFM624Rest.cls
@@ -7,27 +7,33 @@
}
*************************************************************************/
-
+
@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
+ 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; //鍖婚櫌鍚�
@@ -36,55 +42,66 @@
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 Boolean ForbiddenStatus; //骞冲彴鐢ㄦ埛绂佺敤鏍囪瘑
+ 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);
+ // 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('','')
Map < string, string > RecordTypeMap = new Map < string, string > (); //瀛樻斁璁板綍绫诲瀷Id
@@ -105,7 +122,7 @@
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) {
@@ -119,7 +136,7 @@
// continue;
// }
// }
-
+
Savepoint sp = Database.setSavepoint();
List<string> ApproverIDList = new List <string>();//
List < string > PersonManagementCodeList = new List < String > (); //浜哄憳绠$悊缂栫爜List
@@ -130,7 +147,11 @@
try { //鏍规嵁浼犺繃鏉ョ殑绠$悊缂栫爜鏌ヨ濡傛灉鍙互鏌ヨ寰楀埌缁撴灉鍒欐洿鏂帮紝鏌ヨ涓嶅埌鍒欐柊澧�
List < Gedata > newGeDataList = new List < Gedata > ();
for (Gedata gedata: GeDataList) {
- string dataComplete = verify(gedata);
+ //for test
+ gedata.AgentFlag=false;
+ // string dataComplete = verify(gedata);
+ string dataComplete =null;
+ // test end for pi
if (!String.isBlank(dataComplete)) {
logstr += dataComplete;
rowData.Is_Error__c = 1;
@@ -140,8 +161,12 @@
StateList.add(gedata.State);
CityList.add(gedata.City);
ApproverIDList.add(gedata.ApproverID);
- ManagementList.add(gedata.HospitalManagementCode2);
- ManagementList.add(gedata.DepartmentManagementCode2);
+ 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);
@@ -171,21 +196,21 @@
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,
@@ -225,7 +250,7 @@
//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];
@@ -255,42 +280,49 @@
}
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' ? '鏅烘収鍖荤枟' : '鏈嶅姟瀹㈡埛绔�'; //骞冲彴鏉ユ簮
-
+
//鏂板缓鍖婚櫌
Account hp = new Account();
-
+
//鏂板缓鑱旂郴浜�
Contact ct = new Contact();
ct.LastName = gedata.Name;
ct.FirstName = '';
ct.Type__c = gedata.Type;
+ ct.Type_Encrypted__c = gedata.TypeEncrypted;//add for pipl sushanhu 20220316
ct.MobilePhone = gedata.Mobile;
ct.RegSource__c = comefrom;
ct.UnifiedI_Contact_ID__c = gedata.ContactId; //缁熶竴骞冲彴Id
+ // //UPDATE TO AWS 瀛樺偍鐨勭粺涓�骞冲彴id
+ // ct.AWS_UnifiedI_Contact_ID__c=gedata.ContactId; //缁熶竴骞冲彴Id
ct.ServicePlatformCode__c = gedata.ServiceUserId; //鏈嶅姟骞冲彴鐢ㄦ埛Id
ct.Contact_address__c = gedata.ContactAddress;//鑱旂郴鍦板潃
+ ct.Contact_address_Encrypted__c=gedata.ContactAddressEncrypted;//鑱旂郴鍦板潃瀵嗘枃 add 20220215
ct.Platform_disabled_representation__c = gedata.ForbiddenStatus;//骞冲彴绂佺敤鏍囪瘑
//ct.IsFromPlatform__c = true; //鏉ヨ嚜鏅烘収鍖荤枟鍒涘缓
ct.Ignore_Same_Name__c = true; //涓嶆槸閲嶅鐨勫鎴峰悕
//ct.SendToComPlat__c = true;
-
+ ct.AWS_Data_Id__c =gedata.DataId;//add 20220215 aws瀛樺偍鍑瘉
+ ct.MobilePhone_Encrypted__c =gedata.MobileEncrypted;//add 20220215 鎵嬫満瀵嗘枃
+ ct.LastName_Encrypted__c =gedata.NameEncrypted;//add 20220215 濮撳悕瀵嗘枃
+
String personCode = gedata.PersonManagementCode;
-
+
Map < String, Contact > contactMap = new Map < String, Contact > ();//鐢ㄤ簬鏆傚瓨鏇存柊鑱旂郴浜�
//1缁忛攢鍟唗rue
if (gedata.AgentFlag == true) {
@@ -454,7 +486,7 @@
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);
@@ -506,7 +538,7 @@
}
update iflog;
}
-
+
private static String verify(GeData gda) {
String result = '';
if (string.isblank(gda.ContactId)) {
@@ -518,11 +550,19 @@
if (string.isblank(gda.Name)) {
result += 'DataError锛氬鍚嶄负绌篭n';
}
+ if (string.isblank(gda.NameEncrypted)) {
+ result += 'DataError锛氬鍚嶅瘑鏂囦负绌篭n';
+ }
if (string.isblank(gda.Mobile)) {
result += 'DataError锛氭墜鏈哄彿涓虹┖\n';
}
+ if (string.isblank(gda.MobileEncrypted)) {
+ result += 'DataError锛氭墜鏈哄彿瀵嗘枃涓虹┖\n';
+ }
if (string.isblank(gda.RegSource)) {
result += 'DataError锛氭敞鍐屽钩鍙版潵婧愪负绌篭n';
+ }if (string.isblank(gda.DataId)) {
+ result += 'DataError锛欰WS鍔犲瘑鍑嵁涓虹┖\n';
}
if (gda.AgentFlag) {
if (string.isblank(gda.PersonManagementCode)) {
@@ -559,55 +599,7 @@
}
return result;
}
- // global static String contactAllName(String contactName){
- // // 涓浗 澶嶅澶у叏
- // String CompoundSurname = '婵槼銆佸叕鍐躲�佸お鍙斻�佺敵灞犮�佸叕瀛欍�佹厱瀹广�佷徊瀛欍�侀挓绂汇�侀暱瀛欍�佸畤鏂囥�佸徃寰掋�侀矞浜庛�佸徃绌恒�侀椌涓樸�佸瓙杞︺�佷簱瀹樸�佸徃瀵囥�佸帆椹�佸叕瑗裤�侀瀛欍�佸¥椹枫�佸叕鑹�佹紗闆曘�佷箰姝c�佸鐖躲�佽胺姊併�佹嫇璺嬨�佸す璋枫�佽僵杈曘�佷护鐙愩�佹骞层�佺櫨閲屻�佸懠寤躲�佷笢閮�佸崡闂ㄣ�佺緤鑸屻�佸井鐢熴�佸叕鎴枫�佸叕鐜夈�佸叕浠�佹涓樸�佸叕浠层�佸叕涓娿�佸叕闂ㄣ�佸叕灞便�佸叕鍧氥�佸乏涓樸�佸叕浼�佽タ闂ㄣ�佸叕绁栥�佺浜斻�佸叕涔樸�佽疮涓樸�佸叕鐨欍�佸崡鑽c�佷笢閲屻�佷笢瀹�佷徊闀裤�佸瓙涔︺�佸瓙妗戙�佸嵆澧ㄣ�佽揪濂氥�佽甯堛�佸惔閾�';
- // // string allname = '鏈卞惎璐�';
- // // contactName = '绗簲鎯嗘��';
- // String lastName = '';
- // String firstName = '';
- // String result = '';
- // if (contactName.contains('路')) {
- // lastName = contactName.split('路')[0];
- // firstName = contactName.split('路')[1];
- // } else {
- // if (contactName.length() > 2) {
-
- // system.debug('CompoundSurname--->01' + contactName.subString(0, 2));
- // if (CompoundSurname.contains(contactName.subString(0, 2))) {
- // lastName = contactName.substring(0,2);
- // firstName = contactName.substring(2,contactName.length());
- // system.debug('lastName--->'+lastName);
- // system.debug('firstName--->'+firstName);
- // } else {
- // lastName = contactName.substring(0,1);
- // firstName = contactName.substring(1,contactName.length());
- // system.debug('lastName--->'+lastName);
- // system.debug('firstName--->'+firstName);
- // }
- // } else {
- // if (contactName.length() == 2) {
- // lastName = contactName.substring(0,1);
- // firstName = contactName.substring(1,contactName.length());
- // system.debug('lastName--->'+lastName);
- // system.debug('firstName--->'+firstName);
- // } else {
- // lastName = contactName;
- // firstName = contactName;
- // system.debug('lastName--->'+lastName);
- // system.debug('firstName--->'+firstName);
- // }
- // }
- // }
- // if (!contactName.equals(lastName+firstName)) {
- // lastName = contactName;
- // firstName = contactName;
- // }
- // result = lastName + '_' + firstName;
- // //system.debug('CompoundSurname--->02' + CompoundSurname);
- // return result;
- // }
-
+
private static void supplement (String ContactId){
//鎶�620Batch 鍜� 623Batch 鎼繃鏉�
//琛ュ厖璇㈤棶鍗曢儴鍒� start
@@ -618,12 +610,11 @@
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鏌ヨ鑱旂郴浜�
- //select Id,Name,UnifiedI_Contact_ID__c,AccountId,Account.Name from Contact
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);
-
+ system.debug('contactList' + contactList);
+
if(InquiryList.size()>0){
- //缁熶竴鐢ㄦ埛ID瀛樺叆List銆佽闂崟ID瀛楳ap
+ //缁熶竴鐢ㄦ埛ID瀛樺叆List銆佽闂崟ID瀛楳ap
Map<String, String> inquiryMap = new Map<String, String>();
//List<String> contactIdList = new List<String>();
for (Inquiry_form__c inquiryInfo : inquiryList) {
@@ -649,7 +640,8 @@
//琛ュ厖璇㈤棶鍗曢儴鍒� end
//琛ュ厖瀛︿細閮ㄥ垎 start
- List<CampaignMember__c> capMemList = [select Id,Contact_ID__c,Campaign__c,Campaign__r.Num__c,ViewContactId__c from CampaignMember__c where ViewContactId__c = :ContactId];
+ //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>();
@@ -680,4 +672,3 @@
}
//琛ュ厖瀛︿細閮ㄥ垎 end
}
-}
\ No newline at end of file
--
Gitblit v1.9.1