19626
2023-09-09 e14d6d0619330cad423f06493e3aa2371faa2a8f
force-app/main/default/classes/NotetoPdfHandler.cls
@@ -16,13 +16,19 @@
    }
    @TestVisible
    protected override void afterInsert() {
        // 修理ID
        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();
       // NoteMail();
        }
        // 修理ID
       NoteMail();
    }
   // 修理和QIS新建备注时,生成对应的PDF
    private void NotetoPdf() {
       StaticParameter.AttachmentTrigger = false;
       List<String> Rlist = new List<String>();
       // QisID
       for (ContentDocumentLink link : newList) {
@@ -63,7 +69,7 @@
        //     }
        // }
        // 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
@@ -96,7 +102,12 @@
            String accountname = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).HP_Name__c : updateQisMap.get(link.LinkedEntityId).Hospital__r.Name;
            String title = '';
            String body = '';
            if(version.TextPreview != null){
                title = '【修理/QIS】:' + titName + '已新增备注,请查看';
            }else{
            title = '【修理/QIS】:' + titName + '已新增文件,请查看';
            }
            body += '用户名:' + accountname;
            body += '<br/>';
            body += '产品名称/型号 :' + prname;