19626
2023-07-21 e53fdfdd78538a21cddd45b9d3faa1a7e9e37a0a
修改附件
4个文件已添加
19个文件已修改
1141 ■■■■ 已修改文件
force-app/main/default/classes/AttachmentReQisHandler.cls 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AttachmentReQisHandler.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/BidAnnounceIframeController.cls 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InsReportPDFOuterController.cls 113 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InsReportPDFOuterController.cls-meta.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/MaintenanceUpdateProductHandler.cls 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFM401Controller.cls 127 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFM609FiledDownloadBatch.cls 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFMUtil.cls 364 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OFSRepairConsignPDFOuterController.cls 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OFSUploadImageRest.cls 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OFSUploadImageRest.cls-meta.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OFSUploadRepairImageRest.cls 80 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OFSUploadRepairImageRest.cls-meta.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OPDNoReportApplicationController.cls 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/QRAndBRController.cls 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/QRAndBRController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/eSignAgencyConfirmPageController.cls 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/eSignHospitalPageController.cls 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/AssetModifyBelongs.page 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/AssetQR.page 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/ConsumApplyBR.page 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/ConsumApplyQR.page 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AttachmentReQisHandler.cls
New file
@@ -0,0 +1,109 @@
/**
 * SFDC系统案件(修理/QIS)中新建附件或备注时,
 * 系统自动通知到相关业务人员
 * 其中备注会自动生成PDF附件
 */
public without sharing class AttachmentReQisHandler extends Oly_TriggerHandler{
    @TestVisible
    private Map<Id, Attachment> newMap;
    @TestVisible
    private Map<Id, Attachment> oldMap;
    @TestVisible
    private List<Attachment> newList;
    @TestVisible
    private List<Attachment> oldList;
    public AttachmentReQisHandler() {
        this.newMap = (Map<Id, Attachment>) Trigger.newMap;
        this.oldMap = (Map<Id, Attachment>) Trigger.oldMap;
        this.newList = (List<Attachment>) Trigger.new;
        this.oldList = (List<Attachment>) Trigger.old;
    }
    @TestVisible
    protected override void afterInsert() {
        // 修理ID
        NoteMail();
    }
    private void NoteMail() {
        String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>();
        List<String> Rlist = new List<String>();
        List<String> ParentIdList = new List<String>();
        // QisID
        for (Attachment att : newList) {
            if(String.valueOf(att.ParentId).startsWith('a0J')
                || String.valueOf(att.ParentId).startsWith('a0f')){
                Rlist.add(att.Id);
                ParentIdList.add(att.ParentId);
            }
        }
        List<Attachment> NtList = [Select id,ParentId,Name,Body FROM Attachment where Id 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
                                        from Repair__c where id in : ParentIdList] ) {
            updateRprMap.put(re.id, re);
        }
        for (QIS_Report__c qi :[select id,Name,lot_or_serial__c,nonyushohin__r.Name,Hospital__r.Name
                                        from QIS_Report__c where id in : ParentIdList] ) {
            updateQisMap.put(qi.id, qi);
        }
        // Map<Id,Repair__c> updateRprMap = [select id,Name,SerialNumber__c,Delivered_Product__r.Name
        //                              from Repair__c where id in : ParentIdList];
        // Map<Id,QIS_Report__c>updateQisMap = [select id,Name,lot_or_serial__c,nonyushohin__r.Name
        //                              from QIS_Report__c where id in : ParentIdList];
        List<group> gList = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE name = '附件上传通知小组'];
        List<String> IdList = new List<String>();
        if (gList != null && gList.size() > 0) {
            for (Group g : gList) {
                for (GroupMember gm : g.groupMembers) {
                    IdList.add(gm.userOrGroupId);
                }
            }
        }
        List<User> userList = [select Id, Name, Email, Manager.Email from User where id IN :IdList];
        for (Attachment nt : NtList) {
            String titName = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).Name : updateQisMap.get(nt.ParentId).Name;
            String prname = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).Delivered_Product__r.Name : updateQisMap.get(nt.ParentId).nonyushohin__r.Name;
            String Serial = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).SerialNumber__c : updateQisMap.get(nt.ParentId).lot_or_serial__c;
            String accountname = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).HP_Name__c : updateQisMap.get(nt.ParentId).Hospital__r.Name;
            String title = '';
            String body = '';
            title = '【修理/QIS】:' + titName + '已新增附件,请查看';
            body += '用户名:' + accountname;
            body += '<br/>';
            body += '产品名称/型号 :' + prname;
            body += '<br/>';
            body += '机身号/批号 :' + Serial;
            body += '<br/>';
            body += '附件名称/备注名称:' + nt.Name;
            body += '<br/>';
            body += '操作担当:' + UserInfo.getName();
            body += '<br/>';
            body += '<br/>';
            body += '链接:' + baseUrl + '/' + nt.ParentId +' ';
            //收件邮箱
            List<String> toMailList = new List<String>();
            String uId = UserInfo.getUserId();
            for (User u : userList) {
                if (u.Id != uId) {
                    toMailList.add(u.Email);
                }
            }
            //抄送的邮箱
            List<String> ccMailList = new List<String>();
            ccMailList.add('gaozhangwei@prec-tech.com');
            ccMailList.add('wei_liang@olympus.com.cn');
            Messaging.SingleEmailMessage messageNEW = new Messaging.SingleEmailMessage();
            messageNEW.subject = title;
            messageNEW.htmlBody = body;
            messageNEW.setCharset('UTF-8');
            messageNEW.toAddresses = toMailList;
            if(ccMailList.size() > 0){
                messageNEW.ccAddresses = ccMailList;
            }
            sendMails.add(messageNEW);
        }
        //在单个事务中,只能调用send方法 10 次。
        Messaging.SendEmailResult[] results = messaging.sendEmail(sendMails);
    }
}
force-app/main/default/classes/AttachmentReQisHandler.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>41.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/BidAnnounceIframeController.cls
@@ -20,12 +20,12 @@
        if (docList.size() > 0) {
            doc = docList[0];
        }
        ContentVersion version = [select Id from ContentVersion where ContentDocumentId =: doc.Id];
        if (bid.Web_URL__c != null) {
            // 中标通知书URL更新时间 と 最新Attachmentの時間と比較、新しいものを適用
            if (doc != null) {
                if (bid.Web_URL_ModifiedDate__c < doc.ContentModifiedDate) {
                    iframe = '/lightning/r/ContentDocument/' + doc.Id + '/view';
                    iframe = '/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId='+ version.Id;
                } else {
                    iframe = bid.Web_URL__c;
                }
@@ -37,7 +37,7 @@
        } else {
            // Attachmentを適用
            if (doc != null) {
                iframe = '/lightning/r/ContentDocument/' + doc.Id + '/view';
                iframe = '/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId='+ version.Id;
            }
        }
    }
force-app/main/default/classes/InsReportPDFOuterController.cls
@@ -15,46 +15,107 @@
    }
    
    public void saveSign() {
        // Sign画像は一つでいいじゃない?Delete⇒Insertにする
        List<Attachment> atts = [select Id from Attachment where ParentId = :ir.Id and Name = :(ir.Name + '_Sign')];
        if (atts.size() > 0) delete atts;
        // // Sign画像は一つでいいじゃない?Delete⇒Insertにする
        // List<Attachment> atts = [select Id from Attachment where ParentId = :ir.Id and Name = :(ir.Name + '_Sign')];
        // if (atts.size() > 0) delete atts;
        
        Attachment ac = new Attachment();
        ac.Body = EncodingUtil.base64Decode(this.signStr.removeStart('data:image/png;base64,'));
        ac.Name = ir.Name + '_Sign';
        ac.ParentId = ir.Id;
        ac.ContentType = 'jpg';
        // Attachment ac = new Attachment();
        // ac.Body = EncodingUtil.base64Decode(this.signStr.removeStart('data:image/png;base64,'));
        // ac.Name = ir.Name + '_Sign';
        // ac.ParentId = ir.Id;
        // ac.ContentType = 'jpg';
        // try {
        //     insert ac;
        //     //TODO status「サイン済み」にする
        //     ir.ResponsiblePerson_Sign__c = '<img src="/servlet/servlet.FileDownload?file=' + ac.Id + '"/>';
        //     ir.SignUrl__c = '/servlet/servlet.FileDownload?file=' + ac.Id;
        //     ir.Status__c = '已签字';
        //     update ir;
        // } catch (Exception ex) {
        //     ApexPages.addMessages(ex);
        //     //return;
        // }
        List<ContentDocumentLink> links = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId =: ir.Id];
        if (links.size() > 0) {
            List<Id> idList = new List<Id>();
            for (ContentDocumentLink link : links) {
                idList.add(link.ContentDocumentId);
            }
            List<ContentDocument> cons = [select Id from ContentDocument where Id in: idList and Title =: (ir.Name + '_Sign')];
            if (cons.size() > 0) {
                delete cons;
            }
        }
        ContentVersion version = new ContentVersion();
        version.Title = ir.Name + '_Sign';
        version.VersionData = EncodingUtil.base64Decode(this.signStr.removeStart('data:image/png;base64,'));
        version.PathOnClient = ir.Name + '_Sign.jpg';
        version.ContentLocation = 's';
        try {
            insert ac;
            //TODO status「サイン済み」にする
            ir.ResponsiblePerson_Sign__c = '<img src="/servlet/servlet.FileDownload?file=' + ac.Id + '"/>';
            ir.SignUrl__c = '/servlet/servlet.FileDownload?file=' + ac.Id;
            insert version;
            version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
            ContentDocumentLink link = new ContentDocumentLink();
            link.LinkedEntityId = ir.Id;
            link.ShareType = 'I';
            link.ContentDocumentId = version.ContentDocumentId;
            link.Visibility = 'AllUsers';
            insert link;
            //     //TODO status「サイン済み」にする
            // ir.ResponsiblePerson_Sign__c = '<img src="/lightning/r/ContentDocument/'+ link.ContentDocumentId + '/view"/>';
            // ir.SignUrl__c = '/lightning/r/ContentDocument/'+ link.ContentDocumentId + '/view';
            ir.ResponsiblePerson_Sign__c = '<img src="/sfc/servlet.shepherd/version/download/'+ version.Id + '"/>';
            ir.SignUrl__c = '/sfc/servlet.shepherd/version/download/'+ version.Id;
            ir.Status__c = '已签字';
            update ir;
        } catch (Exception ex) {
            ApexPages.addMessages(ex);
            //return;
        } catch (Exception e) {
            ApexPages.addMessages(e);
        }
    }
    
    public void savePDF() {
        // String pdfPageURL = '/apex/InsReportPDF?id=' + ir.Id;
        // PageReference pageRef = new PageReference(pdfPageURL);
        // Attachment att = new Attachment();
        // // TODO TestMethodはgetContentをサポートしない
        // if (!Test.isRunningTest()) {
        //     att.body = pageRef.getContent();
        // } else {
        //     att.body = EncodingUtil.base64Decode('test');
        // }
        // att.Name = ir.Name + '_点检报告书_' + String.valueOf(Datetime.now()) + '.pdf';
        // att.ParentId = ir.Id;
        // try {
        //     insert att;
        // } catch (Exception ex) {
        //     ApexPages.addMessages(ex);
        //     //return;
        // }
        String pdfPageURL = '/apex/InsReportPDF?id=' + ir.Id;
        PageReference pageRef = new PageReference(pdfPageURL);
        Attachment att = new Attachment();
        // TODO TestMethodはgetContentをサポートしない
        ContentVersion version = new ContentVersion();
        if (!Test.isRunningTest()) {
            att.body = pageRef.getContent();
            version.VersionData = pageRef.getContent();
        } else {
            att.body = EncodingUtil.base64Decode('test');
            version.VersionData = EncodingUtil.base64Decode('test');
        }
        att.Name = ir.Name + '_点检报告书_' + String.valueOf(Datetime.now()) + '.pdf';
        att.ParentId = ir.Id;
        // version.Title = ir.Name + '_点检报告书_' + String.valueOf(Datetime.now()) + '.pdf';
        version.Title = ir.Name + '_点检报告书_' + String.valueOf(Datetime.now());
        version.ContentLocation = 's';
        version.PathOnClient = ir.Name + '_点检报告书_' + String.valueOf(Datetime.now()) + '.pdf';
        try {
            insert att;
        } catch (Exception ex) {
            ApexPages.addMessages(ex);
            //return;
            insert version;
            version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
            ContentDocumentLink link = new ContentDocumentLink();
            link.LinkedEntityId = ir.Id;
            link.ShareType = 'I';
            link.Visibility = 'AllUsers';
            link.ContentDocumentId = version.ContentDocumentId;
            insert link;
        } catch (Exception e) {
            ApexPages.addMessages(e);
            // ApexPages.addMessage(e);
        }
    }
    
force-app/main/default/classes/InsReportPDFOuterController.cls-meta.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>29.0</apiVersion>
    <apiVersion>43.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/MaintenanceUpdateProductHandler.cls
@@ -73,8 +73,9 @@
                }   
            }
            for(String id:mpdIds){
                List<Attachment> attachmentinfo = [SELECT Id, Name,OwnerId FROM Attachment WHERE  parentid  =:mpdIds ];
                if(attachmentinfo.size() ==0){
                List<ContentDocumentLink> linksinfo = [select Id from ContentDocumentLink where LinkedEntityId =: id];
                // List<Attachment> attachmentinfo = [SELECT Id, Name,OwnerId FROM Attachment WHERE  parentid  =:mpdIds ];
                if(linksinfo.size() ==0){
                    attachmentSize = true;
                }
            }
@@ -90,7 +91,7 @@
                }
                
                if(newMpd.Status__c=='审批中-服务'&& newMpd.Status__c != old.Status__c && attachmentSize&&attachmentChange){
                    newMpd.addError('还没有上传附件,请上传附件!');
                    newMpd.addError('还没有上传文件,请上传文件!');
                }
            }
        }
force-app/main/default/classes/NFM401Controller.cls
@@ -117,6 +117,13 @@
        public String GLOBAL_ATTRIBUTE1;
        public String RECORD_INSERTED_DATE;
    }
    public class ContentDocmentCtl{
        public String title;
        public Blob versionData;
        public Integer contentSize;
        public String parentId;
        public String Id;
    }
    webservice static void sendToETQ(String iflog_Id,BatchIF_Log__c rowDataSFDC, List<String> repairIds,String statu){
        if(statu == '' || statu == null){
@@ -244,21 +251,34 @@
            
            // 根据修理和QIS ID取得修理附件相关信息
            List<Attachment> attachmentList = [select Id,
                                                Name,
                                                Body,
                                                ParentId,
                                                BodyLength
                                            from Attachment
                                            where ParentId in : repairIds];
            Map<String,List<Attachment>> rAMap = new Map<String,List<Attachment>>();
            for (Attachment ra: attachmentList ) {
                if (!rAMap.containsKey(ra.ParentId)) {
                    rAMap.put(ra.ParentId, new List<Attachment>());
            // List<Attachment> attachmentList = [select Id,
            //                                     Name,
            //                                     Body,
            //                                     ParentId,
            //                                     BodyLength
            //                                 from Attachment
            //                                 where ParentId in : repairIds];
            // Map<String,List<Attachment>> rAMap = new Map<String,List<Attachment>>();
            // for (Attachment ra: attachmentList ) {
            //     if (!rAMap.containsKey(ra.ParentId)) {
            //         rAMap.put(ra.ParentId, new List<Attachment>());
            //     }
            //     rAMap.get(ra.ParentId).add(ra);
            // }
            // 根据修理和QIS ID取得修理文件相关信息
            List<ContentDocumentLink> links = [
                select
                ContentDocumentId,
                LinkedEntityId
                from ContentDocumentLink where LinkedEntityId in: repairIds
            ];
            Map<String,List<ContentDocumentLink>> rAMap = new Map<String,List<ContentDocumentLink>>();
            for (ContentDocumentLink ra: links ) {
                if (!rAMap.containsKey(ra.LinkedEntityId)) {
                    rAMap.put(ra.LinkedEntityId, new List<ContentDocumentLink>());
                }
                rAMap.get(ra.ParentId).add(ra);
                rAMap.get(ra.LinkedEntityId).add(ra);
            }
            // 根据修理ID取得QIS相关信息
            List<QIS_Report__c> qISList = [select id,Name,
@@ -544,19 +564,43 @@
                 //ATTACHMENT
                RepairRequest.ATTACHMENT = new List<Attachment_element>();
                List<Attachment> attList = rAMap.get(rr.id);
                if (attList != null && attList.size() > 0) {
                    for(Attachment rpd : attList){
                // List<Attachment> attList = rAMap.get(rr.id);
                // if (attList != null && attList.size() > 0) {
                //     for(Attachment rpd : attList){
                //         //2020-11-05  如果附件大小超过1.5mb 发送邮件提示
                //         if (rpd.BodyLength > 1048576) {
                //             sendemail(rpd,'修理'+rr.Name);
                //         }else{
                //             Attachment_element Attachmentdet = new Attachment_element();
                //             RepairRequest.ATTACHMENT.add(Attachmentdet);
                //             Attachmentdet.FILE_DATA = EncodingUtil.base64Encode(rpd.body);
                //             Attachmentdet.ATTACHMENT_FIELD_NAME = 'COMPLAINTS_DOCUMENT_ATTACHMENT';
                //             Attachmentdet.FILE_NAME = rpd.Name;
                //             Attachmentdet.GLOBAL_ATTRIBUTE1 = 'COMPLAINT';
                //             Attachmentdet.RECORD_INSERTED_DATE = NFMUtil.formatDate2Str(Date.today());
                //         }
                //     }
                // }
                List<ContentDocumentLink> attList = rAMap.get(rr.id);
                if (attList != null && attList.size() > 0) {
                    for(ContentDocumentLink rpd : attList){
                        ContentVersion version = [
                            select
                            Title,
                            VersionData,
                            ContentSize
                            from ContentVersion where ContentDocumentId =: rpd.ContentDocumentId
                        ];
                        //2020-11-05  如果附件大小超过1.5mb 发送邮件提示
                        if (rpd.BodyLength > 1048576) {
                            sendemail(rpd,'修理'+rr.Name);
                        if (version.ContentSize > 1048576) {
                            sendemail(version,'修理'+rr.Name);
                        }else{
                            Attachment_element Attachmentdet = new Attachment_element();
                            RepairRequest.ATTACHMENT.add(Attachmentdet);
                            Attachmentdet.FILE_DATA = EncodingUtil.base64Encode(rpd.body);
                            Attachmentdet.FILE_DATA = EncodingUtil.base64Encode(version.VersionData);
                            Attachmentdet.ATTACHMENT_FIELD_NAME = 'COMPLAINTS_DOCUMENT_ATTACHMENT';
                            Attachmentdet.FILE_NAME = rpd.Name;
                            Attachmentdet.FILE_NAME = version.Title;
                            Attachmentdet.GLOBAL_ATTRIBUTE1 = 'COMPLAINT';
                            Attachmentdet.RECORD_INSERTED_DATE = NFMUtil.formatDate2Str(Date.today());
                        }
@@ -702,24 +746,47 @@
                // ATTACHMENT
                RepairRequest.ATTACHMENT = new List<Attachment_element>();
                List<Attachment> attList = rAMap.get(qr.id);
                // List<Attachment> attList = rAMap.get(qr.id);
                // if (attList != null && attList.size() > 0) {
                //     for(Attachment rpd :attList){
                //          //2020-11-05  如果附件大小超过1.5mb 发送邮件提示
                //         if (rpd.BodyLength > 1048576) {
                //             sendemail(rpd,'QIS '+qr.Name);
                //         }else{
                //             Attachment_element Attachmentdet = new Attachment_element();
                //             RepairRequest.ATTACHMENT.add(Attachmentdet);
                //             Attachmentdet.FILE_DATA = EncodingUtil.base64Encode(rpd.body);
                //             Attachmentdet.ATTACHMENT_FIELD_NAME = 'COMPLAINTS_DOCUMENT_ATTACHMENT';
                //             Attachmentdet.FILE_NAME = rpd.Name;
                //             Attachmentdet.GLOBAL_ATTRIBUTE1 = 'COMPLAINT';
                //             Attachmentdet.RECORD_INSERTED_DATE = NFMUtil.formatDate2Str(Date.today());
                //         }
                //     }
                // }
                List<ContentDocumentLink> attList = rAMap.get(qr.id);
                if (attList != null && attList.size() > 0) {
                    for(Attachment rpd :attList){
                    for(ContentDocumentLink rpd :attList){
                         //2020-11-05  如果附件大小超过1.5mb 发送邮件提示
                        if (rpd.BodyLength > 1048576) {
                            sendemail(rpd,'QIS '+qr.Name);
                        ContentVersion version = [
                            select
                            VersionData,
                            Title,
                            ContentSize
                            from ContentVersion where ContentDocumentId =: rpd.ContentDocumentId
                        ];
                        if (version.ContentSize > 1048576) {
                            sendemail(version,'QIS '+qr.Name);
                        }else{
                            Attachment_element Attachmentdet = new Attachment_element();
                            RepairRequest.ATTACHMENT.add(Attachmentdet);
                            Attachmentdet.FILE_DATA = EncodingUtil.base64Encode(rpd.body);
                            Attachmentdet.FILE_DATA = EncodingUtil.base64Encode(version.VersionData);
                            Attachmentdet.ATTACHMENT_FIELD_NAME = 'COMPLAINTS_DOCUMENT_ATTACHMENT';
                            Attachmentdet.FILE_NAME = rpd.Name;
                            Attachmentdet.FILE_NAME = version.Title;
                            Attachmentdet.GLOBAL_ATTRIBUTE1 = 'COMPLAINT';
                            Attachmentdet.RECORD_INSERTED_DATE = NFMUtil.formatDate2Str(Date.today());
                        }
                    }
                }
                if (statu == 'Q1') {
                    RepairRequest.AWARE_DATE = NFMUtil.formatDate2Str(qr.Trable_occur_daY_collect__c);
@@ -816,16 +883,16 @@
    //add by rentx 2020-11-05 start
    //发送提示附件过大电子邮件
    public static void SendEmail(Attachment rpd,String str){
    public static void SendEmail(ContentVersion rpd,String str){
        
        // sendMails = new List<Messaging.SingleEmailMessage>();
        //发送邮件
        String title = '';
        String body = '';
        title = str+' 中的附件 '+rpd.Name+' 发送etq失败提醒';
        title = str+' 中的文件 '+rpd.Title+' 发送etq失败提醒';
        body =  '您好,';
        body += '<br/>';
        body += str+'中的附件'+rpd.Name+'过大,导致发送ETQ失败!';
        body += str+'中的文件'+rpd.Title+'过大,导致发送ETQ失败!';
        body += '<br/>';
        body += '请手动上传到ETQ';
        List<String> toMailList = new List<String>();
force-app/main/default/classes/NFM609FiledDownloadBatch.cls
@@ -43,15 +43,15 @@
        }
        try{
            List < Attachment > newAttList = AttachmentFiledDownload(endpoint, parentId, attachmentName);
            List < ContentVersion > newAttList = AttachmentFiledDownload(endpoint, parentId, attachmentName);
            if (newAttList.size() > 0) {
                List < Attachment > delAttaList = [select id from Attachment where ParentId =: parentId];
                if (delAttaList.size() > 0) {
                    delete delAttaList;
                }
                insert newAttList;
            }
            // if (newAttList.size() > 0) {
            //     List < Attachment > delAttaList = [select id from Attachment where ParentId =: parentId];
            //     if (delAttaList.size() > 0) {
            //         delete delAttaList;
            //     }
            //     insert newAttList;
            // }
            if (updateCaseList.size() > 0) {
                update updateCaseList;
            }
@@ -66,9 +66,22 @@
        // }
    }
    global static List < Attachment > AttachmentFiledDownload(String endpoint, String parentId, String attachmentName) {
        List < Attachment > result = new List < Attachment > ();
    global static List < ContentVersion > AttachmentFiledDownload(String endpoint, String parentId, String attachmentName) {
        List<ContentDocumentLink> linkList = [
            select
            ContentDocumentId
            from ContentDocumentLink where LinkedEntityId =: parentId
        ];
        if (linkList.size() > 0) {
            List<Id> idList = new List<Id>();
            for (ContentDocumentLink link : linkList) {
                idList.add(link.ContentDocumentId);
            }
            List<ContentDocument> conList = [select Id from ContentDocument where Id in: idList];
            delete conList;
        }
        // List < Attachment > result = new List < Attachment > ();
        List<ContentVersion> result = new List<ContentVersion>();
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setTimeout(120000);
@@ -82,9 +95,13 @@
        String statusCode = String.valueOf(response.getStatusCode());
        system.debug('statusCode---->' + statusCode);
        Attachment atta = new Attachment();
        atta.ParentId = parentId;
        atta.Name = attachmentName;
        // Attachment atta = new Attachment();
        // atta.ParentId = parentId;
        // atta.Name = attachmentName;
        ContentVersion version = new ContentVersion();
        version.Title = attachmentName;
        version.ContentLocation = 's';
        if ('200'.equals(statusCode)) {
            // 附件大小
            // 12,582,912
@@ -92,14 +109,24 @@
            System.debug('ContentLength----->' + ContentLength);
            if (ContentLength < 12582912) {
                Blob bodyAsBlob = response.getBodyAsBlob();
                atta.Body = bodyAsBlob;
                result.add(atta);
                version.VersionData = bodyAsBlob;
                // atta.Body = bodyAsBlob;
                result.add(version);
            } else {
                atta.Name = '文件大小超过12M,请在新服务系统查看';
                atta.Body = Blob.valueOf('文件大小超过12M');
                result.add(atta);
                // atta.Name = '文件大小超过12M,请在新服务系统查看';
                // atta.Body = Blob.valueOf('文件大小超过12M');
                version.Title = '文件大小超过12M,请在新服务系统查看';
                version.VersionData = Blob.valueOf('文件大小超过12M');
                result.add(version);
            }
            insert result;
            version =  [select ContentDocumentId from ContentVersion where Id =: version.Id];
            ContentDocumentLink link = new ContentDocumentLink();
            link.LinkedEntityId = parentId;
            link.ShareType = 'I';
            link.ContentDocumentId = version.ContentDocumentId;
            link.Visibility = 'AllUsers';
            insert link;
        }
force-app/main/default/classes/NFMUtil.cls
@@ -1375,369 +1375,7 @@
    public static Integer ControllerUtil() {
        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++;
        return i;
    }
}
force-app/main/default/classes/OFSRepairConsignPDFOuterController.cls
@@ -55,8 +55,8 @@
        insert cDe;
        try {
            
            rp.Sign__c = '<img src="/lightning/r/ContentDocument/' + contVerFile.ContentDocumentId + '/view"/>';
            rp.SignUrl__c = '/lightning/r/ContentDocument/' + contVerFile.ContentDocumentId + '/view';
            rp.Sign__c = '<img src="/sfc/servlet.shepherd/version/download/'+ contVerFile.Id + '"/>';
            rp.SignUrl__c = '/sfc/servlet.shepherd/version/download/'+ contVerFile.Id;
            rp.SignDate__c = Date.today();
            update rp;
        } catch (Exception ex) {
force-app/main/default/classes/OFSUploadImageRest.cls
@@ -25,19 +25,37 @@
                    res.responseBody = blob.valueOf(jsonResponse);
                    return;
                }
                Attachment att;
                // Attachment att;
                ContentVersion version;
                if (String.isNotBlank(repairQ.contract_consent_id__c)) {
                    att = [Select Id, Name, Body, ParentId From Attachment Where Id= :repairQ.contract_consent_id__c];
                    // att = [Select Id, Name, Body, ParentId From Attachment Where Id= :repairQ.contract_consent_id__c];
                    version = [select Id,VersionData,Title from ContentVersion where Id =: repairQ.contract_consent_id__c];
                } else {
                    att = new Attachment();
                    att.Name = 'ContractConsent.jpg';
                    att.ParentId = rqId;
                    version = new ContentVersion();
                    version.Title = 'ContractConsent.jpg';
                    version.ContentLocation = 's';
                    version.PathOnClient = 'ContractConsent.jpg';
                    // att = new Attachment();
                    // att.Name = 'ContractConsent.jpg';
                    // att.ParentId = rqId;
                }
                att.Body = EncodingUtil.base64Decode(ccImg);
                // att.Body = EncodingUtil.base64Decode(ccImg);
                version.VersionData = EncodingUtil.base64Decode(ccImg);
                try {
                    if (String.isNotBlank(repairQ.contract_consent_id__c)) { update att; }
                    else { insert att; }
                    ccId = att.Id;
                    if (String.isNotBlank(repairQ.contract_consent_id__c)) {
                        update version;
                    }
                    else {
                        insert version;
                        version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
                        ContentDocumentLink link = new ContentDocumentLink();
                        link.LinkedEntityId = rqId;
                        link.ContentDocumentId = version.ContentDocumentId;
                        link.ShareType = 'I';
                        link.Visibility = 'AllUsers';
                        insert link;
                    }
                    ccId = version.Id;
                    repairQ.contract_consent_id__c = ccId;
                } catch ( Exception ex ) {
                    //TODO:
@@ -60,19 +78,37 @@
                }
            }
            if (String.isNotBlank(acImg)) {
                Attachment att;
                // Attachment att;
                ContentVersion version;
                if (String.isNotBlank(repair.acceptance_id__c)) {
                    att = [Select Id, Name, Body, ParentId From Attachment Where Id= :repair.acceptance_id__c];
                    // att = [Select Id, Name, Body, ParentId From Attachment Where Id= :repair.acceptance_id__c];
                    version = [select Id,Title,VersionData from ContentVersion where Id =: repair.acceptance_id__c];
                } else {
                    att = new Attachment();
                    att.Name = 'Acceptance.jpg';
                    att.ParentId = repairId;
                    version = new ContentVersion();
                    version.Title = 'Acceptance.jpg';
                    version.ContentLocation = 's';
                    version.PathOnClient = 'Acceptance.jpg';
                    // att = new Attachment();
                    // att.Name = 'Acceptance.jpg';
                    // att.ParentId = repairId;
                }
                att.Body = EncodingUtil.base64Decode(acImg);
                // att.Body = EncodingUtil.base64Decode(acImg);
                version.VersionData = EncodingUtil.base64Decode(acImg);
                try {
                    if (String.isNotBlank(repair.acceptance_id__c)) { update att; }
                    else { insert att; }
                    acId = att.Id;
                    if (String.isNotBlank(repair.acceptance_id__c)) {
                        update version;
                    }
                    else {
                        insert version;
                        version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
                        ContentDocumentLink link = new ContentDocumentLink();
                        link.ShareType = 'I';
                        link.Visibility = 'AllUsers';
                        link.ContentDocumentId = version.ContentDocumentId;
                        link.LinkedEntityId = repairId;
                        insert link;
                    }
                    acId = version.Id;
                } catch ( Exception ex ) {
                    //TODO:
                    //error message:cannot update exception
force-app/main/default/classes/OFSUploadImageRest.cls-meta.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>29.0</apiVersion>
    <apiVersion>43.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/OFSUploadRepairImageRest.cls
@@ -26,20 +26,38 @@
                    res.responseBody = blob.valueOf(jsonResponse);
                    return;
                }
                List<Attachment> attList = [Select Id, Name, Body, ParentId From Attachment Where Id= :repairQ.contract_consent_id__c];
                Attachment att = null;
                if (attList.size() > 0) {
                    att = attList[0];
                // List<Attachment> attList = [Select Id, Name, Body, ParentId From Attachment Where Id= :repairQ.contract_consent_id__c];
                // Attachment att = null;
                List<ContentVersion> verisonList = [select Id,Title,VersionData from ContentVersion where Id =: repairQ.contract_consent_id__c];
                ContentVersion version = null;
                if (verisonList.size() > 0) {
                    version = verisonList[0];
                } else {
                    att = new Attachment();
                    att.Name = 'ContractConsent.jpg';
                    att.ParentId = rqId;
                    // att = new Attachment();
                    // att.Name = 'ContractConsent.jpg';
                    // att.ParentId = rqId;
                    version = new ContentVersion();
                    version.Title = 'ContractConsent.jpg';
                    version.ContentLocation = 's';
                    version.PathOnClient = 'ContractConsent.jpg';
                }
                att.Body = EncodingUtil.base64Decode(ccImg);
                // att.Body = EncodingUtil.base64Decode(ccImg);
                version.VersionData = EncodingUtil.base64Decode(ccImg);
                try {
                    if (attList.size() > 0) { update att; }
                    else { insert att; }
                    ccId = att.Id;
                    if (verisonList.size() > 0) {
                        update version;
                    }
                    else {
                        insert version;
                        version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
                        ContentDocumentLink link = new ContentDocumentLink();
                        link.ContentDocumentId = version.ContentDocumentId;
                        link.LinkedEntityId = rqId;
                        link.ShareType = 'I';
                        link.Visibility = 'AllUsers';
                        insert link;
                    }
                    ccId = version.Id;
                    repairQ.contract_consent_id__c = ccId;
                } catch ( Exception ex ) {
                    //TODO:
@@ -62,20 +80,38 @@
                }
            }
            if (String.isNotBlank(acImg)) {
                List<Attachment> attList = [Select Id, Name, Body, ParentId From Attachment Where Id= :repair.acceptance_id__c];
                Attachment att = null;
                if (attList.size() > 0) {
                    att = attList[0];
                // List<Attachment> attList = [Select Id, Name, Body, ParentId From Attachment Where Id= :repair.acceptance_id__c];
                List<ContentVersion> versionList = [select Id,Title,VersionData from ContentVersion where Id =: repair.acceptance_id__c];
                // Attachment att = null;
                ContentVersion version = null;
                if (versionList.size() > 0) {
                    version = versionList[0];
                } else {
                    att = new Attachment();
                    att.Name = 'Acceptance.jpg';
                    att.ParentId = repairId;
                    // att = new Attachment();
                    // att.Name = 'Acceptance.jpg';
                    // att.ParentId = repairId;
                    version = new ContentVersion();
                    version.Title = 'Acceptance.jpg';
                    version.ContentLocation = 's';
                    version.PathOnClient =  'Acceptance.jpg';
                }
                att.Body = EncodingUtil.base64Decode(acImg);
                // att.Body = EncodingUtil.base64Decode(acImg);
                version.VersionData = EncodingUtil.base64Decode(acImg);
                try {
                    if (attList.size() > 0) { update att; }
                    else { insert att; }
                    acId = att.Id;
                    if (versionList.size() > 0) {
                        update version;
                    }
                    else {
                        insert version;
                        version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
                        ContentDocumentLink link = new ContentDocumentLink();
                        link.LinkedEntityId = repairId;
                        link.ShareType = 'I';
                        link.Visibility = 'AllUsers';
                        link.ContentDocumentId = version.ContentDocumentId;
                        insert link;
                    }
                    acId = version.Id;
                } catch ( Exception ex ) {
                    //TODO:
                    //error message:cannot update exception
force-app/main/default/classes/OFSUploadRepairImageRest.cls-meta.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>29.0</apiVersion>
    <apiVersion>43.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/OPDNoReportApplicationController.cls
@@ -71,13 +71,25 @@
    @RemoteAction
     public static String testAddAttachment(String attachmentName,String attachmentType, String attachmentBody,String parentId) {
         String operateResult;
         Attachment tmpAttachment = new Attachment();
         tmpAttachment.Name = attachmentName;
         tmpAttachment.Body = EncodingUtil.base64Decode(attachmentBody);
         tmpAttachment.ParentId = parentId;
         tmpAttachment.ContentType = attachmentType;
        //  Attachment tmpAttachment = new Attachment();
        //  tmpAttachment.Name = attachmentName;
        //  tmpAttachment.Body = EncodingUtil.base64Decode(attachmentBody);
        //  tmpAttachment.ParentId = parentId;
        //  tmpAttachment.ContentType = attachmentType;
        ContentVersion version = new ContentVersion();
        version.Title = attachmentName;
        version.VersionData = EncodingUtil.base64Decode(attachmentBody);
        version.ContentLocation = 's';
        version.PathOnClient = attachmentName + '.' + attachmentType;
         try {
             insert tmpAttachment;
            insert version;
            version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
            ContentDocumentLink link = new ContentDocumentLink();
            link.ContentDocumentId = version.ContentDocumentId;
            link.LinkedEntityId = parentId;
            link.ShareType = 'I';
            link.Visibility = 'AllUsers';
            insert link;
             operateResult = '您已上传文件成功!';
         } catch (Exception e){
             operateResult = '上传文件失败,请重试!';
force-app/main/default/classes/QRAndBRController.cls
New file
@@ -0,0 +1,8 @@
public with sharing class QRAndBRController {
    public QRAndBRController(ApexPages.StandardController controller){
    }
    public String getParentUrl(){
        return ApexPages.currentPage().getHeaders().get('referer');
    }
}
force-app/main/default/classes/QRAndBRController.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/eSignAgencyConfirmPageController.cls
@@ -255,42 +255,62 @@
 
    public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
        ContentVersion version = new ContentVersion();
        version.VersionData = EncodingUtil.base64Decode(base64Data);
        version.Title = fileName;
        version.PathOnClient = fileName + contentType;
        version.ContentLocation = 's';
        insert version;
        version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
        ContentDocumentLink link = new ContentDocumentLink();
        link.LinkedEntityId = parentId;
        link.ContentDocumentId = version.ContentDocumentId;
        link.Visibility = 'AllUsers';
        link.ShareType = 'I';
        insert link;
        // Attachment oAttachment = new Attachment();
        // oAttachment.parentId = parentId;
 
        Attachment oAttachment = new Attachment();
        oAttachment.parentId = parentId;
        // oAttachment.Body = EncodingUtil.base64Decode(base64Data);
        // oAttachment.Name = fileName;
        // oAttachment.ContentType = contentType;
 
        oAttachment.Body = EncodingUtil.base64Decode(base64Data);
        oAttachment.Name = fileName;
        oAttachment.ContentType = contentType;
        // insert oAttachment;
 
        insert oAttachment;
        return oAttachment.Id;
        return link.ContentDocumentId;
    }
 
    private static void appendToFile(Id fileId, String base64Data) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
 
        Attachment a = [
            SELECT Id, Body
            FROM Attachment
            WHERE Id =: fileId
        // Attachment a = [
        //     SELECT Id, Body
        //     FROM Attachment
        //     WHERE Id =: fileId
        // ];
        ContentVersion version = [
            select
            Id,
            VersionData
            from ContentVersion where ContentDocumentId =: fileId
        ];
        String existingBody = EncodingUtil.base64Encode(version.VersionData);
 
        String existingBody = EncodingUtil.base64Encode(a.Body);
        version.VersionData = EncodingUtil.base64Decode(existingBody + base64Data);
 
        a.Body = EncodingUtil.base64Decode(existingBody + base64Data);
        update a;
        update version;
    }
    //文件删除功能  精琢技术 thh 2021-09-26 start
    @AuraEnabled
    public static void deleteChunk(Id AttachmentId) {
        Attachment attachment = new Attachment();
        attachment.id = AttachmentId;
        // Attachment attachment = new Attachment();
        // attachment.id = AttachmentId;
        ContentDocument con = new ContentDocument();
        con.Id = AttachmentId;
        delete attachment;
        delete con;
    }
    //文件删除功能  精琢技术 thh 2021-09-26 end
}
force-app/main/default/classes/eSignHospitalPageController.cls
@@ -262,41 +262,59 @@
    public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
 
        Attachment oAttachment = new Attachment();
        oAttachment.parentId = parentId;
        // Attachment oAttachment = new Attachment();
        // oAttachment.parentId = parentId;
 
        oAttachment.Body = EncodingUtil.base64Decode(base64Data);
        oAttachment.Name = fileName;
        oAttachment.ContentType = contentType;
        // oAttachment.Body = EncodingUtil.base64Decode(base64Data);
        // oAttachment.Name = fileName;
        // oAttachment.ContentType = contentType;
 
        insert oAttachment;
        // insert oAttachment;
        ContentVersion version = new ContentVersion();
        version.Title = fileName;
        version.VersionData = EncodingUtil.base64Decode(base64Data);
        version.ContentLocation = 's';
        version.PathOnClient = fileName + '.' + contentType;
        insert version;
        version = [select ContentDocumentId from ContentVersion where Id =: version.Id limit 1];
        ContentDocumentLink link = new ContentDocumentLink();
        link.LinkedEntityId = parentId;
        link.ContentDocumentId = version.ContentDocumentId;
        link.ShareType = 'I';
        link.Visibility = 'AllUsers';
        insert link;
 
        return oAttachment.Id;
        return link.ContentDocumentId;
    }
 
    private static void appendToFile(Id fileId, String base64Data) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
 
        Attachment a = [
            SELECT Id, Body
            FROM Attachment
            WHERE Id =: fileId
        ];
        // Attachment a = [
        //     SELECT Id, Body
        //     FROM Attachment
        //     WHERE Id =: fileId
        // ];
        ContentVersion verison = [select Id,VersionData from ContentVersion where ContentDocumentId =: fileId];
 
        String existingBody = EncodingUtil.base64Encode(a.Body);
        // String existingBody = EncodingUtil.base64Encode(a.Body);
        String existingBody = EncodingUtil.base64Encode(verison.VersionData);
 
        a.Body = EncodingUtil.base64Decode(existingBody + base64Data);
        verison.VersionData = EncodingUtil.base64Decode(existingBody + base64Data);
 
        update a;
        update verison;
    }
    
    //文件删除功能  精琢技术 thh 2021-09-26 start
    @AuraEnabled
    public static void deleteChunk(Id AttachmentId) {
        Attachment attachment = new Attachment();
        attachment.id = AttachmentId;
        // Attachment attachment = new Attachment();
        // attachment.id = AttachmentId;
        delete attachment;
        // delete attachment;
        ContentDocument con =  new ContentDocument();
        con.Id = AttachmentId;
        delete con;
    }
    //文件删除功能  精琢技术 thh 2021-09-26 end
}
force-app/main/default/pages/AssetModifyBelongs.page
@@ -347,7 +347,7 @@
                <apex:pageBlock title="文件" id="accessory" rendered="{!isShow}">
                
                    <apex:pageBlockButtons location="top">
                        <apex:commandButton value="附件上传"  onclick="uploadingAttachmentJs();" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准',true,false)}"/>
                        <apex:commandButton value="文件上传"  onclick="uploadingAttachmentJs();" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准',true,false)}"/>
                    </apex:pageBlockButtons>
                    
                    <apex:pageBlockTable value="{!contents}" var="attachment" >
force-app/main/default/pages/AssetQR.page
@@ -10,9 +10,7 @@
            var img = div.getElementsByTagName("img");
            var src = img[0].src;
            src = src.substring(22, src.length);
            sforce.connection.sessionId = '{!GETSESSIONID()}';
            // var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Asset.Id}\' and name = \'QRCode\'");
            var record = sforce.connection.query("SELECT ContentDocumentId from ContentDocumentLink where LinkedEntityId =\'{!Asset.Id}\'");
            var records;
@@ -46,7 +44,7 @@
                var es = new sforce.SObject("Asset");
                es.Id = "{!Asset.Id}";
                es.QRId__c = result[0].ContentDocumentId;
                es.QRId__c = versionResult[0].id;
                es.Fixture_QRCode_Text__c = "{!Asset.Fixture_QRCode__c}";
                result = sforce.connection.update([es]);
            } else if ("{!Asset.QRId__c}" == null || "{!Asset.QRId__c}" == '' || "{!Asset.Fixture_QRCode__c}" != "{!Asset.Fixture_QRCode_Text__c}"){
@@ -59,9 +57,9 @@
                // var result = sforce.connection.update([atta]);
                var result = sforce.connection.query("SELECT Id from ContentDocumentLink where ContentDocumentId =" + record[0].Id);
                var version = sforce.connection.query("SELECT Id from ContentVersion where ContentDocumentId =" + record[0].Id);
                var versions = version.getArray("versions");
                var result = sforce.connection.query("SELECT Id from ContentDocumentLink where ContentDocumentId = \'" + records[0].ContentDocumentId + "\'");
                var version = sforce.connection.query("SELECT Id from ContentVersion where ContentDocumentId = \'" + records[0].ContentDocumentId  + "\'");
                var versions = version.getArray("records");
                var atta = new sforce.SObject("ContentVersion");
                atta.VersionData = src;
                atta.Id = versions[0].Id;
@@ -69,7 +67,7 @@
                records = result.getArray("records");
                var es = new sforce.SObject("Asset");
                es.Id = "{!Asset.Id}";
                es.QRId__c = records[0].Id;
                es.QRId__c = atta.Id;
                es.Fixture_QRCode_Text__c = "{!Asset.Fixture_QRCode__c}";
                result = sforce.connection.update([es]);
                // TODO Name変わる可能性あり、upsertにします
force-app/main/default/pages/ConsumApplyBR.page
@@ -52,7 +52,7 @@
            var srcNew = getImgBase64(src);
            src = srcNew.substring(22, srcNew.length);
            sforce.connection.sessionId = '{!GETSESSIONID()}';
            console.log(src);
            // var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Consum_Apply__c.Id}\' and name = \'BRCode-{!Consum_Apply__c.Name_No__c}\'");
            var record = sforce.connection.query("select Id,ContentDocumentId from ContentDocumentLink where LinkedEntityId = \'{!Consum_Apply__c.Id}\'");
force-app/main/default/pages/ConsumApplyQR.page
@@ -16,14 +16,12 @@
            // var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Consum_Apply__c.Id}\' and name = \'QRCode-{!Consum_Apply__c.Name}\'");
            var record = sforce.connection.query("select ContentDocumentId from ContentDocumentLink where LinkedEntityId = \'{!Consum_Apply__c.Id}\'");
            // 不存在qr文件时,新生成一个,并连到申请单上
            console.log(record.size);
            if(record.size > 0){
                var records = record.getArray("records");
                var idList = records.map(obj => "'" + obj.ContentDocumentId + "'").join(",");
                record = sforce.connection.query("select Id from ContentDocument where Id in (" + idList + ") and Title = \'QRCode-{!Consum_Apply__c.Name}\'");
                console.log("select Id from ContentDocument where Id in (" + idList + ") and Title = \'QRCode-{!Consum_Apply__c.Name}\'");
            }
            console.log(record.size);
            if (record.size == 0) {
                // var atta = new sforce.SObject("Attachment");
                // atta.Name = "QRCode-{!Consum_Apply__c.Name}";
@@ -37,11 +35,8 @@
                version.ContentLocation = "s";
                version.PathOnClient = "QRCode-{!Consum_Apply__c.Name}.jpg";
                var result = sforce.connection.create([version]);
                console.log(result[0].id);
                version = sforce.connection.query("select ContentDocumentId from ContentVersion where Id = \'" + result[0].id + "\'");
                console.log(version);
                version = sforce.connection.query("select Id,ContentDocumentId from ContentVersion where Id = \'" + result[0].id + "\'");
                version = version.getArray("records"); 
                console.log(version);
                var link = new sforce.SObject("ContentDocumentLink");
                link.LinkedEntityId = "{!Consum_Apply__c.Id}";
                link.ContentDocumentId = version[0].ContentDocumentId;
@@ -51,16 +46,19 @@
                var es = new sforce.SObject("Consum_Apply__c");
                es.Id = "{!Consum_Apply__c.Id}";
                es.QRId__c = version[0].ContentDocumentId;
                es.QRId__c = version[0].Id;
                result = sforce.connection.update([es]);
            }
            else {
                var records = record.getArray("records");
                var version = new sforce.SObject("ContentVersion");
                version = sforce.connection.query("select Id,ContentDocumentId from ContentVersion where ContentDocumentId = \'" + records[0].Id + "\'");
                version = version.getArray("records");
                // 存在qr时,绑到申请单上
                if(records[0].Id != "{!Consum_Apply__c.QRId__c}"){
                if(version[0].Id != "{!Consum_Apply__c.QRId__c}"){
                    var es = new sforce.SObject("Consum_Apply__c");
                    es.Id = "{!Consum_Apply__c.Id}";
                    es.QRId__c = records[0].Id;
                    es.QRId__c = version[0].Id;
                    result = sforce.connection.update([es]);
                }
            }