From 78ac43791ac9e9d75ce4c33e9dddbdffa88fec2f Mon Sep 17 00:00:00 2001
From: 涂煌豪 <tuhuanghao@prec-tech.com>
Date: 星期一, 23 五月 2022 19:00:04 +0800
Subject: [PATCH] 客户人员重复判断

---
 force-app/main/default/classes/NFM624RestAboutTest.cls          |  102 ++++++++++
 force-app/main/default/classes/ContactTriggerHandler.cls        |   57 +++--
 force-app/main/default/classes/NFM624RestAbout.cls              |  322 ++++++++++++++++++++++++++++++++
 force-app/main/default/classes/NFM624Rest.cls                   |   56 +++--
 force-app/main/default/classes/NFM624RestAboutTest.cls-meta.xml |    5 
 force-app/main/default/classes/NFM624RestAbout.cls-meta.xml     |    5 
 6 files changed, 501 insertions(+), 46 deletions(-)

diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls b/force-app/main/default/classes/ContactTriggerHandler.cls
index 54e167f..2a374e0 100644
--- a/force-app/main/default/classes/ContactTriggerHandler.cls
+++ b/force-app/main/default/classes/ContactTriggerHandler.cls
@@ -315,9 +315,9 @@
                     }
                 }
             }
-            if (Trigger.isInsert) {
-                accountIdSet.add(contactnew.AccountId);  
-            }   
+            // if (Trigger.isInsert) {
+            accountIdSet.add(contactnew.AccountId);  
+            // }   
         }
         //鎵嬫満鍙峰敮涓�鏍¢獙-鍖婚櫌涓嬫柊寤哄鎴蜂汉鍛樻牎楠屼娇鐢ㄥ姞瀵嗘墜鏈哄彿,缁忛攢鍟嗕娇鐢ㄦ櫘閫氭墜鏈哄彿 thh 20220328 end
         // 鏂板鑱旂郴浜烘椂锛�
@@ -349,32 +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);
-                    // 閫氳繃濮撳悕+鎵嬫満鍙峰垽鏂汉鍛樻槸鍚﹂噸澶� 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 (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>();
diff --git a/force-app/main/default/classes/NFM624Rest.cls b/force-app/main/default/classes/NFM624Rest.cls
index bbaf611..6af9655 100644
--- a/force-app/main/default/classes/NFM624Rest.cls
+++ b/force-app/main/default/classes/NFM624Rest.cls
@@ -244,17 +244,28 @@
                 for (Contact ct: peopleList) {
                     if (string.isnotblank(ct.Account.parent.Name)) {
                         Map < String, Contact > snameMap = new Map < String, Contact > ();
-                        string namekey = ct.Account.Name + ' ' + ct.LastName_Encrypted__c.trim();
-                        string nameKey2 = ct.Account.Management_Code__c + ' ' + ct.LastName_Encrypted__c.trim();
+                        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
-                        snameMap.put(ct.LastName_Encrypted__c.trim() + ct.MobilePhone_Encrypted__c.trim(), ct);
-                        // 閫氳繃濮撳悕+鎵嬫満鍙峰垽鏂汉鍛樻槸鍚﹂噸澶� thh 20220518 end
+                        // // 閫氳繃濮撳悕+鎵嬫満鍙峰垽鏂汉鍛樻槸鍚﹂噸澶� 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);
                     }
@@ -394,7 +405,8 @@
                                     } else { //浜哄憳绠$悊缂栫爜涓嶅瓨鍦�
                                         //鎼滅储浜哄悕/涓斿湪褰撳墠鎴樼暐绉戝绉戝涓�
                                         System.debug('浜哄憳绠$悊缂栫爜涓嶅瓨鍦�');
-                                        string namekey = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted;
+                                        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 瀹屾垚 鏇存柊鎿嶄綔
@@ -402,13 +414,16 @@
                                             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) && sMap.get(namekey).UnifiedI_Contact_ID__c == null) {
+                                            if (sMap.containsKey(namekey)) {
                                                 system.debug('Id璧嬪��'+sMap);
                                                 ct.id = sMap.get(namekey).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 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閫昏緫 鏃犱汉鍛樼鐞嗙紪鐮� 鏈夊尰闄� 鏈夌瀹� 浜哄悕鏌ユ壘鏃� 鍔ㄤ綔锛氭柊寤鸿仈绯讳汉 ');
                                             }
@@ -441,7 +456,7 @@
                                         }
                                     } else { //浜哄憳绠$悊缂栫爜涓嶅瓨鍦�
                                         system.debug('浜哄憳绠$悊缂栫爜涓嶅瓨鍦�');
-                                        string namekey = gedata.DepartmentName+ ' ' + gedata.NameEncrypted;
+                                        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);
@@ -450,8 +465,8 @@
                                             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) && sMap.get(namekey).UnifiedI_Contact_ID__c == null) { //鏌ユ壘瀛樺湪 8 瀹屾垚
+                                            system.debug('sMap.containsKey(namekey)'+sMap.containsKey(namekey));
+                                            if (sMap.containsKey(namekey)) { //鏌ユ壘瀛樺湪 8 瀹屾垚
                                                 system.debug('8閫昏緫');
                                                 system.debug('璇ヨ仈绯讳汉瀛樺湪');
                                                 ct.id = sMap.get(namekey).id;
@@ -460,13 +475,14 @@
                                                 // 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 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閫昏緫');
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>

--
Gitblit v1.9.1