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 |  264 +++++++++++-----------------------------------------
 1 files changed, 58 insertions(+), 206 deletions(-)

diff --git a/force-app/main/default/classes/NFM624Rest.cls b/force-app/main/default/classes/NFM624Rest.cls
index c935195..1be71db 100644
--- a/force-app/main/default/classes/NFM624Rest.cls
+++ b/force-app/main/default/classes/NFM624Rest.cls
@@ -7,7 +7,7 @@
         
     }
 *************************************************************************/
-
+ 
 @RestResource(urlMapping = '/NFM624/*')
 global with sharing class NFM624Rest {
     //add to AWS 鍥炲 start sushanhu 20220225 
@@ -18,12 +18,12 @@
     // 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
@@ -51,31 +51,31 @@
         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');
@@ -92,16 +92,16 @@
          //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 
@@ -122,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) {
@@ -136,7 +136,7 @@
         //         continue;
         //     }
         // }
-
+ 
         Savepoint sp = Database.setSavepoint();
         List<string> ApproverIDList = new List <string>();//
         List < string > PersonManagementCodeList = new List < String > (); //浜哄憳绠$悊缂栫爜List
@@ -190,28 +190,27 @@
                 for (Address_Level__c temp: statetempList) {
                     StateMap.put(temp.Name, temp.Id);
                 }
-                system.debug('StateMap----->'+StateMap);
                 //鏌ヨ甯傚尯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);
                 }
-                system.debug('CityMap----->'+CityMap);
+ 
                 //鏌ヨ鍖婚櫌鎵�鏈変汉
                 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, 
@@ -221,15 +220,13 @@
                                                       Account.PlatformCode__c, 
                                                       Account.Management_Code__c, 
                                                       Account.parent.Department_Class_Label__c, 
-                                                      Name,LastName_Encrypted__c,
+                                                      Name, 
                                                       Account.Parent_Management_Code__c, 
                                                       Account.Parent_PlatformCode__c, 
-                                                      CManageCode__c,
+                                                      CManageCode__c, 
                                                       AccountId 
                                                       from Contact 
                                                       where CManageCode__c IN: PersonManagementCodeList 
-                                                      OR Account.PlatformCode__c IN: ManagementList
-                                                      OR Account.Management_Code__c IN: SFDCCodeList
                                                       OR Account.Parent_PlatformCode__c IN: ManagementList 
                                                       OR Account.Parent_Management_Code__c IN: SFDCCodeList]; //鏍规嵁浜哄憳绠$悊缂栫爜妫�绱㈣仈绯讳汉
                 Map < String, Contact > peopleMap = new Map < String, Contact > (); //鑱旂郴浜�
@@ -238,21 +235,22 @@
                     if (string.isnotblank(ct.Account.parent.Name)) {
                         Map < String, Contact > snameMap = new Map < String, Contact > ();
                         string Name = ct.Name.replaceAll(' ','');
-                        string namekey = ct.Account.Name + ' ' + ct.LastName_Encrypted__c;
+                        string namekey = ct.Account.Name + ' ' + Name;
                         // snameMap.put(namekey,ct);
                         if (nameMap.containsKey(ct.Account.parent.Name)) {
                             snameMap = nameMap.get(ct.Account.parent.Name);
                         }
                         snameMap.put(namekey, ct);
-                        snameMap.put(ct.LastName_Encrypted__c, ct);
+                        snameMap.put(ct.Name, ct);
                         nameMap.put(ct.Account.parent.Name, 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);
                 }
-                System.debug('peopleMap'+peopleMap);
+ 
                 //鏌ヨ鍖婚櫌绉戝
                 //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];
@@ -263,16 +261,12 @@
                                                        OCM_man_province_HP__c, 
                                                        Name, Management_Code__c, 
                                                        Is_Active__c, AgentCode_Ext__c, 
-                                                       RelatedMessageGroupNumber__c,
                                                        ParentId, 
                                                        Parent.ParentId, 
                                                        OwnerId
                                                        from Account 
                                                        where Parent_PlatformCode__c IN: ManagementList 
-                                                       OR Parent_Management_Code__c IN: SFDCCodeList
-                                                       OR PlatformCode__c IN: ManagementList
-                                                       OR Management_Code__c IN: SFDCCodeList
-                                                       OR (State_Master__c IN:StateMap.Values()  AND City_Master__c IN:CityMap.Values())];
+                                                       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) {
@@ -283,31 +277,28 @@
                     if (string.isNotBlank(ac.PlatformCode__c)) {
                         AccountMap.put(ac.PlatformCode__c, ac);
                     }
-                    if(string.isNotBlank(ac.Name) && ac.ParentId == null && ac.Parent.ParentId == null){
-                        AccountMap.put(ac.name,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' ? '鏅烘収鍖荤枟' : '鏈嶅姟瀹㈡埛绔�'; //骞冲彴鏉ユ簮
-
+ 
                     //鏂板缓鍖婚櫌
                     Account hp = new Account();
-
+ 
                     //鏂板缓鑱旂郴浜�
                     Contact ct = new Contact();
                     ct.LastName = gedata.Name;
@@ -329,9 +320,9 @@
                     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) {
@@ -354,14 +345,14 @@
                             dpt.Hospital__c = hospital.Id;
                             
                             //鍒ゆ柇鍖婚櫌鏄惁鏈夋晥
-                            if ('鏈夋晥'.equals(hospital.Is_Active_Formula__c) || '鏃犳晥'.equals(hospital.Is_Active_Formula__c)) { 
+                            if ('鏈夋晥'.equals(hospital.Is_Active_Formula__c)) { 
                                 string DepartmentCode = string.isNotBlank(gedata.RelatedDepartment) ? gedata.RelatedDepartment : gedata.DepartmentManagementCode2;
                                 string DepartmentClasskey = gedata.AccountName + ' ' + gedata.DepartmentClass;
                                 //绉戝瀛樺湪
                                 if (AccountMap.containsKey(DepartmentCode)) {
                                     //浜哄憳绠$悊缂栫爜瀛樺湪
                                     ct.AccountId = AccountMap.get(DepartmentCode).id;//绉戝纭畾锛屽皢鑱旂郴浜烘寕鍦ㄨ绉戝涓�
-                                    ct.OwnerId = AccountMap.get(DepartmentCode).OwnerId;//绉戝纭畾锛屽皢灏嗚仈绯讳汉鎵�鏈変汉鐨勫�艰祴涓虹瀹ゆ墍鏈変汉
+                                    ct.OwnerId = AccountMap.get(DepartmentCode).OwnerId;//鍙槸纭畾锛屽皢灏嗚仈绯讳汉鎵�鏈変汉鐨勫�艰祴涓虹瀹ゆ墍鏈変汉
                                     system.debug('personCode' + personCode);
                                     if (string.isnotblank(personCode)) {
                                         system.debug('浜哄憳绠$悊缂栫爜瀛樺湪');
@@ -378,8 +369,7 @@
                                     } else { //浜哄憳绠$悊缂栫爜涓嶅瓨鍦�
                                         //鎼滅储浜哄悕/涓斿湪褰撳墠鎴樼暐绉戝绉戝涓�
                                         System.debug('浜哄憳绠$悊缂栫爜涓嶅瓨鍦�');
-                                        string namekey =  gedata.NameEncrypted;
-                                        system.debug('namekey----->'+namekey);
+                                        string namekey =  gedata.Name;
                                         system.debug('DepartmentClasskey     =    '+DepartmentClasskey);
                                         system.debug('nameMap22222222    '+nameMap);
                                         if (nameMap.containskey(DepartmentClasskey)) { // 6 瀹屾垚 鏇存柊鎿嶄綔
@@ -450,141 +440,29 @@
                                         contactMap.put(Gedata.DepartmentManagementCode2, ct);
                                     }
                                 }
+                            }else if('鏃犳晥'.equals(hospital.Is_Active_Formula__c)){
+                                logstr += 'error:璇ュ尰闄㈡棤鏁堬紝姝ゆ潯鏁版嵁璺宠繃';
+                                continue;
                             }else{
-                                logstr += '璇ュ尰闄㈠浜庤崏妗堜腑/鐢宠涓紝璇风瓑寰呭鎵瑰畬鎴�';
-                                //鐘舵��------>鑽夋涓�/鐢宠涓�------->绛夊緟锛宲lan1:鎶婂尰闄d鍐欏埌鏃ュ織琛ㄤ笂锛堝悗缁绱㈡牴鎹尰闄d妫�绱㈡湭澶勭悊杩囩殑鏃ュ織锛�,plan2:鎶奙essageGroupNumber瀛樺埌鍖婚櫌涓� 
+                                logstr += '璇ュ尰闄㈠浜庤崏妗堜腑锛岃绛夊緟瀹℃壒瀹屾垚';
                                 rowData.NFM624_Secondary_processing__c = false;
                                 continue;
                             }
-                        } else { //鍖婚櫌涓嶅瓨鍦� 鍒欓渶瑕佸鍔犲垽鏂牴鎹悕鍒ら噸
-                            if(accountMap.containskey(gedata.AccountName)){//濡傛灉鏍规嵁鍚嶅瓧鍒ゆ柇鏈夐噸澶嶅垯鏁版嵁鏂板缓鎸囧悜杩欎釜鍖婚櫌
-                                Account dpt = new Account(); 
-                                Account hospital = AccountMap.get(gedata.AccountName);
-                                dpt.PlatformCode__c = gedata.DepartmentManagementCode2;
-                                dpt.Hospital__c = hospital.Id;
-                                //鍖婚櫌瀛樺湪鈫撳彇鐘舵��,鏈夋晥鏃犳晥閮芥柊寤�
-                                if ('鏈夋晥'.equals(hospital.Is_Active_Formula__c) || '鏃犳晥'.equals(hospital.Is_Active_Formula__c)) { 
-                                    string DepartmentCode = string.isNotBlank(gedata.RelatedDepartment) ? gedata.RelatedDepartment : gedata.DepartmentManagementCode2;
-                                    string DepartmentClasskey = gedata.AccountName + ' ' + gedata.DepartmentClass;
-                                    //绉戝瀛樺湪
-                                    if (AccountMap.containsKey(DepartmentCode)) {//鍥犱负SOQL娌℃湁妫�绱㈠埌绉戝鎵�浠ユ病鏈夊垽瀹氫负娌℃湁绉戝
-                                        //浜哄憳绠$悊缂栫爜瀛樺湪
-                                        ct.AccountId = AccountMap.get(DepartmentCode).id;//绉戝纭畾锛屽皢鑱旂郴浜烘寕鍦ㄨ绉戝涓�
-                                        ct.OwnerId = AccountMap.get(DepartmentCode).OwnerId;//鍙槸纭畾锛屽皢灏嗚仈绯讳汉鎵�鏈変汉鐨勫�艰祴涓虹瀹ゆ墍鏈変汉
-                                        system.debug('personCode' + personCode);
-                                        if (string.isnotblank(personCode)) {
-                                            system.debug('浜哄憳绠$悊缂栫爜瀛樺湪');
-                                            //鑱旂郴浜哄瓨鍦� 11 鍖婚櫌鍚嶅瓧鎺掗噸瀛樺湪锛岀瀹ゅ瓨鍦紝鏇存柊鑱旂郴浜猴紝 瀹屾垚
-                                            if (peopleMap.containsKey(personCode)) {
-                                                system.debug('11閫昏緫 鍚嶅瓧鏌ラ噸鍖婚櫌 鏈夌瀹� 鏈変汉鍛樼鐞嗙紪鐮佷笖鏌ユ壘鏈夋浜� 鍔ㄤ綔锛氭洿鏂�');
-                                                ct.Id = peopleMap.get(personCode).Id;
-                                                upsertContactList.add(ct);
-                                            } else { //鑱旂郴浜轰笉瀛樺湪 12 瀹屾垚 
-                                                system.debug('12閫昏緫 鍚嶅瓧鏌ラ噸鍖婚櫌 鏈夌瀹� 鏈変汉鍛樼鐞嗙紪鐮佷絾鏌ユ壘鏃犳浜� 鍔ㄤ綔锛氭姤閿�');
-                                                logstr += 'error:浜哄憳绠$悊缂栫爜 [PersonManagementCode] 瀵瑰簲鐨勮仈绯讳汉涓嶅瓨鍦紝姝ゆ潯鏁版嵁璺宠繃';
-                                                continue;
-                                            }
-                                        } else { //浜哄憳绠$悊缂栫爜涓嶅瓨鍦�
-                                            //鎼滅储浜哄悕/涓斿湪褰撳墠鎴樼暐绉戝绉戝涓�
-                                            System.debug('浜哄憳绠$悊缂栫爜涓嶅瓨鍦�');
-                                            string namekey =  gedata.NameEncrypted;
-                                            system.debug('DepartmentClasskey     =    '+DepartmentClasskey);
-                                            system.debug('nameMap22222222    '+nameMap);
-                                            system.debug('nameMap.containskey(DepartmentClasskey)'+nameMap.containskey(DepartmentClasskey));
-                                            if (nameMap.containskey(DepartmentClasskey)) { // 16 瀹屾垚 鏇存柊鎿嶄綔
-                                                Map < String, Contact > sMap = nameMap.get(DepartmentClasskey);
-                                                if (sMap.containsKey(namekey)) {
-                                                    system.debug('Id璧嬪��'+sMap);
-                                                    ct.id = sMap.get(namekey).id;
-                                                    system.debug('16閫昏緫 鏃犱汉鍛樼鐞嗙紪鐮� 鍖婚櫌鏌ラ噸瀛樺湪 鏈夌瀹� 浜哄悕鏌ユ壘鏈� 鍔ㄤ綔锛氭洿鏂拌仈绯讳汉 ');
-                                                } else { // 17 瀹屾垚
-                                                    system.debug('17閫昏緫 鏃犱汉鍛樼鐞嗙紪鐮� 鍖婚櫌鏌ラ噸瀛樺湪 鏈夌瀹� 浜哄悕鏌ユ壘鏃� 鍔ㄤ綔锛氭柊寤鸿仈绯讳汉 ');
-                                                }
-                                            }
-                                            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)) { //浜哄憳绠$悊缂栫爜鏌ユ壘鏈夊�� 13 瀹屾垚
-                                                System.debug('13閫昏緫');
-                                                //鏂板缓绉戝+鏂板缓鑱旂郴浜�, 
-                                                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 { //浜哄憳绠$悊缂栫爜鏌ユ壘鏃犲�� 14 瀹屾垚
-                                                system.debug('14閫昏緫');
-                                                logstr += 'error:浜哄憳绠$悊缂栫爜 [PersonManagementCode] 瀵瑰簲鐨勮仈绯讳汉涓嶅瓨鍦紝姝ゆ潯鏁版嵁璺宠繃';
-                                                continue;
-                                            }
-                                        } else { //浜哄憳绠$悊缂栫爜涓嶅瓨鍦�
-                                            system.debug('浜哄憳绠$悊缂栫爜涓嶅瓨鍦�');
-                                            string namekey = gedata.DepartmentName+ ' ' + gedata.Name;
-                                            //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);
-                                                if (sMap.containsKey(namekey)) { //鏌ユ壘瀛樺湪 18 瀹屾垚
-                                                    system.debug('18閫昏緫');
-                                                    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;
-                                                    // }
-                                                }else if(sMap.containsKey(gedata.Name)){
-                                                    system.debug('1234567890');
-                                                    ct.Id = sMap.get(gedata.Name).Id;
-                                                    //upsertAccountList.add(dpt);
-                                                }
-                                                system.debug('contactMap        '  +  contactMap);
-                                                System.debug('19閫昏緫');
-                                                contactMap.put(Gedata.DepartmentManagementCode2, ct);
-                                            }
-                                            system.debug('鍒涘缓鑱旂郴浜哄拰绉戝');
-                                            dpt.Department_Name__c = gedata.DepartmentName;
-                                            upsertAccountList.add(dpt);
-                                            contactMap.put(Gedata.DepartmentManagementCode2, ct);
-                                        }
-                                    }
-                                }else{
-                                    logstr += '璇ュ尰闄㈠浜庤崏妗堜腑/鐢宠涓紝璇风瓑寰呭鎵瑰畬鎴�';
-                                    //鐘舵��------>鑽夋涓�/鐢宠涓�------->绛夊緟锛宲lan1:鎶婂尰闄d鍐欏埌鏃ュ織琛ㄤ笂锛堝悗缁绱㈡牴鎹尰闄d妫�绱㈡湭澶勭悊杩囩殑鏃ュ織锛�,plan2:鎶奙essageGroupNumber瀛樺埌鍖婚櫌涓� 
-                                    hospital.RelatedMessageGroupNumber__c += iflog.MessageGroupNumber__c + ';';
-                                    rowData.NFM624_Secondary_processing__c = false;
-                                    upsertAccountList.add(hospital);
-                                }
-                            }else{
-                                //鈫撴柊寤哄尰闄�
-                                system.debug('鏂板缓鍖婚櫌 閫昏緫5閫昏緫10閫昏緫15閫昏緫20 鏃犺浜哄憳绠$悊缂栫爜鏄惁鏈夊�奸兘闇�瑕佹柊寤哄尰闄�');
-                                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;//鏁版嵁闇�瑕佷簩娆″鐞嗘爣璁�
+                        } 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);
@@ -608,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);
@@ -660,7 +538,7 @@
         }
         update iflog;
     }
-
+ 
     private static String verify(GeData gda) {
         String result = '';
         if (string.isblank(gda.ContactId)) {
@@ -734,7 +612,7 @@
         //鏍规嵁缁熶竴鐢ㄦ埛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>();
@@ -794,29 +672,3 @@
         }
         //琛ュ厖瀛︿細閮ㄥ垎 end
     }
-    //鍓嶇疆鏉′欢锛屽尰闄㈢鐞嗙紪鐮佷笉瀛樺湪鐨勬椂鍊欐墽琛岃繖涓搷浣�
-//     private static Account duplicate_removal (Map<String,ACcount> accountNameMap,Gedate ged,BatchIF_Log__c iflog){//鍖婚櫌鍚峂ap,鎺ュ彛鏁版嵁锛屾棩蹇楄〃
-//         //鏌ヨ鍖婚櫌鏄柊澧炴潯浠禣R 锛堢渷 = 浼犲叆鐪� AND 甯� = 浼犲叆甯傦級锛屽鍔犱竴涓竴鍚嶅瓧涓簁ey鐨刴ap锛屾牴鎹紶鍏ユ暟鎹殑鍚嶅瓧鍒ゆ柇鏄惁瀛樺湪
-//         //涓嶅瓨鍦ㄢ�斺�斺��>鏂板缓
-//         //瀛樺湪鈥斺��>鍙栫姸鎬�
-//         //鐘舵��------>鑽夋涓�/鐢宠涓�------->绛夊緟锛宲lan1:鎶婂尰闄d鍐欏埌鏃ュ織琛ㄤ笂锛堝悗缁绱㈡牴鎹尰闄d妫�绱㈡湭澶勭悊杩囩殑鏃ュ織锛�,plan2:鎶奙essageGroupNumber瀛樺埌鍖婚櫌涓�
-//         //鐘舵��------>鏈夋晥锛屾暟鎹柊寤哄埌璇ュ尰闄笅,鍙戦�佽仈绯讳汉淇℃伅
-//         //鐘舵��------>鏃犳晥锛屾暟鎹柊寤哄埌璇ュ尰闄笅,鍏堝彂閫佽仈绯讳汉淇℃伅锛屽啀鍙戦�佸尰闄俊鎭�
-//         if(accountNameMap.containskey(ged.AccountName)){//鏍规嵁鍖婚櫌鍚嶅垽鏂尰闄㈡槸鍚﹀瓨鍦�
-//             //鍖婚櫌瀛樺湪
-//             Account tempHp = accountNameMap.get(ged.AccountName);
-//             if('鑽夋涓�'.equals(tempHp.Is_Active_Formula__c) || '鐢宠涓�'.equals(tempHp.Is_Active_Formula__c)){//鍒ゆ柇鍖婚櫌鐘舵��
-//                 //鑽夋涓�/鐢宠涓姸鎬�
-//                 tempHp.RelatedMessageGroupNumber__c += iflog.MessageGroupNumber__c + ';';
-//                 //continue;
-//                 return tempHp;
-//             }else{
-
-//             }
-//         }else{
-//             //鍖婚櫌涓嶅瓨鍦�
-           
-//             return hp;
-//         }
-//     }
-}
\ No newline at end of file

--
Gitblit v1.9.1