| | |
| | | //存放 签收单id,文件数量 |
| | | 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<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 |
| | | Map<String, Integer> fileAgencyMap = new Map<String, Integer>(); |
| | | Map<String, Integer> fileHPMap = new Map<String, Integer>(); |
| | | //驳回后删除文件 后 排序问题 精琢技术 wql 2020/12/24 end |
| | |
| | | |
| | | //存放所有签收单录入表id |
| | | 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 > (); |
| | | //驳回后 删除之前上传的文件id |
| | | List<Attachment> deleteLastFileList = new List<Attachment>(); |
| | | //List<Attachment> deleteLastFileList = new List<Attachment>(); |
| | | List<FileAddress__c> deleteLastFileList = new List<FileAddress__c>(); //zhj Attachment To AWS 2023-02-06 |
| | | //存放未更新前的经销商审批状态 |
| | | Map < String, String > oldESignAgencyStatusMap = new Map < String, String > (); |
| | | //存放未更新前的医院审批状态 |
| | |
| | | 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<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 |
| | | system.debug('deleteFileList:' + deleteFileList); |
| | | if (deleteFileList.size() > 0) { |
| | | for (eSignForm__c esFile : rejectESignEneryMap.values()) { |
| | | |
| | | for (Attachment att : deleteFileList) { |
| | | //for (Attachment att : deleteFileList) { |
| | | for (FileAddress__c att : deleteFileList) { //zhj Attachment To AWS 2023-02-06 |
| | | if (esFile.agencyRejectDate__c != null || esFile.HPRejectDate__c != null) { |
| | | if (att.parentId == esFile.Id ) { |
| | | if (att.ParentRecordId__c == esFile.Id ) { |
| | | //①经销商驳回后需要删除的附件 |
| | | if (esFile.agencyRejectDate__c != null) { |
| | | if (att.Name.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) { |
| | | //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) { |
| | | deleteLastFileList.add(att); |
| | | } |
| | | } |
| | | //②医院驳回后需要删除的附件 |
| | | if (esFile.HPRejectDate__c != null) { |
| | | if (att.Name.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) { |
| | | //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) { |
| | | deleteLastFileList.add(att); |
| | | } |
| | | } |
| | |
| | | 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) { |
| | | //存放 签收单id,录入表id 文件用 |
| | |
| | | //重新对附件排序 规则变为根据签收单现有附件序号进行排序 精琢技术 wql start |
| | | //暂时存放一下签收单名称 |
| | | Map<string, string> tempMap = new Map<string, string>(); |
| | | List<Attachment> tempAttList = [SELECT parentId, createdDate, Name,Description |
| | | FROM Attachment |
| | | WHERE parentId IN: esFormidList order by createdDate]; |
| | | //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]; |
| | | if (tempAttList.size() > 0) { |
| | | //外层循环签收单 |
| | | for (String es : esFormidList) { |
| | | |
| | | //zhj Attachment To AWS 2023-02-06 |
| | | //内层循环附件 |
| | | for (Attachment att : tempAttList) { |
| | | // 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) { |
| | | //如果id相等 |
| | | if (es.equals(att.parentId)) { |
| | | if (es.equals(att.ParentRecordId__c)) { |
| | | //根据名称拆分 存入不同list |
| | | String name = att.Name; |
| | | String name = att.FileName__c; |
| | | if (name.substring(0, 1).equals('A')) { |
| | | esignAttachAgencyList.add(att); |
| | | } else if (name.substring(0, 1).equals('H')) { |
| | |
| | | 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 |
| | | //签收单id |
| | | 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 |
| | | //存一个id |
| | | idlast = eSignFormEntry.Id; |
| | | //签收单name用作文件命名 |
| | | 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; |
| | | //存一个id |
| | | idlast = eSignFormEntry.Id; |
| | | //签收单name用作文件命名 |
| | | 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); |
| | |
| | | System.debug('fileIdList:' + fileIdList); |
| | | System.debug('fileList:' + fileList); |
| | | //用于最后insert 附件 |
| | | List<Attachment> insertAttactment = new List<Attachment>(); |
| | | //zhj Attachment To AWS 2023-02-06 |
| | | //List<Attachment> insertAttactment = new List<Attachment>(); |
| | | List<FileAddress__c> insertAttactment = new List<FileAddress__c>(); |
| | | //附件 start |
| | | List<Attachment> attachMentList = [SELECT id, parentId, Body, Name, ContentType,Description from Attachment where parentId IN :fileList and Description!='电子签收单:已处理']; |
| | | //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<Attachment> eSignEntryAttachMentList = new List<Attachment>(); |
| | | List<FileAddress__c> eSignEntryAttachMentList = new List<FileAddress__c>(); |
| | | //文件数量 用于文件命名 |
| | | Integer agencyCount = 0; |
| | | Integer hpCount = 0; |
| | |
| | | system.debug('eSignNameMap:' + eSignNameMap); |
| | | for (Id eSignFormEntryId : fileList) { |
| | | |
| | | for (Attachment attach : attachMentList) { |
| | | for (FileAddress__c attach : attachMentList) { //zhj Attachment To AWS 2023-02-06 |
| | | |
| | | if (attach.parentId == eSignFormEntryId) { |
| | | Id eid = eSignFlieIdMap.get(attach.parentId); |
| | | if (attach.ParentRecordId__c == eSignFormEntryId) { |
| | | Id eid = eSignFlieIdMap.get(attach.ParentRecordId__c); |
| | | system.debug('eid:' + eid); |
| | | |
| | | name = eSignNameMap.get(eid); |
| | | system.debug('name:' + name); |
| | | type = eSignTypeMap.get(attach.parentId); |
| | | type = eSignTypeMap.get(attach.ParentRecordId__c); |
| | | |
| | | //因为外层循环是中间表 如果2条以上录入表都有经销商附件 则使用最新构建的经销商附件数量来命名 |
| | | //否则取未更新之前有的经销商附件数量 并且 不是1个录入表多个附件 也就是false的时候 取模拟的最新数量 |
| | |
| | | // title = title +'.jpg'; |
| | | // } |
| | | //判断一下格式,不然下载下来是类型是所有文件 无法打开 |
| | | if (attach.Name.lastIndexOf('.') > -1) { |
| | | title = title + attach.Name.substring(attach.Name.lastIndexOf('.')); |
| | | //zhj Attachment To AWS 2023-02-06 start |
| | | if (attach.FileName__c.lastIndexOf('.') > -1) { |
| | | title = title + attach.FileName__c.substring(attach.FileName__c.lastIndexOf('.')); |
| | | } |
| | | |
| | | Attachment newAttachment = attach.clone(); |
| | | newAttachment.parentId = eid; |
| | | newAttachment.name = title; |
| | | //Attachment newAttachment = attach.clone(); |
| | | FileAddress__c newAttachment = attach.clone(); |
| | | newAttachment.ParentRecordId__c = eid; |
| | | newAttachment.FileName__c = title; |
| | | // newAttachment.ContentType =attach.ContentType; |
| | | //要更新的签收单附件 |
| | | insertAttactment.add(newAttachment); |
| | | //反更新录入表的附件 用来判断附件是否被更新 |
| | | Attachment oldAttachment = new Attachment(); |
| | | //Attachment oldAttachment = new Attachment(); |
| | | FileAddress__c oldAttachment = new FileAddress__c(); |
| | | oldAttachment.Id = attach.Id; |
| | | oldAttachment.Description = '电子签收单:已处理'; |
| | | //oldAttachment.Description = '电子签收单:已处理'; |
| | | oldAttachment.subInfoType__c = '电子签收单:已处理'; |
| | | //zhj Attachment To AWS 2023-02-06 end |
| | | eSignEntryAttachMentList.add(oldAttachment); |
| | | |
| | | } |
| | |
| | | Integer h = 0; |
| | | |
| | | //内层所有需要更新的附件 |
| | | for (Attachment att : insertAttactment) { |
| | | //for (Attachment att : insertAttactment) { |
| | | for (FileAddress__c att : insertAttactment) { //zhj Attachment To AWS 2023-02-06 |
| | | if (es.Id != null) { |
| | | if (es.Id.equals(att.parentId)) { |
| | | if (es.Id.equals(att.ParentRecordId__c)) { |
| | | if (es.agencyAutoSignUpStatus__c != null) { |
| | | if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size()>0) { |
| | | if(!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')){ |
| | | if (att.Name.substring(0, 1).equals('A')) { |
| | | if (att.FileName__c.substring(0, 1).equals('A')) { //zhj Attachment To AWS 2023-02-06 |
| | | a ++; |
| | | } |
| | | } |
| | |
| | | if (es.HPSignUpStatus__c != null) { |
| | | if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size()>0) { |
| | | if(!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')){ |
| | | if (att.Name.substring(0, 1).equals('H')) { |
| | | if (att.FileName__c.substring(0, 1).equals('H')) { //zhj Attachment To AWS 2023-02-06 |
| | | h ++; |
| | | } |
| | | } |
| | |
| | | } |
| | | //电子签收单 增加本次更新附件数量 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 (eSignFormDeleteList.size() > 0) { |
| | | //循环遍历id 删除文件 |
| | | List<String> fileDeleteIdList = new List<String> (); |
| | | List<Attachment> deleteAttachmentList = new List<Attachment>(); |
| | | //List<Attachment> deleteAttachmentList = new List<Attachment>(); |
| | | List<FileAddress__c> deleteAttachmentList = new List<FileAddress__c>(); //zhj Attachment To AWS 2023-02-06 |
| | | |
| | | for (eSignFormEntry__c eSigf : eSignFormDeleteList) { |
| | | fileDeleteIdList.add(eSigf.Id); |
| | |
| | | |
| | | // 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<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>(); |
| | | if (attachMentList.size() > 0) { |
| | | for (Attachment att : attachMentList) { |
| | | Attachment am = new Attachment(); |
| | | for (FileAddress__c att : attachMentList) { |
| | | FileAddress__c am = new FileAddress__c(); //zhj Attachment To AWS 2023-02-06 |
| | | 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 eSignFormDeleteList; |
| | | System.debug('删除录入表 : ' + eSignFormDeleteList); |
| | | // delete eSignFormDeleteList; // 2023-03-14 ssm 暂时不自动删除中间表数据,方便短期内做check |
| | | } |
| | | } |
| | | @TestVisible |
| | |
| | | |
| | | 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,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助理改为签收单OCSM省的营业窗口 |
| | | } |
| | | //①为true的时候 是其他没发生变化只有ocsm省上营业担当改变 |
| | | //②为false的时候,有中间表正常更新的情况 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | public class ErrorBean { |
| | | // public String objectName; |
| | |
| | | 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++; |
| | | } |
| | | } |