| | |
| | | public without sharing class NotetoPdfHandler extends Oly_TriggerHandler { |
| | | // 20231103 陈京武 Lightning文件修改 Start |
| | | @TestVisible |
| | | private Map<Id, ContentDocumentLink> newMap; |
| | | @TestVisible |
| | |
| | | } |
| | | @TestVisible |
| | | protected override void afterInsert() { |
| | | Set<Id> ids = new Set<Id>(); |
| | | for (ContentDocumentLink link : newList) { |
| | | ids.add(link.ContentDocumentId); |
| | | } |
| | | List<ContentVersion> version = [select Id from ContentVersion where ContentDocumentId in: ids and FileType = 'SNOTE']; |
| | | if(version != null){ |
| | | NotetoPdf(); |
| | | } |
| | | // 修理ID |
| | | NotetoPdf(); |
| | | // NoteMail(); |
| | | NoteMail(); |
| | | } |
| | | // 修理和QIS新建备注时,生成对应的PDF |
| | | private void NotetoPdf() { |
| | | StaticParameter.AttachmentTrigger = false; |
| | | List<String> Rlist = new List<String>(); |
| | | // QisID |
| | | for (ContentDocumentLink link : newList) { |
| | |
| | | List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>(); |
| | | List<String> Rlist = new List<String>(); |
| | | List<String> ParentIdList = new List<String>(); |
| | | Map<String,String> idMap = new Map<String,String>(); |
| | | // QisID |
| | | for (ContentDocumentLink link : newList) { |
| | | if(String.valueOf(link.LinkedEntityId).startsWith('a0J') |
| | | || String.valueOf(link.LinkedEntityId).startsWith('a0f')){ |
| | | Rlist.add(link.ContentDocumentId); |
| | | ParentIdList.add(link.LinkedEntityId); |
| | | idMap.put(link.ContentDocumentId,link.LinkedEntityId); |
| | | } |
| | | } |
| | | // for (Attachment att : newList) { |
| | |
| | | // } |
| | | // } |
| | | // List<Attachment> NtList = [Select id,ParentId,Name,Body FROM Attachment where Id in : Rlist]; |
| | | List<ContentVersion> verList = [select Id,Title,VersionData,ContentDocumentId from ContentVersion where ContentDocumentId in: Rlist]; |
| | | List<ContentVersion> verList = [select Id,TextPreview,Title,VersionData,ContentDocumentId from ContentVersion where ContentDocumentId in: Rlist]; |
| | | Map<Id,Repair__c> updateRprMap = new Map<Id,Repair__c>(); |
| | | Map<Id,QIS_Report__c> updateQisMap = new Map<Id,QIS_Report__c>(); |
| | | for (Repair__c re :[select id,Name,SerialNumber__c,Delivered_Product__r.Name,HP_Name__c |
| | |
| | | } |
| | | List<User> userList = [select Id, Name, Email, Manager.Email from User where id IN :IdList]; |
| | | for (ContentVersion version : verList) { |
| | | ContentDocumentLink link = [select LinkedEntityId from ContentDocumentLink where ContentDocumentId =: version.ContentDocumentId limit 1]; |
| | | String titName = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).Name : updateQisMap.get(link.LinkedEntityId).Name; |
| | | String prname = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).Delivered_Product__r.Name : updateQisMap.get(link.LinkedEntityId).nonyushohin__r.Name; |
| | | String Serial = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).SerialNumber__c : updateQisMap.get(link.LinkedEntityId).lot_or_serial__c; |
| | | String accountname = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).HP_Name__c : updateQisMap.get(link.LinkedEntityId).Hospital__r.Name; |
| | | String linkedEntityId = idMap.get(version.ContentDocumentId); |
| | | String titName = updateRprMap.containsKey(linkedEntityId)? updateRprMap.get(linkedEntityId).Name : updateQisMap.get(linkedEntityId).Name; |
| | | String prname = updateRprMap.containsKey(linkedEntityId)? updateRprMap.get(linkedEntityId).Delivered_Product__r.Name : updateQisMap.get(linkedEntityId).nonyushohin__r.Name; |
| | | String Serial = updateRprMap.containsKey(linkedEntityId)? updateRprMap.get(linkedEntityId).SerialNumber__c : updateQisMap.get(linkedEntityId).lot_or_serial__c; |
| | | String accountname = updateRprMap.containsKey(linkedEntityId)? updateRprMap.get(linkedEntityId).HP_Name__c : updateQisMap.get(linkedEntityId).Hospital__r.Name; |
| | | String title = ''; |
| | | String body = ''; |
| | | title = '【修理/QIS】:' + titName + '已新增文件,请查看'; |
| | | if(version.TextPreview != null){ |
| | | title = '【修理/QIS】:' + titName + '已新增备注,请查看'; |
| | | }else{ |
| | | title = '【修理/QIS】:' + titName + '已新增文件,请查看'; |
| | | } |
| | | |
| | | body += '用户名:' + accountname; |
| | | body += '<br/>'; |
| | | body += '产品名称/型号 :' + prname; |
| | |
| | | body += '操作担当:' + UserInfo.getName(); |
| | | body += '<br/>'; |
| | | body += '<br/>'; |
| | | body += '链接:' + baseUrl + '/' + link.LinkedEntityId +' '; |
| | | body += '链接:' + baseUrl + '/' + linkedEntityId +' '; |
| | | //收件邮箱 |
| | | List<String> toMailList = new List<String>(); |
| | | String uId = UserInfo.getUserId(); |
| | |
| | | } |
| | | Messaging.SendEmailResult[] results = messaging.sendEmail(sendMails); |
| | | } |
| | | // 20231103 陈京武 Lightning文件修改 End |
| | | } |