From 3962c2bb0435484b60a3e408e4738d792e249a53 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 05 六月 2023 11:09:55 +0800
Subject: [PATCH] LEX CommunityNewCmp

---
 force-app/main/default/classes/LexInventoryViewController.cls | 1114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,114 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/LexInventoryViewController.cls b/force-app/main/default/classes/LexInventoryViewController.cls
new file mode 100644
index 0000000..cc2ec34
--- /dev/null
+++ b/force-app/main/default/classes/LexInventoryViewController.cls
@@ -0,0 +1,1114 @@
+public without sharing class LexInventoryViewController {
+    /*****************鐢婚潰琛ㄧずBean******************/
+    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+    public static List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
+
+    // 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 pagecount { get; set; }
+    // public static Integer currentpage { get; set; }
+    // public static Boolean hasPrevious { get; set; }
+    // public static Boolean hasNext { get; set; }
+    public static List<ConsumableorderdetailsInfo> pageRecords { get; set; }
+    public static String soql { get; set; }
+
+    // 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>{
+    //     'Product2__c.Name__c',
+    //     'Asset_Model_No__c',
+    //     '',
+    //     'Category3__c',
+    //     'Category4__c',
+    //     'Category5__c',
+    //     ''
+    // };
+
+    public static String[] proLimitAndDate = new List<String>{};
+    private static Map<String, Date> productkucun = new Map<String, Date>();
+    public static List<SelectOption> categoryOptionList { get; set; }
+    @AuraEnabled
+    public static Map<String, String> categoryOptionMap { get; set; }
+    public static List<SelectOption> category4OptionList { get; set; }
+    @AuraEnabled
+    public static Map<String, String> category4OptionMap { get; set; }
+    public static List<SelectOption> category5OptionList { get; set; }
+    @AuraEnabled
+    public static Map<String, String> category5OptionMap { get; set; }
+    public static String category5 { get; set; }
+    public static String category4 { get; set; }
+    public static String category3 { get; set; }
+    public static String category_Goods { get; set; }
+    public static String category1 { get; set; }
+    public static Boolean editAble { get; set; }
+    // 缁忛攢鍟嗗湪搴撲骇鍝両D
+    public static List<String> orderDetZaikuList = new List<String>();
+    // 浜у搧 ID
+    public static String ESetId { get; set; }
+    public static String idCheck { get; set; }
+    /*****************銈姐兗銉堟檪鍐嶆绱㈡潯浠讹紙鐢婚潰銇嬨倝銇叆鍔涙潯浠躲倰鐒¤銇欍倠銇熴倎锛�******************/
+    private static String accountid = null;
+    public static String accountName { get; set; }
+    // 鏌ョ湅浜у搧
+    // private String[] ProidListAll = new String[]{};
+    // 鐧诲綍鑰呭伐浣滃湴
+    private static String userWorkLocation;
+    // 缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
+    public static String agencyProType { get; set; }
+    public static String sqlagencyProType;
+
+    // add by rentx 2021-3-10
+    public static Boolean hasHos { get; set; }
+    // add by rentx 2021-3-10
+
+    public LexInventoryViewController() {
+        consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
+        editAble = false;
+        categoryOptionList = new List<SelectOption>();
+        category4OptionList = new List<SelectOption>();
+        category5OptionList = new List<SelectOption>();
+        categoryOptionMap = new Map<String, String>();
+        category4OptionMap = new Map<String, String>();
+        category5OptionMap = new Map<String, String>();
+
+        // page
+        // pagesize = Integer.valueof(system.label.orderdetLimitsize);
+        // currentpage = 0;
+    }
+    @AuraEnabled
+    public static ResponseBodyLWC init(Integer pageSizeLWC, Integer pageTokenLWC, String sortFieldLWC, String sortOrderLWC) {
+        pageSize = pageSizeLWC;
+        pageToken = pageTokenLWC;
+        sortField = sortFieldLWC;
+        sortOrder = sortOrderLWC;
+
+        ResponseBodyLWC res = new ResponseBodyLWC();
+        Map<String, object> data = new Map<String, object>();
+        res.entity = data;
+
+        categoryOptionMap = new Map<String, String>();
+        category4OptionMap = new Map<String, String>();
+        category5OptionMap = new Map<String, String>();
+
+
+        // 鍙栫敤鎴稩D
+        String userId = UserInfo.getUserId();
+        User useracc = [SELECT Accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
+        accountid = useracc.accountid;
+        userWorkLocation = useracc.Work_Location__c;
+        agencyProType = Useracc.UserPro_Type__c;
+        if (String.isBlank(Useracc.UserPro_Type__c)) {
+            agencyProType = 'ET';
+        }
+        Account accountInfo = [SELECT Name, Dealer_discount__c, Product_Limit_Date__c FROM account WHERE id = :accountid];
+        accountName = accountInfo.Name;
+        // 缁忛攢鍟嗘煡鐪嬩骇鍝�
+        String product_Limit = accountInfo.Product_Limit_Date__c;
+
+        if (product_Limit != null && product_Limit != '') {
+            proLimitAndDate = product_Limit.split(',');
+        }
+
+        List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
+        Map<String, Product2__c> MidMap = new Map<String, Product2__c>();
+        Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+        Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+        // 搴撳瓨鏄庣粏鍙栧緱
+        sqlagencyProType = '%' + agencyProType + '%';
+        orderDetZaikuList = new List<String>();
+        System.debug('sqlagencyProType = ' + sqlagencyProType);
+        System.debug('accountName = ' + accountName);
+        System.debug('userWorkLocation = ' + userWorkLocation);
+        List<AggregateResult> orderDetZaiku = [
+            SELECT count(Id), Consumable_Product__c
+            FROM Consumable_order_details2__c
+            WHERE
+                Dealer_Arrive__c = TRUE
+                AND Dealer_Shipment__c = FALSE
+                AND Dealer_Saled__c = FALSE
+                AND Lose_Flag__c = FALSE
+                AND Dealer_Returned__c = FALSE
+                AND Bar_Code__c != NULL
+                AND Product_Type__c LIKE :sqlagencyProType
+                AND Dealer_Info_text__c = :accountName
+                AND Cancellation_Flag__c = FALSE
+                AND Arrive_Owner_Work_Location__c = :userWorkLocation
+            GROUP BY Consumable_Product__c
+        ];
+
+        for (AggregateResult zaikuId : orderDetZaiku) {
+            orderDetZaikuList.add(String.valueOf(zaikuId.get('Consumable_Product__c')));
+        }
+        System.debug('orderDetZaikuList = ' + orderDetZaikuList);
+        List<Consumable_order_details2__c> CountDel = [
+            SELECT
+                Id,
+                Bar_Code__c,
+                Name,
+                Inventory_date__c,
+                Consumable_Product__c,
+                Recordtypeid,
+                Guarantee_period_for_products__c,
+                Isoverdue__c,
+                Box_Piece__c,
+                hospitalSpecialOffer__c
+            FROM Consumable_order_details2__c
+            WHERE
+                Dealer_Arrive__c = TRUE
+                AND Dealer_Shipment__c = FALSE
+                AND Dealer_Saled__c = FALSE
+                AND Dealer_Returned__c = FALSE
+                AND Lose_Flag__c = FALSE
+                AND Cancellation_Flag__c = FALSE
+                AND Bar_Code__c != NULL
+                AND Product_Type__c LIKE :sqlagencyProType
+                AND Dealer_Info_text__c = :accountName
+                AND Arrive_Owner_Work_Location__c = :userWorkLocation
+        ];
+        System.debug('MidMap = ' + MidMap);
+        System.debug('CountDel111 = ' + CountDel);
+        System.debug('orderDetZaikuList  = ' + orderDetZaikuList);
+        List<Product2__c> product2Selected = [
+            SELECT
+                Id,
+                Name,
+                Name__c,
+                Intra_Trade_List_RMB__c,
+                Asset_Model_No__c,
+                Category3__c,
+                Category4__c,
+                Category5__c,
+                SFDA_Status__c,
+                Product2__r.SFDA_Approbation_No__c,
+                Product2__r.SFDA_Expiration_Date__c,
+                Product2__r.Packing_list_manual__c
+            FROM Product2__c
+            WHERE Id IN :orderDetZaikuList
+        ];
+        System.debug('product2Selected  = ' + product2Selected);
+        for (Integer i = 0; i < product2Selected.size(); i++) {
+            MidMap.put(product2Selected[i].Id, product2Selected[i]);
+        }
+        System.debug('MidMap = ' + MidMap);
+        /////////////////////====================================update by rentx
+        Map<String, ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+        Map<String, ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+        // update by rentx 2021-01-27 start
+        for (Integer i = 0; i < CountDel.size(); i++) {
+            // 鐒跺悗寰幆CountDel鍋欱ox鍜宲iece2涓猰ap
+            if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '鐩�') {
+                String tex = 'A';
+                if (CountDel[i].hospitalSpecialOffer__c) {
+                    tex = 'B';
+                }
+                if (newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
+                    ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)
+                        .clone();
+                    Jstage.allnumber = Jstage.allnumber + 1;
+                    if (CountDel[i].Isoverdue__c == 1) {
+                        Jstage.limitCount = Jstage.limitCount + 1;
+                    }
+                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                    newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                } else {
+                    ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
+                    Jstage.allnumber = Jstage.allnumber + 1;
+                    if (CountDel[i].Isoverdue__c == 1) {
+                        Jstage.limitCount = Jstage.limitCount + 1;
+                    }
+                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                    if (CountDel[i].hospitalSpecialOffer__c) {
+                        Jstage.hospitalSpecialOffer = true;
+                    } else {
+                        Jstage.hospitalSpecialOffer = false;
+                    }
+                    newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                }
+            } else if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '涓�') {
+                String tex = 'A';
+                if (CountDel[i].hospitalSpecialOffer__c) {
+                    tex = 'B';
+                }
+                if (newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
+                    ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
+                            CountDel[i].Consumable_Product__c +
+                            CountDel[i].Box_Piece__c +
+                            tex
+                        )
+                        .clone();
+                    Jstage.allnumber = Jstage.allnumber + 1;
+                    if (CountDel[i].Isoverdue__c == 1) {
+                        Jstage.limitCount = Jstage.limitCount + 1;
+                    }
+                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                    if (CountDel[i].hospitalSpecialOffer__c) {
+                        Jstage.hospitalSpecialOffer = true;
+                    } else {
+                        Jstage.hospitalSpecialOffer = false;
+                    }
+                    newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                } else {
+                    ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
+                    Jstage.allnumber = Jstage.allnumber + 1;
+                    if (CountDel[i].Isoverdue__c == 1) {
+                        Jstage.limitCount = Jstage.limitCount + 1;
+                    }
+                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                    if (CountDel[i].hospitalSpecialOffer__c) {
+                        Jstage.hospitalSpecialOffer = true;
+                    } else {
+                        Jstage.hospitalSpecialOffer = false;
+                    }
+                    newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                }
+            }
+        }
+        consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+        // 鎶夿oxmap閲岀殑鍊间粠鏂拌祴缁檅oxRecords
+        System.debug('newMidBoxMap = ' + newMidBoxMap);
+        for (ConsumableorderdetailsInfo bss : newMidBoxMap.values()) {
+            if (bss.allnumber > 0) {
+                bss.sortBy = false;
+                bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
+                bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+                bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+                bss.overlimitCount = bss.allnumber - bss.limitCount;
+                boxRecords.add(bss);
+            }
+        }
+
+        boxRecords.sort();
+        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+            if (bss.allnumber > 0) {
+                bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
+                bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+                bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+                bss.overlimitCount = bss.allnumber - bss.limitCount;
+            }
+        }
+        for (ConsumableorderdetailsInfo bss : boxRecords) {
+            consumableorderdetailsRecords.add(bss);
+            // 璇ヤ骇鍝佹槸鍖婚櫌鐗逛环浜у搧
+            if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '涓狟')) {
+                if (newMidPieceMap.get(bss.Prod.Id + '涓狟').hospitalSpecialOffer) {
+                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狟'));
+                    newMidPieceMap.remove(bss.Prod.Id + '涓狟');
+                }
+            }
+
+            if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '涓狝')) {
+                // if (newMidPieceMap.get(bss.Prod.Id+'涓狝')) {
+                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狝'));
+                newMidPieceMap.remove(bss.Prod.Id + '涓狝');
+                // }
+            }
+        }
+        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+            if (newMidPieceMap.containsKey(bss.Prod.Id + '涓狟')) {
+                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狟'));
+            }
+        }
+        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+            if (newMidPieceMap.containsKey(bss.Prod.Id + '涓狝')) {
+                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狝'));
+            }
+        }
+        productLimtAndDate();
+        datelimitSearch();
+
+        // add by rentx 2021-3-10 start
+        Integer hosnum = 0;
+        // add by rentx 2021-3-10 end
+        for (ConsumableorderdetailsInfo bss : consumableorderdetailsRecords) {
+            if (productkucun.get(bss.Prod.Id) != null) {
+                bss.guaranteeperiod = productkucun.get(bss.Prod.Id);
+            }
+
+            // add by rentx 2021-3-10 start
+            if (bss.hospitalSpecialOffer) {
+                hosnum = hosnum + 1;
+            }
+        }
+        if (hosnum > 0) {
+            hasHos = true;
+        } else {
+            hasHos = false;
+        }
+        // add by rentx 2021-3-10 end
+        // listCut();
+
+        AggregateResult[] categoryList = [
+            SELECT Count(id), Category3_text__c c3c
+            FROM Product2__c
+            WHERE Estimation_Entry_Possibility__c = '鈼�' AND Product_Type__c LIKE :agencyProType AND Category3_text__c != NULL
+            GROUP BY Category3_text__c
+        ];
+
+        categoryOptionList = new List<SelectOption>();
+        categoryOptionList.add(new SelectOption('', '-鏃�-'));
+        categoryOptionMap.put('', '-鏃�-');
+        for (AggregateResult category3Search : categoryList) {
+            String deliverycnt = String.valueOf(category3Search.get('c3c'));
+            categoryOptionList.add(new SelectOption(deliverycnt, deliverycnt));
+            categoryOptionMap.put(deliverycnt, deliverycnt);
+        }
+
+        category4OptionList = new List<SelectOption>();
+        category4OptionList.add(new SelectOption('', '-鏃�-'));
+        category4OptionMap.put('', '-鏃�-');
+
+        category5OptionList = new List<SelectOption>();
+        category5OptionList.add(new SelectOption('', '-鏃�-'));
+        category5OptionMap.put('', '-鏃�-');
+        System.debug('categoryOptionList===>' + category4OptionList);
+        System.debug('category4OptionList===>' + category4OptionList);
+        System.debug('category5OptionList===>' + category4OptionList);
+
+        //// 鎬讳欢鏁�
+        totalcount = consumableorderdetailsRecords.size();
+        //// 椤垫暟
+        // pagecount = (totalcount  +  pagesize  - 1) / pagesize;
+
+        //// 鏄剧ず绗竴椤�
+
+        // moveToFirst();
+        makeCurrentPageRecords();
+        // data.put('categoryOptionList',categoryOptionList);
+        PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+        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;
+
+        data.put('paginatedAccounts', paginatedAccounts);
+
+        data.put('categoryOptionMap', categoryOptionMap);
+        data.put('category4OptionMap', category4OptionMap);
+        data.put('category5OptionMap', category5OptionMap);
+
+        data.put('agencyProType', agencyProType);
+        data.put('orderDetZaikuList', orderDetZaikuList);
+        data.put('accountid', accountid);
+        data.put('accountName', accountName);
+        data.put('sqlagencyProType', accountName);
+        data.put('userWorkLocation', userWorkLocation);
+        data.put('agencyProType', agencyProType);
+        data.put('pageRecords', pageRecords);
+        data.put('consumableorderdetailsRecords', consumableorderdetailsRecords);
+        data.put('hasHos', hasHos);
+        data.put('productLimtAndDate',proLimitAndDate);
+        res.status = 'Success';
+        res.code = 200;
+        System.debug('res = ' + res);
+        return res;
+    }
+    @AuraEnabled
+    public static ResponseBodyLWC categoryAllload(String category3LWC,String agencyProTypeLWC) {
+        ResponseBodyLWC res = new ResponseBodyLWC();
+        Map<String, object> data = new Map<String, object>();
+        res.entity = data;
+        category3 =  category3LWC;
+        agencyProType =  '%' + agencyProTypeLWC + '%';
+
+        System.debug('category3LWC===>'+category3LWC);
+        System.debug('agencyProType===>'+agencyProType);
+        
+        AggregateResult[] category4List = [
+            SELECT Count(id), Category4_text__c c4c
+            FROM Product2__c
+            WHERE
+                Estimation_Entry_Possibility__c = '鈼�'
+                AND Category3_text__c = :category3
+                AND Product_Type__c LIKE :agencyProType
+                AND Category4_text__c != NULL
+                AND Category5_text__c != NULL
+            GROUP BY Category4_text__c
+        ];
+        category4OptionList = new List<SelectOption>();
+        category4OptionList.add(new SelectOption('', '-鏃�-'));
+        category4OptionMap = new Map<String, String>();
+        category4OptionMap.put('', '-鏃�-');
+
+        for (AggregateResult category4Search : category4List) {
+            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
+            category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
+            category4OptionMap.put(deliverycnt4, deliverycnt4);
+        }
+
+        AggregateResult[] category5List = [
+            SELECT Count(id), Category5_text__c c5c
+            FROM Product2__c
+            WHERE
+                Estimation_Entry_Possibility__c = '鈼�'
+                AND Category3_text__c = :category3
+                AND Product_Type__c LIKE :agencyProType
+                AND Category4_text__c != NULL
+                AND Category5_text__c != NULL
+            GROUP BY Category5_text__c
+        ];
+
+        category5OptionList = new List<SelectOption>();
+        category5OptionList.add(new SelectOption('', '-鏃�-'));
+        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);
+        }
+        System.debug('绫诲埆4'+category4OptionList);
+        System.debug('绫诲埆5'+category5OptionList);
+        data.put('category4OptionMap', category4OptionMap);
+        data.put('category5OptionMap', category5OptionMap);
+        res.status = 'Success';
+        res.code = 200;
+        System.debug('res = ' + res);
+        return res;
+    }
+
+    public static void categoryload() {
+        AggregateResult[] category4List = [
+            SELECT Count(id), Category4_text__c c4c
+            FROM Product2__c
+            WHERE
+                Estimation_Entry_Possibility__c = '鈼�'
+                AND Category3_text__c = :category3
+                AND Product_Type__c LIKE :agencyProType
+                AND Category4_text__c != NULL
+                AND Category5_text__c != NULL
+            GROUP BY Category4_text__c
+        ];
+        category4OptionList = new List<SelectOption>();
+        category4OptionList.add(new SelectOption('', '-鏃�-'));
+        for (AggregateResult category4Search : category4List) {
+            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
+            category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
+        }
+
+        AggregateResult[] category5List = [
+            SELECT Count(id), Category5_text__c c5c
+            FROM Product2__c
+            WHERE
+                Estimation_Entry_Possibility__c = '鈼�'
+                AND Category3_text__c = :category3
+                AND Product_Type__c LIKE :agencyProType
+                AND Category4_text__c = :category4
+                AND Category5_text__c != NULL
+            GROUP BY Category5_text__c
+        ];
+
+        category5OptionList = new List<SelectOption>();
+        category5OptionList.add(new SelectOption('', '-鏃�-'));
+        for (AggregateResult category5Search : category5List) {
+            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
+            category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
+        }
+    }
+    // 妫�绱�
+    @AuraEnabled
+    public static ResponseBodyLWC searchConsumableorderdetails(
+        String category1,
+        String Category3,
+        String Category4,
+        String Category5,
+        List<String> orderDetZaikuListLWC,
+        String accountName,
+        string agencyProType,
+        string userWorkLocation,
+        Integer pageSizeLWC,
+        Integer pageTokenLWC,
+        String sortFieldLWC,
+        String sortOrderLWC
+    ) {
+        try {
+            System.debug('orderDetZaikuListLWC===>'+orderDetZaikuListLWC);
+            pageSize = pageSizeLWC;
+            pageToken = pageTokenLWC;
+            sortField = sortFieldLWC;
+            sortOrder = sortOrderLWC;
+            orderDetZaikuList = new List<String>();
+
+            orderDetZaikuList = orderDetZaikuListLWC;
+            sqlagencyProType = '%' + agencyProType + '%';
+            ResponseBodyLWC res = new ResponseBodyLWC();
+            Map<String, object> data = new Map<String, object>();
+            res.entity = data;
+            System.debug('====>accountName' + accountName);
+            System.debug('====>sqlagencyProType' + sqlagencyProType);
+            System.debug('====>userWorkLocation' + userWorkLocation);
+            System.debug('====>category1' + category1);
+            System.debug('====>Category3' + Category3);
+            System.debug('====>Category4' + Category4);
+            System.debug('====>Category5' + Category5);
+            // sortKey = '2';
+            // preSortKey = '2';
+            // sortOrderAsc = false;
+            // sortOrder = new List<String>(8);
+            // sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '鈫�' };
+
+            List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
+            List<Consumable_order_details2__c> CountDel = [
+                SELECT
+                    Id,
+                    Bar_Code__c,
+                    Name,
+                    Inventory_date__c,
+                    Consumable_Product__c,
+                    Recordtypeid,
+                    Guarantee_period_for_products__c,
+                    Isoverdue__c,
+                    Box_Piece__c,
+                    hospitalSpecialOffer__c
+                FROM Consumable_order_details2__c
+                WHERE
+                    Dealer_Arrive__c = TRUE
+                    AND Dealer_Shipment__c = FALSE
+                    AND Dealer_Saled__c = FALSE
+                    AND Dealer_Returned__c = FALSE
+                    AND Lose_Flag__c = FALSE
+                    AND Cancellation_Flag__c = FALSE
+                    AND Bar_Code__c != NULL
+                    AND Product_Type__c LIKE :sqlagencyProType
+                    AND Dealer_Info_text__c = :accountName
+                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
+            ];
+            System.debug('CountDel = ' + CountDel);
+
+            List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
+            Map<String, Product2__c> MidMap = new Map<String, Product2__c>();
+            Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+            Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+
+            // 鎵�鏈変骇鍝佸彇寰�
+            String soql = makeSoql(category1, category_Goods, category3, category4, category5);
+            //orderDetZaikuList
+            System.debug('orderDetZaikuList = ' + orderDetZaikuList);
+            System.debug('accountName = ' + accountName);
+            System.debug('soql====>' + soql);
+            //鎺掑簭
+            // if (String.isNotBlank(sortField) && String.isNotBlank(sortOrder)) {
+            //     if(sortFieldLWC != 'limitCount'){
+            //         soql += ' ORDER BY ' + sortField + ' ' + sortOrder;
+                    
+            //     }
+            // }
+            System.debug('soql = ' + soql);
+            //soql += ' ORDER BY ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last');
+            List<Product2__c> queryList = Database.query(soql);
+            System.debug('queryList = ' + queryList);
+
+            for (Integer i = 0; i < queryList.size(); i++) {
+                MidMap.put(queryList[i].Id, queryList[i]);
+            }
+            System.debug('MidMap = ' + MidMap);
+            Map<String, ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+            Map<String, ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+            System.debug('CountDel = ' + CountDel);
+            for (Integer i = 0; i < CountDel.size(); i++) {
+                //鐒跺悗寰幆CountDel鍋欱ox鍜宲iece2涓猰ap
+                if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '鐩�') {
+                    String tex = 'A';
+                    if (CountDel[i].hospitalSpecialOffer__c) {
+                        tex = 'B';
+                    }
+                    if (newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
+                        ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(
+                                CountDel[i].Consumable_Product__c +
+                                CountDel[i].Box_Piece__c +
+                                tex
+                            )
+                            .clone();
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
+                            Jstage.limitCount = Jstage.limitCount + 1;
+                        }
+                        Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                        newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                    } else {
+                        ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
+                            Jstage.limitCount = Jstage.limitCount + 1;
+                        }
+                        Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                        if (CountDel[i].hospitalSpecialOffer__c) {
+                            Jstage.hospitalSpecialOffer = true;
+                        } else {
+                            Jstage.hospitalSpecialOffer = false;
+                        }
+                        newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                    }
+                } else if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '涓�') {
+                    String tex = 'A';
+                    if (CountDel[i].hospitalSpecialOffer__c) {
+                        tex = 'B';
+                    }
+                    if (newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
+                        ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
+                                CountDel[i].Consumable_Product__c +
+                                CountDel[i].Box_Piece__c +
+                                tex
+                            )
+                            .clone();
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
+                            Jstage.limitCount = Jstage.limitCount + 1;
+                        }
+                        Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                        if (CountDel[i].hospitalSpecialOffer__c) {
+                            Jstage.hospitalSpecialOffer = true;
+                        } else {
+                            Jstage.hospitalSpecialOffer = false;
+                        }
+                        newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                    } else {
+                        ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
+                            Jstage.limitCount = Jstage.limitCount + 1;
+                        }
+                        Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+                        if (CountDel[i].hospitalSpecialOffer__c) {
+                            Jstage.hospitalSpecialOffer = true;
+                        } else {
+                            Jstage.hospitalSpecialOffer = false;
+                        }
+                        newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                    }
+                }
+            }
+
+            consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+            System.debug('newMidBoxMap = ' + newMidBoxMap);
+            //鎶夿oxmap閲岀殑鍊间粠鏂拌祴缁檅oxRecords
+            for (ConsumableorderdetailsInfo bss : newMidBoxMap.values()) {
+                if (bss.allnumber > 0) {
+                    bss.sortBy = false;
+                    bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
+                    bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+                    bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+                    bss.overlimitCount = bss.allnumber - bss.limitCount;
+                    boxRecords.add(bss);
+                }
+            }
+
+            boxRecords.sort();
+            for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+                if (bss.allnumber > 0) {
+                    bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
+                    bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+                    bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+                    bss.overlimitCount = bss.allnumber - bss.limitCount;
+                }
+            }
+            System.debug('boxRecords = ' + boxRecords);
+            for (ConsumableorderdetailsInfo bss : boxRecords) {
+                consumableorderdetailsRecords.add(bss);
+                //璇ヤ骇鍝佹槸鍖婚櫌鐗逛环浜у搧
+                if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '涓狟')) {
+                    if (newMidPieceMap.get(bss.Prod.Id + '涓狟').hospitalSpecialOffer) {
+                        consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狟'));
+                        newMidPieceMap.remove(bss.Prod.Id + '涓狟');
+                    }
+                }
+
+                if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '涓狝')) {
+                    // if (newMidPieceMap.get(bss.Prod.Id+'涓狝')) {
+                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狝'));
+                    newMidPieceMap.remove(bss.Prod.Id + '涓狝');
+                    // }
+                }
+            }
+            for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+                if (newMidPieceMap.containsKey(bss.Prod.Id + '涓狟')) {
+                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狟'));
+                }
+            }
+            for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+                if (newMidPieceMap.containsKey(bss.Prod.Id + '涓狝')) {
+                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狝'));
+                }
+            }
+
+            productLimtAndDate();
+            datelimitSearch();
+            System.debug('consumableorderdetailsRecords zzz = ' + consumableorderdetailsRecords);
+            for (ConsumableorderdetailsInfo bss : consumableorderdetailsRecords) {
+                if (productkucun.get(bss.Prod.Id) != null) {
+                    bss.guaranteeperiod = productkucun.get(bss.Prod.Id);
+                }
+            }
+            //listCut();
+
+            // sortKey = '2';
+            // preSortKey = '2';
+            // sortOrderAsc = false;
+            // sortOrder = new List<String>(8);
+            // sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '鈫�' };
+
+            // //鎬讳欢鏁�
+            totalcount = consumableorderdetailsRecords.size();
+            // //椤垫暟
+            // pagecount=(totalcount  +  pagesize  - 1) / pagesize;
+
+            //鏄剧ず绗竴椤�
+            //currentpage = 0;
+            //moveToFirst();
+            makeCurrentPageRecords();
+            PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+            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;
+
+            List<ConsumableorderdetailsInfo> pageRecordsCompare = new List<ConsumableorderdetailsInfo>(); 
+            System.debug('queryList = ' + JSON.serialize(queryList));
+            for (Integer i = 0; i < queryList.size(); i++) {
+                for(ConsumableorderdetailsInfo ci : pageRecords){
+                    if(queryList[i].Id == ci.Prod.Id){
+                        System.debug('queryList[i].Id =' + queryList[i].Id);
+                        System.debug('ci.Prod.Id =' + queryList[i].Id);
+                        pageRecordsCompare.add(ci);
+                    }
+                }
+            }
+            data.put('paginatedAccounts', paginatedAccounts);
+            data.put('accountid', accountid);
+            data.put('userWorkLocation', userWorkLocation);
+            data.put('agencyProType', agencyProType);
+            data.put('pageRecords', pageRecordsCompare);
+            data.put('hasHos', hasHos);
+            system.debug('===========>pageRecords' + pageRecordsCompare);
+            system.debug('===========>data' + data);
+            if (pageRecords.isEmpty()) {
+                res.msg = '鏈悳绱㈠埌鐩稿叧娑堣�楀搧璁㈠崟锛�';
+                res.status = 'fail';
+                res.code = 500;
+            } else {
+                res.status = 'Success';
+                res.msg = '鍏辨湁' + pageRecords.size() + '鏉℃暟鎹�';
+                res.code = 200;
+                System.debug('res = ' + res);
+            }
+            return res;
+        } catch (Exception e) {
+            return new ResponseBodyLWC('Error', 500, e.getStackTraceString(), '');
+        }
+    }
+
+    public static void productLimtAndDate() {
+        String nowName = null, nowRightAsstModelNo = null;
+        Map<String, String> productLimt = new Map<String, String>();
+        for (Integer i = 0; i < proLimitAndDate.size(); i++) {
+            nowName = proLimitAndDate[i];
+            if (nowName.indexOf('|') >= 0) {
+                nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
+                nowName = nowName.subString(nowName.indexOf('|') + 1);
+            }
+            productLimt.put(nowRightAsstModelNo, nowName);
+        }
+        for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+            if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
+                ass.lowerlimit = decimal.valueOf(
+                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|'))
+                );
+                ass.upperlimit = decimal.valueOf(
+                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1)
+                );
+            }
+        }
+    }
+
+    public static void datelimitSearch() {
+        List<String> barcodekucun = new List<String>();
+        List<Consumable_order_details2__c> orderkucun = [
+            SELECT Id, Bar_Code__c, Name, Consumable_Product__c, Recordtypeid, Guarantee_period_for_products__c, Sterilization_limit__c
+            FROM Consumable_order_details2__c
+            WHERE
+                Dealer_Arrive__c = TRUE
+                AND Dealer_Shipment__c = FALSE
+                AND Dealer_Saled__c = FALSE
+                AND Dealer_Returned__c = FALSE
+                AND Lose_Flag__c = FALSE
+                AND Bar_Code__c != NULL
+                AND Product_Type__c LIKE :sqlagencyProType
+                AND Dealer_Info_text__c = :accountName
+                AND Arrive_Owner_Work_Location__c = :userWorkLocation
+            ORDER BY Consumable_Product__c, Sterilization_limit__c ASC
+        ];
+        for (Integer i = 0; i < orderkucun.size(); i++) {
+            if (productkucun.containsKey(orderkucun[i].Consumable_Product__c)) {
+                continue;
+            } else {
+                productkucun.put(orderkucun[i].Consumable_Product__c, orderkucun[i].Sterilization_limit__c);
+            }
+        }
+    }
+
+    //鍚嶇О鎺掑簭
+    // public static void SortLimited() {
+    //     Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
+    //     Map<String, ConsumableorderdetailsInfo> newMap = new Map<String, ConsumableorderdetailsInfo>();
+    //     if (sortKey == preSortKey) {
+    //         // 鏂瑰悜銇屽銈忋倠銇伩
+    //         sortOrderAsc = !sortOrderAsc;
+    //         sortOrder[Integer.valueOf(sortKey)] = (sortOrderAsc == true ? '鈫�' : '鈫�');
+    //     } else {
+    //         sortOrderAsc = true;
+    //         sortOrder[Integer.valueOf(preSortKey)] = ' ';
+    //         sortOrder[Integer.valueOf(sortKey)] = (sortOrderAsc == true ? '鈫�' : '鈫�');
+    //     }
+
+    //     preSortKey = sortKey;
+    //     // 鎵�鏈変骇鍝佸彇寰�
+    //     String soql = makeSoql(null, null, null, null, null);
+    //     soql += ' ORDER BY ' + columus[Integer.valueOf(sortKey)] + ' ' + (sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last');
+    //     List<Product2__c> queryList = Database.query(soql);
+    //     for (Integer i = 0; i < queryList.size(); i++) {
+    //         MidMap.put(queryList[i].Id + '鐩�', null);
+    //         MidMap.put(queryList[i].Id + '涓�', null);
+    //     }
+
+    //     //update by rentx 2020-12-29
+    //     for (Integer i = 0; i < pageRecords.size(); i++) {
+    //         if (MidMap.containsKey(pageRecords[i].prod.Id + pageRecords[i].BoxPiece)) {
+    //             ConsumableorderdetailsInfo Jstage = pageRecords[i].clone();
+    //             if (Jstage.hospitalSpecialOffer == true) {
+    //                 newMap.put(pageRecords[i].prod.id + pageRecords[i].BoxPiece, Jstage);
+    //             } else {
+    //                 MidMap.put(pageRecords[i].prod.id + pageRecords[i].BoxPiece, Jstage);
+    //             }
+    //         }
+    //     }
+
+    //     pageRecords = new List<ConsumableorderdetailsInfo>();
+
+    //     //update byr entx 2020-12-29
+    //     //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機pageRecords
+    //     for (ConsumableorderdetailsInfo bss : MidMap.values()) {
+    //         if (bss != null) {
+    //             pageRecords.add(bss);
+    //             if (newMap.get(bss.Prod.Id + bss.BoxPiece) != null) {
+    //                 pageRecords.add(newMap.get(bss.Prod.Id + bss.BoxPiece));
+    //                 newMap.remove(bss.Prod.Id + bss.BoxPiece);
+    //             }
+    //         }
+    //     }
+    //     for (ConsumableorderdetailsInfo bss : newMap.values()) {
+    //         if (bss != null) {
+    //             pageRecords.add(bss);
+    //         }
+    //     }
+    // }
+
+    //搴撳瓨鎺掑簭
+    // public static void SortStore() {
+    //     if (sortKey == preSortKey) {
+    //         // 鏂瑰悜銇屽銈忋倠銇伩
+    //         sortOrder = !sortOrder;
+    //         sortOrder[Integer.valueOf(sortKey)] = (sortOrderAsc == true ? '鈫�' : '鈫�');
+    //     } else {
+    //         sortOrderAsc = true;
+    //         sortOrder[Integer.valueOf(preSortKey)] = ' ';
+    //         sortOrder[Integer.valueOf(sortKey)] = (sortOrderAsc == true ? '鈫�' : '鈫�');
+    //     }
+    //     preSortKey = sortKey;
+
+    //     for (ConsumableorderdetailsInfo ass : pageRecords) {
+    //         ass.sortBy = sortOrderAsc;
+    //     }
+    //     pageRecords.sort();
+    // }
+  
+
+    //妫�绱ql鏂囧仛鎴�
+    private static String makeSoql(String CateName, String CateCode, String Category3, String Category4, String Category5) {
+        System.debug('orderDetZaikuList = ' + orderDetZaikuList);
+        String sqlTail = '(\'';
+        for (Integer i = 0; i < orderDetZaikuList.size(); i++) {
+            if (i < orderDetZaikuList.size() - 1) {
+                sqlTail += orderDetZaikuList[i] + '\',\'';
+            } else {
+                sqlTail += orderDetZaikuList[i] + '\')';
+            }
+        }
+        String soql = 'select Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Category3__c,Category4__c,Category5__c,';
+        soql += ' SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c FROM Product2__c ';
+        soql += ' WHERE Id in' + sqlTail;
+        if (!String.isBlank(CateName)) {
+            soql +=
+                ' AND (Name__c like \'%' +
+                String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
+                '%\' or Asset_Model_No__c like \'%' +
+                String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
+                '%\')';
+        }
+        if (!String.isBlank(Category3)) {
+            soql += ' AND Category3__c = \'' + Category3 + '\'';
+        }
+        if (!String.isBlank(Category4)) {
+            soql += ' AND Category4__c = \'' + Category4 + '\'';
+        }
+        if (!String.isBlank(Category5)) {
+            soql += ' AND Category5__c = \'' + Category5 + '\'';
+        }
+        return soql;
+    }
+    //棣栭〉
+    // public static void moveToFirst() {
+    //     if (currentpage == 1)
+    //         return;
+    //     currentpage = 1;
+    //     canMove();
+    // }
+
+    // //灏鹃〉
+    // public static void moveToLast() {
+    //     if (currentpage >= pagecount)
+    //         return;
+    //     currentpage = pagecount;
+    //     canMove();
+    // }
+
+    // //涓婁竴椤�
+    // public static void moveToPrevious() {
+    //     if (currentpage == 1)
+    //         return;
+    //     currentpage = currentpage - 1;
+    //     canMove();
+    // }
+
+    // //涓嬩竴椤�
+    // public static void moveToNext() {
+    //     if (currentpage >= pagecount)
+    //         return;
+
+    //     currentpage = currentpage + 1;
+    //     canMove();
+    // }
+
+    // //鍒ゆ柇鏄惁鍙炕椤�
+    // public static void canMove() {
+    //     hasPrevious = false;
+    //     hasNext = false;
+    //     if (pagecount > 1 && currentpage > 1)
+    //         hasPrevious = true;
+    //     if (pagecount > 1 && currentpage < pagecount)
+    //         hasNext = true;
+    // }
+
+    //鍒锋柊褰撳墠椤�
+    // public static PageReference refreshPageSize() {
+    //     makeCurrentPageRecords();
+    //     return null;
+    // }
+
+    //缂栬緫褰撳墠椤靛唴瀹�
+    public static void makeCurrentPageRecords() {
+        // pageRecords = new List<ConsumableorderdetailsInfo>();
+        // System.debug('consumableorderdetailsRecords  =' + consumableorderdetailsRecords);
+        // for (Integer i = 0; i < consumableorderdetailsRecords.size(); i++) {
+        //     pageRecords.add(consumableorderdetailsRecords.get(i));
+        // }
+
+        Integer startIdx;
+        Integer endIdx;
+        pageRecords = new List<ConsumableorderdetailsInfo>();
+        startIdx = pageToken;
+        endIdx = pageToken + pageSize;
+        if (endIdx > consumableorderdetailsRecords.size()) {
+            endIdx = consumableorderdetailsRecords.size();
+        }
+        for (Integer i = startIdx; i < endIdx; i++) {
+            pageRecords.add(consumableorderdetailsRecords.get(i));
+        }
+    }
+
+    //鍒嗛〉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; }
+    }
+
+    // Data Bean
+    class ConsumableorderdetailsInfo implements Comparable {
+        @AuraEnabled
+        public Consumable_order_details2__c esd { get; set; }
+        @AuraEnabled
+        public Product2__c Prod { get; set; }
+        @AuraEnabled
+        public Decimal allnumber { get; set; }
+        @AuraEnabled
+        public Integer packing_list { get; set; }
+        @AuraEnabled
+        public Date expiration_Date { get; set; }
+        @AuraEnabled
+        public String approbation_No { get; set; }
+        @AuraEnabled
+        public Consumable_order__c Concc { get; set; }
+        @AuraEnabled
+        public Boolean sortBy { get; set; }
+        @AuraEnabled
+        public Decimal upperlimit { get; set; }
+        @AuraEnabled
+        public Decimal lowerlimit { get; set; }
+        @AuraEnabled
+        public String BoxPiece { get; set; }
+        @AuraEnabled
+        public Date guaranteeperiod { get; set; }
+        @AuraEnabled
+        public Decimal limitCount { get; set; }
+        @AuraEnabled
+        public Decimal overlimitCount { get; set; }
+        @AuraEnabled
+        public Boolean hospitalSpecialOffer { get; set; }
+
+        public ConsumableorderdetailsInfo(Product2__c e) {
+            esd = new Consumable_order_details2__c();
+            Prod = e;
+            allnumber = 0;
+            limitCount = 0;
+            overlimitCount = 0;
+        }
+        // 鎺掑簭
+        public Integer compareTo(Object compareTo) {
+            ConsumableorderdetailsInfo compareToesd = (ConsumableorderdetailsInfo) compareTo;
+            Integer returnValue = 0;
+            if (sortBy == false) {
+                if (allnumber > compareToesd.allnumber) {
+                    returnValue = -1;
+                } else if (allnumber < compareToesd.allnumber) {
+                    returnValue = 1;
+                }
+                return returnValue;
+            } else {
+                if (allnumber > compareToesd.allnumber) {
+                    returnValue = 1;
+                } else if (allnumber < compareToesd.allnumber) {
+                    returnValue = -1;
+                }
+                return returnValue;
+            }
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1