From f0bccccbb88d93ac05010c17d4b2e0cb22a2ce9a Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期四, 20 四月 2023 15:45:11 +0800 Subject: [PATCH] backup0420 --- force-app/main/default/classes/updateESignBatch.cls | 247 +++++++++++++++++++++++++++++-------------------- 1 files changed, 145 insertions(+), 102 deletions(-) diff --git a/force-app/main/default/classes/updateESignBatch.cls b/force-app/main/default/classes/updateESignBatch.cls index d4843e2..05488e2 100644 --- a/force-app/main/default/classes/updateESignBatch.cls +++ b/force-app/main/default/classes/updateESignBatch.cls @@ -311,8 +311,14 @@ //瀛樻斁鎵�鏈夌鏀跺崟褰曞叆琛╥d List < String > luruIsLastSubmitList = new List < String > (); + + // 2023-03-16 ssm 浼樺寲閫昏緫锛岄伩鍏嶅悓鏃跺璁惧鍋氱郴缁熸洿鏂颁互鍙婂尰闄㈠拰缁忛攢鍟嗗湪鍚屼竴鎵规锛�15鍒嗛挓鍐咃級涓婁紶鏁版嵁 start //鍒ゆ柇鏄惁鏈夋湭澶勭悊鐨勫綍鍏ヨ〃 - Map < Id, eSignFormEntry__c > unprocessedESignEneryMap = new Map < Id, eSignFormEntry__c > (); + // Map < Id, eSignFormEntry__c > unprocessedESignEneryMap = new Map < Id, eSignFormEntry__c > (); + Map < Id, List<eSignFormEntry__c> > unprocessedESignEneryMap = new Map < Id, List<eSignFormEntry__c> > (); + List<eSignFormEntry__c> unprocessedEntries = new List<eSignFormEntry__c>(); + // Map <Id, eSignFormEntry__c> unprocessedEntries = new Map<Id, eSignFormEntry__c>(); + // 2023-03-16 ssm 浼樺寲閫昏緫锛岄伩鍏嶅悓鏃跺璁惧鍋氱郴缁熸洿鏂颁互鍙婂尰闄㈠拰缁忛攢鍟嗗湪鍚屼竴鎵规锛�15鍒嗛挓鍐咃級涓婁紶鏁版嵁 start //鐢ㄤ簬鍒ゆ柇鍒犻櫎椹冲洖鐨勯檮浠剁殑绛涢�夋潯浠� Map < Id, eSignForm__c > rejectESignEneryMap = new Map < Id, eSignForm__c > (); @@ -418,9 +424,16 @@ eSignStringMap.put(eSignFormEntryWhole.Id, eSignFormEntryWhole); //鈶℃墍鏈夌殑 鐢ㄤ簬鏇存柊鏂囦欢(鍖呭惈宸插鐞嗘湭澶勭悊鐨勬暟鎹� ) fileIdList.add(eSignFormEntryWhole.Id); - if (eSignFormEntryWhole.IsHandled__c == false) { + // 杩欓噷鏄粈涔堥锛熼兘涓嶅垽鏂竴涓嬬鏀跺崟id鐨勶紵 + // if (eSignFormEntryWhole.IsHandled__c == false) { + if (eSignFormEntryWhole.IsHandled__c == false && eSignFormEntryWhole.eSignForm__r.Id == eid) { //鏈鐞嗙殑 - unprocessedESignEneryMap.put(eid, eSignFormEntryWhole); + // 2023-03-16 ssm 浼樺寲閫昏緫锛岄伩鍏嶅悓鏃跺璁惧鍋氱郴缁熸洿鏂颁互鍙婂尰闄㈠拰缁忛攢鍟嗗湪鍚屼竴鎵规锛�15鍒嗛挓鍐咃級涓婁紶鏁版嵁 start + // unprocessedESignEneryMap.put(eid, eSignFormEntryWhole); + List<eSignFormEntry__c> entries = unprocessedESignEneryMap.size() > 0 && unprocessedESignEneryMap.keySet().contains(eid) ? unprocessedESignEneryMap.get(eid) : new List<eSignFormEntry__c>(); + entries.add(eSignFormEntryWhole); + unprocessedESignEneryMap.put(eid, entries); + // 2023-03-16 ssm 浼樺寲閫昏緫锛岄伩鍏嶅悓鏃跺璁惧鍋氱郴缁熸洿鏂颁互鍙婂尰闄㈠拰缁忛攢鍟嗗湪鍚屼竴鎵规锛�15鍒嗛挓鍐咃級涓婁紶鏁版嵁 end } if (eSignFormEntryWhole.eSignForm__r.Id == eid) { //瀛樻斁 绛炬敹鍗昳d锛屽綍鍏ヨ〃id 鏂囦欢鐢� @@ -595,114 +608,129 @@ boolean IsHPSubmit = false; //閿�鍞笭閬� String Sales_Root_Formula; - //褰曞叆绫诲瀷 - String type; + //褰曞叆绫诲瀷 + String type; // 杩欎笢瑗挎病鏈夌敤 System.debug('lasteSignFormEntryMap:' + lasteSignFormEntryMap); if (lasteSignFormEntryMap.containsKey(eSignFormid)) { eSignForm.id = eSignFormid; + // 2023-03-16 ssm 浼樺寲閫昏緫锛岄伩鍏嶅悓鏃跺璁惧鍋氱郴缁熸洿鏂颁互鍙婂尰闄㈠拰缁忛攢鍟嗗湪鍚屼竴鎵规锛�15鍒嗛挓鍐咃級涓婁紶鏁版嵁 start //绛炬敹鍗昳d - eSignFormEntry__c eSignFormEntry = lasteSignFormEntryMap.get(eSignFormid); - //濡傛灉缁忛攢鍟嗙‘璁ゆ棩涓虹┖鐨勮瘽 杩涘幓鍒ゆ柇鏇存柊缁忛攢鍟嗗鎵圭姸鎬� - if (eSignFormEntry.agencyDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { - if (eSignFormEntry.agencyConfirmDateBack__c == null) { - if (eSignFormEntry.IsSubmit__c == true) { - eSignForm.agencyAutoSignUpStatus__c = '鐢宠涓�'; - eSignForm.agencyReject__c = false; - } else { - if (eSignFormEntry.agencyScanDayBack__c != null && eSignFormEntry.IsAgencyScan__c) { - eSignForm.agencyAutoSignUpStatus__c = '鑽夋涓�'; - eSignForm.agencyReject__c = false; - + // eSignFormEntry__c eSignFormEntry = lasteSignFormEntryMap.get(eSignFormid); + for (eSignFormEntry__c eSignFormEntry : unprocessedESignEneryMap.get(eSignFormid)) { + // 鏍规嵁褰曞叆绫诲瀷鍘绘洿鏂板搴旂殑閮ㄥ垎鏁版嵁 + // entryType__c鍖呭惈缁忛攢鍟� + if (String.isNotBlank(eSignFormEntry.entryType__c) && eSignFormEntry.entryType__c.contains('缁忛攢鍟�')) { + //濡傛灉缁忛攢鍟嗙‘璁ゆ棩涓虹┖鐨勮瘽 杩涘幓鍒ゆ柇鏇存柊缁忛攢鍟嗗鎵圭姸鎬� + if (eSignFormEntry.agencyDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { + if (eSignFormEntry.agencyConfirmDateBack__c == null) { + if (eSignFormEntry.IsSubmit__c == true) { + eSignForm.agencyAutoSignUpStatus__c = '鐢宠涓�'; + eSignForm.agencyReject__c = false; + } else { + if (eSignFormEntry.agencyScanDayBack__c != null && eSignFormEntry.IsAgencyScan__c) { + // 璋冩暣鑽夋涓殑璧嬪�奸�昏緫锛屽绔搷浣滅殑鎯呭喌涓嬫湁鍙兘鍏堢敵璇峰悗鑽夋 + // eSignForm.agencyAutoSignUpStatus__c = '鑽夋涓�'; + eSignForm.agencyAutoSignUpStatus__c = String.isBlank(eSignForm.agencyAutoSignUpStatus__c) ? '鑽夋涓�' : eSignForm.agencyAutoSignUpStatus__c; + eSignForm.agencyReject__c = false; + } + } + } + //鏈洿鏂板墠鐨勭粡閿�鍟嗗鎵圭姸鎬� 鐢ㄤ簬鏂囦欢绱姹囨�� + if(eSignFormEntry.agencyAutoSignUpStatus__c!=null &&eSignFormEntry.agencyAutoSignUpStatus__c!=''){ + oldESignAgencyStatusMap.put('A' + eSignForm.id, eSignFormEntry.agencyAutoSignUpStatus__c); + }else{ + oldESignAgencyStatusMap.put('A' + eSignForm.id, '鏃�'); + } + } + //濡傛灉娌″彉鍖栧垯涓嶆洿鏂� + if (eSignFormEntry.AgencyWorkflowEmailBack__c != eSignFormEntry.AgencyWorkflowEmail__c) { + //缁忛攢鍟嗛偖浠� + eSignForm.AgencyWorkflowEmail__c = eSignFormEntry.AgencyWorkflowEmailBack__c; + } + // 鏃ユ湡鏇存柊 + if (eSignFormEntry.agencyDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { + //缁忛攢鍟嗘壂鎻忔棩 + if (eSignFormEntry.agencyScanDayBack__c != null) { + eSignForm.agencyScanDay__c = eSignFormEntry.agencyScanDayBack__c; + } + //缁忛攢鍟嗙鏀舵棩 + if (eSignFormEntry.agencySignUpDateBack__c != null) { + eSignForm.agencySignUpDate__c = eSignFormEntry.agencySignUpDateBack__c; + } + //缁忛攢鍟嗙‘璁ゆ棩 + if (eSignFormEntry.agencyConfirmDateBack__c != null) { + eSignForm.agencyConfirmDate__c = eSignFormEntry.agencyConfirmDateBack__c; } } } - //鏈洿鏂板墠鐨勭粡閿�鍟嗗鎵圭姸鎬� 鐢ㄤ簬鏂囦欢绱姹囨�� - if(eSignFormEntry.agencyAutoSignUpStatus__c!=null &&eSignFormEntry.agencyAutoSignUpStatus__c!=''){ - oldESignAgencyStatusMap.put('A' + eSignForm.id, eSignFormEntry.agencyAutoSignUpStatus__c); - }else{ - oldESignAgencyStatusMap.put('A' + eSignForm.id, '鏃�'); - } - - } - if (eSignFormEntry.HPDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { - //濡傛灉鍖婚櫌纭鏃ヤ负绌虹殑璇� 杩涘幓鍒ゆ柇鏇存柊鍖婚櫌瀹℃壒鐘舵�� - if (eSignFormEntry.salesHPManageConfirmDate__c == null) { - if (eSignFormEntry.IsHPSubmit__c == true) { - eSignForm.HPSignUpStatus__c = '鐢宠涓�'; - eSignForm.HPReject__c = false; - } else { - if (eSignFormEntry.HPScanDayBack__c != null && eSignFormEntry.IsHPScan__c) { - eSignForm.HPSignUpStatus__c = '鑽夋涓�'; - eSignForm.HPReject__c = false; - + // entryType__c鍖呭惈鍖婚櫌 + if (String.isNotBlank(eSignFormEntry.entryType__c) && eSignFormEntry.entryType__c.contains('鍖婚櫌')) { + if (eSignFormEntry.HPDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { + //濡傛灉鍖婚櫌纭鏃ヤ负绌虹殑璇� 杩涘幓鍒ゆ柇鏇存柊鍖婚櫌瀹℃壒鐘舵�� + if (eSignFormEntry.salesHPManageConfirmDate__c == null) { + if (eSignFormEntry.IsHPSubmit__c == true) { + eSignForm.HPSignUpStatus__c = '鐢宠涓�'; + eSignForm.HPReject__c = false; + } else { + if (eSignFormEntry.HPScanDayBack__c != null && eSignFormEntry.IsHPScan__c) { + // 璋冩暣鑽夋涓殑璧嬪�奸�昏緫锛屽绔搷浣滅殑鎯呭喌涓嬫湁鍙兘鍏堢敵璇峰悗鑽夋 + // eSignForm.HPSignUpStatus__c = '鑽夋涓�'; + eSignForm.HPSignUpStatus__c = String.isBlank(eSignForm.HPSignUpStatus__c) ? '鑽夋涓�' : eSignForm.HPSignUpStatus__c; + eSignForm.HPReject__c = false; + } + } + } + //鏈洿鏂板墠鐨勫尰闄㈠鎵圭姸鎬� 鐢ㄤ簬鏂囦欢绱姹囨�� + if(eSignFormEntry.HPSignUpStatus__c!=null &&eSignFormEntry.HPSignUpStatus__c!=''){ + oldESignHPStatusMap.put('H' + eSignForm.id, eSignFormEntry.HPSignUpStatus__c); + }else{ + oldESignHPStatusMap.put('H' + eSignForm.id, '鏃�'); + } + } + //濡傛灉娌″彉鍖栧垯涓嶆洿鏂� + if (eSignFormEntry.HPWorkflowEmailBack__c != eSignFormEntry.HPWorkflowEmail__c) { + //鍖婚櫌閭欢 + eSignForm.HPWorkflowEmail__c = eSignFormEntry.HPWorkflowEmailBack__c; + } + // 鏃ユ湡鏇存柊 + if (eSignFormEntry.HPDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { + //鍖婚櫌鎵弿鏃� + if (eSignFormEntry.HPScanDayBack__c != null) { + eSignForm.HPScanDay__c = eSignFormEntry.HPScanDayBack__c; + } + //鍖婚櫌绛炬敹鏃� + if (eSignFormEntry.HPSignUpDateBack__c != null) { + eSignForm.HPSignUpDate__c = eSignFormEntry.HPSignUpDateBack__c; + } + //鍖婚櫌纭鏃� + if (eSignFormEntry.HPConfirmDateBack__c != null) { + eSignForm.HPConfirmDate__c = eSignFormEntry.HPConfirmDateBack__c; } } } - //鏈洿鏂板墠鐨勫尰闄㈠鎵圭姸鎬� 鐢ㄤ簬鏂囦欢绱姹囨�� - if(eSignFormEntry.HPSignUpStatus__c!=null &&eSignFormEntry.HPSignUpStatus__c!=''){ - oldESignHPStatusMap.put('H' + eSignForm.id, eSignFormEntry.HPSignUpStatus__c); - }else{ - oldESignHPStatusMap.put('H' + eSignForm.id, '鏃�'); - } - - } + //缁欒惀涓氬姪鐞嗚祴鍊� + //eSignForm.Sales_assistant_name_text__c = eSignFormEntry.Sales_assistant_ID__c;// Commented By Li Jun 20230420 + //瀛樹竴涓猧d + idlast = eSignFormEntry.Id; + //绛炬敹鍗昻ame鐢ㄤ綔鏂囦欢鍛藉悕 + name = eSignFormEntry.eSignForm__r.Name; + //鏄惁缁忛攢鍟嗘彁浜� + IsSubmit = eSignFormEntry.IsSubmit__c; + //鏄惁鍖婚櫌鎻愪氦 + IsHPSubmit = eSignFormEntry.IsHPSubmit__c; + //鏈�鍚庡綍鍏ヨ〃 + eSignForm.finalUpadteFrom__c = eSignFormEntry.Id; + //閿�鍞笭閬� 鍖哄垎鐩撮攢杩樻槸鍒嗛攢 + Sales_Root_Formula = eSignFormEntry.Sales_Root_Formula__c; + //褰曞叆绫诲瀷 + type = eSignFormEntry.entryType__c; // 娌℃湁鐢� - //濡傛灉娌″彉鍖栧垯涓嶆洿鏂� - if (eSignFormEntry.AgencyWorkflowEmailBack__c != eSignFormEntry.AgencyWorkflowEmail__c) { - //缁忛攢鍟嗛偖浠� - eSignForm.AgencyWorkflowEmail__c = eSignFormEntry.AgencyWorkflowEmailBack__c; + // 鎵�鏈夋病鏈夋病鏈夊鐞嗙殑entry閮借鏍囪涓哄鐞� + eSignFormEntry.IsHandled__c = true; + unprocessedEntries.add(eSignFormEntry); + // unprocessedEntries.put(eSignFormEntry.Id, eSignFormEntry); } - //濡傛灉娌″彉鍖栧垯涓嶆洿鏂� - if (eSignFormEntry.HPWorkflowEmailBack__c != eSignFormEntry.HPWorkflowEmail__c) { - //鍖婚櫌閭欢 - eSignForm.HPWorkflowEmail__c = eSignFormEntry.HPWorkflowEmailBack__c; - } - if (eSignFormEntry.agencyDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { - //缁忛攢鍟嗘壂鎻忔棩 - if (eSignFormEntry.agencyScanDayBack__c != null) { - eSignForm.agencyScanDay__c = eSignFormEntry.agencyScanDayBack__c; - } - //缁忛攢鍟嗙鏀舵棩 - if (eSignFormEntry.agencySignUpDateBack__c != null) { - eSignForm.agencySignUpDate__c = eSignFormEntry.agencySignUpDateBack__c; - } - //缁忛攢鍟嗙‘璁ゆ棩 - if (eSignFormEntry.agencyConfirmDateBack__c != null) { - eSignForm.agencyConfirmDate__c = eSignFormEntry.agencyConfirmDateBack__c; - } - } - - if (eSignFormEntry.HPDNSignUpStatus__c != '绛炬敹宸插畬鎴�') { - //鍖婚櫌鎵弿鏃� - if (eSignFormEntry.HPScanDayBack__c != null) { - eSignForm.HPScanDay__c = eSignFormEntry.HPScanDayBack__c; - } - //鍖婚櫌绛炬敹鏃� - if (eSignFormEntry.HPSignUpDateBack__c != null) { - eSignForm.HPSignUpDate__c = eSignFormEntry.HPSignUpDateBack__c; - } - //鍖婚櫌纭鏃� - if (eSignFormEntry.HPConfirmDateBack__c != null) { - eSignForm.HPConfirmDate__c = eSignFormEntry.HPConfirmDateBack__c; - } - } - - //缁欒惀涓氬姪鐞嗚祴鍊� - eSignForm.Sales_assistant_name_text__c = eSignFormEntry.Sales_assistant_ID__c; - //瀛樹竴涓猧d - idlast = eSignFormEntry.Id; - //绛炬敹鍗昻ame鐢ㄤ綔鏂囦欢鍛藉悕 - name = eSignFormEntry.eSignForm__r.Name; - //鏄惁缁忛攢鍟嗘彁浜� - IsSubmit = eSignFormEntry.IsSubmit__c; - //鏄惁鍖婚櫌鎻愪氦 - IsHPSubmit = eSignFormEntry.IsHPSubmit__c; - //鏈�鍚庡綍鍏ヨ〃 - eSignForm.finalUpadteFrom__c = eSignFormEntry.Id; - //閿�鍞笭閬� 鍖哄垎鐩撮攢杩樻槸鍒嗛攢 - Sales_Root_Formula = eSignFormEntry.Sales_Root_Formula__c; - //褰曞叆绫诲瀷 - type = eSignFormEntry.entryType__c; + // 2023-03-16 ssm 浼樺寲閫昏緫锛岄伩鍏嶅悓鏃跺璁惧鍋氱郴缁熸洿鏂颁互鍙婂尰闄㈠拰缁忛攢鍟嗗湪鍚屼竴鎵规锛�15鍒嗛挓鍐咃級涓婁紶鏁版嵁 end } system.debug('绛炬敹鍗曞璞�-----锛�' + eSignForm); @@ -1000,6 +1028,21 @@ //鐢靛瓙绛炬敹鍗� 澧炲姞鏈鏇存柊闄勪欢鏁伴噺 2020/01/07 绮剧悽鎶�鏈� wql end //鏂囦欢 end } + // 鏇存柊绛炬敹鍗曞綍鍏ヨ〃 + if(unprocessedEntries.size() > 0) { + Database.SaveResult[] lsr = Database.update(unprocessedEntries, false); + // Database.SaveResult[] lsr = Database.update(unprocessedEntries.values(), false); + eb.setError(lsr, MAXERRORCNT, eSignFormEntry__c.sObjectType); + for (Integer tIdx = 0; tIdx < lsr.size(); tIdx++) { + Database.SaveResult sr = lsr[tIdx]; + System.debug('sr.isSuccess:' + sr.isSuccess()); + if (!sr.isSuccess()) { + Database.Error emsg = sr.getErrors()[0]; + iflog.ErrorLog__c += 'ERROR ' + unprocessedEntries[tIdx].Id + ' eSignFormEntry__c:' + emsg + '\n'; + // iflog.ErrorLog__c += 'ERROR ' + unprocessedEntries.values()[tIdx].Id + ' eSignFormEntry__c:' + emsg + '\n'; + } + } + } system.debug('鏇存柊鐨勭鏀跺崟锛�' + eSignFormList); //鏇存柊绛炬敹鍗曟槑缁嗗苟娣诲姞鏃ュ織 if (eSignFormLuRUList.size() > 0) { @@ -1114,7 +1157,7 @@ } //鍒犻櫎褰曞叆琛� System.debug('鍒犻櫎褰曞叆琛� : ' + eSignFormDeleteList); - delete eSignFormDeleteList; + // delete eSignFormDeleteList; // 2023-03-14 ssm 鏆傛椂涓嶈嚜鍔ㄥ垹闄や腑闂磋〃鏁版嵁锛屾柟渚跨煭鏈熷唴鍋歝heck } } @TestVisible @@ -1127,14 +1170,14 @@ List < eSignForm__c > eSignFormLastList = new List < eSignForm__c >(); //妫�绱CSM绠$悊鐪佸璞� - List < OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c from OCM_Management_Province__c where Name IN: provinceList]; + List < OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c,Window1__c from OCM_Management_Province__c where Name IN: provinceList]; //瀛樻斁map<鐪侊紝鎷呭綋> for (OCM_Management_Province__c omp : ompList) { //涓嶇敤map<String,list>鐨� 鍘熷洜鏄� 鎯� ocsm绠$悊鐪� 鍜岀鏀跺崟 钀ヤ笟鎷呭綋鐨勯『搴忎繚鎸佷竴鑷� //String salesManage = omp.SalesManage__c+','+omp.SalesManage2__c+','+omp.SalesManage3__c; //provinceOwnerMap.put(omp.Name, salesManage); provinceOwnerMap.put(omp.Name, omp.SalesManage__c); - provinceGIMap.put(omp.Name, omp.GI_assistant__c); + provinceGIMap.put(omp.Name, omp.Window1__c);//Update By Li Jun 20230420 for 绛炬敹鍗曡惀涓氬姪鐞嗕粠GI/SP鍔╃悊鏀逛负绛炬敹鍗昈CSM鐪佺殑钀ヤ笟绐楀彛 } //鈶犱负true鐨勬椂鍊� 鏄叾浠栨病鍙戠敓鍙樺寲鍙湁ocsm鐪佷笂钀ヤ笟鎷呭綋鏀瑰彉 //鈶′负false鐨勬椂鍊欙紝鏈変腑闂磋〃姝e父鏇存柊鐨勬儏鍐� -- Gitblit v1.9.1