| | |
| | | global class updateESignBatch implements Database.Batchable < sObject > , Database.Stateful { |
| | | global class updateESignBatch implements Database.Batchable<sObject>, Database.Stateful { |
| | | //电子签收单-签收单录入表更新签收单 精琢技术 wql 2020-09-25 start |
| | | /* |
| | | ①正常执行 Database.executeBatch(new updateESignBatch(), 20); |
| | |
| | | //存放需要更新的签收单id |
| | | private String id; |
| | | //存放需要更新的一些签收单 |
| | | private List < String > ids; |
| | | private List<String> ids; |
| | | //存放已经最终状态的flag |
| | | private Boolean flag; |
| | | //用于执行batch同时记录日志信息 |
| | | private BatchIF_Log__c iflog; |
| | | global List < String > emailMessages = new List < String > (); |
| | | global List<String> emailMessages = new List<String>(); |
| | | global Integer totalCount = 0; // 总件数 |
| | | global Integer failedCount = 0; //失败件数 |
| | | global Boolean ManualExecution_Identification = false; |
| | | //默认跑所有签收单 |
| | | global updateESignBatch() { |
| | | |
| | | iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = 'ESignBatch'; |
| | | iflog.Is_Error__c = 0; |
| | |
| | | // insert iflog; |
| | | } |
| | | //批量更新签收单 |
| | | global updateESignBatch(List < String > ids) { |
| | | global updateESignBatch(List<String> ids) { |
| | | //手动标识置成true |
| | | this.ManualExecution_Identification = true; |
| | | this.ids = ids; |
| | |
| | | } |
| | | //更新某一条的签收单 |
| | | global updateESignBatch(String id) { |
| | | |
| | | //手动标识置成true |
| | | this.ManualExecution_Identification = true; |
| | | system.debug('手动传参1:' + ManualExecution_Identification); |
| | |
| | | // insert iflog; |
| | | } |
| | | //批量更新已处理的签收单 |
| | | global updateESignBatch(List < String > ids, boolean flag) { |
| | | global updateESignBatch(List<String> ids, boolean flag) { |
| | | //手动标识置成true |
| | | this.ManualExecution_Identification = true; |
| | | this.ids = ids; |
| | |
| | | // 如果哟同名的Batch计划删除已存在的计划重新设置 |
| | | if (haveError) { |
| | | haveError = false; |
| | | for (CronTrigger ct : [SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name |
| | | FROM CronTrigger |
| | | WHERE CronJobDetail.Name = :scB.scName]) { |
| | | for (CronTrigger ct : [ |
| | | SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name |
| | | FROM CronTrigger |
| | | WHERE CronJobDetail.Name = :scB.scName |
| | | ]) { |
| | | System.abortJob(ct.Id); |
| | | } |
| | | try { |
| | |
| | | if (spafter != null && String.isNotBlank(spafter)) { |
| | | b.scName = baseName + '005'; |
| | | b.scTime = spafter + ' ' + day + ' ' + month + ' ? ' + year; |
| | | |
| | | |
| | | // system.schedule(sJobame,spafter + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule()); |
| | | return b; |
| | | } else { |
| | |
| | | b.scName = baseName + '001'; |
| | | b.scTime = '0 ' + minMin + ' ' + (hour + 1) + ' ' + day + ' ' + month + ' ? ' + year; |
| | | // system.schedule(sJobame,'0 ' + minMin + ' ' + (hour + 1) +' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule()); |
| | | |
| | | } |
| | | return b; |
| | | } |
| | | |
| | | public static void removeOtherSc(String likeName, String needName) { |
| | | String likeStr = likeName + '00%'; |
| | | for (CronTrigger ct : [SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name |
| | | FROM CronTrigger |
| | | WHERE CronJobDetail.Name Like :likeStr |
| | | AND CronJobDetail.Name != :needName]) { |
| | | for (CronTrigger ct : [ |
| | | SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name |
| | | FROM CronTrigger |
| | | WHERE CronJobDetail.Name LIKE :likeStr AND CronJobDetail.Name != :needName |
| | | ]) { |
| | | System.abortJob(ct.Id); |
| | | } |
| | | } |
| | | |
| | | global void execute(Database.BatchableContext BC, list < eSignForm__c > eSignList) { |
| | | global void execute(Database.BatchableContext BC, list<eSignForm__c> eSignList) { |
| | | //用作录入表的检索条件 |
| | | List < String > esFormidList = new List < String > (); |
| | | List<String> esFormidList = new List<String>(); |
| | | //存放签收单录入表明细 |
| | | List < eSignFormLineItemEntry__c > eSignFormLineItemEntryList = new List < eSignFormLineItemEntry__c > (); |
| | | List<eSignFormLineItemEntry__c> eSignFormLineItemEntryList = new List<eSignFormLineItemEntry__c>(); |
| | | //用作签收单明细的检索条件 |
| | | List < String > eSignFormLineIdList = new List < String > (); |
| | | List<String> eSignFormLineIdList = new List<String>(); |
| | | //更新的签收单明细 |
| | | List < eSignFormLineItem__c > eSignFormLuRUList = new List < eSignFormLineItem__c > (); |
| | | List<eSignFormLineItem__c> eSignFormLuRUList = new List<eSignFormLineItem__c>(); |
| | | //存放最后更新的 录入表id |
| | | List < Id > fileIdList = new List < Id > (); |
| | | List<Id> fileIdList = new List<Id>(); |
| | | //存放最新的 签收单id,签收单录入id |
| | | Map < Id, Id > eSignIdMap = new Map < Id, Id > (); |
| | | Map<Id, Id> eSignIdMap = new Map<Id, Id>(); |
| | | |
| | | //存放最新的 签收单id,签收单录入id 用于最后一条签收单录入表不删除 |
| | | Map < Id, Id > eSignFormLastIdMap = new Map < Id, Id > (); |
| | | Map<Id, Id> eSignFormLastIdMap = new Map<Id, Id>(); |
| | | |
| | | //存放最新的 签收单id,签收单录入id 用于文件更新 |
| | | Map < Id, Id > eSignFlieIdMap = new Map < Id, Id > (); |
| | | Map<Id, Id> eSignFlieIdMap = new Map<Id, Id>(); |
| | | |
| | | //存放录入表id,录入表 |
| | | Map < String, eSignFormEntry__c > lasteSignFormEntryMap = new Map < String, eSignFormEntry__c > (); |
| | | Map<String, eSignFormEntry__c> lasteSignFormEntryMap = new Map<String, eSignFormEntry__c>(); |
| | | //存放最新的 签收单明细id,签收单明细录入id |
| | | Map < Id, Id > eSignFormLineItemEntryIdMap = new Map < Id, Id > (); |
| | | Map<Id, Id> eSignFormLineItemEntryIdMap = new Map<Id, Id>(); |
| | | //签收单录入表明细id,签收单录入表明细 |
| | | Map < String, eSignFormLineItemEntry__c > lasteSignFormLineItemEntryMap = new Map < String, eSignFormLineItemEntry__c > (); |
| | | Map<String, eSignFormLineItemEntry__c> lasteSignFormLineItemEntryMap = new Map<String, eSignFormLineItemEntry__c>(); |
| | | //存放 签收单id,文件数量 |
| | | Map < String, Integer > fileMap = new Map < String, Integer > (); |
| | | Map<String, Integer> fileMap = new Map<String, Integer>(); |
| | | //驳回后删除文件 后 排序问题 精琢技术 wql 2020/12/24 start |
| | | // List<Attachment> esignAttachAgencyList = new List<Attachment>(); |
| | | // List<Attachment> esignAttachHPList = new List<Attachment>(); |
| | | List<FileAddress__c> esignAttachAgencyList = new List<FileAddress__c>(); //zhj Attachment To AWS 2023-02-06 |
| | | List<FileAddress__c> esignAttachHPList = new List<FileAddress__c>(); //zhj Attachment To AWS 2023-02-06 |
| | | List<Attachment> esignAttachAgencyList = new List<Attachment>(); |
| | | List<Attachment> esignAttachHPList = new List<Attachment>(); |
| | | Map<String, Integer> fileAgencyMap = new Map<String, Integer>(); |
| | | Map<String, Integer> fileHPMap = new Map<String, Integer>(); |
| | | //驳回后删除文件 后 排序问题 精琢技术 wql 2020/12/24 end |
| | | //存放ocsm管理省 |
| | | List < String > provinceList = new List < String > (); |
| | | List<String> provinceList = new List<String>(); |
| | | //存放15位签收单id,ocsm管理省 |
| | | Map < Id, String > provinceMap = new Map < Id, String > (); |
| | | Map<Id, String> provinceMap = new Map<Id, String>(); |
| | | //存放用于更新的签收单数组 |
| | | List < eSignForm__c > eSignFormList = new List < eSignForm__c > (); |
| | | List<eSignForm__c> eSignFormList = new List<eSignForm__c>(); |
| | | //存放签收单录入表id,name |
| | | Map < Id, String > eSignNameMap = new Map < Id, String > (); |
| | | Map<Id, String> eSignNameMap = new Map<Id, String>(); |
| | | //存放签收单录入表id,type |
| | | Map < Id, String > eSignTypeMap = new Map < Id, String > (); |
| | | Map<Id, String> eSignTypeMap = new Map<Id, String>(); |
| | | |
| | | //删除中间表数据用 |
| | | Map < String, eSignFormEntry__c > eSignStringMap = new Map < String, eSignFormEntry__c > (); |
| | | Map<String, eSignFormEntry__c> eSignStringMap = new Map<String, eSignFormEntry__c>(); |
| | | //存放所有签收单录入表id |
| | | List < String > luruIsSubmitList = new List < String > (); |
| | | List<String> luruIsSubmitList = new List<String>(); |
| | | |
| | | //存放所有签收单录入表id |
| | | List < String > luruIsLastSubmitList = new List < String > (); |
| | | List<String> luruIsLastSubmitList = new List<String>(); |
| | | //判断是否有未处理的录入表 |
| | | Map < Id, eSignFormEntry__c > unprocessedESignEneryMap = new Map < Id, eSignFormEntry__c > (); |
| | | Map<Id, eSignFormEntry__c> unprocessedESignEneryMap = new Map<Id, eSignFormEntry__c>(); |
| | | |
| | | //用于判断删除驳回的附件的筛选条件 |
| | | Map < Id, eSignForm__c > rejectESignEneryMap = new Map < Id, eSignForm__c > (); |
| | | Map<Id, eSignForm__c> rejectESignEneryMap = new Map<Id, eSignForm__c>(); |
| | | //驳回后 删除之前上传的文件id |
| | | //List<Attachment> deleteLastFileList = new List<Attachment>(); |
| | | List<FileAddress__c> deleteLastFileList = new List<FileAddress__c>(); //zhj Attachment To AWS 2023-02-06 |
| | | List<Attachment> deleteLastFileList = new List<Attachment>(); |
| | | //存放未更新前的经销商审批状态 |
| | | Map < String, String > oldESignAgencyStatusMap = new Map < String, String > (); |
| | | Map<String, String> oldESignAgencyStatusMap = new Map<String, String>(); |
| | | //存放未更新前的医院审批状态 |
| | | Map < String, String > oldESignHPStatusMap = new Map < String, String > (); |
| | | Map<String, String> oldESignHPStatusMap = new Map<String, String>(); |
| | | try { |
| | | //循环存放签收单id 用作检索签收单录入表的条件 |
| | | system.debug('eSignList:' + eSignList); |
| | | if (eSignList.size() > 0) { |
| | | for (eSignForm__c esForm : eSignList) { |
| | | //存放签收单id,ocsm管理省 如果询价是集采 则取ocsm管理省为集采课的担当 |
| | | if(esForm.Statu_Achievements__r.Opportunity__r.Group_purchase_PCL__c){ |
| | | if (esForm.Statu_Achievements__r.Opportunity__r.Group_purchase_PCL__c) { |
| | | provinceMap.put(esForm.Id, '集采课'); |
| | | //检索条件 |
| | | provinceList.add('集采课'); |
| | | }else{ |
| | | } else { |
| | | provinceMap.put(esForm.Id, esForm.OCM_man_province_cus__c); |
| | | //检索条件 |
| | | provinceList.add(esForm.OCM_man_province_cus__c); |
| | | } |
| | | |
| | | |
| | | esFormidList.add(esForm.Id); |
| | | |
| | | //有经销商驳回或者医院驳回时删除之前附件 |
| | | if (esForm.agencyRejectDate__c != null || esForm.HPRejectDate__c != null) { |
| | | rejectESignEneryMap.put(esForm.Id, esForm); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | system.debug('rejectESignEneryMap:' + rejectESignEneryMap); |
| | | //如果map不为空 则作为筛选条件 |
| | | if (rejectESignEneryMap.size()>0) { |
| | | // List<Attachment> deleteFileList = [SELECT parentId, createdDate, Name,Description |
| | | // FROM Attachment |
| | | // WHERE parentId IN: rejectESignEneryMap.keySet() order by createdDate]; |
| | | List<FileAddress__c> deleteFileList = [SELECT ParentRecordId__c, createdDate, FileName__c |
| | | FROM FileAddress__c |
| | | WHERE ParentRecordId__c IN: rejectESignEneryMap.keySet() order by createdDate]; //zhj Attachment To AWS 2023-02-06 |
| | | if (rejectESignEneryMap.size() > 0) { |
| | | List<Attachment> deleteFileList = [ |
| | | SELECT parentId, createdDate, Name, Description |
| | | FROM Attachment |
| | | WHERE parentId IN :rejectESignEneryMap.keySet() |
| | | ORDER BY createdDate |
| | | ]; |
| | | system.debug('deleteFileList:' + deleteFileList); |
| | | if (deleteFileList.size() > 0) { |
| | | for (eSignForm__c esFile : rejectESignEneryMap.values()) { |
| | | //for (Attachment att : deleteFileList) { |
| | | for (FileAddress__c att : deleteFileList) { //zhj Attachment To AWS 2023-02-06 |
| | | for (Attachment att : deleteFileList) { |
| | | if (esFile.agencyRejectDate__c != null || esFile.HPRejectDate__c != null) { |
| | | if (att.ParentRecordId__c == esFile.Id ) { |
| | | if (att.parentId == esFile.Id) { |
| | | //①经销商驳回后需要删除的附件 |
| | | if (esFile.agencyRejectDate__c != null) { |
| | | //zhj Attachment To AWS 2023-02-06 |
| | | // if (att.Name.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) { |
| | | // deleteLastFileList.add(att); |
| | | // } |
| | | if (att.FileName__c.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) { |
| | | if (att.Name.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) { |
| | | deleteLastFileList.add(att); |
| | | } |
| | | } |
| | | //②医院驳回后需要删除的附件 |
| | | if (esFile.HPRejectDate__c != null) { |
| | | //zhj Attachment To AWS 2023-02-06 |
| | | // if (att.Name.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) { |
| | | // deleteLastFileList.add(att); |
| | | // } |
| | | if (att.FileName__c.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) { |
| | | if (att.Name.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) { |
| | | deleteLastFileList.add(att); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | system.debug('驳回后删除的文件:' + deleteLastFileList); |
| | |
| | | } |
| | | |
| | | //检索所有录入表 |
| | | List < eSignFormEntry__c > eSignFormEntryList = [select id, Name, entryType__c, eSignForm__c, eSignForm__r.OCM_man_province_cus__c, salesManageConfirmDate__c, salesHPManageConfirmDate__c, agencyScanDayBack__c, agencySignUpDateBack__c, agencyConfirmDateBack__c, HPScanDayBack__c, HPSignUpDateBack__c, HPConfirmDateBack__c, |
| | | eSignForm__r.Name, IsSubmit__c, IsHPSubmit__c, IsAgencyConfirmSubmit__c, agencyAutoSignUpStatus__c, HPSignUpStatus__c, Sales_Root_Formula__c, Sales_assistant_ID__c, IsHandled__c, IsHPHandled__c, createdDate, AgencyWorkflowEmailBack__c, HPWorkflowEmailBack__c, AgencyWorkflowEmail__c, HPWorkflowEmail__c, eSignForm__r.Id, agencyDNSignUpStatus__c, HPDNSignUpStatus__c, agencyReject__c, HPReject__c, IsAgencyScan__c, IsHPScan__c |
| | | from eSignFormEntry__c |
| | | where eSignForm__c IN: esFormidList |
| | | order by eSignForm__c, createdDate asc |
| | | ]; |
| | | List<eSignFormEntry__c> eSignFormEntryList = [ |
| | | SELECT |
| | | id, |
| | | Name, |
| | | entryType__c, |
| | | eSignForm__c, |
| | | eSignForm__r.OCM_man_province_cus__c, |
| | | salesManageConfirmDate__c, |
| | | salesHPManageConfirmDate__c, |
| | | agencyScanDayBack__c, |
| | | agencySignUpDateBack__c, |
| | | agencyConfirmDateBack__c, |
| | | HPScanDayBack__c, |
| | | HPSignUpDateBack__c, |
| | | HPConfirmDateBack__c, |
| | | eSignForm__r.Name, |
| | | IsSubmit__c, |
| | | IsHPSubmit__c, |
| | | IsAgencyConfirmSubmit__c, |
| | | agencyAutoSignUpStatus__c, |
| | | HPSignUpStatus__c, |
| | | Sales_Root_Formula__c, |
| | | Sales_assistant_ID__c, |
| | | IsHandled__c, |
| | | IsHPHandled__c, |
| | | createdDate, |
| | | AgencyWorkflowEmailBack__c, |
| | | HPWorkflowEmailBack__c, |
| | | AgencyWorkflowEmail__c, |
| | | HPWorkflowEmail__c, |
| | | eSignForm__r.Id, |
| | | agencyDNSignUpStatus__c, |
| | | HPDNSignUpStatus__c, |
| | | agencyReject__c, |
| | | HPReject__c, |
| | | IsAgencyScan__c, |
| | | IsHPScan__c |
| | | FROM eSignFormEntry__c |
| | | WHERE eSignForm__c IN :esFormidList |
| | | ORDER BY eSignForm__c, createdDate ASC |
| | | ]; |
| | | |
| | | if (eSignFormEntryList.size() > 0) { |
| | | for (Id eid : esFormidList) { |
| | |
| | | //未处理的 |
| | | unprocessedESignEneryMap.put(eid, eSignFormEntryWhole); |
| | | } |
| | | if (eSignFormEntryWhole.eSignForm__r.Id == eid) { |
| | | if (eSignFormEntryWhole.eSignForm__r.Id == eid) { |
| | | //存放 签收单id,录入表id 文件用 |
| | | eSignFlieIdMap.put(eSignFormEntryWhole.Id, eid); |
| | | //存放签收单录入表,id,name 文件用 |
| | | eSignNameMap.put(eid, eSignFormEntryWhole.eSignForm__r.Name); |
| | | } |
| | | |
| | | |
| | | //存放录入表id,记录类型 id,type 文件用 |
| | | eSignTypeMap.put(eSignFormEntryWhole.Id, eSignFormEntryWhole.entryType__c); |
| | |
| | | for (Id esFormid : esFormidList) { |
| | | //内层是签收单录入表 |
| | | for (eSignFormEntry__c eSignFormEntry : eSignFormEntryList) { |
| | | |
| | | //①取最新的 录入表 + 未处理的 |
| | | if (esFormid.equals(eSignFormEntry.eSignForm__c)) { |
| | | |
| | | if (!eSignFormEntry.IsHandled__c) { |
| | | //存放 签收单id,录入表id |
| | | eSignIdMap.put(esFormid, eSignFormEntry.Id); |
| | |
| | | // break; |
| | | } |
| | | eSignFormLastIdMap.put(esFormid, eSignFormEntry.Id); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | //最后更新的录入表id |
| | |
| | | //重新对附件排序 规则变为根据签收单现有附件序号进行排序 精琢技术 wql start |
| | | //暂时存放一下签收单名称 |
| | | Map<string, string> tempMap = new Map<string, string>(); |
| | | //zhj Attachment To AWS 2023-02-06 |
| | | // List<Attachment> tempAttList = [SELECT parentId, createdDate, Name,Description |
| | | // FROM Attachment |
| | | // WHERE parentId IN: esFormidList order by createdDate]; |
| | | List<FileAddress__c> tempAttList = [SELECT ParentRecordId__c, createdDate, FileName__c |
| | | FROM FileAddress__c |
| | | WHERE ParentRecordId__c IN: esFormidList order by createdDate]; |
| | | List<Attachment> tempAttList = [ |
| | | SELECT parentId, createdDate, Name, Description |
| | | FROM Attachment |
| | | WHERE parentId IN :esFormidList |
| | | ORDER BY createdDate |
| | | ]; |
| | | if (tempAttList.size() > 0) { |
| | | //外层循环签收单 |
| | | for (String es : esFormidList) { |
| | | //zhj Attachment To AWS 2023-02-06 |
| | | //内层循环附件 |
| | | // for (Attachment att : tempAttList) { |
| | | // //如果id相等 |
| | | // if (es.equals(att.parentId)) { |
| | | // //根据名称拆分 存入不同list |
| | | // String name = att.Name; |
| | | // if (name.substring(0, 1).equals('A')) { |
| | | // esignAttachAgencyList.add(att); |
| | | // } else if (name.substring(0, 1).equals('H')) { |
| | | // esignAttachHPList.add(att); |
| | | // } |
| | | |
| | | // } |
| | | // } |
| | | for (FileAddress__c att : tempAttList) { |
| | | for (Attachment att : tempAttList) { |
| | | //如果id相等 |
| | | if (es.equals(att.ParentRecordId__c)) { |
| | | if (es.equals(att.parentId)) { |
| | | //根据名称拆分 存入不同list |
| | | String name = att.FileName__c; |
| | | String name = att.Name; |
| | | if (name.substring(0, 1).equals('A')) { |
| | | esignAttachAgencyList.add(att); |
| | | } else if (name.substring(0, 1).equals('H')) { |
| | | esignAttachHPList.add(att); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //分别存入到经销商or医院的附件map 用于后期命名 |
| | |
| | | //清空list 供下一个签收单使用 |
| | | esignAttachAgencyList.clear(); |
| | | esignAttachHPList.clear(); |
| | | |
| | | } |
| | | } |
| | | system.debug('fileAgencyMap:' + fileAgencyMap); |
| | |
| | | //重新对附件排序 规则变为根据签收单现有附件序号进行排序 精琢技术 wql end |
| | | |
| | | //根据所有的签收单录入表id检索所有的签收单明细录入 |
| | | List < eSignFormLineItemEntry__c > eSignFormLineItemEntryLists = [select id, eSignFormEntry__r.entryType__c, eSignFormEntry__r.IsHandled__c, eSignFormLineItem__c, eSignFormEntry__c, |
| | | agencyConfirmResult__c, HPConfirmResult__c, HPGoodStatus__c, agencyGoodStatus__c |
| | | from eSignFormLineItemEntry__c where eSignFormEntry__c in : luruIsSubmitList and eSignFormEntry__r.IsHandled__c = false order by createdDate asc |
| | | ]; |
| | | List<eSignFormLineItemEntry__c> eSignFormLineItemEntryLists = [ |
| | | SELECT |
| | | id, |
| | | eSignFormEntry__r.entryType__c, |
| | | eSignFormEntry__r.IsHandled__c, |
| | | eSignFormLineItem__c, |
| | | eSignFormEntry__c, |
| | | agencyConfirmResult__c, |
| | | HPConfirmResult__c, |
| | | HPGoodStatus__c, |
| | | agencyGoodStatus__c |
| | | FROM eSignFormLineItemEntry__c |
| | | WHERE eSignFormEntry__c IN :luruIsSubmitList AND eSignFormEntry__r.IsHandled__c = FALSE |
| | | ORDER BY createdDate ASC |
| | | ]; |
| | | if (eSignFormLineItemEntryLists.size() > 0) { |
| | | for (eSignFormLineItemEntry__c eSignFormLineItemEntry : eSignFormLineItemEntryLists) { |
| | | eSignFormLineIdList.add(eSignFormLineItemEntry.eSignFormLineItem__c); |
| | |
| | | system.debug('eSignFormLineIdList:' + eSignFormLineIdList); |
| | | if (eSignFormLineIdList.size() > 0) { |
| | | //根据签收单明细录入表 去检索签收单明细 |
| | | List < eSignFormLineItem__c > eSignFormLineItemList = [select id, agencyGoodStatus__c, HPGoodStatus__c from eSignFormLineItem__c where id IN: eSignFormLineIdList]; |
| | | List<eSignFormLineItem__c> eSignFormLineItemList = [ |
| | | SELECT id, agencyGoodStatus__c, HPGoodStatus__c |
| | | FROM eSignFormLineItem__c |
| | | WHERE id IN :eSignFormLineIdList |
| | | ]; |
| | | if (eSignFormLineItemList.size() > 0) { |
| | | //外层签收单明细 |
| | | for (eSignFormLineItem__c eSignFormLineItem : eSignFormLineItemList) { |
| | |
| | | if (eSignFormLineIdList.size() > 0) { |
| | | //循环 更新签收单 |
| | | for (Id esefId : eSignFormLineIdList) { |
| | | |
| | | if (lasteSignFormLineItemEntryMap.containsKey(esefId)) { |
| | | eSignFormLineItemEntry__c luru = lasteSignFormLineItemEntryMap.get(esefId); |
| | | //new 一个签收单明细对象 |
| | |
| | | eSignFormLuRuList.add(eSignLuRu); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | System.debug('更新的签收单明细list:' + eSignFormLuRUList); |
| | |
| | | if (eSignFormEntry.agencyScanDayBack__c != null && eSignFormEntry.IsAgencyScan__c) { |
| | | eSignForm.agencyAutoSignUpStatus__c = '草案中'; |
| | | eSignForm.agencyReject__c = false; |
| | | |
| | | } |
| | | } |
| | | } |
| | | //未更新前的经销商审批状态 用于文件累计汇总 |
| | | if(eSignFormEntry.agencyAutoSignUpStatus__c!=null &&eSignFormEntry.agencyAutoSignUpStatus__c!=''){ |
| | | if (eSignFormEntry.agencyAutoSignUpStatus__c != null && eSignFormEntry.agencyAutoSignUpStatus__c != '') { |
| | | oldESignAgencyStatusMap.put('A' + eSignForm.id, eSignFormEntry.agencyAutoSignUpStatus__c); |
| | | }else{ |
| | | } else { |
| | | oldESignAgencyStatusMap.put('A' + eSignForm.id, '无'); |
| | | } |
| | | |
| | | } |
| | | if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') { |
| | | //如果医院确认日为空的话 进去判断更新医院审批状态 |
| | |
| | | if (eSignFormEntry.HPScanDayBack__c != null && eSignFormEntry.IsHPScan__c) { |
| | | eSignForm.HPSignUpStatus__c = '草案中'; |
| | | eSignForm.HPReject__c = false; |
| | | |
| | | } |
| | | } |
| | | } |
| | | //未更新前的医院审批状态 用于文件累计汇总 |
| | | if(eSignFormEntry.HPSignUpStatus__c!=null &&eSignFormEntry.HPSignUpStatus__c!=''){ |
| | | if (eSignFormEntry.HPSignUpStatus__c != null && eSignFormEntry.HPSignUpStatus__c != '') { |
| | | oldESignHPStatusMap.put('H' + eSignForm.id, eSignFormEntry.HPSignUpStatus__c); |
| | | }else{ |
| | | } else { |
| | | oldESignHPStatusMap.put('H' + eSignForm.id, '无'); |
| | | } |
| | | |
| | | } |
| | | |
| | | //如果没变化则不更新 |
| | |
| | | Sales_Root_Formula = eSignFormEntry.Sales_Root_Formula__c; |
| | | //录入类型 |
| | | type = eSignFormEntry.entryType__c; |
| | | |
| | | } |
| | | system.debug('签收单对象-----:' + eSignForm); |
| | | if (eSignForm != null) { |
| | | system.debug('eSignFormid:' + eSignFormid); |
| | | if (eSignForm.id != null) { |
| | | |
| | | eSignFormList.add(eSignForm); |
| | | } |
| | | |
| | | } |
| | | system.debug('eSignFormList111:' + eSignFormList); |
| | | if (eSignFormList.size() > 0) { |
| | | //更新OCSM管理省 担当 |
| | | eSignFormList = updateOwner(provinceList, provinceMap, eSignFormList, false); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | if (eSignFormList.size() <= 0) { |
| | | system.debug('我走到这里了!'); |
| | | eSignFormList = updateOwner(provinceList, provinceMap, eSignList, true); |
| | | eSignFormList = updateOwner(provinceList, provinceMap, eSignList, true); |
| | | } |
| | | |
| | | |
| | | List<Id> fileList = new List<Id> (); |
| | | List<Id> fileList = new List<Id>(); |
| | | if (fileIdList.size() > 0) { |
| | | for (Id fileId : fileIdList) { |
| | | if (!fileList.contains(fileId)) { |
| | | fileList.add(fileId); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | System.debug('fileIdList:' + fileIdList); |
| | | System.debug('fileList:' + fileList); |
| | | //用于最后insert 附件 |
| | | //zhj Attachment To AWS 2023-02-06 |
| | | //List<Attachment> insertAttactment = new List<Attachment>(); |
| | | List<FileAddress__c> insertAttactment = new List<FileAddress__c>(); |
| | | List<Attachment> insertAttactment = new List<Attachment>(); |
| | | //附件 start |
| | | //List<Attachment> attachMentList = [SELECT id, parentId, Body, Name, ContentType,Description from Attachment where parentId IN :fileList and Description!='电子签收单:已处理']; |
| | | List<FileAddress__c> attachMentList = [SELECT id, ParentRecordId__c, FileName__c,subInfoType__c,AWS_File_Key__c,DownloadLink__c,ViewLink__c from FileAddress__c where ParentRecordId__c IN :fileList and subInfoType__c !='电子签收单:已处理']; |
| | | //修复已处理数据 附件没更新 即没有附件能提交的bug 精琢技术 wql 2021/01/19 start |
| | | //List<Attachment> eSignEntryAttachMentList = new List<Attachment>(); |
| | | List<FileAddress__c> eSignEntryAttachMentList = new List<FileAddress__c>(); |
| | | List<Attachment> attachMentList = [ |
| | | SELECT id, parentId, Body, Name, ContentType, Description |
| | | FROM Attachment |
| | | WHERE parentId IN :fileList AND Description != '电子签收单:已处理' |
| | | ]; |
| | | //修复已处理数据 附件没更新 即没有附件能提交的bug 精琢技术 wql 2021/01/19 start |
| | | List<Attachment> eSignEntryAttachMentList = new List<Attachment>(); |
| | | //文件数量 用于文件命名 |
| | | Integer agencyCount = 0; |
| | | Integer hpCount = 0; |
| | | |
| | | String name; |
| | | String type ; |
| | | String type; |
| | | Integer agencyFileCountNum = 0; |
| | | Integer hpFileCountNum = 0; |
| | | Integer i = 0; |
| | | Integer j = 0; |
| | | //记录该签收单的最新经销商附件数量 |
| | | Map<id,Integer> eSignAgencyAttSum = new Map<id,Integer> (); |
| | | Map<id, Integer> eSignAgencyAttSum = new Map<id, Integer>(); |
| | | //记录该签收单的最新医院附件数量 |
| | | Map<id,Integer> eSignHpAttSum = new Map<id,Integer> (); |
| | | Map<id, Integer> eSignHpAttSum = new Map<id, Integer>(); |
| | | |
| | | //同一条录入表多个附件标识 |
| | | Boolean agencyNumFlag = false; |
| | |
| | | system.debug('eSignFlieIdMap:' + eSignFlieIdMap); |
| | | system.debug('eSignNameMap:' + eSignNameMap); |
| | | for (Id eSignFormEntryId : fileList) { |
| | | |
| | | for (FileAddress__c attach : attachMentList) { //zhj Attachment To AWS 2023-02-06 |
| | | |
| | | if (attach.ParentRecordId__c == eSignFormEntryId) { |
| | | Id eid = eSignFlieIdMap.get(attach.ParentRecordId__c); |
| | | for (Attachment attach : attachMentList) { |
| | | if (attach.parentId == eSignFormEntryId) { |
| | | Id eid = eSignFlieIdMap.get(attach.parentId); |
| | | system.debug('eid:' + eid); |
| | | |
| | | name = eSignNameMap.get(eid); |
| | | system.debug('name:' + name); |
| | | type = eSignTypeMap.get(attach.ParentRecordId__c); |
| | | type = eSignTypeMap.get(attach.parentId); |
| | | |
| | | //因为外层循环是中间表 如果2条以上录入表都有经销商附件 则使用最新构建的经销商附件数量来命名 |
| | | //否则取未更新之前有的经销商附件数量 并且 不是1个录入表多个附件 也就是false的时候 取模拟的最新数量 |
| | | if(eSignAgencyAttSum.size()>0&&!agencyNumFlag){ |
| | | if (eSignAgencyAttSum.size() > 0 && !agencyNumFlag) { |
| | | agencyCount = eSignAgencyAttSum.get(eid); |
| | | //记录一个最新的附件数 |
| | | agencySumCount =agencyCount; |
| | | }else if(agencySumCount>0){ |
| | | agencySumCount = agencyCount; |
| | | } else if (agencySumCount > 0) { |
| | | //本次循环内 第一次取附件数最新值 后续都在此基础上i++ |
| | | agencyCount =agencySumCount; |
| | | } |
| | | else if(fileAgencyMap.size() > 0){ |
| | | agencyCount = agencySumCount; |
| | | } else if (fileAgencyMap.size() > 0) { |
| | | //只有一条数据时,使用此附件数即可 后续在此基础上i++ |
| | | agencyCount = fileAgencyMap.get(eid); |
| | | } |
| | |
| | | //经销商附件命名 end |
| | | //因为外层循环是中间表 如果2条以上录入表都有医院附件 则使用最新构建的医院附件数量来命名 |
| | | //否则取未更新之前有的医院附件数量 并且 不是1个录入表多个附件 也就是false的时候 取模拟的最新数量 |
| | | if(eSignHpAttSum.size()>0&&!hpNumFlag){ |
| | | if (eSignHpAttSum.size() > 0 && !hpNumFlag) { |
| | | hpCount = eSignHpAttSum.get(eid); |
| | | //记录一个最新的附件数 |
| | | hpSumCount = hpCount; |
| | | }else if(hpSumCount >0 ){ |
| | | } else if (hpSumCount > 0) { |
| | | //本次循环内 第一次取附件数最新值 后续都在此基础上j++ |
| | | hpCount =hpSumCount; |
| | | } |
| | | else if(fileHPMap.size() > 0){ |
| | | hpCount = hpSumCount; |
| | | } else if (fileHPMap.size() > 0) { |
| | | //只有一条数据时,使用此附件数即可 后续在此基础上j++ |
| | | hpCount = fileHPMap.get(eid); |
| | | } |
| | | //同一个内部循环里置成true |
| | | hpNumFlag =true; |
| | | hpNumFlag = true; |
| | | //医院附件命名 start |
| | | // if (fileHPMap.size() > 0) { |
| | | // hpCount = fileHPMap.get(eid); |
| | |
| | | hpFileCountNum = hpCount + 1 + j; |
| | | } |
| | | //构建最新的签收单经销商附件数量 |
| | | if(agencyFileCountNum>0){ |
| | | eSignAgencyAttSum.put(eid,agencyFileCountNum); |
| | | if (agencyFileCountNum > 0) { |
| | | eSignAgencyAttSum.put(eid, agencyFileCountNum); |
| | | } |
| | | //构建最新的签收单医院附件数量 |
| | | if(hpFileCountNum>0){ |
| | | eSignHpAttSum.put(eid,hpFileCountNum); |
| | | if (hpFileCountNum > 0) { |
| | | eSignHpAttSum.put(eid, hpFileCountNum); |
| | | } |
| | | //医院附件命名 end |
| | | //用于拆分经销商/医院 区别文件名 |
| | |
| | | // title = title +'.jpg'; |
| | | // } |
| | | //判断一下格式,不然下载下来是类型是所有文件 无法打开 |
| | | //zhj Attachment To AWS 2023-02-06 start |
| | | if (attach.FileName__c.lastIndexOf('.') > -1) { |
| | | title = title + attach.FileName__c.substring(attach.FileName__c.lastIndexOf('.')); |
| | | if (attach.Name.lastIndexOf('.') > -1) { |
| | | title = title + attach.Name.substring(attach.Name.lastIndexOf('.')); |
| | | } |
| | | |
| | | //Attachment newAttachment = attach.clone(); |
| | | FileAddress__c newAttachment = attach.clone(); |
| | | newAttachment.ParentRecordId__c = eid; |
| | | newAttachment.FileName__c = title; |
| | | Attachment newAttachment = attach.clone(); |
| | | newAttachment.parentId = eid; |
| | | newAttachment.name = title; |
| | | // newAttachment.ContentType =attach.ContentType; |
| | | //要更新的签收单附件 |
| | | insertAttactment.add(newAttachment); |
| | | //反更新录入表的附件 用来判断附件是否被更新 |
| | | //Attachment oldAttachment = new Attachment(); |
| | | FileAddress__c oldAttachment = new FileAddress__c(); |
| | | Attachment oldAttachment = new Attachment(); |
| | | oldAttachment.Id = attach.Id; |
| | | //oldAttachment.Description = '电子签收单:已处理'; |
| | | oldAttachment.subInfoType__c = '电子签收单:已处理'; |
| | | //zhj Attachment To AWS 2023-02-06 end |
| | | oldAttachment.Description = '电子签收单:已处理'; |
| | | eSignEntryAttachMentList.add(oldAttachment); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | //整单循环后 清空值 |
| | | i = 0; |
| | | j = 0; |
| | | agencyNumFlag= false; |
| | | hpNumFlag =false; |
| | | agencySumCount =0; |
| | | hpSumCount=0; |
| | | agencyNumFlag = false; |
| | | hpNumFlag = false; |
| | | agencySumCount = 0; |
| | | hpSumCount = 0; |
| | | } |
| | | |
| | | } |
| | | |
| | | //电子签收单 增加本次更新附件数量 2020/01/07 精琢技术 wql start |
| | |
| | | if (insertAttactment.size() > 0) { |
| | | insert insertAttactment; |
| | | //反向更新录入表附件 |
| | | if(eSignEntryAttachMentList.size()>0){ |
| | | if (eSignEntryAttachMentList.size() > 0) { |
| | | update eSignEntryAttachMentList; |
| | | } |
| | | |
| | |
| | | if (eSignFormList.size() > 0) { |
| | | //外层所有签收单 |
| | | for (eSignForm__c es : eSignFormList) { |
| | | |
| | | //a为经销商附件的数量 h为医院附件的数量 |
| | | Integer a = 0; |
| | | Integer h = 0; |
| | | |
| | | //内层所有需要更新的附件 |
| | | //for (Attachment att : insertAttactment) { |
| | | for (FileAddress__c att : insertAttactment) { //zhj Attachment To AWS 2023-02-06 |
| | | for (Attachment att : insertAttactment) { |
| | | if (es.Id != null) { |
| | | if (es.Id.equals(att.ParentRecordId__c)) { |
| | | if (es.Id.equals(att.parentId)) { |
| | | if (es.agencyAutoSignUpStatus__c != null) { |
| | | if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size()>0) { |
| | | if(!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')){ |
| | | if (att.FileName__c.substring(0, 1).equals('A')) { //zhj Attachment To AWS 2023-02-06 |
| | | a ++; |
| | | } |
| | | if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size() > 0) { |
| | | if (!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')) { |
| | | if (att.Name.substring(0, 1).equals('A')) { |
| | | a++; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | if (es.HPSignUpStatus__c != null) { |
| | | if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size()>0) { |
| | | if(!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')){ |
| | | if (att.FileName__c.substring(0, 1).equals('H')) { //zhj Attachment To AWS 2023-02-06 |
| | | h ++; |
| | | if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size() > 0) { |
| | | if (!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')) { |
| | | if (att.Name.substring(0, 1).equals('H')) { |
| | | h++; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | //只有真正扫码提交的 并且没有附件才会被更新 |
| | | if (es.agencyAutoSignUpStatus__c != null) { |
| | | if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size()>0) { |
| | | if(!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')){ |
| | | if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size() > 0) { |
| | | if (!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')) { |
| | | es.agencyAttachNum__c = a; |
| | | } |
| | | |
| | | } |
| | | } |
| | | //只有真正扫码提交的 并且没有附件才会被更新 |
| | | if (es.HPSignUpStatus__c != null) { |
| | | if (es.HPSignUpStatus__c.equals('申请中') &&oldESignHPStatusMap.size()>0 ) { |
| | | if(!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')){ |
| | | es.HPAttachNum__c = h; |
| | | if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size() > 0) { |
| | | if (!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')) { |
| | | es.HPAttachNum__c = h; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | a = 0; |
| | | h = 0; |
| | | |
| | | } |
| | | } |
| | | //电子签收单 增加本次更新附件数量 2020/01/07 精琢技术 wql end |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | }catch(NullPointerException npe){ |
| | | |
| | | iflog.ErrorLog__c += 'ERROR : eSignForm__c:空指针错误-行号:'+ npe.getLineNumber()+ '\n'; |
| | | } |
| | | catch (Exception e) { |
| | | } catch (NullPointerException npe) { |
| | | iflog.ErrorLog__c += 'ERROR : eSignForm__c:空指针错误-行号:' + npe.getLineNumber() + '\n'; |
| | | } catch (Exception e) { |
| | | // Database.rollback(sp); |
| | | |
| | | iflog.ErrorLog__c += 'ERROR : eSignForm__c:'+ e.getMessage() + '\n'; |
| | | |
| | | iflog.ErrorLog__c += 'ERROR : eSignForm__c:' + e.getMessage() + '\n'; |
| | | } |
| | | try{ |
| | | System.debug('luruIsLastSubmitList:'+luruIsLastSubmitList); |
| | | try { |
| | | System.debug('luruIsLastSubmitList:' + luruIsLastSubmitList); |
| | | if (luruIsLastSubmitList.size() > 0) { |
| | | //删除中间表数据(因为住主详关系,删除录入表即可) |
| | | deleteMiddleData(eSignStringMap, luruIsLastSubmitList); |
| | | } |
| | | }catch(Exception e){ |
| | | iflog.ErrorLog__c += 'ERROR : eSignForm__c:'+ e.getMessage() + '\n'; |
| | | } catch (Exception e) { |
| | | iflog.ErrorLog__c += 'ERROR : eSignForm__c:' + e.getMessage() + '\n'; |
| | | } |
| | | //文件 end |
| | | } |
| | | |
| | | //删除中间表数据(因为住主详关系,删除录入表即可) |
| | | private static void deleteMiddleData(Map < String, eSignFormEntry__c > eSignStringMap, List < String > luruIsSubmitList) { |
| | | private static void deleteMiddleData(Map<String, eSignFormEntry__c> eSignStringMap, List<String> luruIsSubmitList) { |
| | | system.debug('检索的所有录入表:' + eSignStringMap); |
| | | system.debug('最后录入的id :' + luruIsSubmitList + '----数量:' + luruIsSubmitList.size()); |
| | | list < eSignFormEntry__c > eSignFormDeleteList = new list < eSignFormEntry__c > (); |
| | | list<eSignFormEntry__c> eSignFormDeleteList = new List<eSignFormEntry__c>(); |
| | | for (String essm : eSignStringMap.keySet()) { |
| | | for (String lisl : luruIsSubmitList) { |
| | | if (essm.equals(lisl)) { |
| | |
| | | } |
| | | system.debug('删除的数据id:' + eSignFormDeleteList + '----数量:' + eSignFormDeleteList.size()); |
| | | |
| | | |
| | | |
| | | //删除签收单录入表其他数据 |
| | | if (eSignFormDeleteList.size() > 0) { |
| | | //循环遍历id 删除文件 |
| | | List<String> fileDeleteIdList = new List<String> (); |
| | | //List<Attachment> deleteAttachmentList = new List<Attachment>(); |
| | | List<FileAddress__c> deleteAttachmentList = new List<FileAddress__c>(); //zhj Attachment To AWS 2023-02-06 |
| | | List<String> fileDeleteIdList = new List<String>(); |
| | | List<Attachment> deleteAttachmentList = new List<Attachment>(); |
| | | |
| | | for (eSignFormEntry__c eSigf : eSignFormDeleteList) { |
| | | fileDeleteIdList.add(eSigf.Id); |
| | | } |
| | | //循环找到文件id |
| | | if (fileDeleteIdList.size() > 0) { |
| | | |
| | | // 2022-02-28 shashiming Apex heap size too large |
| | | // 去掉Body字段 |
| | | //List<Attachment> attachMentList = [SELECT id, parentId, Name, ContentType,Description from Attachment where parentId = :fileDeleteIdList]; |
| | | List<FileAddress__c> attachMentList = [SELECT id, ParentRecordId__c, FileName__c,AWS_File_Key__c from FileAddress__c where ParentRecordId__c = :fileDeleteIdList]; //zhj Attachment To AWS 2023-02-06 |
| | | List<Transaction_Log__c> tranList = new List<Transaction_Log__c>(); |
| | | List<Attachment> attachMentList = [ |
| | | SELECT id, parentId, Name, ContentType, Description |
| | | FROM Attachment |
| | | WHERE parentId = :fileDeleteIdList |
| | | ]; |
| | | |
| | | if (attachMentList.size() > 0) { |
| | | for (FileAddress__c att : attachMentList) { |
| | | FileAddress__c am = new FileAddress__c(); //zhj Attachment To AWS 2023-02-06 |
| | | for (Attachment att : attachMentList) { |
| | | Attachment am = new Attachment(); |
| | | am.Id = att.Id; |
| | | deleteAttachmentList.add(am); |
| | | //zhj 新增日志,删除AWS的附件 2023-02-17 |
| | | Transaction_Log__c tran = new Transaction_Log__c(); |
| | | tran.AWS_Data_Id__c = att.AWS_File_Key__c; |
| | | tran.Status__c = 'In Process'; |
| | | tran.Module__c = '签收单附件删除'; |
| | | tranList.add(tran); |
| | | } |
| | | //新增日志,删除AWS的附件 zhj 2023-02-17 |
| | | if(tranList.size() > 0){ |
| | | insert tranList; |
| | | } |
| | | //删除文件 |
| | | if (deleteAttachmentList.size() > 0) { |
| | | delete deleteAttachmentList; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | //删除录入表 |
| | | System.debug('删除录入表 : ' + eSignFormDeleteList); |
| | | delete eSignFormDeleteList; |
| | | } |
| | | } |
| | | @TestVisible |
| | | //更新营业部担当 |
| | | private static List < eSignForm__c > updateOwner(List < String > provinceList, Map < Id, String > provinceMap, List < eSignForm__c > eSignFormList, boolean ocsmFlag) { |
| | | private static List<eSignForm__c> updateOwner( |
| | | List<String> provinceList, |
| | | Map<Id, String> provinceMap, |
| | | List<eSignForm__c> eSignFormList, |
| | | boolean ocsmFlag |
| | | ) { |
| | | //营业担当 map |
| | | Map < String, String > provinceOwnerMap = new Map < String, String > (); |
| | | Map<String, String> provinceOwnerMap = new Map<String, String>(); |
| | | //营业助理 map |
| | | Map < String, String > provinceGIMap = new Map < String, String > (); |
| | | Map<String, String> provinceGIMap = new Map<String, String>(); |
| | | |
| | | List < eSignForm__c > eSignFormLastList = new List < eSignForm__c >(); |
| | | List<eSignForm__c> eSignFormLastList = new List<eSignForm__c>(); |
| | | //检索OCSM管理省对象 |
| | | 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 |
| | | FROM OCM_Management_Province__c |
| | | WHERE Name IN :provinceList |
| | | ]; |
| | | //存放map<省,担当> |
| | | for (OCM_Management_Province__c omp : ompList) { |
| | | //不用map<String,list>的 原因是 想 ocsm管理省 和签收单 营业担当的顺序保持一致 |
| | |
| | | // } |
| | | // } |
| | | |
| | | |
| | | // } |
| | | // return eSignFormLastList; |
| | | |
| | |
| | | if (ocsmFlag) { |
| | | //给最后要更新的签收单的审批者(营业部担当)赋值 |
| | | for (Integer cnt = 0; cnt < eSignFormList.size(); cnt++) { |
| | | if (provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id)) != eSignFormList[cnt].RC_Manager__c ||provinceMap.get(eSignFormList[cnt].Id).equals('集采课')) { |
| | | |
| | | if ( |
| | | provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id)) != eSignFormList[cnt].RC_Manager__c || |
| | | provinceMap.get(eSignFormList[cnt].Id).equals('集采课') |
| | | ) { |
| | | eSignForm__c eSignForm = new eSignForm__c(); |
| | | eSignForm.Id = eSignFormList[cnt].Id; |
| | | eSignForm.RC_Manager__c = provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id)); |
| | | //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start |
| | | if(provinceMap.get(eSignFormList[cnt].Id).equals('集采课')){ |
| | | //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start |
| | | if (provinceMap.get(eSignFormList[cnt].Id).equals('集采课')) { |
| | | eSignForm.Sales_assistant_name_text__c = provinceGIMap.get(provinceMap.get(eSignFormList[cnt].Id)); |
| | | } |
| | | //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 end |
| | | eSignFormLastList.add(eSignForm); |
| | | } |
| | | |
| | | } |
| | | return eSignFormLastList; |
| | | |
| | | } else { |
| | | //给最后要更新的签收单的审批者(营业部担当)赋值 |
| | | for (eSignForm__c esf : eSignFormList) { |
| | | if (provinceOwnerMap.get(provinceMap.get(esf.Id)) != null) { |
| | | esf.RC_Manager__c = provinceOwnerMap.get(provinceMap.get(esf.Id)); |
| | | //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start |
| | | if(provinceMap.get(esf.Id).equals('集采课')){ |
| | | //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start |
| | | if (provinceMap.get(esf.Id).equals('集采课')) { |
| | | esf.Sales_assistant_name_text__c = provinceGIMap.get(provinceMap.get(esf.Id)); |
| | | } |
| | | //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 end |
| | | } |
| | | |
| | | } |
| | | return eSignFormList; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | global void finish(Database.BatchableContext BC) { |
| | | |
| | | //更新该日志的数据信息 |
| | | iflog.Log__c += '\nupdateESignBatch end'; |
| | | String tmp = iflog.ErrorLog__c; |
| | |
| | | //写死精琢用户 上线后应该会修改成自定义标签 |
| | | // String batchUserId = '00510000005sEEM'; |
| | | String batchUserId = System.Label.Batch_User_Id; |
| | | List<User> us = [Select Id, NAme, Email From User Where Id = : batchUserId]; |
| | | List<User> us = [SELECT Id, NAme, Email FROM User WHERE Id = :batchUserId]; |
| | | if (!us.isEmpty()) { |
| | | User use = us[0]; |
| | | if (String.isNotBlank(use.Email)) { |
| | |
| | | if (System.Label.ESign_Error_Send_To_CC != 'null') { |
| | | MailCc = System.Label.ESign_Error_Send_To_CC.split(','); |
| | | } |
| | | FixtureUtil.sendMessage(batchUserId, |
| | | MailCc, |
| | | 'updateESignBatch Error', |
| | | body |
| | | ); |
| | | FixtureUtil.sendMessage(batchUserId, MailCc, 'updateESignBatch Error', body); |
| | | } |
| | | } |
| | | } |
| | |
| | | messageMap = new Map<Id, String>(); |
| | | overMax = false; |
| | | } |
| | | public void setError (Database.SaveResult[] saveRes, Integer maxCut, Schema.sObjectType obj) { |
| | | public void setError(Database.SaveResult[] saveRes, Integer maxCut, Schema.sObjectType obj) { |
| | | if (messageMap.keySet().size() <= maxCut && overMax == false) { |
| | | String objectName = obj.getDescribe().getName(); |
| | | String objectLabel = obj.getDescribe().getLabel(); |
| | |
| | | break; |
| | | } |
| | | for (Database.Error err : saveRe.getErrors()) { |
| | | |
| | | String message = objectName + ':' |
| | | + objectLabel + ':' |
| | | + err.getStatusCode() + ':' |
| | | + err.getFields() + ':' |
| | | + err.getMessage(); |
| | | String message = |
| | | objectName + |
| | | ':' + |
| | | objectLabel + |
| | | ':' + |
| | | err.getStatusCode() + |
| | | ':' + |
| | | err.getFields() + |
| | | ':' + |
| | | err.getMessage(); |
| | | // 数据里面有复数错误信息的话只获取第一条 |
| | | messageMap.put(saveRe.getId(), message); |
| | | break; |
| | |
| | | } |
| | | |
| | | //定时跑任务 |
| | | public Class ScBean { |
| | | public class ScBean { |
| | | public String scName; |
| | | public String scTime; |
| | | } |
| | | |
| | | public static void improveTestRate(){ |
| | | Integer i = 0; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | } |
| | | } |
| | | } |