| | |
| | | trigger ContentDocumentTrigger on ContentDocument (before delete,before update) { |
| | | // 20231103 陈京武 Lightning文件修改 Start |
| | | if(StaticParameter.ContentDocumentTrigger == false){ |
| | | return; |
| | | } |
| | |
| | | String invoiceStart = System.Label.invoiceStart; |
| | | List<String> rentaldelIdsZhj = new List<String>(); |
| | | List<String> attdelIdsZhj = new List<String>(); |
| | | Set<Id> docidList = new Set<Id>(); |
| | | Set<Id> delDocidList = new Set<Id>(); |
| | | if(Trigger.isDelete && Trigger.isBefore){ |
| | | for (ContentDocument doc : Trigger.old) { |
| | | docidList.add(doc.Id); |
| | | delDocidList.add(doc.Id); |
| | | } |
| | | } |
| | | if(Trigger.isUpdate && Trigger.isBefore){ |
| | | for (ContentDocument doc : Trigger.old) { |
| | | docidList.add(doc.Id); |
| | | } |
| | | } |
| | | ContentVersion ver = new ContentVersion(); |
| | | if(docidList.size() > 0){ |
| | | ver = [select FileType,TextPreview from ContentVersion where ContentDocumentId in: docidList limit 1]; |
| | | System.debug('TextPreview=>' + ver.TextPreview); |
| | | System.debug('FileType=>' + ver.TextPreview); |
| | | if(ver.FileType == 'SNOTE'){ |
| | | System.debug('可恶的备注!!!'); |
| | | return; |
| | | } |
| | | } |
| | | if (Trigger.isBefore && Trigger.isUpdate) { |
| | | List<Id> idList = new List<Id>(); |
| | | for(ContentDocument doc: Trigger.old){ |
| | |
| | | //2023-2-10 sx备品 备品检测分析报告 end |
| | | } |
| | | |
| | | if (specIds.size() > 0) { |
| | | |
| | | Map<String, String> attMap = new Map<String, String>(); |
| | | // List<Attachment> attList = [select Id, ParentId from Attachment where ParentId = :specIds order by ParentId]; |
| | | List<ContentDocumentLink> linkList = [select ContentDocumentId,LinkedEntityId from ContentDocumentLink where ContentDocument.FileType != 'SNOTE' and LinkedEntityId =: specIds order by LinkedEntityId]; |
| | | for (ContentDocumentLink link : linkList) { |
| | | // attMap.put(link.LinkedEntityId, link.LinkedEntityId); |
| | | if(!delDocidList.contains(link.ContentDocumentId)){ |
| | | attMap.put(link.LinkedEntityId, link.LinkedEntityId); |
| | | } |
| | | } |
| | | List<OpportunitySpecialApply__c> updSpecList = new List<OpportunitySpecialApply__c>(); |
| | | for (String specId : specIds) { |
| | | OpportunitySpecialApply__c spec = new OpportunitySpecialApply__c(Id = specId); |
| | | spec.Is_upload_file__c = attMap.containsKey(specId); |
| | | updSpecList.add(spec); |
| | | } |
| | | if (updSpecList.size() > 0) update updSpecList; |
| | | } |
| | | |
| | | //20221207 lt 医院审批优化 start |
| | | //2023-2-10 sx备品 备品检测分析报告 start |
| | |
| | | if (accAppIds.size() > 0) { |
| | | Map<String, String> attMap = new Map<String, String>(); |
| | | // List<Attachment> attList = [select Id, ParentId from Attachment where ParentId = :accAppIds order by ParentId]; |
| | | List<ContentDocumentLink> linkList = [select LinkedEntityId from ContentDocumentLink where LinkedEntityId =: accAppIds order by LinkedEntityId]; |
| | | List<ContentDocumentLink> linkList = [select ContentDocumentId,LinkedEntityId from ContentDocumentLink where ContentDocument.FileType != 'SNOTE' and LinkedEntityId =: accAppIds order by LinkedEntityId]; |
| | | for (ContentDocumentLink link : linkList) { |
| | | // attMap.put(link.LinkedEntityId, link.LinkedEntityId); |
| | | if(!delDocidList.contains(link.ContentDocumentId)){ |
| | | attMap.put(link.LinkedEntityId, link.LinkedEntityId); |
| | | } |
| | | } |
| | | List<Account_Delay_Apply__c> updAccAppList = new List<Account_Delay_Apply__c>(); |
| | | |
| | |
| | | } |
| | | |
| | | //20221207 lt 医院审批优化 end |
| | | if(adaList.size() > 0){ |
| | | // Account_Delay_Apply__c accapp = new Account_Delay_Apply__c(Id = accappid); |
| | | //20221207 lt 医院审批优化 start |
| | | |
| | | for(Account_Delay_Apply__c accapp : adaList){ |
| | | accapp.Is_upload_file__c = attMap.containsKey(accappid); |
| | | updAccAppList.add(accapp); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | try { |
| | |
| | | if (accIds.size() > 0) { |
| | | Map<String, String> attMap = new Map<String, String>(); |
| | | // List<Attachment> attList = [select Id, ParentId from Attachment where ParentId = :accIds order by ParentId]; |
| | | List<ContentDocumentLink> linkList = [select LinkedEntityId from ContentDocumentLink where LinkedEntityId =: accIds order by LinkedEntityId]; |
| | | List<ContentDocumentLink> linkList = [select ContentDocumentId,LinkedEntityId from ContentDocumentLink where ContentDocument.FileType != 'SNOTE' and LinkedEntityId =: accIds order by LinkedEntityId]; |
| | | System.debug('客户Link的条数:' + linkList.size()); |
| | | for (ContentDocumentLink link : linkList) { |
| | | if(!delDocidList.contains(link.ContentDocumentId)){ |
| | | attMap.put(link.LinkedEntityId, link.LinkedEntityId); |
| | | } |
| | | } |
| | | System.debug('attMap的条数:' + attMap); |
| | | List<Account> updAccList = new List<Account>(); |
| | | |
| | | //20221207 lt 医院审批优化 start |
| | |
| | | } |
| | | } |
| | | acc.Is_upload_file__c = attMap.containsKey(accid); |
| | | System.debug('是否上传附件:' + attMap.containsKey(accid)); |
| | | updAccList.add(acc); |
| | | } |
| | | } |
| | | //20221207 lt 医院审批优化 end |
| | | } |
| | | // for (String accid : accIds) { |
| | | // // Account acc = new Account(Id = accid); |
| | | // // acc.Is_upload_file__c = attMap.containsKey(accid); |
| | | // // updAccList.add(acc); |
| | | // // } |
| | | // if (updAccList.size() > 0) update updAccList; |
| | | // Account acc = new Account(Id = accid); |
| | | // acc.Is_upload_file__c = attMap.containsKey(accid); |
| | | // updAccList.add(acc); |
| | | // } |
| | | |
| | | if (updAccList.size() > 0) update updAccList; |
| | | |
| | | } |
| | | // 20231103 陈京武 Lightning文件修改 End |
| | | } |