buli
2023-05-04 d4a4ce824f3b2f3a335a3ad8e8c9efb3b37d630f
backup

backup
18个文件已修改
4个文件已添加
10399 ■■■■■ 已修改文件
force-app/main/default/classes/ArriveGoodsController.cls 2025 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/CPL003Rest.cls 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/DNUpsertBatch.cls 476 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/DNUpsertBatchTest.cls 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InventoryViewController.cls 265 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexArriveGoodsController.cls 389 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexArriveGoodsController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexSummonsCreatController.cls 692 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LogAutoSendBatch.cls 256 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OCSMHandler.cls 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/updateESignBatch.cls 979 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/updateESignBatchTest.cls 620 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/customOutputGoods.html 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/customReturnGoodInput.html 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/customShipmentNumber.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/lexCustomLightningDatatable.js 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.html 1238 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.js 2014 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/paginatedList/paginatedList.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/paginatedList/paginatedList.js 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/summonsCreat.page 1234 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest/packageForSign.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/ArriveGoodsController.cls
@@ -26,7 +26,7 @@
    //超出定货数量的产品
    public List<String> cancellationProList = new List<String>();
    //错误信息
    public String alertMessage {set;get;}
    public String alertMessage { get; set; }
    public integer getinventorysize(){
        return consumableInventory.size();
    }
@@ -51,20 +51,19 @@
    Map<String, Decimal> overOrderCunMap = new Map<String, Decimal>();
    //超出BARCODE和型号
    Map<String, List<String>> overOrderBARcodeCunMap = new Map<String, List<String>>();
    list<String> overOrderBARcodeTTTTTT = new list<String>();
    list<String> overOrderBARcodeTTTTTT = new List<String>();
    //不符合的barcode和型号
    Map<String, List<String>> notEqualBARcodeCunMap = new Map<String, List<String>>();
    list<String> overOrderBARcodeSSSSSS = new list<String>();
    list<String> productList = new list<String>();
    list<String> notInlist = new list<String>();
    list<String> overOrderBARcodeSSSSSS = new List<String>();
    list<String> productList = new List<String>();
    list<String> notInlist = new List<String>();
    //不选择订单时保存订单ID、产品型号用
    //List<String> orderId = new List<String>();
    //List<String> prodName = new List<String>();
    //库存登录使用
    list<String> notInStorelist = new list<String>();
    list<String> exitBarCodeList = new list<String>();
    list<String> notInStorelist = new List<String>();
    list<String> exitBarCodeList = new List<String>();
    // Map<String, Consumable_order_details2__c> reallMap = new Map<String, Consumable_order_details2__c>();
    Map<String,String> HosErrorMap = new Map<String,String>();
@@ -104,7 +103,7 @@
        consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
        orderdetails2trMap = new Map<String,Consumable_order_details2__c>();
        detailsSummary = new List<ConsumableorderdetailsInfo>();
        saveFLGbln = FALSE;
        saveFLGbln = false;
        //overOrderBARcodeTTTTTT.add('');
        //add by rentx 20210602 CHAN-C3K4ZQ start 
        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
@@ -169,7 +168,7 @@
    public void init() {
        // String userId = '00510000007cthP';
        String userId = UserInfo.getUserId();
        List<user> Useracc = New List<user>();
        List<user> Useracc = new List<user>();
        Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:userId];
        accountid = Useracc[0].accountid;
        //--------AddStart-----XHL--------------20181008-------------
@@ -199,27 +198,40 @@
            ReturnFLGbln = false;
        }
        if(ESetId != '' && ESetId !=null){
            List<Consumable_order__c> qs = New List<Consumable_order__c>();
            List<Consumable_order_details2__c> reSet1 = New List<Consumable_order_details2__c>();
            List<Consumable_Orderdetails__c> reSet = New List<Consumable_Orderdetails__c>();
            qs = [SELECT Id,Name,Order_status__c,Dealer_Info__c,Deliver_date__c,ReturnGs_Upload_Date__c,
                        Order_Reason__c,Order_date__c,
                        Contract_application_decision__c,Order_type__c,Total_num__c,
                        OrderNumber_arrived__c,Delivery_detail_count__c,OrderNumber_notarrive__c,orderPattern__c
            List<Consumable_order__c> qs = new List<Consumable_order__c>();
            List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
            List<Consumable_Orderdetails__c> reSet = new List<Consumable_Orderdetails__c>();
            qs = [
                SELECT
                    Id,
                    Name,
                    Order_status__c,
                    Dealer_Info__c,
                    Deliver_date__c,
                    ReturnGs_Upload_Date__c,
                    Order_Reason__c,
                    Order_date__c,
                    Contract_application_decision__c,
                    Order_type__c,
                    Total_num__c,
                    OrderNumber_arrived__c,
                    Delivery_detail_count__c,
                    OrderNumber_notarrive__c,
                    orderPattern__c
                    FROM Consumable_order__c
                    WHERE Id =:ESetId AND Order_Owner_WorkLocal__c =: userWorkLocation
                    AND Dealer_Info__c = :accountid];
                WHERE Id = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation AND Dealer_Info__c = :accountid
            ];
            if (qs.size()>0){
                coc = qs[0];
                orderCountAll = coc.Total_num__c;
                orderCountNotarrive = coc.OrderNumber_notarrive__c;
            }
            //产品定货数量
            reSet = [SELECT Asset_Model_No__c,
                            Consumable_order__c,
                            Consumable_count__c
            reSet = [
                SELECT Asset_Model_No__c, Consumable_order__c, Consumable_count__c
                        FROM Consumable_Orderdetails__c
                        WHERE Consumable_order__c = :ESetId AND Order_Owner_WorkLocal__c =: userWorkLocation];
                WHERE Consumable_order__c = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation
            ];
            for (Integer i = 0; i < reSet.size(); i++) {
                productList.add(reSet[i].Asset_Model_No__c);
                orderProductCunMap.put(reSet[i].Asset_Model_No__c,reSet[i].Consumable_count__c);
@@ -230,7 +242,9 @@
                //overOrderCunMap.put(reSet[i].Asset_Model_No__c,0);
            }
            //
            reSet1 = [SELECT Id,
            reSet1 = [
                SELECT
                    Id,
                            Name,
                            Intra_Trade_List_RMB__c,
                            Asset_Model_No__c,
@@ -251,26 +265,31 @@
                            Rrturn_count__c,
                            ProductPacking_list_manual__c,
                            Report_Product_Approbation__c,
                            Report_Product_Expiration__c
                    Report_Product_Expiration__c,
                            //add by rentx 2020-10-14 start
                            ,ContractNo_text__c/*,ContractNo__c1*/
                    ContractNo_text__c /*,ContractNo__c1*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                    Consumable_order_minor__r.ContractNo__c
                            // tcm end
                            //add by rentx 2020-10-14 end
                        FROM Consumable_order_details2__c
                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                WHERE
                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Arrive_Owner_Work_Location__c = : userWorkLocation
                        AND Consumable_order_minor__c = :ESetId
                        AND Dealer_Arrive__c = true
                        AND Box_Piece__c != '个' ];
                    AND Dealer_Arrive__c = TRUE
                    AND Box_Piece__c != '个'
            ];
            for (Integer i = 0; i < reSet1.size(); i++) {
                // OrderAllMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
                //init的时候不展示已经入库的明细 by rentx 20210617 CHAN-C3K4ZQ
                // ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet1[i]));
                //update by rentx 20210617 end CHAN-C3K4ZQ
                if(orderProductArrivedCunMap.containsKey(reSet1[i].Asset_Model_No__c)){
                   orderProductArrivedCunMap.put(reSet1[i].Asset_Model_No__c,orderProductArrivedCunMap.get(reSet1[i].Asset_Model_No__c)+1);
                    orderProductArrivedCunMap.put(
                        reSet1[i].Asset_Model_No__c,
                        orderProductArrivedCunMap.get(reSet1[i].Asset_Model_No__c) + 1
                    );
                }
            }
            //add by rentx 20210602 start CHAN-C3K4ZQ
@@ -282,7 +301,7 @@
    // 将页面或取得BarCode去掉重复的,转换成List
    //========20160311======ADD_Start================================
    public List<String> ParseBarCode(String Code){
        String[] Cache = new String[]{};
        String[] Cache = new List<String>{};
        Cache = Code.split('\n');
        Set <String> Buff = new Set<String>();
        for(String A : Cache){
@@ -296,15 +315,15 @@
               barMcodeMap.put(B,tracingCode);
            }
            outPut.add(B);
        }system.debug('barMcodeMap等于'+barMcodeMap);
        }
        system.debug('barMcodeMap等于' + barMcodeMap);
        return outPut;
    }
    //========20160311======ADD_End==================================
    //获取明细
    public void SearchPro() {
        notInlist = new list<String>();
        notInlist = new List<String>();
        otherAgencyMap = new Map<String, String>();
        barMcodeMap = new Map<String, String>();
        consumableInventory = new List<ConsumableorderdetailsInfo>();
@@ -378,7 +397,7 @@
        BarCodeListP = new List<String>();
        BarCodeListP = ParseBarCode(barcode);
        Consumable_order_details2__c p = new Consumable_order_details2__c();
        List<Consumable_order_details2__c> Ins = New List<Consumable_order_details2__c>();
        List<Consumable_order_details2__c> Ins = new List<Consumable_order_details2__c>();
        List<Consumable_order_details2__c> reSet = new List<Consumable_order_details2__c>();
        List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
        if(barcode == null || barcode.trim() ==''){
@@ -386,19 +405,22 @@
            return;
        }
        //对比全部库存中是否存在管理编码一样,barcode号不一样的产品
        reSet1 = [SELECT Id,  Name,TracingCode__c,Bar_Code__c,Report_Product_Expiration__c
        reSet1 = [
            SELECT Id, Name, TracingCode__c, Bar_Code__c, Report_Product_Expiration__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 Cancellation_Flag__c = false
                    AND TracingCode__c in :barMcodeMap.values()
                    AND Bar_Code__c not in :barMcodeMap.keySet()
            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 Cancellation_Flag__c = FALSE
                AND TracingCode__c IN :barMcodeMap.values()
                AND Bar_Code__c NOT IN :barMcodeMap.keySet()
                    AND Dealer_Info_text__c = :accountName
                    AND Arrive_Owner_Work_Location__c =: userWorkLocation
                    ORDER BY Name ];
            ORDER BY Name
        ];
        if(reSet1.size()>0){
            for (Integer i = 0; i < reSet1.size(); i++) {
                if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -407,7 +429,12 @@
                }else{
                    for(String str : barMcodeMap.keySet()){
                        if(barMcodeMap.get(str) == reSet1[i].TracingCode__c){
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, str + ' 的管理编码已经存在于系统的库存中,请确认输入信息是否有误。'));
                            ApexPages.addmessage(
                                new ApexPages.message(
                                    ApexPages.severity.ERROR,
                                    str + ' 的管理编码已经存在于系统的库存中,请确认输入信息是否有误。'
                                )
                            );
                            ErrorIdMap.put(str,str);
                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
                        }
@@ -416,18 +443,32 @@
            }
        }
        //管理编码为空的产品
        reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                        Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                        Deliver_date__c,Bar_Code__c,Box_Piece__c,
                        Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                        TracingCode__c,Report_Product_Expiration__c
        reSet1 = [
            SELECT
                Id,
                Name,
                Consumable_Product__r.Name__c,
                Consumable_Product__c,
                Consumable_Product__r.Name,
                Sterilization_limit__c,
                Deliver_date__c,
                Bar_Code__c,
                Box_Piece__c,
                Arrive_date__c,
                Send_Date__c,
                Consumable_order_minor__r.Name,
                Consumable_order_minor__c,
                TracingCode__c,
                Report_Product_Expiration__c
                    FROM Consumable_order_details2__c
                    WHERE Bar_Code__c in :BarCodeListP
            WHERE
                Bar_Code__c IN :BarCodeListP
                    AND Dealer_Info_text__c = :accountName
                    //AND Arrive_Owner_Work_Location__c =: userWorkLocation
                    AND (TracingCode__c = null
                AND (TracingCode__c = NULL
                         OR TracingCode__c = '')
                    ORDER BY Name ];
            ORDER BY Name
        ];
        if(reSet1.size()>0){
            for (Integer i = 0; i < reSet1.size(); i++) {
@@ -446,28 +487,46 @@
        if(EsetId == null || EsetId == ''){
            if(ArrType!='ReG'){
                //到货但产品类型与用户的类型不符            
                reSet1 = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
                                Consumable_Product__c,Consumable_Product__r.Name,
                                Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
                                Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
                                Consumable_order_minor__c,Dealer_Arrive__c,
                                Guarantee_period_for_products__c,CFDA_Status__c,
                                ProductPacking_list_manual__c,Report_Product_Approbation__c,
                                Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
                                Product_Type__c
                                ,ContractNo_text__c/*,ContractNo__c1*/
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Intra_Trade_List_RMB__c,
                        Asset_Model_No__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Consumable_Product__r.Name__c,
                        Consumable_Product__r.Asset_Model_No__c,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        Dealer_Arrive__c,
                        Guarantee_period_for_products__c,
                        CFDA_Status__c,
                        ProductPacking_list_manual__c,
                        Report_Product_Approbation__c,
                        Report_Product_Expiration__c,
                        Box_Piece__c,
                        Rrturn_count__c,
                        Product_Type__c,
                        ContractNo_text__c /*,ContractNo__c1*/,
                                // tcm start
                                ,Consumable_order_minor__r.ContractNo__c
                        Consumable_order_minor__r.ContractNo__c
                                // tcm end
                        FROM Consumable_order_details2__c
                        WHERE Bar_Code__c in :BarCodeListP
                        AND ( not Product_Type__c  like :userPro_Typestr)
                    WHERE
                        Bar_Code__c IN :BarCodeListP
                        AND (NOT Product_Type__c LIKE :userPro_Typestr)
                        AND Dealer_Info_text__c = :accountName
                        AND ((Consumable_order_minor__c != null
                        AND ((Consumable_order_minor__c != NULL
                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) 
                            OR Consumable_order_minor__c = null)
                        ORDER BY Name ];
                        OR Consumable_order_minor__c = NULL)
                    ORDER BY Name
                ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
@@ -482,19 +541,35 @@
                    }
                }
                //销售产品
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,OwnerId,Report_Product_Expiration__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Box_Piece__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                        OwnerId,
                        Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Saled__c = true
                            AND  Dealer_Returned__c = false
                            AND  Bar_Code__c in :BarCodeListP
                    WHERE
                        Dealer_Saled__c = TRUE
                        AND Dealer_Returned__c = FALSE
                        AND Bar_Code__c IN :BarCodeListP
                            AND Dealer_Info_text__c = :accountName
                            AND (Arrive_Owner_Work_Location__c =: userWorkLocation
                                OR OwnerId = :System.Label.User_OlympusSystem)
                            ORDER BY Name ];
                    ORDER BY Name
                ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -509,23 +584,37 @@
                            }
                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
                        }
                    }
                }
                //出库产品
               reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Box_Piece__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                        Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Shipment__c = true
                            AND  Dealer_Returned__c = false
                            AND  Bar_Code__c in :BarCodeListP
                    WHERE
                        Dealer_Shipment__c = TRUE
                        AND Dealer_Returned__c = FALSE
                        AND Bar_Code__c IN :BarCodeListP
                            AND Dealer_Info_text__c = :accountName
                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
                            ORDER BY Name ];
                    ORDER BY Name
                ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -539,18 +628,34 @@
                    }
                }
                //已到货产品
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Lose_Flag__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Lose_Flag__c,
                        Box_Piece__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                        Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = true
                            AND  Dealer_Returned__c = false
                            AND  Bar_Code__c in :BarCodeListP
                    WHERE
                        Dealer_Arrive__c = TRUE
                        AND Dealer_Returned__c = FALSE
                        AND Bar_Code__c IN :BarCodeListP
                            AND Dealer_Info_text__c = :accountName
                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
                            ORDER BY Name ];
                    ORDER BY Name
                ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -558,7 +663,7 @@
                            continue;
                        }else{
                            String str = '该商品已经到货';
                            if (reSet1[i].Lose_Flag__c == TRUE) {
                            if (reSet1[i].Lose_Flag__c == true) {
                                str = '该商品已经丢失';
                            }
                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
@@ -568,19 +673,34 @@
                }
                //已拆盒产品
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Box_Piece__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                        Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = true
                            AND  Bar_Code__c in :BarCodeListP
                    WHERE
                        Dealer_Arrive__c = TRUE
                        AND Bar_Code__c IN :BarCodeListP
                            AND (Dealer_Info_text__c != :accountName
                                OR (Dealer_Info_text__c = :accountName
                                    AND Arrive_Owner_Work_Location__c !=: userWorkLocation))
                            AND Box_Piece__c = '个'
                            ORDER BY Name ];
                    ORDER BY Name
                ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -595,47 +715,75 @@
                }
                // 经销商之间或者同一经销商不同工作地调货
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,Asset_Model_No__c, Arrive_Owner_Work_Location__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,Box_Piece__c,
                                Deliver_date__c,Bar_Code__c,TracingCode__c, Dealer_Info_text__c, OwnerId, Lose_Flag__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,SerialLotNo__c, Dealer_Arrive__c,
                                Consumable_Arrived_order__r.Dealer_Info__c, Consumable_Arrived_order__r.Dealer_Info__r.Name,
                                Intra_Trade_List_RMB__c, Dealer_Shipment__c, Dealer_Saled__c,Consumable_Product__r.Asset_Model_No__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        Asset_Model_No__c,
                        Arrive_Owner_Work_Location__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Box_Piece__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        TracingCode__c,
                        Dealer_Info_text__c,
                        OwnerId,
                        Lose_Flag__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                        SerialLotNo__c,
                        Dealer_Arrive__c,
                        Consumable_Arrived_order__r.Dealer_Info__c,
                        Consumable_Arrived_order__r.Dealer_Info__r.Name,
                        Intra_Trade_List_RMB__c,
                        Dealer_Shipment__c,
                        Dealer_Saled__c,
                        Consumable_Product__r.Asset_Model_No__c,
                                // 更新借调信息 add by gzw 2020-0-415 start
                                ,SummonsForDirction_det__c,Transfer_Time__c,Frist_Transfer_Agency__c,Agency_Transfer__c
                        SummonsForDirction_det__c,
                        Transfer_Time__c,
                        Frist_Transfer_Agency__c,
                        Agency_Transfer__c,
                                // 更新借调信息 add by gzw 2020-0-415 start
                                // 首次入库经销商信息 add by gzw 2020-04-27 start
                                ,Agencyinfo_fromSAP__c,Frist_Storage_Agency__c
                        Agencyinfo_fromSAP__c,
                        Frist_Storage_Agency__c,
                                // 首次入库经销商信息 add by gzw 2020-04-27 end
                                //add by rentx 2020-10-13 start 互相调货时,借入方记录SAP合同号
                                ,ContractNo_text__c/*,ContractNo__c */
                        ContractNo_text__c /*,ContractNo__c */,
                                // tcm start
                                ,Consumable_order_minor__r.ContractNo__c
                        Consumable_order_minor__r.ContractNo__c,
                                // tcm end
                                //add by rentx 2020-10-13 end
                                //add by rentx 2021-03-22 start
                                ,hospitalSpecialOffer__c
                                ,exchangeOutPattern__c
                                ,Report_Product_Expiration__c
                        hospitalSpecialOffer__c,
                        exchangeOutPattern__c,
                        Report_Product_Expiration__c
                                //add by rentx 2021-03-22 end
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = TRUE
                    WHERE
                        Dealer_Arrive__c = TRUE
                            //AND  Dealer_Shipment__c= false
                            //AND  Dealer_Saled__c = FALSE
                            AND  Dealer_Returned__c = FALSE
                            AND  Cancellation_Flag__c = FALSE
                            AND  Bar_Code__c in :BarCodeListP
                        AND Bar_Code__c IN :BarCodeListP
                            //AND (Dealer_Shipment__c = FALSE 
                            //        OR (Dealer_Shipment__c = TRUE 
                            //            AND Consumable_Shipment_order__r.SummonsForDirction__c != '互相调货'))
                            AND (Dealer_Info_text__c != :accountName 
                                OR (Dealer_Info_text__c = :accountName 
                                    AND Arrive_Owner_Work_Location__c != :userWorkLocation)
                            )
                        AND Arrive_Owner_Work_Location__c != :userWorkLocation))
                            // 更新借调信息 add by gzw 2020-0-415 start
                            order by Bar_Code__c, Transfer_Time__c desc
                    ORDER BY Bar_Code__c, Transfer_Time__c DESC
                            // 更新借调信息 add by gzw 2020-0-415 end
                            ];
                if(reSet1.size()>0){
@@ -653,13 +801,15 @@
                                barcodedetList.add(String.valueOf(reSet1[i].Sterilization_limit__c));
                                barcodedetList.add(reSet1[i].SerialLotNo__c);
                                barcodedetList.add(reSet1[i].TracingCode__c);
                                if (reSet1[i].Lose_Flag__c == false
                                if (reSet1[i].Lose_Flag__c == false) {
                                    //&& reSet1[i].Dealer_Info_text__c == accountName
                                     ) {
                                    consumableorderdetails2Cancle.add(reSet1[i]);
                                }
                                // 更新借调信息 add by gzw 2020-0-415 start
                                if (reSet1[i].SummonsForDirction_det__c == '互相调货' && !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)) {
                                if (
                                    reSet1[i].SummonsForDirction_det__c == '互相调货' &&
                                    !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)
                                ) {
                                    orderdetails2trMap.put(reSet1[i].Bar_Code__c, reSet1[i]);
                                }
                                // 更新借调信息 add by gzw 2020-0-415 end
@@ -667,8 +817,7 @@
                                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
                                codsIns.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                                codsIns.Intra_Trade_List_RMB__c     = reSet1[i].Intra_Trade_List_RMB__c;
                                //gzw 手动入库 默认产品单价 20230307
                                codsIns.Intra_Trade_List_RMB__c = null;
                                codsIns.Asset_Model_No__c           = reSet1[i].Asset_Model_No__c;
                                codsIns.Direct_Arrive_Product__c    = true;
                                codsIns.Sterilization_limit__c      = reSet1[i].Sterilization_limit__c;
@@ -678,7 +827,9 @@
                                codsIns.TracingCode__c              = reSet1[i].TracingCode__c;
                                // 更新借调信息 add by gzw 2020-0-415 start
                                codsIns.Transfer_Time__c            = reSet1[i].Transfer_Time__c == null? 1 : reSet1[i].Transfer_Time__c;
                                codsIns.Frist_Transfer_Agency__c    = reSet1[i].Frist_Transfer_Agency__c == null ? reSet1[i].Dealer_Info_text__c : reSet1[i].Frist_Transfer_Agency__c;
                                codsIns.Frist_Transfer_Agency__c = reSet1[i].Frist_Transfer_Agency__c == null
                                    ? reSet1[i].Dealer_Info_text__c
                                    : reSet1[i].Frist_Transfer_Agency__c;
                                codsIns.Agency_Transfer__c          = true;
                                // 更新借调信息 add by gzw 2020-0-415 end
                                 
@@ -715,44 +866,68 @@
                }
                 //发错库 未到货
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,Asset_Model_No__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,TracingCode__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,SerialLotNo__c,Dealer_Arrive__c,
                                Dealer_Shipment__c, Dealer_Saled__c,Consumable_Product__r.Asset_Model_No__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        Asset_Model_No__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        TracingCode__c,
                        Box_Piece__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                        SerialLotNo__c,
                        Dealer_Arrive__c,
                        Dealer_Shipment__c,
                        Dealer_Saled__c,
                        Consumable_Product__r.Asset_Model_No__c,
                                // 更新借调信息 add by gzw 2020-0-415 start
                                ,SummonsForDirction_det__c,Transfer_Time__c,Frist_Transfer_Agency__c,Agency_Transfer__c,
                                Dealer_Info_text__c,Intra_Trade_List_RMB__c
                        SummonsForDirction_det__c,
                        Transfer_Time__c,
                        Frist_Transfer_Agency__c,
                        Agency_Transfer__c,
                        Dealer_Info_text__c,
                                // 更新借调信息 add by gzw 2020-0-415 start
                                // 首次入库经销商信息 add by gzw 2020-04-27 start
                                ,Agencyinfo_fromSAP__c,Frist_Storage_Agency__c
                        Agencyinfo_fromSAP__c,
                        Frist_Storage_Agency__c,
                                // 首次入库经销商信息 add by gzw 2020-04-27 end
                                //add by rentx 2020-10-13 start 互相调货时,借入方记录SAP合同号
                                ,ContractNo_text__c/*,ContractNo__c*/
                        ContractNo_text__c /*,ContractNo__c*/,
                                // tcm start
                                ,Consumable_order_minor__r.ContractNo__c
                        Consumable_order_minor__r.ContractNo__c,
                                // tcm end
                                //add by rentx 2020-10-13 end   互相调货时,借入方记录SAP合同号
                                ,hospitalSpecialOffer__c
                                ,exchangeOutPattern__c
                                ,Lose_Flag__c,Report_Product_Expiration__c
                        hospitalSpecialOffer__c,
                        exchangeOutPattern__c,
                        Lose_Flag__c,
                        Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = FALSE
                    WHERE
                        Dealer_Arrive__c = FALSE
                            AND  Dealer_Shipment__c= FALSE
                            AND  Dealer_Saled__c = FALSE
                            //AND  Cancellation_Flag__c = FALSE
                            AND  Bar_Code__c in :BarCodeListP
                        AND Bar_Code__c IN :BarCodeListP
                            AND  (Dealer_Info_text__c != :accountName
                                OR (Dealer_Info_text__c = :accountName 
                                    AND ((Consumable_order_minor__c != null
                        AND ((Consumable_order_minor__c != NULL
                                            AND (Consumable_order_minor__r.Order_Owner_WorkLocal__c != :userWorkLocation
                                                OR (Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
                                                    AND Cancellation_Flag__c = TRUE)))
                                        OR (Consumable_order_minor__c = null AND Cancellation_Flag__c = TRUE)))
                            )
                        OR (Consumable_order_minor__c = NULL
                        AND Cancellation_Flag__c = TRUE))))
                            // 更新借调信息 add by gzw 2020-0-415 start
                            order by Bar_Code__c, Transfer_Time__c desc
                    ORDER BY Bar_Code__c, Transfer_Time__c DESC
                            // 更新借调信息 add by gzw 2020-0-415 end
                            ];
                if(reSet1.size()>0){
@@ -776,8 +951,10 @@
                                //}
                                // 发错库存时,自动取消 update by gzw 2020-04-15 start
                                // 更新借调信息 add by gzw 2020-0-415 start
                                if (reSet1[i].SummonsForDirction_det__c == '互相调货' && !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)) {
                                if (
                                    reSet1[i].SummonsForDirction_det__c == '互相调货' &&
                                    !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)
                                ) {
                                    orderdetails2trMap.put(reSet1[i].Bar_Code__c, reSet1[i]);
                                }
                                // 更新借调信息 add by gzw 2020-0-415 end
@@ -785,8 +962,7 @@
                                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
                                codsIns.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                                codsIns.Intra_Trade_List_RMB__c     = reSet1[i].Intra_Trade_List_RMB__c;
                                //gzw 手动入库 默认产品单价 20230307
                                codsIns.Intra_Trade_List_RMB__c = null;
                                codsIns.Asset_Model_No__c           = reSet1[i].Asset_Model_No__c;
                                codsIns.Direct_Arrive_Product__c    = true;
                                codsIns.Sterilization_limit__c      = reSet1[i].Sterilization_limit__c;
@@ -832,30 +1008,48 @@
            }else{
                //返品检查
                //到货但产品类型与用户的类型不符            
                reSet1 = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
                                Consumable_Product__c,Consumable_Product__r.Name,
                                Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
                                Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
                                Consumable_order_minor__c,Dealer_Arrive__c,
                                Guarantee_period_for_products__c,CFDA_Status__c,
                                ProductPacking_list_manual__c,Report_Product_Approbation__c,
                                Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
                                Product_Type__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Intra_Trade_List_RMB__c,
                        Asset_Model_No__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Consumable_Product__r.Name__c,
                        Consumable_Product__r.Asset_Model_No__c,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        Dealer_Arrive__c,
                        Guarantee_period_for_products__c,
                        CFDA_Status__c,
                        ProductPacking_list_manual__c,
                        Report_Product_Approbation__c,
                        Report_Product_Expiration__c,
                        Box_Piece__c,
                        Rrturn_count__c,
                        Product_Type__c,
                                //add by rentx 2020-10-14 start
                                ,ContractNo_text__c/*,ContractNo__c*/
                        ContractNo_text__c /*,ContractNo__c*/,
                                // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                        Consumable_order_minor__r.ContractNo__c
                            // tcm end
                                //add by rentx 2020-10-14 end
                        FROM Consumable_order_details2__c
                        WHERE Bar_Code__c in :BarCodeListP
                        AND ( not Product_Type__c  like :userPro_Typestr)
                    WHERE
                        Bar_Code__c IN :BarCodeListP
                        AND (NOT Product_Type__c LIKE :userPro_Typestr)
                        AND Dealer_Info_text__c = :accountName
                        AND ((Consumable_order_minor__c != null
                        AND ((Consumable_order_minor__c != NULL
                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) 
                            OR Consumable_order_minor__c = null)
                        ORDER BY Name ];
                        OR Consumable_order_minor__c = NULL)
                    ORDER BY Name
                ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
@@ -869,26 +1063,40 @@
                        }
                    }
                }
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                            Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                            Deliver_date__c,Bar_Code__c,Box_Piece__c,
                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                            recordtypeid,Consumable_order_minor__r.Arrive_Order__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Box_Piece__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                            //add by rentx 2020-10-14 start
                            ,ContractNo_text__c/*,ContractNo__c*/
                        ContractNo_text__c /*,ContractNo__c*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                        Consumable_order_minor__r.ContractNo__c,
                            // tcm end
                            ,Report_Product_Expiration__c
                        Report_Product_Expiration__c
                            //add by rentx 2020-10-14 end
                        FROM Consumable_order_details2__c
                        WHERE Dealer_Arrive__c = FALSE
                    WHERE
                        Dealer_Arrive__c = FALSE
                        AND  Dealer_Shipment__c= FALSE
                        AND  Dealer_Saled__c = FALSE
                        AND  Dealer_Returned__c = false
                        AND  Bar_Code__c in :BarCodeListP
                        AND Dealer_Returned__c = FALSE
                        AND Bar_Code__c IN :BarCodeListP
                        AND Dealer_Info_text__c = :accountName
                        ORDER BY Name ];//没到货
                    ORDER BY Name
                ]; //没到货
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -901,24 +1109,39 @@
                        }
                    }
                }
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,ToDueDateDays__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Lose_Flag__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Consumable_Product__r.Name__c,
                        ToDueDateDays__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Lose_Flag__c,
                        Box_Piece__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        recordtypeid,
                        Consumable_order_minor__r.Arrive_Order__c,
                                //add by rentx 2020-10-14 start
                                ,ContractNo_text__c/*,ContractNo__c*/
                        ContractNo_text__c /*,ContractNo__c*/,
                                // tcm start
                                ,Consumable_order_minor__r.ContractNo__c
                        Consumable_order_minor__r.ContractNo__c,
                                // tcm end
                                , Report_Product_Expiration__c
                        Report_Product_Expiration__c
                                //add by rentx 2020-10-14 end
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = true
                    WHERE
                        Dealer_Arrive__c = TRUE
                            AND  Dealer_Shipment__c= FALSE
                            AND  Dealer_Saled__c = FALSE
                            AND  Bar_Code__c in :BarCodeListP
                            AND  Dealer_Returned__c = false
                        AND Bar_Code__c IN :BarCodeListP
                        AND Dealer_Returned__c = FALSE
                            // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                            //AND  Lose_Flag__c = FALSE
                            // AND  Lose_Flag__c = FALSE
@@ -929,14 +1152,14 @@
                            // Gzw 20201215修复,拆盒产品不判断
                            AND Box_Piece__c = '盒'
                            // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                            ORDER BY Name ];//没出库,没销售,就是在库
                    ORDER BY Name
                ]; //没出库,没销售,就是在库
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
                            // 跳过已经处理的消耗品明细
                            continue;
                        }else{
                            // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                            // String str = '该商品在库';
                            // if (reSet1[i].Lose_Flag__c) {
@@ -947,7 +1170,12 @@
                                str = '该商品在库';//没出库 ,没销售,没丢失就是在库。
                            }
                            if(reSet1[i].Lose_Flag__c == true && reSet1[i].ToDueDateDays__c >= 0){
                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '产品'+reSet1[i].Consumable_Product__r.Name+'存在丢失记录'));//如果丢失产品就给提示。
                                ApexPages.addmessage(
                                    new ApexPages.message(
                                        ApexPages.severity.WARNING,
                                        '产品' + reSet1[i].Consumable_Product__r.Name + '存在丢失记录'
                                    )
                                ); //如果丢失产品就给提示。
                            }
                            if (reSet1[i].Lose_Flag__c == true && reSet1[i].ToDueDateDays__c < 0) {
                                str = '过期已销存产品,不允许返品';
@@ -964,11 +1192,10 @@
                }
            }
            //到货正确信息
            reSet = [SELECT Id,
            reSet = [
                SELECT
                    Id,
                            Name,
                            Intra_Trade_List_RMB__c,
                            Asset_Model_No__c,
@@ -996,30 +1223,31 @@
                            TracingCode__c,
                            Agencyinfo_fromSAP__c,
                            Frist_Storage_Agency__c,
                            Dealer_Info_text__c
                    Dealer_Info_text__c,
                            //add by rentx 2020-10-14 start
                            ,ContractNo_text__c/*,ContractNo__c*/
                    ContractNo_text__c /*,ContractNo__c*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                    Consumable_order_minor__r.ContractNo__c
                            // tcm end
                            //add by rentx 2020-10-14 end
                        FROM Consumable_order_details2__c
                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Cancellation_Date__c = null
                        AND Dealer_Arrive__c = false
                        AND Product_Type__c like :userPro_Typestr
                        AND Bar_Code__c in :BarCodeListP
                WHERE
                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                    AND Cancellation_Date__c = NULL
                    AND Dealer_Arrive__c = FALSE
                    AND Product_Type__c LIKE :userPro_Typestr
                    AND Bar_Code__c IN :BarCodeListP
                        AND Dealer_Info_text__c = :accountName
                        AND ((Consumable_order_minor__c != null
                    AND ((Consumable_order_minor__c != NULL
                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) 
                            OR Consumable_order_minor__c = null)
                        ORDER BY Name ];
                    OR Consumable_order_minor__c = NULL)
                ORDER BY Name
            ];
            if(reSet.size()>0){
                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'ErrorIdMap+++ '+ ErrorIdMap.keyset()));
                Map<String,String> errorMap = new Map<String,String>();
                for (Integer i = 0; i < reSet.size(); i++) {
                    if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)){
                        // 跳过已经处理的消耗品明细
                        continue;
@@ -1056,7 +1284,9 @@
                }
            }
            //barcode不一致,管理编码一致
            reSet = [SELECT Id,
            reSet = [
                SELECT
                    Id,
                            Name,
                            Intra_Trade_List_RMB__c,
                            Asset_Model_No__c,
@@ -1079,28 +1309,32 @@
                            Report_Product_Expiration__c,
                            Box_Piece__c,
                            Rrturn_count__c,
                            TracingCode__c
                            ,Agencyinfo_fromSAP__c
                            ,Frist_Storage_Agency__c
                    TracingCode__c,
                    Agencyinfo_fromSAP__c,
                    Frist_Storage_Agency__c,
                            //add by rentx 2020-10-14 start
                            ,ContractNo_text__c/*,ContractNo__c */
                    ContractNo_text__c /*,ContractNo__c */,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                    Consumable_order_minor__r.ContractNo__c
                            // tcm end
                            //add by rentx 2020-10-14 end
                        FROM Consumable_order_details2__c
                       WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                WHERE
                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Dealer_Info_text__c = :accountName
                        //update by rentx 2021-01-04 start CHAN-BWX3XW
                        // AND Consumable_order_minor__c != null
                        // AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
                        AND ((Consumable_order_minor__c != null AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) OR Consumable_order_minor__c = null)
                    AND ((Consumable_order_minor__c != NULL
                    AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
                    OR Consumable_order_minor__c = NULL)
                        //update by rentx 2021-01-04 end CHAN-BWX3XW
                        AND Dealer_Arrive__c = false
                        AND Cancellation_Date__c = null
                        AND TracingCode__c in :barMcodeMap.values()
                        AND Bar_Code__c not in :barMcodeMap.keySet()
                        ORDER BY Name ];
                    AND Dealer_Arrive__c = FALSE
                    AND Cancellation_Date__c = NULL
                    AND TracingCode__c IN :barMcodeMap.values()
                    AND Bar_Code__c NOT IN :barMcodeMap.keySet()
                ORDER BY Name
            ];
            if(reSet.size()>0){
                for (Integer i = 0; i < reSet.size(); i++) {
@@ -1121,7 +1355,9 @@
                            if(reSet[i].Bar_Code__c != str && reSet[i].TracingCode__c == barMcodeMap.get(str)){
                                // 20220815 ljh SWAG-CH65B7 start
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'此管理编码与实际发货BarCode不一致,请核对管理编码('+ str +')的入库及库存数据。'));
                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'条形码为('+ str +')的入库数据与发货数据不一致'));
                                ApexPages.addmessage(
                                    new ApexPages.message(ApexPages.severity.WARNING, '条形码为(' + str + ')的入库数据与发货数据不一致')
                                );
                                // 20220815 ljh SWAG-CH65B7 end
                            }
                            if(barMcodeMap.get(str) == reSet[i].TracingCode__c){
@@ -1137,18 +1373,20 @@
                }
            }
            // CHAN-BD43NK 关闭直接返品功能  追加 barcode不一致判断
            reSet1 = [SELECT Id,Name,TracingCode__c,Bar_Code__c,Sale_orderName__c,Report_Product_Expiration__c
            reSet1 = [
                SELECT Id, Name, TracingCode__c, Bar_Code__c, Sale_orderName__c, Report_Product_Expiration__c
                        FROM Consumable_order_details2__c
                        WHERE Dealer_Arrive__c = true
                        AND (Dealer_Shipment__c = true
                            OR Dealer_Saled__c = true)
                        AND TracingCode__c in :barMcodeMap.values()
                        AND Bar_Code__c not in :barMcodeMap.keySet()
                WHERE
                    Dealer_Arrive__c = TRUE
                    AND (Dealer_Shipment__c = TRUE
                    OR Dealer_Saled__c = TRUE)
                    AND TracingCode__c IN :barMcodeMap.values()
                    AND Bar_Code__c NOT IN :barMcodeMap.keySet()
                        AND Dealer_Info_text__c = :accountName
                        AND Arrive_Owner_Work_Location__c =: userWorkLocation
                        ORDER BY Name ];
                ORDER BY Name
            ];
            if(reSet1.size()>0){
                for (Integer i = 0; i < reSet1.size(); i++) {
                    if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -1157,7 +1395,16 @@
                    }else{
                        for(String str : barMcodeMap.keySet()){
                            if(barMcodeMap.get(str) == reSet1[i].TracingCode__c){
                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'barcode' +str + '与出库单' + reSet1[i].Sale_orderName__c + ' 中的管理编码一致,但Barcode不同,请确认具体数据。'));
                                ApexPages.addmessage(
                                    new ApexPages.message(
                                        ApexPages.severity.ERROR,
                                        'barcode' +
                                            str +
                                            '与出库单' +
                                            reSet1[i].Sale_orderName__c +
                                            ' 中的管理编码一致,但Barcode不同,请确认具体数据。'
                                    )
                                );
                                ErrorIdMap.put(str,str);
                                ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
                            }
@@ -1201,7 +1448,12 @@
                        return;
                    }
                }else{
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号'+ notInlist + '不存在,无对应的出库单,请先操作产品入库。'));
                    ApexPages.addmessage(
                        new ApexPages.message(
                            ApexPages.severity.ERROR,
                            'BarCode号' + notInlist + '不存在,无对应的出库单,请先操作产品入库。'
                        )
                    );
                    return;
                }
            }
@@ -1210,27 +1462,40 @@
        if (HosErrorList.size() > 0) {
            for (String str : HosErrorList) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号:' + str + HosErrorMap.get(str)+''));
            }
        }
        //add by rentx 2021-01-27 end
        }else{
                //已取消产品
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
            reSet1 = [
                SELECT
                    Id,
                    Name,
                    Consumable_Product__r.Name__c,
                    Consumable_Product__c,
                    Consumable_Product__r.Name,
                    Sterilization_limit__c,
                    Deliver_date__c,
                    Bar_Code__c,
                    Box_Piece__c,
                    Arrive_date__c,
                    Send_Date__c,
                    Consumable_order_minor__r.Name,
                    Consumable_order_minor__c,
                    recordtypeid,
                    Consumable_order_minor__r.Arrive_Order__c,
                    Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = FALSE
                WHERE
                    Dealer_Arrive__c = FALSE
                            AND  Dealer_Shipment__c= FALSE
                            AND  Dealer_Saled__c = FALSE
                            AND  Dealer_Returned__c = false
                            AND Cancellation_Date__c != null
                            AND  Bar_Code__c in :BarCodeListP
                    AND Dealer_Returned__c = FALSE
                    AND Cancellation_Date__c != NULL
                    AND Bar_Code__c IN :BarCodeListP
                            AND Dealer_Info_text__c = :accountName
                            ORDER BY Name ];//没到货
                ORDER BY Name
            ]; //没到货
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -1244,18 +1509,33 @@
                    }
                }
                //已经销售
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
            reSet1 = [
                SELECT
                    Id,
                    Name,
                    Consumable_Product__r.Name__c,
                    Consumable_Product__c,
                    Consumable_Product__r.Name,
                    Sterilization_limit__c,
                    Deliver_date__c,
                    Bar_Code__c,
                    Box_Piece__c,
                    Arrive_date__c,
                    Send_Date__c,
                    Consumable_order_minor__r.Name,
                    Consumable_order_minor__c,
                    recordtypeid,
                    Consumable_order_minor__r.Arrive_Order__c,
                    Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Saled__c = true
                            AND  Dealer_Returned__c =false
                WHERE
                    Dealer_Saled__c = TRUE
                    AND Dealer_Returned__c = FALSE
                            AND  Dealer_Info_text__c = :accountName
                            AND  Bar_Code__c in :BarCodeListP
                    AND Bar_Code__c IN :BarCodeListP
                            AND  Arrive_Owner_Work_Location__c =: userWorkLocation 
                            ORDER BY Name ];
                ORDER BY Name
            ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -1269,18 +1549,33 @@
                    }
                }
                //已经出库产品
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
            reSet1 = [
                SELECT
                    Id,
                    Name,
                    Consumable_Product__r.Name__c,
                    Consumable_Product__c,
                    Consumable_Product__r.Name,
                    Sterilization_limit__c,
                    Deliver_date__c,
                    Bar_Code__c,
                    Box_Piece__c,
                    Arrive_date__c,
                    Send_Date__c,
                    Consumable_order_minor__r.Name,
                    Consumable_order_minor__c,
                    recordtypeid,
                    Consumable_order_minor__r.Arrive_Order__c,
                    Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Shipment__c = true
                            AND   Dealer_Returned__c =false
                WHERE
                    Dealer_Shipment__c = TRUE
                    AND Dealer_Returned__c = FALSE
                            AND  Dealer_Info_text__c = :accountName
                            AND  Arrive_Owner_Work_Location__c =: userWorkLocation 
                            AND  Bar_Code__c in :BarCodeListP
                            ORDER BY Name ];
                    AND Bar_Code__c IN :BarCodeListP
                ORDER BY Name
            ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -1294,18 +1589,34 @@
                    }
                }
                //已经到货产品
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Lose_Flag__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
            reSet1 = [
                SELECT
                    Id,
                    Name,
                    Consumable_Product__r.Name__c,
                    Consumable_Product__c,
                    Consumable_Product__r.Name,
                    Sterilization_limit__c,
                    Deliver_date__c,
                    Bar_Code__c,
                    Lose_Flag__c,
                    Box_Piece__c,
                    Arrive_date__c,
                    Send_Date__c,
                    Consumable_order_minor__r.Name,
                    Consumable_order_minor__c,
                    recordtypeid,
                    Consumable_order_minor__r.Arrive_Order__c,
                    Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = true
                            AND   Dealer_Returned__c =false
                            AND  Bar_Code__c in :BarCodeListP
                WHERE
                    Dealer_Arrive__c = TRUE
                    AND Dealer_Returned__c = FALSE
                    AND Bar_Code__c IN :BarCodeListP
                            AND Dealer_Info_text__c = :accountName
                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
                            ORDER BY Name ];
                ORDER BY Name
            ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -1313,7 +1624,7 @@
                            continue;
                        }else{
                            String str = '该商品已经到货';
                            if (reSet1[i].Lose_Flag__c == TRUE) {
                        if (reSet1[i].Lose_Flag__c == true) {
                                str = '该商品已经丢失';
                            }
                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
@@ -1322,16 +1633,29 @@
                    }
                }
                //不属于本订单
                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
            reSet1 = [
                SELECT
                    Id,
                    Name,
                    Consumable_Product__r.Name__c,
                    Consumable_Product__c,
                    Consumable_Product__r.Name,
                    Sterilization_limit__c,
                    Deliver_date__c,
                    Bar_Code__c,
                    Box_Piece__c,
                    Arrive_date__c,
                    Send_Date__c,
                    Consumable_order_minor__r.Name,
                    Consumable_order_minor__c,
                    recordtypeid,
                    Consumable_order_minor__r.Arrive_Order__c,
                    Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Consumable_order_minor__c != :ESetId
                            AND  Bar_Code__c in :BarCodeListP
                WHERE Consumable_order_minor__c != :ESetId AND Bar_Code__c IN :BarCodeListP
                            //AND Dealer_Info_text__c = :accountName
                            ORDER BY Name ];
                ORDER BY Name
            ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -1345,30 +1669,48 @@
                    }
                }
            //到货但产品类型与用户的类型不符
                reSet1 = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
                            Consumable_Product__c,Consumable_Product__r.Name,
                            Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
                            Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
                            Consumable_order_minor__c,Dealer_Arrive__c,
                            Guarantee_period_for_products__c,CFDA_Status__c,
                            ProductPacking_list_manual__c,Report_Product_Approbation__c,
                            Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
                            Product_Type__c
                            ,ContractNo_text__c/*,ContractNo__c*/
            reSet1 = [
                SELECT
                    Id,
                    Name,
                    Intra_Trade_List_RMB__c,
                    Asset_Model_No__c,
                    Consumable_Product__c,
                    Consumable_Product__r.Name,
                    Consumable_Product__r.Name__c,
                    Consumable_Product__r.Asset_Model_No__c,
                    Sterilization_limit__c,
                    Deliver_date__c,
                    Bar_Code__c,
                    Arrive_date__c,
                    Send_Date__c,
                    Consumable_order_minor__r.Name,
                    Consumable_order_minor__c,
                    Dealer_Arrive__c,
                    Guarantee_period_for_products__c,
                    CFDA_Status__c,
                    ProductPacking_list_manual__c,
                    Report_Product_Approbation__c,
                    Report_Product_Expiration__c,
                    Box_Piece__c,
                    Rrturn_count__c,
                    Product_Type__c,
                    ContractNo_text__c /*,ContractNo__c*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                    Consumable_order_minor__r.ContractNo__c
                            // tcm end
                        FROM Consumable_order_details2__c
                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                WHERE
                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Dealer_Info_text__c = :accountName
                        AND ( not Product_Type__c  like :userPro_Typestr)
                    AND (NOT Product_Type__c LIKE :userPro_Typestr)
                        AND Consumable_order_minor__c = :ESetId
                        AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
                        AND Dealer_Arrive__c = false
                        AND Cancellation_Date__c = null
                        AND Bar_Code__c in :BarCodeListP
                        ORDER BY Name ];
                    AND Dealer_Arrive__c = FALSE
                    AND Cancellation_Date__c = NULL
                    AND Bar_Code__c IN :BarCodeListP
                ORDER BY Name
            ];
                if(reSet1.size()>0){
                    for (Integer i = 0; i < reSet1.size(); i++) {
                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -1383,33 +1725,51 @@
                }
            //到货正确信息
            reSet = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
                            Consumable_Product__c,Consumable_Product__r.Name,
                            Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
                            Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
                            Consumable_order_minor__c,Dealer_Arrive__c,
                            Guarantee_period_for_products__c,CFDA_Status__c,
                            ProductPacking_list_manual__c,Report_Product_Approbation__c,
                            Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
            reSet = [
                SELECT
                    Id,
                    Name,
                    Intra_Trade_List_RMB__c,
                    Asset_Model_No__c,
                    Consumable_Product__c,
                    Consumable_Product__r.Name,
                    Consumable_Product__r.Name__c,
                    Consumable_Product__r.Asset_Model_No__c,
                    Sterilization_limit__c,
                    Deliver_date__c,
                    Bar_Code__c,
                    Arrive_date__c,
                    Send_Date__c,
                    Consumable_order_minor__r.Name,
                    Consumable_order_minor__c,
                    Dealer_Arrive__c,
                    Guarantee_period_for_products__c,
                    CFDA_Status__c,
                    ProductPacking_list_manual__c,
                    Report_Product_Approbation__c,
                    Report_Product_Expiration__c,
                    Box_Piece__c,
                    Rrturn_count__c,
                            TracingCode__c,
                            Agencyinfo_fromSAP__c,
                            Frist_Storage_Agency__c,
                            Dealer_Info_text__c
                            ,ContractNo_text__c/*,ContractNo__c*/
                    Dealer_Info_text__c,
                    ContractNo_text__c /*,ContractNo__c*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                    Consumable_order_minor__r.ContractNo__c
                            // tcm end
                        FROM Consumable_order_details2__c
                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                WHERE
                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Dealer_Info_text__c = :accountName
                        AND Product_Type__c like :userPro_Typestr
                    AND Product_Type__c LIKE :userPro_Typestr
                        AND Consumable_order_minor__c = :ESetId
                        AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
                        AND Dealer_Arrive__c = false
                        AND Cancellation_Date__c = null
                        AND Bar_Code__c in :BarCodeListP
                        ORDER BY Name ];
                    AND Dealer_Arrive__c = FALSE
                    AND Cancellation_Date__c = NULL
                    AND Bar_Code__c IN :BarCodeListP
                ORDER BY Name
            ];
            if(reSet.size()>0){
                Map<String,String> errorMap = new Map<String,String>();
                for (Integer i = 0; i < reSet.size(); i++) {
@@ -1432,7 +1792,9 @@
            }
            //barcode不一致,管理编码一致
            reSet = [SELECT Id,
            reSet = [
                SELECT
                    Id,
                            Name,
                            Intra_Trade_List_RMB__c,
                            Asset_Model_No__c,
@@ -1455,24 +1817,26 @@
                            ProductPacking_list_manual__c,
                            Report_Product_Approbation__c,
                            Report_Product_Expiration__c,
                            TracingCode__c
                            ,Agencyinfo_fromSAP__c
                            ,Frist_Storage_Agency__c
                            ,ContractNo_text__c/*,ContractNo__c*/
                    TracingCode__c,
                    Agencyinfo_fromSAP__c,
                    Frist_Storage_Agency__c,
                    ContractNo_text__c /*,ContractNo__c*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                    Consumable_order_minor__r.ContractNo__c
                            // tcm end
                        FROM Consumable_order_details2__c
                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Cancellation_Date__c = null
                        AND Dealer_Arrive__c = false
                        AND TracingCode__c in :barMcodeMap.values()
                        AND Bar_Code__c not in :barMcodeMap.keySet()
                WHERE
                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                    AND Cancellation_Date__c = NULL
                    AND Dealer_Arrive__c = FALSE
                    AND TracingCode__c IN :barMcodeMap.values()
                    AND Bar_Code__c NOT IN :barMcodeMap.keySet()
                        AND Dealer_Info_text__c = :accountName
                        AND ((Consumable_order_minor__c != null
                    AND ((Consumable_order_minor__c != NULL
                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
                            OR Consumable_order_minor__c = null)
                        ORDER BY Name ];
                    OR Consumable_order_minor__c = NULL)
                ORDER BY Name
            ];
            if(reSet.size()>0){
                for (Integer i = 0; i < reSet.size(); i++) {
                    if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)){
@@ -1511,7 +1875,6 @@
                else if (coc!= null && coc.orderPattern__c == 'hospitalorder') {
                    HosErrorList.add(BarCodeListP[i]);
                    continue;
                }
                //add by rentx 2021-01-27 end
                else{
@@ -1532,19 +1895,16 @@
        if (HosErrorList.size() > 0) {
            for (String str : HosErrorList) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号:' + str +'是非医院特价产品'));
            }
        }
        //add by rentx 2021-01-27 end
        makeArrivedSummary();
        //add by rentx 20210602 start CHAN-C3K4ZQ
        makeRecordsView(ConsumableorderdetailsRecordsdummy);
        //add by rentx 20210602 end CHAN-C3K4ZQ
    }
    public void inventoryEntryNoESetId (List<String> barCodeList){
        //所有barcode解析到的Jancode
@@ -1570,7 +1930,12 @@
                    //生产日期
                    List<String> janCode = new List<String>();
                    if(barCodeList[i].length() < 16){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!'));
                        ApexPages.addmessage(
                            new ApexPages.message(
                                ApexPages.severity.ERROR,
                                '产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!'
                            )
                        );
                        continue;
                    }else {
                        //if(barCodeList[i].substring(0,2) !='01'){
@@ -1581,13 +1946,17 @@
                        try{
                            Decimal test  = Decimal.valueOf(janCodeMark);
                        }catch(Exception e){
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的janCode错误!'));
                            ApexPages.addmessage(
                                new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')的janCode错误!')
                            );
                            continue;
                        }
                    }
                    if(barCodeList[i].length() >= 22){
                        if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + barCodeList[i] + ')没有管理编码!'));
                            ApexPages.addmessage(
                                new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')没有管理编码!')
                            );
                            continue;
                        }
                        if( barCodeList[i].substring(16,18) =='11'){
@@ -1595,22 +1964,44 @@
                                productDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01' ;
                                productionDate = Date.valueOf(productDateStr);
                            }catch(Exception e){
                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + barCodeList[i] + ')的生产日期' + productDateStr + '错误!'));
                                ApexPages.addmessage(
                                    new ApexPages.message(
                                        ApexPages.severity.ERROR,
                                        '产品BarCode(' + barCodeList[i] + ')的生产日期' + productDateStr + '错误!'
                                    )
                                );
                                continue;
                            }
                            if(barCodeList[i].length() >=32){
                                if( barCodeList[i].substring(24,26) =='17'){
                                    try{
                                        if(barCodeList[i].substring(30,32)=='00'){
                                            expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' + '01' ;
                                            expirationDateStr =
                                                '20' +
                                                barCodeList[i].substring(26, 28) +
                                                '-' +
                                                barCodeList[i].substring(28, 30) +
                                                '-' +
                                                '01';
                                            expirationDate = Date.valueOf(expirationDateStr);
                                            expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                                        }else{
                                            expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' +barCodeList[i].substring(30,32) ;
                                            expirationDateStr =
                                                '20' +
                                                barCodeList[i].substring(26, 28) +
                                                '-' +
                                                barCodeList[i].substring(28, 30) +
                                                '-' +
                                                barCodeList[i].substring(30, 32);
                                        expirationDate = Date.valueOf(expirationDateStr);
                                        }
                                    }catch(Exception e){
                                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                                        ApexPages.addmessage(
                                            new ApexPages.message(
                                                ApexPages.severity.ERROR,
                                                '产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                            )
                                        );
                                        continue;
                                    }
                                    if(barCodeList[i].length() >= 42){
@@ -1625,16 +2016,32 @@
                        }else if(barCodeList[i].substring(16,18) =='17'){
                            try{
                                if(barCodeList[i].substring(22,24)=='00'){
                                    expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01';
                                    expirationDateStr =
                                        '20' +
                                        barCodeList[i].substring(18, 20) +
                                        '-' +
                                        barCodeList[i].substring(20, 22) +
                                        '-01';
                                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品expirationDateStr' + expirationDateStr));
                                    expirationDate = Date.valueOf(expirationDateStr);
                                    expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                                }else{
                                    expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-' +barCodeList[i].substring(22,24);
                                    expirationDateStr =
                                        '20' +
                                        barCodeList[i].substring(18, 20) +
                                        '-' +
                                        barCodeList[i].substring(20, 22) +
                                        '-' +
                                        barCodeList[i].substring(22, 24);
                                    expirationDate = Date.valueOf(expirationDateStr);
                                }
                            }catch(Exception e){
                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                                ApexPages.addmessage(
                                    new ApexPages.message(
                                        ApexPages.severity.ERROR,
                                        '产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                    )
                                );
                                continue;
                            }
                            if(barCodeList[i].length() >= 34){
@@ -1642,24 +2049,33 @@
                                    serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
                                }
                            }
                        }else if(barCodeList[i].length() >= 26){
                            if(barCodeList[i].substring(16,18) =='10' || barCodeList[i].substring(16,18) =='21'){
                                serialNoorLotNo = barCodeList[i].substring(18,barCodeList[i].length() - 8) ;
                            }
                        }
                    }
                    if(barCodeList[i].length() >= 24 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
                    if (
                        barCodeList[i].length() >= 24 &&
                        barCodeList[i].substring(barCodeList[i].length() - 8, barCodeList[i].length() - 5) == '250'
                    ) {
                        if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
                            tracingCode = barCodeList[i].substring(barCodeList[i].length() - 5,barCodeList[i].length());
                            Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
                            if(n.find()){
                                String str = '管理编码不正确,请与管理员确认是否错误。';
                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')管理编码中有数字,请与管理员确认是否错误!'));
                                ApexPages.addmessage(
                                    new ApexPages.message(
                                        ApexPages.severity.ERROR,
                                        '产品BarCode(' + barCodeList[i] + ')管理编码中有数字,请与管理员确认是否错误!'
                                    )
                                );
                                continue;
                            }
                        }else{
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的tracingCode错误!'));
                            ApexPages.addmessage(
                                new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')的tracingCode错误!')
                            );
                            continue;
                        }
                    }
@@ -1682,13 +2098,40 @@
                    Integer jan12 = Integer.valueOf(janCodeMark.substring(11, 12));
                    Integer jan13 = Integer.valueOf(janCodeMark.substring(12, 13));
                    Integer count12 = jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
                    Integer count13 = jan1*3 + jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
                    Integer count12 =
                        jan2 +
                        jan3 * 3 +
                        jan4 +
                        jan5 * 3 +
                        jan6 +
                        jan7 * 3 +
                        jan8 +
                        jan9 * 3 +
                        jan10 +
                        jan11 * 3 +
                        jan12 +
                        jan13 * 3;
                    Integer count13 =
                        jan1 * 3 +
                        jan2 +
                        jan3 * 3 +
                        jan4 +
                        jan5 * 3 +
                        jan6 +
                        jan7 * 3 +
                        jan8 +
                        jan9 * 3 +
                        jan10 +
                        jan11 * 3 +
                        jan12 +
                        jan13 * 3;
                    String frost12  = (String.valueOf(count12)).substring((String.valueOf(count12)).length()-1);
                    String frost13  = (String.valueOf(count13)).substring((String.valueOf(count13)).length()-1);
                    //减去12位个位
                    frost12 = (String.valueOf(10 - Integer.valueOf(frost12))).substring((String.valueOf(10 - Integer.valueOf(frost12))).length()-1);
                    frost13 = (String.valueOf(10 - Integer.valueOf(frost13))).substring((String.valueOf(10 - Integer.valueOf(frost13))).length()-1);
                    frost12 = (String.valueOf(10 - Integer.valueOf(frost12)))
                        .substring((String.valueOf(10 - Integer.valueOf(frost12))).length() - 1);
                    frost13 = (String.valueOf(10 - Integer.valueOf(frost13)))
                        .substring((String.valueOf(10 - Integer.valueOf(frost13))).length() - 1);
                    janCode.add(janCodeMark.substring(1, 13) + frost12);
                    janCode.add(janCodeMark.substring(0, 13) + frost12);
                    janCode.add(janCodeMark.substring(1, 13) + frost13);
@@ -1703,14 +2146,24 @@
                    barcodeinfoMap.put(barCodeList[i], barcodedetList);
                    barCode01List.add(barCodeList[i]);
                }else if(barCodeList[i].substring(0,3) =='241'){
                    if(barCodeList[i].length() > 8 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + barCodeList[i] + ')没有管理编码!'));
                    if (
                        barCodeList[i].length() > 8 &&
                        barCodeList[i].substring(barCodeList[i].length() - 8, barCodeList[i].length() - 5) != '250'
                    ) {
                        ApexPages.addmessage(
                            new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')没有管理编码!')
                        );
                        continue;
                    }
                    List<String> otCodeList = new List<String>();
                    Map<String,String> otCodeMap = new Map<String,String>();
                    if(barCodeList[i].length() < 7){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!'));
                        ApexPages.addmessage(
                            new ApexPages.message(
                                ApexPages.severity.ERROR,
                                '产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!'
                            )
                        );
                        continue;
                    }else if(barCodeList[i].length() == 11){
                        String otCode4 = barCodeList[i].substring(3,7);
@@ -1752,7 +2205,9 @@
                    barOtcodeMap.put(barCodeList[i], otCodeMap);
                    barCode241List.add(barCodeList[i]);
                }else{
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')不符合要求!'));
                    ApexPages.addmessage(
                        new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')不符合要求!')
                    );
                    continue;
                }
            }else{
@@ -1763,11 +2218,21 @@
        //01通过检索产品是否存在
        //-----------XHL--------------UpdateSTART----------------20181010------
        if(alljanCodeList.size() > 0){
            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
                                        Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c
            List<Product2__c> product2InStore = [
                SELECT
                    Id,
                    Name,
                    Name__c,
                    Intra_Trade_List_RMB__c,
                    Asset_Model_No__c,
                    OT_CODE__c,
                    Product2_Jancode__c,
                    Pro2_Dealer_ENG__c,
                    Pro2_Dealer_Object__c
                FROM Product2__c
                WHERE Product2_Jancode__c in :alljanCodeList
                order by SFDA_Expiration_Date__c  desc ] ;
                WHERE Product2_Jancode__c IN :alljanCodeList
                ORDER BY SFDA_Expiration_Date__c DESC
            ];
            if(product2InStore.size() > 0){
                // CHAN-AVSAST
                Map<String,String> rightBar = new Map<String,String>();
@@ -1777,11 +2242,11 @@
                    for(Product2__c produ: product2InStore){
                        if(barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)){
                            cou ++;
                            if(EngFlag == TRUE && produ.Pro2_Dealer_ENG__c == TRUE){
                            if (EngFlag == true && produ.Pro2_Dealer_ENG__c == true) {
                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
                                rightBar.put(bar, bar);
                            }else if(ETFlag == TRUE && produ.Pro2_Dealer_Object__c == TRUE){
                            } else if (ETFlag == true && produ.Pro2_Dealer_Object__c == true) {
                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
                                rightBar.put(bar, bar);
@@ -1789,14 +2254,18 @@
                                errorMap.put(bar, bar);
                            }
                        }
                    }
                    if(cou <= 0 ){
                        notInStorelist.add(bar);
                    }
                }
                if(errorMap.size() > 0){
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号['+ errorMap.values() +']产品类型['+product_Type+']与用户类型['+userPro_Type+']不符'));
                    ApexPages.addmessage(
                        new ApexPages.message(
                            ApexPages.severity.ERROR,
                            'BarCode号[' + errorMap.values() + ']产品类型[' + product_Type + ']与用户类型[' + userPro_Type + ']不符'
                        )
                    );
                }
            }
        }
@@ -1805,13 +2274,21 @@
        if(allotCodeList.size() > 0){
            Map<String,String> errorMap = new Map<String,String>();
            Map<String,String> exitBarCodeMap = new Map<String,String>();
            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
                                Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c
            List<Product2__c> product2InStore = [
                SELECT
                    Id,
                    Name,
                    Name__c,
                    Intra_Trade_List_RMB__c,
                    Asset_Model_No__c,
                    OT_CODE__c,
                    Product2_Jancode__c,
                    Pro2_Dealer_ENG__c,
                    Pro2_Dealer_Object__c
                FROM Product2__c
                WHERE OT_CODE__c in :allotCodeList
                AND (not Product_Type__c like :userPro_Typestr)] ;
                WHERE OT_CODE__c IN :allotCodeList AND (NOT Product_Type__c LIKE :userPro_Typestr)
            ];
            if(product2InStore.size() > 0){
                for(Product2__c produ: product2InStore){
                    for(String bar: barOtcodeMap.keySet() ){
                        if(barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)){
@@ -1822,16 +2299,29 @@
                }
            }
            if(errorMap.size() > 0){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号['+ errorMap.values() +']产品类型['+product_Type+']与用户['+userPro_Type+']类型不符'));
                ApexPages.addmessage(
                    new ApexPages.message(
                        ApexPages.severity.ERROR,
                        'BarCode号[' + errorMap.values() + ']产品类型[' + product_Type + ']与用户[' + userPro_Type + ']类型不符'
                    )
                );
            }
            product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
                                Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c
            product2InStore = [
                SELECT
                    Id,
                    Name,
                    Name__c,
                    Intra_Trade_List_RMB__c,
                    Asset_Model_No__c,
                    OT_CODE__c,
                    Product2_Jancode__c,
                    Pro2_Dealer_ENG__c,
                    Pro2_Dealer_Object__c
                FROM Product2__c
                WHERE OT_CODE__c in :allotCodeList
                AND Product_Type__c like :userPro_Typestr] ;
                WHERE OT_CODE__c IN :allotCodeList AND Product_Type__c LIKE :userPro_Typestr
            ];
            
            if(product2InStore.size() > 0){
                for(Product2__c produ: product2InStore){
                    for(String bar: barOtcodeMap.keySet() ){
                        Date expirationDate = null ;
@@ -1845,34 +2335,67 @@
                                if(bar.length() >= oTcodeLength + 11){
                                    if( bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='11'){
                                        try{
                                            productDateStr = '20' + bar.substring(oTcodeLength + 5,oTcodeLength + 7) + '-' + bar.substring(oTcodeLength + 7,oTcodeLength + 9) + '-01' ;
                                        productDateStr =
                                            '20' +
                                            bar.substring(oTcodeLength + 5, oTcodeLength + 7) +
                                            '-' +
                                            bar.substring(oTcodeLength + 7, oTcodeLength + 9) +
                                            '-01';
                                            productionDate = Date.valueOf(productDateStr);
                                        }catch(Exception e){
                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + bar + ')的生产日期' + productDateStr + '错误!'));
                                        ApexPages.addmessage(
                                            new ApexPages.message(
                                                ApexPages.severity.ERROR,
                                                '产品BarCode(' + bar + ')的生产日期' + productDateStr + '错误!'
                                            )
                                        );
                                            continue;
                                        }
                                        if(bar.length() >=oTcodeLength + 3 + 16){
                                            if( bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='17'){
                                                try{
                                                    if(bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16)=='00'){
                                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' + '01' ;
                                                    expirationDateStr =
                                                        '20' +
                                                        bar.substring(oTcodeLength + 3 + 10, oTcodeLength + 3 + 12) +
                                                        '-' +
                                                        bar.substring(oTcodeLength + 3 + 12, oTcodeLength + 3 + 14) +
                                                        '-' +
                                                        '01';
                                                        expirationDate = Date.valueOf(expirationDateStr);
                                                        expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                                                    }else{
                                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' +bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16) ;
                                                    expirationDateStr =
                                                        '20' +
                                                        bar.substring(oTcodeLength + 3 + 10, oTcodeLength + 3 + 12) +
                                                        '-' +
                                                        bar.substring(oTcodeLength + 3 + 12, oTcodeLength + 3 + 14) +
                                                        '-' +
                                                        bar.substring(oTcodeLength + 3 + 14, oTcodeLength + 3 + 16);
                                                    expirationDate = Date.valueOf(expirationDateStr);
                                                    }
                                                }catch(Exception e){
                                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                                                ApexPages.addmessage(
                                                    new ApexPages.message(
                                                        ApexPages.severity.ERROR,
                                                        '产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                                    )
                                                );
                                                    continue;
                                                }
                                                if(bar.length() >= oTcodeLength + 3 + 25){
                                                    if(bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='10' || bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='21'){
                                                if (
                                                    bar.substring(oTcodeLength + 3 + 16, oTcodeLength + 3 + 18) == '10' ||
                                                    bar.substring(oTcodeLength + 3 + 16, oTcodeLength + 3 + 18) == '21'
                                                ) {
                                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 18,bar.length() - 8) ;
                                                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
                                                    }
                                                }
                                            }else if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
                                        } else if (
                                            bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '10' ||
                                            bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '21'
                                        ) {
                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
                                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
                                            }
@@ -1880,25 +2403,46 @@
                                    }else if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='17'){
                                        try{
                                            if(bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8)=='00'){
                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-01';
                                            expirationDateStr =
                                                '20' +
                                                bar.substring(oTcodeLength + 3 + 2, oTcodeLength + 3 + 4) +
                                                '-' +
                                                bar.substring(oTcodeLength + 3 + 4, oTcodeLength + 3 + 6) +
                                                '-01';
                                                expirationDate = Date.valueOf(expirationDateStr);
                                                expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                                            }else{
                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-' +bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8);
                                            expirationDateStr =
                                                '20' +
                                                bar.substring(oTcodeLength + 3 + 2, oTcodeLength + 3 + 4) +
                                                '-' +
                                                bar.substring(oTcodeLength + 3 + 4, oTcodeLength + 3 + 6) +
                                                '-' +
                                                bar.substring(oTcodeLength + 3 + 6, oTcodeLength + 3 + 8);
                                                expirationDate = Date.valueOf(expirationDateStr);
                                            }
                                        }catch(Exception e){
                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                                        ApexPages.addmessage(
                                            new ApexPages.message(
                                                ApexPages.severity.ERROR,
                                                '产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                            )
                                        );
                                            continue;
                                        }
                                        if(bar.length() >=oTcodeLength + 20){
                                            if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
                                        if (
                                            bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '10' ||
                                            bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '21'
                                        ) {
                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
                                            }
                                        }
                                    }else if(bar.length() >= oTcodeLength + 12){
                                        if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='10' || bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='21'){
                                    if (
                                        bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '10' ||
                                        bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '21'
                                    ) {
                                            serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2,bar.length() - 8) ;
                                        }
                                    }
@@ -1909,11 +2453,18 @@
                                        Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
                                        if(n.find()){
                                            String str = '管理编码不正确,请与管理员确认是否错误。';
                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')管理编码中有数字,请与管理员确认是否错误!'));
                                        ApexPages.addmessage(
                                            new ApexPages.message(
                                                ApexPages.severity.ERROR,
                                                '产品BarCode(' + bar + ')管理编码中有数字,请与管理员确认是否错误!'
                                            )
                                        );
                                            continue;
                                        }
                                    }else{
                                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')的tracingCode错误!'));
                                    ApexPages.addmessage(
                                        new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + bar + ')的tracingCode错误!')
                                    );
                                        continue;
                                    }
                                }
@@ -1925,10 +2476,8 @@
                                barcodedetList.add(tracingCode);
                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
                        }
                    }
                }
            }
            for(String bartxt :barCode241List){
@@ -1939,9 +2488,7 @@
               }
            }
        }
    }
    public void inventoryEntry (List<String> barCodeList){
        //所有barcode解析到的Jancode
@@ -1955,14 +2502,16 @@
        notInStorelist.clear();
        notEqualBARcodeCunMap.clear();
        Map<String,String> orderdetailMap = new Map<String,String>();
        List<Consumable_Orderdetails__c> orderdetail = [SELECT Id,  Name, Consumable_order__c,
                            Consumable_Product__c,Asset_Model_No__c
        List<Consumable_Orderdetails__c> orderdetail = [
            SELECT Id, Name, Consumable_order__c, Consumable_Product__c, Asset_Model_No__c
                        FROM Consumable_Orderdetails__c
                        WHERE Consumable_order__r.Dealer_Info__c = :accountid
                        AND Consumable_order__c != null
            WHERE
                Consumable_order__r.Dealer_Info__c = :accountid
                AND Consumable_order__c != NULL
                        AND Consumable_order__c = :ESetId
                        AND Order_Owner_WorkLocal__c = :userWorkLocation
                        ORDER BY Name ];
            ORDER BY Name
        ];
        for(Integer i = 0; i < orderdetail.size(); i++){
            orderdetailMap.put(orderdetail[i].Consumable_Product__c, orderdetail[i].Consumable_Product__c);
        }
@@ -1980,20 +2529,26 @@
                //生产日期
                List<String> janCode = new List<String>();
                if(barCodeList[i].length() < 16){
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!'));
                    ApexPages.addmessage(
                        new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!')
                    );
                    continue;
                }else {
                    janCodeMark = barCodeList[i].substring(2,16);
                    try{
                        Decimal test  = Decimal.valueOf(janCodeMark);
                    }catch(Exception e){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的janCode错误!'));
                        ApexPages.addmessage(
                            new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')的janCode错误!')
                        );
                        continue;
                    }
                }
                if(barCodeList[i].length() >= 22){
                    if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + barCodeList[i] + ')没有管理编码!'));
                        ApexPages.addmessage(
                            new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')没有管理编码!')
                        );
                        continue;
                    }
                    if( barCodeList[i].substring(16,18) =='11'){
@@ -2001,22 +2556,44 @@
                            productDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01' ;
                            productionDate = Date.valueOf(productDateStr);
                        }catch(Exception e){
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + barCodeList[i] + ')的生产日期' + productDateStr + '错误!'));
                            ApexPages.addmessage(
                                new ApexPages.message(
                                    ApexPages.severity.ERROR,
                                    '产品BarCode(' + barCodeList[i] + ')的生产日期' + productDateStr + '错误!'
                                )
                            );
                            continue;
                        }
                        if(barCodeList[i].length() >=32){
                            if( barCodeList[i].substring(24,26) =='17'){
                                try{
                                    if(barCodeList[i].substring(30,32)=='00'){
                                        expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' + '01' ;
                                        expirationDateStr =
                                            '20' +
                                            barCodeList[i].substring(26, 28) +
                                            '-' +
                                            barCodeList[i].substring(28, 30) +
                                            '-' +
                                            '01';
                                        expirationDate = Date.valueOf(expirationDateStr);
                                        expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                                    }else{
                                        expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' +barCodeList[i].substring(30,32) ;
                                        expirationDateStr =
                                            '20' +
                                            barCodeList[i].substring(26, 28) +
                                            '-' +
                                            barCodeList[i].substring(28, 30) +
                                            '-' +
                                            barCodeList[i].substring(30, 32);
                                    expirationDate = Date.valueOf(expirationDateStr);
                                    }
                                }catch(Exception e){
                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                                    ApexPages.addmessage(
                                        new ApexPages.message(
                                            ApexPages.severity.ERROR,
                                            '产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                        )
                                    );
                                    continue;
                                }
                                if(barCodeList[i].length() >= 42){
@@ -2031,16 +2608,32 @@
                    }else if(barCodeList[i].substring(16,18) =='17'){
                        try{
                            if(barCodeList[i].substring(22,24)=='00'){
                                expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01';
                                expirationDateStr =
                                    '20' +
                                    barCodeList[i].substring(18, 20) +
                                    '-' +
                                    barCodeList[i].substring(20, 22) +
                                    '-01';
                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品expirationDateStr' + expirationDateStr));
                                expirationDate = Date.valueOf(expirationDateStr);
                                expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                            }else{
                                expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-' +barCodeList[i].substring(22,24);
                                expirationDateStr =
                                    '20' +
                                    barCodeList[i].substring(18, 20) +
                                    '-' +
                                    barCodeList[i].substring(20, 22) +
                                    '-' +
                                    barCodeList[i].substring(22, 24);
                                expirationDate = Date.valueOf(expirationDateStr);
                            }
                        }catch(Exception e){
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                            ApexPages.addmessage(
                                new ApexPages.message(
                                    ApexPages.severity.ERROR,
                                    '产品BarCode(' + barCodeList[i] + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                )
                            );
                            continue;
                        }
                        if(barCodeList[i].length() >= 34){
@@ -2048,24 +2641,33 @@
                                serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
                            }
                        }
                    }else if(barCodeList[i].length() >= 26){
                        if(barCodeList[i].substring(16,18) =='10' || barCodeList[i].substring(16,18) =='21'){
                            serialNoorLotNo = barCodeList[i].substring(18,barCodeList[i].length() - 8) ;
                        }
                    }
                }
                if(barCodeList[i].length() >= 24 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
                if (
                    barCodeList[i].length() >= 24 &&
                    barCodeList[i].substring(barCodeList[i].length() - 8, barCodeList[i].length() - 5) == '250'
                ) {
                    if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
                        tracingCode = barCodeList[i].substring(barCodeList[i].length() - 5,barCodeList[i].length());
                        Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
                        if(n.find()){
                            String str = '管理编码不正确,请与管理员确认是否错误。';
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')管理编码中有数字,请与管理员确认是否错误!'));
                            ApexPages.addmessage(
                                new ApexPages.message(
                                    ApexPages.severity.ERROR,
                                    '产品BarCode(' + barCodeList[i] + ')管理编码中有数字,请与管理员确认是否错误!'
                                )
                            );
                            continue;
                        }
                    }else{
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的tracingCode错误!'));
                        ApexPages.addmessage(
                            new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')的tracingCode错误!')
                        );
                        continue;
                    }
                }
@@ -2087,14 +2689,41 @@
                Integer jan11 = Integer.valueOf(janCodeMark.substring(10, 11));
                Integer jan12 = Integer.valueOf(janCodeMark.substring(11, 12));
                Integer jan13 = Integer.valueOf(janCodeMark.substring(12, 13));
                Integer count12 = jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
                Integer count12 =
                    jan2 +
                    jan3 * 3 +
                    jan4 +
                    jan5 * 3 +
                    jan6 +
                    jan7 * 3 +
                    jan8 +
                    jan9 * 3 +
                    jan10 +
                    jan11 * 3 +
                    jan12 +
                    jan13 * 3;
                
                Integer count13 = jan1*3 + jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
                Integer count13 =
                    jan1 * 3 +
                    jan2 +
                    jan3 * 3 +
                    jan4 +
                    jan5 * 3 +
                    jan6 +
                    jan7 * 3 +
                    jan8 +
                    jan9 * 3 +
                    jan10 +
                    jan11 * 3 +
                    jan12 +
                    jan13 * 3;
                String frost12  = (String.valueOf(count12)).substring((String.valueOf(count12)).length()-1);
                String frost13  = (String.valueOf(count13)).substring((String.valueOf(count13)).length()-1);
                //减去12位个位4
                frost12 = (String.valueOf(10 - Integer.valueOf(frost12))).substring((String.valueOf(10 - Integer.valueOf(frost12))).length()-1);
                frost13 = (String.valueOf(10 - Integer.valueOf(frost13))).substring((String.valueOf(10 - Integer.valueOf(frost13))).length()-1);
                frost12 = (String.valueOf(10 - Integer.valueOf(frost12)))
                    .substring((String.valueOf(10 - Integer.valueOf(frost12))).length() - 1);
                frost13 = (String.valueOf(10 - Integer.valueOf(frost13)))
                    .substring((String.valueOf(10 - Integer.valueOf(frost13))).length() - 1);
                
                janCode.add(janCodeMark.substring(1, 13) + frost12);
                janCode.add(janCodeMark.substring(0, 13) + frost12);
@@ -2110,14 +2739,21 @@
                barcodeinfoMap.put(barCodeList[i], barcodedetList);
                barCode01List.add(barCodeList[i]);
            }else if(barCodeList[i].substring(0,3) =='241'){
                if(barCodeList[i].length() > 8 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + barCodeList[i] + ')没有管理编码!'));
                if (
                    barCodeList[i].length() > 8 &&
                    barCodeList[i].substring(barCodeList[i].length() - 8, barCodeList[i].length() - 5) != '250'
                ) {
                    ApexPages.addmessage(
                        new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')没有管理编码!')
                    );
                    continue;
                }
                List<String> otCodeList = new List<String>();
                Map<String,String> otCodeMap = new Map<String,String>();
                if(barCodeList[i].length() < 7){
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!'));
                    ApexPages.addmessage(
                        new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')的位数不足16,不符合要求错误!')
                    );
                    continue;
                }else if(barCodeList[i].length() == 11){
                    String otCode4 = barCodeList[i].substring(3,7);
@@ -2159,7 +2795,9 @@
                barOtcodeMap.put(barCodeList[i], otCodeMap);
                barCode241List.add(barCodeList[i]);
            }else{
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + barCodeList[i] + ')没有janCode或OTcode,不符合要求!'));
                ApexPages.addmessage(
                    new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + barCodeList[i] + ')没有janCode或OTcode,不符合要求!')
                );
                continue;
            }
        }
@@ -2167,13 +2805,22 @@
        Map<String,String> rightBar = new Map<String,String>();
        if(alljanCodeList.size() > 0){
            Map<String,String> exitBarCodeMap = new Map<String,String>();
            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
                                            Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c,
            List<Product2__c> product2InStore = [
                SELECT
                    Id,
                    Name,
                    Name__c,
                    Intra_Trade_List_RMB__c,
                    Asset_Model_No__c,
                    OT_CODE__c,
                    Product2_Jancode__c,
                    Pro2_Dealer_ENG__c,
                    Pro2_Dealer_Object__c,
                                            Product_Type__c                                      
                                                 FROM Product2__c
                                                 WHERE Product2_Jancode__c in :alljanCodeList
                                                 AND (not Product_Type__c like :userPro_Typestr)
                                                 order by SFDA_Expiration_Date__c  desc ] ;
                WHERE Product2_Jancode__c IN :alljanCodeList AND (NOT Product_Type__c LIKE :userPro_Typestr)
                ORDER BY SFDA_Expiration_Date__c DESC
            ];
            if(product2InStore.size() > 0){
                Map<String,String> errorMap = new Map<String,String>();
                for(Product2__c produ: product2InStore){
@@ -2182,20 +2829,33 @@
                            exitBarCodeMap.put(bar,bar);
                            errorMap.put(bar, bar);
                        }
                    }
                }
                if(errorMap.size() > 0){
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号['+ errorMap.values() +']产品类型['+product_Type+']与用户的类型['+userPro_Type+']不符'));
                    ApexPages.addmessage(
                        new ApexPages.message(
                            ApexPages.severity.ERROR,
                            'BarCode号[' + errorMap.values() + ']产品类型[' + product_Type + ']与用户的类型[' + userPro_Type + ']不符'
                        )
                    );
                }
            }                                   
            product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
                                            Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c,
            product2InStore = [
                SELECT
                    Id,
                    Name,
                    Name__c,
                    Intra_Trade_List_RMB__c,
                    Asset_Model_No__c,
                    OT_CODE__c,
                    Product2_Jancode__c,
                    Pro2_Dealer_ENG__c,
                    Pro2_Dealer_Object__c,
                                            Product_Type__c                                      
                                                 FROM Product2__c
                                                 WHERE Product2_Jancode__c in :alljanCodeList
                                                 AND Product_Type__c like :userPro_Typestr
                                                 order by SFDA_Expiration_Date__c  desc ] ;
                WHERE Product2_Jancode__c IN :alljanCodeList AND Product_Type__c LIKE :userPro_Typestr
                ORDER BY SFDA_Expiration_Date__c DESC
            ];
            if(product2InStore.size() > 0){
                Map<String,String> errorMap = new Map<String,String>();
                for(Product2__c produ: product2InStore){
@@ -2208,7 +2868,7 @@
                            }else{
                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
                                rightBar.put(bar, bar);
                                list<String> overOrderBARcodeCunList = new list<String>();
                                list<String> overOrderBARcodeCunList = new List<String>();
                                if(notEqualBARcodeCunMap.containsKey(produ.Id)){
                                    overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id).clone();
                                    overOrderBARcodeCunList.add(bar);
@@ -2218,7 +2878,6 @@
                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
                                }
                            }
                        }
                    }
                }
@@ -2228,18 +2887,17 @@
                  notInStorelist.add(bartxt);
               }
            }
        }
        //241通过检索产品是否存在
        if(allotCodeList.size() > 0){
            Map<String,String> exitBarCodeMap = new Map<String,String>();
            Map<String,String> errorMap = new Map<String,String>();
            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,
                                            Pro2_Dealer_Object__c,Pro2_Dealer_ENG__c
            List<Product2__c> product2InStore = [
                SELECT Id, Name, Name__c, Intra_Trade_List_RMB__c, Asset_Model_No__c, OT_CODE__c, Pro2_Dealer_Object__c, Pro2_Dealer_ENG__c
                                                     FROM Product2__c
                                                     WHERE OT_CODE__c in :allotCodeList
                                                     AND (not Product_Type__c like :userPro_Typestr)] ;
                WHERE OT_CODE__c IN :allotCodeList AND (NOT Product_Type__c LIKE :userPro_Typestr)
            ];
            if(product2InStore.size() > 0){
                for(Product2__c produ: product2InStore){
                    for(String bar: barOtcodeMap.keySet() ){
@@ -2251,13 +2909,18 @@
                }
            }
            if(errorMap.size() > 0){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号['+ errorMap.values() +']产品类型['+product_Type+']与用户['+userPro_Type+']类型不符'));
                ApexPages.addmessage(
                    new ApexPages.message(
                        ApexPages.severity.ERROR,
                        'BarCode号[' + errorMap.values() + ']产品类型[' + product_Type + ']与用户[' + userPro_Type + ']类型不符'
                    )
                );
            }
            product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,
                                            Pro2_Dealer_Object__c,Pro2_Dealer_ENG__c
            product2InStore = [
                SELECT Id, Name, Name__c, Intra_Trade_List_RMB__c, Asset_Model_No__c, OT_CODE__c, Pro2_Dealer_Object__c, Pro2_Dealer_ENG__c
                                                     FROM Product2__c
                                                     WHERE OT_CODE__c in :allotCodeList
                                                     AND Product_Type__c like :userPro_Typestr] ;
                WHERE OT_CODE__c IN :allotCodeList AND Product_Type__c LIKE :userPro_Typestr
            ];
            
            if(product2InStore.size() > 0){
                for(Product2__c produ: product2InStore){
@@ -2273,10 +2936,20 @@
                        if(bar.length() >= oTcodeLength + 11){
                            if( bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='11'){
                                try{
                                    productDateStr = '20' + bar.substring(oTcodeLength + 5,oTcodeLength + 7) + '-' + bar.substring(oTcodeLength + 7,oTcodeLength + 9) + '-01' ;
                                    productDateStr =
                                        '20' +
                                        bar.substring(oTcodeLength + 5, oTcodeLength + 7) +
                                        '-' +
                                        bar.substring(oTcodeLength + 7, oTcodeLength + 9) +
                                        '-01';
                                    productionDate = Date.valueOf(productDateStr);
                                }catch(Exception e){
                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '产品BarCode(' + bar + ')的生产日期' + productDateStr + '错误!'));
                                    ApexPages.addmessage(
                                        new ApexPages.message(
                                            ApexPages.severity.ERROR,
                                            '产品BarCode(' + bar + ')的生产日期' + productDateStr + '错误!'
                                        )
                                    );
                                    continue;
                                }
                                if(bar.length() >=oTcodeLength + 3 + 16){
@@ -2284,24 +2957,47 @@
                                    if( bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='17'){
                                        try{
                                            if(bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16)=='00'){
                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' + '01' ;
                                                expirationDateStr =
                                                    '20' +
                                                    bar.substring(oTcodeLength + 3 + 10, oTcodeLength + 3 + 12) +
                                                    '-' +
                                                    bar.substring(oTcodeLength + 3 + 12, oTcodeLength + 3 + 14) +
                                                    '-' +
                                                    '01';
                                                expirationDate = Date.valueOf(expirationDateStr);
                                                expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                                            }else{
                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' +bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16) ;
                                                expirationDateStr =
                                                    '20' +
                                                    bar.substring(oTcodeLength + 3 + 10, oTcodeLength + 3 + 12) +
                                                    '-' +
                                                    bar.substring(oTcodeLength + 3 + 12, oTcodeLength + 3 + 14) +
                                                    '-' +
                                                    bar.substring(oTcodeLength + 3 + 14, oTcodeLength + 3 + 16);
                                            expirationDate = Date.valueOf(expirationDateStr);
                                            }
                                        }catch(Exception e){
                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                                            ApexPages.addmessage(
                                                new ApexPages.message(
                                                    ApexPages.severity.ERROR,
                                                    '产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                                )
                                            );
                                            continue;
                                        }
                                        if(bar.length() >= oTcodeLength + 3 + 25){
                                            if(bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='10' || bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='21'){
                                            if (
                                                bar.substring(oTcodeLength + 3 + 16, oTcodeLength + 3 + 18) == '10' ||
                                                bar.substring(oTcodeLength + 3 + 16, oTcodeLength + 3 + 18) == '21'
                                            ) {
                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 18,bar.length() - 8) ;
                                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
                                            }
                                        }
                                    }else if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
                                    } else if (
                                        bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '10' ||
                                        bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '21'
                                    ) {
                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
                                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
                                    }
@@ -2309,25 +3005,46 @@
                            }else if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='17'){
                                try{
                                    if(bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8)=='00'){
                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-01';
                                        expirationDateStr =
                                            '20' +
                                            bar.substring(oTcodeLength + 3 + 2, oTcodeLength + 3 + 4) +
                                            '-' +
                                            bar.substring(oTcodeLength + 3 + 4, oTcodeLength + 3 + 6) +
                                            '-01';
                                        expirationDate = Date.valueOf(expirationDateStr);
                                        expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
                                    }else{
                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-' +bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8);
                                        expirationDateStr =
                                            '20' +
                                            bar.substring(oTcodeLength + 3 + 2, oTcodeLength + 3 + 4) +
                                            '-' +
                                            bar.substring(oTcodeLength + 3 + 4, oTcodeLength + 3 + 6) +
                                            '-' +
                                            bar.substring(oTcodeLength + 3 + 6, oTcodeLength + 3 + 8);
                                        expirationDate = Date.valueOf(expirationDateStr);
                                    }
                                }catch(Exception e){
                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'));
                                    ApexPages.addmessage(
                                        new ApexPages.message(
                                            ApexPages.severity.ERROR,
                                            '产品BarCode(' + bar + ')的滅菌有効期限' + expirationDateStr + '错误!'
                                        )
                                    );
                                    continue;
                                }
                                if(bar.length() >=oTcodeLength + 20){
                                    if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
                                    if (
                                        bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '10' ||
                                        bar.substring(oTcodeLength + 3 + 8, oTcodeLength + 3 + 10) == '21'
                                    ) {
                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
                                    }
                                }
                            }else if(bar.length() >= oTcodeLength + 12){
                                if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='10' || bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='21'){
                                if (
                                    bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '10' ||
                                    bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '21'
                                ) {
                                    serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2,bar.length() - 8) ;
                                }
                            }
@@ -2338,11 +3055,18 @@
                                Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
                                if(n.find()){
                                    String str = '管理编码不正确,请与管理员确认是否错误。';
                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')管理编码中有数字,请与管理员确认是否错误!'));
                                    ApexPages.addmessage(
                                        new ApexPages.message(
                                            ApexPages.severity.ERROR,
                                            '产品BarCode(' + bar + ')管理编码中有数字,请与管理员确认是否错误!'
                                        )
                                    );
                                    continue;
                                }
                            }else{
                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'产品BarCode(' + bar + ')的tracingCode错误!'));
                                ApexPages.addmessage(
                                    new ApexPages.message(ApexPages.severity.ERROR, '产品BarCode(' + bar + ')的tracingCode错误!')
                                );
                                continue;
                            }
                        }
@@ -2358,7 +3082,7 @@
                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
                            }else{
                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
                                list<String> overOrderBARcodeCunList = new list<String>();
                                list<String> overOrderBARcodeCunList = new List<String>();
                                if(notEqualBARcodeCunMap.containsKey(produ.Id)){
                                    overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id).clone();
                                    overOrderBARcodeCunList.add(bar);
@@ -2368,7 +3092,6 @@
                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
                                }
                            } 
                        }
                    }
                }
@@ -2396,20 +3119,26 @@
    }
    public String ConfimResult() {
        list<String> overOrderproList = new list<String>();
        list<String> overOrderBARcodeCunList = new list<String>();
        list<String> overOrderBARcodeCunListTest = new list<String>();
        list<String> overOrderproList = new List<String>();
        list<String> overOrderBARcodeCunList = new List<String>();
        list<String> overOrderBARcodeCunListTest = new List<String>();
        //overOrderBARcodeCunMap.clear();
        for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords)  {
            if(orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) > orderProductCunMap.get(ass.esd.Asset_Model_No__c)-1){
            if (
                orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) >
                orderProductCunMap.get(ass.esd.Asset_Model_No__c) - 1
            ) {
                // 获取超过定货数量的消耗品信息
                overOrderBARcodeCunList = new list<String>();
                overOrderBARcodeCunList = new List<String>();
                overOrderBARcodeCunList = overOrderBARcodeCunMap.get(ass.esd.Asset_Model_No__c).clone();
                overOrderBARcodeCunList.add(ass.esd.Bar_Code__c);
                overOrderBARcodeCunMap.put(ass.esd.Asset_Model_No__c,overOrderBARcodeCunList);
                overOrderCunMap.put(ass.esd.Asset_Model_No__c,overOrderCunMap.get(ass.esd.Asset_Model_No__c)+1);
                cancellationProList.add(ass.esd.Asset_Model_No__c);
            }else if(orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) == orderProductCunMap.get(ass.esd.Asset_Model_No__c)-1){
            } else if (
                orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) ==
                orderProductCunMap.get(ass.esd.Asset_Model_No__c) - 1
            ) {
                consumableorderdetailsRecordsUse.add(ass);
                cancellationProList.add(ass.esd.Asset_Model_No__c);
            }else{
@@ -2422,10 +3151,12 @@
                consumableInventoryUse.add(ass);
                continue;
            }
            if(orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) > orderProductCunMap.get(ass.Prod.Asset_Model_No__c)-1){
            if (
                orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) >
                orderProductCunMap.get(ass.Prod.Asset_Model_No__c) - 1
            ) {
                //取得原有list
                overOrderBARcodeCunList = new list<String>();
                overOrderBARcodeCunList = new List<String>();
                overOrderBARcodeCunList = overOrderBARcodeCunMap.get(ass.Prod.Asset_Model_No__c).clone();
                //更新list
                overOrderBARcodeCunList.add(ass.barCodeNo);
@@ -2433,8 +3164,10 @@
                overOrderBARcodeCunMap.put(ass.Prod.Asset_Model_No__c,overOrderBARcodeCunList);
                overOrderCunMap.put(ass.Prod.Asset_Model_No__c,overOrderCunMap.get(ass.Prod.Asset_Model_No__c)+1);
                cancellationProList.add(ass.Prod.Asset_Model_No__c);
            }else if(orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) == orderProductCunMap.get(ass.Prod.Asset_Model_No__c)-1){
            } else if (
                orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) ==
                orderProductCunMap.get(ass.Prod.Asset_Model_No__c) - 1
            ) {
                consumableInventoryUse.add(ass);
                cancellationProList.add(ass.Prod.Asset_Model_No__c);
            }else{
@@ -2453,7 +3186,6 @@
        }else{
            return '';
        }
    }
    public void confimResultWithoutOrder() {
@@ -2540,7 +3272,11 @@
        }
        
        System.debug('======accountGroupMap'+accountGroupMap);
        List<Consumable_order__c> orderList = [select Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c from Consumable_order__c where id in : orderIdList];
        List<Consumable_order__c> orderList = [
            SELECT Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c
            FROM Consumable_order__c
            WHERE id IN :orderIdList
        ];
        // 生成各经销商出库订单List
        // List<Consumable_order__c> orderList = new List<Consumable_order__c> ();
@@ -2550,7 +3286,7 @@
            List<Consumable_order_details2__c> prodPriceList = accountGroupMap.get(acc);
            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
            pNumMap = productMap.get(acc);
            List<Consumable_orderdetails__c> insDetail1 = New List<Consumable_orderdetails__c>();
            List<Consumable_orderdetails__c> insDetail1 = new List<Consumable_orderdetails__c>();
            for (Id id : pNumMap.keySet()) {
                Consumable_orderdetails__c ins = new Consumable_orderdetails__c();
                
@@ -2596,7 +3332,6 @@
    }
    // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
    // 经销商的不同工作地调货自动生成出库单
    public void addSaleOrderAuto (List<Consumable_order_details2__c> addList) {
        Map<String, List<Consumable_order_details2__c>> accountGroupMap = new Map<String, List<Consumable_order_details2__c>>();
@@ -2635,13 +3370,13 @@
            autoOrder.RecordTypeid = System.Label.RT_ConOrder_Shipment;
            autoOrder.Outbound_Date__c = Date.today();
            autoOrder.Order_date__c = Date.today();
            autoOrder.AutoShipment__c = TRUE;
            autoOrder.AutoShipment__c = true;
            orderList.add(autoOrder);
            List<Consumable_order_details2__c> prodPriceList = accountGroupMap.get(acc);
            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
            pNumMap = productMap.get(acc);
            List<Consumable_orderdetails__c> insDetail1 = New List<Consumable_orderdetails__c>();
            List<Consumable_orderdetails__c> insDetail1 = new List<Consumable_orderdetails__c>();
            for (Id id : pNumMap.keySet()) {
                Consumable_orderdetails__c ins = new Consumable_orderdetails__c();
                
@@ -2675,7 +3410,7 @@
        }
        orderList = new List<Consumable_order__c> ();
        orderList = [select Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c from Consumable_order__c where id in : orderIdList];
        orderList = [SELECT Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c FROM Consumable_order__c WHERE id IN :orderIdList];
        // 设置明细1 和 明细2 的 订单ID
        List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c> ();
@@ -2724,7 +3459,7 @@
        StaticParameter.ConsumableOrderTrigger = true;
        //add by rentx 20210618 end CHAN-C3K4ZQ 跳过不必要的查询
        cancellationProList = new List<String>();
        List<Consumable_order_details2__c> ins = New List<Consumable_order_details2__c>();
        List<Consumable_order_details2__c> ins = new List<Consumable_order_details2__c>();
        String resultcheck = '';
        List<String> resultcheckWithoutOrder = new List<String>();
        Savepoint sp = Database.setSavepoint();
@@ -2738,7 +3473,12 @@
            if(resultcheck.length() > 0){
                for(String widget : overOrderBARcodeCunMap.keySet()) {
                    if(overOrderBARcodeCunMap.get(widget).size() >0){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '产品' + widget + '本次到货数量超过' + overOrderBARcodeCunMap.get(widget).size() +'个订货的数量。'));
                        ApexPages.addmessage(
                            new ApexPages.message(
                                ApexPages.severity.INFO,
                                '产品' + widget + '本次到货数量超过' + overOrderBARcodeCunMap.get(widget).size() + '个订货的数量。'
                            )
                        );
                        for(String barcodeListTTT : (List<String>)overOrderBARcodeCunMap.get(widget)) {
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, barcodeListTTT));
                        }
@@ -2750,7 +3490,7 @@
        }
        try{
            Consumable_order__c orderMain = new Consumable_order__c();
            List<Consumable_order_details2__c> orderdetails = New List<Consumable_order_details2__c>();
            List<Consumable_order_details2__c> orderdetails = new List<Consumable_order_details2__c>();
            //到货正确信息
            orderMain.Name            = '*';
            orderMain.Order_status__c = '批准';
@@ -2769,6 +3509,7 @@
            arriveId = orderMain.id;
            Decimal arriveAmount =0;
            for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsUse)  {
                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------1------'));
                Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
                insDetails.Id                           = ass.esd.Id;
                insDetails.Consumable_Arrived_order__c  = orderMain.id;
@@ -2779,13 +3520,17 @@
                if (orderdetails2trMap.containsKey(ass.esd.Bar_Code__c)) {
                    insDetails.Transfer_Time__c = ass.esd.Transfer_Time__c == null ? 1 : ass.esd.Transfer_Time__c;
                    insDetails.Agency_Transfer__c = true;
                    insDetails.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c == null ? ass.esd.Dealer_Info_text__c : ass.esd.Frist_Transfer_Agency__c;
                    insDetails.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c == null
                        ? ass.esd.Dealer_Info_text__c
                        : ass.esd.Frist_Transfer_Agency__c;
                }
                // 更新借调信息 add by gzw 2020-0-415 end
                 
                // 追加首次入库经销商 add by gzw 2020-04-27 start
                insDetails.Agencyinfo_fromSAP__c = ass.esd.Agencyinfo_fromSAP__c;
                insDetails.Frist_Storage_Agency__c  = ass.esd.Frist_Storage_Agency__c == null ? ass.esd.Dealer_Info_text__c : ass.esd.Frist_Storage_Agency__c;
                insDetails.Frist_Storage_Agency__c = ass.esd.Frist_Storage_Agency__c == null
                    ? ass.esd.Dealer_Info_text__c
                    : ass.esd.Frist_Storage_Agency__c;
                // 追加首次入库经销商 add by gzw 2020-04-27 end
                arriveAmount                            += ass.esd.Intra_Trade_List_RMB__c;
                orderdetails.add(insDetails);
@@ -2800,14 +3545,11 @@
                // }
                insAfterDel.Name                        = consumable_order[0].Name + '-'+ str;
                insAfterDel.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                // gzw 手动入库 默认产品单价 20230307
                // if(EsetId != null && EsetId != ''){
                //     insAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
                // }else{
                //     insAfterDel.Intra_Trade_List_RMB__c = 0;
                // }
                if (EsetId != null && EsetId != '') {
                insAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
                //gzw 手动入库 默认产品单价 20230307
                } else {
                    insAfterDel.Intra_Trade_List_RMB__c = 0;
                }
                insAfterDel.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
                if(EsetId != null && EsetId != ''){
                    insAfterDel.Consumable_order_minor__c   = ESetId;
@@ -2831,13 +3573,17 @@
                if (orderdetails2trMap.containsKey(ass.esd.Bar_Code__c)) {
                    insAfterDel.Transfer_Time__c = ass.esd.Transfer_Time__c == null ? 1 : ass.esd.Transfer_Time__c;
                    insAfterDel.Agency_Transfer__c = true;
                    insAfterDel.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c == null ? accountName : ass.esd.Frist_Transfer_Agency__c;
                    insAfterDel.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c == null
                        ? accountName
                        : ass.esd.Frist_Transfer_Agency__c;
                }
                // 更新借调信息 add by gzw 2020-0-415 end
                 
                // 追加首次入库经销商 add by gzw 2020-04-27 start
                insAfterDel.Agencyinfo_fromSAP__c = ass.esd.Agencyinfo_fromSAP__c;
                insAfterDel.Frist_Storage_Agency__c  = ass.esd.Frist_Storage_Agency__c == null ? accountName : ass.esd.Frist_Storage_Agency__c;
                insAfterDel.Frist_Storage_Agency__c = ass.esd.Frist_Storage_Agency__c == null
                    ? accountName
                    : ass.esd.Frist_Storage_Agency__c;
                // 追加首次入库经销商 add by gzw 2020-04-27 end
                arriveAmount += insAfterDel.Intra_Trade_List_RMB__c;
                //add by rentx 2020-10-14 strat
@@ -2853,7 +3599,6 @@
                i++;
                ins.add(insAfterDel);
            }
            orderMain.Arrive_total_amount__c = arriveAmount;
            update orderMain;
@@ -2863,7 +3608,7 @@
            for(Consumable_order_details2__c Cod : consumableorderdetails2Cancle){
                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------3------'));
                if (Cod.Dealer_Arrive__c) {
                    if (Cod.Dealer_Shipment__c == FALSE && Cod.Dealer_Saled__c == FALSE) {
                    if (Cod.Dealer_Shipment__c == false && Cod.Dealer_Saled__c == false) {
                        addSaleOrderList.add(Cod);
                    }
                } else {
@@ -2880,6 +3625,7 @@
            if(updateconsumableorderdetails2.size() > 0){
                update updateconsumableorderdetails2;
            }
            List<Consumable_order_details2__c> insertconsumableorderdetails2 = new List<Consumable_order_details2__c>();
            for(Consumable_order_details2__c Cod2 : consumableorderdetails2Insert){
                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4------'));
@@ -2926,13 +3672,15 @@
            //超出到货数量产品取消日期更新
            List<Consumable_order_details2__c> needcanceldet = new List<Consumable_order_details2__c>();
            if(cancellationProList.size() > 0){
                needcanceldet = [SELECT Id,
                                    Cancellation_Date__c
                needcanceldet = [
                    SELECT Id, Cancellation_Date__c
                                FROM Consumable_order_details2__c
                                WHERE Asset_Model_No__c in :cancellationProList
                    WHERE
                        Asset_Model_No__c IN :cancellationProList
                                AND Consumable_order_minor__c = :ESetId
                                AND Dealer_Arrive__c = FALSE
                                AND Cancellation_Date__c = null ];
                        AND Cancellation_Date__c = NULL
                ];
                if(needcanceldet.size() >0){
                    for(Integer a = 0; a < needcanceldet.size(); a++){
                        needcanceldet[a].Cancellation_Date__c = Date.today();
@@ -2941,14 +3689,26 @@
                    ControllerUtil.updateOrderDetailsSatus(needcanceldet);
                }
            }
            List<Consumable_order__c> qs = New List<Consumable_order__c>();
            qs = [SELECT Id,Name,Order_status__c,Dealer_Info__c,Deliver_date__c,ReturnGs_Upload_Date__c,
                        Order_Reason__c,Order_date__c,
                        Contract_application_decision__c,Order_type__c,Total_num__c,
                        OrderNumber_arrived__c,Delivery_detail_count__c,OrderNumber_notarrive__c
            List<Consumable_order__c> qs = new List<Consumable_order__c>();
            qs = [
                SELECT
                    Id,
                    Name,
                    Order_status__c,
                    Dealer_Info__c,
                    Deliver_date__c,
                    ReturnGs_Upload_Date__c,
                    Order_Reason__c,
                    Order_date__c,
                    Contract_application_decision__c,
                    Order_type__c,
                    Total_num__c,
                    OrderNumber_arrived__c,
                    Delivery_detail_count__c,
                    OrderNumber_notarrive__c
                    FROM Consumable_order__c
                    WHERE Id =:ESetId
                    AND Dealer_Info__c = :accountid];
                WHERE Id = :ESetId AND Dealer_Info__c = :accountid
            ];
            if (qs.size()>0){
                coc = qs[0];
            }
@@ -2978,39 +3738,56 @@
        for(    String  Str :   GrListIn  ){
            CheckBarcodeResult.put( str , 'UnFind');
        }
        List<Consumable_order_details2__c>   BarcodeRetrunResult =
                 [  SELECT  Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
                            Consumable_Product__c,Consumable_Product__r.Name,
                            Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
                            Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
                            Consumable_order_minor__c,Dealer_Arrive__c,
                            Guarantee_period_for_products__c,CFDA_Status__c,
                            ProductPacking_list_manual__c,Report_Product_Approbation__c,
                            Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
                            Product_Type__c
        List<Consumable_order_details2__c> BarcodeRetrunResult = [
            SELECT
                Id,
                Name,
                Intra_Trade_List_RMB__c,
                Asset_Model_No__c,
                Consumable_Product__c,
                Consumable_Product__r.Name,
                Consumable_Product__r.Name__c,
                Consumable_Product__r.Asset_Model_No__c,
                Sterilization_limit__c,
                Deliver_date__c,
                Bar_Code__c,
                Arrive_date__c,
                Send_Date__c,
                Consumable_order_minor__r.Name,
                Consumable_order_minor__c,
                Dealer_Arrive__c,
                Guarantee_period_for_products__c,
                CFDA_Status__c,
                ProductPacking_list_manual__c,
                Report_Product_Approbation__c,
                Report_Product_Expiration__c,
                Box_Piece__c,
                Rrturn_count__c,
                Product_Type__c,
                            //add by rentx 2020-10-14 start
                            ,ContractNo_text__c/*,ContractNo__c*/
                ContractNo_text__c /*,ContractNo__c*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                Consumable_order_minor__r.ContractNo__c
                            // tcm end
                            //add by rentx 2020-10-14 end
                    FROM    Consumable_order_details2__c
                    WHERE   ((Dealer_Arrive__c = true
                            AND(  Dealer_Shipment__c = true
            WHERE
                Dealer_Arrive__c = TRUE
                AND (Dealer_Shipment__c = TRUE
                                    //AND Consumable_Shipment_order__r.SummonsForDirction__c != '互相调货')
                                  or  Dealer_Saled__c = true
                                )
                            ))
                OR Dealer_Saled__c = TRUE)
                    AND     Dealer_Info_text__c = :accountName
                    AND     Bar_Code__c in :GrListIn
                    AND     ( not Product_Type__c  like :userPro_Typestr)
                    AND     Dealer_Returned__c = false
                AND Bar_Code__c IN :GrListIn
                AND (NOT Product_Type__c LIKE :userPro_Typestr)
                AND Dealer_Returned__c = FALSE
                    AND     Arrive_Owner_Work_Location__c =: userWorkLocation
                    ORDER BY Box_Piece__c desc,Name ];
            ORDER BY Box_Piece__c DESC, Name
        ];
        if(BarcodeRetrunResult.size()>0){
            for (Integer i = 0; i < BarcodeRetrunResult.size(); i++) {
                if(ErrorIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c) || ExistIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c)){
                if (
                    ErrorIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c) || ExistIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c)
                ) {
                    // 跳过已经处理的消耗品明细
                    continue;
                }else{
@@ -3021,8 +3798,9 @@
            }
        }
        AllMap.putAll(ErrorIdMap);
        BarcodeRetrunResult =
                 [  SELECT  Id,
        BarcodeRetrunResult = [
            SELECT
                Id,
                            Consumable_order_minor__c,
                            Deliver_date__c,
                            Asset_Model_No__c,
@@ -3065,32 +3843,33 @@
                            Transfer_Time__c,
                            Frist_Transfer_Agency__c,
                            Arrive_Owner_Work_Location__c,
                            Agency_Transfer__c
                Agency_Transfer__c,
                            //add by rentx 2020-10-14 start
                            ,ContractNo_text__c/*,ContractNo__c*/
                ContractNo_text__c /*,ContractNo__c*/,
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                Consumable_order_minor__r.ContractNo__c,
                            // tcm end
                            //add by rentx 2020-10-14 end
                            ,Report_Product_Expiration__c
                            ,Intra_Trade_List__c
                Report_Product_Expiration__c
                    FROM    Consumable_order_details2__c
                    WHERE   ((Dealer_Arrive__c = true
                            AND(  Dealer_Shipment__c = true
            WHERE
                Dealer_Arrive__c = TRUE
                AND (Dealer_Shipment__c = TRUE
                                    //AND Consumable_Shipment_order__r.SummonsForDirction__c != '互相调货')
                                  or  Dealer_Saled__c = true
                OR Dealer_Saled__c = TRUE
                                  // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                                  or (Dealer_Shipment__c = false and Dealer_Saled__c = false and Lose_Flag__c = true)
                OR (Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Lose_Flag__c = TRUE))
                                  // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                                )
                            ))
                    AND     Dealer_Info_text__c = :accountName
                    AND     Bar_Code__c in :GrListIn
                    AND     Product_Type__c  like :userPro_Typestr
                    AND     Dealer_Returned__c = false
                AND Bar_Code__c IN :GrListIn
                AND Product_Type__c LIKE :userPro_Typestr
                AND Dealer_Returned__c = FALSE
                    AND     (Arrive_Owner_Work_Location__c =: userWorkLocation
                        OR OwnerId = :System.Label.User_OlympusSystem)
                    ORDER BY Box_Piece__c desc,Name ];
            ORDER BY Box_Piece__c DESC, Name
        ];
        ShowGoodsofReturnList   =   new List<ConsumableorderdetailsInfo>();
        //返品时istinct处理
@@ -3103,7 +3882,6 @@
                // 跳过已经处理的消耗品明细
                continue;
            }else{
                Matcher n = Pattern.compile('[0-9]').matcher(codc.TracingCode__c);
                if(n.find()){
                    String str = '管理编码中有数字,请与管理员确认是否错误。';
@@ -3143,8 +3921,9 @@
    public integer Getconsumableorderdetails2Nobox(){
        consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
        BarcodeCntMap.clear();
        consumableorderdetails2Nobox =
                 [  SELECT  Id,
        consumableorderdetails2Nobox = [
            SELECT
                Id,
                            Consumable_order_minor__c,
                            Deliver_date__c,
                            Asset_Model_No__c,
@@ -3176,42 +3955,52 @@
                            Rrturn_count__c,
                            Dealer_Info_text__c,
                            Arrive_Owner_Work_Location__c,
                            Intra_Trade_List_RMB__c
                Intra_Trade_List_RMB__c,
                            //add by rentx 2020-10-13 start 返品时 新数据记录SAP合同号
                            ,ContractNo_text__c/*,ContractNo__c*/
                ContractNo_text__c /*,ContractNo__c*/,
                             // tcm start
                             ,Consumable_order_minor__r.ContractNo__c
                Consumable_order_minor__r.ContractNo__c,
                             // tcm end
                            ,Report_Product_Expiration__c
                Report_Product_Expiration__c
                            //add by rentx 2020-10-13 end
                            ,Intra_Trade_List__c
                            //gzw 手动入库 默认产品单价 20230307
                    FROM    Consumable_order_details2__c
                    WHERE
                            // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                            // (Dealer_Shipment__c = true or Dealer_Saled__c =  true)
                            (Dealer_Shipment__c = true or Dealer_Saled__c =  true or (Dealer_Shipment__c = false and Dealer_Saled__c = false and Lose_Flag__c = true))
                (Dealer_Shipment__c = TRUE
                OR Dealer_Saled__c = TRUE
                OR (Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Lose_Flag__c = TRUE))
                            // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                    AND     Dealer_Info_text__c = :accountName
                    AND     Bar_Code__c in :noboxBarcodeList
                AND Bar_Code__c IN :noboxBarcodeList
                    AND     Arrive_Owner_Work_Location__c =: userWorkLocation
                    AND     Dealer_Returned__c = false
                AND Dealer_Returned__c = FALSE
                    AND     Box_Piece__c = '个'
                    ORDER BY Consumable_ZS_order__c,RemoveBox_No__c];
            ORDER BY Consumable_ZS_order__c, RemoveBox_No__c
        ];
         AggregateResult[] results = [SELECT  Consumable_ZS_order__c,Bar_Code__c,count(Id) recordCount
        AggregateResult[] results = [
            SELECT Consumable_ZS_order__c, Bar_Code__c, count(Id) recordCount
                                      FROM Consumable_order_details2__c 
                                      WHERE Dealer_Arrive__c = true
            WHERE
                Dealer_Arrive__c = TRUE
                                      // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                                      // AND  (Dealer_Shipment__c= true OR  Dealer_Saled__c = true)
                                      AND  (Dealer_Shipment__c= true OR  Dealer_Saled__c = true or(Dealer_Shipment__c = false and Dealer_Saled__c = false and Lose_Flag__c = true))
                AND (Dealer_Shipment__c = TRUE
                OR Dealer_Saled__c = TRUE
                OR (Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Lose_Flag__c = TRUE))
                                      // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                                      AND  Dealer_Returned__c = false
                                      AND  Bar_Code__c in :noboxBarcodeList
                AND Dealer_Returned__c = FALSE
                AND Bar_Code__c IN :noboxBarcodeList
                                      AND  Arrive_Owner_Work_Location__c =: userWorkLocation
                                      AND  Box_Piece__c = '个'
                                      AND Dealer_Info_text__c = :accountName
                                      GROUP BY Consumable_ZS_order__c,Bar_Code__c];
            GROUP BY Consumable_ZS_order__c, Bar_Code__c
        ];
        for(AggregateResult ar: results){               
            String key = '' + ar.get('Consumable_ZS_order__c') + ar.get('Bar_Code__c');
@@ -3228,8 +4017,7 @@
        for(Consumable_order_details2__c details2 : duplicates){
            Boolean found = false;
            for(Consumable_order_details2__c result : distinctOrder){
                if(details2.Consumable_ZS_order__c == result.Consumable_ZS_order__c
                   && details2.Bar_Code__c == result.Bar_Code__c){
                if (details2.Consumable_ZS_order__c == result.Consumable_ZS_order__c && details2.Bar_Code__c == result.Bar_Code__c) {
                    found = true;
                    break;
                }
@@ -3238,7 +4026,8 @@
            if(!found){
                distinctOrder.add(details2);
                if(details2.Box_Piece__c == '个') noboxBarcodeList.add(details2.Bar_Code__c);
                if (details2.Box_Piece__c == '个')
                    noboxBarcodeList.add(details2.Bar_Code__c);
            } 
        }
        return distinctOrder;
@@ -3256,7 +4045,6 @@
        boolean hasLoseGoods = false;
        try{
            if( ShowGoodsofReturnList.size() >0 || consumableInventory.size()>0 ){
                Consumable_order__c Return_Order_Sheet     = new Consumable_order__c();
                Return_Order_Sheet.Name                    ='*';
                Return_Order_Sheet.Order_status__c         = '批准';
@@ -3294,7 +4082,11 @@
                Inventory_Order_Sheet.Order_ProType__c        = userPro_Type;
                insert Inventory_Order_Sheet;
                inventory_Order_id = Inventory_Order_Sheet.id;
                List<Consumable_order__c> consumable_order_Inv = [SELECT Name FROM Consumable_order__c WHERE id =:Inventory_Order_Sheet.id];
                List<Consumable_order__c> consumable_order_Inv = [
                    SELECT Name
                    FROM Consumable_order__c
                    WHERE id = :Inventory_Order_Sheet.id
                ];
                // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                List<Consumable_order_details2__c>   codcList    =   new List<Consumable_order_details2__c>();
@@ -3302,10 +4094,12 @@
                List<Consumable_order_details2__c>   codcorderdetList    =   new List<Consumable_order_details2__c>();
                //返品原因,返品数量检查
                for( ConsumableorderdetailsInfo  codi    :   ShowGoodsofReturnList ){
                    if (codi.esd.Box_Piece__c =='个' && (
                        codi.esd.Rrturn_count__c == null ||
                    if (
                        codi.esd.Box_Piece__c == '个' &&
                        (codi.esd.Rrturn_count__c == null ||
                        String.valueof(codi.esd.Rrturn_count__c) =='' || 
                        codi.esd.Rrturn_count__c <= 0)){
                        codi.esd.Rrturn_count__c <= 0)
                    ) {
                        continue;
                    }
@@ -3313,7 +4107,6 @@
                        codi.esd.Return_reason__c.addError('请补充返品原因');
                        return null;
                    }
                    if(codi.esd.Box_Piece__c=='个' && codi.esd.Rrturn_count__c > 0){
                        String key = '' + codi.esd.Consumable_ZS_order__c + codi.esd.Bar_Code__c;
@@ -3333,10 +4126,12 @@
                    Consumable_order_details2__c codcorderdet = new Consumable_order_details2__c();
                    
                    //单位=个
                    if (codi.esd.Box_Piece__c =='个' && (
                        codi.esd.Rrturn_count__c == null ||
                    if (
                        codi.esd.Box_Piece__c == '个' &&
                        (codi.esd.Rrturn_count__c == null ||
                        String.valueof(codi.esd.Rrturn_count__c) =='' || 
                        codi.esd.Rrturn_count__c <= 0)){
                        codi.esd.Rrturn_count__c <= 0)
                    ) {
                        continue;
                    }
@@ -3345,7 +4140,10 @@
                        Integer cnt = 1;
                        for(Consumable_order_details2__c codctmp    :   consumableorderdetails2Nobox ){
                            if(codctmp.Consumable_ZS_order__c == codi.esd.Consumable_ZS_order__c && codctmp.Bar_Code__c == codi.esd.Bar_Code__c){
                            if (
                                codctmp.Consumable_ZS_order__c == codi.esd.Consumable_ZS_order__c &&
                                codctmp.Bar_Code__c == codi.esd.Bar_Code__c
                            ) {
                                Consumable_order_details2__c esd = codctmp;
                                // esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
                                esd.Return_reason__c                = codi.esd.Return_reason__c;
@@ -3354,16 +4152,18 @@
                                // esd.Return_reason__c                = codi.esd.Return_reason__c;
                                // esd.Return_date__c                  = Date.today();
                                // esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
                                if(codi.esd.Dealer_Saled__c == false && codi.esd.Dealer_Shipment__c == false && codi.esd.Lose_Flag__c == true){
                                if (
                                    codi.esd.Dealer_Saled__c == false &&
                                    codi.esd.Dealer_Shipment__c == false &&
                                    codi.esd.Lose_Flag__c == true
                                ) {
                                    // esd.Lose_Flag__c = false;
                                    esd.Consumable_Inventory_order__c = Inventory_Order_Sheet.id;
                                    conOrderDetail2InList.add(esd);
                                    hasLoseGoods = true;
                                }
                                else{
                                } else {
                                    // esd.Return_date__c                  = Date.today();
                                    esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
                                }
                                // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                                esd.ReturnGs_Uploader_ID__c         = UserInfo.getUserId();
@@ -3387,8 +4187,7 @@
                                codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
                                codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
                                codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
                                //gzw 手动入库 默认产品单价 20230307
                                codcorderdet.Intra_Trade_List_RMB__c     =  (codi.esd.Intra_Trade_List_RMB__c == null || codi.esd.Intra_Trade_List_RMB__c == 0) ? codi.esd.Intra_Trade_List__c : codi.esd.Intra_Trade_List_RMB__c;
                                codcorderdet.Intra_Trade_List_RMB__c = codi.esd.Intra_Trade_List_RMB__c;
                                codcorderdet.RemoveBox_No__c             = codctmp.RemoveBox_No__c;
                                codcorderdet.RemoveBox_date__c           = codctmp.RemoveBox_date__c;
                                codcorderdet.Box_Piece__c                = codctmp.Box_Piece__c;
@@ -3403,7 +4202,6 @@
                                }
                                // tcm end
                                //add by rentx 2020-10-13 end   返品时新数据记录SAP合同号
                                // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                                if(hasLoseGoods){
@@ -3420,18 +4218,19 @@
                                codcorderdet.Agencyinfo_fromSAP__c       = codi.esd.Agencyinfo_fromSAP__c;
                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------1------' + codi.esd.Frist_Storage_Agency__c));
                                codcorderdet.Frist_Storage_Agency__c     = codi.esd.Frist_Storage_Agency__c == null ? codi.esd.Dealer_Info_text__c : codi.esd.Frist_Storage_Agency__c;
                                codcorderdet.Frist_Storage_Agency__c = codi.esd.Frist_Storage_Agency__c == null
                                    ? codi.esd.Dealer_Info_text__c
                                    : codi.esd.Frist_Storage_Agency__c;
                                // 追加首次入库经销商 add by gzw 2020-04-27 end
                                codcorderdetList.add(codcorderdet);
                                codcList.add(   esd    );
                                cnt++;
                                if(cnt > codi.esd.Rrturn_count__c) break;
                            }
                                if (cnt > codi.esd.Rrturn_count__c)
                                    break;
                        }
                    }
                    else{
                    } else {
                        hasReturnGoods = true;
                        //单位=盒
                        //changeinvoiceInfo(codi.esd);
@@ -3445,11 +4244,9 @@
                            codi.esd.Consumable_Inventory_order__c      = Inventory_Order_Sheet.id;
                            conOrderDetail2InList.add(codi.esd);
                            hasLoseGoods = true;
                        }
                        else{
                        } else {
                            // codi.esd.Return_date__c                  = Date.today();
                            codi.esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
                        }
                        // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                        codi.esd.ReturnGs_Uploader_ID__c         = UserInfo.getUserId();
@@ -3470,8 +4267,7 @@
                        codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
                        codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
                        codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
                        //gzw 手动入库 默认产品单价 20230307
                        codcorderdet.Intra_Trade_List_RMB__c     =  (codi.esd.Intra_Trade_List_RMB__c == null || codi.esd.Intra_Trade_List_RMB__c == 0) ? codi.esd.Intra_Trade_List__c : codi.esd.Intra_Trade_List_RMB__c;
                        codcorderdet.Intra_Trade_List_RMB__c = codi.esd.Intra_Trade_List_RMB__c;
                        // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                        if(hasLoseGoods){
                            codcorderdet.loseInventory__c = true;
@@ -3486,7 +4282,9 @@
                        codcorderdet.Agencyinfo_fromSAP__c        = codi.esd.Agencyinfo_fromSAP__c;
                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------2------' + codi.esd.Frist_Storage_Agency__c));
                        codcorderdet.Frist_Storage_Agency__c      = codi.esd.Frist_Storage_Agency__c == null ? codi.esd.Dealer_Info_text__c : codi.esd.Frist_Storage_Agency__c;
                        codcorderdet.Frist_Storage_Agency__c = codi.esd.Frist_Storage_Agency__c == null
                            ? codi.esd.Dealer_Info_text__c
                            : codi.esd.Frist_Storage_Agency__c;
                        // 追加首次入库经销商 add by gzw 2020-04-27 end
                        //add by rentx 2020-10-13 start 返品时新数据记录SAP合同号
@@ -3504,6 +4302,7 @@
                        codcList.add(   codi.esd    );
                    }
                }
                //明细2不存在的对应的到货订单明细 2017-07-05
                Integer i = 1;
                //for(ConsumableorderdetailsInfo ass : consumableInventoryUse){
@@ -3524,8 +4323,7 @@
                    //到货明细
                    codcorderdetail.Name                        = consumable_order_arr[0].Name + '-'+ str;
                    codcorderdetail.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                    codcorderdetail.Intra_Trade_List_RMB__c     = ass.Prod.Intra_Trade_List_RMB__c;
                    //gzw 手动入库 默认产品单价 20230307
                    codcorderdetail.Intra_Trade_List_RMB__c = null;
                    codcorderdetail.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
                    codcorderdetail.Direct_Arrive_Product__c    = true;
                    codcorderdetail.Sterilization_limit__c      = ass.sterilizationlimitDate;
@@ -3562,11 +4360,9 @@
                    retorddetail.Consumable_Return_order__c  = Return_Order_Sheet.id;
                    // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 end
                    retorddetail.Name                        = consumable_order_ret[0].Name + '-'+ str;
                    retorddetail.RecordTypeId                = System.Label.RT_ConOrderDetail2_Return;
                    retorddetail.Intra_Trade_List_RMB__c     = ass.Prod.Intra_Trade_List_RMB__c;
                    //gzw 手动入库 默认产品单价 20230307
                    retorddetail.Intra_Trade_List_RMB__c = null;
                    retorddetail.Dealer_Info_IF__c           = accountid;
                    retorddetail.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
                    retorddetail.Direct_Arrive_Product__c    = true;
@@ -3624,12 +4420,10 @@
                        // return null;
                    }
                    // WYIN-BPE3T4 虚拟盘点单 update by vivek 2020-05-11 start
                }
                else{
                } else {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'没有需要登录的返品'));
                    return null;
                }
            }else{
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'没有需要登录的返品'));
                return null;
@@ -3739,7 +4533,6 @@
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();  
            }
        }
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
            canEdit = false;
@@ -3754,7 +4547,6 @@
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();  
            }
        }
        public ConsumableorderdetailsInfo(Product2__c e,List<String> barinfoL) {
@@ -3782,7 +4574,6 @@
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();  
            }
        }
        public ConsumableorderdetailsInfo(Product2__c e) {
            Prod = e;
force-app/main/default/classes/CPL003Rest.cls
@@ -1,16 +1,15 @@
@RestResource(urlMapping='/CPL003/*')
global with sharing class CPL003Rest {
    global class GeDatas {
        webservice NFMUtil.Monitoring Monitoring;
        webservice CPL003Rest.GeData[] Inventory;
        webService NFMUtil.Monitoring Monitoring;
        webService CPL003Rest.GeData[] Inventory;
    }
    global class GeData {
        webservice String MaterialNumber; //产品编码(产品代码)
        webservice String ItemQuantity;   //OpenPO和库存的总数量
        webService String MaterialNumber; //产品编码(产品代码)
        webService String ItemQuantity; //OpenPO和库存的总数量
        webservice String Area;    //区域(待定)
        webService String Area; //区域(待定)
        //webservice String other1;
        //webservice String other2;
        //webservice String other3;
@@ -46,7 +45,6 @@
        return;
    }
    @future
    global static void executefuture(String rowData_Id) {
        main(rowData_Id);
@@ -54,8 +52,29 @@
    global static void main(String rowData_Id) {
        Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
        BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,retry_cnt__c from BatchIF_Log__c where RowDataFlg__c = true and Id = :rowData_Id];
        MDMITMWebService.isRunning = true;
        BatchIF_Log__c rowData = [
            SELECT
                Id,
                Name,
                Log__c,
                ErrorLog__c,
                Log2__c,
                Log3__c,
                Log4__c,
                Log5__c,
                Log6__c,
                Log7__c,
                Log8__c,
                Log9__c,
                Log10__c,
                Log11__c,
                Log12__c,
                MessageGroupNumber__c,
                retry_cnt__c
            FROM BatchIF_Log__c
            WHERE RowDataFlg__c = TRUE AND Id = :rowData_Id
        ];
        //MDMITMWebService.isRunning = true; //Commented By Li Jun 20230428
        String logstr = rowData.MessageGroupNumber__c + ' start\n';
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = 'CPL003';
@@ -78,14 +97,18 @@
            List<String> materialNumberList = new List<String>();
            for (GeData GeData : itemMasterList) {
                if (String.isBlank(GeData.MaterialNumber))  continue;
                if (String.isBlank(GeData.ItemQuantity))  continue;
                if (String.isBlank(GeData.MaterialNumber))
                    continue;
                if (String.isBlank(GeData.ItemQuantity))
                    continue;
                materialNumberList.add(GeData.MaterialNumber);
            }
            List<Product2> product2List = [select Id, ProductCode, StorageStatusNo__c
                                             from Product2
                                            where ProductCode in :materialNumberList ];
            List<Product2> product2List = [
                SELECT Id, ProductCode, StorageStatusNo__c
                FROM Product2
                WHERE ProductCode IN :materialNumberList
            ];
            
            Map<String,Product2> product2Map = new Map<String,Product2>();
            for (Product2 product2 : product2List) {
@@ -96,7 +119,6 @@
            Map<String,Product2> prdUpdateMap = new Map<String, Product2>();
            for (GeData GeData : itemMasterList) {
                if (String.isBlank(GeData.MaterialNumber)) {
                    iflog.ErrorLog__c += 'MaterialNumber is required.\n';
                    continue;
@@ -106,14 +128,14 @@
                    Product2 product = product2Map.get(GeData.MaterialNumber);
                    product.StorageStatusNo__c = Double.valueOf(GeData.ItemQuantity);
                    upsertProList.add(product);
                } else {
                    iflog.ErrorLog__c += 'This MaterialNumber [ ' + GeData.MaterialNumber + ' ] is not Exist.\n';
                    continue;
                }
            }
            if(upsertProList.size() > 0)    upsert upsertProList;
            if (upsertProList.size() > 0)
                upsert upsertProList;
            logstr += '\nend';
            rowData.retry_cnt__c=0;
@@ -122,13 +144,20 @@
            Database.rollback(sp);
            logstr += '\n' + ex.getMessage();
            iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
            if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
            if (rowData.retry_cnt__c == null)
                rowData.retry_cnt__c = 0;
            if (rowData.retry_cnt__c < batch_retry_max_cnt){
                rowData.retry_cnt__c++;
                LogAutoSendSchedule.assignOneMinute();
            }
            if (rowData.retry_cnt__c >= batch_retry_max_cnt){
                rowData.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowData.ErrorLog__c+'错误次数已经超过自动收信设定的最大次数,请手动收信';
                rowData.ErrorLog__c =
                    ex.getMessage() +
                    '\n' +
                    ex.getStackTraceString() +
                    '\n' +
                    rowData.ErrorLog__c +
                    '错误次数已经超过自动收信设定的最大次数,请手动收信';
            }
        }
force-app/main/default/classes/DNUpsertBatch.cls
@@ -14,23 +14,63 @@
    global Database.QueryLocator start(Database.BatchableContext bc) {
        if( string.isBlank( rowData_Id )){
            return Database.getQueryLocator(
                [Select Id, Name, Log__c, ErrorLog__c, Log2__c,
                 Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c,
                 Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,
                 retry_cnt__c,DN_retry_cnt__c, CreatedDate
                 from BatchIF_Log__c
                 where RowDataFlg__c = true
                 and IsUpsertDN__c = true
                 and (DN_retry_cnt__c = null
                     or (DN_retry_cnt__c != 0 and DN_retry_cnt__c < 3))]);
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        retry_cnt__c,
                        DN_retry_cnt__c,
                        CreatedDate
                    FROM BatchIF_Log__c
                    WHERE
                        RowDataFlg__c = TRUE
                        AND IsUpsertDN__c = TRUE
                        AND (DN_retry_cnt__c = NULL
                        OR (DN_retry_cnt__c != 0
                        AND DN_retry_cnt__c < 3))
                ]
            );
        }else{
            return Database.getQueryLocator([Select Id, Name, Log__c, ErrorLog__c, Log2__c,
                                             Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c,
                                             Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,
                                             retry_cnt__c ,DN_retry_cnt__c,CreatedDate
                                             from BatchIF_Log__c
                                             where RowDataFlg__c = true
                                             and Id = :rowData_Id ]);
            return Database.getQueryLocator(
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        retry_cnt__c,
                        DN_retry_cnt__c,
                        CreatedDate
                    FROM BatchIF_Log__c
                    WHERE RowDataFlg__c = TRUE AND Id = :rowData_Id
                ]
            );
        }
    }
    global void execute(Database.BatchableContext BC, List<BatchIF_Log__c> rowDataList) {
@@ -69,18 +109,18 @@
        iflog.ErrorLog__c = '';
        insert iflog;
        String rowDataStr = NFMUtil.getRowDataStr(rowData);
        List<NFM110Rest.GeneralData> generalDataList =
            (List<NFM110Rest.GeneralData>) JSON.deserialize(rowDataStr, List<NFM110Rest.GeneralData>.class);
        List<NFM110Rest.GeneralData> generalDataList = (List<NFM110Rest.GeneralData>) JSON.deserialize(
            rowDataStr,
            List<NFM110Rest.GeneralData>.class
        );
        if (generalDataList == null || generalDataList.size() == 0) {
            return;
        }
        // 电子签收单 start 优化原有select
        list<account> olympusAcclist =
            [select Id , ParentId ,AgentCode_Ext__c
             from Account
             where AgentCode_Ext__c = '9999900' or
             AgentCode_Ext__c = '9999999' or
             AgentCode_Ext__c = '9999901'
        list<account> olympusAcclist = [
            SELECT Id, ParentId, AgentCode_Ext__c
            FROM Account
            WHERE AgentCode_Ext__c = '9999900' OR AgentCode_Ext__c = '9999999' OR AgentCode_Ext__c = '9999901'
        ];
        Account ocm ,olympus,olympus_return;
        for(Account tempAcc : olympusAcclist){
@@ -145,9 +185,7 @@
                        //根据数据传的样式决定
                    }
                }
                if (!(infoH.ReturnMark == null || infoH.ReturnMark  == ''
                      || infoH.ReturnMark == '1' || infoH.ReturnMark == '3'
                     )) {
                if (!(infoH.ReturnMark == null || infoH.ReturnMark == '' || infoH.ReturnMark == '1' || infoH.ReturnMark == '3')) {
                         // ReturnMark = 上記以外の場合 Errorメッセージ出力
                         continue;
                     }
@@ -157,17 +195,12 @@
                    // CHAN-BBLAAP start
                    string Product_Serial_No = '';
                    if (dnInfo.SorLMark == 'S') {
                        Product_Serial_No =
                            dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo;
                        Product_Serial_No = dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo;
                    } else {
                        Product_Serial_No  =
                            dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo
                            + '(' + dnInfo.TracingCode + ')';
                        Product_Serial_No = dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo + '(' + dnInfo.TracingCode + ')';
                    }
                    // CHAN-BBLAAP end
                    if (dnInfo.OTCode == null || dnInfo.OTCode == ''
                        || dnInfo.SerialNoorLotNo == null || dnInfo.SerialNoorLotNo == ''
                       ) {
                    if (dnInfo.OTCode == null || dnInfo.OTCode == '' || dnInfo.SerialNoorLotNo == null || dnInfo.SerialNoorLotNo == '') {
                           // 商品コードがない場合、処理と飛ばす
                           continue;
                       }
@@ -178,33 +211,55 @@
                    productSerialNoList.add(dnInfo.SerialNoorLotNo);
                    productSerialNoList.add(dnInfo.SerialNoorLotNo + '(' + dnInfo.TracingCode + ')');
                }
            }
            // 电子签收单 start 额外检索end user
             List<Account> accList = [select Id, Name, Management_Code__c, Department_Class__c, Hospital__c, ParentId,
                                     RecordType.DeveloperName, Department_Name__c, OCM_man_province_txt__c
                                     from Account
                                     where Management_Code__c in :managementCodeList];
            List<Account> accList = [
                SELECT
                    Id,
                    Name,
                    Management_Code__c,
                    Department_Class__c,
                    Hospital__c,
                    ParentId,
                    RecordType.DeveloperName,
                    Department_Name__c,
                    OCM_man_province_txt__c
                FROM Account
                WHERE Management_Code__c IN :managementCodeList
            ];
            // HHOA-BLC8S6 update by vivek 2020-02-13 end
            Map<String, Account> accsMap = new Map<String, Account>();
            for (Account acc : accList) {
                accsMap.put(acc.Management_Code__c, acc);
            }
            Map<String, Opportunity> oppMap = new Map<String, Opportunity>();
            List<Opportunity> oppList = [Select Id, Purchase_Type__c, Opportunity_No__c,Strategic_department_Class_Name__c,
                                         Sales_Root__c, SAP_Province__c, Trade__c, Agency1__c,Agency1__r.Name,
                                         Agency1__r.OCM_man_province_txt__c, Opportunity_Category__c,
                                         OCM_man_province_cus__c, Sales_assistant_name_text__c
            List<Opportunity> oppList = [
                SELECT
                    Id,
                    Purchase_Type__c,
                    Opportunity_No__c,
                    Strategic_department_Class_Name__c,
                    Sales_Root__c,
                    SAP_Province__c,
                    Trade__c,
                    Agency1__c,
                    Agency1__r.Name,
                    Agency1__r.OCM_man_province_txt__c,
                    Opportunity_Category__c,
                    OCM_man_province_cus__c,
                    Sales_assistant_name_text__c,
                                        // 电子签收单 start
                                        // 临时使用 用作试点经销商
                                        ,Agency1__r.EsignTestAccount__c,Agency1__r.EsignTestAccountType__c
                    Agency1__r.EsignTestAccount__c,
                    Agency1__r.EsignTestAccountType__c,
                                        // 电子签收单 end
                                        //集中采购询价 精琢技术 wql  start
                                        ,Group_purchase_PCL__c
                    Group_purchase_PCL__c,
                                        //集中采购询价 精琢技术 wql  end
                                        ,Is_Corrosion__c
                                         From Opportunity Where Opportunity_No__c IN :inquiryNoList];
                    Is_Corrosion__c
                FROM Opportunity
                WHERE Opportunity_No__c IN :inquiryNoList
            ];
            for (Opportunity opp : oppList) {
                oppMap.put(opp.Opportunity_No__c, opp);
@@ -212,7 +267,7 @@
            // 检索出DN 并生成DN Map
            Boolean flg=true;
            map <string, Statu_Achievements_DN__c> DNMap = new  map <string, Statu_Achievements_DN__c>();
            map<string, Statu_Achievements_DN__c> DNMap = new Map<string, Statu_Achievements_DN__c>();
            List<Statu_Achievements_DN__c> DNList = GetDNList(DNNoSet);
                // [select id, Name,
                //  DeliveryDate_Raw__c,
@@ -254,31 +309,56 @@
            List<DNdetail> insertDNdetailList = new List<DNdetail>();
            // CHAN-BBLAAP  end
            List<Statu_Achievements__c> boList = [select Id, Name
                                                  from Statu_Achievements__c
                                                  where Name in :soNoList and OverviewStatus__c <> '无效合同'];
            List<Statu_Achievements__c> boList = [
                SELECT Id, Name
                FROM Statu_Achievements__c
                WHERE Name IN :soNoList AND OverviewStatus__c != '无效合同'
            ];
            Map<String, String> boMap = new Map<String, String>();
            for (Statu_Achievements__c bo : boList) {
                boMap.put(bo.Name, bo.Id);
            }
            
            List<Product2> prdList = [select Id, Name, ProductCode, ProductCode_Ext__c, MDM_Model_No__c
                                      from Product2
                                      where ProductCode_Ext__c in :productCodeList];
            List<Product2> prdList = [
                SELECT Id, Name, ProductCode, ProductCode_Ext__c, MDM_Model_No__c
                FROM Product2
                WHERE ProductCode_Ext__c IN :productCodeList
            ];
            Map<String, Product2> prdsMap = new Map<String, Product2>();
            for (Product2 prd : prdList) {
                prdsMap.put(prd.ProductCode_Ext__c, prd);
            }
            List<Asset> astList = [select Id, Name, Product2.ProductCode, Product2.Dealer_special_Object__c , Product2.Dealer_Object__c,
                                   SerialNumber, Product_Serial_No__c, Repair_Count__c, TracingCode__c,
                                   Product2Id, AccountId, Account.Management_Code__c, Department_Class__c, Hospital__c,
                                   Posting_Date__c, InstallDate, SLMark__c, MDM_Model_No__c, OT_CODE__c,
                                   Guarantee_period_for_products__c, Installation_Site__c, Delete_Flag__c, Return_Flag__c,
                                   Extend_Gurantee_DateTo__c, guarantee_period__c, Proviston_period__c
                                   from Asset
                                   where SerialNumber in :productSerialNoList
                                   and IsCompetitorProduct = false
                                   and Information_From__c <> '失单'];
            List<Asset> astList = [
                SELECT
                    Id,
                    Name,
                    Product2.ProductCode,
                    Product2.Dealer_special_Object__c,
                    Product2.Dealer_Object__c,
                    SerialNumber,
                    Product_Serial_No__c,
                    Repair_Count__c,
                    TracingCode__c,
                    Product2Id,
                    AccountId,
                    Account.Management_Code__c,
                    Department_Class__c,
                    Hospital__c,
                    Posting_Date__c,
                    InstallDate,
                    SLMark__c,
                    MDM_Model_No__c,
                    OT_CODE__c,
                    Guarantee_period_for_products__c,
                    Installation_Site__c,
                    Delete_Flag__c,
                    Return_Flag__c,
                    Extend_Gurantee_DateTo__c,
                    guarantee_period__c,
                    Proviston_period__c
                FROM Asset
                WHERE SerialNumber IN :productSerialNoList AND IsCompetitorProduct = FALSE AND Information_From__c != '失单'
            ];
            Map<String, Asset> astsMap = new Map<String, Asset>();
            for (Asset ast : astList) {
                astsMap.put(ast.MDM_Model_No__c + ast.SerialNumber, ast);
@@ -291,12 +371,11 @@
            Map < String, String > provinceGIMap = new Map< String, String > ();
            //检索OCSM管理省对象
            //集中采购询价 增加检索助理 
            List < OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c,Window1__c   from OCM_Management_Province__c ];
            List<OCM_Management_Province__c> ompList = [SELECT id, Name, SalesManage__c, GI_assistant__c FROM OCM_Management_Province__c];
            //存放map<省,担当>
            for (OCM_Management_Province__c omp: ompList) {
                provinceOwnerMap.put(omp.Name, omp.SalesManage__c);
                //provinceGIMap.put(omp.Name,omp.GI_assistant__c); //Commented by Li Jun 20230420
                provinceGIMap.put(omp.Name, omp.Window1__c);// Add By Li Jun 更新 签收单的【营业助理】值,从OCSM管理省对应的【营业窗口】字段获取
                provinceGIMap.put(omp.Name, omp.GI_assistant__c);
            }
            // 电子签收单 end
@@ -320,33 +399,58 @@
                    continue;
                }
                if (infoH.DnInformation == null || infoH.DnInformation.size() == 0) {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] DnInformation is required. This DN is skipped.\n';
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] DnInformation is required. This DN is skipped.\n';
                    continue;
                }
                if (infoH.EndUserNo == null || infoH.EndUserNo  == '') {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] EndUserNo is required. This DN is skipped.\n';
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] EndUserNo is required. This DN is skipped.\n';
                    continue;
                }
                if (accsMap.get(infoH.EndUserNo) == null) {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] EndUserNo[' + infoH.EndUserNo + ']NotExist. This DN is skipped.\n';
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] EndUserNo[' +
                        infoH.EndUserNo +
                        ']NotExist. This DN is skipped.\n';
                    continue;
                } else if (accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'HP'
                           && accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'Agency'
                           && accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'AgencyContract') {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] EndUserNo[' + infoH.EndUserNo + ']Is Not HP or Agency(Contract). This DN is skipped.\n';
                } else if (
                    accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'HP' &&
                    accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'Agency' &&
                    accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'AgencyContract'
                ) {
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] EndUserNo[' +
                        infoH.EndUserNo +
                        ']Is Not HP or Agency(Contract). This DN is skipped.\n';
                    continue;
                }
                Statu_Achievements_DN__c tempSADN =
                    DNMap.get(infoH.DeliveryNote);
                Statu_Achievements_DN__c tempSADN = DNMap.get(infoH.DeliveryNote);
                if (infoH.DeliveryNote != null) {
                    if (tempSADN == null) {
                        tempSADN = new Statu_Achievements_DN__c();
                        tempSADN.Statu_Achievements__c = null;
                        tempSADN = SetSADN(tempSADN, infoH, boMap, oppMap, accsMap , provinceOwnerMap,provinceGIMap);
                        checkSA( tempSADN, UpsertDNList, iflog, infoH );
                    } else {
                        if (infoH.SoNo != tempSADN.SoNo_Raw__c ||
                        if (
                            infoH.SoNo != tempSADN.SoNo_Raw__c ||
                            infoH.InquiryNo != tempSADN.InquiryNo_Raw__c ||
                            infoH.ReturnMark != tempSADN.ReturnMark_Raw__c ||
                            infoH.DeliveryDate != tempSADN.DeliveryDate_Raw__c ||
@@ -356,8 +460,7 @@
                           ) {
                               string SADNID = tempSADN.id;
                               // 电子签收单  额外增加营业管理部担当赋值 start
                               tempSADN = SetSADN(tempSADN, infoH, boMap,
                               oppMap,accsMap, provinceOwnerMap,provinceGIMap);
                            tempSADN = SetSADN(tempSADN, infoH, boMap, oppMap, accsMap, provinceOwnerMap, provinceGIMap);
                               // 电子签收单  额外增加营业管理部担当赋值 end
                               tempSADN.id = SADNID;
                               checkSA( tempSADN, UpsertDNList, iflog, infoH );
@@ -377,10 +480,13 @@
                    }
                    //  CHAN-BBLAAP 插入保有设备明细时插入对应DN start
                    boolean tempReturnFlg = infoH.ReturnMark == '1' ? true : false;
                    DNdetail tempDNdetail
                        = SetSADNDetails(infoH.DeliveryNote, tempReturnFlg, dnInfo, ast,
                                         dnInfo.SerialNoorLotNo != null && dnInfo.SerialNoorLotNo.equals('.') ?
                                         tempDNdetailNumber++ : tempDNdetailNumber);
                    DNdetail tempDNdetail = SetSADNDetails(
                        infoH.DeliveryNote,
                        tempReturnFlg,
                        dnInfo,
                        ast,
                        dnInfo.SerialNoorLotNo != null && dnInfo.SerialNoorLotNo.equals('.') ? tempDNdetailNumber++ : tempDNdetailNumber
                    );
                    insertDNdetailList.add(tempDNdetail);
                }
            }
@@ -424,10 +530,9 @@
                DNMap.put(dn.Name, dn);
            }
            list<Statu_Achievements_DN_details__c> insertSADNdetailList
                = new  list<Statu_Achievements_DN_details__c>();
            list<Statu_Achievements_DN_details__c> insertSADNdetailList = new List<Statu_Achievements_DN_details__c>();
            //电子签收单 虚进虚出 tracingcode为空不生成签收单 精琢技术 2020/12/08 start
             map <string, Statu_Achievements_DN__c> DNRestructureMap = new  map <string, Statu_Achievements_DN__c>();
            map<string, Statu_Achievements_DN__c> DNRestructureMap = new Map<string, Statu_Achievements_DN__c>();
            //电子签收单 虚进虚出 tracingcode为空不生成签收单 精琢技术 2020/12/08 end
            for (DNdetail tempDNd : insertDNdetailList) {
                if (DNMap.containskey(tempDNd.DeliveryNote)) {
@@ -442,21 +547,18 @@
                    if(tempSADN.ACC_Text__c != 'Y'){
                        if(String.isBlank(tempDNd.DNd.TracingCode_Raw__c)){
                            tempSADN.ACC_Text__c = 'Y';
                        }
                    }
                    DNRestructureMap.put(tempSADN.Name, tempSADN);
                    //电子签收单 虚进虚出 tracingcode为空不生成签收单 精琢技术 2020/12/08 end
                }
            }
            List<Statu_Achievements_DN_details__c> DNdetailList =
                [SELECT Id
            List<Statu_Achievements_DN_details__c> DNdetailList = [
                SELECT Id
                 FROM Statu_Achievements_DN_details__c
                 where Statu_Achievements_DN__r.Name in: DNMap.keySet()];
                WHERE Statu_Achievements_DN__r.Name IN :DNMap.keySet()
            ];
            if (DNdetailList.size() > 0 && !System.Test.isRunningTest()) {
                delete DNdetailList;
@@ -466,13 +568,12 @@
            }
            // 电子签收单  2020/07/17 start
            // 检索出签收单,并生成签收单map key 为DN号
            map <string, eSignForm__c> eSFMap = new  map <string, eSignForm__c>();
            List<eSignForm__c> eSFList =
                [select id, DNName__c,
                Hazardous_Chemicals__c,
                 Statu_Achievements__c,Statu_Achievements_DN__c
                 from eSignForm__c where
                 DNName__c in: DNNoSet];
            map<string, eSignForm__c> eSFMap = new Map<string, eSignForm__c>();
            List<eSignForm__c> eSFList = [
                SELECT id, DNName__c, Hazardous_Chemicals__c, Statu_Achievements__c, Statu_Achievements_DN__c
                FROM eSignForm__c
                WHERE DNName__c IN :DNNoSet
            ];
            for (eSignForm__c eSF : eSFList) {
                eSFMap.put(eSF.DNName__c, eSF);
            }
@@ -484,28 +585,24 @@
                upsert UpsertESFList;
            }
            // key 为 对应DN的ID
            map <string, eSignForm__c> eSFAllMap = new map <string, eSignForm__c> ();
            map<string, eSignForm__c> eSFAllMap = new Map<string, eSignForm__c>();
            for( eSignForm__c tempeSignForm : UpsertESFList){
                eSFAllMap.put(tempeSignForm.DNName__c,tempeSignForm);
            }
            // 检索现有签收单明细,并生成签收单明细map key 为DN号 + 产品OTCode
            map <string, eSignFormLineItem__c> eSFLMap = new  map <string, eSignFormLineItem__c>();
            List<eSignFormLineItem__c> eSFLList =
                [select id,DNProductNo__c,
                 Count__c,Product2__c,eSignForm__c
                 , CaseNumber__c
                 from eSignFormLineItem__c
                 where eSignForm__r.DNName__c in: DNNoSet
            map<string, eSignFormLineItem__c> eSFLMap = new Map<string, eSignFormLineItem__c>();
            List<eSignFormLineItem__c> eSFLList = [
                SELECT id, DNProductNo__c, Count__c, Product2__c, eSignForm__c, CaseNumber__c
                FROM eSignFormLineItem__c
                WHERE eSignForm__r.DNName__c IN :DNNoSet
                ];
            for (eSignFormLineItem__c eSFL : eSFLList) {
                eSFL.Count__c = 0;
                eSFLMap.put(eSFL.DNProductNo__c, eSFL);
            }
            // 构造签收单明细
            list<eSignFormLineItem__c> UpsertESFLList =
                SetupeSignFormLineItems( insertSADNdetailList, eSFLMap , eSFAllMap, prdsMap);
            list<eSignFormLineItem__c> UpsertESFLList = SetupeSignFormLineItems(insertSADNdetailList, eSFLMap, eSFAllMap, prdsMap);
            if(UpsertESFLList.size() > 0){
                upsert UpsertESFLList;
            }
@@ -515,19 +612,25 @@
                throw new ControllerUtil.myException('测试错误!');
            }
            // 电子签收单  2020/07/17 end
        } catch (Exception ex) {
            Database.rollback(sp);
            logstr += '\n' + ex.getMessage();
             rowData.IsUpsertDN__c = true;
            iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
            if (rowData.DN_retry_cnt__c == null) rowData.DN_retry_cnt__c = 0;
            if (rowData.DN_retry_cnt__c == null)
                rowData.DN_retry_cnt__c = 0;
            if (rowData.DN_retry_cnt__c < batch_retry_max_cnt) {
                rowData.DN_retry_cnt__c++;
                DNUpsertSchedule.assignOneMinute();
            }
            if (rowData.DN_retry_cnt__c >= batch_retry_max_cnt) {
                rowData.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowData.ErrorLog__c + '错误次数已经超过自动收信设定的最大次数,请手动收信';
                rowData.ErrorLog__c =
                    ex.getMessage() +
                    '\n' +
                    ex.getStackTraceString() +
                    '\n' +
                    rowData.ErrorLog__c +
                    '错误次数已经超过自动收信设定的最大次数,请手动收信';
            }
        }
@@ -540,12 +643,13 @@
            iflog.ErrorLog__c = iflog.ErrorLog__c.subString(0, 32760) + ' ...';
        }
        update iflog;
    }
    //优化两次sql查询 thh 2021-11-02 start
    private static list<Statu_Achievements_DN__c> GetDNList(Set<String> DNNoSet){
        List<Statu_Achievements_DN__c> DNList =
                [select id, Name,
        List<Statu_Achievements_DN__c> DNList = [
            SELECT
                id,
                Name,
                 DeliveryDate_Raw__c,
                 DeliveryNote_Raw__c,
                 DepartmentNo_Raw__c,
@@ -555,49 +659,33 @@
                 SoNo_Raw__c,
                 Opportunity__c,
                 Statu_Achievements__c,
                 endUser__c
                endUser__c,
                 //电子签收单试点用户赋值
                 ,endUser__r.RecordType.Name
                endUser__r.RecordType.Name,
                 // 电子签收单 start 
                 , Sales_assistant_name_text__c,
                 RC_Manager__c,ReturnMark__c
                Sales_assistant_name_text__c,
                RC_Manager__c,
                ReturnMark__c,
                 // 试点用户,届时需要删掉
                 , EsignTestAccount__c
                EsignTestAccount__c,
                 // 电子签收单  end
                 //ET召回品不生成签收单 start
                , ETRecalledProducts__c
                ETRecalledProducts__c,
                 //ET召回品不生成签收单 end
                 //acc标识 start
                 ,ACC_Text__c,
                ACC_Text__c,
                 Is_Corrosion__c,
                 //无偿出库标识 thh 2021-11-01 start
                 Statu_Achievements__r.orderType__c 
                 //无偿出库标识 thh 2021-11-01 end
                 //acc标识 end
                 //Add by Li Jun 20230420 start
                 ,Opportunity__r.OCM_man_province_cus__c
                 //Add By Li Jun 20230420 end
                 from Statu_Achievements_DN__c where
                 Name in: DNNoSet];
            FROM Statu_Achievements_DN__c
            WHERE Name IN :DNNoSet
        ];
        return DNList;
    }
    global void finish(Database.BatchableContext BC) {
    }
    //Add By Li Jun 0420 Start query management province
    private static Map<String,OCM_Management_Province__c> provinceManagementMap{set;get;}
    public static Map<String,OCM_Management_Province__c> getManagementProvince(){
        if(provinceManagementMap !=null && provinceManagementMap.keySet().size()>0 ){
            return provinceManagementMap;
        }
        provinceManagementMap = new Map<String,OCM_Management_Province__c>();
        List <OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c,Window1__c   from OCM_Management_Province__c];
        for (OCM_Management_Province__c omp: ompList) {
            provinceManagementMap.put(omp.Name,omp);
        }
        return provinceManagementMap;
    }
      //Add By Li Jun 0420 End
    /* 构建签收单:
     * eSFMap 是系统里面现有的签收单
     * key 为 DN号;
@@ -605,7 +693,7 @@
     */
    @TestVisible
    private static list<eSignForm__c> SetupeSignForm(map <string, eSignForm__c> eSFMap , list<Statu_Achievements_DN__c> DNList){
        list<eSignForm__c> UpsertESFList = new list<eSignForm__c> ();
        list<eSignForm__c> UpsertESFList = new List<eSignForm__c>();
        for(Statu_Achievements_DN__c tempDN:DNList ){
            // 获取现有签收单
            eSignForm__c tempeSF = eSFMap.get(tempDN.Name);
@@ -614,21 +702,14 @@
            }
            // 签收单名字 为: DN号-发货日年月日
            string datestr = tempDN.DeliveryDate_Raw__c == null?
            Date.today().format().ReplaceAll('/', ''):
            tempDN.DeliveryDate_Raw__c ;
            string datestr = tempDN.DeliveryDate_Raw__c == null ? Date.today().format().ReplaceAll('/', '') : tempDN.DeliveryDate_Raw__c;
            tempeSF.Name = string.valueof(integer.valueOf(tempDN.Name)) + '-' +datestr;
            
            tempeSF.DNName__c = tempDN.Name;
            tempeSF.Statu_Achievements__c = tempDN.Statu_Achievements__c;
            tempeSF.Statu_Achievements_DN__c = tempDN.ID;
            //Updated By Li Jun 20230420 start
            //tempeSF.Sales_assistant_name_text__c = tempDN.Sales_assistant_name_text__c;
            tempeSF.Sales_assistant_name_text__c = tempDN.Opportunity__c != null && tempDN.Opportunity__r.OCM_man_province_cus__c != '' && getManagementProvince().containsKey(tempDN.Opportunity__r.OCM_man_province_cus__c)?
                                                    getManagementProvince().get(tempDN.Opportunity__r.OCM_man_province_cus__c).Window1__c: null;
            tempeSF.Sales_assistant_name_text__c = tempDN.Sales_assistant_name_text__c;
            tempeSF.RC_Manager__c = tempDN.RC_Manager__c;
            //Updated By Li Jun 20230420 end
            //生成签收单时,给是否无偿出库赋值  精琢技术 thh 2021-10-15 start
            if(tempDN.Statu_Achievements__r.orderType__c == 'ZM16'){
                tempeSF.isFreeDelivery__c = true;
@@ -637,9 +718,16 @@
            // 经销商试点用户
            //电子签收单 虚进虚出 明细为racing code 为空的 不生成签收单 20201207 精琢技术 start
            if(tempDN.EsignTestAccount__c && !tempDN.ETRecalledProducts__c&&!tempDN.ReturnMark__c&&(tempDN.ACC_Text__c!='Y'||(tempDN.ACC_Text__c=='Y'&&tempDN.Is_Corrosion__c))){//&&tempDN.Is_Corrosion__c
            if (
                tempDN.EsignTestAccount__c &&
                !tempDN.ETRecalledProducts__c &&
                !tempDN.ReturnMark__c &&
                (tempDN.ACC_Text__c != 'Y' || (tempDN.ACC_Text__c == 'Y' && tempDN.Is_Corrosion__c))
            ) {
                //&&tempDN.Is_Corrosion__c
                //添加危化品标识
                if(tempDN.ACC_Text__c=='Y'&&tempDN.Is_Corrosion__c){//&&tempDN.Is_Corrosion__c
                if (tempDN.ACC_Text__c == 'Y' && tempDN.Is_Corrosion__c) {
                    //&&tempDN.Is_Corrosion__c
                    tempeSF.Hazardous_Chemicals__c=true;
                }
                UpsertESFList.add(tempeSF);
@@ -663,12 +751,13 @@
    @TestVisible
    private static list<eSignFormLineItem__c> SetupeSignFormLineItems(
        list<Statu_Achievements_DN_details__c> insertSADNdetailList,
        map <string, eSignFormLineItem__c> eSFLMap ,map <string, eSignForm__c> eSFAllMap,
        Map<String, Product2> prdsMap){
        map<string, eSignFormLineItem__c> eSFLMap,
        map<string, eSignForm__c> eSFAllMap,
        Map<String, Product2> prdsMap
    ) {
            // key 是 DN号 + 箱号 + 产品OTCode
            for(Statu_Achievements_DN_details__c tempDNDetail : insertSADNdetailList){
                string key = tempDNDetail.DNName__c + '-' +
                tempDNDetail.CaseNumber__c + '-' + tempDNDetail.OTCode_Raw__c;
            string key = tempDNDetail.DNName__c + '-' + tempDNDetail.CaseNumber__c + '-' + tempDNDetail.OTCode_Raw__c;
                //获取现有签收单明细
                eSignFormLineItem__c tempeSignFormLineItem = eSFLMap.get(key);
                if( tempeSignFormLineItem == null){
@@ -684,8 +773,13 @@
                }
                // Double CaseNumber = tempDNDetail.CaseNumber__c == null ? tempDNDetail.CaseNumber__c : Double.valueOf(tempDNDetail.CaseNumber__c);
                tempeSignFormLineItem.DNProductNo__c = key ;
                tempeSignFormLineItem.Name  = tempDNDetail.CaseNumber__c == null ? String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) + '-' +  tempDNDetail.OTCode_Raw__c:String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) + '-' +
                tempDNDetail.CaseNumber__c + '-' + tempDNDetail.OTCode_Raw__c;
            tempeSignFormLineItem.Name = tempDNDetail.CaseNumber__c == null
                ? String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) + '-' + tempDNDetail.OTCode_Raw__c
                : String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) +
                  '-' +
                  tempDNDetail.CaseNumber__c +
                  '-' +
                  tempDNDetail.OTCode_Raw__c;
                tempeSignFormLineItem.Product2__c = prdsMap.get(tempDNDetail.OTCode_Raw__c).ID;
                if(eSFAllMap.containskey(tempDNDetail.DNName__c)){
                    tempeSignFormLineItem.eSignForm__c = eSFAllMap.get(tempDNDetail.DNName__c).ID;
@@ -702,7 +796,8 @@
        Map<String, Opportunity> oppMap,
      Map<String, Account> accsMap, 
        Map < String, String > provinceOwnerMap,
        Map < String, String > provinceGIMap) {
        Map<String, String> provinceGIMap
    ) {
            tempSADN.SoNo_Raw__c = infoH.SoNo;
            tempSADN.InquiryNo_Raw__c = infoH.InquiryNo ;
            tempSADN.ReturnMark_Raw__c = infoH.ReturnMark ;
@@ -754,22 +849,17 @@
                    tempSADN.Is_Corrosion__c=opp.Is_Corrosion__c;
                    // 电子签收单  赋值营业助理和营业管理部担当 start
                    //集中采购的询价 精琢技术 wql 2020/01/11 start 
                    //Add By Li Jun 20230420 Start
                    tempSADN.Sales_assistant_name_text__c =opp.OCM_man_province_cus__c!='' && provinceGIMap.containskey(opp.OCM_man_province_cus__c)?provinceGIMap.get(opp.OCM_man_province_cus__c):null;
                    //Add By Li Jun 20230420 End
                    if(opp.Group_purchase_PCL__c){
                        //tempSADN.Sales_assistant_name_text__c = provinceGIMap.get('集采课'); //Commented By Li Jun 20230420
                    tempSADN.Sales_assistant_name_text__c = provinceGIMap.get('集采课');
                        tempSADN.RC_Manager__c =  provinceOwnerMap.get('集采课');
                    }else{
                        //tempSADN.Sales_assistant_name_text__c = opp.Sales_assistant_name_text__c; //Commented By Li Jun 20230420
                    tempSADN.Sales_assistant_name_text__c = opp.Sales_assistant_name_text__c;
                        tempSADN.RC_Manager__c =  provinceOwnerMap.get(opp.OCM_man_province_cus__c);
                    }
                    //集中采购的询价 精琢技术 wql 2020/01/11 end
                    
                    //如果 发货日期 大于 2020/12/01 才生成签收单
                    if(DeliveryDate >= todate){
                        tempSADN.EsignTestAccount__c =true;
                    }else{
                        tempSADN.EsignTestAccount__c =false;
@@ -782,7 +872,6 @@
                    }else{
                        tempSADN.ETRecalledProducts__c =false;
                    }
                }
                if (Inquiry.size() > 1) {
                    tempSADN.Order_No__c = Inquiry[1];
@@ -790,35 +879,40 @@
            }
            return tempSADN;
        }
    private static void checkSA(Statu_Achievements_DN__c tempSADN,
    private static void checkSA(
        Statu_Achievements_DN__c tempSADN,
                                List<Statu_Achievements_DN__c> UpsertDNList,
                                BatchIF_Log__c iflog,
                                NFM110rest.GeneralData infoH ) {
        NFM110rest.GeneralData infoH
    ) {
                                    if (tempSADN.Statu_Achievements__c != null)
                                        UpsertDNList.add(tempSADN);
                                    else {
                                        iflog.ErrorLog__c += 'warning! SoNo[' + infoH.SoNo +
                                            '] Statu_Achievements__c  NotExist. The insert of this DN is skipped.\n';
            iflog.ErrorLog__c += 'warning! SoNo[' + infoH.SoNo + '] Statu_Achievements__c  NotExist. The insert of this DN is skipped.\n';
                                    }                                    
                                }
    private static DNdetail SetSADNDetails(string DNnumber, boolean returnFlg,
                                           NFM110Rest.DnInformation dnInfo, asset ast, integer tempDNdetailNumber) {
    private static DNdetail SetSADNDetails(
        string DNnumber,
        boolean returnFlg,
        NFM110Rest.DnInformation dnInfo,
        asset ast,
        integer tempDNdetailNumber
    ) {
                                               DNdetail tempDNdetail = new DNdetail();
                                               Statu_Achievements_DN_details__c DNd = new Statu_Achievements_DN_details__c();
                                               DNd.Qty_Raw__c = dnInfo.QTY;
                                               DNd.QTY__c = String.isBlank(dnInfo.QTY) || Decimal.valueOf(dnInfo.QTY.trim()) == 0 ?
                                                   1 : Decimal.valueOf(dnInfo.QTY.trim());
                                               DNd.ShippedAmount_without_tax__c = String.isBlank(dnInfo.NetWorth) ?
                                                   0 : returnFlg == false ?
                                                       Decimal.valueOf(dnInfo.NetWorth.trim()) : - Decimal.valueOf(dnInfo.NetWorth.trim());
        DNd.QTY__c = String.isBlank(dnInfo.QTY) || Decimal.valueOf(dnInfo.QTY.trim()) == 0 ? 1 : Decimal.valueOf(dnInfo.QTY.trim());
        DNd.ShippedAmount_without_tax__c = String.isBlank(dnInfo.NetWorth)
            ? 0
            : returnFlg == false ? Decimal.valueOf(dnInfo.NetWorth.trim()) : -Decimal.valueOf(dnInfo.NetWorth.trim());
                                               DNd.ShippedAmount__c = String.isBlank(dnInfo.VALUE) ?
                                                   0 : returnFlg == false ?
                                                       Decimal.valueOf(dnInfo.VALUE.trim()) : - Decimal.valueOf(dnInfo.VALUE.trim());
        DNd.ShippedAmount__c = String.isBlank(dnInfo.VALUE)
            ? 0
            : returnFlg == false ? Decimal.valueOf(dnInfo.VALUE.trim()) : -Decimal.valueOf(dnInfo.VALUE.trim());
                                               DNd.NetWorthNoProviston__c = String.isBlank(dnInfo.NetWorthNoProviston) ?
                                                   0 : returnFlg == false ?
                                                       Decimal.valueOf(dnInfo.NetWorthNoProviston.trim()) : - Decimal.valueOf(dnInfo.NetWorthNoProviston.trim());
        DNd.NetWorthNoProviston__c = String.isBlank(dnInfo.NetWorthNoProviston)
            ? 0
            : returnFlg == false ? Decimal.valueOf(dnInfo.NetWorthNoProviston.trim()) : -Decimal.valueOf(dnInfo.NetWorthNoProviston.trim());
                                               if (dnInfo.SorLMark == 'S') {
                                                   DNd.SerialNumber__c = dnInfo.SerialNoorLotNo;
                                               } else {
force-app/main/default/classes/DNUpsertBatchTest.cls
@@ -221,13 +221,5 @@
        prdsMap.put(prd.ProductCode_Ext__c, prd);
        DNUpsertBatch.SetupeSignFormLineItems(insertSADNdetailList, eSFLMap, eSFMap, prdsMap);
        //Add By DTT - Li Jun Start 20230425
        OCM_Management_Province__c ocsmTest = new OCM_Management_Province__c();
        ocsmTest.Name = '其他';
        ocsmTest.Province__c = '北京市';
        ocsmTest.Window1__c = UserInfo.getUserId();
        insert ocsmTest;
        Map<String, OCM_Management_Province__c> provinceMap = DNUpsertBatch.getManagementProvince();
        //Add by DTT - Li Jun End 20230425
    }
}
force-app/main/default/classes/InventoryViewController.cls
@@ -4,10 +4,10 @@
    public List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
    //page
    Public Integer pagesize{get; set;}
    Public Integer totalcount{get; set;}
    Public Integer pagecount{get; set;}
    Public Integer currentpage{get; set;}
    public Integer pagesize { get; set; }
    public Integer totalcount { get; set; }
    public Integer pagecount { get; set; }
    public Integer currentpage { get; set; }
    public Boolean hasPrevious{get; set;}
    public Boolean hasNext{get; set;}
    public List<ConsumableorderdetailsInfo> pageRecords { get; set; }
@@ -17,9 +17,17 @@
    public String preSortKey { get; private set; }
    public Boolean sortOrderAsc { get; private set; }
    public String[] sortOrder { get; private set; }
    private String[] columus = new String[]{ 'Product2__c.Name__c','Asset_Model_No__c','','Category3__c','Category4__c','Category5__c',''};
    private String[] columus = new List<String>{
        'Product2__c.Name__c',
        'Asset_Model_No__c',
        '',
        'Category3__c',
        'Category4__c',
        'Category5__c',
        ''
    };
    
    String[] proLimitAndDate =new String[]{};
    String[] proLimitAndDate = new List<String>{};
    private Map<String,Date> productkucun = new Map<String,Date>();
    public List<SelectOption> categoryOptionList{get;set;}
    public List<SelectOption> category4OptionList{get;set;}
@@ -64,17 +72,15 @@
    }
    // 画面初始化
    public void init() {
        this.sortKey = '2';
        this.preSortKey = '2';
        this.sortOrderAsc = false;
        this.sortOrder = new String[8];
        this.sortOrder = new String[]{' ','',' ',' ','','','','↓'};
        this.sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '↓' };
         
        //取用户ID
        String userId = UserInfo.getUserId();
        User useracc = [select Accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:userId];
        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;
@@ -97,24 +103,28 @@
        //库存明细取得
        sqlagencyProType = '%' + agencyProType + '%';
        orderDetZaikuList = new List<String>();
        List<AggregateResult>  orderDetZaiku = [SELECT count(Id),
                                                      Consumable_Product__c
        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
            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 Cancellation_Flag__c = FALSE
                                                AND Arrive_Owner_Work_Location__c =: userWorkLocation
                                                group by Consumable_Product__c];
            GROUP BY Consumable_Product__c
        ];
        for(AggregateResult zaikuId : orderDetZaiku){
            orderDetZaikuList.add(String.valueOf(zaikuId.get('Consumable_Product__c')));
        }
        List<Consumable_order_details2__c> CountDel = [SELECT Id,
        List<Consumable_order_details2__c> CountDel = [
            SELECT
                Id,
                            Bar_Code__c,
                            Name,
                            Inventory_date__c,
@@ -125,26 +135,35 @@
                            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
            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
                        ];
        List<Product2__c> product2Selected = [select Id, Name,Name__c,Intra_Trade_List_RMB__c,
        List<Product2__c> product2Selected = [
            SELECT
                Id,
                Name,
                Name__c,
                Intra_Trade_List_RMB__c,
                                Asset_Model_No__c,
                                Category3__c,Category4__c,Category5__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 ];
            WHERE Id IN :orderDetZaikuList
        ];
        for (Integer i = 0; i < product2Selected.size(); i++) {
            MidMap.put(product2Selected[i].Id, product2Selected[i]);
        }
@@ -160,7 +179,8 @@
                    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();
                    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;
@@ -187,7 +207,10 @@
                    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();
                    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;
@@ -210,7 +233,6 @@
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                }
@@ -265,7 +287,6 @@
                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个A'));
            }
        }
        
        /////////////////////====================================update by rentx
@@ -369,7 +390,12 @@
        //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];
        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('', '-无-'));
@@ -377,7 +403,6 @@
            String deliverycnt = String.valueOf(category3Search.get('c3c'));
            categoryOptionList.add(new SelectOption(deliverycnt,deliverycnt));
         }
         category4OptionList = new List<SelectOption>();
         category4OptionList.add(new SelectOption('', '-无-'));
@@ -392,10 +417,19 @@
        //显示第一页
        moveToFirst();
        makeCurrentPageRecords();
    }
  public void categoryAllload() {
         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];
        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) {
@@ -403,7 +437,17 @@
            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 != null AND Category5_text__c != null group by Category5_text__c];
        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('', '-无-'));
@@ -411,11 +455,20 @@
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5,deliverycnt5));
         }
    }
    
    public 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];
        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) {
@@ -423,7 +476,17 @@
            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];
        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('', '-无-'));
@@ -431,7 +494,6 @@
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5,deliverycnt5));
         }
    }
        // 检索
    public void searchConsumableorderdetails() {
@@ -439,10 +501,12 @@
        this.preSortKey = '2';
        this.sortOrderAsc = false;
        this.sortOrder = new String[8];
        this.sortOrder = new String[]{' ','',' ',' ','','','','↓'};
        this.sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '↓' };
        List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
        List<Consumable_order_details2__c> CountDel = [SELECT Id,
        List<Consumable_order_details2__c> CountDel = [
            SELECT
                Id,
                            Bar_Code__c,
                            Name,
                            Inventory_date__c,
@@ -453,13 +517,14 @@
                            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 Bar_Code__c !=null
                        AND Product_Type__c like : sqlagencyProType
            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
                        ];
@@ -469,9 +534,9 @@
        Map<String,ConsumableorderdetailsInfo> newMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String,ConsumableorderdetailsInfo> newMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
      
        // 所有产品取得
        String soql = this.makeSoql(category1,category_Goods,category3,category4,category5);
        System.debug('====>soql11' + 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);
        for (Integer i = 0; i < queryList.size(); i++) {
@@ -628,7 +693,8 @@
                    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();
                    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;
@@ -655,7 +721,10 @@
                    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();
                    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;
@@ -678,7 +747,6 @@
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                }
@@ -735,7 +803,6 @@
            }
        }
        /////////////////////====================================update by rentx
        /*//把Boxmap里的值从新赋给boxRecords
        for(ConsumableorderdetailsInfo bss : newMidBoxMap.values()){
@@ -782,7 +849,7 @@
        this.preSortKey = '2';
        this.sortOrderAsc = false;
        this.sortOrder = new String[8];
        this.sortOrder = new String[]{' ','',' ',' ','','','','↓'};
        this.sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '↓' };
        //总件数
        totalcount = consumableorderdetailsRecords.size();
@@ -809,27 +876,33 @@
        }
        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));
                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 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
        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
            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];
            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;
@@ -856,12 +929,15 @@
        this.preSortKey = this.sortKey;
        // 所有产品取得
        String soql = this.makeSoql(null,null,null,null,null);
        soql += ' ORDER BY ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last');
        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);
        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
@@ -888,7 +964,6 @@
        //update byr entx 2020-12-29
        //再把map里的值从新赋给CpageRecords
        for(ConsumableorderdetailsInfo bss : MidMap.values()){
            if(bss != null){
                pageRecords.add(bss);
                if (newMap.get(bss.Prod.Id+bss.BoxPiece) != null) {
@@ -944,42 +1019,54 @@
        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 (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)){
        }
        if (!String.isBlank(Category4)) {
            soql += ' AND Category4__c = \'' +  Category4 + '\'';
        }if(!String.isBlank(Category5)){
        }
        if (!String.isBlank(Category5)) {
            soql += ' AND Category5__c = \'' +  Category5 + '\'';
        }
        System.debug('====>soql' + soql);
        return soql;
    }
    //首页
    public void moveToFirst(){
        if(currentpage == 1) return;
        if (currentpage == 1)
            return;
        currentpage = 1;
        canMove();
    }
    //尾页
    public void moveToLast(){
        if(currentpage >= pagecount) return;
        if (currentpage >= pagecount)
            return;
        currentpage = pagecount;
        canMove();
    }
   //上一页
   public void moveToPrevious(){
        if(currentpage == 1) return;
        if (currentpage == 1)
            return;
        currentpage = currentpage -1;
        canMove();
    }
    //下一页
    public void moveToNext(){
        if(currentpage >= pagecount) return;
        if (currentpage >= pagecount)
            return;
        currentpage = currentpage + 1;
        canMove();
@@ -989,10 +1076,11 @@
    public void canMove(){
        hasPrevious = false;
        hasNext = false;
        if(pagecount > 1 && currentpage > 1) hasPrevious = true;
        if(pagecount > 1 && currentpage < pagecount)  hasNext = true;
        if (pagecount > 1 && currentpage > 1)
            hasPrevious = true;
        if (pagecount > 1 && currentpage < pagecount)
            hasNext = true;
    }
    //刷新当前页
    public PageReference refreshPageSize() {
@@ -1061,7 +1149,6 @@
                }
                return returnValue;
            }
        }
    }
}
force-app/main/default/classes/LexArriveGoodsController.cls
New file
@@ -0,0 +1,389 @@
public without sharing class LexArriveGoodsController {
    public static String barcode { get; set; }
    public static Consumable_order__c coc { get; set; }
    /*****************画面表示Bean******************/
    public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
    public static List<ConsumableorderdetailsInfo> consumableInventory { get; set; }
    public static List<ConsumableorderdetailsInfo> detailsSummary { get; set; }
    public static List<ConsumableorderdetailsInfo> consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
    //更新明细取消时间
    public static List<Consumable_order_details2__c> consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
    // 更新借调信息 add by gzw 2020-0-415 start
    public static Map<String, Consumable_order_details2__c> orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
    // 更新借调信息 add by gzw 2020-0-415 end
    public static List<Consumable_order_details2__c> consumableorderdetails2Insert = new List<Consumable_order_details2__c>();
    public static List<Consumable_order_details2__c> consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
    public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordserror { get; set; }
    public static transient List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
    public static List<ConsumableorderdetailsInfo> ShowGoodsofReturnList { get; set; }
    public static List<ConsumableorderdetailsInfo> ShowGoodsofRemoveBoxReturnList { get; set; }
    //add by rentx 20210602 CHAN-C3K4ZQ
    public static List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview { get; set; }
    //add by rentx 20210602 CHAN-C3K4ZQ
    public static List<String> GrList = new List<String>();
    //超出定货数量的产品
    public static List<String> cancellationProList = new List<String>();
    //错误信息
    public static String alertMessage { get; set; }
    public static integer getinventorysize() {
        return consumableInventory.size();
    }
    public static integer geterrorsize() {
        return ConsumableorderdetailsRecordserror.size();
    }
    public static Set<String> noboxBarcodeList = new Set<String>();
    public static transient Map<String, String> ExistIdMap = new Map<String, String>();
    public static transient Map<String, String> ErrorIdMap = new Map<String, String>();
    public static transient Map<String, String> AllMap = new Map<String, String>();
    public static Map<String, String> otherAgencyMap = new Map<String, String>();
    public static transient Map<String, String> barMcodeMap = new Map<String, String>();
    public static Map<String, Integer> BarcodeCntMap = new Map<String, Integer>();
    public static transient List<String> BarCodeListP = new List<String>();
    public static Map<String, Decimal> orderProductCunMap = new Map<String, Decimal>();
    public static Map<String, Decimal> orderProductArrivedCunMap = new Map<String, Decimal>();
    public static Map<String, Decimal> orderWantArriveCunMap = new Map<String, Decimal>();
    //超出型号和数量
    public static Map<String, Decimal> overOrderCunMap = new Map<String, Decimal>();
    //超出BARCODE和型号
    public static Map<String, List<String>> overOrderBARcodeCunMap = new Map<String, List<String>>();
    public static List<String> overOrderBARcodeTTTTTT = new List<String>();
    //不符合的barcode和型号
    public static Map<String, List<String>> notEqualBARcodeCunMap = new Map<String, List<String>>();
    public static List<String> overOrderBARcodeSSSSSS = new List<String>();
    public static List<String> productList = new List<String>();
    public static List<String> notInlist = new List<String>();
    //不选择订单时保存订单ID、产品型号用
    //库存登录使用
    public static List<String> notInStorelist = new List<String>();
    public static List<String> exitBarCodeList = new List<String>();
    public static Map<String, String> HosErrorMap = new Map<String, String>();
    public static List<String> HosErrorList = new List<String>();
    public static String baseUrl { get; private set; }
    public static String ESetId { get; set; }
    public static String arriveId = '';
    private static String accountid = null;
    private static String accountName = null;
    public static Decimal orderCountAll = 0;
    public static Decimal orderCountNotarrive = 0;
    private static id return_Order_id = null;
    private static id inventory_Order_id = null;
    public static boolean ReturnFLGbln { get; set; }
    public static boolean saveFLGbln { get; set; }
    public static String ArrType { get; set; }
    // 登录者工作地
    private static String userWorkLocation;
    //用户产品区分
    public static String userPro_Typestr = null;
    public static String userPro_Type = null;
    public static String product_Type = null;
    public static Boolean EngFlag = false;
    public static Boolean ETFlag = false;
    @AuraEnabled
    public static Results init(String arrTypeStr, String eSetIdStr) {
        Results results = new Results();
        ESetId = eSetIdStr;
        ArrType = arrTypeStr;
        ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
        ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
        ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
        consumableInventory = new List<ConsumableorderdetailsInfo>();
        consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
        consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
        consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
        orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
        detailsSummary = new List<ConsumableorderdetailsInfo>();
        saveFLGbln = false;
        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
        try {
            String userId = UserInfo.getUserId();
            List<user> Useracc = new List<user>();
            Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
            accountid = Useracc[0].accountid;
            userPro_Type = Useracc[0].UserPro_Type__c;
            if (String.isBlank(userPro_Type)) {
                userPro_Type = 'ET';
            }
            if (userPro_Type == 'ENG') {
                product_Type = 'ET';
                EngFlag = true;
            } else {
                product_Type = 'ENG';
                ETFlag = true;
            }
            userPro_Typestr = '%' + userPro_Type + '%';
            userWorkLocation = Useracc[0].Work_Location__c;
            system.debug('userWorkLocation' + userWorkLocation);
            List<account> accountInfo = [SELECT Name FROM account WHERE id = :accountid];
            accountName = accountInfo[0].Name;
            system.debug('accountName' + accountName);
            coc = new Consumable_order__c();
            if (ArrType == 'ReG') {
                ReturnFLGbln = true;
            } else {
                ReturnFLGbln = false;
            }
            if (ESetId != '' && ESetId != null) {
                List<Consumable_order__c> qs = new List<Consumable_order__c>();
                List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
                List<Consumable_Orderdetails__c> reSet = new List<Consumable_Orderdetails__c>();
                qs = [
                    SELECT
                        Id,
                        Name,
                        Order_status__c,
                        Dealer_Info__c,
                        Deliver_date__c,
                        ReturnGs_Upload_Date__c,
                        Order_Reason__c,
                        Order_date__c,
                        Contract_application_decision__c,
                        Order_type__c,
                        Total_num__c,
                        OrderNumber_arrived__c,
                        Delivery_detail_count__c,
                        OrderNumber_notarrive__c,
                        orderPattern__c
                    FROM Consumable_order__c
                    WHERE Id = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation AND Dealer_Info__c = :accountid
                ];
                if (qs.size() > 0) {
                    coc = qs[0];
                    orderCountAll = coc.Total_num__c;
                    orderCountNotarrive = coc.OrderNumber_notarrive__c;
                }
                //产品定货数量
                reSet = [
                    SELECT Asset_Model_No__c, Consumable_order__c, Consumable_count__c
                    FROM Consumable_Orderdetails__c
                    WHERE Consumable_order__c = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation
                ];
                for (Integer i = 0; i < reSet.size(); i++) {
                    productList.add(reSet[i].Asset_Model_No__c);
                    orderProductCunMap.put(reSet[i].Asset_Model_No__c, reSet[i].Consumable_count__c);
                    orderProductArrivedCunMap.put(reSet[i].Asset_Model_No__c, 0);
                    orderWantArriveCunMap.put(reSet[i].Asset_Model_No__c, 0);
                    overOrderCunMap.put(reSet[i].Asset_Model_No__c, 0);
                    overOrderBARcodeCunMap.put(reSet[i].Asset_Model_No__c, overOrderBARcodeTTTTTT);
                }
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Intra_Trade_List_RMB__c,
                        Asset_Model_No__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Consumable_Product__r.Name__c,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        Dealer_Arrive__c,
                        Guarantee_period_for_products__c,
                        CFDA_Status__c,
                        Box_Piece__c,
                        Rrturn_count__c,
                        ProductPacking_list_manual__c,
                        Report_Product_Approbation__c,
                        Report_Product_Expiration__c,
                        ContractNo_text__c,
                        Consumable_order_minor__r.ContractNo__c
                    FROM Consumable_order_details2__c
                    WHERE
                        recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Arrive_Owner_Work_Location__c = :userWorkLocation
                        AND Consumable_order_minor__c = :ESetId
                        AND Dealer_Arrive__c = TRUE
                        AND Box_Piece__c != '个'
                ];
                for (Integer i = 0; i < reSet1.size(); i++) {
                    if (orderProductArrivedCunMap.containsKey(reSet1[i].Asset_Model_No__c)) {
                        orderProductArrivedCunMap.put(
                            reSet1[i].Asset_Model_No__c,
                            orderProductArrivedCunMap.get(reSet1[i].Asset_Model_No__c) + 1
                        );
                    }
                }
            }
            results.accountId = accountid;
            results.accountName = accountName;
            results.userProType = userPro_Type;
            results.userProTypestr = userPro_Typestr;
            results.productType = product_Type;
            results.saveFLGbln = saveFLGbln;
            results.returnFLGbln = ReturnFLGbln;
            results.engFlag = EngFlag;
            results.etFlag = ETFlag;
            results.userWorkLocation = userWorkLocation;
            results.productList = productList;
            results.orderProductCunMap = orderProductCunMap;
            results.orderProductArrivedCunMap = orderProductArrivedCunMap;
            results.orderWantArriveCunMap = orderWantArriveCunMap;
            results.overOrderCunMap = overOrderCunMap;
            results.overOrderBARcodeCunMap = overOrderBARcodeCunMap;
            results.result = 'Success';
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
        }
        return results;
    }
    @AuraEnabled
    public static Results methodName() {
        Results results = new Results();
        try {
            results.result = 'Success';
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
        }
        return results;
    }
    public class Results {
        @AuraEnabled
        public String result;
        @AuraEnabled
        public String errorMsg;
        @AuraEnabled
        public String accountId;
        @AuraEnabled
        public String accountName;
        @AuraEnabled
        public String userProType;
        @AuraEnabled
        public String userProTypestr;
        @AuraEnabled
        public String productType;
        @AuraEnabled
        public String userWorkLocation;
        @AuraEnabled
        public String inventoryOrderId;
        @AuraEnabled
        public String returnOrderId;
        @AuraEnabled
        public String arriveId;
        @AuraEnabled
        public Boolean returnFLGbln;
        @AuraEnabled
        public Boolean saveFLGbln;
        @AuraEnabled
        public Boolean engFlag;
        @AuraEnabled
        public Boolean etFlag;
        @AuraEnabled
        public Consumable_order__c coc;
        @AuraEnabled
        public List<String> productList;
        @AuraEnabled
        public Map<String, Decimal> orderProductCunMap;
        @AuraEnabled
        public Map<String, Decimal> orderProductArrivedCunMap;
        @AuraEnabled
        public Map<String, Decimal> orderWantArriveCunMap;
        @AuraEnabled
        public Map<String, Decimal> overOrderCunMap;
        @AuraEnabled
        public Map<String, List<String>> overOrderBARcodeCunMap;
    }
    public class ConsumableorderdetailsInfo implements Comparable {
        @AuraEnabled
        public Consumable_order_details2__c esd { get; set; }
        @AuraEnabled
        public Product2__c Prod { get; set; }
        @AuraEnabled
        public String ProductName { get; set; }
        @AuraEnabled
        public String barCodeNo { get; set; }
        @AuraEnabled
        public Date sterilizationlimitDate { get; set; }
        @AuraEnabled
        public String serialNoorLotNo { get; set; }
        @AuraEnabled
        public String tracingCodeNo { get; set; }
        @AuraEnabled
        public String ReturnReason { get; set; }
        @AuraEnabled
        public String oldConsumableCount { get; set; }
        @AuraEnabled
        public String ErrorReason { get; set; }
        @AuraEnabled
        public boolean canEdit { get; set; }
        @AuraEnabled
        public Integer intMark { get; set; }
        @AuraEnabled
        public Decimal arriveAmount { get; set; }
        @AuraEnabled
        public Decimal arrivedCount { get; set; }
        public String ReportProductExpirationDate { get; set; }
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e, string str) {
            esd = e;
            Prod = e.Consumable_Product__r;
            oldConsumableCount = e.name;
            ErrorReason = str;
            intMark = 1;
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
            }
        }
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
            canEdit = false;
            if (e.Box_Piece__c == '盒') {
                e.Rrturn_count__c = 1;
                canEdit = true;
            }
            esd = e;
            Prod = e.Consumable_Product__r;
            oldConsumableCount = e.name;
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
            }
        }
        public ConsumableorderdetailsInfo(Product2__c e, List<String> barinfoL) {
            esd = new Consumable_order_details2__c();
            ProductName = e.Name__c;
            Prod = e;
            barCodeNo = barinfoL[0];
            if (String.isNotBlank(barinfoL[1])) {
                sterilizationlimitDate = Date.valueOf(barinfoL[1]);
            }
            serialNoorLotNo = barinfoL[2];
            tracingCodeNo = barinfoL[3];
            ReturnReason = '';
        }
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e, List<String> barinfoL) {
            esd = e;
            Prod = e.Consumable_Product__r;
            barCodeNo = barinfoL[0];
            if (String.isNotBlank(barinfoL[1])) {
                sterilizationlimitDate = Date.valueOf(barinfoL[1]);
            }
            serialNoorLotNo = barinfoL[2];
            tracingCodeNo = barinfoL[3];
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
            }
        }
        public ConsumableorderdetailsInfo(Product2__c e) {
            Prod = e;
        }
        // 排序
        public Integer compareTo(Object compareTo) {
            return null;
        }
    }
}
force-app/main/default/classes/LexArriveGoodsController.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>56.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/LexSummonsCreatController.cls
@@ -1,5 +1,4 @@
public without sharing class LexSummonsCreatController {
    public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    /*****************検索用******************/
@@ -49,6 +48,12 @@
    public static Map<String,String> category5OptionMap { get; set; }
    /*****************画面表示Bean******************/
    private static List<ConsumableorderdetailsInfo> consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
    //明细2
    @AuraEnabled
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
    //错误明细
    @AuraEnabled
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror { get; set; }
    @AuraEnabled
    public static List<ConsumableorderdetailsInfo> pageRecords { get; set; }
    public static List<ConsumableorderdetailsInfoLwc> pageRecordsLwc { get; set; }
@@ -58,6 +63,18 @@
    private static List<ConsumableorderdetailsInfo> consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
    private static List<Attachment> attachmentinfo = new List<Attachment>();
    public static List<Product2__c> product2Selected = new List<Product2__c>();
    @AuraEnabled
    public static Map<String, String> orderpieceorboxMap { get; set; }
    @AuraEnabled
    public static List<Consumable_orderdetails__c> orderdetails { get; set; }
    @AuraEnabled
    public static Map<String, Decimal> orderagencypriceMap { get; set; }
    @AuraEnabled
    public static Map<String, Decimal> orderpriceMap { get; set; }
    @AuraEnabled
    public static Map<String, Decimal> orderdetCountMap { get; set; }
    @AuraEnabled
    public static Boolean hasSpecialHos { get; set; }
    //选择产品size
    public static Integer consumableorderdetailsCount {
        get {
@@ -88,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>();
@@ -217,9 +245,10 @@
    // 画面初始化
    @AuraEnabled
    public static ResponseBodyLWC init(String ESetidJs) {
    public static ResponseBodyLWC init(String ESetidJs, String statusEdit, Integer pageSizeLWC, Integer pageTokenLWC) {
        // try {
        firstInit(ESetidJs);
        statusEdit = statusEdit;
        arriveorder = '';
        HospitalName = '';
        provinceOpts = new List<SelectOption>();
@@ -227,12 +256,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 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;
@@ -308,6 +343,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,
@@ -341,8 +379,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++) {
@@ -396,6 +434,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);
@@ -432,7 +471,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;
@@ -623,7 +662,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) {
@@ -690,9 +729,8 @@
                    consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i]));
                }
            }
        }
        } else {
        // 更新、
        else {
            SummonsFlag = 'visible';
            // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select
            consumableInvoiceRecords = [
@@ -703,6 +741,8 @@
                    AND Invoice_status__c != '草案中'
            ];
            System.debug('coc ESetId = ' + ESetId);
            System.debug('coc userWorkLocation = ' + userWorkLocation);
            coc = [
                SELECT
                    Id,
@@ -998,9 +1038,8 @@
                for (Integer i = 0; i < consumablearriveproductdetailsSelected.size(); i++) {
                    consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i]));
                }
            }
            } else {
            // 不是到货订单来的时候
            else {
                if (coc.SummonsStatus_c__c == '已提交' || coc.SummonsStatus_c__c == '批准') {
                    system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c);
                    saveBtnDisabled = true;
@@ -1157,7 +1196,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){
@@ -1295,11 +1334,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);
@@ -1318,8 +1384,11 @@
        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);
        data.put('HospitalInfo', HospitalInfo);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
@@ -1329,9 +1398,119 @@
        // }
    }
    @AuraEnabled
    public static ResponseBodyLWC categoryAllload(String category3Lwc) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        category3 = category3Lwc;
        AggregateResult[] category4List = [
            SELECT Count(id), Category4_text__c c4c
            FROM Product2__c
            WHERE Category3_text__c = :category3 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 Category3_text__c = :category3 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);
        }
        data.put('category4OptionMap', category4OptionMap);
        data.put('category5OptionMap', category5OptionMap);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    @AuraEnabled
    public static ResponseBodyLWC categoryload(String category3Lwc, String category4Lwc) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        category3 = category3Lwc;
        category4 = category4Lwc;
        AggregateResult[] category4List = [
            SELECT Count(id), Category4_text__c c4c
            FROM Product2__c
            WHERE Category3_text__c = :category3 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 Category3_text__c = :category3 AND Category4_text__c = :category4 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);
        }
        data.put('category4OptionMap', category4OptionMap);
        data.put('category5OptionMap', category5OptionMap);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    // 检索
    @AuraEnabled
    public static ResponseBodyLWC searchConsumableorderdetails(String agencyProTypeLwc,String accountNameLwc,String userWorkLocationLwc,String outOutPattern,String category1,String category3,String category4,String category5,Boolean editAbleLwc,List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,String arriveorderLwc) {
    public static ResponseBodyLWC searchConsumableorderdetails(
        String agencyProTypeLwc,
        String accountNameLwc,
        String userWorkLocationLwc,
        String outOutPattern,
        String category1,
        String category3,
        String category4,
        String category5,
        Boolean editAbleLwc,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,
        List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
        String arriveorderLwc,
        Integer pageSizeLWC,
        Integer pageTokenLWC
    ) {
        consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
        pageRecordsLwc = pageRecordsLwcLwc;
        System.debug('pageRecordsLwc = ' + pageRecordsLwc);
@@ -1339,6 +1518,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
@@ -1383,9 +1570,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]));
@@ -1464,20 +1651,53 @@
            hasHosPro = false;
        }
        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);
@@ -1487,22 +1707,32 @@
    private static String makeSoql(String CateName,String Category3,String Category4,String Category5){
        String sqlTail1 = '(\'';
        for(Integer i = 0 ; i< zaikuId.size();i++){
            if (zaikuId[i] != null) {
            if(i<zaikuId.size()-1){
                sqlTail1 += zaikuId[i]+'\',\'';
            }else{
                sqlTail1 += zaikuId[i];
            }
        }
        }
        sqlTail1 += '\')';
        String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c  FROM Product2__c ';
        soql += ' WHERE Id in' + sqlTail1;
        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 (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)){
        }
        if (!String.isBlank(Category4)) {
            soql += ' AND Category4__c = \'' +  Category4 + '\'';
        }if(!String.isBlank(Category5)){
        }
        if (!String.isBlank(Category5)) {
            soql += ' AND Category5__c = \'' +  Category5 + '\'';
        }
        return soql;
@@ -1526,10 +1756,12 @@
    public static String makeSoqlinventory() {
        String sqlTail = '(\'';
        for (Integer i = 0; i < zaikuId.size(); i++) {
            if (zaikuId[i] != null) {
            if (i < zaikuId.size() - 1) {
                sqlTail += zaikuId[i] + '\',\'';
            } else {
                sqlTail += zaikuId[i];
                }
            }
        }
        sqlTail += '\')';
@@ -1568,6 +1800,7 @@
        }
        System.debug('zhj3');
        pageRecords = new List<ConsumableorderdetailsInfo>();
        System.debug('reSet.size() = ' + reSet.size());
        if (editAble && String.isBlank(arriveorder)) {
            pageRecords = reSet;
        }
@@ -1575,7 +1808,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 (
@@ -1600,6 +1833,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) {
@@ -1608,18 +1842,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;
@@ -1646,19 +1882,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;
@@ -1667,24 +1908,44 @@
                addNo++;
            }
        }
        System.debug('pageRecords = ' + pageRecords);
        System.debug('pageRecords.size() = ' + pageRecords.size());
        System.debug('end  addData = ' + addData);
        return pageRecords;
    }
    // 保存按钮
    @AuraEnabled
    public static ResponseBodyLWC save(Consumable_order__c cocLwc,String hospitalInfoLwc,String hospitalNameLwc,String secondaryDistributor,List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,String accountid,String ESetId,List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc) {
        System.debug('cocLwc = ' + cocLwc);
    public static ResponseBodyLWC save(
        Consumable_order__c cocLwc,
        String hospitalInfoLwc,
        String hospitalNameLwc,
        String secondaryDistributorLwc,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,
        String accountidLwc,
        String ESetIdLwc,
        List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
        String agencyProTypeLwc,
        String userWorkLocationLwc
    ) {
        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;
@@ -1693,8 +1954,7 @@
            // coc.SummonsForDirction__c.addError('请输入指示单目的。');
            // return null;
            return new ResponseBodyLWC('Error',500, '请输入指示单目的。', '');
        }
        else if(coc.SummonsForDirction__c =='直接销售给医院'){
        } else if (coc.SummonsForDirction__c == '直接销售给医院') {
            if(String.isBlank(HospitalInfo) || String.isBlank(HospitalName)){
                // coc.addError('请输入医院。');
                // return null;
@@ -1704,8 +1964,7 @@
                // coc.Order_ForCustomerText__c.addError('请输入科室。');
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入科室。', '');
            }
            else if(String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)){
            } else if (String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)) {
                // coc.addError('不需要二级经销商和经销商(录入)信息。' );
                // return null;
                return new ResponseBodyLWC('Error',500, '不需要二级经销商和经销商(录入)信息。', '');
@@ -1721,8 +1980,7 @@
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入科室。', '');
            }
        }
        else if(coc.SummonsForDirction__c =='销售给二级经销商'){
        } else if (coc.SummonsForDirction__c == '销售给二级经销商') {
            if(String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)){
                // coc.addError('必须输入二级经销商或经销商(录入)。');
                // return null;
@@ -1738,8 +1996,7 @@
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入科室。', '');
            }
        }
        else if(coc.SummonsForDirction__c =='互相调货'){
        } else if (coc.SummonsForDirction__c == '互相调货') {
            if(String.isNotBlank(HospitalInfo) || String.isNotBlank(HospitalName)){
                // coc.addError('不需要输入医院。');
                // return null;
@@ -1797,7 +2054,7 @@
        //特价医院出库非本医院维护的特价商品时,报错 非特价医院出库维护在医院特价关系表的产品时 报错
        if(coc.SummonsForDirction__c !='互相调货'){
            //非特价医院出库特价产品时 报错(当前经销商下没有特价医院除外)
            List<hospitalprice__c> hopList = [select id,hospital__c,product__c from hospitalprice__c where account__c = :accountid];
            List<hospitalprice__c> hopList = [SELECT id, hospital__c, product__c FROM hospitalprice__c WHERE account__c = :accountid];
            //经销商对应医院下的所有特价产品
            Map<String,String> proMap = new Map<String,String>();
            //经销商下的所有特价产品
@@ -1813,7 +2070,6 @@
                            flag = true; 
                            proMap.put(hp.product__c, '');
                        }
                    }
                }
                for(ConsumableorderdetailsInfoLwc ass : pageRecordsLwc){
@@ -1838,7 +2094,11 @@
            }
        }else{
            //如果是互相调货,判断 经销商(录入) 是否维护了 当前选中的特价产品 
            List<hospitalprice__c> hopList = [select id,hospital__c,product__c from hospitalprice__c where account__c = :coc.Order_ForDealerTextID__c];
            List<hospitalprice__c> hopList = [
                SELECT id, hospital__c, product__c
                FROM hospitalprice__c
                WHERE account__c = :coc.Order_ForDealerTextID__c
            ];
            Map<Id,String> proMap = new Map<Id,String>();
            if (hopList != null && hopList.size() > 0) {
                for (hospitalprice__c hpc : hopList) {
@@ -1858,15 +2118,20 @@
                if (proStr != '') {
                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '经销商:'+coc.Order_ForDealerText__c +' 没有消耗品:'+proStr.substring(0,proStr.length()-1) + ' 的特价'));
                    // return null;
                    return new ResponseBodyLWC('Error',500, '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0,proStr.length()-1) + ' 的特价', '');
                    return new ResponseBodyLWC(
                        'Error',
                        500,
                        '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0, proStr.length() - 1) + ' 的特价',
                        ''
                    );
                }
            }
        }
        
        // checkOutPattern();
        Consumable_order__c p = new Consumable_order__c();
        List<Consumable_orderdetails__c> Ins = New List<Consumable_orderdetails__c>();
        List<Consumable_order_details2__c> InsProduct = New List<Consumable_order_details2__c>();
        List<Consumable_orderdetails__c> Ins = new List<Consumable_orderdetails__c>();
        List<Consumable_order_details2__c> InsProduct = new List<Consumable_order_details2__c>();
        Savepoint sp = Database.setSavepoint();
        // try {
            //新建订单时
@@ -1874,7 +2139,8 @@
                p.Name = '*';
                p.Order_type__c = '传票';
                p.Order_ProType__c = agencyProType;
                if(coc.SummonsStatus_c__c ==null||String.isBlank(coc.SummonsStatus_c__c))coc.SummonsStatus_c__c ='草案中';
            if (coc.SummonsStatus_c__c == null || String.isBlank(coc.SummonsStatus_c__c))
                coc.SummonsStatus_c__c = '草案中';
                // update strat by vivek 2019-7-12
                p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
                // update end by vivek 2019-7-12
@@ -1916,7 +2182,11 @@
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入正确的出货单价 (元)。', '');
                        }
                        if(ass.orderdetails1.Delivery_List_RMB__c == 0 && (coc.SummonsForDirction__c =='销售给二级经销商' || coc.SummonsForDirction__c =='直接销售给医院')){
                    if (
                        ass.orderdetails1.Delivery_List_RMB__c == 0 &&
                        (coc.SummonsForDirction__c == '销售给二级经销商' ||
                        coc.SummonsForDirction__c == '直接销售给医院')
                    ) {
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', '');
@@ -1940,7 +2210,12 @@
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                                }
                            }
                        }else if(ass.orderdetails1.Box_Piece__c == '个'){
@@ -1951,7 +2226,12 @@
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                                }
                            }
                        }
@@ -2003,22 +2283,18 @@
                    insert Ins;
                }
                if(InsProduct.size() >0){
                    ControllerUtil.updateOrderDetailsSatus(InsProduct);
                //ControllerUtil.updateOrderDetailsSatus(InsProduct);
                update InsProduct;
                }
            }
        } else if (ESetId != null || ESetId.length() > 0) {
            //修改之后 保存订单
            else if(ESetId != null || ESetId.length() >0 ){
                List<Consumable_order__c> cocinfo = New List<Consumable_order__c>();
            List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
                // update start by vivek 2019-7-15 add "NoConfirmedPrice__c" in select
                cocinfo = [SELECT Id,
                                Name,
                                SummonsStatus_c__c,
                                NoConfirmedPrice__c,
                                Dealer_Info__c,
                                Order_ForHospital__c,
                                SummonsForDirction__c
            cocinfo = [
                SELECT Id, Name, SummonsStatus_c__c, NoConfirmedPrice__c, Dealer_Info__c, Order_ForHospital__c, SummonsForDirction__c
                            FROM Consumable_order__c
                            WHERE Id =:ESetId];
                WHERE Id = :ESetId
            ];
                // update end by vivek 2019-7-15
                if (cocinfo.size()>0){
                    p = cocinfo[0];
@@ -2026,10 +2302,11 @@
                p.Name = coc.Name;
                p.Dealer_Info__c = accountid;
                p.Order_ProType__c = agencyProType;
                if(SecondDealer == null){
            if (String.isEmpty(SecondDealer)) {
                    p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                    p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                    p.Order_ForDealer__c = SecondDealer;
                System.debug('SecondDealer = ' + SecondDealer);
                p.Order_ForDealer__c = null;
                }else {
                    p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                    p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
@@ -2065,7 +2342,11 @@
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', '');
                        }
                        if(ass.orderdetails1.Delivery_List_RMB__c == 0 && (coc.SummonsForDirction__c =='销售给二级经销商' || coc.SummonsForDirction__c =='直接销售给医院')){
                    if (
                        ass.orderdetails1.Delivery_List_RMB__c == 0 &&
                        (coc.SummonsForDirction__c == '销售给二级经销商' ||
                        coc.SummonsForDirction__c == '直接销售给医院')
                    ) {
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', '');
@@ -2083,7 +2364,12 @@
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                                }
                            }
                        }else if(ass.orderdetails1.Box_Piece__c == '个'){
@@ -2093,7 +2379,12 @@
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                                }
                            }
                        }
@@ -2102,7 +2393,6 @@
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货数量。', '');
                        }else{
                            String str = string.valueOf(i);
                            if(str.length() == 1){
                                str = '0' + str;
@@ -2127,7 +2417,7 @@
                    }
                }
                update p;
                List<Consumable_orderdetails__c> qs = New List<Consumable_orderdetails__c>();
            List<Consumable_orderdetails__c> qs = new List<Consumable_orderdetails__c>();
                qs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c =:ESetId];
                if (qs.size()>0){
                    delete qs;
@@ -2135,7 +2425,6 @@
                if(Ins.size()>0){
                    insert Ins;
                }
            }
        // }catch (Exception ex) {
        //     Database.rollback(sp);
@@ -2178,9 +2467,21 @@
        if(coc.SummonsStatus_c__c =='批准'){
            Consumable_order__c P = new Consumable_order__c();
            List<Consumable_order__c> cocinfo = New List<Consumable_order__c>();
            List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
            // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select 
            cocinfo = [SELECT Id,Name,SummonsStatus_c__c,NoConfirmedPrice__c,Dealer_Info__c,Order_ForHospital__c,SummonsForDirction__c,Billed_Status__c FROM Consumable_order__c WHERE Id =:ESetId];
            cocinfo = [
                SELECT
                    Id,
                    Name,
                    SummonsStatus_c__c,
                    NoConfirmedPrice__c,
                    Dealer_Info__c,
                    Order_ForHospital__c,
                    SummonsForDirction__c,
                    Billed_Status__c
                FROM Consumable_order__c
                WHERE Id = :ESetId
            ];
            // update end by vivek 2019-7-15
                if (cocinfo.size()>0){
                    p = cocinfo[0];
@@ -2189,6 +2490,159 @@
            update p;
        }
        data.put('ESetId',ESetId);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    //查找经销商
    @AuraEnabled(cacheable=true scope='global')
    public static List<LookupSearchResult> search(String searchTerm) {
        System.debug('searchTerm = ' + searchTerm);
        String nameCondition = '';
        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);
        }
        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';
        for (Account account : accs) {
            String subtitle = account.BillingCity == null ? 'Account' : 'Account • ' + account.BillingCity;
            results.add(new LookupSearchResult(account.Id, 'Account', accountIcon, account.Name, subtitle));
        }
        results.sort();
        System.debug('results = ' + results);
        return results;
    }
    //保存附件
    @AuraEnabled
    public static String saveFile(Id recordId, String fileName, String base64Data) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
        ContentVersion cv = new ContentVersion();
        cv.Title = fileName;
        cv.PathOnClient = '/' + fileName;
        cv.FirstPublishLocationId = recordId;
        cv.VersionData = EncodingUtil.base64Decode(base64Data);
        cv.IsMajorVersion = true;
        insert cv;
        return cv.Id;
    }
    //获取附件
    @AuraEnabled
    public static ResponseBodyLWC getFiles(Id recordId) {
        System.debug('getFiles recordId = ' + recordId);
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        List<ContentVersion> cvList = [
            SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate
            FROM ContentVersion
            WHERE FirstPublishLocationId = :recordId
        ];
        data.put('cvList', cvList);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    //跳转出货/销售
    @AuraEnabled
    public static ResponseBodyLWC GoodsDelivery(
        Consumable_order__c cocLwc,
        String ESetId,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc
    ) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        coc = cocLwc;
        ESetId = ESetId;
        pageRecordsLwc = pageRecordsLwcLwc;
        if (coc.SummonsForDirction__c == '互相调货') {
            List<Account> accList = [
                SELECT Id
                FROM Account
                WHERE Name = :coc.Order_ForDealerText__c AND RecordType.DeveloperName = 'Agency'
            ];
            if (accList.size() < 1) {
                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请输入二级经销商全称!'));
                // return null;
                return new ResponseBodyLWC('Error', 500, '请输入二级经销商全称!', '');
            }
        }
        if (coc.SummonsStatus_c__c == '批准') {
            // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请先打印指示单!'));
            // return null;
            return new ResponseBodyLWC('Error', 500, '请先打印指示单!', '');
        }
        for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
            if (ass.orderdetails1.Shipment_Count__c > ass.allnumber) {
                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                // return null;
                return new ResponseBodyLWC('Error', 500, '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
            }
        }
        data.put('ESetid', ESetid);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    //删除按钮
    @AuraEnabled
    public static ResponseBodyLWC DelConsumable(String ESetId) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        ESetId = ESetId;
        Savepoint sp = Database.setSavepoint();
        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];
            qs = [SELECT Id FROM Consumable_order__c WHERE Id = :ESetId];
            if (Dqs.size() > 0 || qs.size() > 0) {
                delete Dqs;
                delete qs;
            }
        } catch (Exception e) {
            Database.rollback(sp);
            System.debug(e.getMessage() + e.getLineNumber());
            return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
        }
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
@@ -2240,7 +2694,8 @@
        @AuraEnabled
        public Boolean hosPro { get; set; }
        public ConsumableorderdetailsInfo(){}
        public ConsumableorderdetailsInfo() {
        }
        public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
            check = true;
@@ -2289,6 +2744,7 @@
            hospitalSpecialOffer = false;
            hosPro = false;
        }
        public ConsumableorderdetailsInfo(Product2__c e) {
            check = false;
            oldCheck = false;
@@ -2397,4 +2853,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; }
    }
}
force-app/main/default/classes/LogAutoSendBatch.cls
@@ -1,15 +1,9 @@
global class LogAutoSendBatch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful {
    private String typeNFM;
    private String messageGroupNumber;
    private Datetime times;
    private Boolean isForecast;// 20220318 ljh SWAG-CC54R2 add  
    private String loginId;
     //20230203 lt 计划的作业优化  一小时两次 start
     private BatchEmailUtil.ScBean scB1;
     //20230203 lt 计划的作业优化  一小时两次 end
    /**
     * コンスタント
     */
@@ -43,53 +37,102 @@
     */
    public Integer max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
    global Database.QueryLocator start(Database.BatchableContext BC) {
        //20230203 lt 计划的作业优化  一小时两次 start
        scB1 = BatchEmailUtil.setSc1('LogAutoSendSchedule', 0, 23, 0, '0 30 *', null);
        if (System.Test.isRunningTest() == false) {
            for(CronTrigger ct : [SELECT Id FROM CronTrigger WHERE CronJobDetail.Name =: scB1.scName]) {
                System.abortJob(ct.Id);
            }
            system.schedule(scB1.scName, scB1.scTime, new LogAutoSendSchedule());
        }
        //20230203 lt 计划的作业优化  一小时两次 end
        String profileId = UserInfo.getProfileId();
        // 20220318 ljh SWAG-CC54R2 add start
        if(String.isNotBlank(typeNFM) && typeNFM == 'NFM010' && String.isBlank(messageGroupNumber)){
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                 AND (retry_cnt__c = null OR (retry_cnt__c != null AND retry_cnt__c > 0 AND retry_cnt__c < : max_cnt))
                 AND Type__c = : typeNFM ]
                    WHERE
                        RowDataFlg__c = TRUE
                        AND (retry_cnt__c = NULL
                        OR (retry_cnt__c != NULL
                        AND retry_cnt__c > 0
                        AND retry_cnt__c < :max_cnt))
                        AND Type__c = :typeNFM
                ]
                );
        }
        // gzw 603 重发判断 暂时用
        // ljh只执行自己这条日志,而且这个日志retry_cnt__c不是0
        else if (String.isNotBlank(loginId)) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                    Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                    retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                    FROM BatchIF_Log__c
                    WHERE RowDataFlg__c = true
                    AND retry_cnt__c != 0
                    AND id = : loginId ]
                    WHERE RowDataFlg__c = TRUE AND retry_cnt__c != 0 AND id = :loginId
                ]
                );
        }
        // gzw 603 重发判断 暂时用
        // 2023-01-19   zyh   add start
        else if (String.isNotBlank(typeNFM) && String.isNotBlank(messageGroupNumber) && times == null) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                                       AND Type__c = : typeNFM AND MessageGroupNumber__c = : messageGroupNumber
                    WHERE RowDataFlg__c = TRUE AND Type__c = :typeNFM AND MessageGroupNumber__c = :messageGroupNumber
                                                    ]
                );
        }
@@ -99,43 +142,115 @@
        //20191224 HWAG-BK65E8 add start
        // if (String.isNotBlank(typeNFM) && String.isNotBlank(messageGroupNumber) && times != null) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                    WHERE
                        RowDataFlg__c = TRUE
                                         AND Type__c != 'NFM007'  // 2023-01-18   ZYH   ADD
                                        AND Type__c = : typeNFM AND CreatedDate >= : times AND MessageGroupNumber__c >= : messageGroupNumber
                                                     order by MessageGroupNumber__c asc ]
                        AND Type__c = :typeNFM
                        AND CreatedDate >= :times
                        AND MessageGroupNumber__c >= :messageGroupNumber
                    ORDER BY MessageGroupNumber__c ASC
                ]
                );
            //20191224 HWAG-BK65E8 add end
        } else if (profileId.left(15).equals('00e10000000dzzG') || profileId.left(15).equals('00e10000000Y3o5')) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                    WHERE
                        RowDataFlg__c = TRUE
                                         AND Type__c != 'NFM007'  // 2023-01-18   ZYH   ADD
                                        AND ((retry_cnt__c != null AND retry_cnt__c > 0 AND retry_cnt__c < : max_cnt)
                                            OR (NFM501Future_Count__c != null
                                                AND NFM501Future_Count__c > 0 AND NFM501Future_Count__c < : max_cnt)
                                            OR(NFM501_Web_Annex_Count__c != null
                                               AND NFM501_Web_Annex_Count__c > 0 AND NFM501_Web_Annex_Count__c < : max_cnt))]
                        AND ((retry_cnt__c != NULL
                        AND retry_cnt__c > 0
                        AND retry_cnt__c < :max_cnt)
                        OR (NFM501Future_Count__c != NULL
                        AND NFM501Future_Count__c > 0
                        AND NFM501Future_Count__c < :max_cnt)
                        OR (NFM501_Web_Annex_Count__c != NULL
                        AND NFM501_Web_Annex_Count__c > 0
                        AND NFM501_Web_Annex_Count__c < :max_cnt))
                ]
                );
        }else {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                    WHERE
                        RowDataFlg__c = TRUE
                                         AND Type__c != 'NFM007'  // 2023-01-18   ZYH   ADD
                                        AND ((retry_cnt__c != null AND retry_cnt__c > 0 AND retry_cnt__c < : max_cnt)
                                            OR (NFM501Future_Count__c != null
                                                AND NFM501Future_Count__c > 0 AND NFM501Future_Count__c < : max_cnt)
                                            OR(NFM501_Web_Annex_Count__c != null
                                               AND NFM501_Web_Annex_Count__c > 0 AND NFM501_Web_Annex_Count__c < : max_cnt))
                        AND ((retry_cnt__c != NULL
                        AND retry_cnt__c > 0
                        AND retry_cnt__c < :max_cnt)
                        OR (NFM501Future_Count__c != NULL
                        AND NFM501Future_Count__c > 0
                        AND NFM501Future_Count__c < :max_cnt)
                        OR (NFM501_Web_Annex_Count__c != NULL
                        AND NFM501_Web_Annex_Count__c > 0
                        AND NFM501_Web_Annex_Count__c < :max_cnt))
                                       AND ownerId = : UserInfo.getUserId()
                                       ORDER BY CreatedDate // 2023-02-04   ZYH   ADD
                                       ]
@@ -163,12 +278,14 @@
            if (strType_c == 'NFM001') {
                NFM001Controller.execute(rowData, null);
            }
            if (strType_c == 'NFM002') {
                NFM002WebService.execute(rowData.Id);
            }
            if (strType_c == 'NFM006') {
                NFM006WebService.execute(rowData.Id);
            }
            // 清理Apex 20230428 LHJ Start
            //if (strType_c == 'NFM002') {
            //    NFM002WebService.execute(rowData.Id);
            //}
            //if (strType_c == 'NFM006') {
            //    NFM006WebService.execute(rowData.Id);
            //}
            // 清理Apex 20230428 LHJ End
            if (strType_c == 'NFM007') {
                NFM007Controller.execute(rowData, null);
            }
@@ -330,17 +447,20 @@
            // if (strType_c == 'NFM624') {//智慧医疗pk
            //     NFM624Rest.main(rowData.Id);
            // }
            if (strType_c == 'NFM624Rest2') {//智慧医疗pk
            if (strType_c == 'NFM624Rest2') {
                //智慧医疗pk
                NFMUtil.againSendToAWS624(rowData.Id);
            }
            //zhj 新方案改造 2023-01-06 end
            if (strType_c == 'NFM622') {
                NFM622Controller.execute(rowData, null);
            }
            if (strType_c == 'NFM112') {//先款后修pk
            if (strType_c == 'NFM112') {
                //先款后修pk
                NFM112Controller.ManualExecute(rowData.id);
            }
            if (strType_c == 'NFM113') {//先款后修pk
            if (strType_c == 'NFM113') {
                //先款后修pk
                NFM113Rest.main(rowData.id);
            }
            if (strType_c == 'NFM701') {
@@ -534,8 +654,6 @@
    }
    global void finish(Database.BatchableContext BC) {
        BatchEmailUtil.removeOtherSc('LogAutoSendSchedule', scB1.scName);  //20230203 lt 计划的作业优化
        // 今回はやることないです
        // 20220318 ljh SWAG-CC54R2 add start
        if(String.isNotBlank(typeNFM) && typeNFM == 'NFM010' && isForecast){
force-app/main/default/classes/OCSMHandler.cls
@@ -1,15 +1,15 @@
public with sharing class OCSMHandler extends Oly_TriggerHandler {
    //LY          2021/11/12                  start
    //平台窗口1、2、3任何一个有变更都会触发客户人员接口,向共通平台发送
    public static void OCSMToUser(List<OCM_Management_Province__c> newList, Map<Id, OCM_Management_Province__c> newMap, List<OCM_Management_Province__c> oldList, Map<Id, OCM_Management_Province__c> oldMap){
    public static void OCSMToUser(
        List<OCM_Management_Province__c> newList,
        Map<Id, OCM_Management_Province__c> newMap,
        List<OCM_Management_Province__c> oldList,
        Map<Id, OCM_Management_Province__c> oldMap
    ) {
        OCM_Management_Province__c old = null;
        List<String> noList = new List<String>();
        //Add By Li Jun 20230420 Start OCSM省的【营业窗口】人员发生变动时,需要更新现有的未完成的签收单的【营业助理】值
        Set<String> changedWindowProvince = new set<String>();
        //Add By Li Jun 20230420 End
        for (OCM_Management_Province__c local : newList) {
            if (Trigger.isInsert) {
                if (String.isNotBlank(local.OnlinePlatformWindow1__c)) {
                    noList.add(local.OnlinePlatformWindow1__c);
@@ -48,23 +48,11 @@
                        noList.add(old.OnlinePlatformWindow3__c);
                    }
                }
                //Add By Li Jun 20230420 Start
                if (local.Window1__c != null &&  local.Window1__c != old.Window1__c) {
                    changedWindowProvince.add(local.Name);
                }                
                //Add By Li Jun 20230420 End
            }
        }
        if (noList.size() > 0) {
            NFM621Controller.callout('',  noList);
        }
        //Add By Li Jun 20230420 Start
        if(changedWindowProvince.size() > 0){
            SyncProvinceWIndowToSignForm.syncProvinceWIndow(changedWindowProvince);
        }
        //Add By Li Jun 20230420 End
    }
}
//LY          2021/11/12                  end
force-app/main/default/classes/updateESignBatch.cls
@@ -40,7 +40,6 @@
    global Boolean ManualExecution_Identification = false;
    //默认跑所有签收单
    global updateESignBatch() {
        iflog = new BatchIF_Log__c();
        iflog.Type__c = 'ESignBatch';
        iflog.Is_Error__c = 0;
@@ -88,7 +87,6 @@
    }
    //更新某一条的签收单
    global updateESignBatch(String id) {
        //手动标识置成true
        this.ManualExecution_Identification = true;
        system.debug('手动传参1:' + ManualExecution_Identification);
@@ -138,9 +136,11 @@
            // 如果哟同名的Batch计划删除已存在的计划重新设置
            if (haveError) {
                haveError = false;
                for (CronTrigger ct : [SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
                for (CronTrigger ct : [
                    SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
                                       FROM CronTrigger
                                       WHERE CronJobDetail.Name = :scB.scName]) {
                    WHERE CronJobDetail.Name = :scB.scName
                ]) {
                    System.abortJob(ct.Id);
                }
                try {
@@ -242,17 +242,17 @@
            b.scName = baseName + '001';
            b.scTime = '0 ' + minMin + ' ' + (hour + 1) + ' ' + day + ' ' + month + ' ? ' + year;
            // system.schedule(sJobame,'0 ' + minMin + ' ' + (hour + 1) +' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
        }
        return b;
    }
    public static void removeOtherSc(String likeName, String needName) {
        String likeStr = likeName + '00%';
        for (CronTrigger ct : [SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
        for (CronTrigger ct : [
            SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
                               FROM CronTrigger
                               WHERE CronJobDetail.Name Like :likeStr
                               AND CronJobDetail.Name != :needName]) {
            WHERE CronJobDetail.Name LIKE :likeStr AND CronJobDetail.Name != :needName
        ]) {
            System.abortJob(ct.Id);
        }
    }
@@ -286,10 +286,8 @@
        //存放 签收单id,文件数量
        Map < String, Integer > fileMap = new Map < String, Integer > ();
        //驳回后删除文件 后  排序问题  精琢技术 wql  2020/12/24 start
        // List<Attachment> esignAttachAgencyList = new List<Attachment>();
        // List<Attachment> esignAttachHPList = new List<Attachment>();
        List<FileAddress__c> esignAttachAgencyList = new List<FileAddress__c>();        //zhj Attachment To AWS 2023-02-06
        List<FileAddress__c> esignAttachHPList = new List<FileAddress__c>();            //zhj Attachment To AWS 2023-02-06
        List<Attachment> esignAttachAgencyList = new List<Attachment>();
        List<Attachment> esignAttachHPList = new List<Attachment>();
        Map<String, Integer> fileAgencyMap = new Map<String, Integer>();
        Map<String, Integer> fileHPMap = new Map<String, Integer>();
        //驳回后删除文件 后  排序问题  精琢技术 wql  2020/12/24 end
@@ -311,20 +309,13 @@
        //存放所有签收单录入表id
        List < String > luruIsLastSubmitList = new List < String > ();
        // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
        //判断是否有未处理的录入表
        // Map < Id, eSignFormEntry__c > unprocessedESignEneryMap = new Map < Id, eSignFormEntry__c > ();
        Map < Id, List<eSignFormEntry__c> > unprocessedESignEneryMap = new Map < Id, List<eSignFormEntry__c> > ();
        List<eSignFormEntry__c> unprocessedEntries = new List<eSignFormEntry__c>();
        // Map <Id, eSignFormEntry__c> unprocessedEntries = new Map<Id, eSignFormEntry__c>();
        // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
        Map<Id, eSignFormEntry__c> unprocessedESignEneryMap = new Map<Id, eSignFormEntry__c>();
        //用于判断删除驳回的附件的筛选条件
        Map < Id, eSignForm__c > rejectESignEneryMap = new Map < Id, eSignForm__c > ();
        //驳回后 删除之前上传的文件id
        //List<Attachment> deleteLastFileList = new List<Attachment>();
        List<FileAddress__c> deleteLastFileList = new List<FileAddress__c>();       //zhj Attachment To AWS 2023-02-06
        List<Attachment> deleteLastFileList = new List<Attachment>();
        //存放未更新前的经销商审批状态
        Map < String, String > oldESignAgencyStatusMap = new Map < String, String > ();
        //存放未更新前的医院审批状态
@@ -351,55 +342,39 @@
                    if (esForm.agencyRejectDate__c != null || esForm.HPRejectDate__c != null) {
                        rejectESignEneryMap.put(esForm.Id, esForm);
                    }
                }
            }
            system.debug('rejectESignEneryMap:' + rejectESignEneryMap);
            //如果map不为空 则作为筛选条件
            if (rejectESignEneryMap.size()>0) {
                // List<Attachment> deleteFileList = [SELECT parentId, createdDate, Name,Description
                //                                    FROM Attachment
                //                                    WHERE parentId IN: rejectESignEneryMap.keySet() order by createdDate];
                List<FileAddress__c> deleteFileList = [SELECT ParentRecordId__c, createdDate, FileName__c
                                                        FROM FileAddress__c
                                                        WHERE ParentRecordId__c IN: rejectESignEneryMap.keySet() order by createdDate];  //zhj Attachment To AWS 2023-02-06
                List<Attachment> deleteFileList = [
                    SELECT parentId, createdDate, Name, Description
                    FROM Attachment
                    WHERE parentId IN :rejectESignEneryMap.keySet()
                    ORDER BY createdDate
                ];
                system.debug('deleteFileList:' + deleteFileList);
                if (deleteFileList.size() > 0) {
                    for (eSignForm__c esFile : rejectESignEneryMap.values()) {
                        //for (Attachment att : deleteFileList) {
                        for (FileAddress__c att : deleteFileList) {             //zhj Attachment To AWS 2023-02-06
                        for (Attachment att : deleteFileList) {
                            if (esFile.agencyRejectDate__c != null || esFile.HPRejectDate__c != null) {
                                if (att.ParentRecordId__c == esFile.Id ) {
                                if (att.parentId == esFile.Id) {
                                    //①经销商驳回后需要删除的附件
                                    if (esFile.agencyRejectDate__c != null) {
                                        //zhj Attachment To AWS 2023-02-06
                                        // if (att.Name.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) {
                                        //     deleteLastFileList.add(att);
                                        // }
                                        if (att.FileName__c.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) {
                                        if (att.Name.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) {
                                            deleteLastFileList.add(att);
                                        }
                                    }
                                    //②医院驳回后需要删除的附件
                                    if (esFile.HPRejectDate__c != null) {
                                        //zhj Attachment To AWS 2023-02-06
                                        // if (att.Name.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) {
                                        //     deleteLastFileList.add(att);
                                        // }
                                        if (att.FileName__c.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) {
                                        if (att.Name.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) {
                                            deleteLastFileList.add(att);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            system.debug('驳回后删除的文件:' + deleteLastFileList);
@@ -409,11 +384,46 @@
            }
            //检索所有录入表
            List < eSignFormEntry__c > eSignFormEntryList = [select id, Name, entryType__c, eSignForm__c, eSignForm__r.OCM_man_province_cus__c, salesManageConfirmDate__c, salesHPManageConfirmDate__c, agencyScanDayBack__c, agencySignUpDateBack__c, agencyConfirmDateBack__c, HPScanDayBack__c, HPSignUpDateBack__c, HPConfirmDateBack__c,
                                       eSignForm__r.Name, IsSubmit__c, IsHPSubmit__c, IsAgencyConfirmSubmit__c, agencyAutoSignUpStatus__c, HPSignUpStatus__c, Sales_Root_Formula__c, Sales_assistant_ID__c, IsHandled__c, IsHPHandled__c, createdDate, AgencyWorkflowEmailBack__c, HPWorkflowEmailBack__c, AgencyWorkflowEmail__c, HPWorkflowEmail__c, eSignForm__r.Id, agencyDNSignUpStatus__c, HPDNSignUpStatus__c, agencyReject__c, HPReject__c, IsAgencyScan__c, IsHPScan__c
                                       from eSignFormEntry__c
                                       where eSignForm__c IN: esFormidList
                                       order by eSignForm__c, createdDate asc
            List<eSignFormEntry__c> eSignFormEntryList = [
                SELECT
                    id,
                    Name,
                    entryType__c,
                    eSignForm__c,
                    eSignForm__r.OCM_man_province_cus__c,
                    salesManageConfirmDate__c,
                    salesHPManageConfirmDate__c,
                    agencyScanDayBack__c,
                    agencySignUpDateBack__c,
                    agencyConfirmDateBack__c,
                    HPScanDayBack__c,
                    HPSignUpDateBack__c,
                    HPConfirmDateBack__c,
                    eSignForm__r.Name,
                    IsSubmit__c,
                    IsHPSubmit__c,
                    IsAgencyConfirmSubmit__c,
                    agencyAutoSignUpStatus__c,
                    HPSignUpStatus__c,
                    Sales_Root_Formula__c,
                    Sales_assistant_ID__c,
                    IsHandled__c,
                    IsHPHandled__c,
                    createdDate,
                    AgencyWorkflowEmailBack__c,
                    HPWorkflowEmailBack__c,
                    AgencyWorkflowEmail__c,
                    HPWorkflowEmail__c,
                    eSignForm__r.Id,
                    agencyDNSignUpStatus__c,
                    HPDNSignUpStatus__c,
                    agencyReject__c,
                    HPReject__c,
                    IsAgencyScan__c,
                    IsHPScan__c
                FROM eSignFormEntry__c
                WHERE eSignForm__c IN :esFormidList
                ORDER BY eSignForm__c, createdDate ASC
                                                            ];
            if (eSignFormEntryList.size() > 0) {
@@ -424,16 +434,9 @@
                        eSignStringMap.put(eSignFormEntryWhole.Id, eSignFormEntryWhole);
                        //②所有的 用于更新文件(包含已处理未处理的数据 )
                        fileIdList.add(eSignFormEntryWhole.Id);
                        // 这里是什么鬼?都不判断一下签收单id的?
                        // if (eSignFormEntryWhole.IsHandled__c == false) {
                        if (eSignFormEntryWhole.IsHandled__c == false && eSignFormEntryWhole.eSignForm__r.Id  == eid) {
                        if (eSignFormEntryWhole.IsHandled__c == false) {
                            //未处理的
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
                            // unprocessedESignEneryMap.put(eid, eSignFormEntryWhole);
                            List<eSignFormEntry__c> entries = unprocessedESignEneryMap.size() > 0 && unprocessedESignEneryMap.keySet().contains(eid) ? unprocessedESignEneryMap.get(eid) : new List<eSignFormEntry__c>();
                            entries.add(eSignFormEntryWhole);
                            unprocessedESignEneryMap.put(eid, entries);
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 end
                            unprocessedESignEneryMap.put(eid, eSignFormEntryWhole);
                        }
                        if (eSignFormEntryWhole.eSignForm__r.Id  == eid) {
                            //存放 签收单id,录入表id 文件用
@@ -441,7 +444,6 @@
                            //存放签收单录入表,id,name 文件用
                            eSignNameMap.put(eid, eSignFormEntryWhole.eSignForm__r.Name);
                        }
                        //存放录入表id,记录类型 id,type 文件用
                        eSignTypeMap.put(eSignFormEntryWhole.Id, eSignFormEntryWhole.entryType__c);
@@ -453,10 +455,8 @@
                for (Id esFormid : esFormidList) {
                    //内层是签收单录入表
                    for (eSignFormEntry__c eSignFormEntry : eSignFormEntryList) {
                        //①取最新的 录入表 + 未处理的
                        if (esFormid.equals(eSignFormEntry.eSignForm__c)) {
                            if (!eSignFormEntry.IsHandled__c) {
                                //存放 签收单id,录入表id
                                eSignIdMap.put(esFormid, eSignFormEntry.Id);
@@ -465,9 +465,7 @@
                                // break;
                            }
                            eSignFormLastIdMap.put(esFormid, eSignFormEntry.Id);
                        }
                    }
                }
                //最后更新的录入表id
@@ -482,42 +480,26 @@
                //重新对附件排序  规则变为根据签收单现有附件序号进行排序 精琢技术 wql start
                //暂时存放一下签收单名称
                Map<string, string> tempMap = new Map<string, string>();
                //zhj Attachment To AWS 2023-02-06
                // List<Attachment> tempAttList = [SELECT parentId, createdDate, Name,Description
                //                                 FROM Attachment
                //                                 WHERE parentId IN: esFormidList order by createdDate];
                List<FileAddress__c> tempAttList = [SELECT ParentRecordId__c, createdDate, FileName__c
                                                FROM FileAddress__c
                                                WHERE ParentRecordId__c IN: esFormidList order by createdDate];
                List<Attachment> tempAttList = [
                    SELECT parentId, createdDate, Name, Description
                    FROM Attachment
                    WHERE parentId IN :esFormidList
                    ORDER BY createdDate
                ];
                if (tempAttList.size() > 0) {
                    //外层循环签收单
                    for (String es : esFormidList) {
                        //zhj Attachment To AWS 2023-02-06
                        //内层循环附件
                        // for (Attachment att : tempAttList) {
                        //     //如果id相等
                        //     if (es.equals(att.parentId)) {
                        //         //根据名称拆分 存入不同list
                        //         String name = att.Name;
                        //         if (name.substring(0, 1).equals('A')) {
                        //             esignAttachAgencyList.add(att);
                        //         } else if (name.substring(0, 1).equals('H')) {
                        //             esignAttachHPList.add(att);
                        //         }
                        //     }
                        // }
                        for (FileAddress__c att : tempAttList) {
                        for (Attachment att : tempAttList) {
                            //如果id相等
                            if (es.equals(att.ParentRecordId__c)) {
                            if (es.equals(att.parentId)) {
                                //根据名称拆分 存入不同list
                                String name = att.FileName__c;
                                String name = att.Name;
                                if (name.substring(0, 1).equals('A')) {
                                    esignAttachAgencyList.add(att);
                                } else if (name.substring(0, 1).equals('H')) {
                                    esignAttachHPList.add(att);
                                }
                            }
                        }
                        //分别存入到经销商or医院的附件map 用于后期命名
@@ -530,7 +512,6 @@
                        //清空list 供下一个签收单使用
                        esignAttachAgencyList.clear();
                        esignAttachHPList.clear();
                    }
                }
                system.debug('fileAgencyMap:' + fileAgencyMap);
@@ -538,9 +519,20 @@
                //重新对附件排序  规则变为根据签收单现有附件序号进行排序 精琢技术 wql end
                //根据所有的签收单录入表id检索所有的签收单明细录入
                List < eSignFormLineItemEntry__c > eSignFormLineItemEntryLists = [select id, eSignFormEntry__r.entryType__c, eSignFormEntry__r.IsHandled__c, eSignFormLineItem__c, eSignFormEntry__c,
                                                   agencyConfirmResult__c, HPConfirmResult__c, HPGoodStatus__c, agencyGoodStatus__c
                                                   from eSignFormLineItemEntry__c where eSignFormEntry__c in : luruIsSubmitList  and eSignFormEntry__r.IsHandled__c = false order by createdDate asc
                List<eSignFormLineItemEntry__c> eSignFormLineItemEntryLists = [
                    SELECT
                        id,
                        eSignFormEntry__r.entryType__c,
                        eSignFormEntry__r.IsHandled__c,
                        eSignFormLineItem__c,
                        eSignFormEntry__c,
                        agencyConfirmResult__c,
                        HPConfirmResult__c,
                        HPGoodStatus__c,
                        agencyGoodStatus__c
                    FROM eSignFormLineItemEntry__c
                    WHERE eSignFormEntry__c IN :luruIsSubmitList AND eSignFormEntry__r.IsHandled__c = FALSE
                    ORDER BY createdDate ASC
                                                                                 ];
                if (eSignFormLineItemEntryLists.size() > 0) {
                    for (eSignFormLineItemEntry__c eSignFormLineItemEntry : eSignFormLineItemEntryLists) {
@@ -550,7 +542,11 @@
                system.debug('eSignFormLineIdList:' + eSignFormLineIdList);
                if (eSignFormLineIdList.size() > 0) {
                    //根据签收单明细录入表 去检索签收单明细
                    List < eSignFormLineItem__c > eSignFormLineItemList = [select id, agencyGoodStatus__c, HPGoodStatus__c from eSignFormLineItem__c where id IN: eSignFormLineIdList];
                    List<eSignFormLineItem__c> eSignFormLineItemList = [
                        SELECT id, agencyGoodStatus__c, HPGoodStatus__c
                        FROM eSignFormLineItem__c
                        WHERE id IN :eSignFormLineIdList
                    ];
                    if (eSignFormLineItemList.size() > 0) {
                        //外层签收单明细
                        for (eSignFormLineItem__c eSignFormLineItem : eSignFormLineItemList) {
@@ -570,7 +566,6 @@
                if (eSignFormLineIdList.size() > 0) {
                    //循环 更新签收单
                    for (Id esefId : eSignFormLineIdList) {
                        if (lasteSignFormLineItemEntryMap.containsKey(esefId)) {
                            eSignFormLineItemEntry__c luru = lasteSignFormLineItemEntryMap.get(esefId);
                            //new 一个签收单明细对象
@@ -591,8 +586,6 @@
                                eSignFormLuRuList.add(eSignLuRu);
                            }
                        }
                    }
                }
                System.debug('更新的签收单明细list:' + eSignFormLuRUList);
@@ -609,17 +602,12 @@
                        //销售渠道
                        String Sales_Root_Formula;
                        //录入类型 
                        String type; // 这东西没有用
                        String type;
                        System.debug('lasteSignFormEntryMap:' + lasteSignFormEntryMap);
                        if (lasteSignFormEntryMap.containsKey(eSignFormid)) {
                            eSignForm.id = eSignFormid;
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
                            //签收单id
                            // eSignFormEntry__c eSignFormEntry = lasteSignFormEntryMap.get(eSignFormid);
                            for (eSignFormEntry__c eSignFormEntry : unprocessedESignEneryMap.get(eSignFormid)) {
                                // 根据录入类型去更新对应的部分数据
                                // entryType__c包含经销商
                                if (String.isNotBlank(eSignFormEntry.entryType__c) && eSignFormEntry.entryType__c.contains('经销商')) {
                            eSignFormEntry__c eSignFormEntry = lasteSignFormEntryMap.get(eSignFormid);
                                    //如果经销商确认日为空的话 进去判断更新经销商审批状态
                                    if (eSignFormEntry.agencyDNSignUpStatus__c != '签收已完成') {
                                        if (eSignFormEntry.agencyConfirmDateBack__c == null) {
@@ -628,9 +616,7 @@
                                                eSignForm.agencyReject__c = false;
                                            } else {
                                                if (eSignFormEntry.agencyScanDayBack__c != null && eSignFormEntry.IsAgencyScan__c) {
                                                    // 调整草案中的赋值逻辑,多端操作的情况下有可能先申请后草案
                                                    // eSignForm.agencyAutoSignUpStatus__c = '草案中';
                                                    eSignForm.agencyAutoSignUpStatus__c = String.isBlank(eSignForm.agencyAutoSignUpStatus__c) ? '草案中' : eSignForm.agencyAutoSignUpStatus__c;
                                            eSignForm.agencyAutoSignUpStatus__c = '草案中';
                                                    eSignForm.agencyReject__c = false;
                                                }
                                            }
@@ -642,12 +628,37 @@
                                            oldESignAgencyStatusMap.put('A' + eSignForm.id, '无');
                                        }
                                    }
                            if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') {
                                //如果医院确认日为空的话 进去判断更新医院审批状态
                                if (eSignFormEntry.salesHPManageConfirmDate__c == null) {
                                    if (eSignFormEntry.IsHPSubmit__c == true) {
                                        eSignForm.HPSignUpStatus__c = '申请中';
                                        eSignForm.HPReject__c = false;
                                    } else {
                                        if (eSignFormEntry.HPScanDayBack__c != null && eSignFormEntry.IsHPScan__c) {
                                            eSignForm.HPSignUpStatus__c = '草案中';
                                            eSignForm.HPReject__c = false;
                                        }
                                    }
                                }
                                //未更新前的医院审批状态 用于文件累计汇总
                                if (eSignFormEntry.HPSignUpStatus__c != null && eSignFormEntry.HPSignUpStatus__c != '') {
                                    oldESignHPStatusMap.put('H' + eSignForm.id, eSignFormEntry.HPSignUpStatus__c);
                                } else {
                                    oldESignHPStatusMap.put('H' + eSignForm.id, '无');
                                }
                            }
                                    //如果没变化则不更新
                                    if (eSignFormEntry.AgencyWorkflowEmailBack__c != eSignFormEntry.AgencyWorkflowEmail__c) {
                                        //经销商邮件
                                        eSignForm.AgencyWorkflowEmail__c = eSignFormEntry.AgencyWorkflowEmailBack__c;
                                    }
                                    // 日期更新
                            //如果没变化则不更新
                            if (eSignFormEntry.HPWorkflowEmailBack__c != eSignFormEntry.HPWorkflowEmail__c) {
                                //医院邮件
                                eSignForm.HPWorkflowEmail__c = eSignFormEntry.HPWorkflowEmailBack__c;
                            }
                                    if (eSignFormEntry.agencyDNSignUpStatus__c != '签收已完成') {
                                        //经销商扫描日
                                        if (eSignFormEntry.agencyScanDayBack__c != null) {
@@ -662,37 +673,7 @@
                                            eSignForm.agencyConfirmDate__c = eSignFormEntry.agencyConfirmDateBack__c;
                                        }
                                    }
                                }
                                // entryType__c包含医院
                                if (String.isNotBlank(eSignFormEntry.entryType__c) && eSignFormEntry.entryType__c.contains('医院')) {
                                    if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') {
                                        //如果医院确认日为空的话 进去判断更新医院审批状态
                                        if (eSignFormEntry.salesHPManageConfirmDate__c == null) {
                                            if (eSignFormEntry.IsHPSubmit__c == true) {
                                                eSignForm.HPSignUpStatus__c = '申请中';
                                                eSignForm.HPReject__c = false;
                                            } else {
                                                if (eSignFormEntry.HPScanDayBack__c != null && eSignFormEntry.IsHPScan__c) {
                                                    // 调整草案中的赋值逻辑,多端操作的情况下有可能先申请后草案
                                                    // eSignForm.HPSignUpStatus__c = '草案中';
                                                    eSignForm.HPSignUpStatus__c = String.isBlank(eSignForm.HPSignUpStatus__c) ? '草案中' : eSignForm.HPSignUpStatus__c;
                                                    eSignForm.HPReject__c = false;
                                                }
                                            }
                                        }
                                        //未更新前的医院审批状态 用于文件累计汇总
                                        if(eSignFormEntry.HPSignUpStatus__c!=null &&eSignFormEntry.HPSignUpStatus__c!=''){
                                            oldESignHPStatusMap.put('H' + eSignForm.id, eSignFormEntry.HPSignUpStatus__c);
                                        }else{
                                            oldESignHPStatusMap.put('H' + eSignForm.id, '无');
                                        }
                                    }
                                    //如果没变化则不更新
                                    if (eSignFormEntry.HPWorkflowEmailBack__c != eSignFormEntry.HPWorkflowEmail__c) {
                                        //医院邮件
                                        eSignForm.HPWorkflowEmail__c = eSignFormEntry.HPWorkflowEmailBack__c;
                                    }
                                    // 日期更新
                                    if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') {
                                        //医院扫描日
                                        if (eSignFormEntry.HPScanDayBack__c != null) {
@@ -707,9 +688,9 @@
                                            eSignForm.HPConfirmDate__c = eSignFormEntry.HPConfirmDateBack__c;
                                        }
                                    }
                                }
                                //给营业助理赋值
                                //eSignForm.Sales_assistant_name_text__c = eSignFormEntry.Sales_assistant_ID__c;// Commented By Li Jun 20230420
                            eSignForm.Sales_assistant_name_text__c = eSignFormEntry.Sales_assistant_ID__c;
                                //存一个id
                                idlast = eSignFormEntry.Id;
                                //签收单name用作文件命名
@@ -723,36 +704,22 @@
                                //销售渠道 区分直销还是分销
                                Sales_Root_Formula = eSignFormEntry.Sales_Root_Formula__c;
                                //录入类型
                                type = eSignFormEntry.entryType__c; // 没有用
                                // 所有没有没有处理的entry都要标记为处理
                                eSignFormEntry.IsHandled__c = true;
                                unprocessedEntries.add(eSignFormEntry);
                                // unprocessedEntries.put(eSignFormEntry.Id, eSignFormEntry);
                            }
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 end
                            type = eSignFormEntry.entryType__c;
                        }
                        system.debug('签收单对象-----:' + eSignForm);
                        if (eSignForm != null) {
                            system.debug('eSignFormid:' + eSignFormid);
                            if (eSignForm.id != null) {
                                eSignFormList.add(eSignForm);
                            }
                        }
                        system.debug('eSignFormList111:' + eSignFormList);
                        if (eSignFormList.size() > 0) {
                            //更新OCSM管理省 担当
                            eSignFormList = updateOwner(provinceList, provinceMap, eSignFormList, false);
                        }
                    }
                }
            }
            if (eSignFormList.size() <= 0) {
@@ -760,29 +727,27 @@
                eSignFormList  = updateOwner(provinceList, provinceMap, eSignList, true);
            }
            List<Id> fileList = new List<Id> ();
            if (fileIdList.size() > 0) {
                for (Id fileId : fileIdList) {
                    if (!fileList.contains(fileId)) {
                        fileList.add(fileId);
                    }
                }
            }
            System.debug('fileIdList:' + fileIdList);
            System.debug('fileList:' + fileList);
            //用于最后insert 附件
            //zhj Attachment To AWS 2023-02-06
            //List<Attachment> insertAttactment = new List<Attachment>();
            List<FileAddress__c> insertAttactment = new List<FileAddress__c>();
            List<Attachment> insertAttactment = new List<Attachment>();
            //附件  start
            //List<Attachment> attachMentList = [SELECT id, parentId, Body, Name, ContentType,Description  from Attachment where parentId IN :fileList and Description!='电子签收单:已处理'];
            List<FileAddress__c> attachMentList = [SELECT id, ParentRecordId__c, FileName__c,subInfoType__c,AWS_File_Key__c,DownloadLink__c,ViewLink__c  from FileAddress__c where ParentRecordId__c IN :fileList and subInfoType__c  !='电子签收单:已处理'];
            List<Attachment> attachMentList = [
                SELECT id, parentId, Body, Name, ContentType, Description
                FROM Attachment
                WHERE parentId IN :fileList AND Description != '电子签收单:已处理'
            ];
            //修复已处理数据 附件没更新  即没有附件能提交的bug 精琢技术 wql 2021/01/19 start 
            //List<Attachment> eSignEntryAttachMentList = new List<Attachment>();
            List<FileAddress__c> eSignEntryAttachMentList = new List<FileAddress__c>();
            List<Attachment> eSignEntryAttachMentList = new List<Attachment>();
            //文件数量 用于文件命名
            Integer agencyCount = 0;
            Integer hpCount = 0;
@@ -811,16 +776,14 @@
                system.debug('eSignFlieIdMap:' + eSignFlieIdMap);
                system.debug('eSignNameMap:' + eSignNameMap);
                for (Id eSignFormEntryId : fileList) {
                    for (FileAddress__c attach : attachMentList) {          //zhj Attachment To AWS 2023-02-06
                        if (attach.ParentRecordId__c == eSignFormEntryId) {
                            Id eid = eSignFlieIdMap.get(attach.ParentRecordId__c);
                    for (Attachment attach : attachMentList) {
                        if (attach.parentId == eSignFormEntryId) {
                            Id eid = eSignFlieIdMap.get(attach.parentId);
                            system.debug('eid:' + eid);
                            name = eSignNameMap.get(eid);
                            system.debug('name:' + name);
                            type = eSignTypeMap.get(attach.ParentRecordId__c);
                            type = eSignTypeMap.get(attach.parentId);
                            //因为外层循环是中间表 如果2条以上录入表都有经销商附件 则使用最新构建的经销商附件数量来命名
                            //否则取未更新之前有的经销商附件数量 并且 不是1个录入表多个附件 也就是false的时候 取模拟的最新数量
@@ -831,8 +794,7 @@
                            }else if(agencySumCount>0){
                                //本次循环内 第一次取附件数最新值 后续都在此基础上i++
                                agencyCount =agencySumCount;
                            }
                            else if(fileAgencyMap.size() > 0){
                            } else if (fileAgencyMap.size() > 0) {
                                //只有一条数据时,使用此附件数即可 后续在此基础上i++
                                agencyCount = fileAgencyMap.get(eid);
                            }
@@ -861,8 +823,7 @@
                            }else if(hpSumCount >0 ){
                                //本次循环内 第一次取附件数最新值 后续都在此基础上j++
                                hpCount =hpSumCount;                        
                            }
                            else if(fileHPMap.size() > 0){
                            } else if (fileHPMap.size() > 0) {
                                //只有一条数据时,使用此附件数即可 后续在此基础上j++
                                hpCount = fileHPMap.get(eid);
                            }
@@ -915,30 +876,22 @@
                            //     title = title +'.jpg';
                            // }
                            //判断一下格式,不然下载下来是类型是所有文件 无法打开
                            //zhj Attachment To AWS 2023-02-06 start
                            if (attach.FileName__c.lastIndexOf('.') > -1) {
                                title = title + attach.FileName__c.substring(attach.FileName__c.lastIndexOf('.'));
                            if (attach.Name.lastIndexOf('.') > -1) {
                                title = title + attach.Name.substring(attach.Name.lastIndexOf('.'));
                            }
                            //Attachment newAttachment = attach.clone();
                            FileAddress__c newAttachment = attach.clone();
                            newAttachment.ParentRecordId__c = eid;
                            newAttachment.FileName__c = title;
                            Attachment newAttachment = attach.clone();
                            newAttachment.parentId = eid;
                            newAttachment.name = title;
                            // newAttachment.ContentType =attach.ContentType;
                            //要更新的签收单附件
                            insertAttactment.add(newAttachment);
                            //反更新录入表的附件 用来判断附件是否被更新
                            //Attachment oldAttachment = new  Attachment();
                            FileAddress__c oldAttachment = new  FileAddress__c();
                            Attachment oldAttachment = new Attachment();
                            oldAttachment.Id = attach.Id;
                            //oldAttachment.Description = '电子签收单:已处理';
                            oldAttachment.subInfoType__c = '电子签收单:已处理';
                            //zhj Attachment To AWS 2023-02-06 end
                            oldAttachment.Description = '电子签收单:已处理';
                            eSignEntryAttachMentList.add(oldAttachment);
                        }
                    }
                    //整单循环后 清空值
                    i = 0;
@@ -948,7 +901,6 @@
                    agencySumCount =0;
                    hpSumCount=0;
                }
            }
            //电子签收单 增加本次更新附件数量  2020/01/07 精琢技术 wql start
@@ -964,40 +916,34 @@
                if (eSignFormList.size() > 0) {
                    //外层所有签收单
                    for (eSignForm__c es : eSignFormList) {
                        //a为经销商附件的数量 h为医院附件的数量
                        Integer a = 0;
                        Integer h = 0;
                        //内层所有需要更新的附件
                        //for (Attachment att : insertAttactment) {
                        for (FileAddress__c att : insertAttactment) {   //zhj Attachment To AWS 2023-02-06
                        for (Attachment att : insertAttactment) {
                            if (es.Id != null) {
                                if (es.Id.equals(att.ParentRecordId__c)) {
                                if (es.Id.equals(att.parentId)) {
                                    if (es.agencyAutoSignUpStatus__c != null) {
                                        if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size()>0) {
                                                if(!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')){
                                                    if (att.FileName__c.substring(0, 1).equals('A')) {      //zhj Attachment To AWS 2023-02-06
                                                if (att.Name.substring(0, 1).equals('A')) {
                                                        a ++;
                                                    }
                                                }
                                        }
                                    }
                                    if (es.HPSignUpStatus__c != null) {
                                        if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size()>0) {
                                            if(!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')){
                                                if (att.FileName__c.substring(0, 1).equals('H')) {          //zhj Attachment To AWS 2023-02-06
                                                if (att.Name.substring(0, 1).equals('H')) {
                                                    h ++;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //只有真正扫码提交的 并且没有附件才会被更新
@@ -1006,7 +952,6 @@
                                if(!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')){
                                    es.agencyAttachNum__c = a;
                                }
                            }
                        }
                        //只有真正扫码提交的 并且没有附件才会被更新
@@ -1015,33 +960,15 @@
                                if(!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')){
                                     es.HPAttachNum__c = h;
                                }
                            }
                        }
                        a = 0;
                        h = 0;
                    }
                }
                //电子签收单 增加本次更新附件数量  2020/01/07 精琢技术 wql end
                //文件 end
            }
            // 更新签收单录入表
            if(unprocessedEntries.size() > 0) {
                Database.SaveResult[] lsr = Database.update(unprocessedEntries, false);
                // Database.SaveResult[] lsr = Database.update(unprocessedEntries.values(), false);
                eb.setError(lsr, MAXERRORCNT, eSignFormEntry__c.sObjectType);
                for (Integer tIdx = 0; tIdx < lsr.size(); tIdx++) {
                    Database.SaveResult sr = lsr[tIdx];
                    System.debug('sr.isSuccess:' + sr.isSuccess());
                    if (!sr.isSuccess()) {
                        Database.Error emsg = sr.getErrors()[0];
                        iflog.ErrorLog__c += 'ERROR ' + unprocessedEntries[tIdx].Id + ' eSignFormEntry__c:' + emsg + '\n';
                        // iflog.ErrorLog__c += 'ERROR ' + unprocessedEntries.values()[tIdx].Id + ' eSignFormEntry__c:' + emsg + '\n';
                    }
                }
            }
            system.debug('更新的签收单:' + eSignFormList);
            //更新签收单明细并添加日志
@@ -1070,17 +997,12 @@
                    }
                }
            }
        }catch(NullPointerException npe){
                iflog.ErrorLog__c += 'ERROR : eSignForm__c:空指针错误-行号:'+ npe.getLineNumber()+ '\n';
        }
        catch (Exception e) {
        } catch (Exception e) {
            // Database.rollback(sp);
                
            iflog.ErrorLog__c += 'ERROR : eSignForm__c:'+ e.getMessage() + '\n';
        }
        try{
            System.debug('luruIsLastSubmitList:'+luruIsLastSubmitList);
@@ -1098,7 +1020,7 @@
    private static void deleteMiddleData(Map < String, eSignFormEntry__c > eSignStringMap, List < String > luruIsSubmitList) {
        system.debug('检索的所有录入表:' + eSignStringMap);
        system.debug('最后录入的id :' + luruIsSubmitList + '----数量:' + luruIsSubmitList.size());
        list < eSignFormEntry__c > eSignFormDeleteList = new list < eSignFormEntry__c > ();
        list<eSignFormEntry__c> eSignFormDeleteList = new List<eSignFormEntry__c>();
        for (String essm : eSignStringMap.keySet()) {
            for (String lisl : luruIsSubmitList) {
                if (essm.equals(lisl)) {
@@ -1111,58 +1033,49 @@
        }
        system.debug('删除的数据id:' + eSignFormDeleteList + '----数量:' + eSignFormDeleteList.size());
        //删除签收单录入表其他数据
        if (eSignFormDeleteList.size() > 0) {
            //循环遍历id 删除文件
            List<String> fileDeleteIdList = new List<String> ();
            //List<Attachment> deleteAttachmentList = new List<Attachment>();
            List<FileAddress__c> deleteAttachmentList = new List<FileAddress__c>();     //zhj Attachment To AWS 2023-02-06
            List<Attachment> deleteAttachmentList = new List<Attachment>();
            for (eSignFormEntry__c eSigf : eSignFormDeleteList) {
                fileDeleteIdList.add(eSigf.Id);
            }
            //循环找到文件id
            if (fileDeleteIdList.size() > 0) {
                // 2022-02-28 shashiming Apex heap size too large
                // 去掉Body字段
                //List<Attachment> attachMentList = [SELECT id, parentId, Name, ContentType,Description  from Attachment where parentId = :fileDeleteIdList];
                List<FileAddress__c> attachMentList = [SELECT id, ParentRecordId__c, FileName__c,AWS_File_Key__c  from FileAddress__c where ParentRecordId__c = :fileDeleteIdList];       //zhj Attachment To AWS 2023-02-06
                List<Transaction_Log__c> tranList = new List<Transaction_Log__c>();
                List<Attachment> attachMentList = [
                    SELECT id, parentId, Name, ContentType, Description
                    FROM Attachment
                    WHERE parentId = :fileDeleteIdList
                ];
                if (attachMentList.size() > 0) {
                    for (FileAddress__c att : attachMentList) {
                        FileAddress__c am = new FileAddress__c();           //zhj Attachment To AWS 2023-02-06
                    for (Attachment att : attachMentList) {
                        Attachment am = new Attachment();
                        am.Id = att.Id;
                        deleteAttachmentList.add(am);
                        //zhj 新增日志,删除AWS的附件 2023-02-17
                        Transaction_Log__c tran = new Transaction_Log__c();
                        tran.AWS_Data_Id__c = att.AWS_File_Key__c;
                        tran.Status__c = 'In Process';
                        tran.Module__c = '签收单附件删除';
                        tranList.add(tran);
                    }
                    //新增日志,删除AWS的附件 zhj 2023-02-17
                    if(tranList.size() > 0){
                        insert tranList;
                    }
                    //删除文件
                    if (deleteAttachmentList.size() > 0) {
                        delete deleteAttachmentList;
                    }
                }
            }
            //删除录入表
            System.debug('删除录入表 : ' + eSignFormDeleteList);
            // delete eSignFormDeleteList;  // 2023-03-14 ssm 暂时不自动删除中间表数据,方便短期内做check
            delete eSignFormDeleteList;
        }
    }
    @TestVisible
    //更新营业部担当
    private static List < eSignForm__c > updateOwner(List < String > provinceList, Map < Id, String > provinceMap, List < eSignForm__c > eSignFormList, boolean ocsmFlag) {
    private static List<eSignForm__c> updateOwner(
        List<String> provinceList,
        Map<Id, String> provinceMap,
        List<eSignForm__c> eSignFormList,
        boolean ocsmFlag
    ) {
        //营业担当 map
        Map < String, String > provinceOwnerMap = new Map < String, String > ();
        //营业助理 map
@@ -1170,14 +1083,18 @@
        List < eSignForm__c > eSignFormLastList = new List < eSignForm__c >();
        //检索OCSM管理省对象
        List < OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c,Window1__c    from OCM_Management_Province__c where Name IN: provinceList];
        List<OCM_Management_Province__c> ompList = [
            SELECT id, Name, SalesManage__c, GI_assistant__c
            FROM OCM_Management_Province__c
            WHERE Name IN :provinceList
        ];
        //存放map<省,担当>
        for (OCM_Management_Province__c omp : ompList) {
            //不用map<String,list>的 原因是 想 ocsm管理省 和签收单 营业担当的顺序保持一致
            //String salesManage = omp.SalesManage__c+','+omp.SalesManage2__c+','+omp.SalesManage3__c;
            //provinceOwnerMap.put(omp.Name, salesManage);
            provinceOwnerMap.put(omp.Name, omp.SalesManage__c);
            provinceGIMap.put(omp.Name, omp.Window1__c);//Update By Li Jun 20230420 for  签收单营业助理从GI/SP助理改为签收单OCSM省的营业窗口
            provinceGIMap.put(omp.Name, omp.GI_assistant__c);
        }
        //①为true的时候 是其他没发生变化只有ocsm省上营业担当改变
        //②为false的时候,有中间表正常更新的情况
@@ -1223,7 +1140,6 @@
        //             }
        //         }
        //     }
        //     return eSignFormLastList;
@@ -1257,8 +1173,10 @@
        if (ocsmFlag) {
            //给最后要更新的签收单的审批者(营业部担当)赋值
            for (Integer cnt = 0; cnt < eSignFormList.size(); cnt++) {
                if (provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id)) != eSignFormList[cnt].RC_Manager__c ||provinceMap.get(eSignFormList[cnt].Id).equals('集采课')) {
                if (
                    provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id)) != eSignFormList[cnt].RC_Manager__c ||
                    provinceMap.get(eSignFormList[cnt].Id).equals('集采课')
                ) {
                    eSignForm__c eSignForm = new eSignForm__c();
                    eSignForm.Id = eSignFormList[cnt].Id;
                    eSignForm.RC_Manager__c = provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id));
@@ -1269,10 +1187,8 @@
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 end
                    eSignFormLastList.add(eSignForm);
                }
            }
            return eSignFormLastList;
        } else {
            //给最后要更新的签收单的审批者(营业部担当)赋值
            for (eSignForm__c esf : eSignFormList) {
@@ -1284,16 +1200,12 @@
                    }
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 end
                }
            }
            return eSignFormList;
        }
    }
    global void finish(Database.BatchableContext BC) {
        //更新该日志的数据信息
        iflog.Log__c += '\nupdateESignBatch end';
        String tmp = iflog.ErrorLog__c;
@@ -1331,7 +1243,7 @@
                //写死精琢用户 上线后应该会修改成自定义标签
                // String batchUserId = '00510000005sEEM';
                String batchUserId = System.Label.Batch_User_Id;
                List<User> us = [Select Id, NAme, Email From User Where Id = : batchUserId];
                List<User> us = [SELECT Id, NAme, Email FROM User WHERE Id = :batchUserId];
                if (!us.isEmpty()) {
                    User use = us[0];
                    if (String.isNotBlank(use.Email)) {
@@ -1339,11 +1251,7 @@
                        if (System.Label.ESign_Error_Send_To_CC != 'null') {
                            MailCc = System.Label.ESign_Error_Send_To_CC.split(',');
                        }
                        FixtureUtil.sendMessage(batchUserId,
                                                MailCc,
                                                'updateESignBatch Error',
                                                body
                                               );
                        FixtureUtil.sendMessage(batchUserId, MailCc, 'updateESignBatch Error', body);
                    }
                }
            }
@@ -1376,12 +1284,16 @@
                                break;
                            }
                            for (Database.Error err : saveRe.getErrors()) {
                                String message = objectName + ':'
                                                 + objectLabel + ':'
                                                 + err.getStatusCode() + ':'
                                                 + err.getFields() + ':'
                                                 + err.getMessage();
                                String message =
                                    objectName +
                                    ':' +
                                    objectLabel +
                                    ':' +
                                    err.getStatusCode() +
                                    ':' +
                                    err.getFields() +
                                    ':' +
                                    err.getMessage();
                                // 数据里面有复数错误信息的话只获取第一条
                                messageMap.put(saveRe.getId(), message);
                                break;
@@ -1394,519 +1306,8 @@
    }
    //定时跑任务
    public Class ScBean {
    public class ScBean {
        public String scName;
        public String scTime;
    }
    public static void improveTestRate(){
        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++;
    }
}
force-app/main/default/classes/updateESignBatchTest.cls
@@ -2,33 +2,46 @@
private class updateESignBatchTest {
    //测试经销商收货
    static testMethod void testMethod1() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -39,7 +52,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -72,13 +85,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -107,7 +124,6 @@
        eSignForm.Statu_Achievements__c = Sac.Id;
        eSignForm.Name = '::测试电子签收单';
        insert eSignForm;
        eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c();
@@ -130,7 +146,6 @@
        eSignFormEntry2.HPConfirmDateBack__c = Date.today().addDays(-2);
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
@@ -155,7 +170,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -179,40 +194,52 @@
        Test.startTest();
        Database.executeBatch(new updateESignBatch(), 20);
        Test.stopTest();
    }
    //测试经销商确认
    static testMethod void testMethod2() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -223,7 +250,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -256,13 +283,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -313,7 +344,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -337,7 +367,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -367,33 +397,46 @@
    //测试医院收货
    static testMethod void testMethod3() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -404,7 +447,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -437,13 +480,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -495,7 +542,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -519,7 +565,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -546,33 +592,46 @@
    //测试医院确认
    static testMethod void testMethod4() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -583,7 +642,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -616,13 +675,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -674,7 +737,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -698,7 +760,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -724,35 +786,47 @@
        Test.stopTest();
    }
    static testMethod void testMethod5() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -763,7 +837,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -796,13 +870,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -924,7 +1002,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -952,33 +1030,46 @@
    }
    static testMethod void testMethod6() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -989,7 +1080,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1022,13 +1113,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1150,7 +1245,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1177,33 +1272,46 @@
    }
    static testMethod void testMethod7() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1214,7 +1322,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1247,13 +1355,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1375,7 +1487,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1404,33 +1516,46 @@
    }
    static testMethod void testMethod8() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1441,7 +1566,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1474,13 +1599,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1602,7 +1731,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1630,33 +1759,46 @@
    }
    static testMethod void testMethod9() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1667,7 +1809,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1700,13 +1842,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1828,7 +1974,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1857,33 +2003,46 @@
    }
    static testMethod void testMethod10() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1894,7 +2053,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1927,13 +2086,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2055,7 +2218,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2086,33 +2249,46 @@
    //测试经销商收货
    static testMethod void testMethod11() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2123,7 +2299,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2156,13 +2332,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2229,7 +2409,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry4;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -2267,7 +2446,7 @@
        insert eSignFormLineItemEntry4;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2294,33 +2473,46 @@
    }
    //测试医院确认
    static testMethod void testMethod12() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2331,7 +2523,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2364,13 +2556,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2422,7 +2618,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -2446,7 +2641,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2474,33 +2669,46 @@
        //测试经销商收货
    static testMethod void testMethod13() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2511,7 +2719,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2544,13 +2752,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2584,8 +2796,6 @@
        eSignForm.agencyRejectDate__c   = Date.today().addDays(2);
        eSignForm.HPRejectDate__c   = Date.today().addDays(2);
        insert eSignForm;
/*        eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c();
@@ -2609,12 +2819,10 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;*/
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
        eSignFormLineItem.eSignForm__c = eSignForm.Id;
        insert eSignFormLineItem;
@@ -2634,7 +2842,7 @@
        insert eSignFormLineItemEntry2;*/
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2658,42 +2866,52 @@
        Test.startTest();
        Database.executeBatch(new updateESignBatch(), 20);
        Test.stopTest();
    }
     //跑单独方法
    @isTest
    private static void test_upsertESignLineItems() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2704,7 +2922,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2737,13 +2955,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2767,16 +2989,12 @@
        );
        insert Sac;
        //新建电子签收单
        eSignForm__c eSignForm = new eSignForm__c();
        eSignForm.Statu_Achievements__c = Sac.Id;
        eSignForm.Name = '::测试电子签收单';
        
        insert eSignForm;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
@@ -2784,8 +3002,6 @@
        eSignFormLineItem.eSignForm__c = eSignForm.Id;
        insert eSignFormLineItem;
        /*list<Attachment> attachmentList = new list<Attachment>();
        Attachment attach=new Attachment();     
@@ -2893,14 +3109,12 @@
        // }
        OCM_Management_Province__c mp1 = new OCM_Management_Province__c();
        mp1.Name = '江西';
        mp1.GI_assistant__c = UserInfo.getUserId();
        mp1.SP_assistant__c = UserInfo.getUserId();
        mp1.Energy_assistant__c = UserInfo.getUserId();
        mp1.SalesManage__c = UserInfo.getUserId();
        mp1.Window1__c = UserInfo.getUserId();
        insert mp1;
@@ -2915,38 +3129,50 @@
        eSignFormList.add(eSignForm);
        updateESignBatch.updateOwner(provinceList,provinceMap,eSignFormList,true);
    }
        //测试经销商收货
    static testMethod void testMethod14() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2957,7 +3183,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2990,13 +3216,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -3027,14 +3257,12 @@
        eSignForm.agencyRejectDate__c   = Date.today().addDays(2);
        eSignForm.HPRejectDate__c   = Date.today().addDays(2);
        insert eSignForm;
        eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c();
        eSignFormEntry1.Name = '::电子签收单录入表1';
        eSignFormEntry1.eSignForm__c = eSignForm.Id;
        eSignFormEntry1.entryType__c = '经销商收货';
        
        insert eSignFormEntry1;
@@ -3051,7 +3279,6 @@
        eSignFormEntry2.HPConfirmDateBack__c = Date.today().addDays(-2);
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
@@ -3076,7 +3303,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -3094,7 +3321,6 @@
        attach1.parentId=eSignForm.id;
        attach1.ContentType = 'application/pdf';
        
        attachmentList.add(attach1);
        Attachment attach2=new Attachment();     
@@ -3104,21 +3330,13 @@
        attach2.parentId=eSignForm.id;
        attach2.ContentType = 'application/pdf';
        
        attachmentList.add(attach2);
        insert attachmentList;
        Test.startTest();
        Database.executeBatch(new updateESignBatch(), 20);
        Test.stopTest();
    }
    static testMethod void testMethod15(){
        Test.startTest();
        updateESignBatch.improveTestRate();
        Test.stopTest();
    }
}
force-app/main/default/lwc/lexCustomLightningDatatable/customOutputGoods.html
New file
@@ -0,0 +1,7 @@
<template>
    <c-custom-output-good
        output-value={typeAttributes.outputValue}
        output-type={typeAttributes.type}
        record-id={typeAttributes.recordId}
    ></c-custom-output-good>
</template>
force-app/main/default/lwc/lexCustomLightningDatatable/customReturnGoodInput.html
New file
@@ -0,0 +1,7 @@
<template>
    <c-lex-return-good-cus-input
        intput-value={typeAttributes.inputValue}
        box-price={typeAttributes.boxPrice}
        record-id={typeAttributes.recordId}
    ></c-lex-return-good-cus-input>
</template>
force-app/main/default/lwc/lexCustomLightningDatatable/customShipmentNumber.html
@@ -1,8 +1,8 @@
<template>
    <c-custom-shipment-number-comp
        style="border-color: red"
    record-id={typeAttributes.recordId}
    shipment-number={typeAttributes.shipmentNumber}
    >
    </c-custom-shipment-number-comp>
</template>
force-app/main/default/lwc/lexCustomLightningDatatable/lexCustomLightningDatatable.js
@@ -5,6 +5,9 @@
import customShipmentAmountTemplate from './customShipmentAmount.html';
import customDiffReasonTemplate from './lexCustomDiffReason.html';
import attachmentTypeTemplate from './customAttachmentType.html';
import customTableInputTemplate from './customTableInput.html';
import customOutputGoodsTemplate from './customOutputGoods.html';
import customReturnGoodInputTemplate from './customReturnGoodInput.html';
import { loadStyle} from 'lightning/platformResourceLoader';
import LexCustomDataTable from '@salesforce/resourceUrl/LexCustomDataTable';
@@ -12,37 +15,48 @@
    static customTypes = {
        customUnit: {
            template: customUnitTemplate,
            typeAttributes: ['unitValue','unitOptions','recordId'],
            typeAttributes: ['unitValue', 'unitOptions', 'recordId']
        },
        customShipment: {
            template: customShipmentNumberTemplate,
            typeAttributes: ['shipmentNumber','recordId'],
            typeAttributes: ['shipmentNumber', 'recordId']
        },
        customShipmentUnitPrice: {
            template: customShippingUnitPriceTemplate,
            typeAttributes: ['shippingUnitPrice','recordId'],
            typeAttributes: ['shippingUnitPrice', 'recordId']
        },
        customShipmentAmount: {
            template: customShipmentAmountTemplate,
            typeAttributes: ['shipmentAmount','recordId'],
            typeAttributes: ['shipmentAmount', 'recordId']
        },
        customDiffReason : {
            template: customDiffReasonTemplate,
            typeAttributes: ['ProdId'],
            typeAttributes: ['ProdId']
        },
        customAttachmentType: {
            template: attachmentTypeTemplate,
            typeAttributes: ['typeValue','typeOptions','recordId','isDisabledAttachment'],
            typeAttributes: [
                'typeValue',
                'typeOptions',
                'recordId',
                'isDisabledAttachment'
            ]
        },
        customTableInput: {
            template: customTableInputTemplate,
            typeAttributes:['inputValue','recordId'],
            typeAttributes: ['inputValue', 'recordId']
        },
        customOutputGood: {
            template: customOutputGoodsTemplate,
            typeAttributes: ['outputValue', 'type', 'recordId']
        },
        customReturnGoodInput: {
            template: customReturnGoodInputTemplate,
            typeAttributes: ['inputValue', 'boxPrice', 'recordId']
        }
    };
    constructor() {
        super();
        Promise.all([
            loadStyle(this, LexCustomDataTable),
        ]).then(() => {})
        Promise.all([loadStyle(this, LexCustomDataTable)]).then(() => {});
    }
}
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.html
@@ -2,51 +2,96 @@
<!-- sldsValidatorIgnore -->
<template>
    <template if:true={isShowSpinner}>
        <lightning-spinner alternative-text="Loading" size="large"></lightning-spinner>
        <lightning-spinner
            alternative-text="Loading"
            size="large"
        ></lightning-spinner>
    </template>
    <!-- 搜索客户名 -->
    <template if:true={isModalOpen}>
        <!-- Modal/Popup Box LWC starts here -->
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true"
            aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
        <section
            role="dialog"
            tabindex="-1"
            aria-labelledby="modal-heading-01"
            aria-modal="true"
            aria-describedby="modal-content-id-1"
            class="slds-modal slds-fade-in-open"
        >
            <div class="slds-modal__container">
                <!-- Modal/Popup Box LWC header here -->
                <header class="slds-modal__header">
                    <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
                        title="Close" onclick={closeModal}>
                        <lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse"
                            size="small"></lightning-icon>
                    <button
                        class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
                        title="Close"
                        onclick={closeModal}
                    >
                        <lightning-icon
                            icon-name="utility:close"
                            alternative-text="close"
                            variant="inverse"
                            size="small"
                        ></lightning-icon>
                        <span class="slds-assistive-text">Close</span>
                    </button>
                    <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">
                    <h2
                        id="modal-heading-01"
                        class="slds-text-heading_medium slds-hyphenate"
                    >
                        经销商医院检索
                    </h2>
                </header>
                <!-- Modal/Popup Box LWC body starts here -->
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                <div
                    class="slds-modal__content slds-p-around_medium"
                    id="modal-content-id-1"
                >
                    <lightning-layout>
                        <lightning-layout-item flexibility="auto" padding="around-small">
                            <lightning-input type="text" label="医院名称" onchange={dataChange}
                                data-field="searchHospitalName" value={searchHospitalName}
                                variant="label-inline"></lightning-input>
                        <lightning-layout-item
                            flexibility="auto"
                            padding="around-small"
                        >
                            <lightning-input
                                type="text"
                                label="医院名称"
                                onchange={dataChange}
                                data-field="searchHospitalName"
                                value={searchHospitalName}
                                variant="label-inline"
                            ></lightning-input>
                        </lightning-layout-item>
                        <lightning-layout-item flexibility="auto" padding="around-small">
                            <lightning-button label="检索" onclick={searchHospital}></lightning-button>
                        <lightning-layout-item
                            flexibility="auto"
                            padding="around-small"
                        >
                            <lightning-button
                                label="检索"
                                onclick={searchHospital}
                            ></lightning-button>
                        </lightning-layout-item>
                    </lightning-layout>
                    <div class="tableColumn">
                        <lightning-layout class="datatable">
                            <lightning-datatable class="datatabel slds-border_top" key-field="id" data={hospitalList}
                                columns={hospitalColumns} hide-checkbox-column="true"
                                onrowaction={searchHandleRowAction}>
                            <lightning-datatable
                                class="datatabel slds-border_top"
                                key-field="id"
                                data={hospitalList}
                                columns={hospitalColumns}
                                hide-checkbox-column="true"
                                onrowaction={searchHandleRowAction}
                            >
                            </lightning-datatable>
                        </lightning-layout>
                    </div>
                </div>
                <!-- Modal/Popup Box LWC footer starts here -->
                <footer class="slds-modal__footer">
                    <button class="slds-button slds-button_neutral" onclick={closeModal} title="Cancel">
                    <button
                        class="slds-button slds-button_neutral"
                        onclick={closeModal}
                        title="Cancel"
                    >
                        关闭
                    </button>
                </footer>
@@ -57,27 +102,64 @@
    <!-- 上传附件弹窗 -->
    <template if:true={showAttPop}>
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open slds-modal_small" style="border: 1px solid #D4D4D4;">
        <section
            role="dialog"
            tabindex="-1"
            aria-labelledby="modal-heading-01"
            aria-modal="true"
            aria-describedby="modal-content-id-1"
            class="slds-modal slds-fade-in-open slds-modal_small"
            style="border: 1px solid #d4d4d4"
        >
            <template if:true={showPopSpinner}>
                <lightning-spinner size="medium" variant="brand"></lightning-spinner>
                <lightning-spinner
                    size="medium"
                    variant="brand"
                ></lightning-spinner>
            </template>
            <div class="slds-modal__container">
                <header class="slds-modal__header" style="background-color: #F3F3F3;">
                    <button style="" class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closePop}>
                        <lightning-icon icon-name="utility:close"
                <header
                    class="slds-modal__header"
                    style="background-color: #f3f3f3"
                >
                    <button
                        style=""
                        class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
                        title="Close"
                        onclick={closePop}
                    >
                        <lightning-icon
                            icon-name="utility:close"
                            alternative-text="close"
                            variant="inverse"
                            size="small" ></lightning-icon>
                            size="small"
                        ></lightning-icon>
                        <span class="slds-assistive-text">Close</span>
                    </button>
                    <h2 id="modal-heading-02" class="slds-text-heading_medium slds-hyphenate">上传附件</h2>
                    <h2
                        id="modal-heading-02"
                        class="slds-text-heading_medium slds-hyphenate"
                    >
                        上传附件
                    </h2>
                </header>
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-2" style="border: 1px solid #F3F3F3;">
                <div
                    class="slds-modal__content slds-p-around_medium"
                    id="modal-content-id-2"
                    style="border: 1px solid #f3f3f3"
                >
                    <div class="slds-m-top_medium slds-m-bottom_x-large">
                        <div class="slds-p-around_medium lgc-bg">
                            <lightning-input type="file" label="附件上传" accept=".xlsx, .xls, .csv, .png, .doc, .docx, .pdf" onchange={attChange}></lightning-input>
                            <lightning-input
                                type="file"
                                label="附件上传"
                                accept=".xlsx, .xls, .csv, .png, .doc, .docx, .pdf"
                                onchange={attChange}
                            ></lightning-input>
                        </div>
                        <p>已选择文件:{fileName} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <p>
                            已选择文件:{fileName}
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <template if:true={attDelBtn}>
                                <a onclick={removeAtt}>移除</a>
                            </template>
@@ -85,8 +167,18 @@
                    </div>
                </div>
                <footer class="slds-modal__footer">
                    <lightning-button style="margin-left: 10px;" variant="neutral" label="取消" onclick={closePop}></lightning-button>
                    <lightning-button style="margin-left: 10px;" variant="neutral" label="上传" onclick={handleSave}></lightning-button>
                    <lightning-button
                        style="margin-left: 10px"
                        variant="neutral"
                        label="取消"
                        onclick={closePop}
                    ></lightning-button>
                    <lightning-button
                        style="margin-left: 10px"
                        variant="neutral"
                        label="上传"
                        onclick={handleSave}
                    ></lightning-button>
                </footer>
            </div>
        </section>
@@ -121,8 +213,11 @@
                                <tr>
                                    <td>
                                        <template if:true={isSaveShow}>
                                            <lightning-button label="保存" onclick={saveConfirmJs}
                                                style="width: 150px"></lightning-button>
                                            <lightning-button
                                                label="保存"
                                                onclick={saveConfirmJs}
                                                style="width: 150px"
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td colspan="4">
@@ -135,25 +230,35 @@
                                <tr>
                                    <td></td>
                                    <td>
                                        <template if:true={isEditShow}>
                                            <lightning-button label="编辑出库单" onclick={EditConsumable}
                                                style="width: 150px" disabled={isEditDisabled}></lightning-button>
                                            <lightning-button
                                                label="编辑出库单"
                                                onclick={EditConsumable}
                                                style="width: 150px"
                                                disabled={isEditDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isDeliveryShow}>
                                            <lightning-button label="出货/销售" onclick={GoodsDeliveryJs}
                                                style="width: 150px;" disabled={isDeliveryDisabled}></lightning-button>
                                            <lightning-button
                                                label="出货/销售"
                                                onclick={GoodsDeliveryJs}
                                                style="width: 150px"
                                                disabled={isDeliveryDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isOpenToInvoiceShow}>
                                            <lightning-button label="开票" onclick={openToInvoiceJs} style="width: 150px"
                                                disabled={isOpenToInvoiceDisabled}></lightning-button>
                                            <lightning-button
                                                label="开票"
                                                onclick={openToInvoiceJs}
                                                style="width: 150px"
                                                disabled={isOpenToInvoiceDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                </tr>
@@ -161,26 +266,34 @@
                                    <td></td>
                                    <td>
                                        <template if:true={isPraseToPDFShow}>
                                            <lightning-button label="打印指示单" onclick={PraseToPDFJs} style="width: 150px"
                                                disabled={isPraseToPDFDisabled}></lightning-button>
                                            <lightning-button
                                                label="打印指示单"
                                                onclick={PraseToPDFJs}
                                                style="width: 150px"
                                                disabled={isPraseToPDFDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isOpenReportShow}>
                                            <lightning-button label="显示明细" onclick={openReportJs} style="width: 150px"
                                                disabled={isOpenReportDisabled}></lightning-button>
                                            <lightning-button
                                                label="显示明细"
                                                onclick={openReportJs}
                                                style="width: 150px"
                                                disabled={isOpenReportDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isDeleteShow}>
                                            <lightning-button label="删除" onclick={DeleteConsumable} style="width: 150px"
                                                disabled={isDeleteDisabled}></lightning-button>
                                            <lightning-button
                                                label="删除"
                                                onclick={DeleteConsumable}
                                                style="width: 150px"
                                                disabled={isDeleteDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td></td>
@@ -202,182 +315,323 @@
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <!-- SummonsStatus_c__c == '价格未定' -->
                                <template if:true={summonsStatusPriceNotDetermined}>
                                    <lightning-record-edit-form object-api-name="Consumable_order__c" record-id={cocId}
                                        onload={handleLoad}>
                                <template
                                    if:true={summonsStatusPriceNotDetermined}
                                >
                                    <lightning-record-edit-form
                                        object-api-name="Consumable_order__c"
                                        record-id={cocId}
                                        onload={handleLoad}
                                    >
                                        <!-- 出库单号 出库单状态 -->
                                        <lightning-layout multiple-rows="true">
                                            <template if:true={isSummonsFlag}>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item size="4">
                                                    <lightning-output-field field-name="Name"
                                                        class="hehe-layoutItem"></lightning-output-field>
                                                    <lightning-output-field
                                                        field-name="Name"
                                                        class="hehe-layoutItem"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="SummonsStatus_c__c"></lightning-output-field>
                                                        field-name="SummonsStatus_c__c"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                            </template>
                                        </lightning-layout>
                                        <!-- 目的   开票状态 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="SummonsForDirction__c"></lightning-output-field>
                                                    field-name="SummonsForDirction__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="Billed_Status__c"></lightning-output-field>
                                                    field-name="Billed_Status__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 二级经销商 -->
                                        <template if:true={isSummonsForDirctionTwoShow}>
                                            <lightning-layout multiple-rows="true">
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                        <template
                                            if:true={isSummonsForDirctionTwoShow}
                                        >
                                            <lightning-layout
                                                multiple-rows="true"
                                            >
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="Order_Dealer_Info__c"></lightning-output-field>
                                                        field-name="Order_Dealer_Info__c"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                            </lightning-layout>
                                        </template>
                                        <!-- 客户名 发票-->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-output-field class="hideHelpText"
                                                    field-name="ShipmentAccount__c"></lightning-output-field>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    class="hideHelpText"
                                                    field-name="ShipmentAccount__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field data-field={ConInvoice_Code__c}
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    data-field={ConInvoice_Code__c}
                                                    onchange={invoiceChange}
                                                    field-name="ConInvoice_Code__c"></lightning-input-field>
                                                    field-name="ConInvoice_Code__c"
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 科室 出库金额 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="Order_ForCustomerText__c"></lightning-output-field>
                                                    field-name="Order_ForCustomerText__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="Shipment_total_amount__c"></lightning-output-field>
                                                    field-name="Shipment_total_amount__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 没有确定价格 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="NoConfirmedPrice__c"></lightning-output-field>
                                                    field-name="NoConfirmedPrice__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                    </lightning-record-edit-form>
                                </template>
                                <!-- SummonsStatus_c__c != '价格未定' -->
                                <template if:false={summonsStatusPriceNotDetermined}>
                                    <lightning-record-edit-form object-api-name="Consumable_order__c" record-id={cocId}
                                        onsubmit={handleSubmit} onload={handleLoad}>
                                <template
                                    if:false={summonsStatusPriceNotDetermined}
                                >
                                    <lightning-record-edit-form
                                        object-api-name="Consumable_order__c"
                                        record-id={cocId}
                                        onsubmit={handleSubmit}
                                        onload={handleLoad}
                                    >
                                        <!-- 出库单号 出库单状态 -->
                                        <lightning-layout multiple-rows="true">
                                            <template if:true={isSummonsFlag}>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                    <lightning-output-field field-name="Name"></lightning-output-field>
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="Name"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="SummonsStatus_c__c"></lightning-output-field>
                                                        field-name="SummonsStatus_c__c"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                            </template>
                                        </lightning-layout>
                                        <!-- 目的   二级经销商 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field data-field="summonsForDirction"
                                                    value={summonsForDirction} field-name="SummonsForDirction__c"
                                                    required="true" onchange={ChangeDirction}></lightning-input-field>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    data-field="summonsForDirction"
                                                    value={summonsForDirction}
                                                    field-name="SummonsForDirction__c"
                                                    required="true"
                                                    onchange={ChangeDirction}
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-combobox data-field="secondaryDistributor"
                                                    name="secondaryDistributor" label="二级经销商"
                                                    value={secondaryDistributor} placeholder="请选择..."
                                                    options={secondaryDistributorOptions} variant="label-inline"
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-combobox
                                                    data-field="secondaryDistributor"
                                                    name="secondaryDistributor"
                                                    label="二级经销商"
                                                    value={secondaryDistributor}
                                                    placeholder="请选择..."
                                                    options={secondaryDistributorOptions}
                                                    variant="label-inline"
                                                    onchange={dataChange}
                                                    disabled={isDisabledSecondaryDistributor}></lightning-combobox>
                                                    disabled={isDisabledSecondaryDistributor}
                                                ></lightning-combobox>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 客户名   经销商录入 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <div
                                                    class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right">
                                                    <lightning-icon size="x-small"
                                                    class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right"
                                                >
                                                    <lightning-icon
                                                        size="x-small"
                                                        class="iconMargin slds-icon slds-input__icon slds-input__icon_right slds-icon-text-default"
                                                        icon-name="utility:search"></lightning-icon>
                                                    <lightning-input type="text" name="HospitalName" label="客户名"
                                                        value={HospitalName} variant="label-inline"
                                                        onclick={searchHospitalNameModal} data-field="HospitalName"
                                                        icon-name="utility:search"
                                                    ></lightning-icon>
                                                    <lightning-input
                                                        type="text"
                                                        name="HospitalName"
                                                        label="客户名"
                                                        value={HospitalName}
                                                        variant="label-inline"
                                                        onclick={searchHospitalNameModal}
                                                        data-field="HospitalName"
                                                        disabled={isDisabledHospitalName}
                                                        onchange={clearAgencyI}></lightning-input>
                                                        onchange={clearAgencyI}
                                                    ></lightning-input>
                                                </div>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <template if:true={isMutualTransferGoods}>
                                                    <c-lex-lookup onsearch={handleSearch}
                                                        onselectionchange={handleSelectionChange} label="经销商(录入)"
                                                        variant="label-inline" placeholder="搜索经销商"
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <template
                                                    if:true={isMutualTransferGoods}
                                                >
                                                    <c-lex-lookup
                                                        onsearch={handleSearch}
                                                        onselectionchange={handleSelectionChange}
                                                        label="经销商(录入)"
                                                        variant="label-inline"
                                                        placeholder="搜索经销商"
                                                        onisdisabledfordealertext={isDisabledForDealerText}
                                                        onblur={vpClear2Delay} disabled={isDisabledForDealerText}>
                                                        onblur={vpClear2Delay}
                                                        disabled={isDisabledForDealerText}
                                                    >
                                                    </c-lex-lookup>
                                                </template>
                                                <template if:false={isMutualTransferGoods}>
                                                    <lightning-input type="text" name="Order_ForDealerText__c"
                                                        label="经销商(录入)" value={ForDealerText} onchange={dataChange}
                                                <template
                                                    if:false={isMutualTransferGoods}
                                                >
                                                    <lightning-input
                                                        type="text"
                                                        name="Order_ForDealerText__c"
                                                        label="经销商(录入)"
                                                        value={ForDealerText}
                                                        onchange={dataChange}
                                                        data-field="Order_ForDealerText__c"
                                                        disabled={isDisabledForDealerText} variant="label-inline">
                                                        disabled={isDisabledForDealerText}
                                                        variant="label-inline"
                                                    >
                                                    </lightning-input>
                                                </template>
                                            </lightning-layout-item>
@@ -385,32 +639,60 @@
                                        <!-- 科室   总金额 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field onchange={dataChange}
                                                    data-field="ForCustomerText" value={ForCustomerText}
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    onchange={dataChange}
                                                    data-field="ForCustomerText"
                                                    value={ForCustomerText}
                                                    field-name="Order_ForCustomerText__c"
                                                    disabled={isDisabledForCustomerText}></lightning-input-field>
                                                    disabled={isDisabledForCustomerText}
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input type="text" name="sumPrice" label="总金额"
                                                    value={sumPrice} variant="label-inline" onchange={dataChange}
                                                    data-field="sumPrice" readonly></lightning-input>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input
                                                    type="text"
                                                    name="sumPrice"
                                                    label="总金额"
                                                    value={sumPrice}
                                                    variant="label-inline"
                                                    onchange={dataChange}
                                                    data-field="sumPrice"
                                                    readonly
                                                ></lightning-input>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 没有确定价格 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field value={NoConfirmedPrice}
                                                    field-name="NoConfirmedPrice__c" data-field="NoConfirmedPrice"
                                                    onchange={dataChange}></lightning-input-field>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    value={NoConfirmedPrice}
                                                    field-name="NoConfirmedPrice__c"
                                                    data-field="NoConfirmedPrice"
                                                    onchange={dataChange}
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                    </lightning-record-edit-form>
@@ -431,100 +713,146 @@
                        <div style="padding: 10px">
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <lightning-record-edit-form object-api-name="Consumable_order__c" record-id={cocId}
                                    onload={handleLoad2}>
                                <lightning-record-edit-form
                                    object-api-name="Consumable_order__c"
                                    record-id={cocId}
                                    onload={handleLoad2}
                                >
                                    <!-- 出库单号 出库单状态 -->
                                    <lightning-layout multiple-rows="true">
                                        <template if:true={isSummonsFlag}>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item size="4">
                                                <lightning-output-field field-name="Name"
                                                    class="hehe-layoutItem"></lightning-output-field>
                                                <lightning-output-field
                                                    field-name="Name"
                                                    class="hehe-layoutItem"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item size="4">
                                                <lightning-output-field field-name="SummonsStatus_c__c"
                                                    class="hehe-layoutItem"></lightning-output-field>
                                                <lightning-output-field
                                                    field-name="SummonsStatus_c__c"
                                                    class="hehe-layoutItem"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </template>
                                    </lightning-layout>
                                    <!-- 目的   开票状态 -->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="SummonsForDirction__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="SummonsForDirction__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="Billed_Status__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="Billed_Status__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                    <!-- 二级经销商 -->
                                    <template if:true={isSummonsForDirctionTwoShow}>
                                    <template
                                        if:true={isSummonsForDirctionTwoShow}
                                    >
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item size="4">
                                                <lightning-output-field field-name="Order_Dealer_Info__c"
                                                    class="hehe-layoutItem"></lightning-output-field>
                                                <lightning-output-field
                                                    field-name="Order_Dealer_Info__c"
                                                    class="hehe-layoutItem"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                    </template>
                                    <!-- 客户名 发票-->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field class="hideHelpText"
                                                field-name="ShipmentAccount__c"></lightning-output-field>
                                            <lightning-output-field
                                                class="hideHelpText"
                                                field-name="ShipmentAccount__c"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <template if:true={isConInvoiceShow}>
                                            <lightning-layout-item size="4">
                                                <lightning-input-field data-field={ConInvoice_Code__c}
                                                    onchange={invoiceChange} field-name="ConInvoice_Code__c"
                                                    class="hehe-layoutItem"></lightning-input-field>
                                                <lightning-input-field
                                                    data-field={ConInvoice_Code__c}
                                                    onchange={invoiceChange}
                                                    field-name="ConInvoice_Code__c"
                                                    class="hehe-layoutItem"
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                        </template>
                                    </lightning-layout>
                                    <!-- 科室 出库金额 -->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="Order_ForCustomerText__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="Order_ForCustomerText__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="Shipment_total_amount__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="Shipment_total_amount__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                    <!-- 没有确定价格 -->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="NoConfirmedPrice__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="NoConfirmedPrice__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                </lightning-record-edit-form>
@@ -540,61 +868,153 @@
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <lightning-layout multiple-rows>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label">消耗品名称</div>
                                            <lightning-input type="text" name="consumableName" label="消耗品名称"
                                                value={consumableName} variant="label-hidden" onchange={dataChange}
                                                data-field="consumableName"></lightning-input>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                            >
                                                消耗品名称
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label" style="width:70px">第3分类</div>
                                            <lightning-combobox name="progress" label="第3分类" value={Category3}
                                                variant="label-hidden" options={category3Options} onchange={dataChange}
                                                data-field="Category3" style="min-width: 185px;"></lightning-combobox>
                                            <lightning-input
                                                type="text"
                                                name="consumableName"
                                                label="消耗品名称"
                                                value={consumableName}
                                                variant="label-hidden"
                                                onchange={dataChange}
                                                data-field="consumableName"
                                            ></lightning-input>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label" style="width:70px">第4分类</div>
                                            <lightning-combobox name="progress" label="第4分类" value={Category4}
                                                variant="label-hidden" options={category4Options} onchange={dataChange}
                                                data-field="Category4" style="min-width: 185px;"></lightning-combobox>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                                style="width: 70px"
                                            >
                                                第3分类
                                        </div>
                                            <lightning-combobox
                                                name="progress"
                                                label="第3分类"
                                                value={Category3}
                                                variant="label-hidden"
                                                options={category3Options}
                                                onchange={dataChange}
                                                data-field="Category3"
                                                style="min-width: 160px"
                                            ></lightning-combobox>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label" style="width:70px">第5分类</div>
                                            <lightning-combobox name="progress" label="第5分类" value={Category5}
                                                variant="label-hidden" onchange={dataChange} data-field="Category5"
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                                style="width: 70px"
                                            >
                                                第4分类
                                            </div>
                                            <lightning-combobox
                                                name="progress"
                                                label="第4分类"
                                                value={Category4}
                                                variant="label-hidden"
                                                options={category4Options}
                                                onchange={dataChange}
                                                data-field="Category4"
                                                style="min-width: 160px"
                                            ></lightning-combobox>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                                style="width: 70px"
                                            >
                                                第5分类
                                            </div>
                                            <lightning-combobox
                                                name="progress"
                                                label="第5分类"
                                                value={Category5}
                                                variant="label-hidden"
                                                onchange={dataChange}
                                                data-field="Category5"
                                                options={category5Options}
                                                style="min-width: 185px;"></lightning-combobox>
                                                style="min-width: 160px"
                                            ></lightning-combobox>
                                        </div>
                                    </lightning-layout-item>
                                    <template if:true={hasHosPro}>
                                        <lightning-layout-item padding="around-small">
                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                <div class="slds-form-element__label">医院特价</div>
                                                <lightning-combobox name="progress" label="医院特价" value={outOutPattern}
                                                    variant="label-hidden" options={outOutPatternOptionList}
                                                    onchange={handleChange}></lightning-combobox>
                                        <lightning-layout-item
                                            padding="around-small"
                                            flexibility="auto"
                                        >
                                            <div
                                                class="slds-grid slds-grid_vertical-align-center"
                                            >
                                                <div
                                                    class="slds-form-element__label"
                                                >
                                                    医院特价
                                                </div>
                                                <lightning-combobox
                                                    name="progress"
                                                    label="医院特价"
                                                    value={outOutPattern}
                                                    variant="label-hidden"
                                                    options={outOutPatternOptionList}
                                                    onchange={handleChange}
                                                ></lightning-combobox>
                                            </div>
                                        </lightning-layout-item>
                                    </template>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <lightning-button label="检索" onclick={searchProductJs}></lightning-button>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <lightning-button
                                                label="检索"
                                                onclick={searchProductJs}
                                            ></lightning-button>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <lightning-button label="清空" onclick={ClearJs}></lightning-button>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <lightning-button
                                                label="清空"
                                                onclick={ClearJs}
                                            ></lightning-button>
                                        </div>
                                    </lightning-layout-item>
                                </lightning-layout>
@@ -613,23 +1033,83 @@
                    <div style="padding: 10px">
                        <template if:true={EditAble}>
                            <template if:true={showTable}>
                                <c-lex-custom-lightning-datatable key-field="Id" data={data} columns={columns}
                                    onunitchange={handleUnitChange} onshipmentnumber={handleShipmentNumber}
                                    onshipmentunitprice={handleShipmentUnitPrice} onrowselection={getSelectedRows}
                                    selected-rows={selectedRows} style="word-wrap:break-word; word-break:break-all; ">
                                <c-lex-custom-lightning-datatable
                                    key-field="Id"
                                    data={data}
                                    columns={columns}
                                    onunitchange={handleUnitChange}
                                    onshipmentnumber={handleShipmentNumber}
                                    onshipmentunitprice={handleShipmentUnitPrice}
                                    onrowselection={getSelectedRows}
                                    selected-rows={selectedRows}
                                    default-sort-direction={defaultSortDirection}
                                    sorted-direction={sortDirection}
                                    sorted-by={sortedBy}
                                    onsort={onHandleSort}
                                    style="
                                        word-wrap: break-word;
                                        word-break: break-all;
                                    "
                                >
                                </c-lex-custom-lightning-datatable>
                            </template>
                            <c-paginator
                                onprevious={handlePrevious}
                                onnext={handleNext}
                                onpageschange={handlePageschange}
                                onfirst={handleFirst}
                                onlast={handleLast}
                                page-size-options={pageSizeOptions}
                                previous-button-disabled={previousButtonDisabled}
                                next-button-disabled={nextButtonDisabled}
                                record-start={recordStart}
                                record-end={recordEnd}
                                total-records={totalRecords}
                            ></c-paginator>
                        </template>
                        <template if:false={EditAble}>
                            <template if:true={showTable}>
                                <c-lex-custom-lightning-datatable hide-checkbox-column key-field="Id" data={data}
                                    columns={editColumns} onunitchange={handleUnitChange}
                                <c-lex-custom-lightning-datatable
                                    hide-checkbox-column
                                    key-field="Id"
                                    data={editData}
                                    columns={editColumns}
                                    onunitchange={handleUnitChange}
                                    onshipmentnumber={handleShipmentNumber}
                                    onshipmentunitprice={handleShipmentUnitPrice} onrowselection={getSelectedRows}
                                    selected-rows={selectedRows} style="word-wrap:break-word; word-break:break-all; ">
                                    onshipmentunitprice={handleShipmentUnitPrice}
                                    onrowselection={getSelectedRows}
                                    selected-rows={selectedRows}
                                    default-sort-direction={defaultSortDirection}
                                    sorted-direction={sortDirection}
                                    sorted-by={sortedBy}
                                    onsort={onHandleSort}
                                    style="
                                        word-wrap: break-word;
                                        word-break: break-all;
                                    "
                                >
                                </c-lex-custom-lightning-datatable>
                                <c-paginator
                                    onprevious={editHandlePrevious}
                                    onnext={editHandleNext}
                                    onpageschange={editHandlePageschange}
                                    onfirst={editHandleFirst}
                                    onlast={editHandleLast}
                                    page-size-options={pageSizeOptions}
                                    previous-button-disabled={previousButtonDisabled}
                                    next-button-disabled={nextButtonDisabled}
                                    record-start={recordStart}
                                    record-end={recordEnd}
                                    total-records={totalRecords}
                                ></c-paginator>
                            </template>
                        </template>
                        <template if:true={isEditShowSpinner}>
                            <lightning-spinner
                                alternative-text="Uploading now"
                            ></lightning-spinner>
                        </template>
                    </div>
                </div>
@@ -643,8 +1123,12 @@
                            </p>
                        </div>
                        <div style="padding: 10px">
                            <lightning-datatable key-field="id" data={consumableorderdetails2Records}
                                columns={consumableorderdetails2RecordsColumns} hide-checkbox-column>
                            <lightning-datatable
                                key-field="id"
                                data={consumableorderdetails2Records}
                                columns={consumableorderdetails2RecordsColumns}
                                hide-checkbox-column
                            >
                            </lightning-datatable>
                        </div>
                    </div>
@@ -662,7 +1146,10 @@
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <lightning-card title="">
                                    <lightning-layout multiple-rows="true" style="margin-top: -20px">
                                    <lightning-layout
                                        multiple-rows="true"
                                        style="margin-top: -20px"
                                    >
                                        <!-- <lightning-layout-item size="12">
                                            <lightning-input label="" name="file uploader" onchange={handleFilesChange}
                                                type="file" accept={acceptedType}></lightning-input><br />
@@ -676,16 +1163,27 @@
                                        </lightning-layout-item> -->
                                        <lightning-layout-item size="5">
                                        </lightning-layout-item>
                                        <lightning-layout-item padding="around-small">
                                            <lightning-button label='上传附件' onclick={uploadOrder}></lightning-button>
                                        <lightning-layout-item
                                            padding="around-small"
                                        >
                                            <lightning-button
                                                label="上传附件"
                                                onclick={uploadOrder}
                                            ></lightning-button>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                    <template if:true={showLoadingSpinner}>
                                        <lightning-spinner alternative-text="Uploading now"></lightning-spinner>
                                        <lightning-spinner
                                            alternative-text="Uploading now"
                                        ></lightning-spinner>
                                    </template>
                                    <footer style="margin-top: 20px">
                                        <lightning-datatable key-field="id" data={fileData} columns={fileColumns}
                                            hide-checkbox-column>
                                        <lightning-datatable
                                            key-field="id"
                                            data={fileData}
                                            columns={fileColumns}
                                            hide-checkbox-column
                                        >
                                        </lightning-datatable>
                                    </footer>
                                </lightning-card>
@@ -707,65 +1205,151 @@
                        <div lwc:dom="manual" class="resultDiv"></div>
                        <div draggable="false">
                            <lightning-layout multiple-rows="true">
                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                <lightning-layout-item
                                    class="hehe-layoutItem"
                                    size="4"
                                >
                                </lightning-layout-item>
                                <template if:true={isSales}>
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                        <lightning-button label="销售" onclick={SaveP}
                                            style="margin-top:-10px"></lightning-button>
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                        <lightning-button
                                            label="销售"
                                            onclick={SaveP}
                                            style="margin-top: -10px"
                                        ></lightning-button>
                                    </lightning-layout-item>
                                </template>
                                <template if:false={isSales}>
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                        <lightning-button label="出货" onclick={SaveE}></lightning-button>
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                        <lightning-button
                                            label="出货"
                                            onclick={SaveE}
                                        ></lightning-button>
                                    </lightning-layout-item>
                                </template>
                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                <lightning-layout-item
                                    class="hehe-layoutItem"
                                    size="4"
                                >
                                </lightning-layout-item>
                            </lightning-layout>
                            <template if:true={isShowInformation}>
                                <div class="borderCss" style="margin-top: 5px;">
                                <div class="borderCss" style="margin-top: 5px">
                                    <div class="headerDorderCss">
                                        <p style="font-size: 16px">
                                            <strong>出库单信息</strong>
                                        </p>
                                    </div>
                                    <div style="padding: 10px">
                                        <div lwc:dom="manual" class="resultDiv"></div>
                                        <div
                                            lwc:dom="manual"
                                            class="resultDiv"
                                        ></div>
                                        <div draggable="false">
                                            <lightning-record-edit-form object-api-name="Consumable_order__c"
                                                record-id={cocId} onload={handleLoad2}>
                                                <lightning-layout multiple-rows="true">
                                                    <lightning-layout-item size="3" padding="around-small">
                                            <lightning-record-edit-form
                                                object-api-name="Consumable_order__c"
                                                record-id={cocId}
                                                onload={handleLoad2}
                                            >
                                                <lightning-layout
                                                    multiple-rows="true"
                                                >
                                                    <lightning-layout-item
                                                        size="3"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field field-name="Name"></lightning-output-field> -->
                                                        <div class="slds-grid slds-grid_vertical-align-center">
                                                            <div class="slds-form-element__label" style="padding: 0px;">出库单号:</div>
                                                            <lightning-output-field field-name="Name" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                出库单号:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="Name"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                        </div>
                                                    </lightning-layout-item>
                                                    <lightning-layout-item size="4" padding="around-small">
                                                    <lightning-layout-item
                                                        size="4"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field
                                                            field-name="ShipmentAccount__c" class="hideHelpText"></lightning-output-field> -->
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label" style="padding: 0px;">客户名:</div>
                                                                <lightning-output-field field-name="ShipmentAccount__c" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                客户名:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="ShipmentAccount__c"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                            </div>
                                                    </lightning-layout-item>
                                                    <lightning-layout-item size="2" padding="around-small">
                                                    <lightning-layout-item
                                                        size="2"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field
                                                            field-name="Order_ForCustomerText__c"></lightning-output-field> -->
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label" style="padding: 0px;">科室:</div>
                                                                <lightning-output-field field-name="Order_ForCustomerText__c" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                科室:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="Order_ForCustomerText__c"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                            </div>
                                                    </lightning-layout-item>
                                                    <lightning-layout-item size="2" padding="around-small">
                                                    <lightning-layout-item
                                                        size="2"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field
                                                            field-name="SummonsForDirction__c"></lightning-output-field> -->
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label" style="padding: 0px;">目的:</div>
                                                                <lightning-output-field field-name="SummonsForDirction__c" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                目的:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="SummonsForDirction__c"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                            </div>
                                                    </lightning-layout-item>
                                                </lightning-layout>
@@ -782,31 +1366,63 @@
                                            </p>
                                        </div>
                                        <div style="padding: 10px">
                                            <div lwc:dom="manual" class="resultDiv"></div>
                                            <div
                                                lwc:dom="manual"
                                                class="resultDiv"
                                            ></div>
                                            <div draggable="false">
                                                <lightning-record-edit-form object-api-name="Consumable_order__c"
                                                    record-id={cocId}>
                                                    <lightning-layout multiple-rows="true">
                                                        <lightning-layout-item size="1"></lightning-layout-item>
                                                        <lightning-layout-item padding="around-small">
                                                <lightning-record-edit-form
                                                    object-api-name="Consumable_order__c"
                                                    record-id={cocId}
                                                >
                                                    <lightning-layout
                                                        multiple-rows="true"
                                                    >
                                                        <lightning-layout-item
                                                            size="1"
                                                        ></lightning-layout-item>
                                                        <lightning-layout-item
                                                            padding="around-small"
                                                        >
                                                            <!-- <lightning-textarea name="Barcode" label="BarCode号"
                                                                onchange={dataChange} variant="label-inline"
                                                                data-field="Barcode"
                                                                value={Barcode}></lightning-textarea> -->
                                                            <div class="slds-grid">
                                                                <div class="slds-form-element__label">BarCode号</div>
                                                                <lightning-textarea name="Barcode" label="BarCode号"
                                                                    onchange={dataChange} variant="label-hidden"
                                                                    data-field="Barcode" value={Barcode}
                                                                    style="min-width: 400px;"></lightning-textarea>
                                                            <div
                                                                class="slds-grid"
                                                            >
                                                                <div
                                                                    class="slds-form-element__label"
                                                                >
                                                                    BarCode号
                                                                </div>
                                                                <lightning-textarea
                                                                    name="Barcode"
                                                                    label="BarCode号"
                                                                    onchange={dataChange}
                                                                    variant="label-hidden"
                                                                    data-field="Barcode"
                                                                    value={Barcode}
                                                                    style="
                                                                        min-width: 400px;
                                                                    "
                                                                ></lightning-textarea>
                                                            </div>
                                                        </lightning-layout-item>
                                                        <lightning-layout-item padding="around-small">
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label">
                                                                    <lightning-button label="确认"
                                                                        onclick={SalesearchProductJs}></lightning-button>
                                                        <lightning-layout-item
                                                            padding="around-small"
                                                        >
                                                            <div
                                                                class="slds-grid slds-grid_vertical-align-center"
                                                            >
                                                                <div
                                                                    class="slds-form-element__label"
                                                                >
                                                                    <lightning-button
                                                                        label="确认"
                                                                        onclick={SalesearchProductJs}
                                                                    ></lightning-button>
                                                                </div>
                                                            </div>
                                                        </lightning-layout-item>
@@ -824,11 +1440,21 @@
                                        </p>
                                    </div>
                                    <div style="padding: 10px">
                                        <div lwc:dom="manual" class="resultDiv"></div>
                                        <div
                                            lwc:dom="manual"
                                            class="resultDiv"
                                        ></div>
                                        <div draggable="false">
                                            <lightning-datatable key-field="id" data={salesData} columns={salesColumns}
                                            <lightning-datatable
                                                key-field="id"
                                                data={salesData}
                                                columns={salesColumns}
                                                hide-checkbox-column
                                                style="word-wrap:break-word; word-break:break-all; ">
                                                style="
                                                    word-wrap: break-word;
                                                    word-break: break-all;
                                                "
                                            >
                                            </lightning-datatable>
                                        </div>
                                    </div>
@@ -841,30 +1467,58 @@
                                        </p>
                                    </div>
                                    <div style="padding: 10px">
                                        <div lwc:dom="manual" class="resultDiv"></div>
                                        <div
                                            lwc:dom="manual"
                                            class="resultDiv"
                                        ></div>
                                        <div draggable="false">
                                            <lightning-datatable key-field="id" data={salesErrorData}
                                                columns={salesErrorColumns} hide-checkbox-column
                                                style="word-wrap:break-word; word-break:break-all; ">
                                            <lightning-datatable
                                                key-field="id"
                                                data={salesErrorData}
                                                columns={salesErrorColumns}
                                                hide-checkbox-column
                                                style="
                                                    word-wrap: break-word;
                                                    word-break: break-all;
                                                "
                                            >
                                            </lightning-datatable>
                                        </div>
                                    </div>
                                </div>
                                <lightning-layout multiple-rows="true">
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                    </lightning-layout-item>
                                    <template if:true={isSales}>
                                        <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-button label="销售" onclick={SaveP}></lightning-button>
                                        <lightning-layout-item
                                            class="hehe-layoutItem"
                                            size="4"
                                        >
                                            <lightning-button
                                                label="销售"
                                                onclick={SaveP}
                                            ></lightning-button>
                                        </lightning-layout-item>
                                    </template>
                                    <template if:false={isSales}>
                                        <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-button label="出货" onclick={SaveE}></lightning-button>
                                        <lightning-layout-item
                                            class="hehe-layoutItem"
                                            size="4"
                                        >
                                            <lightning-button
                                                label="出货"
                                                onclick={SaveE}
                                            ></lightning-button>
                                        </lightning-layout-item>
                                    </template>
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                    </lightning-layout-item>
                                </lightning-layout>
                            </template>
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.js
@@ -1,414 +1,418 @@
import { LightningElement, wire, api, track } from "lwc";
import init from "@salesforce/apex/LexSummonsCreatController.init";
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import searchConsumableorderdetails from "@salesforce/apex/LexSummonsCreatController.searchConsumableorderdetails";
import PraseToPDF from "@salesforce/apex/LexSummonsCreatController.PraseToPDF";
import apexSearch from "@salesforce/apex/LexSummonsCreatController.search";
import saveFile from "@salesforce/apex/LexSummonsCreatController.saveFile";
import getFiles from "@salesforce/apex/LexSummonsCreatController.getFiles";
import GoodsDelivery from "@salesforce/apex/LexSummonsCreatController.GoodsDelivery";
import DelConsumable from "@salesforce/apex/LexSummonsCreatController.DelConsumable";
import categoryAllload from "@salesforce/apex/LexSummonsCreatController.categoryAllload";
import categoryload from "@salesforce/apex/LexSummonsCreatController.categoryload";
import GoodsDeliveryInit from "@salesforce/apex/LexSaleOrderController.GoodsDeliveryInit";
import SearchPro from "@salesforce/apex/LexSaleOrderController.SearchPro";
import ProdElivery from "@salesforce/apex/LexSaleOrderController.ProdElivery";
import ProSale from "@salesforce/apex/LexSaleOrderController.ProSale";
import save from "@salesforce/apex/LexSummonsCreatController.save";
import OPPORTUNITY_OBJECT from "@salesforce/schema/Consumable_Orderdetails__c";
import { getObjectInfo } from "lightning/uiObjectInfoApi";
import hospitalInit from "@salesforce/apex/lexSearchAgencyHospitalController.init";
import serContact from "@salesforce/apex/lexSearchAgencyHospitalController.serContact";
import { NavigationMixin } from "lightning/navigation";
import { LightningElement, wire, api, track } from 'lwc';
import init from '@salesforce/apex/LexSummonsCreatController.init';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import searchConsumableorderdetails from '@salesforce/apex/LexSummonsCreatController.searchConsumableorderdetails';
import PraseToPDF from '@salesforce/apex/LexSummonsCreatController.PraseToPDF';
import apexSearch from '@salesforce/apex/LexSummonsCreatController.search';
import saveFile from '@salesforce/apex/LexSummonsCreatController.saveFile';
import getFiles from '@salesforce/apex/LexSummonsCreatController.getFiles';
import GoodsDelivery from '@salesforce/apex/LexSummonsCreatController.GoodsDelivery';
import DelConsumable from '@salesforce/apex/LexSummonsCreatController.DelConsumable';
import categoryAllload from '@salesforce/apex/LexSummonsCreatController.categoryAllload';
import categoryload from '@salesforce/apex/LexSummonsCreatController.categoryload';
import GoodsDeliveryInit from '@salesforce/apex/LexSaleOrderController.GoodsDeliveryInit';
import SearchPro from '@salesforce/apex/LexSaleOrderController.SearchPro';
import ProdElivery from '@salesforce/apex/LexSaleOrderController.ProdElivery';
import ProSale from '@salesforce/apex/LexSaleOrderController.ProSale';
import save from '@salesforce/apex/LexSummonsCreatController.save';
import OPPORTUNITY_OBJECT from '@salesforce/schema/Consumable_Orderdetails__c';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import hospitalInit from '@salesforce/apex/lexSearchAgencyHospitalController.init';
import serContact from '@salesforce/apex/lexSearchAgencyHospitalController.serContact';
import { NavigationMixin } from 'lightning/navigation';
export default class LexSummonsCreat extends NavigationMixin(LightningElement) {
    @track isShowSpinner = true;
    @track isEditShowSpinner = false;
    @track showResults = true;
    @track results = [
        {
            Id: "1",
            Name: "z",
            Id: '1',
            Name: 'z'
        },
        {
            Id: "2",
            Name: "h",
            Id: '2',
            Name: 'h'
        },
        {
            Id: "3",
            Name: "j",
        },
            Id: '3',
            Name: 'j'
        }
    ];
    @track COLS = [
        {
            label: "Account Name",
            type: "customName",
            label: 'Account Name',
            type: 'customName',
            typeAttributes: {
                accountName: { fieldName: "Name" },
            },
        },
                accountName: { fieldName: 'Name' }
            }
        }
    ];
    @track columns = [
        {
            label: "消耗品名称",
            fieldName: "Name__c",
            //hideDefaultActions: true,
            label: '消耗品名称',
            fieldName: 'Name__c',
            hideDefaultActions: true,
            wrapText: true,
            //initialWidth : 100,
            initialWidth: 150,
            sortable: true
        },
        {
            label: "规格",
            fieldName: "packinglist",
            label: '规格',
            fieldName: 'packinglist',
            //initialWidth : 50,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "CFDA状态",
            fieldName: "SFDA_Status__c",
            label: 'CFDA状态',
            fieldName: 'SFDA_Status__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证编码号",
            fieldName: "approbation_No",
            label: '注册证编码号',
            fieldName: 'approbation_No',
            //initialWidth : 150,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证效期",
            label: '注册证效期',
            //initialWidth : 100,
            wrapText: true,
            fieldName: "expiration_Date",
            hideDefaultActions: true,
            fieldName: 'expiration_Date',
            hideDefaultActions: true
        },
        {
            label: "第3分类",
            fieldName: "Category3__c",
            label: '第3分类',
            fieldName: 'Category3__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第4分类",
            fieldName: "Category4__c",
            label: '第4分类',
            fieldName: 'Category4__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第5分类",
            fieldName: "Category5__c",
            label: '第5分类',
            fieldName: 'Category5__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "单位",
            type: "customUnit",
            label: '单位',
            type: 'customUnit',
            //initialWidth : 100,
            hideDefaultActions: true,
            typeAttributes: {
                unitValue: { fieldName: "unitValue" },
                unitOptions: { fieldName: "unitOptions" },
                recordId: { fieldName: "recordId" },
            },
                unitValue: { fieldName: 'unitValue' },
                unitOptions: { fieldName: 'unitOptions' },
                recordId: { fieldName: 'recordId' }
            }
        },
        {
            label: "出货数量",
            type: "customShipment",
            label: '出货数量',
            type: 'customShipment',
            //initialWidth : 150,
            hideDefaultActions: true,
            typeAttributes: {
                recordId: { fieldName: "recordId" },
                shipmentNumber: { fieldName: "shipmentNumber" },
            },
                recordId: { fieldName: 'recordId' },
                shipmentNumber: { fieldName: 'shipmentNumber' }
            }
        },
        {
            label: "出货单价(元)",
            type: "customShipmentUnitPrice",
            label: '出货单价(元)',
            type: 'customShipmentUnitPrice',
            //initialWidth : 150,
            hideDefaultActions: true,
            typeAttributes: {
                recordId: { fieldName: "recordId" },
                shippingUnitPrice: { fieldName: "shippingUnitPrice" },
            },
                recordId: { fieldName: 'recordId' },
                shippingUnitPrice: { fieldName: 'shippingUnitPrice' }
            }
        },
        {
            label: "出货金额(元)",
            type: "customShipmentAmount",
            label: '出货金额(元)',
            type: 'customShipmentAmount',
            //initialWidth : 120,
            hideDefaultActions: true,
            typeAttributes: {
                shipmentAmount: { fieldName: "shipmentAmount" },
            },
                shipmentAmount: { fieldName: 'shipmentAmount' }
            }
        },
        {
            label: "有效期内库存(盒)",
            fieldName: "Boxnumber",
            label: '有效期内库存(盒)',
            fieldName: 'Boxnumber',
            //initialWidth : 120,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "有效期内库存(个)",
            fieldName: "Piecenumber",
            label: '有效期内库存(个)',
            fieldName: 'Piecenumber',
            //initialWidth : 120,
            wrapText: true,
            hideDefaultActions: true,
        },
            hideDefaultActions: true
        }
    ];
    @track editColumns = [
        {
            label: "消耗品名称",
            fieldName: "Name__c",
            label: '消耗品名称',
            fieldName: 'Name__c',
            hideDefaultActions: true,
            initialWidth: 250,
            wrapText: true,
            sortable: true
        },
        {
            label: "规格",
            fieldName: "packinglist",
            label: '规格',
            fieldName: 'packinglist',
            initialWidth: 50,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "CFDA状态",
            fieldName: "SFDA_Status__c",
            label: 'CFDA状态',
            fieldName: 'SFDA_Status__c',
            initialWidth: 100,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证编码号",
            fieldName: "approbation_No",
            label: '注册证编码号',
            fieldName: 'approbation_No',
            initialWidth: 150,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证效期",
            label: '注册证效期',
            initialWidth: 100,
            fieldName: "expiration_Date",
            hideDefaultActions: true,
            fieldName: 'expiration_Date',
            hideDefaultActions: true
        },
        {
            label: "第3分类",
            fieldName: "Category3__c",
            label: '第3分类',
            fieldName: 'Category3__c',
            initialWidth: 100,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第4分类",
            fieldName: "Category4__c",
            label: '第4分类',
            fieldName: 'Category4__c',
            initialWidth: 100,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第5分类",
            fieldName: "Category5__c",
            label: '第5分类',
            fieldName: 'Category5__c',
            initialWidth: 100,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "单位",
            fieldName: "Box_Piece__c",
            label: '单位',
            fieldName: 'Box_Piece__c',
            initialWidth: 100,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "出货数量",
            fieldName: "Shipment_Count__c",
            label: '出货数量',
            fieldName: 'Shipment_Count__c',
            initialWidth: 150,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "出货单价(元)",
            fieldName: "Shipment_amount__c",
            type: "number",
            label: '出货单价(元)',
            fieldName: 'Shipment_amount__c',
            type: 'number',
            typeAttributes: {
                minimumFractionDigits: 2,
                minimumFractionDigits: 2
            },
            initialWidth: 150,
            hideDefaultActions: true,
        },
            hideDefaultActions: true
        }
    ];
    @track editData = [];
    @track hospitalList = [];
    @track hospitalColumns = [
        {
            label: "医院名称",
            fieldName: "Name",
            label: '医院名称',
            fieldName: 'Name',
            initialWidth: 400,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "省份",
            fieldName: "stateMasterName",
            hideDefaultActions: true,
            label: '省份',
            fieldName: 'stateMasterName',
            hideDefaultActions: true
        },
        {
            label: "选择",
            fieldName: "Id1",
            type: "button",
            label: '选择',
            fieldName: 'Id1',
            type: 'button',
            hideDefaultActions: true,
            typeAttributes: {
                label: "选择",
                name: "Id2",
                size: 1,
            },
        },
                label: '选择',
                name: 'Id2',
                size: 1
            }
        }
    ];
    @track accountid = "";
    @track accountid = '';
    @track consumableproductdetailsRecords = [];
    @track SummonsStatus = "";
    @track ESetid = "";
    @track statusEdit = "";
    @track SummonsStatus = '';
    @track ESetid = '';
    @track statusEdit = '';
    @track cocLwc = {};
    @track selectedRows = [];
    @track ConsumableOut_report = "";
    @track ConsumableOut_report = '';
    @track isMutualTransferGoods = false;
    @track Barcode = "";
    @track Barcode = '';
    @track summonsForDirction = '';
    @track consumableorderdetails2RecordsColumns = [
        {
            label: "消耗品名称",
            fieldName: "ProdName",
            hideDefaultActions: true,
            label: '消耗品名称',
            fieldName: 'ProdName',
            hideDefaultActions: true
        },
        {
            label: "批次号",
            fieldName: "orderdetails2SerialLotNo__c",
            hideDefaultActions: true,
            label: '批次号',
            fieldName: 'orderdetails2SerialLotNo__c',
            hideDefaultActions: true
        },
        {
            label: "管理编码",
            fieldName: "orderdetails2TracingCode__c",
            hideDefaultActions: true,
            label: '管理编码',
            fieldName: 'orderdetails2TracingCode__c',
            hideDefaultActions: true
        },
        {
            label: "使用期限",
            fieldName: "orderdetails2Sterilization_limit__c",
            hideDefaultActions: true,
        },
            label: '使用期限',
            fieldName: 'orderdetails2Sterilization_limit__c',
            hideDefaultActions: true
        }
    ];
    @track consumableorderdetails2Records = [];
    //出货/销售
    @track salesColumns = [
        {
            label: "消耗品订单",
            fieldName: "Consumable_order_minor__c",
            label: '消耗品订单',
            fieldName: 'Consumable_order_minor__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品明细2名称",
            fieldName: "orderdetails2NameUrl",
            type: "url",
            label: '消耗品明细2名称',
            fieldName: 'orderdetails2NameUrl',
            type: 'url',
            typeAttributes: {
                label: { fieldName: "orderdetails2Name" },
                target: "_blank",
                label: { fieldName: 'orderdetails2Name' },
                target: '_blank'
            },
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 240
        },
        {
            label: "单位",
            fieldName: "Box_Piece__c",
            label: '单位',
            fieldName: 'Box_Piece__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品名称",
            fieldName: "ProdName",
            label: '消耗品名称',
            fieldName: 'ProdName',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "发货日期",
            fieldName: "Deliver_date__c",
            label: '发货日期',
            fieldName: 'Deliver_date__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "BarCode",
            fieldName: "Bar_Code__c",
            label: 'BarCode',
            fieldName: 'Bar_Code__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 500
        },
        {
            label: "使用期限",
            fieldName: "Sterilization_limit__c",
            label: '使用期限',
            fieldName: 'Sterilization_limit__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "出货数量",
            fieldName: "outboundCount",
            label: '出货数量',
            fieldName: 'outboundCount',
            hideDefaultActions: true,
            wrapText: true,
        },
            wrapText: true
        }
    ];
    @track salesData = [];
    @track salesErrorColumns = [
        {
            label: "消耗品订单",
            fieldName: "Consumable_order_minor__c",
            label: '消耗品订单',
            fieldName: 'Consumable_order_minor__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品明细2名称",
            fieldName: "orderdetails2Name",
            label: '消耗品明细2名称',
            fieldName: 'orderdetails2Name',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品名称",
            fieldName: "ProdName",
            label: '消耗品名称',
            fieldName: 'ProdName',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "单位",
            fieldName: "Box_Piece__c",
            label: '单位',
            fieldName: 'Box_Piece__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "BarCode",
            fieldName: "Bar_Code__c",
            hideDefaultActions: true,
            label: 'BarCode',
            fieldName: 'Bar_Code__c',
            hideDefaultActions: true
        },
        {
            label: "使用期限",
            fieldName: "Sterilization_limit__c",
            label: '使用期限',
            fieldName: 'Sterilization_limit__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "错误原因",
            fieldName: "ErrorReason",
            label: '错误原因',
            fieldName: 'ErrorReason',
            hideDefaultActions: true,
            wrapText: true,
        },
            wrapText: true
        }
    ];
    @track salesErrorData = [];
    @track salesAccountName = "";
    @track salesUserWorkLocation = "";
    @track salesAccountid = "";
    @track salesAccountName = '';
    @track salesUserWorkLocation = '';
    @track salesAccountid = '';
    @track salesOrderdetails = [];
    @track salesCoc = {};
    @track salesOrderpieceorboxMap;
@@ -441,55 +445,55 @@
    @track isDeleteDisabled = false;
    //出库单信息
    @track cocId = "";
    @track cocId = '';
    @track EditAble = false;
    @track summonsStatusPriceNotDetermined = false;
    @track isSummonsForDirctionTwoShow = false;
    @track isSummonsFlag = false;
    @track isConInvoiceShow = false;
    @track sumPrice = "";
    @track sumPrice = '';
    @track isSearchShow = false;
    @track Existarrive = false;
    @track Category3 = "";
    @track Category3 = '';
    @track category3Options = [];
    @track Category4 = "";
    @track Category4 = '';
    @track category4Options = [];
    @track Category5 = "";
    @track Category5 = '';
    @track category5Options = [];
    //发票id
    @track invoiceId = '';
    //二级经销商
    @track secondaryDistributor = "";
    @track secondaryDistributor = '';
    @track secondaryDistributorOptions = [];
    @track isDisabledSecondaryDistributor = false;
    //经销商录入
    @track ForDealerText = "";
    @track ForDealerText = '';
    @track isDisabledForDealerText = false;
    //客户名
    @track isModalOpen = false;
    @track HospitalName = "";
    @track searchHospitalName = "";
    @track OECId = "";
    @track HospitalName = '';
    @track searchHospitalName = '';
    @track OECId = '';
    @track isDisabledHospitalName = false;
    //科室
    @track ForCustomerText = "";
    @track ForCustomerText = '';
    @track isDisabledForCustomerText = false;
    //没有确定价格
    @track NoConfirmedPrice = false;
    //消耗品名称
    @track consumableName = "";
    @track consumableName = '';
    @track agencyProType = "";
    @track accountName = "";
    @track userWorkLocation = "";
    @track agencyProType = '';
    @track accountName = '';
    @track userWorkLocation = '';
    @track OutPattern__c = false;
    @track outOutPattern = "";
    @track outOutPattern = '';
    //出库单明细
    @track showTable = false;
@@ -497,37 +501,59 @@
    @track isSelectShow = false;
    @track hidecheckboxcolumn = false;
    @track is345Show = false;
    @track arriveorder = "";
    @track arriveorder = '';
    @track hasHosPro = false;
    @track InvoiceProNotLabel = "";
    @track RrturnProLabel = "";
    @track InvoicedLabel = "";
    @track InvoiceProNotLabel = '';
    @track RrturnProLabel = '';
    @track InvoicedLabel = '';
    @track outOutPatternOptionList = [];
    //文件上传
    @track showLoadingSpinner = false;
    @track UploadFile = "Upload File";
    @track fileName = "";
    @track UploadFile = 'Upload File';
    @track fileName = '';
    @track fileData = [];
    @track fileColumns = [
        {
            label: "标题",
            fieldName: "url",
            type: "url",
            typeAttributes: { label: { fieldName: "Title" }, target: "_blank" },
            hideDefaultActions: true,
            label: '标题',
            fieldName: 'url',
            type: 'url',
            typeAttributes: { label: { fieldName: 'Title' }, target: '_blank' },
            hideDefaultActions: true
        },
        {
            label: "创建人",
            fieldName: "CreatedByName",
            hideDefaultActions: true,
        },
            label: '创建人',
            fieldName: 'CreatedByName',
            hideDefaultActions: true
        }
    ];
    filesUploaded = [];
    fileContents;
    fileReader;
    content;
    MAX_FILE_SIZE = 1500000;
    //分页start
    //@track sortBy = "";
    //@track sortDirection = "asc";
    defaultSortDirection = 'asc';
    sortDirection = 'asc';
    sortedBy;
    @track pageSize = 5;
    error;
    records;
    currentPageToken = 0;
    nextPageToken = this.pageSize;
    @track totalRecords = 0;
    @track loader = false;
    @track pageNumber = 1;
    @track paginationVisibility = false;
    @track totalPages = 1;
    pageSizeOptions = [5, 10, 25, 50, 75, 100];
    @track recordStart = 0;
    @track recordEnd = 0;
    //end
    @track SearchDone = '';
    //InvoiceProNotLabel    RrturnProLabel  InvoicedLabel
    @wire(getObjectInfo, { objectApiName: OPPORTUNITY_OBJECT })
@@ -536,16 +562,16 @@
            this.InvoiceProNotLabel = data.fields.InvoiceProNot_count__c.label;
            this.RrturnProLabel = data.fields.RrturnPro_count__c.label;
            this.InvoicedLabel = data.fields.Invoiced_Procount__c.label;
            console.log("this.InvoiceProNotLabel = " + this.InvoiceProNotLabel);
            console.log("this.RrturnProLabel = " + this.RrturnProLabel);
            console.log("this.InvoicedLabel = " + this.InvoicedLabel);
            console.log('this.InvoiceProNotLabel = ' + this.InvoiceProNotLabel);
            console.log('this.RrturnProLabel = ' + this.RrturnProLabel);
            console.log('this.InvoicedLabel = ' + this.InvoicedLabel);
        }
    }
    //获取链接参数
    getQueryString(name) {
        console.log("getQueryString name " + name);
        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        console.log('getQueryString name ' + name);
        let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        let r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return decodeURIComponent(r[2]);
@@ -553,31 +579,54 @@
        return null;
    }
    connectedCallback() {
        console.log("connectedCallback LexSummonsCreat");
        this.ESetid = this.getQueryString("ESetid");
        this.ESetid = this.ESetid == null ? "" : this.ESetid;
        console.log('connectedCallback LexSummonsCreat');
        this.ESetid = this.getQueryString('ESetid');
        this.ESetid = this.ESetid == null ? '' : this.ESetid;
        //statusEdit
        this.statusEdit = this.getQueryString("KeyWords");
        this.statusEdit = this.statusEdit == null ? "" : this.statusEdit;
        console.log("this.ESetid = " + this.ESetid);
        console.log("this.statusEdit = " + this.statusEdit);
        if (this.ESetid == "") {
        this.statusEdit = this.getQueryString('KeyWords');
        this.statusEdit = this.statusEdit == null ? '' : this.statusEdit;
        console.log('this.ESetid = ' + this.ESetid);
        console.log('this.statusEdit = ' + this.statusEdit);
        if (this.ESetid == '') {
            this.isShowInformation = false;
        }
        console.log("init LexSummonsCreat");
        console.log('init LexSummonsCreat');
        init({
            ESetidJs: this.ESetid,
            statusEdit: this.statusEdit
        }).then((r) => {
            statusEdit: this.statusEdit,
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        })
            .then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
            if (r.status == "Success") {
                if (r.status == 'Success') {
                    //分页
                    console.log(
                        'r.entity.paginatedAccounts = ' +
                            JSON.stringify(r.entity.paginatedAccounts)
                    );
                    this.nextPageToken =
                        r.entity.paginatedAccounts.nextPageToken;
                    this.totalRecords = r.entity.paginatedAccounts.totalRecords;
                    this.recordStart = r.entity.paginatedAccounts.recordStart;
                    this.recordEnd = r.entity.paginatedAccounts.recordEnd;
                    this.totalPages = Math.ceil(
                        r.entity.paginatedAccounts.totalRecords / this.pageSize
                    );
                    console.log('this.totalPages = ' + this.totalPages);
                this.OECId = r.entity.HospitalInfo == null ? '' : r.entity.HospitalInfo;
                console.log("this.OECId = " + this.OECId);
                    this.OECId =
                        r.entity.HospitalInfo == null
                            ? ''
                            : r.entity.HospitalInfo;
                    console.log('this.OECId = ' + this.OECId);
                this.ConsumableOut_report = r.entity.ConsumableOut_report;
                console.log("this.ConsumableOut_report = " + this.ConsumableOut_report);
                    console.log(
                        'this.ConsumableOut_report = ' +
                            this.ConsumableOut_report
                    );
                this.accountid = r.entity.accountid;
                this.consumableproductdetailsRecords =
                    r.entity.consumableproductdetailsRecords;
@@ -589,105 +638,226 @@
                this.consumableorderdetails2Records =
                    r.entity.consumableorderdetails2Records;
                for (var i in this.consumableorderdetails2Records) {
                    this.consumableorderdetails2Records[i]["ProdName"] =
                        this.consumableorderdetails2Records[i]['ProdName'] =
                        this.consumableorderdetails2Records[i].Prod.Name;
                    this.consumableorderdetails2Records[i][
                        "orderdetails2SerialLotNo__c"
                            'orderdetails2SerialLotNo__c'
                    ] =
                        this.consumableorderdetails2Records[i].orderdetails2.SerialLotNo__c;
                            this.consumableorderdetails2Records[
                                i
                            ].orderdetails2.SerialLotNo__c;
                    this.consumableorderdetails2Records[i][
                        "orderdetails2TracingCode__c"
                            'orderdetails2TracingCode__c'
                    ] =
                        this.consumableorderdetails2Records[i].orderdetails2.TracingCode__c;
                            this.consumableorderdetails2Records[
                                i
                            ].orderdetails2.TracingCode__c;
                    this.consumableorderdetails2Records[i][
                        "orderdetails2Sterilization_limit__c"
                            'orderdetails2Sterilization_limit__c'
                    ] =
                        this.consumableorderdetails2Records[
                            i
                        ].orderdetails2.Sterilization_limit__c;
                }
                this.isShowOutboundProductDetails =
                    r.entity.consumableorderdetails2Count > 0 ? true : false;
                console.log("this.agencyProType = " + this.agencyProType);
                console.log("this.EditAble = " + this.EditAble);
                        r.entity.consumableorderdetails2Count > 0
                            ? true
                            : false;
                    console.log('this.agencyProType = ' + this.agencyProType);
                    console.log('this.EditAble = ' + this.EditAble);
                //查询附件
                if (!this.EditAble) this.getFiles();
                //第3分类
                for (var key in r.entity.categoryOptionMap) {
                    let object = {};
                    object["label"] = r.entity.categoryOptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.categoryOptionMap[key];
                        object['value'] = key;
                    this.category3Options.push(object);
                }
                console.log("this.category3Options = " + JSON.stringify(this.category3Options));
                    console.log(
                        'this.category3Options = ' +
                            JSON.stringify(this.category3Options)
                    );
                //第4分类
                for (var key in r.entity.category4OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category4OptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.category4OptionMap[key];
                        object['value'] = key;
                    this.category4Options.push(object);
                }
                console.log("this.category4Options = " + this.category4Options);
                    console.log(
                        'this.category4Options = ' + this.category4Options
                    );
                //第5分类
                for (var key in r.entity.category5OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category5OptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.category5OptionMap[key];
                        object['value'] = key;
                    this.category5Options.push(object);
                }
                console.log("this.category5Options = " + this.category5Options);
                    console.log(
                        'this.category5Options = ' + this.category5Options
                    );
                this.data = r.entity.pageRecords;
                console.log("this.data start = " + JSON.stringify(this.data));
                    this.editData = r.entity.pageRecords;
                    console.log(
                        'this.data start = ' + JSON.stringify(this.data)
                    );
                    if (this.EditAble) {
                for (var i in this.data) {
                    let unitOptions = [];
                    for (var key in this.data[i].boxorpieceMap) {
                        let unitOption = {};
                        unitOption["label"] = this.data[i].boxorpieceMap[key];
                        unitOption["value"] = key;
                                unitOption['label'] =
                                    this.data[i].boxorpieceMap[key];
                                unitOption['value'] = key;
                        unitOptions.push(unitOption);
                    }
                    this.data[i]["unitOptions"] = unitOptions;
                    this.data[i]["unitValue"] = this.data[i]["unitValue"] == null ? unitOptions[0].value : this.data[i]["unitValue"];
                            this.data[i]['unitOptions'] = unitOptions;
                            this.data[i]['unitValue'] =
                                this.data[i]['unitValue'] == null
                                    ? unitOptions[0].value
                                    : this.data[i]['unitValue'];
                    if (this.EditAble) {
                        this.data[i].orderdetails1["Box_Piece__c"] = this.data[i].orderdetails1["Box_Piece__c"] == null ? unitOptions[0].value : this.data[i].orderdetails1["Box_Piece__c"];
                        this.data[i].orderdetails1["Shipment_Count__c"] = this.data[i].orderdetails1["Shipment_Count__c"] == null ? 0 : this.data[i].orderdetails1["Shipment_Count__c"];
                        this.data[i].orderdetails1["Delivery_List_RMB__c"] = this.data[i].orderdetails1["Delivery_List_RMB__c"] == null ? 0.0 : this.data[i].orderdetails1["Delivery_List_RMB__c"];
                                this.data[i].orderdetails1['Box_Piece__c'] =
                                    this.data[i].orderdetails1[
                                        'Box_Piece__c'
                                    ] == null
                                        ? unitOptions[0].value
                                        : this.data[i].orderdetails1[
                                              'Box_Piece__c'
                                          ];
                                this.data[i].orderdetails1[
                                    'Shipment_Count__c'
                                ] =
                                    this.data[i].orderdetails1[
                                        'Shipment_Count__c'
                                    ] == null
                                        ? 0
                                        : this.data[i].orderdetails1[
                                              'Shipment_Count__c'
                                          ];
                                this.data[i].orderdetails1[
                                    'Delivery_List_RMB__c'
                                ] =
                                    this.data[i].orderdetails1[
                                        'Delivery_List_RMB__c'
                                    ] == null
                                        ? 0.0
                                        : this.data[i].orderdetails1[
                                              'Delivery_List_RMB__c'
                                          ];
                    } else {
                        this.data[i]["InvoiceProNot_count__c"] =
                            this.data[i].orderdetails1.InvoiceProNot_count__c;
                        this.data[i]["RrturnPro_count__c"] =
                            this.data[i].orderdetails1.RrturnPro_count__c;
                        this.data[i]["Invoiced_Procount__c"] =
                            this.data[i].orderdetails1.Invoiced_Procount__c;
                                this.data[i]['InvoiceProNot_count__c'] =
                                    this.data[
                                        i
                                    ].orderdetails1.InvoiceProNot_count__c;
                                this.data[i]['RrturnPro_count__c'] =
                                    this.data[
                                        i
                                    ].orderdetails1.RrturnPro_count__c;
                                this.data[i]['Invoiced_Procount__c'] =
                                    this.data[
                                        i
                                    ].orderdetails1.Invoiced_Procount__c;
                    }
                    // this.data[i]["shipmentNumber"] = 0;
                    // this.data[i]["shippingUnitPrice"] = 0.0;
                    //this.data[i]["shipmentNumber"] = this.data[i].orderdetails1["Shipment_Count__c"] == 0 ? '' : this.data[i].orderdetails1["Shipment_Count__c"];
                    //this.data[i]["shippingUnitPrice"] = this.data[i].orderdetails1["Delivery_List_RMB__c"] == 0 ? '' : this.data[i].orderdetails1["Delivery_List_RMB__c"];
                    this.data[i]["shipmentNumber"] = this.data[i].orderdetails1["Shipment_Count__c"];
                    this.data[i]["shippingUnitPrice"] = this.data[i].orderdetails1["Delivery_List_RMB__c"];
                            this.data[i]['shipmentNumber'] =
                                this.data[i].orderdetails1['Shipment_Count__c'];
                            this.data[i]['shippingUnitPrice'] =
                                this.data[i].orderdetails1[
                                    'Delivery_List_RMB__c'
                                ];
                    this.data[i]["recordId"] = this.data[i].Prod.Id;
                    this.data[i]["Id"] = this.data[i].Prod.Id;
                    this.data[i]["Name__c"] = this.data[i].Prod.Name__c;
                    this.data[i]["SFDA_Status__c"] = this.data[i].Prod.SFDA_Status__c;
                    this.data[i]["Category3__c"] = this.data[i].Prod.Category3__c;
                    this.data[i]["Category4__c"] = this.data[i].Prod.Category4__c;
                    this.data[i]["Category5__c"] = this.data[i].Prod.Category5__c;
                    this.data[i]["Box_Piece__c"] = this.data[i].orderdetails1.Box_Piece__c;
                    this.data[i]["shipmentAmount"] = this.data[i].orderdetails1.Shipment_amount__c;
                    this.data[i]["Shipment_amount__c"] = this.data[i].orderdetails1.Shipment_amount__c;
                    this.data[i]["Shipment_Count__c"] = this.data[i].orderdetails1.Shipment_Count__c;
                            this.data[i]['recordId'] = this.data[i].Prod.Id;
                            this.data[i]['Id'] = this.data[i].Prod.Id;
                            this.data[i]['Name__c'] = this.data[i].Prod.Name__c;
                            this.data[i]['SFDA_Status__c'] =
                                this.data[i].Prod.SFDA_Status__c;
                            this.data[i]['Category3__c'] =
                                this.data[i].Prod.Category3__c;
                            this.data[i]['Category4__c'] =
                                this.data[i].Prod.Category4__c;
                            this.data[i]['Category5__c'] =
                                this.data[i].Prod.Category5__c;
                            this.data[i]['Box_Piece__c'] =
                                this.data[i].orderdetails1.Box_Piece__c;
                            this.data[i]['shipmentAmount'] =
                                this.data[i].orderdetails1.Shipment_amount__c;
                            this.data[i]['Shipment_amount__c'] =
                                this.data[i].orderdetails1.Shipment_amount__c;
                            this.data[i]['Shipment_Count__c'] =
                                this.data[i].orderdetails1.Shipment_Count__c;
                    if (this.data[i]['check']) {
                        this.selectedRows.push(this.data[i].Id);
                    }
                }
                console.log("this.data = " + JSON.stringify(this.data));
                    } else {
                        for (var i in this.editData) {
                            this.editData[i]['unitValue'] =
                                this.editData[i]['unitValue'];
                            this.editData[i]['InvoiceProNot_count__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.InvoiceProNot_count__c;
                            this.editData[i]['RrturnPro_count__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.RrturnPro_count__c;
                            this.editData[i]['Invoiced_Procount__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.Invoiced_Procount__c;
                            this.editData[i]['shipmentNumber'] =
                                this.editData[i].orderdetails1[
                                    'Shipment_Count__c'
                                ];
                            this.editData[i]['shippingUnitPrice'] =
                                this.editData[i].orderdetails1[
                                    'Delivery_List_RMB__c'
                                ];
                            this.editData[i]['recordId'] =
                                this.editData[i].Prod.Id;
                            this.editData[i]['Id'] = this.editData[i].Prod.Id;
                            this.editData[i]['Name__c'] =
                                this.editData[i].Prod.Name__c;
                            this.editData[i]['SFDA_Status__c'] =
                                this.editData[i].Prod.SFDA_Status__c;
                            this.editData[i]['Category3__c'] =
                                this.editData[i].Prod.Category3__c;
                            this.editData[i]['Category4__c'] =
                                this.editData[i].Prod.Category4__c;
                            this.editData[i]['Category5__c'] =
                                this.editData[i].Prod.Category5__c;
                            this.editData[i]['Box_Piece__c'] =
                                this.editData[i].orderdetails1.Box_Piece__c;
                            this.editData[i]['shipmentAmount'] =
                                this.editData[
                                    i
                                ].orderdetails1.Shipment_amount__c;
                            this.editData[i]['Shipment_amount__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.Shipment_amount__c;
                            this.editData[i]['Shipment_Count__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.Shipment_Count__c;
                        }
                    }
                    console.log('this.data = ' + JSON.stringify(this.data));
                //show
                if (r.entity.EditDelCommitBtnDisabled || r.entity.EditAble) {
                    if (
                        r.entity.EditDelCommitBtnDisabled ||
                        r.entity.EditAble
                    ) {
                    this.isSaveShow = true;
                } else {
                    this.isEditShow = true;
@@ -700,110 +870,116 @@
                this.Existarrive = r.entity.Existarrive;
                console.log("this.EditAble = " + this.EditAble);
                    console.log('this.EditAble = ' + this.EditAble);
                this.hasHosPro = r.entity.hasHosPro;
                //disable
                if (Object.values(r.entity.coc).length > 0) {
                    this.cocLwc = r.entity.coc;
                    console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
                        console.log(
                            'this.cocLwc = ' + JSON.stringify(this.cocLwc)
                        );
                    var coc = r.entity.coc;
                    this.cocId = coc.Id;
                    console.log('cocId = ' + this.cocId);
                    coc.SummonsStatus = coc.SummonsStatus_c__c;
                    if (coc.SummonsStatus_c__c == "已完成") {
                        if (coc.SummonsStatus_c__c == '已完成') {
                        this.isEditDisabled = true;
                    }
                    if (
                        coc.SummonsStatus_c__c == "批准" ||
                        coc.SummonsStatus_c__c == "已销售待上传纳品书" ||
                        coc.SummonsStatus_c__c == "出库单已打印" ||
                        coc.SummonsStatus_c__c == "已完成"
                            coc.SummonsStatus_c__c == '批准' ||
                            coc.SummonsStatus_c__c == '已销售待上传纳品书' ||
                            coc.SummonsStatus_c__c == '出库单已打印' ||
                            coc.SummonsStatus_c__c == '已完成'
                    ) {
                        this.isDeliveryDisabled = true;
                    }
                    if (
                        ((coc.Billed_Status__c != "全部开票" &&
                            coc.SummonsStatus_c__c == "已完成") ||
                            ((coc.Billed_Status__c != '全部开票' &&
                                coc.SummonsStatus_c__c == '已完成') ||
                            coc.Onchange_order__c == true) &&
                        coc.SummonsForDirction__c != "互相调货"
                            coc.SummonsForDirction__c != '互相调货'
                    ) {
                        this.isOpenToInvoiceDisabled = false;
                    }
                    if (
                        coc.SummonsStatus_c__c == "已销售待上传纳品书" ||
                        coc.SummonsStatus_c__c == "批准" ||
                        coc.SummonsStatus_c__c == "出库单已打印" ||
                        coc.SummonsStatus_c__c == "草案中"
                            coc.SummonsStatus_c__c == '已销售待上传纳品书' ||
                            coc.SummonsStatus_c__c == '批准' ||
                            coc.SummonsStatus_c__c == '出库单已打印' ||
                            coc.SummonsStatus_c__c == '草案中'
                    ) {
                        this.isPraseToPDFDisabled = false;
                    }
                    if (
                        coc.Billed_Status__c != "还没开票" ||
                        coc.SummonsStatus_c__c == "已完成"
                            coc.Billed_Status__c != '还没开票' ||
                            coc.SummonsStatus_c__c == '已完成'
                    ) {
                        this.isOpenReportDisabled = false;
                    }
                    if (
                        coc.SummonsStatus_c__c == "已销售待上传纳品书" ||
                        coc.SummonsStatus_c__c == "价格未定" ||
                        coc.SummonsStatus_c__c == "批准" ||
                        coc.SummonsStatus_c__c == "出库单已打印" ||
                        coc.SummonsStatus_c__c == "已完成"
                            coc.SummonsStatus_c__c == '已销售待上传纳品书' ||
                            coc.SummonsStatus_c__c == '价格未定' ||
                            coc.SummonsStatus_c__c == '批准' ||
                            coc.SummonsStatus_c__c == '出库单已打印' ||
                            coc.SummonsStatus_c__c == '已完成'
                    ) {
                        this.isDeleteDisabled = true;
                    }
                    this.isConInvoiceShow =
                        coc.SummonsStatus_c__c == "已完成" &&
                            coc.SummonsForDirction__c != "互相调货"
                            coc.SummonsStatus_c__c == '已完成' &&
                            coc.SummonsForDirction__c != '互相调货'
                            ? true
                            : false;
                    this.summonsStatusPriceNotDetermined =
                        coc.SummonsStatus_c__c == "价格未定" ? true : false;
                            coc.SummonsStatus_c__c == '价格未定' ? true : false;
                    this.isSummonsForDirctionTwoShow =
                        coc.SummonsForDirction__c == "销售给二级经销商" ? true : false;
                            coc.SummonsForDirction__c == '销售给二级经销商'
                                ? true
                                : false;
                }
                this.isSearchShow =
                    !this.Existarrive &&
                        r.entity.coc.SummonsStatus_c__c != "价格未定" &&
                        r.entity.coc.SummonsStatus_c__c != '价格未定' &&
                        r.entity.EditAble
                        ? true
                        : false;
                this.hidecheckboxcolumn = !this.isSearchShow;
                this.arriveorder = r.entity.arriveorder;
                this.is345Show =
                    this.arriveorder == "" && this.Existarrive == false && this.EditAble
                        this.arriveorder == '' &&
                        this.Existarrive == false &&
                        this.EditAble
                        ? true
                        : false;
                //如果不显示345分类,columns里面删除3,4,5分类
                if (!this.is345Show) {
                    for (var i = 0; i < this.columns.length; i++) {
                        if (this.columns[i].label == "第3分类") {
                            if (this.columns[i].label == '第3分类') {
                            this.columns.splice(i, 1);
                        }
                    }
                    for (var i = 0; i < this.columns.length; i++) {
                        if (this.columns[i].label == "第4分类") {
                            if (this.columns[i].label == '第4分类') {
                            this.columns.splice(i, 1);
                        }
                    }
                    for (var i = 0; i < this.columns.length; i++) {
                        if (this.columns[i].label == "第5分类") {
                            if (this.columns[i].label == '第5分类') {
                            this.columns.splice(i, 1);
                        }
                    }
                    for (var i = 0; i < this.editColumns.length; i++) {
                        if (this.editColumns[i].label == "第3分类") {
                            if (this.editColumns[i].label == '第3分类') {
                            this.editColumns.splice(i, 1);
                        }
                    }
                    for (var i = 0; i < this.editColumns.length; i++) {
                        if (this.editColumns[i].label == "第4分类") {
                            if (this.editColumns[i].label == '第4分类') {
                            this.editColumns.splice(i, 1);
                        }
                    }
                    for (var i = 0; i < this.editColumns.length; i++) {
                        if (this.editColumns[i].label == "第5分类") {
                            if (this.editColumns[i].label == '第5分类') {
                            this.editColumns.splice(i, 1);
                        }
                    }
@@ -816,63 +992,71 @@
                if (!this.EditAble) {
                    let object1 = {
                        label: this.InvoiceProNotLabel,
                        fieldName: "InvoiceProNot_count__c",
                        type: "number",
                            fieldName: 'InvoiceProNot_count__c',
                            type: 'number',
                        typeAttributes: {
                            minimumFractionDigits: 2,
                                minimumFractionDigits: 2
                        },
                        hideDefaultActions: true,
                            hideDefaultActions: true
                    };
                    let object2 = {
                        label: this.RrturnProLabel,
                        fieldName: "RrturnPro_count__c",
                        hideDefaultActions: true,
                            fieldName: 'RrturnPro_count__c',
                            hideDefaultActions: true
                    };
                    let object3 = {
                        label: this.InvoicedLabel,
                        fieldName: "Invoiced_Procount__c",
                        type: "number",
                            fieldName: 'Invoiced_Procount__c',
                            type: 'number',
                        typeAttributes: {
                            minimumFractionDigits: 2,
                                minimumFractionDigits: 2
                        },
                        hideDefaultActions: true,
                            hideDefaultActions: true
                    };
                    this.editColumns.push(object1);
                    this.editColumns.push(object2);
                    this.editColumns.push(object3);
                } else {
                    this.ForCustomerText = this.cocLwc.Order_ForCustomerText__c;
                    console.log('EditAble = true this.ForCustomerText = ' + this.ForCustomerText);
                    this.summonsForDirction = this.cocLwc.SummonsForDirction__c;
                    console.log('EditAble = true this.summonsForDirction = ' + this.summonsForDirction);
                        this.ForCustomerText =
                            this.cocLwc.Order_ForCustomerText__c;
                        console.log(
                            'EditAble = true this.ForCustomerText = ' +
                                this.ForCustomerText
                        );
                        this.summonsForDirction =
                            this.cocLwc.SummonsForDirction__c;
                        console.log(
                            'EditAble = true this.summonsForDirction = ' +
                                this.summonsForDirction
                        );
                    let value = this.summonsForDirction;
                    switch (value) {
                        case "直接销售给医院":
                            case '直接销售给医院':
                            this.isDisabledHospitalName = false;
                            this.isDisabledForCustomerText = false;
                            this.secondaryDistributor = "";
                            this.ForDealerText = "";
                                this.secondaryDistributor = '';
                                this.ForDealerText = '';
                            this.isDisabledForDealerText = true;
                            this.isDisabledSecondaryDistributor = true;
                            break;
                        case "医院试用":
                            case '医院试用':
                            this.isDisabledHospitalName = false;
                            this.isDisabledForCustomerText = false;
                            this.isDisabledForDealerText = false;
                            this.isDisabledSecondaryDistributor = false;
                            break;
                        case "销售给二级经销商":
                            case '销售给二级经销商':
                            this.isDisabledHospitalName = false;
                            this.isDisabledForCustomerText = false;
                            this.isDisabledForDealerText = false;
                            this.isDisabledSecondaryDistributor = false;
                            break;
                        case "互相调货":
                            case '互相调货':
                            this.isDisabledHospitalName = true;
                            this.HospitalName = "";
                            this.OECId = "";
                                this.HospitalName = '';
                                this.OECId = '';
                            this.isDisabledForCustomerText = true;
                            this.ForCustomerText = "";
                                this.ForCustomerText = '';
                            this.isDisabledForDealerText = false;
                            this.isDisabledSecondaryDistributor = false;
                            this.isMutualTransferGoods = true;
@@ -888,79 +1072,84 @@
                //如果hasHosPro = true 医院特价
                if (this.hasHosPro) {
                    let object1 = {
                        label: "医院特价",
                        fieldName: "InvoiceProNot_count__c",
                        hideDefaultActions: true,
                            label: '医院特价',
                            fieldName: 'hospitalSpecialOffer',
                            type: 'boolean',
                            hideDefaultActions: true
                    };
                    this.columns.push(object1);
                    this.editColumns.push(object1);
                }
                //出库单信息
                this.isSummonsFlag = r.entity.SummonsFlag == "visible" ? true : false;
                console.log("r.entity.provinceOptsMap = " + r.entity.provinceOptsMap);
                    this.isSummonsFlag =
                        r.entity.SummonsFlag == 'visible' ? true : false;
                    console.log(
                        'r.entity.provinceOptsMap = ' + r.entity.provinceOptsMap
                    );
                for (var key in r.entity.provinceOptsMap) {
                    let object = {};
                    object["label"] = r.entity.provinceOptsMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.provinceOptsMap[key];
                        object['value'] = key;
                    this.secondaryDistributorOptions.push(object);
                }
                for (var key in r.entity.outOutPatternOptionMap) {
                    let object = {};
                    object["label"] = r.entity.outOutPatternOptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.outOutPatternOptionMap[key];
                        object['value'] = key;
                    this.outOutPatternOptionList.push(object);
                }
                console.log(
                    "this.secondaryDistributorOptions = " +
                        'this.secondaryDistributorOptions = ' +
                    JSON.stringify(this.secondaryDistributorOptions)
                );
                this.HospitalName = r.entity.HospitalName;
                this.sumPrice = r.entity.sumPrice.toFixed(2) + "元";
                    this.sumPrice = r.entity.sumPrice.toFixed(2) + '元';
                this.isShowSpinner = false;
                this.showTable = true;
                console.log("ESetid = " + this.ESetid);
                    console.log('ESetid = ' + this.ESetid);
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
            }
        }).catch((error) => {
            console.log("error = " + JSON.stringify(error));
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
        });
    }
    ChangeDirction(event) {
        let value = event.target.value;
        this.summonsForDirction = value;
        this.cocLwc["SummonsForDirction__c"] = value;
        console.log("选择了 = " + value);
        this.cocLwc['SummonsForDirction__c'] = value;
        console.log('选择了 = ' + value);
        switch (value) {
            case "直接销售给医院":
            case '直接销售给医院':
                this.isDisabledHospitalName = false;
                this.isDisabledForCustomerText = false;
                this.secondaryDistributor = "";
                this.ForDealerText = "";
                this.secondaryDistributor = '';
                this.ForDealerText = '';
                this.isDisabledForDealerText = true;
                this.isDisabledSecondaryDistributor = true;
                this.isMutualTransferGoods = false;
                break;
            case "医院试用":
            case '医院试用':
                this.isDisabledHospitalName = false;
                this.isDisabledForCustomerText = false;
                this.isDisabledForDealerText = false;
                this.isDisabledSecondaryDistributor = false;
                break;
            case "销售给二级经销商":
            case '销售给二级经销商':
                this.isDisabledHospitalName = false;
                this.isDisabledForCustomerText = false;
                this.isDisabledForDealerText = false;
                this.isDisabledSecondaryDistributor = false;
                break;
            case "互相调货":
            case '互相调货':
                this.isDisabledHospitalName = true;
                this.HospitalName = "";
                this.OECId = "";
                this.HospitalName = '';
                this.OECId = '';
                this.isDisabledForCustomerText = true;
                this.ForCustomerText = "";
                this.ForCustomerText = '';
                this.isDisabledForDealerText = false;
                this.isDisabledSecondaryDistributor = false;
                this.isMutualTransferGoods = true;
@@ -974,39 +1163,39 @@
    }
    dataChange(event) {
        let fieldName = event.target.getAttribute("data-field");
        let fieldName = event.target.getAttribute('data-field');
        let value = event.detail.value;
        console.log("fieldName = " + fieldName + " value = " + value);
        console.log('fieldName = ' + fieldName + ' value = ' + value);
        switch (fieldName) {
            case "summonsForDirction":
            case 'summonsForDirction':
                this.summonsForDirction = value;
                break;
            case "secondaryDistributor":
            case 'secondaryDistributor':
                this.secondaryDistributor = value;
                break;
            case "HospitalName":
            case 'HospitalName':
                this.HospitalName = value;
                break;
            case "ForDealerText":
            case 'ForDealerText':
                this.ForDealerText = value;
                this.cocLwc["Order_ForDealerText__c"] = value;
                this.cocLwc['Order_ForDealerText__c'] = value;
                break;
            case "ForCustomerText":
                this.cocLwc["Order_ForCustomerText__c"] = value;
            case 'ForCustomerText':
                this.cocLwc['Order_ForCustomerText__c'] = value;
                this.ForCustomerText = value;
                break;
            case "sumPrice":
            case 'sumPrice':
                this.sumPrice = value.toFixed(2);
                break;
            case "NoConfirmedPrice":
            case 'NoConfirmedPrice':
                this.NoConfirmedPrice = !this.NoConfirmedPrice;
                this.cocLwc["NoConfirmedPrice__c"] = this.NoConfirmedPrice;
                console.log("this.NoConfirmedPrice = " + this.NoConfirmedPrice);
                this.cocLwc['NoConfirmedPrice__c'] = this.NoConfirmedPrice;
                console.log('this.NoConfirmedPrice = ' + this.NoConfirmedPrice);
                break;
            case "consumableName":
            case 'consumableName':
                this.consumableName = value;
                break;
            case "Category3":
            case 'Category3':
                this.Category3 = value;
                //调用后台显示第四五分类
                this.showAllCate();
@@ -1015,7 +1204,7 @@
                    this.Category5 = '';
                }
                break;
            case "Category4":
            case 'Category4':
                this.Category4 = value;
                //调用后台显示第五分类
                this.showCate();
@@ -1023,84 +1212,92 @@
                    this.Category5 = '';
                }
                break;
            case "Category5":
            case 'Category5':
                this.Category5 = value;
                break;
            case "searchHospitalName":
            case 'searchHospitalName':
                this.searchHospitalName = value;
                break;
            case "Barcode":
            case 'Barcode':
                this.Barcode = value;
                break;
        }
    }
    showAllCate() {
        console.log('showAllCate')
        console.log('showAllCate');
        categoryAllload({
            category3Lwc: this.Category3
        }).then((r) => {
        })
            .then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                this.category4Options = [];
                this.category5Options = [];
                //第4分类
                for (var key in r.entity.category4OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category4OptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.category4OptionMap[key];
                        object['value'] = key;
                    this.category4Options.push(object);
                }
                console.log("this.category4Options = " + this.category4Options);
                    console.log(
                        'this.category4Options = ' + this.category4Options
                    );
                //第5分类
                for (var key in r.entity.category5OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category5OptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.category5OptionMap[key];
                        object['value'] = key;
                    this.category5Options.push(object);
                }
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
            }
        }).catch((error) => {
            console.log("error" + JSON.stringify(error));
            })
            .catch((error) => {
                console.log('error' + JSON.stringify(error));
        });
    }
    showCate() {
        console.log('showAllCate')
        console.log('showAllCate');
        categoryload({
            category3Lwc: this.Category3,
            category4Lwc: this.Category4
        }).then((r) => {
        })
            .then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                this.category4Options = [];
                this.category5Options = [];
                //第4分类
                for (var key in r.entity.category4OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category4OptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.category4OptionMap[key];
                        object['value'] = key;
                    this.category4Options.push(object);
                }
                console.log("this.category4Options = " + this.category4Options);
                    console.log(
                        'this.category4Options = ' + this.category4Options
                    );
                //第5分类
                for (var key in r.entity.category5OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category5OptionMap[key];
                    object["value"] = key;
                        object['label'] = r.entity.category5OptionMap[key];
                        object['value'] = key;
                    this.category5Options.push(object);
                }
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
            }
        }).catch((error) => {
            console.log("error" + JSON.stringify(error));
            })
            .catch((error) => {
                console.log('error' + JSON.stringify(error));
        });
    }
@@ -1112,38 +1309,41 @@
    showToast(type, msg) {
        this.isShowSpinner = false;
        this.showLoadingSpinner = false;
        this.isEditShowSpinner = false;
        const event = new ShowToastEvent({
            title: type,
            variant: type,
            message: msg,
            message: msg
        });
        this.dispatchEvent(event);
    }
    searchProductJs() {
        this.isShowSpinner = true;
        this.isEditShowSpinner = true;
        //this.showTable = false;
        //查询有哪些选择了的然后check
        const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        const selectedRows = this.template
            .querySelector('c-lex-custom-lightning-datatable')
            .getSelectedRows();
        console.log('selectedRows = ' + selectedRows);
        for (var i in this.data) {
            this.data[i]["check"] = false;
            this.data[i]['check'] = false;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                    this.data[i]['check'] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
            cloneData[i]["Category4"] = cloneData[i].Category4__c;
            cloneData[i]["Category5"] = cloneData[i].Category5__c;
            cloneData[i]["BoxPiece"] = cloneData[i].Box_Piece__c;
            cloneData[i]['Name'] = cloneData[i].Name__c;
            cloneData[i]['Category3'] = cloneData[i].Category3__c;
            cloneData[i]['Category4'] = cloneData[i].Category4__c;
            cloneData[i]['Category5'] = cloneData[i].Category5__c;
            cloneData[i]['BoxPiece'] = cloneData[i].Box_Piece__c;
            delete cloneData[i].Name__c;
            delete cloneData[i].Category3__c;
            delete cloneData[i].Category4__c;
@@ -1151,7 +1351,7 @@
            delete cloneData[i].Box_Piece__c;
        }
        console.log("cloneData = " + JSON.stringify(cloneData));
        console.log('cloneData = ' + JSON.stringify(cloneData));
        searchConsumableorderdetails({
            agencyProTypeLwc: this.agencyProType,
            accountNameLwc: this.accountName,
@@ -1163,161 +1363,194 @@
            category5: this.Category5,
            editAbleLwc: this.EditAble,
            pageRecordsLwcLwc: cloneData,
            consumableproductdetailsRecordsLwc: this.consumableproductdetailsRecords,
            consumableproductdetailsRecordsLwc:
                this.consumableproductdetailsRecords,
            arriveorderLwc: this.arriveorder,
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                //分页
                console.log(
                    'r.entity.paginatedAccounts = ' +
                        JSON.stringify(r.entity.paginatedAccounts)
                );
                this.nextPageToken = r.entity.paginatedAccounts.nextPageToken;
                this.totalRecords = r.entity.paginatedAccounts.totalRecords;
                this.recordStart = r.entity.paginatedAccounts.recordStart;
                this.recordEnd = r.entity.paginatedAccounts.recordEnd;
                this.totalPages = Math.ceil(
                    r.entity.paginatedAccounts.totalRecords / this.pageSize
                );
                console.log('this.totalPages = ' + this.totalPages);
                this.SearchDone = r.entity.SearchDone;
                let tempData = [];
                //this.data = r.entity.pageRecords;
                this.selectedRows = [];
                tempData = r.entity.pageRecords;
                for (var i in tempData) {
                    let unitOptions = [];
                    for (var key in tempData[i].boxorpieceMap) {
                        let unitOption = {};
                        unitOption["label"] = tempData[i].boxorpieceMap[key];
                        unitOption["value"] = key;
                        unitOption['label'] = tempData[i].boxorpieceMap[key];
                        unitOption['value'] = key;
                        unitOptions.push(unitOption);
                    }
                    tempData[i]["unitOptions"] = unitOptions;
                    tempData[i]["unitValue"] = tempData[i]["unitValue"] == null ? unitOptions[0].value : tempData[i]["unitValue"];
                    tempData[i]['unitOptions'] = unitOptions;
                    tempData[i]['unitValue'] =
                        tempData[i]['unitValue'] == null
                            ? unitOptions[0].value
                            : tempData[i]['unitValue'];
                    if (this.EditAble) {
                        tempData[i].orderdetails1["Box_Piece__c"] = tempData[i].orderdetails1["Box_Piece__c"] == null ? unitOptions[0].value : tempData[i].orderdetails1["Box_Piece__c"];
                        tempData[i].orderdetails1["Shipment_Count__c"] = tempData[i].orderdetails1["Shipment_Count__c"] == null ? 0 : tempData[i].orderdetails1["Shipment_Count__c"];
                        tempData[i].orderdetails1["Delivery_List_RMB__c"] = tempData[i].orderdetails1["Delivery_List_RMB__c"] == null ? 0.0 : tempData[i].orderdetails1["Delivery_List_RMB__c"];
                        tempData[i].orderdetails1['Box_Piece__c'] =
                            tempData[i].orderdetails1['Box_Piece__c'] == null
                                ? unitOptions[0].value
                                : tempData[i].orderdetails1['Box_Piece__c'];
                        tempData[i].orderdetails1['Shipment_Count__c'] =
                            tempData[i].orderdetails1['Shipment_Count__c'] ==
                            null
                                ? 0
                                : tempData[i].orderdetails1[
                                      'Shipment_Count__c'
                                  ];
                        tempData[i].orderdetails1['Delivery_List_RMB__c'] =
                            tempData[i].orderdetails1['Delivery_List_RMB__c'] ==
                            null
                                ? 0.0
                                : tempData[i].orderdetails1[
                                      'Delivery_List_RMB__c'
                                  ];
                    } else {
                        tempData[i]["InvoiceProNot_count__c"] =
                        tempData[i]['InvoiceProNot_count__c'] =
                            tempData[i].orderdetails1.InvoiceProNot_count__c;
                        tempData[i]["RrturnPro_count__c"] =
                        tempData[i]['RrturnPro_count__c'] =
                            tempData[i].orderdetails1.RrturnPro_count__c;
                        tempData[i]["Invoiced_Procount__c"] =
                        tempData[i]['Invoiced_Procount__c'] =
                            tempData[i].orderdetails1.Invoiced_Procount__c;
                    }
                    tempData[i]["shipmentNumber"] = tempData[i].orderdetails1["Shipment_Count__c"];
                    tempData[i]["shippingUnitPrice"] = tempData[i].orderdetails1["Delivery_List_RMB__c"];
                    tempData[i]['shipmentNumber'] =
                        tempData[i].orderdetails1['Shipment_Count__c'];
                    tempData[i]['shippingUnitPrice'] =
                        tempData[i].orderdetails1['Delivery_List_RMB__c'];
                    tempData[i]["recordId"] = tempData[i].Prod.Id;
                    tempData[i]["Id"] = tempData[i].Prod.Id;
                    tempData[i]["Name__c"] = tempData[i].Prod.Name__c;
                    tempData[i]["SFDA_Status__c"] = tempData[i].Prod.SFDA_Status__c;
                    tempData[i]["Category3__c"] = tempData[i].Prod.Category3__c;
                    tempData[i]["Category4__c"] = tempData[i].Prod.Category4__c;
                    tempData[i]["Category5__c"] = tempData[i].Prod.Category5__c;
                    tempData[i]["Box_Piece__c"] = tempData[i].orderdetails1.Box_Piece__c;
                    tempData[i]["shipmentAmount"] = tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]["Shipment_amount__c"] = tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]["Shipment_Count__c"] = tempData[i].orderdetails1.Shipment_Count__c;
                    tempData[i]['recordId'] = tempData[i].Prod.Id;
                    console.log(
                        'tempData[i]["hospitalSpecialOffer"] = ' +
                            tempData[i]['hospitalSpecialOffer']
                    );
                    if (tempData[i]['hospitalSpecialOffer']) {
                        tempData[i]['Id'] = tempData[i].Prod.Id + 'ishos';
                    } else {
                        tempData[i]['Id'] = tempData[i].Prod.Id + 'nothos';
                    }
                    tempData[i]['Name__c'] = tempData[i].Prod.Name__c;
                    tempData[i]['SFDA_Status__c'] =
                        tempData[i].Prod.SFDA_Status__c;
                    tempData[i]['Category3__c'] = tempData[i].Prod.Category3__c;
                    tempData[i]['Category4__c'] = tempData[i].Prod.Category4__c;
                    tempData[i]['Category5__c'] = tempData[i].Prod.Category5__c;
                    tempData[i]['Box_Piece__c'] =
                        tempData[i].orderdetails1.Box_Piece__c;
                    tempData[i]['shipmentAmount'] =
                        tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]['Shipment_amount__c'] =
                        tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]['Shipment_Count__c'] =
                        tempData[i].orderdetails1.Shipment_Count__c;
                    if (tempData[i]["shippingUnitPrice"] && tempData[i]["shipmentNumber"])
                        tempData[i]["shipmentAmount"] = this.amend(
                            tempData[i]["shipmentNumber"],
                            tempData[i]["shippingUnitPrice"],
                            "*"
                    if (
                        tempData[i]['shippingUnitPrice'] &&
                        tempData[i]['shipmentNumber']
                    )
                        tempData[i]['shipmentAmount'] = this.amend(
                            tempData[i]['shipmentNumber'],
                            tempData[i]['shippingUnitPrice'],
                            '*'
                        );
                    if (tempData[i]['check']) {
                        this.selectedRows.push(tempData[i].Id);
                    }
                }
                // for (var i in tempData) {
                //     let unitOptions = [];
                //     for (var key in tempData[i].boxorpieceMap) {
                //         let unitOption = {};
                //         unitOption["label"] = tempData[i].boxorpieceMap[key];
                //         unitOption["value"] = key;
                //         unitOptions.push(unitOption);
                //     }
                //     tempData[i]["unitOptions"] = unitOptions;
                //     tempData[i]["unitValue"] = unitOptions[0].value;
                //     tempData[i]["recordId"] = tempData[i].Prod.Id;
                //     tempData[i]["Id"] = tempData[i].Prod.Id;
                //     tempData[i]["Name__c"] = tempData[i].Prod.Name__c;
                //     tempData[i]["SFDA_Status__c"] = tempData[i].Prod.SFDA_Status__c;
                //     tempData[i]["Category3__c"] = tempData[i].Prod.Category3__c;
                //     tempData[i]["Category4__c"] = tempData[i].Prod.Category4__c;
                //     tempData[i]["Category5__c"] = tempData[i].Prod.Category5__c;
                //     tempData[i]["Box_Piece__c"] = tempData[i].orderdetails1.Box_Piece__c;
                //     tempData[i]["shipmentNumber"] = tempData[i].orderdetails1.Shipment_Count__c;
                //     tempData[i]["shippingUnitPrice"] = tempData[i].orderdetails1.Delivery_List_RMB__c;
                //     console.log(
                //         "shippingUnitPrice = " + tempData[i]["shippingUnitPrice"]
                //     );
                // if (tempData[i]["shippingUnitPrice"] && tempData[i]["shipmentNumber"])
                //     tempData[i]["shipmentAmount"] = this.amend(
                //         tempData[i]["shipmentNumber"],
                //         tempData[i]["shippingUnitPrice"],
                //         "*"
                //     );
                // }
                this.data = tempData;
                console.log("this.data = " + JSON.stringify(this.data));
                console.log('this.data = ' + JSON.stringify(this.data));
                console.log(
                    ' this.selectedRows = ' + JSON.stringify(this.selectedRows)
                );
                //this.showTable = true;
                this.isShowSpinner = false;
                this.isEditShowSpinner = false;
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
                console.log('r = ' + JSON.stringify(r));
                this.showToast('Error', r.msg);
            }
        });
    }
    searchHospitalNameModal() {
        console.log("searchHospitalNameModal");
        console.log('searchHospitalNameModal');
        hospitalInit({
            ctype: this.agencyProType,
            ctype: this.agencyProType
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            if (r.status == "Success") {
            if (r.status == 'Success') {
                this.hospitalList = r.entity.at;
                for (var i in this.hospitalList) {
                    this.hospitalList[i]["stateMasterName"] =
                    this.hospitalList[i]['stateMasterName'] =
                        this.hospitalList[i].State_Master__r.Name;
                }
                console.log("hospitalInit r = " + JSON.stringify(this.hospitalList));
                console.log(
                    'hospitalInit r = ' + JSON.stringify(this.hospitalList)
                );
                this.isModalOpen = true;
            }
        });
    }
    searchHospital() {
        console.log("this.searchHospitalName = " + this.searchHospitalName);
        console.log('this.searchHospitalName = ' + this.searchHospitalName);
        serContact({
            searchName: this.searchHospitalName,
            ctype: this.agencyProType,
            ctype: this.agencyProType
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            if (r.status == "Success") {
            if (r.status == 'Success') {
                this.hospitalList = r.entity.at;
                for (var i in this.hospitalList) {
                    this.hospitalList[i]["stateMasterName"] =
                    this.hospitalList[i]['stateMasterName'] =
                        this.hospitalList[i].State_Master__r.Name;
                }
                console.log("hospitalInit r = " + JSON.stringify(this.hospitalList));
                console.log(
                    'hospitalInit r = ' + JSON.stringify(this.hospitalList)
                );
            }
        });
    }
    searchHandleRowAction(event) {
        console.log("searchHandleRowAction");
        console.log('searchHandleRowAction');
        let row = event.detail.row;
        this.OECId = row.Id;
        this.HospitalName = row.Name;
        console.log(
            "this.OECId = " + this.OECId + " this.HospitalName = " + this.HospitalName
            'this.OECId = ' +
                this.OECId +
                ' this.HospitalName = ' +
                this.HospitalName
        );
        this.isModalOpen = false;
        console.log("this.isModalOpen = " + this.isModalOpen);
        console.log('this.isModalOpen = ' + this.isModalOpen);
    }
    clearAgencyI(event) {
        this.HospitalName = event.target.value;
        if (this.HospitalName == "" || this.HospitalName == null) {
            this.OECId = "";
        if (this.HospitalName == '' || this.HospitalName == null) {
            this.OECId = '';
        }
        console.log("this.HospitalName = " + this.HospitalName);
        console.log("this.OECId = " + this.OECId);
        if (this.OECId != null && this.OECId != "") {
        console.log('this.HospitalName = ' + this.HospitalName);
        console.log('this.OECId = ' + this.OECId);
        if (this.OECId != null && this.OECId != '') {
            this.checkOutPattern();
        }
    }
@@ -1334,9 +1567,9 @@
            }
        }
        if (ishos > 0) {
            this.cocLwc["OutPattern__c"] = true;
            this.cocLwc['OutPattern__c'] = true;
        } else {
            this.cocLwc["OutPattern__c"] = false;
            this.cocLwc['OutPattern__c'] = false;
        }
    }
@@ -1345,28 +1578,31 @@
    }
    handleUnitChange(event) {
        console.log("handleUnitChange");
        console.log('handleUnitChange');
        const unitDetail = event.detail;
        console.log("unitDetail = " + JSON.stringify(unitDetail));
        console.log('unitDetail = ' + JSON.stringify(unitDetail));
        for (var i in this.data) {
            if (this.data[i].recordId == unitDetail.data.recordId) {
                this.data[i].unitValue = unitDetail.data.unitValue;
                this.data[i].orderdetails1["Box_Piece__c"] = unitDetail.data.unitValue;
                this.data[i].orderdetails1['Box_Piece__c'] =
                    unitDetail.data.unitValue;
            }
        }
        console.log("this.data = " + JSON.stringify(this.data));
        console.log('this.data = ' + JSON.stringify(this.data));
    }
    handleShipmentNumber(event) {
        console.log("handleShipmentNumber");
        console.log('handleShipmentNumber');
        const numberDetail = event.detail;
        console.log("numberDetail = " + JSON.stringify(numberDetail));
        console.log('numberDetail = ' + JSON.stringify(numberDetail));
        let index = 0;
        for (var i in this.data) {
            if (this.data[i].recordId == numberDetail.data.recordId) {
                index = i;
                this.data[i].shipmentNumber = Number(numberDetail.data.shipmentnumber);
                this.data[i].orderdetails1["Shipment_Count__c"] = Number(
                this.data[i].shipmentNumber = Number(
                    numberDetail.data.shipmentnumber
                );
                this.data[i].orderdetails1['Shipment_Count__c'] = Number(
                    numberDetail.data.shipmentnumber
                );
            }
@@ -1379,7 +1615,7 @@
    }
    handleShipmentUnitPrice(event) {
        console.log("handleShipmentUnitPrice");
        console.log('handleShipmentUnitPrice');
        const priceDetail = event.detail;
        let index = 0;
        for (var i in this.data) {
@@ -1388,7 +1624,7 @@
                this.data[i].shippingUnitPrice = Number(
                    priceDetail.data.shipmentunitprice
                );
                this.data[i].orderdetails1["Delivery_List_RMB__c"] = Number(
                this.data[i].orderdetails1['Delivery_List_RMB__c'] = Number(
                    priceDetail.data.shipmentunitprice
                );
            }
@@ -1401,20 +1637,21 @@
    }
    ComputePrice(index, number, price) {
        console.log("index = " + index);
        console.log("number = " + number);
        console.log("price = " + price);
        let shipmentAmount = this.amend(number, price, "*");
        console.log("shipmentAmount = " + shipmentAmount);
        console.log('index = ' + index);
        console.log('number = ' + number);
        console.log('price = ' + price);
        let shipmentAmount = this.amend(number, price, '*');
        console.log('shipmentAmount = ' + shipmentAmount);
        let sumPrice = 0.0;
        this.data[index].shipmentAmount = shipmentAmount;
        for (var i in this.data) {
            if (this.data[i].shipmentAmount) sumPrice += this.data[i].shipmentAmount;
            if (this.data[i].shipmentAmount)
                sumPrice += this.data[i].shipmentAmount;
        }
        this.sumPrice = sumPrice.toFixed(2) + "元";
        this.sumPrice = sumPrice.toFixed(2) + '元';
        //存下选择行,不会被清空
        if (this.selectedRows.indexOf(this.data[index].Id) == -1)
            this.selectedRows.push(this.data[index].Id);
        // if (this.selectedRows.indexOf(this.data[index].Id) == -1)
        //     this.selectedRows.push(this.data[index].Id);
        // this.selectedRows = [];
        // for (var i in this.data) {
        //     if (this.data[i].check) {
@@ -1422,9 +1659,9 @@
        //     }
        // }
        this.data = [...this.data];
        this.selectedRows = [...this.selectedRows]
        console.log("this.selectedRows = " + JSON.stringify(this.selectedRows));
        console.log("this.data = " + JSON.stringify(this.data));
        this.selectedRows = [...this.selectedRows];
        console.log('this.selectedRows = ' + JSON.stringify(this.selectedRows));
        console.log('this.data = ' + JSON.stringify(this.data));
    }
    //num1 num2传入两个值  symbol +-*/符号
@@ -1436,12 +1673,12 @@
            str2Length;
        //解决整数没有小数点方法
        try {
            str1Length = str1.split(".")[1].length;
            str1Length = str1.split('.')[1].length;
        } catch (error) {
            str1Length = 0;
        }
        try {
            str2Length = str2.split(".")[1].length;
            str2Length = str2.split('.')[1].length;
        } catch (error) {
            str2Length = 0;
        }
@@ -1449,16 +1686,16 @@
        //
        console.log(step);
        switch (symbol) {
            case "+":
            case '+':
                result = (num1 * step + num2 * step) / step;
                break;
            case "-":
            case '-':
                result = (num1 * step - num2 * step) / step;
                break;
            case "*":
            case '*':
                result = (num1 * step * (num2 * step)) / step / step;
                break;
            case "/":
            case '/':
                result = (num1 * step) / (num2 * step);
                break;
            default:
@@ -1469,10 +1706,27 @@
    getSelectedRows(event) {
        let selectedRowsEvent = event.detail.selectedRows;
        console.log('selectedRowsEvent = ' + JSON.stringify(selectedRowsEvent));
        this.selectedRows = [];
        for (var i in selectedRowsEvent) {
            this.selectedRows.push(selectedRowsEvent[i].Id)
            this.selectedRows.push(selectedRowsEvent[i].Id);
        }
        // for (var i in this.data) {
        //     for (var j in selectedRowsEvent) {
        //         if (this.data[i].Id == selectedRowsEvent[j].Prod.Id) {
        //             this.ComputePrice(
        //                 i,
        //                 this.data[i].shipmentNumber,
        //                 this.data[i].shippingUnitPrice
        //             );
        //         }
        //     }
        // }
        // this.ComputePrice(
        //     index,
        //     this.data[index].shipmentNumber,
        //     this.data[index].shippingUnitPrice
        // );
        // const selectedRows = event.detail.selectedRows;
        // console.log("this.selectedRows = " + this.selectedRows);
        // for (var i in this.data) {
@@ -1488,8 +1742,8 @@
    }
    saveConfirmJs() {
        let msg = "出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!";
        if (this.SummonsStatus == "价格未定") {
        let msg = '出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!';
        if (this.SummonsStatus == '价格未定') {
            if (confirm(msg) == true) {
                this.saveConfirm();
            }
@@ -1502,41 +1756,43 @@
        this.isShowSpinner = true;
        //查询有哪些选择了的然后check
        const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        const selectedRows = this.template
            .querySelector('c-lex-custom-lightning-datatable')
            .getSelectedRows();
        console.log('selectedRows = ' + selectedRows);
        for (var i in this.data) {
            this.data[i]["check"] = false;
            this.data[i]['check'] = false;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                    this.data[i]['check'] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
            cloneData[i]["Category4"] = cloneData[i].Category4__c;
            cloneData[i]["Category5"] = cloneData[i].Category5__c;
            cloneData[i]["BoxPiece"] = cloneData[i].Box_Piece__c;
            cloneData[i]['Name'] = cloneData[i].Name__c;
            cloneData[i]['Category3'] = cloneData[i].Category3__c;
            cloneData[i]['Category4'] = cloneData[i].Category4__c;
            cloneData[i]['Category5'] = cloneData[i].Category5__c;
            cloneData[i]['BoxPiece'] = cloneData[i].Box_Piece__c;
            delete cloneData[i].Name__c;
            delete cloneData[i].Category3__c;
            delete cloneData[i].Category4__c;
            delete cloneData[i].Category5__c;
            delete cloneData[i].Box_Piece__c;
        }
        console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log("this.OECId = " + this.OECId);
        console.log("this.HospitalName = " + this.HospitalName);
        console.log("this.secondaryDistributor = " + this.secondaryDistributor);
        console.log("this.pageRecordsLwc = " + JSON.stringify(cloneData));
        console.log("this.accountid = " + this.accountid);
        console.log("this.ESetid = " + this.ESetid);
        console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
        console.log('this.OECId = ' + this.OECId);
        console.log('this.HospitalName = ' + this.HospitalName);
        console.log('this.secondaryDistributor = ' + this.secondaryDistributor);
        console.log('this.pageRecordsLwc = ' + JSON.stringify(cloneData));
        console.log('this.accountid = ' + this.accountid);
        console.log('this.ESetid = ' + this.ESetid);
        console.log(
            "this.consumableproductdetailsRecords = " +
            'this.consumableproductdetailsRecords = ' +
            JSON.stringify(this.consumableproductdetailsRecords)
        );
        save({
@@ -1547,79 +1803,87 @@
            pageRecordsLwc: cloneData,
            accountidLwc: this.accountid,
            ESetIdLwc: this.ESetid,
            consumableproductdetailsRecordsLwc: this.consumableproductdetailsRecords,
            consumableproductdetailsRecordsLwc:
                this.consumableproductdetailsRecords,
            agencyProTypeLwc: this.agencyProType,
            userWorkLocationLwc: this.userWorkLocation
        }).then((r) => {
        })
            .then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            debugger
            if (r.status == "Success") {
                let url = "/lexsummonscreat?ESetid=" + r.entity.ESetId;
                console.log('r = ' + JSON.stringify(r));
                debugger;
                if (r.status == 'Success') {
                    let url = '/lexsummonscreat?ESetid=' + r.entity.ESetId;
                this[NavigationMixin.Navigate]({
                    type: "standard__webPage",
                        type: 'standard__webPage',
                    attributes: {
                        url: url,
                    },
                            url: url
                        }
                });
            } else {
                console.log("r.msg = " + r.msg);
                this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
            }
        }).catch((error) => {
            console.log("error = " + JSON.stringify(error));
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
        });
    }
    //打印指示单
    PraseToPDFJs() {
        console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log("this.ESetId = " + this.ESetid);
        console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
        console.log('this.ESetId = ' + this.ESetid);
        PraseToPDF({
            cocLwc: this.cocLwc,
            ESetId: this.ESetid,
            ESetId: this.ESetid
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                window.open("/customer/summonsPDF?ESetid=" + r.entity.ESetId);
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                window.open('/customer/summonsPDF?ESetid=' + r.entity.ESetId);
            } else {
                console.log("r.msg = " + r.msg);
                this.showToast("Error", r.msg);
                console.log('r.msg = ' + r.msg);
                this.showToast('Error', r.msg);
            }
        });
    }
    //显示明细
    openReportJs() {
        console.log("openReportJs");
        console.log('openReportJs');
        var reportId = this.ESetid;
        reportId = reportId.substring(0, 15);
        let reportFilters = '[{"operator":"equals","value":"' + reportId + '","column":"FK_CUSTENT_ID"}]';
        let url = "/report/00O0l000000zZtpEAE?reportFilters=" + encodeURIComponent(reportFilters);
        console.log("url = " + url);
        let reportFilters =
            '[{"operator":"equals","value":"' +
            reportId +
            '","column":"FK_CUSTENT_ID"}]';
        let url =
            '/report/00O0l000000zZtpEAE?reportFilters=' +
            encodeURIComponent(reportFilters);
        console.log('url = ' + url);
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            type: 'standard__webPage',
            attributes: {
                url: url,
            },
                url: url
            }
        });
    }
    vpClear2Delay(event) {
        console.log("vpClear2Delay");
        if (this.summonsForDirction != "互相调货") {
            this.cocLwc["Order_ForDealerText__c"] = event.target.value;
            console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log('vpClear2Delay');
        if (this.summonsForDirction != '互相调货') {
            this.cocLwc['Order_ForDealerText__c'] = event.target.value;
            console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
        } else {
            //console.log('Order_ForDealerTextID__c = ' + this.cocLwc['Order_ForDealerTextID__c'])
            this.cocLwc["Order_ForDealerText__c"] =
                this.cocLwc["Order_ForDealerTextID__c"] == "" ||
                    this.cocLwc["Order_ForDealerTextID__c"] == null ||
                    this.cocLwc["Order_ForDealerTextID__c"] == undefined
                    ? ""
                    : this.cocLwc["Order_ForDealerText__c"];
            console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
            this.cocLwc['Order_ForDealerText__c'] =
                this.cocLwc['Order_ForDealerTextID__c'] == '' ||
                this.cocLwc['Order_ForDealerTextID__c'] == null ||
                this.cocLwc['Order_ForDealerTextID__c'] == undefined
                    ? ''
                    : this.cocLwc['Order_ForDealerText__c'];
            console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
            // console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
            // this.ForDealerText = this.cocLwc['Order_ForDealerText__c'];
            // event.target.value = this.cocLwc['Order_ForDealerText__c'];
@@ -1628,28 +1892,28 @@
    }
    handleSearch(event) {
        const lookupElement = event.target;
        console.log("event.detail = " + JSON.stringify(event.detail));
        console.log('event.detail = ' + JSON.stringify(event.detail));
        apexSearch({
            searchTerm: event.detail.searchTerm,
            searchTerm: event.detail.searchTerm
        })
            .then((results) => {
                lookupElement.setSearchResults(results);
            })
            .catch((error) => {
                console.log("error" + JSON.stringify(error));
                console.log('error' + JSON.stringify(error));
            });
    }
    handleSelectionChange(event) {
        const selection = event.target.getSelection();
        console.log("selection = " + JSON.stringify(selection));
        this.cocLwc["Order_ForDealerTextID__c"] = selection[0].id;
        this.cocLwc["Order_ForDealerText__c"] = selection[0].title;
        console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log('selection = ' + JSON.stringify(selection));
        this.cocLwc['Order_ForDealerTextID__c'] = selection[0].id;
        this.cocLwc['Order_ForDealerText__c'] = selection[0].title;
        console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
    }
    handleFilesChange(event) {
        console.log("handleFilesChange");
        console.log('handleFilesChange');
        if (event.target.files.length > 0) {
            this.filesUploaded = event.target.files;
            this.fileName = event.target.files[0].name;
@@ -1657,11 +1921,11 @@
    }
    handleSave() {
        console.log("saveFile");
        console.log('saveFile');
        if (this.filesUploaded.length > 0) {
            this.file = this.filesUploaded[0];
            if (this.file.size > this.MAX_FILE_SIZE) {
                this.showToast("Error", "文件过大");
                this.showToast('Error', '文件过大');
                return;
            }
            this.showPopSpinner = true;
@@ -1669,60 +1933,62 @@
            this.fileReader.onloadend = () => {
                this.fileContents = this.fileReader.result;
                let base64 = "base64,";
                this.content = this.fileContents.indexOf(base64) + base64.length;
                let base64 = 'base64,';
                this.content =
                    this.fileContents.indexOf(base64) + base64.length;
                this.fileContents = this.fileContents.substring(this.content);
                this.saveToFile();
            };
            this.fileReader.readAsDataURL(this.file);
        } else {
            this.fileName = "选择一个文件上传";
            this.fileName = '选择一个文件上传';
        }
    }
    saveToFile() {
        console.log("saveToFile");
        console.log("base64Data = " + encodeURIComponent(this.fileContents));
        console.log('saveToFile');
        console.log('base64Data = ' + encodeURIComponent(this.fileContents));
        saveFile({
            recordId: this.ESetid,
            fileName: this.fileName,
            base64Data: encodeURIComponent(this.fileContents),
            base64Data: encodeURIComponent(this.fileContents)
        })
            .then((r) => {
                this.showPopSpinner = false;
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                this.closePop();
                this.showToast("Success", "上传成功");
                this.showToast('Success', '上传成功');
                this.getFiles();
            })
            .catch((error) => {
                this.showPopSpinner = false;
                console.log("error = " + error.message);
                this.showToast("Error", "上传失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '上传失败');
            });
    }
    getFiles() {
        console.log("getFiles");
        console.log('getFiles');
        this.showLoadingSpinner = true;
        getFiles({
            recordId: this.ESetid,
            recordId: this.ESetid
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                this.fileData = r.entity.cvList;
                for (var i in this.fileData) {
                    this.fileData[i]["CreatedByName"] = this.fileData[i].CreatedBy.Name;
                    this.fileData[i]["url"] = "/" + this.fileData[i].Id;
                    this.fileData[i]['CreatedByName'] =
                        this.fileData[i].CreatedBy.Name;
                    this.fileData[i]['url'] = '/' + this.fileData[i].Id;
                }
                console.log("this.fileData = " + this.fileData);
                console.log('this.fileData = ' + this.fileData);
                this.showLoadingSpinner = false;
            })
            .catch((error) => {
                console.log("error = " + error.message);
                this.showToast("Error", "获取附件失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '获取附件失败');
            });
    }
@@ -1730,93 +1996,100 @@
        this.isShowSpinner = true;
        //查询有哪些选择了的然后check
        const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        const selectedRows = this.template
            .querySelector('c-lex-custom-lightning-datatable')
            .getSelectedRows();
        console.log('selectedRows = ' + selectedRows);
        for (var i in this.data) {
            this.data[i]["check"] = false;
            this.data[i]['check'] = false;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                    this.data[i]['check'] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
            cloneData[i]["Category4"] = cloneData[i].Category4__c;
            cloneData[i]["Category5"] = cloneData[i].Category5__c;
            cloneData[i]["BoxPiece"] = cloneData[i].Box_Piece__c;
            cloneData[i]['Name'] = cloneData[i].Name__c;
            cloneData[i]['Category3'] = cloneData[i].Category3__c;
            cloneData[i]['Category4'] = cloneData[i].Category4__c;
            cloneData[i]['Category5'] = cloneData[i].Category5__c;
            cloneData[i]['BoxPiece'] = cloneData[i].Box_Piece__c;
            delete cloneData[i].Name__c;
            delete cloneData[i].Category3__c;
            delete cloneData[i].Category4__c;
            delete cloneData[i].Category5__c;
            delete cloneData[i].Box_Piece__c;
        }
        console.log("cloneData = " + JSON.stringify(cloneData));
        console.log('cloneData = ' + JSON.stringify(cloneData));
        GoodsDelivery({
            cocLwc: this.cocLwc,
            ESetId: this.ESetid,
            pageRecordsLwcLwc: cloneData,
            pageRecordsLwcLwc: cloneData
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log(
                        "Summons_Order_type__c = " + this.cocLwc["Summons_Order_type__c"]
                        'Summons_Order_type__c = ' +
                            this.cocLwc['Summons_Order_type__c']
                    );
                    this.isSales =
                        this.cocLwc["Summons_Order_type__c"] == "销售" ? true : false;
                        this.cocLwc['Summons_Order_type__c'] == '销售'
                            ? true
                            : false;
                    this.GoodsDeliveryInit();
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
                this.isShippingSales = true;
            })
            .catch((error) => {
                console.log("error = " + error.message);
                this.showToast("Error", "跳转失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '跳转失败');
            });
    }
    GoodsDeliveryInit() {
        console.log("GoodsDeliveryInit");
        console.log('GoodsDeliveryInit');
        GoodsDeliveryInit({
            ESetId: this.ESetid,
            ESetId: this.ESetid
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.salesCoc = r.entity.coc;
                    this.salesAccountName = r.entity.accountName;
                    this.salesUserWorkLocation = r.entity.userWorkLocation;
                    this.salesAccountid = r.entity.accountid;
                    this.salesOrderdetails = r.entity.orderdetails;
                    this.salesData = r.entity.consumableorderdetailsRecords;
                    this.salesErrorData = r.entity.consumableorderdetailsRecordserror;
                    this.salesErrorData =
                        r.entity.consumableorderdetailsRecordserror;
                    this.salesOrderpieceorboxMap = r.entity.orderpieceorboxMap;
                    this.salesOrderpriceMap = r.entity.orderpriceMap;
                    this.salesOrderagencypriceMap = r.entity.orderagencypriceMap;
                    this.salesOrderagencypriceMap =
                        r.entity.orderagencypriceMap;
                    this.isShowSpinner = false;
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + error.message);
                this.showToast("Error", "初始化失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '初始化失败');
            });
    }
    SalesearchProductJs() {
        console.log("this.Barcode = " + this.Barcode);
        console.log('this.Barcode = ' + this.Barcode);
        this.isShowSpinner = true;
        SearchPro({
            cocLwc: this.salesCoc,
@@ -1825,55 +2098,65 @@
            userWorkLocation: this.salesUserWorkLocation,
            accountid: this.salesAccountid,
            orderdetails: this.salesOrderdetails,
            orderpieceorboxMap: this.salesOrderpieceorboxMap,
            orderpieceorboxMap: this.salesOrderpieceorboxMap
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                    console.log("SearchPro success");
                    this.salesErrorData = r.entity.consumableorderdetailsRecordserror;
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log('SearchPro success');
                    this.salesErrorData =
                        r.entity.consumableorderdetailsRecordserror;
                    this.salesData = r.entity.consumableorderdetailsRecords;
                    for (var i in this.salesErrorData) {
                        this.salesErrorData[i]["Consumable_order_minor__c"] =
                            this.salesErrorData[i].orderdetails2.Consumable_order_minor__c;
                        this.salesErrorData[i]["orderdetails2Name"] =
                        this.salesErrorData[i]['Consumable_order_minor__c'] =
                            this.salesErrorData[
                                i
                            ].orderdetails2.Consumable_order_minor__c;
                        this.salesErrorData[i]['orderdetails2Name'] =
                            this.salesErrorData[i].orderdetails2.Name;
                        this.salesErrorData[i]["ProdName"] =
                        this.salesErrorData[i]['ProdName'] =
                            this.salesErrorData[i].Prod.Name;
                        this.salesErrorData[i]["Box_Piece__c"] =
                        this.salesErrorData[i]['Box_Piece__c'] =
                            this.salesErrorData[i].orderdetails2.Box_Piece__c;
                        this.salesErrorData[i]["Bar_Code__c"] =
                        this.salesErrorData[i]['Bar_Code__c'] =
                            this.salesErrorData[i].orderdetails2.Bar_Code__c;
                        this.salesErrorData[i]["Sterilization_limit__c"] =
                            this.salesErrorData[i].orderdetails2.Sterilization_limit__c;
                        this.salesErrorData[i]['Sterilization_limit__c'] =
                            this.salesErrorData[
                                i
                            ].orderdetails2.Sterilization_limit__c;
                    }
                    for (var i in this.salesData) {
                        this.salesData[i]["Consumable_order_minor__c"] =
                            this.salesData[i].orderdetails2.Consumable_order_minor__c;
                        this.salesData[i]["orderdetails2Name"] =
                        this.salesData[i]['Consumable_order_minor__c'] =
                            this.salesData[
                                i
                            ].orderdetails2.Consumable_order_minor__c;
                        this.salesData[i]['orderdetails2Name'] =
                            this.salesData[i].orderdetails2.Name;
                        this.salesData[i]["orderdetails2NameUrl"] =
                            "/" + this.salesData[i].orderdetails2.Id;
                        this.salesData[i]["Box_Piece__c"] =
                        this.salesData[i]['orderdetails2NameUrl'] =
                            '/' + this.salesData[i].orderdetails2.Id;
                        this.salesData[i]['Box_Piece__c'] =
                            this.salesData[i].orderdetails2.Box_Piece__c;
                        this.salesData[i]["ProdName"] = this.salesData[i].Prod.Name;
                        this.salesData[i]["Deliver_date__c"] =
                        this.salesData[i]['ProdName'] =
                            this.salesData[i].Prod.Name;
                        this.salesData[i]['Deliver_date__c'] =
                            this.salesData[i].orderdetails2.Deliver_date__c;
                        this.salesData[i]["Bar_Code__c"] =
                        this.salesData[i]['Bar_Code__c'] =
                            this.salesData[i].orderdetails2.Bar_Code__c;
                        this.salesData[i]["Sterilization_limit__c"] =
                            this.salesData[i].orderdetails2.Sterilization_limit__c;
                        this.salesData[i]['Sterilization_limit__c'] =
                            this.salesData[
                                i
                            ].orderdetails2.Sterilization_limit__c;
                    }
                    this.isShowSpinner = false;
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + JSON.stringify(error.message));
                this.showToast("Error", "初始化失败");
                console.log('error = ' + JSON.stringify(error.message));
                this.showToast('Error', '初始化失败');
            });
    }
@@ -1888,7 +2171,7 @@
            delete cloneSalesData[i].Deliver_date__c;
            delete cloneSalesData[i].Bar_Code__c;
            delete cloneSalesData[i].Sterilization_limit__c;
            cloneSalesData[i]["ErrorReason"] = "";
            cloneSalesData[i]['ErrorReason'] = '';
        }
        this.isShowSpinner = true;
        ProSale({
@@ -1900,28 +2183,28 @@
            consumableorderdetailsRecordsLwc: JSON.stringify(cloneSalesData),
            orderdetails: this.salesOrderdetails,
            orderpriceMap: this.salesOrderpriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                    console.log("ProdElivery success");
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log('ProdElivery success');
                    this.isShowSpinner = false;
                    this[NavigationMixin.Navigate]({
                        type: "standard__webPage",
                        type: 'standard__webPage',
                        attributes: {
                            url: "/lexsaleanddelivery",
                        },
                            url: '/lexsaleanddelivery'
                        }
                    });
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + JSON.stringify(error.message));
                this.showToast("Error", "ProSale2失败");
                console.log('error = ' + JSON.stringify(error.message));
                this.showToast('Error', 'ProSale2失败');
            });
    }
@@ -1936,7 +2219,7 @@
            delete cloneSalesData[i].Deliver_date__c;
            delete cloneSalesData[i].Bar_Code__c;
            delete cloneSalesData[i].Sterilization_limit__c;
            cloneSalesData[i]["ErrorReason"] = "";
            cloneSalesData[i]['ErrorReason'] = '';
        }
        this.isShowSpinner = true;
        ProdElivery({
@@ -1948,28 +2231,28 @@
            consumableorderdetailsRecordsLwc: JSON.stringify(cloneSalesData),
            orderdetails: this.salesOrderdetails,
            orderpriceMap: this.salesOrderpriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                    console.log("ProdElivery success");
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log('ProdElivery success');
                    this.isShowSpinner = false;
                    this[NavigationMixin.Navigate]({
                        type: "standard__webPage",
                        type: 'standard__webPage',
                        attributes: {
                            url: "/lexsaleanddelivery",
                        },
                            url: '/lexsaleanddelivery'
                        }
                    });
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + JSON.stringify(error.message));
                this.showToast("Error", "初始化失败");
                console.log('error = ' + JSON.stringify(error.message));
                this.showToast('Error', '初始化失败');
            });
    }
@@ -1978,15 +2261,23 @@
        let url = '';
        console.log('this.invoiceId = ' + this.invoiceId);
        if (this.invoiceId.length > 0 && this.invoiceId != '000000000000000') {
            url = "/lexconinvoiceview?deliveryId=" + this.ESetid + "&invoiceId=" + this.invoiceId + "&KeyWords=Redirect";
            url =
                '/lexconinvoiceview?deliveryId=' +
                this.ESetid +
                '&invoiceId=' +
                this.invoiceId +
                '&KeyWords=Redirect';
        } else {
            url = "/lexconinvoiceview?deliveryId=" + this.ESetid + "&KeyWords=Redirect";
            url =
                '/lexconinvoiceview?deliveryId=' +
                this.ESetid +
                '&KeyWords=Redirect';
        }
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            type: 'standard__webPage',
            attributes: {
                url: url,
            },
                url: url
            }
        });
    }
@@ -1994,33 +2285,35 @@
    DeleteConsumable() {
        this.isShowSpinner = true;
        DelConsumable({
            ESetId: this.ESetid,
        }).then((r) => {
            ESetId: this.ESetid
        })
            .then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                let url = "/lexsaleanddelivery";
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    let url = '/lexsaleanddelivery';
                this[NavigationMixin.Navigate]({
                    type: "standard__webPage",
                        type: 'standard__webPage',
                    attributes: {
                        url: url,
                    },
                            url: url
                        }
                });
            } else {
                console.log("r.msg = " + r.msg);
                this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
            }
        }).catch((error) => {
            console.log("error = " + error.message);
            this.showToast("Error", "跳转失败");
            })
            .catch((error) => {
                console.log('error = ' + error.message);
                this.showToast('Error', '跳转失败');
        });
    }
    handleLoad() {
        console.log('handleLoad')
        console.log('handleLoad');
        try {
            const style = document.createElement('style');
            style.innerText = '.slds-button__icon {display: none;}';
            //style.innerText = '.slds-button__icon {display: none;}';
            this.template.querySelector('.hideHelpText').appendChild(style);
        } catch (error) {
            console.log(error);
@@ -2028,14 +2321,15 @@
    }
    handleLoad2() {
        console.log('handleLoad2')
        console.log('handleLoad2');
        try {
            const style = document.createElement('style');
            style.innerText = '.slds-button__icon {display: none;}';
            // style.innerText = '.slds-button__icon {display: none;}';
            this.template.querySelector('.hideHelpText').appendChild(style);
            const style2 = document.createElement('style');
            style2.innerText = '.hehe-layoutItem  .slds-form-element__label {padding : 0px}';
            style2.innerText =
                '.hehe-layoutItem  .slds-form-element__label {padding : 0px}';
            this.template.querySelector('.hideHelpText').appendChild(style2);
        } catch (error) {
            console.log(error);
@@ -2043,12 +2337,13 @@
    }
    //编辑出库单
    EditConsumable() {
        let url = "/lexsummonscreat?ESetid=" + this.ESetid + "&KeyWords=Redirect";
        let url =
            '/lexsummonscreat?ESetid=' + this.ESetid + '&KeyWords=Redirect';
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            type: 'standard__webPage',
            attributes: {
                url: url,
            },
                url: url
            }
        });
    }
@@ -2068,7 +2363,11 @@
    //是否显示附件移除
    get attDelBtn() {
        if (this.fileName != '' && this.fileName != null && this.fileName != '请选择一个文件上传') {
        if (
            this.fileName != '' &&
            this.fileName != null &&
            this.fileName != '请选择一个文件上传'
        ) {
            return true;
        } else {
            return false;
@@ -2095,4 +2394,211 @@
        this.Category5 = '';
        this.searchProductJs();
    }
    sortBy(field, reverse, primer) {
        const key = primer
            ? function (x) {
                  return primer(x[field]);
              }
            : function (x) {
                  return x[field];
              };
        return function (a, b) {
            a = key(a);
            b = key(b);
            return reverse * ((a > b) - (b > a));
        };
    }
    onHandleSort(event) {
        //将已经选好了的放到前面,不进行排序
        if (this.EditAble) {
            const { fieldName: sortedBy, sortDirection } = event.detail;
            const cloneData = [...this.data];
            cloneData.sort(
                this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)
            );
            let index = 0;
            let selectedRows = this.template
                .querySelector('c-lex-custom-lightning-datatable')
                .getSelectedRows();
            let selectedRowsIds = [];
            for (var i in selectedRows) {
                selectedRowsIds.push(selectedRows[i].Id);
            }
            console.log('selectedRowsIds = ' + JSON.stringify(selectedRowsIds));
            for (var i = 0; i < cloneData.length; i++) {
                if (selectedRowsIds.indexOf(cloneData[i].Id) != -1) {
                    if (i != 0) {
                        let temp = cloneData[index];
                        cloneData[index] = cloneData[i];
                        cloneData[i] = temp;
                    }
                    index++;
                }
            }
            this.data = cloneData;
            this.sortDirection = sortDirection;
            this.sortedBy = sortedBy;
        } else {
            const { fieldName: sortedBy, sortDirection } = event.detail;
            const cloneData = [...this.editData];
            cloneData.sort(
                this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)
            );
            this.editData = cloneData;
            this.sortDirection = sortDirection;
            this.sortedBy = sortedBy;
        }
    }
    handlePrevious() {
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.searchProductJs();
    }
    handleNext() {
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.searchProductJs();
    }
    handleFirst() {
        this.currentPageToken = 0;
        this.searchProductJs();
    }
    handleLast() {
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.searchProductJs();
    }
    handlePageschange(event) {
        console.log(event.detail);
        this.pageSize = event.detail;
        this.currentPageToken = 0;
        this.searchProductJs();
    }
    editHandlePrevious() {
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.searchEditProductJs();
    }
    editHandleNext() {
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.searchEditProductJs();
    }
    editHandleFirst() {
        this.currentPageToken = 0;
        this.searchEditProductJs();
    }
    editHandleLast() {
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.searchEditProductJs();
    }
    editHandlePageschange(event) {
        console.log(event.detail);
        this.pageSize = event.detail;
        this.currentPageToken = 0;
        this.searchEditProductJs();
    }
    searchEditProductJs() {
        this.isEditShowSpinner = true;
        this.showTable = false;
        init({
            ESetidJs: this.ESetid,
            statusEdit: this.statusEdit,
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    //分页
                    console.log(
                        'r.entity.paginatedAccounts = ' +
                            JSON.stringify(r.entity.paginatedAccounts)
                    );
                    this.nextPageToken =
                        r.entity.paginatedAccounts.nextPageToken;
                    this.totalRecords = r.entity.paginatedAccounts.totalRecords;
                    this.recordStart = r.entity.paginatedAccounts.recordStart;
                    this.recordEnd = r.entity.paginatedAccounts.recordEnd;
                    this.totalPages = Math.ceil(
                        r.entity.paginatedAccounts.totalRecords / this.pageSize
                    );
                    console.log('this.totalPages = ' + this.totalPages);
                    this.editData = r.entity.pageRecords;
                    console.log(
                        'this.data start = ' + JSON.stringify(this.data)
                    );
                    for (var i in this.editData) {
                        this.editData[i]['unitValue'] =
                            this.editData[i]['unitValue'];
                        this.editData[i]['InvoiceProNot_count__c'] =
                            this.editData[
                                i
                            ].orderdetails1.InvoiceProNot_count__c;
                        this.editData[i]['RrturnPro_count__c'] =
                            this.editData[i].orderdetails1.RrturnPro_count__c;
                        this.editData[i]['Invoiced_Procount__c'] =
                            this.editData[i].orderdetails1.Invoiced_Procount__c;
                        this.editData[i]['shipmentNumber'] =
                            this.editData[i].orderdetails1['Shipment_Count__c'];
                        this.editData[i]['shippingUnitPrice'] =
                            this.editData[i].orderdetails1[
                                'Delivery_List_RMB__c'
                            ];
                        this.editData[i]['recordId'] = this.editData[i].Prod.Id;
                        this.editData[i]['Id'] = this.editData[i].Prod.Id;
                        this.editData[i]['Name__c'] =
                            this.editData[i].Prod.Name__c;
                        this.editData[i]['SFDA_Status__c'] =
                            this.editData[i].Prod.SFDA_Status__c;
                        this.editData[i]['Category3__c'] =
                            this.editData[i].Prod.Category3__c;
                        this.editData[i]['Category4__c'] =
                            this.editData[i].Prod.Category4__c;
                        this.editData[i]['Category5__c'] =
                            this.editData[i].Prod.Category5__c;
                        this.editData[i]['Box_Piece__c'] =
                            this.editData[i].orderdetails1.Box_Piece__c;
                        this.editData[i]['shipmentAmount'] =
                            this.editData[i].orderdetails1.Shipment_amount__c;
                        this.editData[i]['Shipment_amount__c'] =
                            this.editData[i].orderdetails1.Shipment_amount__c;
                        this.editData[i]['Shipment_Count__c'] =
                            this.editData[i].orderdetails1.Shipment_Count__c;
                    }
                    this.showTable = true;
                    this.isEditShowSpinner = false;
                } else {
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
    get previousButtonDisabled() {
        return this.currentPageToken === 0;
    }
    get nextButtonDisabled() {
        return this.nextPageToken === undefined;
    }
}
force-app/main/default/lwc/paginatedList/paginatedList.html
@@ -1,6 +1,9 @@
<template>
    <template if:true={loader}>
        <lightning-spinner alternative-text="Loading..." size="small"></lightning-spinner>
        <lightning-spinner
            alternative-text="Loading..."
            size="small"
        ></lightning-spinner>
    </template>
    <template if:true={records}>
        <div class="table-container">
@@ -15,7 +18,6 @@
            </lightning-datatable>
        </div>
        <c-paginator    
            if:true={paginationVisibility}
            onprevious={handlePrevious}
            onnext={handleNext}
            onpageschange={handlePageschange}
force-app/main/default/lwc/paginatedList/paginatedList.js
@@ -1,36 +1,36 @@
import { LightningElement, api, track } from "lwc";
import getAccountsPaginated from "@salesforce/apex/PaginatedListControllerLwc.getAccountsPaginated";
import { LightningElement, api, track } from 'lwc';
import getAccountsPaginated from '@salesforce/apex/PaginatedListControllerLwc.getAccountsPaginated';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { reduceErrors } from 'c/ldsUtils';
import ACCOUNT_NAME_FIELD from "@salesforce/schema/Account.Name";
import ACCOUNT_TYPE_FIELD from "@salesforce/schema/Account.Type";
import ACCOUNT_PHONE_FIELD from "@salesforce/schema/Account.Type";
import ACCOUNT_EMPLOYEES_FIELD from "@salesforce/schema/Account.NumberOfEmployees";
import ACCOUNT_NAME_FIELD from '@salesforce/schema/Account.Name';
import ACCOUNT_TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_PHONE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_EMPLOYEES_FIELD from '@salesforce/schema/Account.NumberOfEmployees';
const COLUMNS = [
    {
        label: "Account Name",
        label: 'Account Name',
        fieldName: ACCOUNT_NAME_FIELD.fieldApiName,
        type: "text",
        sortable: "true"
        type: 'text',
        sortable: 'true'
    },
    { label: "Type", fieldName: ACCOUNT_TYPE_FIELD.fieldApiName, type: "text" },
    { label: 'Type', fieldName: ACCOUNT_TYPE_FIELD.fieldApiName, type: 'text' },
    {
        label: "Phone",
        label: 'Phone',
        fieldName: ACCOUNT_PHONE_FIELD.fieldApiName,
        type: "phone"
        type: 'phone'
    },
    {
        label: "Employees",
        label: 'Employees',
        fieldName: ACCOUNT_EMPLOYEES_FIELD.fieldApiName,
        type: "Number"
        type: 'Number'
    }
];
export default class PaginatedList extends LightningElement {
    columns = COLUMNS;
    @track sortBy = "Name";
    @track sortDirection = "asc";
    @track sortBy = 'Name';
    @track sortDirection = 'asc';
    @track pageSize = 10;
    error;
    records;
@@ -61,8 +61,11 @@
                    this.totalRecords = result.totalRecords;
                    this.recordStart = result.recordStart;
                    this.recordEnd = result.recordEnd;
                    this.totalPages = Math.ceil(result.totalRecords / this.pageSize);
                    this.paginationVisibility = this.totalPages > 1 ? true : false;
                    this.totalPages = Math.ceil(
                        result.totalRecords / this.pageSize
                    );
                    this.paginationVisibility =
                        this.totalPages > 1 ? true : false;
                }
            })
            .catch((error) => {
@@ -78,7 +81,7 @@
            });
    }
    doSorting(event) {
        console.log("Sort");
        console.log('Sort');
        this.sortBy = event.detail.fieldName;
        this.sortDirection = event.detail.sortDirection;
        this.currentPageToken = 0;
@@ -86,12 +89,14 @@
    }
    handlePrevious() {
        this.currentPageToken = Number(this.currentPageToken) - Number(this.pageSize);
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.getAccounts();
    }
    handleNext() {
        this.currentPageToken = Number(this.currentPageToken) + Number(this.pageSize);
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.getAccounts();
    }
    handleFirst() {
@@ -100,7 +105,8 @@
    }
    handleLast() {
        this.currentPageToken = this.totalPages > 1? (this.totalPages-1)* this.pageSize:0;
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.getAccounts();
    }
force-app/main/default/pages/summonsCreat.page
@@ -1,4 +1,12 @@
<apex:page Controller="summonsCreatController" showHeader="true" tabStyle="SaleAndDelivery__tab" sidebar="true" id="allPage" action="{!init}" title="出库单管理">
<apex:page
    Controller="summonsCreatController"
    showHeader="true"
    tabStyle="SaleAndDelivery__tab"
    sidebar="true"
    id="allPage"
    action="{!init}"
    title="出库单管理"
>
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
@@ -9,6 +17,13 @@
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<script type="text/javascript">
        console.log('hasHosPro = ' + '{!hasHosPro}')
        console.log('EditAble = ' + '{!EditAble}')
        console.log('pageRecords = ' + '{!pageRecords}')
        console.log('coc = ' + '{!coc}')
        console.log('provinceOpts = ' + '{!provinceOpts}')
        console.log('Existarrive = ' + '{!Existarrive}')
        console.log('SecondDealer = ' + '{!SecondDealer}')
function setFocusOnLoad() {}
function bodyOnLoad(){setFocusOnLoad();}
function searchsearchAgencyH(str){
@@ -64,6 +79,8 @@
}
// vivek update start
function saveConfirmJs(str){
            console.log('pageRecords = ' + '{!pageRecords}')
            debugger
    var msg = "出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!";
    if(str == '价格未定'){
        if(confirm(msg)==true){
@@ -87,6 +104,7 @@
            options = {minchars:3, minwords:1, resultsClass:'visitorplace_results'};
            jQuery(escapeVfId(str)).unbind();
            if (strPage != null) {
                        console.log('进入strPage != null')
                jQuery(escapeVfId(str)).suggest(strPage,options);
            }
        }catch(e){
@@ -362,7 +380,6 @@
}
window.sfdcPage.appendToOnloadQueue(function() { onLoadDirction(); });
</script>
<style>
    .visitorplace_results {
@@ -385,7 +402,8 @@
        color: #101010;
        text-align: left;
    }
    .panelGridCenter td,.panelGridCenter tr {
        .panelGridCenter td,
        .panelGridCenter tr {
        text-align: center;
    }
    .dateFormat  {
@@ -404,38 +422,109 @@
</style>
    <apex:form id="allForm">
    <!-- //add  by rentx 2021-2-26 -->
        <apex:actionFunction name="checkOutPatternFn" action="{!checkOutPattern}" status="fetchStatus" reRender="ConsumableorderdetailsSection,message,OutPattern01" onComplete="CountCounttestPrice();onLoadDirction();"/>
        <apex:actionFunction
            name="checkOutPatternFn"
            action="{!checkOutPattern}"
            status="fetchStatus"
            reRender="ConsumableorderdetailsSection,message,OutPattern01"
            onComplete="CountCounttestPrice();onLoadDirction();"
        />
    <!-- //add by rentx 2021-2-26 -->
        <apex:actionFunction name="refreshPageSize" action="{!refreshPageSize}" status="fetchStatus" reRender="ConsumableorderdetailsSection,message" onComplete="CountCounttestPrice();onLoadDirction();"/>
        <apex:actionFunction name="save" action="{!save}" rerender=" message,Editable,ConsumableorderdetailsSection" onComplete="unblockUI();CountCounttestPrice();onLoadDirction();">
        <apex:actionFunction
            name="refreshPageSize"
            action="{!refreshPageSize}"
            status="fetchStatus"
            reRender="ConsumableorderdetailsSection,message"
            onComplete="CountCounttestPrice();onLoadDirction();"
        />
        <apex:actionFunction
            name="save"
            action="{!save}"
            rerender=" message,Editable,ConsumableorderdetailsSection"
            onComplete="unblockUI();CountCounttestPrice();onLoadDirction();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="categoryload" action="{!categoryload}" rerender="searchBlock" onComplete="unblockUI();">
        <apex:actionFunction
            name="categoryload"
            action="{!categoryload}"
            rerender="searchBlock"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
         <apex:actionFunction name="categoryAllload" action="{!categoryAllload}" rerender="searchBlock" onComplete="unblockUI();">
        <apex:actionFunction
            name="categoryAllload"
            action="{!categoryAllload}"
            rerender="searchBlock"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="searchConsumableorderdetails" action="{!searchConsumableorderdetails}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CountCounttestPrice();onLoadDirction();">
        <apex:actionFunction
            name="searchConsumableorderdetails"
            action="{!searchConsumableorderdetails}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();CountCounttestPrice();onLoadDirction();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="setEditAble" action="{!setEditAble}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="setEditAble"
            action="{!setEditAble}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="approval" action="{!approval}" rerender="allForm" onComplete="unblockUI();openPDF();">
        <apex:actionFunction
            name="approval"
            action="{!approval}"
            rerender="allForm"
            onComplete="unblockUI();openPDF();"
        >
        </apex:actionFunction>
         <apex:actionFunction name="DelConsumable" action="{!DelConsumable}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="DelConsumable"
            action="{!DelConsumable}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="PraseToPDF" action="{!PraseToPDF}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="PraseToPDF"
            action="{!PraseToPDF}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="GoodsDelivery" action="{!GoodsDelivery}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="GoodsDelivery"
            action="{!GoodsDelivery}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="SortLimited" action="{!SortLimited}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CountCounttestPrice();onLoadDirction();">
        <apex:actionFunction
            name="SortLimited"
            action="{!SortLimited}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();CountCounttestPrice();onLoadDirction();"
        >
            <apex:param name="firstParam" assignTo="{!sortKey}" value="" />
        </apex:actionFunction>
        <!--<apex:actionFunction name="SortStore" action="{!SortStore}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
            <apex:param name="firstParam" assignTo="{!sortKey}" value="" />
        </apex:actionFunction>-->
        <apex:actionFunction name="FilesUpload" action="{!FilesUpload}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="FilesUpload"
            action="{!FilesUpload}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
        <input type="hidden" id="userState" value="{!localuser.State_Hospital__c}"/>
            <input
                type="hidden"
                id="userState"
                value="{!localuser.State_Hospital__c}"
            />
            <apex:pageBlock id="allBlock" >
                <table>
                    <colgroup>
@@ -456,33 +545,98 @@
                    </colgroup>
                    <tr>
                        <td></td>
                        <td  colspan="4"><apex:commandButton onclick="saveConfirmJs('{!coc.SummonsStatus_c__c}');" value="保存" style="width:150px" rerender="dummy" rendered="{!(EditDelCommitBtnDisabled||EditAble)}"/></td>
                        <td colspan="4">
                            <apex:commandButton
                                onclick="saveConfirmJs('{!coc.SummonsStatus_c__c}');"
                                value="保存"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!(EditDelCommitBtnDisabled||EditAble)}"
                            />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td ><apex:commandButton onclick="EditConsumable();"   value="编辑出库单" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已完成',true,false)}"/></td>
                        <td>
                            <apex:commandButton
                                onclick="EditConsumable();"
                                value="编辑出库单"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已完成',true,false)}"
                            />
                        </td>
                        <!--CHAN-B65CAZ 20181105 UpdateStart-->
                        <!-- <td ><apex:commandButton onclick="CommitConsumable();" value="提交出库单" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='已完成',true,false)}"/></td> -->
                        <td ><apex:commandButton onclick="GoodsDeliveryJs();"  value="出货/销售"     style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='已完成'||coc.SummonsStatus_c__c='价格未定',true,false)}"/></td>
                        <td>
                            <apex:commandButton
                                onclick="GoodsDeliveryJs();"
                                value="出货/销售"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='已完成'||coc.SummonsStatus_c__c='价格未定',true,false)}"
                            />
                        </td>
                        <!-- CHAN-B65CAZ 20181105 UpdateEnd-->
                        <td ><apex:commandButton onclick="openToInvoiceJs();return false;" value="开票" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(((coc.Billed_Status__c !='全部开票' &&coc.SummonsStatus_c__c='已完成') || coc.Onchange_order__c = true) && coc.SummonsForDirction__c!='互相调货',false,true)}"/></td>
                        <td>
                            <apex:commandButton
                                onclick="openToInvoiceJs();return false;"
                                value="开票"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(((coc.Billed_Status__c !='全部开票' &&coc.SummonsStatus_c__c='已完成') || coc.Onchange_order__c = true) && coc.SummonsForDirction__c!='互相调货',false,true)}"
                            />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <!--CHAN-B65CAZ 20181105 UpdateStart-->
                        <td ><apex:commandButton onclick="PraseToPDFJs();" value="打印指示单" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='草案中',false,true)}"/></td>
                        <!-- CHAN-B65CAZ 20181105 UpdateEnd-->
                        <td ><apex:commandButton onclick="openReportJs(); return false;" value="显示明细" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.Billed_Status__c !='还没开票' || coc.SummonsStatus_c__c='已完成',false,true)}"/></td>
                        <td ><apex:commandButton onclick="DeleteConsumable();" value="删除" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='价格未定'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='已完成',true,false)}"/></td>
                        <td >
                            <apex:commandButton
                                onclick="PraseToPDFJs();"
                                value="打印指示单"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='草案中',false,true)}"
                            />
                        </td>
                        <!-- CHAN-B65CAZ 20181105 UpdateEnd-->
                        <td>
                            <apex:commandButton
                                onclick="openReportJs(); return false;"
                                value="显示明细"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.Billed_Status__c !='还没开票' || coc.SummonsStatus_c__c='已完成',false,true)}"
                            />
                        </td>
                        <td>
                            <apex:commandButton
                                onclick="DeleteConsumable();"
                                value="删除"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='价格未定'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='已完成',true,false)}"
                            />
                        </td>
                        <td></td>
                    </tr>
                </table>
                <apex:outputPanel id="message">
                    <apex:pageMessages />
                 </apex:outputPanel>
<!--==============20160314====INSERT_CODE_END=======================================-->
                <apex:pageBlock title="出库单信息" id="Editable" rendered="{!EditAble}">
                <apex:pageBlock
                    title="出库单信息"
                    id="Editable"
                    rendered="{!EditAble}"
                >
                <!-- update start by vivek 2019-7-15 -->
                    <!-- <table>
                        <colgroup>
@@ -503,7 +657,9 @@
                        </colgroup> -->
                <!-- update end by vivek 2019-7-15 -->
                        <!-- update start by vivek 2019-7-15 -->
                        <apex:outputPanel rendered="{! If(coc.SummonsStatus_c__c == '价格未定',true,false) }">
                    <apex:outputPanel
                        rendered="{! If(coc.SummonsStatus_c__c == '价格未定',true,false) }"
                    >
                        <table>
                        <colgroup>
                            <col width="150px"/>
@@ -523,52 +679,118 @@
                        </colgroup>
                                <tr>
                                <td align="right">出库单号:</td>
                                <td align="left"><apex:outputField id="OrderCode_out2"  value="{!coc.Name}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderCode_out2"
                                        value="{!coc.Name}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right">出库单状态:</td>
                                <td align="left"><apex:outputField id="OrderStatus_out2" value="{!coc.SummonsStatus_c__c}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderStatus_out2"
                                        value="{!coc.SummonsStatus_c__c}"
                                        style="width: 300px"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">目的:</td>
                                <td align="left"><apex:outputField id="OrderDirction_out2"  value="{!coc.SummonsForDirction__c}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderDirction_out2"
                                        value="{!coc.SummonsForDirction__c}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right">开票状态:</td>
                                <td align="left">
                                <apex:outputField id="SecondDealer_level22" value="{!coc.Billed_Status__c}" style="width:300px"/>
                                    <apex:outputField
                                        id="SecondDealer_level22"
                                        value="{!coc.Billed_Status__c}"
                                        style="width: 300px"
                                    />
                                </td>
                            </tr>
                            <tr style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}">
                            <tr
                                style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}"
                            >
                                <td align="right">二级经销商:</td>
                                <td align="left"><apex:outputField id="SecondDealer_out2" value="{!coc.Order_Dealer_Info__c}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="SecondDealer_out2"
                                        value="{!coc.Order_Dealer_Info__c}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right"></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="right">客户名:</td>
                                <td align="left"><apex:outputField id="OrderForHospital_out2" value="{!coc.ShipmentAccount__c}" style="width:300px"/></td>
                                <td align="right"><apex:outputText value="发票:" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/></td>
                                <td align="left"><apex:inputField value="{!coc.ConInvoice_Code__c}" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}" id="ConInvoice_Code2"/>
                                <c:helpicon helpText="已开票的换货的时候,选择已开票的发票。" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderForHospital_out2"
                                        value="{!coc.ShipmentAccount__c}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right">
                                    <apex:outputText
                                        value="发票:"
                                        rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                    />
                                </td>
                                <td align="left">
                                    <apex:inputField
                                        value="{!coc.ConInvoice_Code__c}"
                                        rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                        id="ConInvoice_Code2"
                                    />
                                    <c:helpicon
                                        helpText="已开票的换货的时候,选择已开票的发票。"
                                        rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">科室:</td>
                                <td align="left">
                                    <apex:outputField id="Order_ForDealerText2" value="{!coc.Order_ForCustomerText__c}" style="width:170px"/>
                                    <apex:outputField
                                        id="Order_ForDealerText2"
                                        value="{!coc.Order_ForCustomerText__c}"
                                        style="width: 170px"
                                    />
                                </td>
                                <td align="right">出库金额:</td>
                                <td align="left"><apex:outputField id="sumPrice_buttom2" value="{!coc.Shipment_total_amount__c}" style="width:300px"/> 元</td>
                                <td align="left">
                                    <apex:outputField
                                        id="sumPrice_buttom2"
                                        value="{!coc.Shipment_total_amount__c}"
                                        style="width: 300px"
                                    />
                                    元
                                </td>
                            </tr>
                            <tr>
                                <td align="right">没有确定价格:</td>
                                <td align="left">
                                    <apex:inputCheckbox id="NoConfirmedPrice_out2" value="{!coc.NoConfirmedPrice__c}" disabled="true" />
                                    <apex:inputCheckbox
                                        id="NoConfirmedPrice_out2"
                                        value="{!coc.NoConfirmedPrice__c}"
                                        disabled="true"
                                    />
                                </td>
                                <!-- ===add by rentx 2020-12-04 start -->
                                <!-- <apex:detail rendered="{!agencyProType == 'ENG'}"> -->
                                    <!-- <td align="right">是否医院特价出库 : </td> -->
                                    <!-- <td align="left"> -->
                                        <apex:inputHidden id="OutPattern02" value="{!coc.OutPattern__c}"  />
                                <apex:inputHidden
                                    id="OutPattern02"
                                    value="{!coc.OutPattern__c}"
                                />
                                        <!-- <apex:outputField id="OutPattern02" value="{!coc.OutPattern__c}"  /> -->
                                        <!-- <apex:inputCheckbox id="OutPattern02" value="{!coc.OutPattern__c}" disabled="true"  /> -->
@@ -579,7 +801,9 @@
                            </tr>
                        </table>
                            </apex:outputPanel>
                        <apex:outputPanel rendered="{! If(coc.SummonsStatus_c__c != '价格未定',true,false) }">
                    <apex:outputPanel
                        rendered="{! If(coc.SummonsStatus_c__c != '价格未定',true,false) }"
                    >
                        <table>
                        <colgroup>
                            <col width="150px"/>
@@ -597,50 +821,124 @@
                            <col width="70px"/>
                            <col width="100px"/>
                        </colgroup>
                            <tr id = "SummonsFlag" style="visibility:{!SummonsFlag}">
                            <tr
                                id="SummonsFlag"
                                style="visibility:{!SummonsFlag}"
                            >
                                <td align="right">出库单号:</td>
                                <td align="left"><apex:outputField id="OrderCode"  value="{!coc.Name}" style="width:100px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderCode"
                                        value="{!coc.Name}"
                                        style="width: 100px"
                                    />
                                </td>
                                <td align="right">出库单状态:</td>
                                <td align="left"><apex:outputField id="SummonsStatus_c__c" value="{!coc.SummonsStatus_c__c}" style="width:100px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="SummonsStatus_c__c"
                                        value="{!coc.SummonsStatus_c__c}"
                                        style="width: 100px"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">目的:</td>
                                <td align="left"><div style="width:3px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div>
                                <apex:inputField onchange="ChangeDirction(this)" id="SummonsForDirction__c" value="{!coc.SummonsForDirction__c}" style="width:160px"/></td>
                                <td align="left">
                                    <div
                                        style="
                                            width: 3px;
                                            height: 20px;
                                            background-color: red;
                                            position: absolute;
                                            margin-right: 5px;
                                        "
                                    ></div>
                                    <apex:inputField
                                        onchange="ChangeDirction(this)"
                                        id="SummonsForDirction__c"
                                        value="{!coc.SummonsForDirction__c}"
                                        style="width: 160px"
                                    />
                                </td>
                                <td align="right">二级经销商:</td>
                                <td align="left">
                                <apex:selectList id="province" value="{!SecondDealer}" style="width:160px" size="1" >
                                    <apex:selectOptions value="{!provinceOpts}"/>
                                    <apex:selectList
                                        id="province"
                                        value="{!SecondDealer}"
                                        style="width: 160px"
                                        size="1"
                                    >
                                        <apex:selectOptions
                                            value="{!provinceOpts}"
                                        />
                                </apex:selectList>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">客户名:</td>
                                <td align="left">
                                    <apex:inputText id="OEC" value="{!HospitalName}" onclick="searchsearchAgencyH('{!agencyProType}'); return false;" onblur="clearAgencyI();return false;" style="width:155px"  />
                                    <apex:inputHidden value="{!HospitalInfo}" id="OECId" />
                                    <apex:inputText
                                        id="OEC"
                                        value="{!HospitalName}"
                                        onclick="searchsearchAgencyH('{!agencyProType}'); return false;"
                                        onblur="clearAgencyI();return false;"
                                        style="width: 155px"
                                    />
                                    <apex:inputHidden
                                        value="{!HospitalInfo}"
                                        id="OECId"
                                    />
                                </td>
                                <td align="right">经销商(录入):</td>
                                <td align="left">
                                    <apex:inputField id="Order_ForDealerText" value="{!coc.Order_ForDealerText__c}" onfocus="setVisitorPlace();" style="width:155px" onblur="if (j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value() == '互相调货'){vpClear2_delay();}"/>
                                    <apex:inputField
                                        id="Order_ForDealerText"
                                        value="{!coc.Order_ForDealerText__c}"
                                        onfocus="setVisitorPlace();"
                                        style="width: 155px"
                                        onblur="if (j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value() == '互相调货'){vpClear2_delay();}"
                                    />
<!--                                    <apex:inputField id="Order_ForDealerText" value="{!coc.Order_ForDealerText__c}"  style="width:155px" onblur="if (j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value() == '互相调货'){vpClear2_delay();}"/>-->
                                    <apex:inputHidden id="Order_ForDealerTextHidden" value="{!coc.Order_ForDealerText__c}" />
                                    <apex:inputHidden id="Order_ForDealerTextId" value="{!coc.Order_ForDealerTextID__c}" />
                                    <apex:inputHidden id="Order_ForDealerTextHiddenId" value="{!coc.Order_ForDealerTextID__c}" />
                                    <apex:inputHidden
                                        id="Order_ForDealerTextHidden"
                                        value="{!coc.Order_ForDealerText__c}"
                                    />
                                    <apex:inputHidden
                                        id="Order_ForDealerTextId"
                                        value="{!coc.Order_ForDealerTextID__c}"
                                    />
                                    <apex:inputHidden
                                        id="Order_ForDealerTextHiddenId"
                                        value="{!coc.Order_ForDealerTextID__c}"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">科室:</td>
                                <td align="left">
                                    <apex:inputField id="Order_ForCustomer" value="{!coc.Order_ForCustomerText__c}" style="width:155px"/>
                                    <apex:inputField
                                        id="Order_ForCustomer"
                                        value="{!coc.Order_ForCustomerText__c}"
                                        style="width: 155px"
                                    />
                                </td>
                                <td align="right">总金额:</td>
                                <td align="left"><apex:outputText id="sumPrice_buttom" value="{!sumPrice}"/> 元</td>
                                <td align="left">
                                    <apex:outputText
                                        id="sumPrice_buttom"
                                        value="{!sumPrice}"
                                    />
                                    元
                                </td>
                            </tr>
                            <tr>
                                <td align="right">没有确定价格:</td>
                                <td align="left">
                                    <apex:inputCheckbox id="NoConfirmedPrice" value="{!coc.NoConfirmedPrice__c}" />
                                    <apex:inputCheckbox
                                        id="NoConfirmedPrice"
                                        value="{!coc.NoConfirmedPrice__c}"
                                    />
                                </td>
                                <!-- ===add by rentx 2020-12-04 start 因为目前维护了特价产品的医院都是ENG医院,所以只有ENG的时候展示 是否医院特价出库 即可-->
@@ -648,12 +946,14 @@
                                    <!-- <td align="right" >是否医院特价出库 : </td> -->
                                    <!-- <td align="left"> -->
                                        <!-- <apex:outputField id="OutPattern01" value="{!coc.OutPattern__c}" /> -->
                                        <apex:inputHidden id="OutPattern01" value="{!coc.OutPattern__c}" />
                                <apex:inputHidden
                                    id="OutPattern01"
                                    value="{!coc.OutPattern__c}"
                                />
                                    <!-- </td> -->
                                <!-- </apex:detail> -->
                                <!-- ===add by rentx 2020-12-04 end -->
                            </tr>
                        </table>
                        </apex:outputPanel>
@@ -705,7 +1005,11 @@
                    <!-- update end by vivek2019-7-12 -->
                </apex:pageBlock>
<!--==============20160314====INSERT_CODE_START=======================================-->
                 <apex:pageBlock title="出库单信息" id="unEditable" rendered="{!!EditAble}">
                <apex:pageBlock
                    title="出库单信息"
                    id="unEditable"
                    rendered="{!!EditAble}"
                >
                    <table>
                        <colgroup>
                            <col width="150px"/>
@@ -725,51 +1029,113 @@
                        </colgroup>
                        <tr>
                            <td align="right">出库单号:</td>
                            <td align="left"><apex:outputField id="OrderCode_out"  value="{!coc.Name}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="OrderCode_out"
                                    value="{!coc.Name}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right">出库单状态:</td>
                            <td align="left"><apex:outputField id="OrderStatus_out" value="{!coc.SummonsStatus_c__c}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="OrderStatus_out"
                                    value="{!coc.SummonsStatus_c__c}"
                                    style="width: 300px"
                                />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">目的:</td>
                            <td align="left"><apex:outputField id="OrderDirction_out"  value="{!coc.SummonsForDirction__c}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="OrderDirction_out"
                                    value="{!coc.SummonsForDirction__c}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right">开票状态:</td>
                            <td align="left">
                            <apex:outputField id="SecondDealer_level2" value="{!coc.Billed_Status__c}" style="width:300px"/>
                                <apex:outputField
                                    id="SecondDealer_level2"
                                    value="{!coc.Billed_Status__c}"
                                    style="width: 300px"
                                />
                            </td>
                        </tr>
                        <tr style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}">
                        <tr
                            style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}"
                        >
                            <td align="right">二级经销商:</td>
                            <td align="left"><apex:outputField id="SecondDealer_out" value="{!coc.Order_Dealer_Info__c}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="SecondDealer_out"
                                    value="{!coc.Order_Dealer_Info__c}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right"></td>
                            <td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right">客户名:</td>
                            <td align="left"><apex:outputField id="OrderForHospital_out" value="{!coc.ShipmentAccount__c}" style="width:300px"/></td>
                            <td align="right"><apex:outputText value="发票:" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/></td>
                            <td align="left"><apex:inputField value="{!coc.ConInvoice_Code__c}" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}" id="ConInvoice_Code"/>
                            <c:helpicon helpText="已开票的换货的时候,选择已开票的发票。" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/>
                            <td align="left">
                                <apex:outputField
                                    id="OrderForHospital_out"
                                    value="{!coc.ShipmentAccount__c}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right">
                                <apex:outputText
                                    value="发票:"
                                    rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                />
                            </td>
                            <td align="left">
                                <apex:inputField
                                    value="{!coc.ConInvoice_Code__c}"
                                    rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                    id="ConInvoice_Code"
                                />
                                <c:helpicon
                                    helpText="已开票的换货的时候,选择已开票的发票。"
                                    rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">科室:</td>
                            <td align="left">
                                <apex:outputField id="Order_ForDealerText" value="{!coc.Order_ForCustomerText__c}" style="width:170px"/>
                                <apex:outputField
                                    id="Order_ForDealerText"
                                    value="{!coc.Order_ForCustomerText__c}"
                                    style="width: 170px"
                                />
                            </td>
                            <td align="right">出库金额:</td>
                            <td align="left"><apex:outputField id="sumPrice_buttom" value="{!coc.Shipment_total_amount__c}" style="width:300px"/> 元</td>
                            <td align="left">
                                <apex:outputField
                                    id="sumPrice_buttom"
                                    value="{!coc.Shipment_total_amount__c}"
                                    style="width: 300px"
                                />
                                元
                            </td>
                        <!--    <td/>
                            <td align="right" style="visibility:hidden">出库单日期:</td>
                            <td align="right" style="visibility:hidden"><apex:outputField id="OrderDate_out" value="{!coc.Order_date__c}" style="width:300px"/></td> -->
                        </tr>
                        <!-- update start by vivek2019-7-12 -->
                        <tr>
                            <td align="right">没有确定价格:</td>
                            <td align="left">
                                <apex:inputCheckbox id="NoConfirmedPrice_out" value="{!coc.NoConfirmedPrice__c}" disabled="true" />
                                <apex:inputCheckbox
                                    id="NoConfirmedPrice_out"
                                    value="{!coc.NoConfirmedPrice__c}"
                                    disabled="true"
                                />
                            </td>
                            <!-- ===add by rentx 2020-12-04 start -->
@@ -777,7 +1143,10 @@
                                <!-- <td align="right">是否医院特价出库 : </td> -->
                                <!-- <td align="left"> -->
                                    <!-- <apex:outputField id="OutPattern" value="{!coc.OutPattern__c}"/> -->
                                    <apex:inputHidden id="OutPattern" value="{!coc.OutPattern__c}"/>
                            <apex:inputHidden
                                id="OutPattern"
                                value="{!coc.OutPattern__c}"
                            />
                                <!-- </td> -->
                            <!-- </apex:detail> -->
                            <!-- ===add by rentx 2020-12-04 end -->
@@ -789,7 +1158,10 @@
<!--==============20160310====到货联动时不需要检索====================================-->
                <!-- update start by vivek 2019-7-15 -->
                <apex:pageBlock id="searchBlock" rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}">
                <apex:pageBlock
                    id="searchBlock"
                    rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                >
                <!-- apex:pageBlock id="searchBlock" rendered="{!IF(!Existarrive && EditAble,true,false)}"> -->
                <!-- update end by vivek 2019-7-15 -->
                    <table>
@@ -817,26 +1189,55 @@
                        </colgroup>
                        <tr>
                            <td align="right">消耗品名称</td>
                            <td><apex:inputText id="OrderDateSearch" value="{!category1}" style="width:100px"/></td>
                            <td>
                                <apex:inputText
                                    id="OrderDateSearch"
                                    value="{!category1}"
                                    style="width: 100px"
                                />
                            </td>
                            <td/>
                            <td align="right">第3分类</td>
                            <td>
                             <apex:selectList id="category3Search" value="{!category3}" style="width:100px" size="1" onchange="showAllCate();">
                                <apex:selectOptions value="{!categoryOptionList}"/>
                                <apex:selectList
                                    id="category3Search"
                                    value="{!category3}"
                                    style="width: 100px"
                                    size="1"
                                    onchange="showAllCate();"
                                >
                                    <apex:selectOptions
                                        value="{!categoryOptionList}"
                                    />
                            </apex:selectList>
                            </td>
                            <td/>
                             <td align="right">第4分类</td>
                            <td>
                             <apex:selectList id="category4Search" value="{!category4}" style="width:100px" size="1" onchange="showCate();">
                                <apex:selectOptions value="{!category4OptionList}"/>
                                <apex:selectList
                                    id="category4Search"
                                    value="{!category4}"
                                    style="width: 100px"
                                    size="1"
                                    onchange="showCate();"
                                >
                                    <apex:selectOptions
                                        value="{!category4OptionList}"
                                    />
                            </apex:selectList>
                            </td>
                            <td/>
                             <td align="right">第5分类</td>
                             <td>
                             <apex:selectList id="category5Search" value="{!category5}" style="width:100px" size="1">
                                <apex:selectOptions value="{!category5OptionList}"/>
                                <apex:selectList
                                    id="category5Search"
                                    value="{!category5}"
                                    style="width: 100px"
                                    size="1"
                                >
                                    <apex:selectOptions
                                        value="{!category5OptionList}"
                                    />
                            </apex:selectList>
                            </td>
                            <td/>
@@ -844,8 +1245,15 @@
                            <apex:detail rendered="{!hasHosPro}">
                                <td align="right" width="120px">医院特价</td>
                                 <td>
                                 <apex:selectList id="outOutPattern" value="{!outOutPattern}" style="width:100px" size="1">
                                    <apex:selectOptions value="{!outOutPatternOptionList}"/>
                                    <apex:selectList
                                        id="outOutPattern"
                                        value="{!outOutPattern}"
                                        style="width: 100px"
                                        size="1"
                                    >
                                        <apex:selectOptions
                                            value="{!outOutPatternOptionList}"
                                        />
                                </apex:selectList>
                                </td>
                                </apex:detail>
@@ -855,8 +1263,22 @@
                            <!-- <td align="right">产品型号</td>
                            <td><apex:inputText id="OrderCodeSearch" value="{!category_Goods}" style="width:100px"/></td> -->
                            <td align="right"></td>
                            <td><apex:commandButton value="检索" style="width: 100px;" onclick="searchProductJs(); return false;" /></td>
                            <td><input type="button" value="清空" style="width: 100px;" onclick="ClearJs()" class="btn"/></td>
                            <td>
                                <apex:commandButton
                                    value="检索"
                                    style="width: 100px"
                                    onclick="searchProductJs(); return false;"
                                />
                            </td>
                            <td>
                                <input
                                    type="button"
                                    value="清空"
                                    style="width: 100px"
                                    onclick="ClearJs()"
                                    class="btn"
                                />
                            </td>
                            <td/>
                        </tr>
                        <tr>
@@ -864,33 +1286,92 @@
                        </tr>
                    </table>
                </apex:pageBlock>
                <div id="ErrorName" style="color: red;font-weight: bold;">{!alertMessage}</div>
                <apex:pageBlock title="出库单明细" id="ConsumableorderdetailsSection">
                <div id="ErrorName" style="color: red; font-weight: bold">
                    {!alertMessage}
                </div>
                <apex:pageBlock
                    title="出库单明细"
                    id="ConsumableorderdetailsSection"
                >
                    <!--<apex:inputHidden id="consumableorderdetailsCnt" value="{!consumableorderdetailsCount}"/>-->
                    <input type="hidden" id="allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount" value="{!consumableorderdetailsCount}" />
                    <table class="list" border="0" cellpadding="0" cellspacing="0" id="ConsumableorderdetailsTable">
                    <input
                        type="hidden"
                        id="allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount"
                        value="{!consumableorderdetailsCount}"
                    />
                    <table
                        class="list"
                        border="0"
                        cellpadding="0"
                        cellspacing="0"
                        id="ConsumableorderdetailsTable"
                    >
                         <tr class="headerRow">
                            <!-- update start by vivek 2019-7-15 -->
                            <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}">
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                            >
                            <!-- <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble,true,false)}"> -->
                            <!-- update start by vivek 2019-7-15 -->
                                <th><input type='checkbox' onClick='checkAll()' id='checker'/>选择</th>
                                <th>
                                    <input
                                        type="checkbox"
                                        onClick="checkAll()"
                                        id="checker"
                                    />选择
                                </th>
                            </apex:variable>
                            <th><a href="#" onclick="SortLimitedJs('0');return false;" style="text-decoration: underline;">消耗品名称</a>{!sortOrder[0]}</th>
                            <th>
                                <a
                                    href="#"
                                    onclick="SortLimitedJs('0');return false;"
                                    style="text-decoration: underline"
                                    >消耗品名称</a
                                >{!sortOrder[0]}
                            </th>
                        <!--    <th><a href="#" onclick="SortLimitedJs('1');return false;" style="text-decoration: underline;">产品型号</a>{!sortOrder[1]}</th>-->
                            <!-- TODO 本番暂不显示 -->
                            <apex:variable var="v" value="">
                            <th style="width: 80px;text-align:center;">规格</th>
                                <th style="width: 80px; text-align: center">
                                    规格
                                </th>
                            </apex:variable>
                            <th>CFDA状态</th>
                            <th>注册证编码号</th>
                            <th>注册证效期</th>
                            <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}">
                             <th><a href="#" onclick="SortLimitedJs('5');return false;" style="text-decoration: underline;">第3分类</a>{!sortOrder[5]}</th>
                            <th><a href="#" onclick="SortLimitedJs('6');return false;" style="text-decoration: underline;">第4分类</a>{!sortOrder[6]}</th>
                            <th><a href="#" onclick="SortLimitedJs('7');return false;" style="text-decoration: underline;">第5分类</a>{!sortOrder[7]}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}"
                            >
                                <th>
                                    <a
                                        href="#"
                                        onclick="SortLimitedJs('5');return false;"
                                        style="text-decoration: underline"
                                        >第3分类</a
                                    >{!sortOrder[5]}
                                </th>
                                <th>
                                    <a
                                        href="#"
                                        onclick="SortLimitedJs('6');return false;"
                                        style="text-decoration: underline"
                                        >第4分类</a
                                    >{!sortOrder[6]}
                                </th>
                                <th>
                                    <a
                                        href="#"
                                        onclick="SortLimitedJs('7');return false;"
                                        style="text-decoration: underline"
                                        >第5分类</a
                                    >{!sortOrder[7]}
                                </th>
                            </apex:variable>
                            <th>单位</th>
                            <th>出货数量</th>
@@ -906,23 +1387,50 @@
                                <th>出货单价(元)</th>
                            </apex:variable>-->
                            <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="BoxPiece_UnEditout">
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}"
                                id="BoxPiece_UnEditout"
                            >
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!if(EditAble,true,false)}">
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!if(EditAble,true,false)}"
                            >
                            <th>出货金额(元)</th>
                            <!--<th><a href="#" onclick="SortStoreJs('3');return false;" style="text-decoration: underline;width: 100px;text-align: center;">有效期内库存</a>{!sortOrder[3]}</th>-->
                            <th>有效期内库存(盒)</th>
                            <th>有效期内库存(个)</th>
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!!EditAble}">
                                <th>{!$ObjectType.Consumable_Orderdetails__c.fields.InvoiceProNot_count__c.label}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!!EditAble}"
                            >
                                <th>
                                    {!$ObjectType.Consumable_Orderdetails__c.fields.InvoiceProNot_count__c.label}
                                </th>
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!!EditAble}">
                                <th>{!$ObjectType.Consumable_Orderdetails__c.fields.RrturnPro_count__c.label}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!!EditAble}"
                            >
                                <th>
                                    {!$ObjectType.Consumable_Orderdetails__c.fields.RrturnPro_count__c.label}
                                </th>
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!!EditAble}">
                                <th>{!$ObjectType.Consumable_Orderdetails__c.fields.Invoiced_Procount__c.label}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!!EditAble}"
                            >
                                <th>
                                    {!$ObjectType.Consumable_Orderdetails__c.fields.Invoiced_Procount__c.label}
                                </th>
                            </apex:variable>
                            <!-- //add by rentx 2020-11-27 start -->
@@ -931,38 +1439,92 @@
                            </apex:detail>
                            <!-- //add by rentx 2020-11-27 end -->
                        </tr>
                        <apex:repeat value="{!pageRecords}" var="records" id="ConsumableorderdetailsTable">
                        <apex:repeat
                            value="{!pageRecords}"
                            var="records"
                            id="ConsumableorderdetailsTable"
                        >
                            <tr class="dataRow">
                                <!-- update start by vivek 2019-7-15 -->
                                <!-- <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble,true,false)}" id="variableinfo"> -->
                                <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}" id="variableinfo">
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                                    id="variableinfo"
                                >
                                <!-- update end by vivek 2019-7-15 -->
                                    <td>
                                    <apex:inputCheckbox value="{!records.check}" id="consumablesCountproRowCheckbox" disabled="{!!records.canSelect}"/>
                                     <apex:inputCheckbox value="{!records.oldCheck}" id="proRowOldCheckbox" style="display:none"/></td>
                                        <apex:inputCheckbox
                                            value="{!records.check}"
                                            id="consumablesCountproRowCheckbox"
                                            disabled="{!!records.canSelect}"
                                        />
                                        <apex:inputCheckbox
                                            value="{!records.oldCheck}"
                                            id="proRowOldCheckbox"
                                            style="display: none"
                                        />
                                    </td>
                                 </apex:variable>
                                <td class="dataCell">
                                    <apex:outputText id="ProductName" value="{!IF(records.oldCheck=false,records.Prod.Name__c,records.orderdetails1.Consumable_Product__r.Name__c)}"/>
                                    <apex:outputText
                                        id="ProductName"
                                        value="{!IF(records.oldCheck=false,records.Prod.Name__c,records.orderdetails1.Consumable_Product__r.Name__c)}"
                                    />
                                </td>
                            <!--    <td>{!records.Prod.Asset_Model_No__c}</td>
                                 -->
                                <td style="width: 80px;text-align:center;">{!records.packinglist}</td>
                                <td class="dataCell">{!records.Prod.SFDA_Status__c}</td>
                                <td class="dataCell">{!records.approbation_No}</td>
                                <td style="width: 80px; text-align: center">
                                    {!records.packinglist}
                                </td>
                                <td class="dataCell">
                                    <apex:outputText value="{0, date, yyyy/MM/dd}">
                                        <apex:param value="{!records.expiration_Date}" />
                                    {!records.Prod.SFDA_Status__c}
                                </td>
                                <td class="dataCell">
                                    {!records.approbation_No}
                                </td>
                                <td class="dataCell">
                                    <apex:outputText
                                        value="{0, date, yyyy/MM/dd}"
                                    >
                                        <apex:param
                                            value="{!records.expiration_Date}"
                                        />
                                    </apex:outputText>
                                </td>
                                <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}" id="variableCategory3">
                                 <td class="dataCell">{!records.Prod.Category3__c}</td>
                                 <td class="dataCell">{!records.Prod.Category4__c}</td>
                                 <td class="dataCell">{!records.Prod.Category5__c}</td>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}" id="BoxPiece_UnEditout1">
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}"
                                    id="variableCategory3"
                                >
                                 <td class="dataCell">
                                    <apex:selectList value="{!records.orderdetails1.Box_Piece__c}" size="1" style="width:60px;" id="BoxPiece">
                                    <apex:selectOptions value="{!records.boxorpiece}"/>
                                        {!records.Prod.Category3__c}
                                    </td>
                                    <td class="dataCell">
                                        {!records.Prod.Category4__c}
                                    </td>
                                    <td class="dataCell">
                                        {!records.Prod.Category5__c}
                                    </td>
                                    <!-- update start by vivek 2019-7-15 -->
                                    <apex:variable
                                        var="v"
                                        value=""
                                        rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                                        id="BoxPiece_UnEditout1"
                                    >
                                        <td class="dataCell">
                                            <apex:selectList
                                                value="{!records.orderdetails1.Box_Piece__c}"
                                                size="1"
                                                style="width: 60px"
                                                id="BoxPiece"
                                            >
                                                <apex:selectOptions
                                                    value="{!records.boxorpiece}"
                                                />
                                    </apex:selectList>
                                </td>
                                </apex:variable>
@@ -970,62 +1532,183 @@
                                 </apex:variable>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}" id="BoxPiece_UnEditout1">
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}"
                                    id="BoxPiece_UnEditout1"
                                >
                                <!-- <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="BoxPiece_UnEditout"> -->
                                <!-- update end by vivek 2019-7-15 -->
                                <td><apex:outputField id="BoxPiece_UnEditin" value="{!records.orderdetails1.Box_Piece__c}"/></td>
                                    <td>
                                        <apex:outputField
                                            id="BoxPiece_UnEditin"
                                            value="{!records.orderdetails1.Box_Piece__c}"
                                        />
                                    </td>
                                </apex:variable>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}" id="consumablesCount_UnEditout">
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}"
                                    id="consumablesCount_UnEditout"
                                >
                                <!-- <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="consumablesCount_UnEditout"> -->
                                <!-- update start by vivek 2019-7-15 -->
                                <!--<td style="text-align:right;"><apex:outputField id="consumablesCount_Unagency" value="{!records.orderdetails1.Unitprice_To_agency__c}"/></td>-->
                                <td style="text-align:center;"><apex:outputField id="consumablesCount_UnEditin" value="{!records.orderdetails1.Shipment_Count__c}"/></td>
                                    <td style="text-align: center">
                                        <apex:outputField
                                            id="consumablesCount_UnEditin"
                                            value="{!records.orderdetails1.Shipment_Count__c}"
                                        />
                                    </td>
                                </apex:variable>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}" id="variable">
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                                    id="variable"
                                >
                                 <!-- <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}" id="variable"> -->
                                <!-- update end by vivek 2019-7-15 -->
                                <td class="dataCell">
                                    <div style="width:2px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div>
                                    <apex:inputField onblur="ComputePrice(this)" id="consumablesCount" value="{!records.orderdetails1.Shipment_Count__c}" style="width: 100px;" /></td>
                                        <div
                                            style="
                                                width: 2px;
                                                height: 20px;
                                                background-color: red;
                                                position: absolute;
                                                margin-right: 5px;
                                            "
                                        ></div>
                                        <apex:inputField
                                            onblur="ComputePrice(this)"
                                            id="consumablesCount"
                                            value="{!records.orderdetails1.Shipment_Count__c}"
                                            style="width: 100px"
                                        />
                                    </td>
                                 </apex:variable>
                                <apex:variable var="v" value="" rendered="{!EditAble}" id="variableMoneyinfo">
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!EditAble}"
                                    id="variableMoneyinfo"
                                >
                                    <td class="dataCell">
                                    <div style="width:2px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div>
                                    <apex:inputField onblur="ComputePriceCheck(this)" value="{!records.orderdetails1.Delivery_List_RMB__c}" style="width: 100px;" id="productOrderMoneyinfo"/>
                                        <div
                                            style="
                                                width: 2px;
                                                height: 20px;
                                                background-color: red;
                                                position: absolute;
                                                margin-right: 5px;
                                            "
                                        ></div>
                                        <apex:inputField
                                            onblur="ComputePriceCheck(this)"
                                            value="{!records.orderdetails1.Delivery_List_RMB__c}"
                                            style="width: 100px"
                                            id="productOrderMoneyinfo"
                                        />
                                    </td>
                                    <!-- <td class="dataCell">
                                    <apex:inputField id="Unitpriceagency" value="{!records.orderdetails1.Unitprice_To_agency__c}"  style="width: 100px;"/>
                                    </td> -->
                                </apex:variable>
                                <apex:variable var="v" value="" rendered="{!!EditAble}">
                                    <td class="dataCell" style="text-align:center;">
                                    <apex:outputText id="consumablesCountDealerPrice_Unedit" value="{!IF(records.orderdetails1.Delivery_List_RMB__c==null,0.00,records.orderdetails1.Delivery_List_RMB__c)}"/>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!!EditAble}"
                                >
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputText
                                            id="consumablesCountDealerPrice_Unedit"
                                            value="{!IF(records.orderdetails1.Delivery_List_RMB__c==null,0.00,records.orderdetails1.Delivery_List_RMB__c)}"
                                        />
                                    </td>
                                    <!-- <td style="text-align:center;"><apex:outputField id="consumablesCount_Unagency" value="{!records.orderdetails1.Unitprice_To_agency__c}"/></td> -->
                                </apex:variable>
                                <apex:variable var="v" value="" id="variableAllprice" rendered="{!EditAble}">
                                <td class="dataCell" style="text-align:center;">
                                    <apex:outputField id="consumablesCounttestPrice" value="{!records.orderdetails1.Shipment_amount__c}"/>
                                <apex:variable
                                    var="v"
                                    value=""
                                    id="variableAllprice"
                                    rendered="{!EditAble}"
                                >
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            id="consumablesCounttestPrice"
                                            value="{!records.orderdetails1.Shipment_amount__c}"
                                        />
                                </td>
                                <!--<td class="dataCell" style="text-align:right;width: 50px;">{!records.allnumber}</td>-->
                                <td class="dataCell" style="text-align:center;width: 50px;">{!records.Boxnumber}</td>
                                <td class="dataCell" style="text-align:center;width: 50px;">{!records.Piecenumber}</td>
                                    <td
                                        class="dataCell"
                                        style="text-align: center; width: 50px"
                                    >
                                        {!records.Boxnumber}
                                    </td>
                                    <td
                                        class="dataCell"
                                        style="text-align: center; width: 50px"
                                    >
                                        {!records.Piecenumber}
                                    </td>
                                </apex:variable>
                                <apex:variable var="v" value="" rendered="{!!EditAble}">
                                    <td class="dataCell" style="text-align:center;"><apex:outputField value="{!records.orderdetails1.InvoiceProNot_count__c}"/></td>
                                    <td class="dataCell" style="text-align:center;"><apex:outputField value="{!records.orderdetails1.RrturnPro_count__c}"/></td>
                                    <td class="dataCell" style="text-align:center;"><apex:outputField value="{!records.orderdetails1.Invoiced_Procount__c}"/></td>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!!EditAble}"
                                >
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            value="{!records.orderdetails1.InvoiceProNot_count__c}"
                                        />
                                    </td>
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            value="{!records.orderdetails1.RrturnPro_count__c}"
                                        />
                                    </td>
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            value="{!records.orderdetails1.Invoiced_Procount__c}"
                                        />
                                    </td>
                                </apex:variable>
                                    <!-- add by rentx 2020-11-26 start -->
                                <apex:detail rendered="{!hasHosPro}" >
                                    <td>
                                        <!-- <apex:outputField value="{!records.orderdetails2.hospitalSpecialOffer__c}"/> -->
                                        <apex:detail rendered="{!records.hospitalSpecialOffer}" >
                                            <apex:inputHidden value="{!records.hospitalSpecialOffer}"  id="hosOffer"/>
                                            <apex:inputHidden value="{!records.hosPro}"  id="hosPro"/>
                                        <apex:detail
                                            rendered="{!records.hospitalSpecialOffer}"
                                        >
                                            <apex:inputHidden
                                                value="{!records.hospitalSpecialOffer}"
                                                id="hosOffer"
                                            />
                                            <apex:inputHidden
                                                value="{!records.hosPro}"
                                                id="hosPro"
                                            />
                                            √
                                        </apex:detail>
                                    </td>
@@ -1039,8 +1722,10 @@
                            <td>
                                <!-- Page X of Y -->
                                <!-- PageNumber:当前页面所在位置,ResultSize:记录总条数,PageSize:每页记录条数 -->
                                <apex:outputText value="{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,
                                 (setCon.pageNumber * size))} 共 {!noOfRecords} 个" />
                                <apex:outputText
                                    value="{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,
                                 (setCon.pageNumber * size))} 共 {!noOfRecords} 个"
                                />
                                 <!--<apex:outputPanel >
                                    <apex:actionStatus id="fetchStatus" >
                                        <apex:facet name="start" >
@@ -1053,62 +1738,160 @@
                                <div class="paginator line1">
                                <span class="prevNextLinks">
                                <!-- 有连接 -->
                                <apex:outputPanel rendered="{!setCon.hasPrevious}">
                                        <apex:outputPanel
                                            rendered="{!setCon.hasPrevious}"
                                        >
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!setCon.first}" oncomplete="refreshPageSizeJs();" title="首页" >
                                <img src="/s.gif" title="首页" alt="首页" class="{!if((setCon.hasPrevious),'first','firstoff')}"/>
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.first}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="首页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="首页"
                                                        alt="首页"
                                                        class="{!if((setCon.hasPrevious),'first','firstoff')}"
                                                    />
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection"  action="{!setCon.previous}" oncomplete="refreshPageSizeJs();"  title="上一页">
                                <img src="/s.gif" title="上一页" alt="上一页" class="{!if((setCon.hasPrevious),'prev','prevoff')}"/>上一页
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.previous}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="上一页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="上一页"
                                                        alt="上一页"
                                                        class="{!if((setCon.hasPrevious),'prev','prevoff')}"
                                                    />上一页
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                <!-- 无连接 -->
                                <apex:outputPanel rendered="{!!setCon.hasPrevious}">
                                        <apex:outputPanel
                                            rendered="{!!setCon.hasPrevious}"
                                        >
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection" title="首页" >
                                <img src="/s.gif" title="首页" alt="首页" class="{!if((setCon.hasPrevious),'first','firstoff')}"/>
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="首页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="首页"
                                                        alt="首页"
                                                        class="{!if((setCon.hasPrevious),'first','firstoff')}"
                                                    />
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection"  title="上一页">
                                <img src="/s.gif" title="上一页" alt="上一页" class="{!if((setCon.hasPrevious),'prev','prevoff')}"/>上一页
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="上一页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="上一页"
                                                        alt="上一页"
                                                        class="{!if((setCon.hasPrevious),'prev','prevoff')}"
                                                    />上一页
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                <!-- 有连接 -->
                                <apex:outputPanel rendered="{!setCon.hasNext}">
                                <span class="prevNext" rendered = "{!!setCon.hasNext}">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!setCon.next}" oncomplete="refreshPageSizeJs();" title="下一页" rendered="{!setCon.hasNext}">下一页
                                <img src="/s.gif" title="下一页" alt="下一页" class="{!if((setCon.hasNext),'next','nextoff')}" />
                                        <apex:outputPanel
                                            rendered="{!setCon.hasNext}"
                                        >
                                            <span
                                                class="prevNext"
                                                rendered="{!!setCon.hasNext}"
                                            >
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.next}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="下一页"
                                                    rendered="{!setCon.hasNext}"
                                                    >下一页
                                                    <img
                                                        src="/s.gif"
                                                        title="下一页"
                                                        alt="下一页"
                                                        class="{!if((setCon.hasNext),'next','nextoff')}"
                                                    />
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!setCon.last}"  oncomplete="refreshPageSizeJs();" title="尾页">
                                <img src="/s.gif" title="尾页" alt="尾页" class="{!if((setCon.hasNext),'last','lastoff')}"/>
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.last}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="尾页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="尾页"
                                                        alt="尾页"
                                                        class="{!if((setCon.hasNext),'last','lastoff')}"
                                                    />
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                <!-- 无连接 -->
                                <apex:outputPanel rendered="{!!setCon.hasNext}">
                                <span class="prevNext" rendered = "{!setCon.hasNext}">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection"  title="下一页">下一页
                                <img src="/s.gif" title="下一页" alt="下一页" class="{!if((setCon.hasNext),'next','nextoff')}" />
                                        <apex:outputPanel
                                            rendered="{!!setCon.hasNext}"
                                        >
                                            <span
                                                class="prevNext"
                                                rendered="{!setCon.hasNext}"
                                            >
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="下一页"
                                                    >下一页
                                                    <img
                                                        src="/s.gif"
                                                        title="下一页"
                                                        alt="下一页"
                                                        class="{!if((setCon.hasNext),'next','nextoff')}"
                                                    />
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection" title="尾页">
                                <img src="/s.gif" title="尾页" alt="尾页" class="{!if((setCon.hasNext),'last','lastoff')}"/>
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="尾页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="尾页"
                                                        alt="尾页"
                                                        class="{!if((setCon.hasNext),'last','lastoff')}"
                                                    />
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                </span>
                                </div>
                             </td>
                             <td align="right" width="20%">
                            </td>
                            <td align="right" width="20%"></td>
                        </tr>
                    </table>
                    <!--
@@ -1138,47 +1921,85 @@
            </apex:panelGrid>-->
                </apex:pageBlock>
                <apex:pageBlock title="发票明细" rendered="{!IF((coc.Billed_Status__c !='还没开票') && IdCheck != null,true,false)}">
                     <apex:pageblocksection columns="1" id="consumableInvoiceRecordsSection">
                        <apex:pageblocktable value="{!consumableInvoiceRecords}" var="records" id="consumableInvoiceRecordsTable">
                <apex:pageBlock
                    title="发票明细"
                    rendered="{!IF((coc.Billed_Status__c !='还没开票') && IdCheck != null,true,false)}"
                >
                    <apex:pageblocksection
                        columns="1"
                        id="consumableInvoiceRecordsSection"
                    >
                        <apex:pageblocktable
                            value="{!consumableInvoiceRecords}"
                            var="records"
                            id="consumableInvoiceRecordsTable"
                        >
                             <apex:column width="80">
                                 <apex:facet name="header">发票号</apex:facet>
                                 <apex:outputField value="{!records.Name}"/>
                             </apex:column>
                              <apex:column width="80">
                                 <apex:facet name="header">发票日</apex:facet>
                                 <apex:outputField value="{!records.Invoice_Date__c}"/>
                                <apex:outputField
                                    value="{!records.Invoice_Date__c}"
                                />
                             </apex:column>
                             <apex:column width="80" style="text-align: center;">
                                 <apex:facet name="header">发票票面金额(元)</apex:facet>
                                 <apex:outputField value="{!records.Invoice_total_amount__c}"/>
                            <apex:column width="80" style="text-align: center">
                                <apex:facet name="header"
                                    >发票票面金额(元)</apex:facet
                                >
                                <apex:outputField
                                    value="{!records.Invoice_total_amount__c}"
                                />
                             </apex:column>
                             <apex:column width="80">
                                 <apex:facet name="header">发票状态</apex:facet>
                                 <apex:outputField value="{!records.Invoice_status__c}"/>
                                <apex:outputField
                                    value="{!records.Invoice_status__c}"
                                />
                             </apex:column>
                        </apex:pageblocktable>
                    </apex:pageblocksection>
                </apex:pageBlock>
                <apex:pageBlock title="出库产品明细" rendered="{!IF(consumableorderdetails2Count > 0,true,false)}">
                <apex:pageblocksection columns="1" id="Consumableorderdetails2Section">
                    <apex:pageblocktable value="{!consumableorderdetails2Records}" var="records" id="Consumableorderdetails2Table">
                <apex:pageBlock
                    title="出库产品明细"
                    rendered="{!IF(consumableorderdetails2Count > 0,true,false)}"
                >
                    <apex:pageblocksection
                        columns="1"
                        id="Consumableorderdetails2Section"
                    >
                        <apex:pageblocktable
                            value="{!consumableorderdetails2Records}"
                            var="records"
                            id="Consumableorderdetails2Table"
                        >
                         <apex:column width="80">
                             <apex:facet name="header">消耗品名称</apex:facet>
                             <apex:outputField value="{!records.Prod.name}"/>
                                <apex:facet name="header"
                                    >消耗品名称</apex:facet
                                >
                                <apex:outputField
                                    value="{!records.Prod.name}"
                                />
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">批次号</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.SerialLotNo__c}" />
                                <apex:outputField
                                    value="{!records.orderdetails2.SerialLotNo__c}"
                                />
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">管理编码</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.TracingCode__c}"/>
                                <apex:outputField
                                    value="{!records.orderdetails2.TracingCode__c}"
                                />
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">使用期限</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.Sterilization_limit__c}"/>
                                <apex:outputField
                                    value="{!records.orderdetails2.Sterilization_limit__c}"
                                />
                         </apex:column>
                        <!-- <apex:column width="80">
                             <apex:facet name="header">开票日</apex:facet>
@@ -1195,10 +2016,17 @@
            </apex:pageBlock>
            </apex:pageBlock>
        </apex:outputPanel>
        <apex:pageBlock title="附件" id="ConsumableConsumeSection" rendered="{!!editAble}">
        <apex:pageBlock
            title="附件"
            id="ConsumableConsumeSection"
            rendered="{!!editAble}"
        >
        <apex:pageBlockTable value="{!AttachmentRecoeds}" var="a" >
        <apex:column headerValue="标题" style="width: 33%">
        <apex:outputLink value="{!a.Concc.Id}" target="LINK_{!a.Concc.Id}">
                    <apex:outputLink
                        value="{!a.Concc.Id}"
                        target="LINK_{!a.Concc.Id}"
                    >
            {!a.Concc.name}
        </apex:outputLink>
        </apex:column>
@@ -1207,11 +2035,15 @@
        </apex:column>
        </apex:pageBlockTable>
        <apex:pageBlockButtons location="top" >
            <apex:commandButton onclick="FilesUaplodJs();" value="上传附件" style="margin-left:30px;width:100px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"/>
                <apex:commandButton
                    onclick="FilesUaplodJs();"
                    value="上传附件"
                    style="margin-left: 30px; width: 100px"
                    rerender="dummy"
                    rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                />
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
<script>
</script>
    <script></script>
</apex:page>
manifest/packageForSign.xml
@@ -9,6 +9,7 @@
        <members>DNUpsertBatchTest</members>
        <members>SyncProvinceWIndowToSignForm</members>
        <members>SyncProvinceWIndowToSignFormTest</members>
        <members>LexArriveGoodsController</members>
        <name>ApexClass</name>
    </types>
    <version>52.0</version>