buli
2023-05-22 71b93327e8f3fb3bffffc7c033c1f782e7b6ab32
force-app/main/default/classes/LexSummonsCreatController.cls
@@ -105,31 +105,42 @@
    public static Boolean EditDelCommitBtnDisabled { get; private set; }
    public static Boolean saveBtnDisabled { get; private set; }
    public static Boolean SorderBtnDisabled { get; private set; }
    // page
    public static Integer pagesize { get; set; }
    public static Integer pageToken { get; set; }
    //public static String sortField { get; set; }
    //public static String sortOrder { get; set; }
    public static Integer totalcount { get; set; }
    public static Integer addSize { get; set; }
    //List<ConsumableorderdetailsInfoLwc> reSetLwc
    public static List<ConsumableorderdetailsInfo> addData { get; set; }
    public static Map<String, String> skipData { get; set; }
    // 保存后动作: 1.检索 2.排序
    public static String sortKey { get; set; }
    public static String preSortKey { get; private set; }
    public static Boolean sortOrderAsc { get; private set; }
    public static String[] sortOrder { get; private set; }
    private static String[] columus = new List<String>{
        'Consumable_Product__r.Name',
        'Consumable_Product__r.Asset_Model_No__c',
        'Consumable_Product__r.Intra_Trade_List_RMB__c',
        '',
        '',
        'Consumable_Product__r.Category3__c',
        'Consumable_Product__r.Category4__c',
        'Consumable_Product__r.Category5__c'
    };
    private static String[] columus_no = new List<String>{
        'Product2__c.Name',
        'Product2__c.Asset_Model_No__c',
        'Product2__c.Intra_Trade_List_RMB__c',
        '',
        '',
        'Category3__c',
        'Category4__c',
        'Category5__c'
    };
    // public static String sortKey { get; set; }
    // public static String preSortKey { get; private set; }
    // public static Boolean sortOrderAsc { get; private set; }
    // public static String[] sortOrder { get; private set; }
    // private static String[] columus = new List<String>{
    //     'Consumable_Product__r.Name',
    //     'Consumable_Product__r.Asset_Model_No__c',
    //     'Consumable_Product__r.Intra_Trade_List_RMB__c',
    //     '',
    //     '',
    //     'Consumable_Product__r.Category3__c',
    //     'Consumable_Product__r.Category4__c',
    //     'Consumable_Product__r.Category5__c'
    // };
    // private static String[] columus_no = new List<String>{
    //     'Product2__c.Name',
    //     'Product2__c.Asset_Model_No__c',
    //     'Product2__c.Intra_Trade_List_RMB__c',
    //     '',
    //     '',
    //     'Category3__c',
    //     'Category4__c',
    //     'Category5__c'
    // };
    //到货单明细1
    private static List<Consumable_Orderdetails__c> consumableorderdetailsSelected = new List<Consumable_Orderdetails__c>();
@@ -234,7 +245,12 @@
    // 画面初始化
    @AuraEnabled
    public static ResponseBodyLWC init(String ESetidJs,String statusEdit) {
    public static ResponseBodyLWC init(
        String ESetidJs,
        String statusEdit,
        Integer pageSizeLWC,
        Integer pageTokenLWC
    ) {
        // try {
        firstInit(ESetidJs);
        statusEdit = statusEdit;
@@ -245,12 +261,18 @@
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        // public static Integer pagesize { get; set; }
        // public static Integer pageToken { get; set; }
        // public static String sortField { get; set; }
        // public static String sortOrder { get; set; }
        pagesize = pageSizeLWC;
        pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
        sortKey = '1';
        preSortKey = '1';
        sortOrderAsc = false;
        sortOrder = new List<String>(8);
        sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '↓', '', '', '' };
        // sortKey = '1';
        // preSortKey = '1';
        // sortOrderAsc = false;
        // sortOrder = new List<String>(8);
        // sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '↓', '', '', '' };
        //cate1ForSort = '';
        sumPrice = 0;
        IdCheck = EsetId;
@@ -326,6 +348,9 @@
        for (AggregateResult orderdetail : orderdetailCount) {
            zaikuId.add(String.valueOf(orderdetail.get('cpc')));
        }
        System.debug('sqlagencyProType = ' + sqlagencyProType);
        System.debug('userWorkLocation = ' + userWorkLocation);
        System.debug('accountName = ' + accountName);
        List<Consumable_order_details2__c> CountDel = [
            SELECT
                Id,
@@ -359,8 +384,8 @@
            SummonsFlag = 'hidden';
            String msoql = makeSoqlinventory();
            initStandardController(msoql);
            System.debug('msoql = ' + msoql);
            product2Selected = Database.query(msoql);
            //product2Selected = product2s();
            if (String.isBlank(arriveorder)) {
                EditDelCommitBtnDisabled = true;
                for (Integer i = 0; i < product2Selected.size(); i++) {
@@ -414,6 +439,7 @@
                            MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
                        }
                    }
                    System.debug('MidMap2.size() = ' + MidMap2.size());
                    /*//然后循环CountDel去修改map里的allnumber
                        if(MidMap.containsKey(CountDel[i].Consumable_Product__c)){
                            ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c);
@@ -450,7 +476,7 @@
                Integer ishosnum = 0;
                for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
                    ass.sortBy = sortOrderAsc;
                    //ass.sortBy = sortOrderAsc;
                    //add by rentx 2021-3-10
                    if (ass.hospitalSpecialOffer) {
                        ishosnum = ishosnum + 1;
@@ -641,7 +667,7 @@
                Integer ishosnum = 0;
                for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
                    ass.sortBy = sortOrderAsc;
                    //ass.sortBy = sortOrderAsc;
                    for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
                        cdc1.Shipment_Count__c = cdc1.Consumable_count__c;
                        if (ass.prod.Id == cdc1.Consumable_Product__c) {
@@ -720,6 +746,8 @@
                    AND Invoice_status__c != '草案中'
            ];
            System.debug('coc ESetId = ' + ESetId);
            System.debug('coc userWorkLocation = ' + userWorkLocation);
            coc = [
                SELECT
                    Id,
@@ -1173,7 +1201,7 @@
                // return null;
                Integer ishosnum = 0;
                for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
                    ass.sortBy = sortOrderAsc;
                    //ass.sortBy = sortOrderAsc;
                    for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
                        //update by rentx 2012-3-1 start
                        // if(ass.prod.Id == cdc1.Consumable_Product__c){
@@ -1311,10 +1339,38 @@
        category5OptionMap = new Map<String, String>();
        category5OptionMap.put('', '-无-');
        //分页
        PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
        totalCount = pageRecords.size();
        System.debug('pageToken = ' + pageToken);
        System.debug('pageSize = ' + pageSize);
        System.debug('totalCount = ' + totalCount);
        paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
        System.debug('paginatedAccounts.nextPageToken = ' + paginatedAccounts.nextPageToken);
        paginatedAccounts.recordStart = pageToken + 1;
        paginatedAccounts.pageNumber = pageToken / pageSize + 1;
        Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
        paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
        paginatedAccounts.totalRecords = totalCount;
        Integer startIdx;
        Integer endIdx;
        startIdx = pageToken;
        endIdx = pageToken + pageSize;
        List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
        if (endIdx > pageRecords.size()) {
            endIdx = pageRecords.size();
        }
        for (Integer i = startIdx; i < endIdx; i++) {
            pageRecordsTemp.add(pageRecords.get(i));
        }
        Boolean Existarrive = (coc.Arrive_Order__c != null);
        String ConsumableOut_report = System.Label.ConsumableOut_report;
        System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords);
        data.put('ConsumableOut_report', 'ConsumableOut_report');
        data.put('paginatedAccounts', paginatedAccounts);
        data.put('ConsumableOut_report', ConsumableOut_report);
        data.put('accountid', accountid);
        data.put('consumableproductdetailsRecords', consumableproductdetailsRecords);
        data.put('agencyProType', agencyProType);
@@ -1333,7 +1389,7 @@
        data.put('EditDelCommitBtnDisabled', EditDelCommitBtnDisabled);
        data.put('EditAble', EditAble);
        data.put('coc', coc);
        data.put('pageRecords', pageRecords);
        data.put('pageRecords', pageRecordsTemp);
        data.put('arriveorder', arriveorder);
        data.put('consumableorderdetails2Count', consumableorderdetails2Count);
        data.put('consumableorderdetails2Records', consumableorderdetails2Records);
@@ -1362,7 +1418,7 @@
        ];
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category4OptionMap = new Map<String,String>();
        category4OptionMap = new Map<String, String>();
        category4OptionMap.put('', '-无-');
        for (AggregateResult category4Search : category4List) {
            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
@@ -1379,15 +1435,15 @@
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        category5OptionMap = new Map<String,String>();
        category5OptionMap = new Map<String, String>();
        category5OptionMap.put('', '-无-');
        for (AggregateResult category5Search : category5List) {
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
            category5OptionMap.put(deliverycnt5, deliverycnt5);
        }
        data.put('category4OptionMap',category4OptionMap);
        data.put('category5OptionMap',category5OptionMap);
        data.put('category4OptionMap', category4OptionMap);
        data.put('category5OptionMap', category5OptionMap);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
@@ -1395,7 +1451,7 @@
    }
    @AuraEnabled
    public static ResponseBodyLWC categoryload(String category3Lwc,String category4Lwc) {
    public static ResponseBodyLWC categoryload(String category3Lwc, String category4Lwc) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
@@ -1410,7 +1466,7 @@
        ];
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category4OptionMap = new Map<String,String>();
        category4OptionMap = new Map<String, String>();
        category4OptionMap.put('', '-无-');
        for (AggregateResult category4Search : category4List) {
            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
@@ -1427,15 +1483,15 @@
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        category5OptionMap = new Map<String,String>();
        category5OptionMap = new Map<String, String>();
        category5OptionMap.put('', '-无-');
        for (AggregateResult category5Search : category5List) {
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
            category5OptionMap.put(deliverycnt5, deliverycnt5);
        }
        data.put('category4OptionMap',category4OptionMap);
        data.put('category5OptionMap',category5OptionMap);
        data.put('category4OptionMap', category4OptionMap);
        data.put('category5OptionMap', category5OptionMap);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
@@ -1456,7 +1512,9 @@
        Boolean editAbleLwc,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,
        List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
        String arriveorderLwc
        String arriveorderLwc,
        Integer pageSizeLWC,
        Integer pageTokenLWC
    ) {
        consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
        pageRecordsLwc = pageRecordsLwcLwc;
@@ -1465,6 +1523,14 @@
        accountName = accountNameLwc;
        userWorkLocation = userWorkLocationLwc;
        agencyProType = agencyProTypeLwc;
        product2Selected = new List<Product2__c>();
        pagesize = pageSizeLWC;
        pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
        addSize = 0;
        addData = new List<ConsumableorderdetailsInfo>();
        System.debug('start addData = ' + addData);
        System.debug('accountName = ' + accountName);
        System.debug('userWorkLocation = ' + userWorkLocation);
        String sqlagencyProType = '%' + agencyProTypeLwc + '%';
        List<AggregateResult> orderdetailCount = [
            SELECT count(id), Consumable_Product__c cpc, Box_Piece__c
@@ -1509,9 +1575,9 @@
        consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
        //consumableorderdetailsSelectRecords = reSet;
        String soql = makeSoql(category1, category3, category4, category5);
        System.debug('soql = ' + soql);
        size = Integer.valueOf(System.Label.orderdetLimitsize);
        initStandardController(soql);
        System.debug('soql = ' + soql);
        product2Selected = Database.query(soql);
        for (Integer i = 0; i < product2Selected.size(); i++) {
            MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
@@ -1591,18 +1657,52 @@
        }
        consumableorderdetailsSelectRecords.sort();
        //add by rentx
        //noOfRecords = consumableorderdetailsSelectRecords.size();
        //add by rentx
        //makepagerecords();
        makepagerecordsLwc();
        // this.sortKey = '1';
        // this.preSortKey = '1';
        // this.sortOrderAsc = false;
        // this.sortOrder = new String[8];
        // this.sortOrder = new String[]{' ',' ',' ',' ','↓','','',''};
        data.put('pageRecords', pageRecords);
        data.put('test', 'test');
        //分页
        PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
        totalCount = pageRecords.size();
        paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
        paginatedAccounts.recordStart = pageToken + 1;
        paginatedAccounts.pageNumber = pageToken / pageSize + 1;
        Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
        paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
        paginatedAccounts.totalRecords = totalCount;
        System.debug('addSize = ' + addSize);
        Integer startIdx;
        Integer endIdx;
        startIdx = pageToken;
        endIdx = pageToken + pageSize;
        List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
        if (endIdx > pageRecords.size()) {
            endIdx = pageRecords.size();
        }
        System.debug('addData.size() = ' + addData.size());
        for (ConsumableorderdetailsInfo ci : addData) {
            pageRecordsTemp.add(ci);
        }
        System.debug('startIdx = ' + startIdx);
        System.debug('endIdx = ' + endIdx);
        System.debug('skipData = ' + skipData);
        System.debug('pageRecords = ' + pageRecords.size());
        String hos = '';
        for (Integer i = startIdx; i < endIdx; i++) {
            System.debug('skipData.get(pageRecords.get(i).Prod.Id) = ' + skipData.get(pageRecords.get(i).Prod.Id));
            if (pageRecords.get(i).hospitalSpecialOffer == true) {
                hos = 'ishos';
            } else {
                hos = 'nothos';
            }
            if (skipData.get(pageRecords.get(i).Prod.Id + hos) == null) {
                pageRecordsTemp.add(pageRecords.get(i));
            }
        }
        System.debug('pageRecordsTemp = ' + pageRecordsTemp.size());
        data.put('paginatedAccounts', paginatedAccounts);
        data.put('pageRecords', pageRecordsTemp);
        data.put('SearchDone', SearchDone);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
@@ -1612,10 +1712,12 @@
    private static String makeSoql(String CateName, String Category3, String Category4, String Category5) {
        String sqlTail1 = '(\'';
        for (Integer i = 0; i < zaikuId.size(); i++) {
            if (i < zaikuId.size() - 1) {
                sqlTail1 += zaikuId[i] + '\',\'';
            } else {
                sqlTail1 += zaikuId[i];
            if (zaikuId[i] != null) {
                if (i < zaikuId.size() - 1) {
                    sqlTail1 += zaikuId[i] + '\',\'';
                } else {
                    sqlTail1 += zaikuId[i];
                }
            }
        }
        sqlTail1 += '\')';
@@ -1659,10 +1761,12 @@
    public static String makeSoqlinventory() {
        String sqlTail = '(\'';
        for (Integer i = 0; i < zaikuId.size(); i++) {
            if (i < zaikuId.size() - 1) {
                sqlTail += zaikuId[i] + '\',\'';
            } else {
                sqlTail += zaikuId[i];
            if (zaikuId[i] != null) {
                if (i < zaikuId.size() - 1) {
                    sqlTail += zaikuId[i] + '\',\'';
                } else {
                    sqlTail += zaikuId[i];
                }
            }
        }
        sqlTail += '\')';
@@ -1701,6 +1805,7 @@
        }
        System.debug('zhj3');
        pageRecords = new List<ConsumableorderdetailsInfo>();
        System.debug('reSet.size() = ' + reSet.size());
        if (editAble && String.isBlank(arriveorder)) {
            pageRecords = reSet;
        }
@@ -1708,7 +1813,7 @@
        //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
        Integer addNo = 0;
        //update by rentx 2021-2-26 start
        System.debug('consumableorderdetailsSelectRecords = ' + consumableorderdetailsSelectRecords);
        System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size());
        for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) {
            Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
            if (
@@ -1733,6 +1838,7 @@
    public static List<ConsumableorderdetailsInfo> makepagerecordsLwc() {
        List<ConsumableorderdetailsInfoLwc> reSetLwc = new List<ConsumableorderdetailsInfoLwc>();
        Map<String, String> selectedIdMap = new Map<String, String>();
        skipData = new Map<String, String>();
        System.debug('makepagerecordsLwc pageRecordsLwc = ' + pageRecordsLwc);
        //取出选择的产品
        if (pageRecordsLwc != null) {
@@ -1741,18 +1847,20 @@
                if (ass.check == true) {
                    if (ass.hospitalSpecialOffer == true) {
                        selectedIdMap.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
                        skipData.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
                    } else {
                        selectedIdMap.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
                        skipData.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
                    }
                    reSetLwc.add(ass);
                }
            }
        }
        System.debug('reSetLwc = ' + reSetLwc);
        System.debug('selectedIdMap = ' + selectedIdMap);
        pageRecords = new List<ConsumableorderdetailsInfo>();
        if (editAble && String.isBlank(arriveorder)) {
            List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
            System.debug('reSetLwc = ' + reSetLwc);
            for (ConsumableorderdetailsInfoLwc assLwc : reSetLwc) {
                ConsumableorderdetailsInfo ci = new ConsumableorderdetailsInfo();
                ci.check = assLwc.check;
@@ -1779,19 +1887,24 @@
                reSet.add(ci);
            }
            pageRecords = reSet;
            System.debug('reSet = ' + reSet);
            addData = reSet.clone();
            System.debug('addData = reSet = ' + addData);
        }
        //Integer pagestartNo = (setCon.getPageNumber() * size)-size;
        //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
        Integer addNo = 0;
        //update by rentx 2021-2-26 start
        System.debug('consumableorderdetailsSelectRecords = ' + consumableorderdetailsSelectRecords);
        System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size());
        for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) {
            Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
            if (
                (info.hospitalSpecialOffer && selectedIdMap.containsKey(info.Prod.Id + 'ishos')) ||
                (info.hospitalSpecialOffer == false && selectedIdMap.containsKey(info.Prod.Id + 'nothos'))
            ) {
                System.debug('去掉的id : ' + info.Prod.Id);
                addNo++;
                addSize++;
            } else {
                if (info.check == false) {
                    info.orderdetails1 = orderdetails1;
@@ -1800,7 +1913,8 @@
                addNo++;
            }
        }
        System.debug('pageRecords = ' + pageRecords);
        System.debug('pageRecords.size() = ' + pageRecords.size());
        System.debug('end  addData = ' + addData);
        return pageRecords;
    }
@@ -1810,19 +1924,33 @@
        Consumable_order__c cocLwc,
        String hospitalInfoLwc,
        String hospitalNameLwc,
        String secondaryDistributor,
        String secondaryDistributorLwc,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,
        String accountid,
        String ESetId,
        List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc
        String accountidLwc,
        String ESetIdLwc,
        List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
        String agencyProTypeLwc,
        String userWorkLocationLwc
    ) {
        System.debug('cocLwc = ' + cocLwc);
        coc = cocLwc;
        HospitalInfo = hospitalInfoLwc;
        HospitalName = hospitalNameLwc;
        SecondDealer = secondaryDistributor;
        SecondDealer = secondaryDistributorLwc;
        pageRecordsLwc = pageRecordsLwc;
        accountid = accountidLwc;
        consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
        ESetId = ESetIdLwc;
        agencyProType = agencyProTypeLwc;
        userWorkLocation = userWorkLocationLwc;
        System.debug('coc = ' + coc);
        System.debug('HospitalInfo = ' + HospitalInfo);
        System.debug('HospitalName = ' + HospitalName);
        System.debug('SecondDealer = ' + SecondDealer);
        System.debug('pageRecordsLwc = ' + pageRecordsLwc);
        System.debug('accountid = ' + accountid);
        System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords);
        System.debug('ESetId = ' + ESetId);
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
@@ -2393,32 +2521,53 @@
        nameCondition += '%' + String.escapeSingleQuotes(''.replaceAll('%', '\\%')) + '%';
        List<Account> accs;
        System.debug('nameCondition = ' + nameCondition);
        accs = [
            SELECT id, Parentid
            FROM Account
            WHERE
                Parent.Name LIKE :nameCondition
                AND Contract_Decide_Start_Date__c <= :Date.Today()
                AND Contract_Decide_End_Date__c >= :Date.Today()
        ];
        // 用于保存特约经销商匹配到的其父类的id
        Set<String> pids = new Set<String>();
        for (Account acc : accs) {
            pids.add(acc.Parentid);
        }
        //查询条件修改
        //筛选判断条件:当前财年的4/1 ~ 第二年的6/30  & ET or ENG类型 & 当前用户类型
        //1 and 2
        //1. Integer year 2022/4/1 ~ 2023/6/30
        //开始日期 + 结束日期
        //Contract_Decide_Start_Date__c>=开始日期  and Contract_Decide_End_Date__c<结束日期
        //2. 添加经销商允销类型:ET经销商协议;ENG耗材经销商协议
        //取当前用户的类型,如果用户类型是ET,ET经销商协议 = true
        accs = [
            SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
            FROM Account
            WHERE
                (Id IN :pids
                OR (Name = '奥林巴斯(北京)销售服务有限公司'
                AND Name LIKE :nameCondition))
                 Name = '奥林巴斯(北京)销售服务有限公司'
                AND Name LIKE :nameCondition
                AND RecordType.DeveloperName = 'Agency'
                AND Is_Active__c != '無効'
                //And 1 And 2
                //AND Is_Active__c != '無効'
            ORDER BY Name
            LIMIT 5
            LIMIT 49
        ];
        // accs = [
        //     SELECT id, Parentid
        //     FROM Account
        //     WHERE
        //         Parent.Name LIKE :nameCondition
        //         AND Contract_Decide_Start_Date__c <= :Date.Today()
        //         AND Contract_Decide_End_Date__c >= :Date.Today()
        // ];
        // 用于保存特约经销商匹配到的其父类的id
        // Set<String> pids = new Set<String>();
        // for (Account acc : accs) {
        //     pids.add(acc.Parentid);
        // }
        // accs = [
        //     SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
        //     FROM Account
        //     WHERE
        //         (Id IN :pids
        //         OR (Name = '奥林巴斯(北京)销售服务有限公司'
        //         AND Name LIKE :nameCondition))
        //         AND RecordType.DeveloperName = 'Agency'
        //         AND Is_Active__c != '無効'
        //     ORDER BY Name
        //     LIMIT 5
        // ];
        List<LookupSearchResult> results = new List<LookupSearchResult>();
        String accountIcon = 'standard:account';
@@ -2453,7 +2602,7 @@
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        List<ContentVersion> cvList = [
            SELECT id, Title, CreatedBy.Name, PathOnClient,CreatedDate
            SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate,ContentDocumentId
            FROM ContentVersion
            WHERE FirstPublishLocationId = :recordId
        ];
@@ -2518,7 +2667,7 @@
        ESetId = ESetId;
        Savepoint sp = Database.setSavepoint();
        try{
        try {
            List<Consumable_order__c> qs = new List<Consumable_order__c>();
            List<Consumable_orderdetails__c> Dqs = new List<Consumable_orderdetails__c>();
            Dqs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId];
@@ -2527,7 +2676,7 @@
                delete Dqs;
                delete qs;
            }
        }catch(Exception e){
        } catch (Exception e) {
            Database.rollback(sp);
            System.debug(e.getMessage() + e.getLineNumber());
            return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
@@ -2742,4 +2891,18 @@
        @AuraEnabled
        public String Category5 { get; set; }
    }
    //分页Bean
    public class PaginatedAccounts {
        @AuraEnabled
        public Integer nextPageToken;
        @AuraEnabled
        public Integer pageNumber { get; set; }
        @AuraEnabled
        public Integer totalRecords { get; set; }
        @AuraEnabled
        public Integer recordStart { get; set; }
        @AuraEnabled
        public Integer recordEnd { get; set; }
    }
}