From 1312ba82d4c880bdb5357d28e0d4af5b285f610f Mon Sep 17 00:00:00 2001 From: 高章伟 <gaozhangwei@prec-tech.com> Date: 星期四, 10 三月 2022 15:54:39 +0800 Subject: [PATCH] 最近一月修改内容 --- force-app/main/default/classes/DealerPersonnelController.cls | 141 +++++++++++++--------------------------------- 1 files changed, 41 insertions(+), 100 deletions(-) diff --git a/force-app/main/default/classes/DealerPersonnelController.cls b/force-app/main/default/classes/DealerPersonnelController.cls index e83ca1b..41ed30f 100644 --- a/force-app/main/default/classes/DealerPersonnelController.cls +++ b/force-app/main/default/classes/DealerPersonnelController.cls @@ -6,16 +6,13 @@ public static String processData(String fileData,String sobjectName,List<String> fields) { system.debug('fileData===============>'+fileData); String errorMage = ''; - String str = ''; try { if(fileData != null){ String[] fileLines = new String[]{}; fileLines = fileData.split('\n'); system.debug('fileLines===================>'+fileLines); - // 璁板綍绫诲瀷 - List<String> recordTypeList = new List<String>(); - // 瀹㈡埛鍚� - List<String> accountNameList = new List<String>(); + // 缁忛攢鍟嗙鐞嗙紪鐮� + List<String> managementCodeList = new List<String>(); // 瀵煎叆鐨勬暟鎹� List<List<String>> inputList = new List<List<String>>(); for (Integer i = 1,j = fileLines.size(); i < j; i++) { @@ -23,133 +20,89 @@ inputValues = fileLines[i].split(','); System.debug('inputValues=============>'+inputValues); if(inputValues != null){ - if(inputValues[0] == '' || inputValues[0] == null){ - errorMage += 'errorMage: 绗�' + i + '琛�,璁板綍绫诲瀷涓嶈兘涓虹┖!'; + if(inputValues[0] == '' || inputValues[0]== null){ + errorMage += 'errorMage: 绗�' + i + '琛�,濮撳悕涓嶈兘涓虹┖!'; errorMage += '='; } - if(inputValues[1] == '' || inputValues[1]== null){ - errorMage += 'errorMage: 绗�' + i + '琛�,濮撴皬涓嶈兘涓虹┖!'; - errorMage += '='; - } - if(inputValues[2] == '' || inputValues[2] == null){ - errorMage += 'errorMage: 绗�' + i + '琛�,鍚嶅瓧涓嶈兘涓虹┖!'; - errorMage += '='; - } - if(inputValues[3] == '' || inputValues[3] ==null){ + if(inputValues[1] == '' || inputValues[1] ==null){ errorMage += 'errorMage: 绗�' + i + '琛�,鎵嬫満涓嶈兘涓虹┖!'; errorMage += '='; } - boolean mobileNumberFlag = mobileNumberVerification(inputValues[3]); - System.debug('mobileNumberFlag=============>'+mobileNumberFlag); - + boolean mobileNumberFlag = mobileNumberVerification(inputValues[1]); if(mobileNumberFlag == false){ errorMage += 'errorMage: 浣犵殑鎵嬫満鍙风爜涓嶅お姝g‘,璇锋鏌ユ偍鐨勬墜鏈烘槸鍚︽纭�!'; errorMage += '='; } - if(inputValues[4] == '' || inputValues[4] == null){ + if(inputValues[2] == '' || inputValues[2] == null){ errorMage += 'errorMage: 绗�' + i + '琛�,閭涓嶈兘涓虹┖!'; errorMage += '='; } - boolean mailboxFlag = mailboxVerification(inputValues[4]); - System.debug('mailboxFlag=============>'+mailboxFlag); - + boolean mailboxFlag = mailboxVerification(inputValues[2]); if(mailboxFlag == false){ errorMage += 'errorMage: 浣犵殑閭涓嶅お姝g‘,璇锋鏌ユ偍鐨勯偖绠辨牸寮�!'; errorMage += '='; } - if(inputValues[5] == '' || inputValues[5] == null){ - errorMage += 'errorMage: 绗�' + i + '琛�,瀹㈡埛鍚嶄笉鑳戒负绌�!'; + if(inputValues[3] == '' || inputValues[3] == null){ + errorMage += 'errorMage: 绗�' + i + '琛�,缁忛攢鍟嗙鐞嗙紪鐮佷笉鑳戒负绌�!'; errorMage += '='; } - - str = inputValues[5]; - recordTypeList.add(inputValues[0]); - accountNameList.add(str); - //瀵煎叆鐨勬暟鎹� - inputList.add(inputvalues); + managementCodeList.add(inputValues[3]); + inputList.add(inputValues); + //瀵煎叆鐨勬暟鎹� System.debug('inputValues[0]===============>'+ inputValues[0]); System.debug('inputValues[1]===============>'+ inputValues[1]); System.debug('inputValues[2]===============>'+ inputValues[2]); System.debug('inputValues[3]===============>'+ inputValues[3]); - System.debug('inputValues[4]===============>'+ inputValues[4]); - System.debug('inputValues[5]===============>'+ inputValues[5]); - System.debug('inputValues[6]===============>'+ inputValues[6]); } } - - Map<String,Account> accountMap = new Map<String,Account>(); - List<String> accountIdList = new List<String>(); - Map<String,RecordType> recordTypeMap = new Map<String,RecordType>(); - List<String> recordTypeIdList = new List<String>(); - List<Account> accountList = [select id, Name from Account where Name in: accountNameList]; - List<RecordType> rectCo = [select Id,Name from RecordType where IsActive = true and SobjectType = 'Contact' and Name in: recordTypeList]; + Map<String,Account> accountIdMap = new Map<String,Account>(); + List<Account> accountList = [select id, Name,Management_Code__c from Account where Management_Code__c in: managementCodeList]; for(Account ac : accountList){ - accountMap.put(ac.Name, ac); - accountIdList.add(ac.Id); - } - system.debug('accountList===============>'+accountList); - system.debug('accountNameList===============>'+accountNameList); - system.debug('accountMap===============>'+accountMap); - for(RecordType re : rectCo){ - recordTypeMap.put(re.Name, re); - recordTypeIdList.add(re.Id); + accountIdMap.put(ac.Management_Code__c,ac); } List<Contact> cnList = new List<Contact>(); Integer lineNumber = 1; for(List<String> lineList :inputList){ Contact con = new Contact(); - if(recordTypeMap.containsKey(lineList[0])){ - con.RecordTypeId = recordTypeMap.get(lineList[0]).id; + //鏆傛椂瀵煎叆鐨勬槸缁忛攢鍟嗙敤鎴凤紝鎵�浠ヨ褰曠被鍨嬪彧鏈夌粡閿�鍟嗭紝鏆傛椂鍐欐锛涘悗鏈熷鏋滄湁鍙樺姩鍐嶆洿鏀� + con.RecordTypeId = '01210000000QfWiAAK'; + if(lineList[0] != null && lineList[0] != ''){ + con.LastName = lineList[0]; }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,璁板綍绫诲瀷'+lineList[0]+'涓嶅瓨鍦�'; - errorMage += '='; - } - if(lineList[1] != null && lineList[1] != ''){ - con.LastName = lineList[1]; - }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,濮撴皬'+lineList[1]+'涓嶅瓨鍦�'; + errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,濮撴皬'+lineList[0]+'涓嶅瓨鍦�'; errorMage += '='; } + if(lineList[1] != null && lineList[1] != ''){ + if(mobileNumberVerification(lineList[1])){ + con.MobilePhone = lineList[1]; + }else{ + errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鎵嬫満'+lineList[1]+'涓嶆纭�!'; + errorMage += '='; + } + }else{ + errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鎵嬫満'+lineList[1]+'涓嶅瓨鍦�'; + errorMage += '='; + } if(lineList[2] != null && lineList[2] != ''){ - con.FirstName = lineList[2]; - }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鍚嶅瓧'+lineList[2]+'涓嶅瓨鍦�'; - errorMage += '='; - } - if(lineList[3] != null && lineList[3] != ''){ - if(mobileNumberVerification(lineList[3])){ - con.MobilePhone = lineList[3]; + if(mailboxVerification(lineList[2])){ + con.Email = lineList[2]; }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鎵嬫満'+lineList[3]+'涓嶆纭�!'; + errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鐢靛瓙閭欢'+lineList[2]+'涓嶆纭�!'; errorMage += '='; } }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鎵嬫満'+lineList[3]+'涓嶅瓨鍦�'; + errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鐢靛瓙閭欢'+lineList[2]+'涓嶅瓨鍦�'; errorMage += '='; } - if(lineList[4] != null && lineList[4] != ''){ - if(mailboxVerification(lineList[4])){ - con.Email = lineList[4]; - }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鐢靛瓙閭欢'+lineList[4]+'涓嶆纭�!'; - errorMage += '='; - } + if(accountIdMap.containsKey(lineList[3])){ + con.AccountId = accountIdMap.get(lineList[3]).id; }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,鐢靛瓙閭欢'+lineList[4]+'涓嶅瓨鍦�'; + errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,缁忛攢鍟嗙紪鐮�'+lineList[3]+'涓嶅瓨鍦�'; errorMage += '='; } - if(accountMap.containsKey(lineList[5])){ - con.AccountId = accountMap.get(lineList[5]).id; - }else{ - errorMage += 'error: 绗�'+ lineNumber +'琛屾暟鎹�,瀹㈡埛鍚�'+lineList[5]+'涓嶅瓨鍦�'; - errorMage += '='; - } - if(lineList[6] == 'TRUE'){ - con.Agency_User__c = true; - }else{ - con.Agency_User__c = false; - } + //鏆傚畾鍒涘缓鐩存帴涓� true + con.Agency_User__c = true; lineNumber++; cnList.add(con); } @@ -190,18 +143,6 @@ } //鏂板瀹㈡埛浜哄憳锛� public static void insertContact(List<Contact> data) { - // System.debug('data==============>'+data); - // List<String> lastNameList = new List<String>(); - // List<String> firstNameList = new List<String>(); - // for(Contact con:data){ - // lastNameList.add(con.LastName); - // firstNameList.add(con.FirstName); - // } - // List<Contact> contactList = [select id, Name,Agency_User__c from contact where LastName in: lastNameList AND FirstName in: firstNameList]; - // if(contactList.size() >= 0){ - // return ''; - // } - // System.debug('strNameList==============>'+strNameList); insert data; } -- Gitblit v1.9.1