19626
2023-08-09 5363705f99dcbb7c270a619804beb4ac29b3faa0
今日修改
12个文件已添加
13个文件已修改
3062 ■■■■■ 已修改文件
force-app/main/default/classes/AttachmentReQisHandler.cls 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AttachmentTriggerTest.cls 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/CheckAllOlympusAssetController.cls 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InventoryReportController.cls 485 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InventoryResultRecordController.cls 592 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NotetoPdfHandler.cls 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NotetoPdfHandler.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/AssetMaintain.page 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/AssetMaintainIframe.page 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/AssetMaintainIframe.page-meta.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/CheckAllOlympusAsset.page 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/InventoryIframe.page 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/InventoryIframe.page-meta.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/InventoryReport.page 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/InventoryResultRecord.page 175 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/QLMAttachmentPreview1.page 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/TenderAttachment.page 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/AttachmentTrigger.trigger 240 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/ContentDocumentLink.trigger 567 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/ContentDocumentTrigger.trigger 496 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/ContentDocumentTrigger.trigger-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/ContentVersionTrigger.trigger 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/ContentVersionTrigger.trigger-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/NotetoPdf.trigger 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/NotetoPdf.trigger-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AttachmentReQisHandler.cls
@@ -105,9 +105,9 @@
            }
            //抄送的邮箱
            List<String> ccMailList = new List<String>();
            // ccMailList.add('gaozhangwei@prec-tech.com');
            // ccMailList.add('wei_liang@olympus.com.cn');
            ccMailList.add('chenjingwu@prec-tech.com');
            ccMailList.add('gaozhangwei@prec-tech.com');
            ccMailList.add('wei_liang@olympus.com.cn');
            // ccMailList.add('chenjingwu@prec-tech.com');
            Messaging.SingleEmailMessage messageNEW = new Messaging.SingleEmailMessage();
            messageNEW.subject = title;
            messageNEW.htmlBody = body;
force-app/main/default/classes/AttachmentTriggerTest.cls
@@ -8,7 +8,6 @@
    
    @isTest 
    static void test_method_one() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            return;
@@ -66,22 +65,37 @@
        ofile.Opportunity__c = opp.Id;
        ofile.Oppor_File_Stage__c = 'G';
        insert ofile;
        Attachment att1 = new Attachment(
            Name = 'test',
            ParentId = ofile.Id,
            Body = EncodingUtil.base64Decode('test')
        ContentVersion version = new ContentVersion(
            Title = 'test',
            VersionData = EncodingUtil.base64Decode('test'),
            ContentLocation = 's',
            PathOnClient = 'test.txt'
        );
        System.Test.startTest();
        insert att1;
        Attachment att = new Attachment(
            Name = 'test',
            ParentId = ofile.Id,
            Body = EncodingUtil.base64Decode('test')
        );
        insert att;
        insert version;
        version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
        ContentDocumentLink link = new ContentDocumentLink();
        link.ContentDocumentId = version.ContentDocumentId;
        link.LinkedEntityId = ofile.Id;
        link.ShareType = 'I';
        link.Visibility = 'AllUsers';
        insert link;
        ContentDocument con = [select Id from ContentDocument where Id =: version.ContentDocumentId];
        delete con;
        // Attachment att1 = new Attachment(
        //     Name = 'test',
        //     ParentId = ofile.Id,
        //     Body = EncodingUtil.base64Decode('test')
        // );
        // System.Test.startTest();
        // insert att1;
        // Attachment att = new Attachment(
        //     Name = 'test',
        //     ParentId = ofile.Id,
        //     Body = EncodingUtil.base64Decode('test')
        // );
        // insert att;
        
        //delete att1;
        System.Test.stopTest();
    }
    
    //@isTest 
force-app/main/default/classes/CheckAllOlympusAssetController.cls
@@ -1,7 +1,7 @@
public with sharing class CheckAllOlympusAssetController {
    public static Asset StaticAssetQuertResult;
    // 按钮区域
    public String assertQueryCondition {get; private set;}
    public String assertQueryCondition {get; set;}
    public Boolean allBlueFlag {get; private set;}  // 查看全部保有设备蓝色按钮Flag
    public Boolean consumableBlueFlag {get; private set;}  // 查看在库的保有设备蓝色按钮Flag
    public Boolean lendingBlueFlag {get; private set;}  // 查看出借中保有设备蓝色按钮Flag
@@ -218,6 +218,27 @@
        set;
    }
     //chenjingwu 2023.8.2
    //设备状态
    public List<SelectOption> assertQueryConditionOpts {
        get {
            if(assertQueryConditionOpts == null){
                assertQueryConditionOpts = new List<SelectOption>();
                assertQueryConditionOpts.add(new SelectOption('all', '--无--'));
                assertQueryConditionOpts.add(new SelectOption('consumable', '有效库存'));
                assertQueryConditionOpts.add(new SelectOption('lending', '借出分配数'));
                assertQueryConditionOpts.add(new SelectOption('repairing', '修理中'));
                assertQueryConditionOpts.add(new SelectOption('scrapping', '待报废'));
                assertQueryConditionOpts.add(new SelectOption('scrapped', '已报废'));
                assertQueryConditionOpts.add(new SelectOption('consumed', '已消耗'));
                assertQueryConditionOpts.add(new SelectOption('soonExpired', '即将到期'));
                assertQueryConditionOpts.add(new SelectOption('expired', '已过期'));
            }
            return assertQueryConditionOpts;
        }
        set;
    }
    private String targetColumusStr;  // SOQL中的检索列
    // 项目set 字段标签
force-app/main/default/classes/InventoryReportController.cls
@@ -1,4 +1,8 @@
public without sharing class InventoryReportController {
     // 按钮区域
     public Boolean inventoryBlueFlag {get; private set;}  // 查看盘点蓝色按钮Flag
     public Boolean rentBlueFlag {get; private set;}  // 查看备品蓝色按钮Flag
     public Boolean consumBlueFlag {get; private set;}  // 查看耗材盘点蓝色按钮Flag
    public List<String> xAxis {get; set;}
    public List<String> yAxis {get; set;}
@@ -65,6 +69,7 @@
     * 画面初始化
     */
    public PageReference init() {
        initSearchButtonColor();
        /************** 必填项标红设置 ***************/
        //页面布局中字段得权限 包括 r,w,wmLostReportEdit
@@ -289,6 +294,13 @@
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'when init ' + e.getMessage()));
            return null;
        }
    }
    // 初始化按钮颜色
    public void initSearchButtonColor() {
        inventoryBlueFlag = false;
        rentBlueFlag = true;
        consumBlueFlag = false;
    }
    /**
@@ -556,478 +568,7 @@
    }
     @TestVisible private static void test() {
        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++;
    }
}
force-app/main/default/classes/InventoryResultRecordController.cls
@@ -1,4 +1,16 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-07-12 11:08:28
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-08-08 18:43:40
 */
public with sharing class InventoryResultRecordController {
    // 按钮区域
    public Boolean inventoryBlueFlag {get; private set;}  // 查看盘点蓝色按钮Flag
    public Boolean rentBlueFlag {get; private set;}  // 查看备品蓝色按钮Flag
    public Boolean consumBlueFlag {get; private set;}  // 查看耗材盘点蓝色按钮Flag
    // 检索区域
    public String fixtureModelNo {get; set;}  // 备品配套明细型号 Fixture_Model_No__c
    public String assetStatus {get; set;}  // 备品状态 Asset_Status__c
@@ -51,6 +63,13 @@
            selectOptions.add(new SelectOption('耗材', '耗材'));
            return selectOptions;
        }
    }
    // 初始化按钮颜色
    public void initSearchButtonColor() {
        inventoryBlueFlag = true;
        rentBlueFlag = false;
        consumBlueFlag = false;
    }
    // 所在地区(本部)PlickList
@@ -149,6 +168,7 @@
    // 画面初始化
    public void init() {
        initSearchButtonColor();
        angecylookrole = false;
        bpPankuiYing = NONE;
        ifInternalAsset = NONE;
@@ -1059,576 +1079,6 @@
    }
    @TestVisible private static void test() {
        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++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
      }
}
force-app/main/default/classes/NotetoPdfHandler.cls
New file
@@ -0,0 +1,136 @@
public without sharing class NotetoPdfHandler extends Oly_TriggerHandler {
    @TestVisible
    private Map<Id, ContentDocumentLink> newMap;
    @TestVisible
    private Map<Id, ContentDocumentLink> oldMap;
    @TestVisible
    private List<ContentDocumentLink> newList;
    @TestVisible
    private List<ContentDocumentLink> oldList;
    public NotetoPdfHandler() {
        this.newMap = (Map<Id, ContentDocumentLink>) Trigger.newMap;
        this.oldMap = (Map<Id, ContentDocumentLink>) Trigger.oldMap;
        this.newList = (List<ContentDocumentLink>) Trigger.new;
        this.oldList = (List<ContentDocumentLink>) Trigger.old;
    }
    @TestVisible
    protected override void afterInsert() {
        // 修理ID
        NotetoPdf();
        // NoteMail();
    }
    // 修理和QIS新建备注时,生成对应的PDF
    private void NotetoPdf() {
        StaticParameter.AttachmentTrigger = false;
        List<String> Rlist = new List<String>();
        // QisID
        for (ContentDocumentLink link : newList) {
            if(String.valueOf(link.LinkedEntityId).startsWith('a0J')
                || String.valueOf(link.LinkedEntityId).startsWith('a0f')){
                Rlist.add(link.Id);
            }
        }
        if (Rlist.size() > 0) {
            ReAndQISNotePDFController.generateAttachment(Rlist);
        }
    }
    private void NoteMail() {
        List<Id> linkIdList = new List<Id>();
        for (ContentDocumentLink link : newList) {
            linkIdList.add(link.Id);
        }
        newList = [select Id,LinkedEntityId,ContentDocumentId from ContentDocumentLink where Id in: linkIdList];
        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 (ContentDocumentLink link : newList) {
            if(String.valueOf(link.LinkedEntityId).startsWith('a0J')
                || String.valueOf(link.LinkedEntityId).startsWith('a0f')){
                Rlist.add(link.ContentDocumentId);
                ParentIdList.add(link.LinkedEntityId);
            }
        }
        // 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];
        List<ContentVersion> verList = [select Id,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
                                        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 (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 title = '';
            String body = '';
            title = '【修理/QIS】:' + titName + '已新增文件,请查看';
            body += '用户名:' + accountname;
            body += '<br/>';
            body += '产品名称/型号 :' + prname;
            body += '<br/>';
            body += '机身号/批号 :' + Serial;
            body += '<br/>';
            body += '附件名称/备注名称:' + version.Title;
            body += '<br/>';
            body += '操作担当:' + UserInfo.getName();
            body += '<br/>';
            body += '<br/>';
            body += '链接:' + baseUrl + '/' + link.LinkedEntityId +' ';
            //收件邮箱
            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);
        }
        Messaging.SendEmailResult[] results = messaging.sendEmail(sendMails);
    }
}
force-app/main/default/classes/NotetoPdfHandler.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/pages/AssetMaintain.page
@@ -1,7 +1,8 @@
<apex:page controller="AssetMaintainController" title="数据维护" showHeader="true" sidebar="false" id="allPage" action="{!init}" docType="html-5.0" lightningStylesheets="true">
<apex:page controller="AssetMaintainController" title="数据维护" showHeader="false" sidebar="false" id="allPage" action="{!init}" docType="html-5.0" lightningStylesheets="true">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/>
    <style>
        .dateFormat  {
            display: none;
@@ -46,7 +47,6 @@
        }
        div#in_Div_L td.dataCellBorder1 {
            border-width: 1px;
            border-left: 1px solid rgb(229, 229, 229);
        }
        div#in_Div_R td.dataCellBorder1 {
            border-width: 1px;
@@ -198,21 +198,21 @@
        }
        var globalQueryCondition;
        var fromQuickBarFlag = 'false';
        function checkAssetJs(queryCondition) {
            fromQuickBarFlag = 'true';
            globalQueryCondition = queryCondition;
            var changeFlg = checkChangeFlg();
            if (changeFlg == '1') {
                blockme();
                checkAssetFunc(queryCondition, fromQuickBarFlag);
            } else if (changeFlg == '3') {
                blockme();
                checkAssetFunc(queryCondition, fromQuickBarFlag);
                globalQueryCondition = '';
            }
            fromQuickBarFlag = 'false';
            return false;
        }
        // function checkAssetJs(queryCondition) {
        //     fromQuickBarFlag = 'true';
        //     globalQueryCondition = queryCondition;
        //     var changeFlg = checkChangeFlg();
        //     if (changeFlg == '1') {
        //         blockme();
        //         checkAssetFunc(queryCondition, fromQuickBarFlag);
        //     } else if (changeFlg == '3') {
        //         blockme();
        //         checkAssetFunc(queryCondition, fromQuickBarFlag);
        //         globalQueryCondition = '';
        //     }
        //     fromQuickBarFlag = 'false';
        //     return false;
        // }
        // 检索按钮
        function searchBtnJs() {
@@ -395,7 +395,8 @@
            <!-- 取消是清空检索区 -->
            <apex:actionFunction name="clearAllSearchConditionWhenCancel" action="{!clearAllSearchConditionWhenCancel}"></apex:actionFunction>
            <!-- 左侧按钮区 -->
            <apex:outputPanel layout="block" style="width: 13%; float: left;" rendered="{!showTop}">
            <!-- chenjingwu 2023.8.2 start-->
            <!-- <apex:outputPanel layout="block" style="width: 13%; float: left;" rendered="{!showTop}">
                <apex:pageBlock mode="maindetail">
                    <table style='height: 220px'>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看全部保有设备" rendered="{!!allBlueFlag}" onclick="checkAssetJs('all'); return false;" /></td></tr>
@@ -409,9 +410,10 @@
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看待报废保有设备" rendered="{!!scrappingBlueFlag}" onclick="checkAssetJs('scrapping'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看待报废保有设备" rendered="{!scrappingBlueFlag}" onclick="checkAssetJs('scrapping'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看已报废保有设备" rendered="{!!scrappedBlueFlag}" onclick="checkAssetJs('scrapped'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已报废保有设备" rendered="{!scrappedBlueFlag}" onclick="checkAssetJs('scrapped'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已报废保有设备" rendered="{!scrappedBlueFlag}" onclick="checkAssetJs('scrapped'); return false;" /></td></tr> -->
                        <!-- OLY_OCM-818 -->
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看已消耗的保有设备" rendered="{!!consumedBlueFlag}" onclick="checkAssetJs('consumed'); return false;" /></td></tr>
                        <!-- <tr><td class="checkButtonStyle"><apex:commandButton value="查看已消耗的保有设备" rendered="{!!consumedBlueFlag}" onclick="checkAssetJs('consumed'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已消耗的保有设备" rendered="{!consumedBlueFlag}" onclick="checkAssetJs('consumed'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看即将到期的保有设备" rendered="{!!soonExpiredBlueFlag}" onclick="checkAssetJs('soonExpired'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看即将到期的保有设备" rendered="{!soonExpiredBlueFlag}" onclick="checkAssetJs('soonExpired'); return false;" /></td></tr>
@@ -419,9 +421,21 @@
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已过期的保有设备" rendered="{!expiredBlueFlag}" onclick="checkAssetJs('expired'); return false;" /></td></tr>
                    </table>
                </apex:pageBlock>
            </apex:outputPanel>
            </apex:outputPanel> -->
            <!-- <apex:outputPanel layout="block" style="width: 13%; float: left;" rendered="{!showTop}">
                <apex:pageBlock mode="maindetail">
                    <table style='height: 220px'>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看全部保有设备" rendered="{!!allBlueFlag}" onclick="checkAssetJs('all'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看全部保有设备" rendered="{!allBlueFlag}" onclick="checkAssetJs('all'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看有效库存" rendered="{!!consumableBlueFlag}" onclick="checkAssetJs('consumable'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看有效库存" rendered="{!consumableBlueFlag}" onclick="checkAssetJs('consumable'); return false;" /></td></tr>
                    </table>
                </apex:pageBlock>
            </apex:outputPanel> -->
            <!-- chenjingwu 2023.8.2 end-->
            <!-- 右侧检索区 -->
            <apex:outputPanel layout="block" style="width: 87%; float: right;" rendered="{!showTop}">
            <apex:outputPanel layout="block" style="width: 100%;margin: 0 auto;" rendered="{!showTop}">
                <apex:pageBlock mode="maindetail">
                    <table style='width: 95%; height: 220px'>
                        <tr>
@@ -541,6 +555,14 @@
                                </apex:selectList>
                            </td>
                            <td class="blankStyle"></td>
                            <!-- chenjingwu 2023.8.2 start-->
                            <td class="labelStyle">设备状态</td>
                            <td class="inputTextStyle">
                                <apex:selectList value="{!assertQueryCondition}" id="assertQueryCondition" size="1">
                                    <apex:selectOptions value="{!assertQueryConditionOpts}"/>
                                </apex:selectList>
                            </td>
                            <!-- chenjingwu 2023.8.2 end-->
                        </tr>
                    </table>
                </apex:pageBlock>
force-app/main/default/pages/AssetMaintainIframe.page
New file
@@ -0,0 +1,44 @@
<apex:page lightningStylesheets="true">
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
        <style>
            .right-pane {
                flex: 2;
                padding: 20px;
            }
        </style>
    <apex:form >
        <apex:actionFunction action="{!loadPage}" name="cancel" rerender="allForm" oncomplete="unblockUI();"/>
        <div class="vf-container">
            <div style="width:10%;float:left;">
                <div>
                    <apex:commandButton style="width: 99%" value="数据维护" onclick="loadPage('/apex/AssetMaintain'); return false"/>
                </div>
                <div>
                    <apex:commandButton style="width: 99%" value="维护产品主数据" onclick="location.href = '/a3z/o'; return false"/>
                </div>
            </div>
            <div style="width:90%;float:right;" id="vf-content">
                <!-- VF 页面内容将在此处显示 -->
            </div>
        </div>
    </apex:form>
        <script>
            function loadPage(pageUrl) {
                var vfContent = "<iframe src='" + pageUrl + "' style='width: 100%; height: 1000px; border: none;'></iframe>";
                document.getElementById("vf-content").innerHTML = vfContent;
            }
            window.addEventListener('load', function () {
                blockme();
                var vfContent = "<iframe src='/apex/AssetMaintain' style='width: 100%; height: 1000px; border: none;'></iframe>";
                document.getElementById("vf-content").innerHTML = vfContent;
                unblockUI();
            });
        </script>
</apex:page>
force-app/main/default/pages/AssetMaintainIframe.page-meta.xml
New file
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <availableInTouch>false</availableInTouch>
    <confirmationTokenRequired>false</confirmationTokenRequired>
    <label>AssetMaintainIframe</label>
</ApexPage>
force-app/main/default/pages/CheckAllOlympusAsset.page
@@ -1,7 +1,8 @@
<apex:page controller="CheckAllOlympusAssetController" title="检索保有设备" showHeader="true" sidebar="false" id="allPage" action="{!init}" tabStyle="CheckAllOlympusAsset__tab" docType="html-5.0">
<apex:page controller="CheckAllOlympusAssetController" title="检索保有设备" showHeader="true" sidebar="false" id="allPage" action="{!init}" tabStyle="CheckAllOlympusAsset__tab" docType="html-5.0" lightningStylesheets="true">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/>
    <style>
        .dateFormat  {
            display: none;
@@ -219,21 +220,21 @@
        }
        var globalQueryCondition;
        var fromQuickBarFlag = 'false';
        function checkAssetJs(queryCondition) {
            fromQuickBarFlag = 'true';
            globalQueryCondition = queryCondition;
            var changeFlg = checkChangeFlg();
            if (changeFlg == '1') {
                blockme();
                checkAssetFunc(queryCondition, fromQuickBarFlag);
            } else if (changeFlg == '3') {
                blockme();
                checkAssetFunc(queryCondition, fromQuickBarFlag);
                globalQueryCondition = '';
            }
            fromQuickBarFlag = 'false';
            return false;
        }
        // function checkAssetJs(queryCondition) {
        //     fromQuickBarFlag = 'true';
        //     globalQueryCondition = queryCondition;
        //     var changeFlg = checkChangeFlg();
        //     if (changeFlg == '1') {
        //         blockme();
        //         checkAssetFunc(queryCondition, fromQuickBarFlag);
        //     } else if (changeFlg == '3') {
        //         blockme();
        //         checkAssetFunc(queryCondition, fromQuickBarFlag);
        //         globalQueryCondition = '';
        //     }
        //     fromQuickBarFlag = 'false';
        //     return false;
        // }
        // 检索按钮
        function searchBtnJs() {
@@ -443,7 +444,8 @@
            <!-- 取消是清空检索区 -->
            <apex:actionFunction name="clearAllSearchConditionWhenCancel" action="{!clearAllSearchConditionWhenCancel}"></apex:actionFunction>
            <!-- 左侧按钮区 -->
            <apex:outputPanel layout="block" style="width: 13%; float: left;">
            <!-- chenjingwu 2023.8.2 start-->
            <!-- <apex:outputPanel layout="block" style="width: 13%; float: left;">
                <apex:pageBlock mode="maindetail">
                    <table style='height: 220px'>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看全部保有设备" rendered="{!!allBlueFlag}" onclick="checkAssetJs('all'); return false;" /></td></tr>
@@ -456,19 +458,20 @@
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看修理中保有设备" rendered="{!repairingBlueFlag}" onclick="checkAssetJs('repairing'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看待报废保有设备" rendered="{!!scrappingBlueFlag}" onclick="checkAssetJs('scrapping'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看待报废保有设备" rendered="{!scrappingBlueFlag}" onclick="checkAssetJs('scrapping'); return false;" /></td></tr>
                        <apex:outputText rendered="{!angecylookrole}"> <!-- 1650-->
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看已报废保有设备" rendered="{!!scrappedBlueFlag && angecylookrole}" onclick="checkAssetJs('scrapped'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已报废保有设备" rendered="{!scrappedBlueFlag}" onclick="checkAssetJs('scrapped'); return false;" /></td></tr>
                        <apex:outputText rendered="{!angecylookrole}">  -->
                            <!-- 1650-->
                        <!-- <tr><td class="checkButtonStyle"><apex:commandButton value="查看已报废保有设备" rendered="{!!scrappedBlueFlag && angecylookrole}" onclick="checkAssetJs('scrapped'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已报废保有设备" rendered="{!scrappedBlueFlag}" onclick="checkAssetJs('scrapped'); return false;" /></td></tr> -->
                        <!-- OLY_OCM-818 -->
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看已消耗的保有设备" rendered="{!!consumedBlueFlag && angecylookrole}" onclick="checkAssetJs('consumed'); return false;" /></td></tr>
                        <!-- <tr><td class="checkButtonStyle"><apex:commandButton value="查看已消耗的保有设备" rendered="{!!consumedBlueFlag && angecylookrole}" onclick="checkAssetJs('consumed'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已消耗的保有设备" rendered="{!consumedBlueFlag}" onclick="checkAssetJs('consumed'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看即将到期的保有设备" rendered="{!!soonExpiredBlueFlag && angecylookrole}" onclick="checkAssetJs('soonExpired'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看即将到期的保有设备" rendered="{!soonExpiredBlueFlag}" onclick="checkAssetJs('soonExpired'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="查看已过期的保有设备" rendered="{!!expiredBlueFlag && angecylookrole}" onclick="checkAssetJs('expired'); return false;" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="查看已过期的保有设备" rendered="{!expiredBlueFlag}" onclick="checkAssetJs('expired'); return false;" /></td></tr>
                        </apex:outputText>
                        </apex:outputText> -->
                        <!-- OLY_OCM-818 -->
                        <tr>
                        <!-- <tr>
                            <td class="checkButtonStyle">
                                <apex:commandButton value="盘点结果记录" onclick="checkChangeFlg(); gotoInventoryResultRecord(); return false;" />
                            </td>
@@ -490,9 +493,10 @@
                        </tr>
                    </table>
                </apex:pageBlock>
            </apex:outputPanel>
            </apex:outputPanel> -->
            <!-- chenjingwu 2023.8.2 end-->
            <!-- 右侧检索区 -->
            <apex:outputPanel layout="block" style="width: 87%; float: right;">
            <apex:outputPanel layout="block" style="width: 90%;margin: 0 auto;">
                <apex:pageBlock mode="maindetail">
                    <table style='width: 95%; height: 220px'>
                        <tr>
@@ -633,6 +637,21 @@
                                </apex:selectList>
                            </td>
                            <td class="blankStyle"></td>
                            <!-- chenjingwu 2023.8.2 start-->
                            <td class="labelStyle">设备状态</td>
                            <td class="inputTextStyle">
                                <apex:selectList value="{!assertQueryCondition}" id="assertQueryCondition" size="1">
                                    <apex:selectOptions value="{!assertQueryConditionOpts}"/>
                                </apex:selectList>
                            </td>
                            <!-- chenjingwu 2023.8.2 end-->
                        </tr>
                        <tr><td><br /><br /></td></tr>
                        <tr>
                            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
                            <td class="searchButtonStyle">
                                <apex:commandButton style="width: 100%;float:right" value="数据维护​" onclick="gotoAssetMaintain(); return false;" rerender="allForm" />
                            </td>
                        </tr>
                    </table>
                </apex:pageBlock>
force-app/main/default/pages/InventoryIframe.page
New file
@@ -0,0 +1,50 @@
<apex:page lightningStylesheets="true">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <style>
        .right-pane {
            flex: 2;
            padding: 20px;
        }
    </style>
<apex:form >
    <apex:actionFunction action="{!loadPage}" name="cancel" rerender="allForm" oncomplete="unblockUI();"/>
    <div class="vf-container">
        <div style="width:9%;float:left;">
            <div>
                <apex:commandButton style="width: 99%" value="盘点" onclick="loadPage('/apex/InventoryResultRecord'); return false"/>
            </div>
            <div>
                <apex:commandButton style="width: 99%" value="备品盘点报告" onclick="loadPage('/apex/InventoryReport'); return false"/>
            </div>
            <div>
                <apex:commandButton style="width: 99%" value="耗材盘点报告" onclick="loadPage('/apex/InventoryReport?isConsum=true'); return false"/>
            </div>
            <div>
                <apex:commandButton style="width: 99%" value="盘点表头" onclick="location.href = '/a3H/o'; return false"/>
            </div>
        </div>
        <div style="width:91%;float:right;" id="vf-content">
            <!-- VF 页面内容将在此处显示 -->
        </div>
    </div>
</apex:form>
    <script>
        function loadPage(pageUrl) {
            var vfContent = "<iframe src='" + pageUrl + "' style='width: 100%; height: 1000px; border: none;'></iframe>";
            document.getElementById("vf-content").innerHTML = vfContent;
        }
        window.addEventListener('load', function () {
            blockme();
            var vfContent = "<iframe src='/apex/InventoryResultRecord' style='width: 100%; height: 1000px; border: none;'></iframe>";
            document.getElementById("vf-content").innerHTML = vfContent;
            unblockUI();
        });
    </script>
</apex:page>
force-app/main/default/pages/InventoryIframe.page-meta.xml
New file
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <availableInTouch>false</availableInTouch>
    <confirmationTokenRequired>false</confirmationTokenRequired>
    <label>InventoryIframe</label>
</ApexPage>
force-app/main/default/pages/InventoryReport.page
@@ -1,6 +1,7 @@
<apex:page extensions="InventoryReportController" standardController="Inventory_Header__c" showHeader="false" sidebar="false" id="allPage" action="{!init}" tabStyle="CheckAllOlympusAsset__tab" applyHtmlTag="false">
<apex:page extensions="InventoryReportController" standardController="Inventory_Header__c" showHeader="false" sidebar="false" id="allPage" action="{!init}" tabStyle="CheckAllOlympusAsset__tab"  lightningStylesheets="true" applyHtmlTag="false">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <style>
        .dateFormat  {
@@ -291,8 +292,20 @@
            <apex:param value="" name="saveType"/>
        </apex:actionFunction>
        <apex:pageBlock id="searchBlock">
            <apex:outputPanel id="RightArea" layout="block" style="margin:0 20%">
                <apex:outputPanel id="message">
            <!-- <apex:outputPanel layout="block" style="width: 13%; float: left;">
                <apex:pageBlock mode="maindetail">
                    <table style='width:140px; height: 80px'>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="盘点" rendered="{!!inventoryBlueFlag}" onclick="location.href='/apex/InventoryResultRecord'; return false"/></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="盘点" rendered="{!inventoryBlueFlag}"/></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="备品盘点报告" rendered="{!!rentBlueFlag}" onclick="location.href='{!$Page.InventoryReport}'; return false" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="备品盘点报告" rendered="{!rentBlueFlag}"/></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="耗材盘点报告" rendered="{!!consumBlueFlag}" onclick="location.href='{!$Page.InventoryReport}?isConsum=true'; return false" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="耗材盘点报告" rendered="{!consumBlueFlag}"/></td></tr>
                    </table>
                </apex:pageBlock>
            </apex:outputPanel> -->
            <apex:outputPanel id="RightArea" layout="block" style="width: 100%;">
                <apex:outputPanel id="message" style="width: auto" >
                    <apex:pageMessages />
                </apex:outputPanel>
                <div style="margin-top: 1%" class="startInventory">
force-app/main/default/pages/InventoryResultRecord.page
@@ -1,4 +1,4 @@
<apex:page controller="InventoryResultRecordController" showHeader="false" sidebar="false" id="allPage" action="{!init}" tabStyle="CheckAllOlympusAsset__tab">
<apex:page controller="InventoryResultRecordController" showHeader="false" sidebar="false" id="allPage" action="{!init}" tabStyle="CheckAllOlympusAsset__tab" lightningStylesheets="true" applyHtmlTag="false">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
@@ -7,7 +7,157 @@
<apex:includeScript value="{!URLFOR($Resource.jquery_confirm, 'jquery-confirm.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/>
    <style>
        .dateFormat  {
            display: none;
        }
        .requiredBlock  {
            display: none;
        }
        .message {
            margin: 0px;
            /*width: 1125px;*/
        }
        table {
            table-layout: fixed;
            border-collapse: collapse;
        }
        a {
            text-decoration: none;
        }
        /*TODO width margin-left 这里调节宽度*/
        div#out_Div_L {
            position: relative;
            overflow: hidden;
            width: 1300px;
        }
        div#out_Div_R {
            position: relative;
            overflow: hidden;
            width: 1200px;
            margin-left: 686px;
        }
        div#in_Div_L {
            position: relative;
            width: 745px;
            height: 451px;
        }
        div#in_Div_R {
            position: relative;
            overflow: auto;
            height: 451px;
            margin-left: 686px;
            margin-top: -451px;
        }
        div#in_Div_L td.dataCellBorder1 {
            border-width: 1px;
        }
        div#in_Div_R td.dataCellBorder1 {
            border-width: 1px;
        }
        /* 默认 */
        table.list td {width:100px;}
        table.list td select {width:95%;}
        table.list td input {width:95%;}
        table.list td textarea {
            height:50px;
            width:90%;
        }
        table.list .col_Internal_asset_location__c {width:130px;}
        table.list .col_Salesdepartment__c {width:110px;}
        table.list .col_SalesProvince__c {width:70px;}
        table.list .col_Asset_loaner_category__c {width:80px;}
        table.list .col_Fixture_Model_No_F__c {width:80px;}
        table.list .col_CompanyOfEquipment__c {width:60px;}
        table.list .col_Asset_name__c {width:60px;}
        table.list .col_Internal_Asset_number__c {width:80px;}
        table.list .col_Internal_Asset_number_key__c {width:80px;}
        table.list .col_SerialNumber {width:60px;}  /*机身编号*/
        table.list .col_Product_Serial_No__c {width:60px;}  /*产品 + 机体编码*/
        table.list .col_Product_category__c {width:60px;}
        table.list .col_Equipment_Type__c {width:120px;}
        table.list .col_Consumable_Guaranteen_end__c {width:70px;}
        table.list .col_Manage_type__c {width:80px;}  /*管理种类*/
        table.list .col_Loaner_accsessary__c {width:50px;}
        table.list .col_EquipmentSet_Managment_Code__c {width:50px;}
        table.list .col_AssetManageConfirm__c {width:50px;}
        table.list .col_Fixture_QRCode__c {width:50px;}
        table.list .col_WH_location__c {width:30px;}
        table.list .col_Quantity {width:30px;}
        table.list .col_You_Xiao_Ku_Cun__c {width:30px;}
        table.list .col_Ji_Zhong_Guan_Li_Ku_Cun__c {width:30px;}
        table.list .col_Out_of_wh__c {width:30px;}
        table.list .col_Rental_Count__c {width:30px;}
        table.list .col_Frozen_Quantity__c {width:30px;}
        table.list .col_Abandoned_RealThing__c {width:30px;}
        table.list .col_Abandoned_Inventory__c {width:40px;}
        table.list .col_Repairing_Count__c {width:30px;}
        table.list .col_Fixture_Status__c {width:30px;}
        table.list .col_Main_OneToOne__c {width:40px;}
        .navigationBarBlock {
            width: 100%;
        }
        .apexp .bPageBlock.apexDefaultPageBlock .pbBody {
            margin: 0px;
        }
        .checkButtonStyle input {
            width: 100%;
            text-align: left;
        }
        .searchButtonStyle {
            width: 50%;
        }
        .searchButtonStyle input {
            width: 80%;
            background: #9BC2E6;
        }
        .setButtonStyle {
            width: 8%;
        }
        .setButtonStyle input {
            width: 100%;
            background: #9BC2E6;
        }
        .startInventoryButtonStyle {
            width: 12%;
        }
        .labelSettingStyle {
            width: 8%;
            text-align: right;
        }
        .labelStyle {
            width: 8%;
            text-align: left;
        }
        .blankStyle {
            width: 1%;
        }
        .inputTextStyle {
            width: 9%;
        }
        .inputTextStyle input {
            width: 90%;
        }
        .inputTextStyle select {
            width: 95%;
        }
        .redStyle {
            background-color: #F00;
        }
        .greyStyle {
            background-color: #AAA;
        }
        .blueStyle input {
            background: #9BC2E6;
        }
        #pageBlockButton1 {
            margin: 0pxt;
        }
        .overlay {
            position: absolute;
            top: 0;
@@ -201,6 +351,15 @@
            text-decoration: none;
            cursor: pointer;
        }
        #pageBlockButton1 {
            margin: 0pxt;
        }
        div#in_Div_L td.dataCellBorder1 {
            border-width: 1px;
        }
        div#in_Div_R td.dataCellBorder1 {
            border-width: 1px;
        }
    </style>
    <script type="text/javascript">
        sforce.connection.sessionId = "{!$Api.Session_ID}";
@@ -370,6 +529,20 @@
                    </table>
                </apex:pageBlock>
            </apex:outputPanel> -->
            <!-- <apex:outputPanel layout="block" style="width: 14%; float: left;">
                <apex:pageBlock mode="maindetail">
                    <table style='width:140px;height: 120px'>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="盘点" rendered="{!!inventoryBlueFlag}" onclick="location.href='/apex/InventoryResultRecord'; return false"/></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="盘点" rendered="{!inventoryBlueFlag}"/></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="备品盘点报告" rendered="{!!rentBlueFlag}" onclick="location.href='{!$Page.InventoryReport}'; return false" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="备品盘点报告" rendered="{!rentBlueFlag}"/></td></tr>
                        <tr><td class="checkButtonStyle"><apex:commandButton value="耗材盘点报告" rendered="{!!consumBlueFlag}" onclick="location.href='{!$Page.InventoryReport}?isConsum=true'; return false" /></td></tr>
                        <tr><td class="checkButtonStyle blueStyle"><apex:commandButton value="耗材盘点报告" rendered="{!consumBlueFlag}"/></td></tr>
                        <tr><td></td></tr>
                    </table>
                </apex:pageBlock>
            </apex:outputPanel> -->
            <!-- 右侧检索区 -->
            <apex:outputPanel layout="block">
                <apex:pageBlock mode="maindetail" id="maindetailId">
force-app/main/default/pages/QLMAttachmentPreview1.page
@@ -1,4 +1,4 @@
<apex:page showheader="false" showquickactionvfheader="false" controller="QLMAttachmentPreviewController">
<apex:page showheader="false" showquickactionvfheader="false" controller="QLMAttachmentPreviewController" lightningStylesheets="true">
<!-- 隐藏原图 展示画布 旋转图片(4个90°)鼠标滚轮伸缩放大放小 (会失帧) -->
    <head>
        <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
@@ -6,7 +6,7 @@
        <apex:includescript value="{!URLFOR($Resource.jquery183minjs)}">
        </apex:includescript>
        <title>
            查看附件
            查看文件
        </title>
        <style>
            * {
force-app/main/default/pages/TenderAttachment.page
@@ -5,7 +5,7 @@
        <apex:includescript value="{!URLFOR($Resource.jquery183minjs)}">
        </apex:includescript>
        <title>
           查看附件
           查看文件
        </title>
        <style>
            * {
force-app/main/default/triggers/AttachmentTrigger.trigger
@@ -21,7 +21,7 @@
    List<String> OpporFileIds = new List<String>();
    Map<String,String> OpporFileUndeleteMap = new Map<String,String>();
    List<String> DeleteReIds = new List<String>();
Map<String,String> OppordeleteReUserMap = new Map<String,String>();
    Map<String,String> OppordeleteReUserMap = new Map<String,String>();
    Map<String,Datetime> OppordeleteReTimeMap = new Map<String,Datetime>();
    //CHAN-BCNCRB ---XHL----Start-----
    List<String> opportunity_FileIds = new List<String>();
@@ -29,6 +29,13 @@
    List<String> opportunityFileOrderIds = new List<String>();
    List<String> oFOrderIds = new List<String>();
    Map<String,Boolean> oFOrderIdMap = new Map<String,Boolean>();
    // sx 20230210start 备品借出申请故障报告附件提取
    List<String> rentalApplyFaultIds = new List<String>();
    Map<String,List<Id>> trentalImages = new Map<String,List<Id>>();
    List<String> rentaldeleteApplyFaultIds = new List<String>();
    Map<String,List<Id>> deleteImages = new Map<String,List<Id>>();
    // sx 20230210end 备品借出申请故障报告附件提取
    if (Trigger.isBefore && Trigger.isInsert) {
        for (Attachment att : Trigger.new) {
            if(String.valueOf(att.ParentId).startsWith(System.Label.Oppor_sepKey)){
@@ -55,7 +62,7 @@
            if (String.valueOf(att.ParentId).startsWith('001')) {
                accIds.add(att.ParentId);
            }
            //20221014 yc 医院审批优化 start  正式的叫a5A
            //20221014 yc 医院审批优化 start
            if (String.valueOf(att.ParentId).startsWith('a5C') || String.valueOf(att.ParentId).startsWith('a5A')) {
                accAppIds.add(att.ParentId);
            }
@@ -80,9 +87,25 @@
                oFOrderIds.add(att.ParentId);
                oFOrderIdMap.put(att.ParentId,true);
            }
            //2023-2-10  sx备品 备品检测分析报告 start
            Id cid = att.ParentId;
            String parentLabel = cid.getSObjectType().getDescribe().getName();
            if(parentLabel.equals('Rental_Apply_Fault__c')){
                rentalApplyFaultIds.add(att.ParentId);
                if(trentalImages.containskey(att.ParentId)){
                    trentalImages.get(att.ParentId).add(att.Id);
                }else{
                    List<Id> temp = new List<Id>();
                    temp.add(att.Id);
                    trentalImages.put(att.ParentId,temp);
                }
            }
            //2023-2-10  sx备品 备品检测分析报告 end
        }
    }
    if (Trigger.isBefore && Trigger.isDelete) {
        List<Attachment> attDeleteList = new List<Attachment>();
        for (Attachment att : Trigger.old) {
            //if (att.Name.toUpperCase() == '合同书.PDF' && String.valueOf(att.ParentId).startsWith('a0t')) {
            // 添付した契約書のファイル名は指定できない
@@ -102,7 +125,32 @@
                oFOrderIds.add(att.ParentId);
                oFOrderIdMap.put(att.ParentId,false);
            }
            //2023-2-10  sx备品 备品检测分析报告 start
            Id cid = att.ParentId;
            String parentLabel = cid.getSObjectType().getDescribe().getName();
            if(parentLabel.equals('Rental_Apply_Fault__c')){
                rentaldeleteApplyFaultIds.add(att.ParentId);
                attDeleteList.add(att);
                if(deleteImages.containskey(att.ParentId)){
                    deleteImages.get(att.ParentId).add(att.Id);
                }else{
                    List<Id> temp = new List<Id>();
                    temp.add(att.Id);
                    deleteImages.put(att.ParentId,temp);
                }
            }
            //2023-2-10  sx备品 备品检测分析报告 end
        }
        //2023-2-10  sx备品 备品检测分析报告 start
        List<Rental_Apply_Fault__c> rafList = [SELECT Id, Name FROM Rental_Apply_Fault__c WHERE Id IN: rentaldeleteApplyFaultIds AND (status__c = '已发送' OR status__c = '已反馈')];
        for (Rental_Apply_Fault__c raf : rafList) {
            for (Attachment att : attDeleteList) {
                if (att.ParentId == raf.Id) {
                    att.addError('非草案中的检测分析报告不允许删除已上传的故障图片');
                }
            }
        }
        //2023-2-10  sx备品 备品检测分析报告 end
    }
    if (Trigger.isAfter && Trigger.isDelete) {
        for (Attachment att : Trigger.old) {
@@ -134,8 +182,44 @@
        }
    }
    //20221207 lt 医院审批优化 start
    //2023-2-10  sx备品 备品检测分析报告 start
    if(rentalApplyFaultIds.size() > 0){
        List<Rental_Apply_Fault__c> renList = [SELECT Id,AttachmentId1__c,AttachmentId2__c from Rental_Apply_Fault__c where Id in :rentalApplyFaultIds];
        system.debug('updrentalApplyFaultList====='+renList);
        for(Rental_Apply_Fault__c ren : renList){
            if(trentalImages.containskey(ren.Id)){
                if (ren.AttachmentId1__c == null) {
                    ren.AttachmentId1__c = trentalImages.get(ren.id)[0];
                } else if(ren.AttachmentId2__c == null) {
                    ren.AttachmentId2__c = trentalImages.get(ren.id)[0];
                }
            }
        }
        system.debug('updrentalApplyFaultList====='+renList);
        UPDATE renList;
    }
    if(rentaldeleteApplyFaultIds.size() > 0){
        List<Rental_Apply_Fault__c> renList = [SELECT Id,AttachmentId1__c,AttachmentId2__c from Rental_Apply_Fault__c where Id in :rentaldeleteApplyFaultIds];
        system.debug('renList====='+renList);
        for(Rental_Apply_Fault__c ren : renList){
            if(deleteImages.containskey(ren.Id)){
                if(deleteImages.get(ren.Id).contains(ren.AttachmentId1__c)){
                    ren.AttachmentId1__c = '';
                }
                if(deleteImages.get(ren.Id).contains(ren.AttachmentId2__c)){
                    ren.AttachmentId2__c = '';
                }
            }
        }
        system.debug('renList====='+renList);
        UPDATE renList;
    }
    //2023-2-10  sx备品 备品检测分析报告 end
    if (rentaldelIds.size() > 0) {
        List<Consumable_accessories_invoice__c> rentaldelList = new List<Consumable_accessories_invoice__c>();
        for (Consumable_accessories_invoice__c ra : [select Id from Consumable_accessories_invoice__c where Invoice_code__c in :rentaldelIds and Attachment_ID__c in :attdelIds]) {
@@ -492,153 +576,17 @@
                    oFOrder.LatestUploadUser__c = null;
                    oFOrder.LatestUploadTime__c = null;
                }
            }
            }、
            update oFOrderList;
        }                                            
    }
   if (Test.isRunningTest()) {
        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++;
    // DB202304087063 SFDC系统附件上传自动通知功能开发需求 start
    if (Trigger.isInsert && Trigger.isAfter && StaticParameter.AttachmentTrigger) {
        AttachmentReQisHandler handler = new AttachmentReQisHandler();
        handler.run();
    }
    // DB202304087063 SFDC系统附件上传自动通知功能开发需求 end
}
force-app/main/default/triggers/ContentDocumentLink.trigger
@@ -1,75 +1,530 @@
trigger ContentDocumentLink on ContentDocumentLink (before delete, after insert) {
    // if((!Test.isRunningTest())&&UserInfo.getUserId()==System.Label.ByPassTrigger){
    //     return;
    // }
    system.debug('enter ContentDocumentLink');
    system.debug('Trigger.new = ' + (List<ContentDocumentLink>) Trigger.new);
    system.debug('Trigger.old = ' + (List<ContentDocumentLink>) Trigger.old);
    String invoiceStart = System.Label.invoiceStart;
    System.debug('invoiceStart = ' + invoiceStart);
trigger ContentDocumentLink on ContentDocumentLink (before insert,after insert,before delete,after delete, before update, after update) {
    List<String> rentalIds = new List<String>();
    List<String> attIds = new List<String>();
    // List<String> rentaldelIds = new List<String>();
    // List<String> attdelIds = new List<String>();
    List<String> rentaldelIds = new List<String>();
    List<String> attdelIds = new List<String>();
    List<String> rentalApplyIds = new List<String>();
    List<String> accIds = new List<String>();
    //20221014 yc 医院审批优化 start
    List<String> accAppIds = new List<String>();
    //20221014 yc 医院审批优化 end
    // LHJ CHAN-BCLD4P 20190618 Start
    List<String> specIds = new List<String>();
    List<String> specDelIds = new List<String>();
    // LHJ CHAN-BCLD4P 20190618 End
    if (Trigger.isAfter && Trigger.isInsert) {
        System.debug('Trigger.isAfter && Trigger.isInsert');
        for (ContentDocumentLink cdl : Trigger.new) {
            System.debug('cdl.LinkedEntityId = ' + cdl.LinkedEntityId);
            System.debug('cdl.ContentDocumentId = ' + cdl.ContentDocumentId);
            if (String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)) {
                System.debug('String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)');
                rentalIds.add(cdl.LinkedEntityId);
                attIds.add(cdl.ContentDocumentId);
                System.debug('rentalIds = ' + rentalIds);
                System.debug('attIds = ' + attIds);
    // MZY SWAG-BXXBKA  2021-02-19 start
    List<String> opdIds = new List<String>();
    Map<String,String> opdMap = new Map<String,String>();
    // MZY SWAG-BXXBKA  2021-02-19 end
    List<String> OpporFileIds = new List<String>();
    Map<String,String> OpporFileUndeleteMap = new Map<String,String>();
    List<String> DeleteReIds = new List<String>();
    Map<String,String> OppordeleteReUserMap = new Map<String,String>();
    Map<String,Datetime> OppordeleteReTimeMap = new Map<String,Datetime>();
    //CHAN-BCNCRB ---XHL----Start-----
    List<String> opportunity_FileIds = new List<String>();
    List<String> opportunityFileOrderIds = new List<String>();
    List<String> oFOrderIds = new List<String>();
    Map<String,Boolean> oFOrderIdMap = new Map<String,Boolean>();
    // sx 20230210start 备品借出申请故障报告附件提取
    List<String> rentalApplyFaultIds = new List<String>();
    Map<String,List<Id>> trentalImages = new Map<String,List<Id>>();
    List<String> rentaldeleteApplyFaultIds = new List<String>();
    Map<String,List<Id>> deleteImages = new Map<String,List<Id>>();
    // sx 20230210end 备品借出申请故障报告附件提取
    if (Trigger.isBefore && Trigger.isInsert) {
        for (ContentDocumentLink link : Trigger.new) {
            if(String.valueOf(link.LinkedEntityId).startsWith(System.Label.Oppor_sepKey)){
                opportunity_FileIds.add(link.LinkedEntityId);
            }
            if(String.valueOf(link.LinkedEntityId).startsWith('a3Z')){
                opportunityFileOrderIds.add(link.LinkedEntityId);
            }
        }
    }
    // if (Trigger.isBefore && Trigger.isDelete) {
    //     System.debug('Trigger.isBefore && Trigger.isDelete');
    //     for (ContentDocumentLink cdl : Trigger.old) {
    //         System.debug('cdl.LinkedEntityId = ' + cdl.LinkedEntityId);
    //         System.debug('cdl.ContentDocumentId = ' + cdl.ContentDocumentId);
    //         if (String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)) {
    //             System.debug('String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)');
    //             rentaldelIds.add(cdl.LinkedEntityId);
    //             attdelIds.add(cdl.ContentDocumentId);
    //             System.debug('rentaldelIds = ' + rentaldelIds);
    //             System.debug('attdelIds = ' + attdelIds);
    //         }
    //     }
    // }
    //CHAN-BCNCRB ---XHL----End-----
    if (Trigger.isAfter && Trigger.isInsert) {
        for (ContentDocumentLink link : Trigger.new) {
            ContentVersion version = [select Id,Title from ContentVersion where ContentDocumentId =: link.ContentDocumentId];
            //if (att.Name.toUpperCase() == '合同书.PDF' && String.valueOf(att.ParentId).startsWith('a0t')) {
            // 添付した契約書のファイル名は指定できない
            if (String.valueOf(link.LinkedEntityId).startsWith('a2K')) {
                rentalIds.add(link.LinkedEntityId);
                attIds.add(version.Id);
            }
            if (String.valueOf(link.LinkedEntityId).startsWith('a0t')) {
                rentalApplyIds.add(link.LinkedEntityId);
            }
            if (String.valueOf(link.LinkedEntityId).startsWith('001')) {
                accIds.add(link.LinkedEntityId);
            }
            //20221014 yc 医院审批优化 start
            if (String.valueOf(link.LinkedEntityId).startsWith('a5C') || String.valueOf(link.LinkedEntityId).startsWith('a5A')) {
                accAppIds.add(link.LinkedEntityId);
            }
            //20221014 yc 医院审批优化 end
            if(String.valueOf(link.LinkedEntityId).startsWith(System.Label.Oppor_sepKey)){
                OpporFileIds.add(link.LinkedEntityId);
            }
            // LHJ CHAN-BCLD4P 20190618 Start
            if(String.valueOf(link.LinkedEntityId).startsWith(System.Label.OppSpecialApply)){
                specIds.add(link.LinkedEntityId);
            }
            // LHJ CHAN-BCLD4P 20190618 End
            // MZY SWAG-BXXBKA  2021-02-19 start
            if(String.valueOf(link.LinkedEntityId).startsWith('a3E')){
                opdIds.add(link.LinkedEntityId);
                opdMap.put(link.LinkedEntityId,version.Title);
             }
            // MZY SWAG-BXXBKA  2021-02-19 end
            if(String.valueOf(link.LinkedEntityId).startsWith('a3Z')){
                oFOrderIds.add(link.LinkedEntityId);
                oFOrderIdMap.put(link.LinkedEntityId,true);
            }
            //2023-2-10  sx备品 备品检测分析报告 start
            Id cid = link.LinkedEntityId;
            String parentLabel = cid.getSObjectType().getDescribe().getName();
            if(parentLabel.equals('Rental_Apply_Fault__c')){
                rentalApplyFaultIds.add(link.LinkedEntityId);
                if(trentalImages.containskey(link.LinkedEntityId)){
                    trentalImages.get(link.LinkedEntityId).add(version.Id);
                }else{
                    List<Id> temp = new List<Id>();
                    temp.add(version.Id);
                    trentalImages.put(link.LinkedEntityId,temp);
                }
            }
            //2023-2-10  sx备品 备品检测分析报告 end
        }
    }
    if (Trigger.isAfter && Trigger.isDelete) {
        for (ContentDocumentLink link : Trigger.old) {
            if (String.valueOf(link.LinkedEntityId).startsWith('001')) {
                accIds.add(link.LinkedEntityId);
            }
            // LHJ CHAN-BCLD4P 20190618 Start
            if(String.valueOf(link.LinkedEntityId).startsWith(System.Label.OppSpecialApply)){
                specIds.add(link.LinkedEntityId);
            }
            // LHJ CHAN-BCLD4P 20190618 End
            //20221014 yc 医院审批优化 start
            if (String.valueOf(link.LinkedEntityId).startsWith('a5C') || String.valueOf(link.LinkedEntityId).startsWith('a5A')) {
                accAppIds.add(link.LinkedEntityId);
            }
            //20221014 yc 医院审批优化 end
        }
    }
    //2023-2-10  sx备品 备品检测分析报告 start
    if(rentalApplyFaultIds.size() > 0){
        List<Rental_Apply_Fault__c> renList = [SELECT Id,AttachmentId1__c,AttachmentId2__c from Rental_Apply_Fault__c where Id in :rentalApplyFaultIds];
        system.debug('updrentalApplyFaultList====='+renList);
        for(Rental_Apply_Fault__c ren : renList){
            if(trentalImages.containskey(ren.Id)){
                if (ren.AttachmentId1__c == null) {
                    ren.AttachmentId1__c = trentalImages.get(ren.id)[0];
                } else if(ren.AttachmentId2__c == null) {
                    ren.AttachmentId2__c = trentalImages.get(ren.id)[0];
                }
            }
        }
        system.debug('updrentalApplyFaultList====='+renList);
        UPDATE renList;
    }
    if(rentaldeleteApplyFaultIds.size() > 0){
        List<Rental_Apply_Fault__c> renList = [SELECT Id,AttachmentId1__c,AttachmentId2__c from Rental_Apply_Fault__c where Id in :rentaldeleteApplyFaultIds];
        system.debug('renList====='+renList);
        for(Rental_Apply_Fault__c ren : renList){
            if(deleteImages.containskey(ren.Id)){
                if(deleteImages.get(ren.Id).contains(ren.AttachmentId1__c)){
                    ren.AttachmentId1__c = '';
                }
                if(deleteImages.get(ren.Id).contains(ren.AttachmentId2__c)){
                    ren.AttachmentId2__c = '';
                }
            }
        }
        system.debug('renList====='+renList);
        UPDATE renList;
    }
    //2023-2-10  sx备品 备品检测分析报告 end
    if (rentaldelIds.size() > 0) {
        List<Consumable_accessories_invoice__c> rentaldelList = new List<Consumable_accessories_invoice__c>();
        for (Consumable_accessories_invoice__c ra : [select Id from Consumable_accessories_invoice__c where Invoice_code__c in :rentaldelIds and Attachment_ID__c in :attdelIds]) {
            rentaldelList.add(ra);
        }
        ControllerUtil.delConsumableAccessoriesInvoiceSet(rentaldelList);
    }
    if (rentalIds.size() > 0) {
        List<Consumable_order__c> rentalList = new List<Consumable_order__c>();
        for (Consumable_order__c ra : [SELECT Id FROM Consumable_order__c WHERE Id IN :rentalIds]) {
        for (Consumable_order__c ra : [select Id from Consumable_order__c where Id in :rentalIds]) {
            ra.Consumable_pdf_insert_day__c = Date.today();
            ra.Order_Attachment__c = attIds[0];
            //ra.Order_status__c = '录入完成';
            //ra.Contract_pdf_updated__c = true;
            rentalList.add(ra);
        }
        System.debug('rentalList = ' + rentalList);
        ControllerUtil.updRentalApplyList(rentalList);
    }
    // if (Trigger.isInsert && Trigger.isAfter && StaticParameter.ContentDocumentLink) {
    //     AttachmentReQisHandler handler = new AttachmentReQisHandler();
    //     handler.run();
    // }
     if (rentalApplyIds.size() > 0) {
        List<Rental_Apply__c> rentalApplyList = new List<Rental_Apply__c>();
        for (Rental_Apply__c ra : [select Id from Rental_Apply__c where Id in :rentalApplyIds]) {
            ra.Contract_pdf_update_day__c = Date.today();
            ra.Contract_pdf_updated__c = true;
            rentalApplyList.add(ra);
        }
        ControllerUtil.updRentalApplyList(rentalApplyList);
    }
    // if (rentaldelIds.size() > 0) {
    //     List<Consumable_accessories_invoice__c> rentaldelList = new List<Consumable_accessories_invoice__c>();
    //     for (Consumable_accessories_invoice__c ra : [
    //         SELECT Id
    //         FROM Consumable_accessories_invoice__c
    //         WHERE Invoice_code__c IN :rentaldelIds AND Attachment_ID__c IN :attdelIds
    //     ]) {
    //         rentaldelList.add(ra);
    //     }
    //     System.debug('rentaldelList = ' + rentaldelList);
    //     ControllerUtil.delConsumableAccessoriesInvoiceSet(rentaldelList);
    // }
    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];
        for (ContentDocumentLink link : linkList) {
            attMap.put(link.LinkedEntityId, link.LinkedEntityId);
        }
        List<Account> updAccList = new List<Account>();
        //20221207 lt 医院审批优化 start
        List<Account> accList = [select id,Name,
                                                         Is_Active__c
                                               from Account
                                               where id in:accIds ];
        //20221207 lt 医院审批优化 end
        for (String accid : accIds) {
            if(accList.size() > 0){
                // Account acc = new Account(Id = accid);
                //20221207 lt 医院审批优化 start
                for(Account acc : accList){
                    if(Trigger.isDelete && (Trigger.isAfter)){
                        for(ContentDocumentLink link : Trigger.old){
                            // if(attMap.containsKey(att.ParentID) && acc.Is_Active__c != '草案中'){
                            if(acc.Is_Active__c != '草案中'){
                                link.addError('非草案中,附件不允许删除。');
                                return;
                            }
                        }
                    }
                    acc.Is_upload_file__c = 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;
    }
    //20221014 yc 医院审批优化 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];
        for (ContentDocumentLink link : linkList) {
            attMap.put(link.LinkedEntityId, link.LinkedEntityId);
        }
        List<Account_Delay_Apply__c> updAccAppList = new List<Account_Delay_Apply__c>();
        //20221207 lt 医院审批优化 start
        List<Account_Delay_Apply__c> adaList = [select id,Name,
                                                         Is_Active__c
                                               from Account_Delay_Apply__c
                                               where id in:accAppIds ];
        //20221207 lt 医院审批优化 end
        for (String accappid : accAppIds) {
            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);
                }
            }
            //20221207 lt 医院审批优化 end
        }
        if (updAccAppList.size() > 0) update updAccAppList;
    }
    //20221014 yc 医院审批优化 end
    // LHJ CHAN-BCLD4P 20190618 Start
    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 LinkedEntityId from ContentDocumentLink where LinkedEntityId =: specIds order by LinkedEntityId];
        for (ContentDocumentLink link : linkList) {
            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;
    }
    // LHJ CHAN-BCLD4P 20190618 End
    // MZY SWAG-BXXBKA  2021-02-19 start
    System.debug('SWAG-BXXBKA start');
    if (opdIds.size()>0) {
        List<OPDPlan__c> updateOPDs = new List<OPDPlan__c>();
        OPDPlan__c tempOPD = new OPDPlan__c();
        for (String i :opdIds ) {
            tempOPD.id = i;
            tempOPD.AttachmentCertificate__c = opdMap.get(i);
            updateOPDs.add(tempOPD);
        }
        System.debug('临时OPD :'+tempOPD);
        if (updateOPDs.size()>0){
            update updateOPDs;
        }
    }
    System.debug('SWAG-BXXBKA end');
    // MZY SWAG-BXXBKA  2021-02-19 end
    if(OpporFileIds.size()>0){
        List<Opportunity_File__c> OpporList = [select id,Last_upload_time__c,
                                                            Is_Locked__c,
                                                            Last_upload_user__c,
                                                            Stock_apply_time__c
                                                        from Opportunity_File__c
                                                        where id
                                                        in:OpporFileIds ];
        if(OpporList.size()>0){
            for(Opportunity_File__c ofc : OpporList){
                if(!ofc.Is_Locked__c){
                    ofc.Last_upload_user__c = UserInfo.getUserId();
                    ofc.Last_upload_time__c = System.now();
                    System.debug(ofc+'23333');
                }else{
                    OpporFileUndeleteMap.put(ofc.id,ofc.id);
                    System.debug(ofc+'23333444444');
                }
            }
            update OpporList;
        }
    }
    System.debug(Trigger.isDelete+'Trigger.isDelete');
    System.debug(Trigger.isBefore+'Trigger.isBefore');
    if(Trigger.isDelete && Trigger.isAfter){
        for(ContentDocumentLink link : Trigger.old){
            if(OpporFileUndeleteMap.containsKey(link.LinkedEntityId)){
                link.addError('备货已审批,不可删除附件');
                return;
            }else{
                DeleteReIds.add(link.LinkedEntityId);
            }
        }
    }
    if(Trigger.isInsert){
        for(ContentDocumentLink link : Trigger.new){
            if(OpporFileUndeleteMap.containsKey(link.LinkedEntityId)){
                ContentDocument doc = [select Id from ContentDocument where Id =: link.ContentDocumentId];
                doc.addError('备货已审批,不可删除附件');
                // link.addError('备货已审批,不可删除附件');
                return;
            }else{
                DeleteReIds.add(link.LinkedEntityId);
            }
        }
    }
    // List<Attachment> atcList = [select id,ParentId,createddate,createdbyid from Attachment where ParentId in:DeleteReIds];
    List<ContentDocumentLink> linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId in:DeleteReIds];
    List<Id> idList = new List<Id>();
    for (ContentDocumentLink link : linkList) {
        idList.add(link.ContentDocumentId);
    }
    List<ContentDocument> docList = [select Id,ArchivedDate,ArchivedById from ContentDocument where Id =: idList];
    System.debug(DeleteReIds+'222222222222');
    if(docList.size()>0){
        for(String ids : DeleteReIds){
            for(ContentDocument doc : docList){
                if(OppordeleteReTimeMap.containsKey(ids)){
                    if(doc.ArchivedDate > OppordeleteReTimeMap.get(ids)){
                        OppordeleteReTimeMap.put(ids,doc.ArchivedDate);
                        OppordeleteReUserMap.put(ids,doc.ArchivedById);
                    }else{
                        continue;
                    }
                }else{
                    OppordeleteReTimeMap.put(ids,doc.ArchivedDate);
                    OppordeleteReUserMap.put(ids,doc.ArchivedById);
                }
            }
        }
        List<Opportunity_File__c> reDateList = [select id,Last_upload_time__c,
                                                                Is_Locked__c,
                                                                Last_upload_user__c
                                                            from Opportunity_File__c
                                                            where id
                                                            in:DeleteReIds ];
        if(reDateList.size()>0){
            for(Opportunity_File__c ofc : reDateList){
                ofc.Last_upload_time__c = OppordeleteReTimeMap.get(ofc.id);
                ofc.Last_upload_user__c = OppordeleteReUserMap.get(ofc.id);
                System.debug(ofc+'233333333');
            }
            update reDateList;
        }
    }else{
        List<Opportunity_File__c> reDateList = [select id,Last_upload_time__c,
                                                                Is_Locked__c,
                                                                Last_upload_user__c
                                                            from Opportunity_File__c
                                                            where id
                                                            in:DeleteReIds ];
        if(reDateList.size()>0){
            for(Opportunity_File__c ofc : reDateList){
                if (!ofc.Is_Locked__c) {
                    ofc.Last_upload_time__c = null;
                    ofc.Last_upload_user__c = null;
                    update reDateList;
                }
            }
        }
    }
    //CHAN-BCNCRB ---XHL----Start-----
    if (opportunity_FileIds.size() > 0) {
        List<Opportunity_File__c> opporList = [select id,Last_upload_time__c,
                                                            Is_Locked__c,
                                                            Last_upload_user__c,
                                                            Stock_apply_time__c,
                                                            Oppor_File_Stage__c
                                                        from Opportunity_File__c
                                                        where id in:opportunity_FileIds And Oppor_File_Stage__c = 'G'];
        List<String>  ofIds = new  List<String>();
        if (opporList.size() > 0) {
            for (Opportunity_File__c oppf : opporList) {
                ofIds.add(oppf.Id);
            }
            if (ofIds.size() > 0 ) {
                //  List<Attachment> atcList = [select id,ParentId,createddate,createdbyid from Attachment where ParentId in:ofIds];
                List<ContentDocumentLink> linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId in:ofIds];
                List<Id> idList = new List<Id>();
                for (ContentDocumentLink link : linkList) {
                    idList.add(link.ContentDocumentId);
                }
                List<ContentDocument> docList = [select Id from ContentDocument where Id in: idList];
                if (docList.size() > 0) {
                    delete docList;
                }
            }
        }
    }
    //CHAN-BCNCRB ---XHL----End-----
    if (opportunityFileOrderIds.size() > 0) {
        List<OpportunityFileOrder__c> ofoList = [select id,
                                                            OpporFileStage__c
                                                        from OpportunityFileOrder__c
                                                        where Id in:opportunityFileOrderIds And OpporFileStage__c = 'G'];
        List<String>  ofoIds = new  List<String>();
        if (ofoList.size() > 0) {
            for (OpportunityFileOrder__c ofo : ofoList) {
                ofoIds.add(ofo.Id);
            }
            if (ofoIds.size() > 0 ) {
                //  List<Attachment> atcList = [select id,ParentId,createddate,createdbyid from Attachment where ParentId in:ofoIds];
                List<ContentDocumentLink> linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId in:ofoIds];
                List<Id> idList = new List<Id>();
                for (ContentDocumentLink link : linkList) {
                    idList.add(link.ContentDocumentId);
                }
                List<ContentDocument> docList = [select Id from ContentDocument where Id in: idList];
                if (docList.size() > 0) {
                    delete docList;
                }
            }
        }
    }
    if (oFOrderIdMap.size() > 0) {
        List<OpportunityFileOrder__c> oFOrderList = [select Id,Name,LatestUploadUser__c,LatestUploadTime__c
                                                    from OpportunityFileOrder__c
                                                    where Id In : oFOrderIdMap.keySet()];
        if (oFOrderList.size() > 0 ) {
            for (OpportunityFileOrder__c oFOrder :oFOrderList) {
                if (oFOrderIdMap.get(oFOrder.Id)) {
                    oFOrder.LatestUploadUser__c = UserInfo.getUserId();
                    oFOrder.LatestUploadTime__c = System.now();
                } else if (oFOrderIdMap.get(oFOrder.Id) == false){
                    oFOrder.LatestUploadUser__c = null;
                    oFOrder.LatestUploadTime__c = null;
                }
            }
            update oFOrderList;
        }
    }
    // DB202304087063 SFDC系统附件上传自动通知功能开发需求 start
    if (Trigger.isInsert && Trigger.isAfter && false) {
        AttachmentReQisHandler handler = new AttachmentReQisHandler();
        handler.run();
    }
    // DB202304087063 SFDC系统附件上传自动通知功能开发需求 end
}
force-app/main/default/triggers/ContentDocumentTrigger.trigger
New file
@@ -0,0 +1,496 @@
trigger ContentDocumentTrigger on ContentDocument (before delete) {
    List<String> rentalIds = new List<String>();
    List<String> attIds = new List<String>();
    List<String> rentaldelIds = new List<String>();
    List<String> attdelIds = new List<String>();
    List<String> rentalApplyIds = new List<String>();
    List<String> accIds = new List<String>();
    //20221014 yc 医院审批优化 start
    List<String> accAppIds = new List<String>();
    //20221014 yc 医院审批优化 end
    // LHJ CHAN-BCLD4P 20190618 Start
    List<String> specIds = new List<String>();
    List<String> specDelIds = new List<String>();
    // LHJ CHAN-BCLD4P 20190618 End
    // MZY SWAG-BXXBKA  2021-02-19 start
    List<String> opdIds = new List<String>();
    Map<String,String> opdMap = new Map<String,String>();
    // MZY SWAG-BXXBKA  2021-02-19 end
    List<String> OpporFileIds = new List<String>();
    Map<String,String> OpporFileUndeleteMap = new Map<String,String>();
    List<String> DeleteReIds = new List<String>();
    Map<String,String> OppordeleteReUserMap = new Map<String,String>();
    Map<String,Datetime> OppordeleteReTimeMap = new Map<String,Datetime>();
    //CHAN-BCNCRB ---XHL----Start-----
    List<String> opportunity_FileIds = new List<String>();
    List<String> opportunityFileOrderIds = new List<String>();
    List<String> oFOrderIds = new List<String>();
    Map<String,Boolean> oFOrderIdMap = new Map<String,Boolean>();
    // sx 20230210start 备品借出申请故障报告附件提取
    List<String> rentalApplyFaultIds = new List<String>();
    Map<String,List<Id>> trentalImages = new Map<String,List<Id>>();
    List<String> rentaldeleteApplyFaultIds = new List<String>();
    Map<String,List<Id>> deleteImages = new Map<String,List<Id>>();
    // sx 20230210end 备品借出申请故障报告附件提取
    //CHAN-BCNCRB ---XHL----End-----
    if (Trigger.isBefore && Trigger.isDelete) {
        // List<Attachment> attDeleteList = new List<Attachment>();
        List<ContentDocumentLink> conDeleteList = new List<ContentDocumentLink>();
        for (ContentDocument doc : Trigger.old) {
            List<ContentDocumentLink> link = [select LinkedEntityId from ContentDocumentLink where ContentDocumentId =: doc.Id limit 1];
            //if (att.Name.toUpperCase() == '合同书.PDF' && String.valueOf(att.ParentId).startsWith('a0t')) {
            // 添付した契約書のファイル名は指定できない
            ContentVersion version = [select Id from ContentVersion where ContentDocumentId =: doc.Id];
            if (String.valueOf(link[0].LinkedEntityId).startsWith('a2K')) {
                rentaldelIds.add(link[0].LinkedEntityId);
                attdelIds.add(version.Id);
            }
            if(String.valueOf(link[0].LinkedEntityId).startsWith(System.Label.Oppor_sepKey)){
                OpporFileIds.add(link[0].LinkedEntityId);
            }
            // LHJ CHAN-BCLD4P 20190618 Start
            if(String.valueOf(link[0].LinkedEntityId).startsWith(System.Label.OppSpecialApply)){
                specDelIds.add(link[0].LinkedEntityId);
            }
            // LHJ CHAN-BCLD4P 20190618 End
            if(String.valueOf(link[0].LinkedEntityId).startsWith('a3Z')){
                oFOrderIds.add(link[0].LinkedEntityId);
                oFOrderIdMap.put(link[0].LinkedEntityId,false);
            }
            //2023-2-10  sx备品 备品检测分析报告 start
            Id cid = link[0].LinkedEntityId;
            String parentLabel = cid.getSObjectType().getDescribe().getName();
            if(parentLabel.equals('Rental_Apply_Fault__c')){
                rentaldeleteApplyFaultIds.add(link[0].LinkedEntityId);
                conDeleteList.add(link[0]);
                if(deleteImages.containskey(version.Id)){
                    deleteImages.get(link[0].LinkedEntityId).add(version.Id);
                }else{
                    List<Id> temp = new List<Id>();
                    temp.add(version.Id);
                    deleteImages.put(link[0].LinkedEntityId,temp);
                }
            }
            //2023-2-10  sx备品 备品检测分析报告 end
        }
        //2023-2-10  sx备品 备品检测分析报告 start
        List<Rental_Apply_Fault__c> rafList = [SELECT Id, Name FROM Rental_Apply_Fault__c WHERE Id IN: rentaldeleteApplyFaultIds AND (status__c = '已发送' OR status__c = '已反馈')];
        for (Rental_Apply_Fault__c raf : rafList) {
            for (ContentDocumentLink link : conDeleteList) {
                if (link.LinkedEntityId == raf.Id) {
                    ContentDocument doc = [select Id from ContentDocument where Id =: link.ContentDocumentId];
                    doc.addError('非草案中的检测分析报告不允许删除已上传的故障图片');
                }
            }
        }
        //2023-2-10  sx备品 备品检测分析报告 end
    }
    //20221207 lt 医院审批优化 start
    //2023-2-10  sx备品 备品检测分析报告 start
    if(rentalApplyFaultIds.size() > 0){
        List<Rental_Apply_Fault__c> renList = [SELECT Id,AttachmentId1__c,AttachmentId2__c from Rental_Apply_Fault__c where Id in :rentalApplyFaultIds];
        system.debug('updrentalApplyFaultList====='+renList);
        for(Rental_Apply_Fault__c ren : renList){
            if(trentalImages.containskey(ren.Id)){
                if (ren.AttachmentId1__c == null) {
                    ren.AttachmentId1__c = trentalImages.get(ren.id)[0];
                } else if(ren.AttachmentId2__c == null) {
                    ren.AttachmentId2__c = trentalImages.get(ren.id)[0];
                }
            }
        }
        system.debug('updrentalApplyFaultList====='+renList);
        UPDATE renList;
    }
    if(rentaldeleteApplyFaultIds.size() > 0){
        List<Rental_Apply_Fault__c> renList = [SELECT Id,AttachmentId1__c,AttachmentId2__c from Rental_Apply_Fault__c where Id in :rentaldeleteApplyFaultIds];
        system.debug('renList====='+renList);
        for(Rental_Apply_Fault__c ren : renList){
            if(deleteImages.containskey(ren.Id)){
                if(deleteImages.get(ren.Id).contains(ren.AttachmentId1__c)){
                    ren.AttachmentId1__c = '';
                }
                if(deleteImages.get(ren.Id).contains(ren.AttachmentId2__c)){
                    ren.AttachmentId2__c = '';
                }
            }
        }
        system.debug('renList====='+renList);
        UPDATE renList;
    }
    //2023-2-10  sx备品 备品检测分析报告 end
    if (rentaldelIds.size() > 0) {
        List<Consumable_accessories_invoice__c> rentaldelList = new List<Consumable_accessories_invoice__c>();
        for (Consumable_accessories_invoice__c ra : [select Id from Consumable_accessories_invoice__c where Invoice_code__c in :rentaldelIds and Attachment_ID__c in :attdelIds]) {
            rentaldelList.add(ra);
        }
        ControllerUtil.delConsumableAccessoriesInvoiceSet(rentaldelList);
    }
    if (rentalIds.size() > 0) {
        List<Consumable_order__c> rentalList = new List<Consumable_order__c>();
        for (Consumable_order__c ra : [select Id from Consumable_order__c where Id in :rentalIds]) {
            ra.Consumable_pdf_insert_day__c = Date.today();
            ra.Order_Attachment__c = attIds[0];
            //ra.Order_status__c = '录入完成';
            //ra.Contract_pdf_updated__c = true;
            rentalList.add(ra);
        }
        ControllerUtil.updRentalApplyList(rentalList);
    }
     if (rentalApplyIds.size() > 0) {
        List<Rental_Apply__c> rentalApplyList = new List<Rental_Apply__c>();
        for (Rental_Apply__c ra : [select Id from Rental_Apply__c where Id in :rentalApplyIds]) {
            ra.Contract_pdf_update_day__c = Date.today();
            ra.Contract_pdf_updated__c = true;
            rentalApplyList.add(ra);
        }
        ControllerUtil.updRentalApplyList(rentalApplyList);
    }
    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];
        for (ContentDocumentLink link : linkList) {
            attMap.put(link.LinkedEntityId, link.LinkedEntityId);
        }
        List<Account> updAccList = new List<Account>();
        //20221207 lt 医院审批优化 start
        List<Account> accList = [select id,Name,
                                                         Is_Active__c
                                               from Account
                                               where id in:accIds ];
        //20221207 lt 医院审批优化 end
        for (String accid : accIds) {
            if(accList.size() > 0){
                // Account acc = new Account(Id = accid);
                //20221207 lt 医院审批优化 start
                for(Account acc : accList){
                    if(Trigger.isDelete && (Trigger.isBefore || Trigger.isAfter)){
                        for(ContentDocument doc : Trigger.old){
                            // if(attMap.containsKey(att.ParentID) && acc.Is_Active__c != '草案中'){
                            if(acc.Is_Active__c != '草案中'){
                                doc.addError('非草案中,附件不允许删除。');
                                return;
                            }
                        }
                    }
                    acc.Is_upload_file__c = 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;
    }
    //20221014 yc 医院审批优化 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];
        for (ContentDocumentLink link : linkList) {
            attMap.put(link.LinkedEntityId, link.LinkedEntityId);
        }
        List<Account_Delay_Apply__c> updAccAppList = new List<Account_Delay_Apply__c>();
        //20221207 lt 医院审批优化 start
        List<Account_Delay_Apply__c> adaList = [select id,Name,
                                                         Is_Active__c
                                               from Account_Delay_Apply__c
                                               where id in:accAppIds ];
        //20221207 lt 医院审批优化 end
        for (String accappid : accAppIds) {
            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){
                    if(Trigger.isDelete){
                        for(ContentDocument doc : Trigger.old){
                            // if(attMap.containsKey(att.ParentID) && accapp.Is_Active__c != '草案中'){
                            if(accapp.Is_Active__c != '草案中'){
                                doc.addError('非草案中,附件不允许删除。');
                                return;
                            }
                        }
                    }
                    accapp.Is_upload_file__c = attMap.containsKey(accappid);
                    updAccAppList.add(accapp);
                }
            }
            //20221207 lt 医院审批优化 end
        }
        if (updAccAppList.size() > 0) update updAccAppList;
    }
    //20221014 yc 医院审批优化 end
    // LHJ CHAN-BCLD4P 20190618 Start
    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 LinkedEntityId from ContentDocumentLink where LinkedEntityId =: specIds order by LinkedEntityId];
        for (ContentDocumentLink link : linkList) {
            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;
    }
    // LHJ CHAN-BCLD4P 20190618 End
    // MZY SWAG-BXXBKA  2021-02-19 start
    System.debug('SWAG-BXXBKA start');
    if (opdIds.size()>0) {
        List<OPDPlan__c> updateOPDs = new List<OPDPlan__c>();
        OPDPlan__c tempOPD = new OPDPlan__c();
        for (String i :opdIds ) {
            tempOPD.id = i;
            tempOPD.AttachmentCertificate__c = opdMap.get(i);
            updateOPDs.add(tempOPD);
        }
        System.debug('临时OPD :'+tempOPD);
        if (updateOPDs.size()>0){
            update updateOPDs;
        }
    }
    System.debug('SWAG-BXXBKA end');
    // MZY SWAG-BXXBKA  2021-02-19 end
    if(OpporFileIds.size()>0){
        List<Opportunity_File__c> OpporList = [select id,Last_upload_time__c,
                                                            Is_Locked__c,
                                                            Last_upload_user__c,
                                                            Stock_apply_time__c
                                                        from Opportunity_File__c
                                                        where id
                                                        in:OpporFileIds ];
        if(OpporList.size()>0){
            for(Opportunity_File__c ofc : OpporList){
                if(!ofc.Is_Locked__c){
                    ofc.Last_upload_user__c = UserInfo.getUserId();
                    ofc.Last_upload_time__c = System.now();
                    System.debug(ofc+'23333');
                    update ofc;
                }else{
                    OpporFileUndeleteMap.put(ofc.id,ofc.id);
                    System.debug(ofc+'23333444444');
                }
            }
        }
    }
    System.debug(Trigger.isDelete+'Trigger.isDelete');
    System.debug(Trigger.isBefore+'Trigger.isBefore');
    if(Trigger.isDelete && Trigger.isBefore){
        for(ContentDocument doc : Trigger.old){
            List<ContentDocumentLink> link = [select LinkedEntityId from ContentDocumentLink where ContentDocumentId =: doc.Id];
            if(OpporFileUndeleteMap.containsKey(link[0].LinkedEntityId)){
                doc.addError('备货已审批,不可删除附件');
                return;
            }else{
            }
        }
    }
    if(Trigger.isDelete && Trigger.isAfter){
        for(ContentDocument doc : Trigger.old){
            List<ContentDocumentLink> link = [select LinkedEntityId from ContentDocumentLink where ContentDocumentId =: doc.Id];
            if(OpporFileUndeleteMap.containsKey(link[0].LinkedEntityId)){
                doc.addError('备货已审批,不可删除附件');
                return;
            }else{
                DeleteReIds.add(link[0].LinkedEntityId);
            }
        }
    }
    // List<Attachment> atcList = [select id,ParentId,createddate,createdbyid from Attachment where ParentId in:DeleteReIds];
    if (DeleteReIds.size() > 0) {
        List<ContentDocumentLink> linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId =:DeleteReIds];
        List<Id> idList = new List<Id>();
        for (ContentDocumentLink link : linkList) {
            idList.add(link.ContentDocumentId);
        }
        List<ContentDocument> docList = [select Id,ArchivedDate,ArchivedById from ContentDocument where Id =: idList];
        System.debug(DeleteReIds+'222222222222');
        if(docList.size()>0){
            for(String ids : DeleteReIds){
                for(ContentDocument doc : docList){
                    if(OppordeleteReTimeMap.containsKey(ids)){
                        if(doc.ArchivedDate > OppordeleteReTimeMap.get(ids)){
                            OppordeleteReTimeMap.put(ids,doc.ArchivedDate);
                            OppordeleteReUserMap.put(ids,doc.ArchivedById);
                        }else{
                            continue;
                        }
                    }else{
                        OppordeleteReTimeMap.put(ids,doc.ArchivedDate);
                        OppordeleteReUserMap.put(ids,doc.ArchivedById);
                    }
                }
            }
            List<Opportunity_File__c> reDateList = [select id,Last_upload_time__c,
                                                                    Is_Locked__c,
                                                                    Last_upload_user__c
                                                                from Opportunity_File__c
                                                                where id
                                                                in:DeleteReIds ];
            if(reDateList.size()>0){
                for(Opportunity_File__c ofc : reDateList){
                    ofc.Last_upload_time__c = OppordeleteReTimeMap.get(ofc.id);
                    ofc.Last_upload_user__c = OppordeleteReUserMap.get(ofc.id);
                    System.debug(ofc+'233333333');
                }
                update reDateList;
            }
        }else{
            List<Opportunity_File__c> reDateList = [select id,Last_upload_time__c,
                                                                    Is_Locked__c,
                                                                    Last_upload_user__c
                                                                from Opportunity_File__c
                                                                where id
                                                                in:DeleteReIds ];
            if(reDateList.size()>0){
                for(Opportunity_File__c ofc : reDateList){
                    ofc.Last_upload_time__c = null;
                    ofc.Last_upload_user__c = null;
                }
                update reDateList;
            }
        }
    }
    //CHAN-BCNCRB ---XHL----Start-----
    if (opportunity_FileIds.size() > 0) {
        List<Opportunity_File__c> opporList = [select id,Last_upload_time__c,
                                                            Is_Locked__c,
                                                            Last_upload_user__c,
                                                            Stock_apply_time__c,
                                                            Oppor_File_Stage__c
                                                        from Opportunity_File__c
                                                        where id in:opportunity_FileIds And Oppor_File_Stage__c = 'G'];
        List<String>  ofIds = new  List<String>();
        if (opporList.size() > 0) {
            for (Opportunity_File__c oppf : opporList) {
                ofIds.add(oppf.Id);
            }
            if (ofIds.size() > 0 ) {
                //  List<Attachment> atcList = [select id,ParentId,createddate,createdbyid from Attachment where ParentId in:ofIds];
                List<ContentDocumentLink> linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId in: ofIds];
                List<Id> idList = new List<Id>();
                for (ContentDocumentLink link : linkList) {
                    idList.add(link.ContentDocumentId);
                }
                List<ContentDocument> docList = [select Id from ContentDocument where Id in: idList];
                if (docList.size() > 0) {
                    delete docList;
                }
            }
        }
    }
    //CHAN-BCNCRB ---XHL----End-----
    if (opportunityFileOrderIds.size() > 0) {
        List<OpportunityFileOrder__c> ofoList = [select id,
                                                            OpporFileStage__c
                                                        from OpportunityFileOrder__c
                                                        where Id in:opportunityFileOrderIds And OpporFileStage__c = 'G'];
        List<String>  ofoIds = new  List<String>();
        if (ofoList.size() > 0) {
            for (OpportunityFileOrder__c ofo : ofoList) {
                ofoIds.add(ofo.Id);
            }
            if (ofoIds.size() > 0 ) {
                //  List<Attachment> atcList = [select id,ParentId,createddate,createdbyid from Attachment where ParentId in:ofoIds];
                List<ContentDocumentLink> linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId in:ofoIds];
                List<Id> idList = new List<Id>();
                for (ContentDocumentLink link : linkList) {
                    idList.add(link.ContentDocumentId);
                }
                List<ContentDocument> docList = [select Id from ContentDocument where Id in: idList];
                if (docList.size() > 0) {
                    delete docList;
                }
            }
        }
    }
    if (oFOrderIdMap.size() > 0) {
        List<OpportunityFileOrder__c> oFOrderList = [select Id,Name,LatestUploadUser__c,LatestUploadTime__c
                                                    from OpportunityFileOrder__c
                                                    where Id In : oFOrderIdMap.keySet()];
        if (oFOrderList.size() > 0 ) {
            for (OpportunityFileOrder__c oFOrder :oFOrderList) {
                if (oFOrderIdMap.get(oFOrder.Id)) {
                    oFOrder.LatestUploadUser__c = UserInfo.getUserId();
                    oFOrder.LatestUploadTime__c = System.now();
                } else if (oFOrderIdMap.get(oFOrder.Id) == false){
                    oFOrder.LatestUploadUser__c = null;
                    oFOrder.LatestUploadTime__c = null;
                }
            }
            update oFOrderList;
        }
    }
}
force-app/main/default/triggers/ContentDocumentTrigger.trigger-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <status>Active</status>
</ApexTrigger>
force-app/main/default/triggers/ContentVersionTrigger.trigger
New file
@@ -0,0 +1,3 @@
trigger ContentVersionTrigger on ContentVersion (before update,after update) {
}
force-app/main/default/triggers/ContentVersionTrigger.trigger-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>56.0</apiVersion>
    <status>Active</status>
</ApexTrigger>
force-app/main/default/triggers/NotetoPdf.trigger
New file
@@ -0,0 +1,9 @@
/**
 * SFDC系统案件(修理/QIS)中新建附件或备注时,
 * 系统自动通知到相关业务人员
 * 其中备注会自动生成PDF附件
 */
trigger NotetoPdf on Note(after insert) {
    NotetoPdfHandler handler = new NotetoPdfHandler();
    handler.run();
}
force-app/main/default/triggers/NotetoPdf.trigger-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>41.0</apiVersion>
    <status>Active</status>
</ApexTrigger>