高章伟
2023-03-07 fbac2ed0a87dad3180b3d22a9ed189437e4b7f19
force-app/main/default/classes/ArriveGoodsController.cls
@@ -15,7 +15,7 @@
    public List<Consumable_order_details2__c> consumableorderdetails2Insert= new List<Consumable_order_details2__c>();
    public List<Consumable_order_details2__c> consumableorderdetails2Nobox= new List<Consumable_order_details2__c>();
    public List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordserror { get; set; }
    public List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
    public transient List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
    public List<ConsumableorderdetailsInfo> ShowGoodsofReturnList{get;set;}
    public List<ConsumableorderdetailsInfo> ShowGoodsofRemoveBoxReturnList{get;set;}
    //add by rentx 20210602 CHAN-C3K4ZQ
@@ -34,15 +34,16 @@
        return ConsumableorderdetailsRecordserror.size();
    }
    Set<String> noboxBarcodeList = new Set<String>();
    Map<String, String> ExistIdMap = new Map<String, String>();
    Map<String, String> ErrorIdMap = new Map<String, String>();
    Map<String, String> AllMap = new Map<String, String>();
    public transient Map<String, String> ExistIdMap = new Map<String, String>();
    public transient Map<String, String> ErrorIdMap = new Map<String, String>();
    public transient Map<String, String> AllMap = new Map<String, String>();
    Map<String, String> otherAgencyMap = new Map<String, String>();
    Map<String, String> barMcodeMap = new Map<String, String>();
    public transient Map<String, String> barMcodeMap = new Map<String, String>();
    Map<String, Integer> BarcodeCntMap = new Map<String, Integer>();
    public List<String> BarCodeListP = new List<String>();
    //qi
    public transient List<String> BarCodeListP = new List<String>();
    Map<String, String> OrderAllMap = new Map<String, String>();
    // public transient Map<String, String> OrderAllMap = new Map<String, String>();
    Map<String, Decimal> orderProductCunMap = new Map<String, Decimal>();
    Map<String, Decimal> orderProductArrivedCunMap = new Map<String, Decimal>();
    Map<String, Decimal> orderWantArriveCunMap = new Map<String, Decimal>();
@@ -65,7 +66,7 @@
    list<String> exitBarCodeList = new list<String>();
    Map<String, Consumable_order_details2__c> reallMap = new Map<String, Consumable_order_details2__c>();
    // Map<String, Consumable_order_details2__c> reallMap = new Map<String, Consumable_order_details2__c>();
    Map<String,String> HosErrorMap = new Map<String,String>();
    List<String> HosErrorList = new List<String>();
    public String baseUrl {get;private set;}
@@ -108,36 +109,65 @@
        //add by rentx 20210602 CHAN-C3K4ZQ start 
        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
        //add by rentx 20210602 CHAN-C3K4ZQ end 
        // OrderAllMap = new Map<String, String>();
    }
    //add by rentx 20210602 CHAN-C3K4ZQ start 出错的原因是页面最多展示1000条数据,但是需要展示的数据超过了1000条,现在把展示上线改为2000
    //add by rentx 20210602 CHAN-C3K4ZQ start 出错的原因是页面最多展示1000条数据,但是需要展示的数据超过了1000条,现在把展示上线改为1000 * 1000
    public void makeRecordsView(List<ConsumableorderdetailsInfo> recordsdummy){
        //拆分暂用list
        List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
        List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
        ConsumableorderdetailsInfo c = null;
        ConsumableorderdetailsRecordsbreak.clear();
        ConsumableorderdetailsRecordsbreakover.clear();
        consumableorderdetailsRecordsview.clear();
        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
        if(recordsdummy.size() > 1000){
            for(Integer i = 0; i < recordsdummy.size(); i++){
                if(i < 1000){
                    c = recordsdummy.get(i);
                    ConsumableorderdetailsRecordsbreak.add(c);
                }else{
                    c = recordsdummy.get(i);
                    ConsumableorderdetailsRecordsbreakover.add(c);
            List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
            List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
            ConsumableorderdetailsInfo c = null;
            ConsumableorderdetailsRecordsbreak.clear();
            ConsumableorderdetailsRecordsbreakover.clear();
            consumableorderdetailsRecordsview.clear();
            //选择产品view
            ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
            ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
            if(recordsdummy.size() > 1000){
                for(Integer i = 0; i < recordsdummy.size(); i++){
                    if(i < 1000){
                        c = recordsdummy.get(i);
                        ConsumableorderdetailsRecordsbreak.add(c);
                    }else{
                        c = recordsdummy.get(i);
                        ConsumableorderdetailsRecordsbreakover.add(c);
                    }
                }
                consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreak);
                consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreakover);
            }else{
                consumableorderdetailsRecordsview.add(recordsdummy);
            }
            consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreak);
            consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreakover);
            // Integer count = recordsdummy.size() / 1000;
            // Integer last = recordsdummy.size() - (1000*count);
            // for(Integer i = 0; i < count ; i++){
            //     List<ConsumableorderdetailsInfo> tempList = new List<ConsumableorderdetailsInfo>();
            //     for(Integer j=0; j < 1000; j++){
            //         tempList.add(recordsdummy.get(i * count + j ));
            //         // itemList.add(resList.get(i*count+j));
            //     }
            //     consumableorderdetailsRecordsview.add(tempList);
            // }
            // if (last > 0) {
            //     List<ConsumableorderdetailsInfo> tempList = new List<ConsumableorderdetailsInfo>();
            //     for(Integer j=0; j < last; j++){
            //         tempList.add(recordsdummy.get(count * 1000 + j ));
            //         // itemList.add(resList.get(i*count+j));
            //     }
            //     consumableorderdetailsRecordsview.add(tempList);
            // }
        }else{
            consumableorderdetailsRecordsview.add(recordsdummy);
        }
    }
    //add by rentx 20210602 CHAN-C3K4ZQ end
    public void init() {
        // String userId = '00510000007cthP';
        String userId = UserInfo.getUserId();
        List<user> Useracc = New List<user>();
        Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:userId];
@@ -235,14 +265,16 @@
                        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);
                ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet1[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);
                }
            }
            //add by rentx 20210602 start CHAN-C3K4ZQ
            makeRecordsView(ConsumableorderdetailsRecordsdummy);
            // makeRecordsView(ConsumableorderdetailsRecordsdummy);
            //add by rentx 20210602 end CHAN-C3K4ZQ
        }
    }
@@ -264,7 +296,7 @@
               barMcodeMap.put(B,tracingCode);
            }
            outPut.add(B);
        }
        }system.debug('barMcodeMap等于'+barMcodeMap);
        return outPut;
    }
@@ -287,12 +319,15 @@
        noboxBarcodeList.clear();
        //再检索项目清空
        ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
        ErrorIdMap = new Map<String, String>();
        ErrorIdMap.clear();
        AllMap = new Map<String, String>();
        AllMap.clear();
        ExistIdMap = new Map<String, String>();
        ExistIdMap.clear();
        consumableorderdetails2Insert = new List<Consumable_order_details2__c>();
        ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
        if(EsetId != null && EsetId != ''){
        /*if(EsetId != null && EsetId != ''){
            List<Consumable_order_details2__c> reSet1 = [SELECT Id,
                            Name,
                            Intra_Trade_List_RMB__c,
@@ -316,10 +351,7 @@
                            Report_Product_Approbation__c,
                            Report_Product_Expiration__c
                            //add by rentx 2020-10-14 start
                           ,ContractNo_text__c/*,ContractNo__c1*/
                           // tcm start
                           ,Consumable_order_minor__r.ContractNo__c
                           // tcm end
                            ,ContractNo_text__c,/*ContractNo__c1*
                            //add by rentx 2020-10-14 end
                            ,hospitalSpecialOffer__c
                        FROM Consumable_order_details2__c
@@ -328,19 +360,22 @@
                        AND Arrive_Owner_Work_Location__c =: userWorkLocation
                        AND Dealer_Arrive__c = true ];
            for (Integer i = 0; i < reSet1.size(); i++) {
                OrderAllMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
                // OrderAllMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
                //add by rentx 2021-01-27
                reallMap.put(reSet1[i].Bar_Code__C, reSet1[i]);
                // reallMap.put(reSet1[i].Bar_Code__C, reSet1[i]);
                //add by rentx 2021-01-27
                ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet1[i]));
                //不需要展示已到货的明细 update by rentx 20210617 start 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);
                //}
            }
        }
        }*/
        ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
        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>();
@@ -351,7 +386,7 @@
            return;
        }
        //对比全部库存中是否存在管理编码一样,barcode号不一样的产品
        reSet1 = [SELECT Id,  Name,TracingCode__c,Bar_Code__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
@@ -385,7 +420,7 @@
                        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
                        TracingCode__c,Report_Product_Expiration__c
                    FROM Consumable_order_details2__c
                    WHERE Bar_Code__c in :BarCodeListP
                    AND Dealer_Info_text__c = :accountName
@@ -451,7 +486,7 @@
                                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
                                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
@@ -483,7 +518,7 @@
                                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
                                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
@@ -508,7 +543,7 @@
                                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
                                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
@@ -537,7 +572,7 @@
                                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
                                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
@@ -583,6 +618,7 @@
                                //add by rentx 2021-03-22 start
                                ,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
@@ -631,7 +667,8 @@
                                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
                                codsIns.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                                codsIns.Intra_Trade_List_RMB__c     =null;
                                codsIns.Intra_Trade_List_RMB__c     = reSet1[i].Intra_Trade_List_RMB__c;
                                //gzw 手动入库 默认产品单价 20230307
                                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;
@@ -661,8 +698,9 @@
                                //add by rentx 2020-10-13 end
                                //add by rentx 2021-03-22 start
                                if (reSet1[i].Lose_Flag__c == true){
                                    codsIns.exchangeOutPattern__c = reSet1[i].hospitalSpecialOffer__c;
                                // if (reSet1[i].Lose_Flag__c == true){
                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '互相调货'){
                                    codsIns.exchangeOutPattern__c = true;
                                }
                                //add by rentx 2021-03-22 end
@@ -685,7 +723,7 @@
                                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
                                Dealer_Info_text__c,Intra_Trade_List_RMB__c
                                // 更新借调信息 add by gzw 2020-0-415 start
                                // 首次入库经销商信息 add by gzw 2020-04-27 start
                                ,Agencyinfo_fromSAP__c,Frist_Storage_Agency__c 
@@ -698,7 +736,7 @@
                                //add by rentx 2020-10-13 end   互相调货时,借入方记录SAP合同号
                                ,hospitalSpecialOffer__c
                                ,exchangeOutPattern__c
                                ,Lose_Flag__c
                                ,Lose_Flag__c,Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = FALSE
                            AND  Dealer_Shipment__c= FALSE
@@ -747,7 +785,8 @@
                                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
                                codsIns.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                                codsIns.Intra_Trade_List_RMB__c     =null;
                                codsIns.Intra_Trade_List_RMB__c     = reSet1[i].Intra_Trade_List_RMB__c;
                                //gzw 手动入库 默认产品单价 20230307
                                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;
@@ -778,8 +817,9 @@
                                //add by rentx 2020-10-13 end   互相调货时,借入方记录SAP合同号
                                //add by rentx 2021-03-22 start
                                if (reSet1[i].Lose_Flag__c == true){
                                    codsIns.exchangeOutPattern__c = reSet1[i].hospitalSpecialOffer__c;
                                // if (reSet1[i].Lose_Flag__c == true){
                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '互相调货'){
                                    codsIns.exchangeOutPattern__c = true;
                                }
                                //add by rentx 2021-03-22 end
@@ -839,6 +879,7 @@
                            // tcm start
                            ,Consumable_order_minor__r.ContractNo__c
                            // tcm end
                            ,Report_Product_Expiration__c
                            //add by rentx 2020-10-14 end
                        FROM Consumable_order_details2__c
                        WHERE Dealer_Arrive__c = FALSE 
@@ -870,6 +911,7 @@
                                // tcm start
                                ,Consumable_order_minor__r.ContractNo__c
                                // tcm end
                                , Report_Product_Expiration__c
                                //add by rentx 2020-10-14 end
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = true
@@ -1075,8 +1117,17 @@
                        }
                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
                        for(String str : barMcodeMap.keySet()){
                            // BarCode不一致时的警告信息
                            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 +')的入库数据与发货数据不一致'));
                                // 20220815 ljh SWAG-CH65B7 end
                            }
                            if(barMcodeMap.get(str) == reSet[i].TracingCode__c){
                                reSet[i].Bar_Code__c = str;
                                //=====================================
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'入库BarCode('+ str +')和库存条码不一致。'));
                                ExistIdMap.put(str,str);
                            }
                        }
@@ -1088,7 +1139,7 @@
            // CHAN-BD43NK 关闭直接返品功能  追加 barcode不一致判断
            reSet1 = [SELECT Id,Name,TracingCode__c,Bar_Code__c,Sale_orderName__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
@@ -1170,7 +1221,7 @@
                                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
                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
                            FROM Consumable_order_details2__c
                            WHERE Dealer_Arrive__c = FALSE 
                            AND  Dealer_Shipment__c= FALSE
@@ -1197,7 +1248,7 @@
                                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
                                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
@@ -1222,7 +1273,7 @@
                                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
                                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
@@ -1247,7 +1298,7 @@
                                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
                                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
@@ -1275,7 +1326,7 @@
                                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
                                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
@@ -2669,11 +2720,15 @@
    //到货确认
    public PageReference ArriveGoodsConfim() {
        //add by rentx 20210618 start CHAN-C3K4ZQ 跳过不必要的查询
        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>();
        String resultcheck = '';
        List<String> resultcheckWithoutOrder = new List<String>();
        Savepoint sp = Database.setSavepoint();
        if(ConsumableorderdetailsRecords.size()<1 && consumableInventory.size()<1){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'不存在到货明细'));
            return null;
@@ -2714,7 +2769,6 @@
            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;
@@ -2746,11 +2800,14 @@
                // }
                insAfterDel.Name                        = consumable_order[0].Name + '-'+ str;
                insAfterDel.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                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;
                }
                // 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;
                // }
                insAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
                //gzw 手动入库 默认产品单价 20230307
                insAfterDel.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
                if(EsetId != null && EsetId != ''){
                    insAfterDel.Consumable_order_minor__c   = ESetId;
@@ -2784,7 +2841,7 @@
                // 追加首次入库经销商 add by gzw 2020-04-27 end
                arriveAmount += insAfterDel.Intra_Trade_List_RMB__c;
                //add by rentx 2020-10-14 strat
                // insAfterDel.ContractNo_text__c      = /*ass.esd.ContractNo__c*/;
                //insAfterDel.ContractNo_text__c      = /*ass.esd.ContractNo__c*/;
                // tcm start
                if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
                    insAfterDel.ContractNo_text__c= ass.esd.ContractNo_text__c;
@@ -2823,7 +2880,6 @@
            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------'));
@@ -2855,7 +2911,7 @@
                i++;
            }
            //return null;
            // return null;
            if(insertconsumableorderdetails2.size() >0){
                insert insertconsumableorderdetails2;
@@ -3016,6 +3072,8 @@
                            ,Consumable_order_minor__r.ContractNo__c
                            // tcm end
                            //add by rentx 2020-10-14 end
                            ,Report_Product_Expiration__c
                            ,Intra_Trade_List__c
                    FROM    Consumable_order_details2__c
                    WHERE   ((Dealer_Arrive__c = true
                            AND(  Dealer_Shipment__c = true
@@ -3124,7 +3182,10 @@
                             // tcm start
                             ,Consumable_order_minor__r.ContractNo__c
                             // tcm end
                            ,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
@@ -3326,7 +3387,8 @@
                                codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
                                codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
                                codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
                                codcorderdet.Intra_Trade_List_RMB__c     = codi.esd.Intra_Trade_List_RMB__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.RemoveBox_No__c             = codctmp.RemoveBox_No__c;
                                codcorderdet.RemoveBox_date__c           = codctmp.RemoveBox_date__c;
                                codcorderdet.Box_Piece__c                = codctmp.Box_Piece__c;
@@ -3408,7 +3470,8 @@
                        codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
                        codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
                        codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
                        codcorderdet.Intra_Trade_List_RMB__c     = codi.esd.Intra_Trade_List_RMB__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;
                        // WYIN-BLZE48盘点丢失产品增加入库方式 update by vivek 2020-03-05 start
                        if(hasLoseGoods){
                            codcorderdet.loseInventory__c = true;
@@ -3441,7 +3504,6 @@
                        codcList.add(   codi.esd    );
                    }
                }
                //明细2不存在的对应的到货订单明细 2017-07-05
                Integer i = 1;
                //for(ConsumableorderdetailsInfo ass : consumableInventoryUse){
@@ -3462,7 +3524,8 @@
                    //到货明细
                    codcorderdetail.Name                        = consumable_order_arr[0].Name + '-'+ str;
                    codcorderdetail.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
                    codcorderdetail.Intra_Trade_List_RMB__c     = null;
                    codcorderdetail.Intra_Trade_List_RMB__c     = ass.Prod.Intra_Trade_List_RMB__c;
                    //gzw 手动入库 默认产品单价 20230307
                    codcorderdetail.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
                    codcorderdetail.Direct_Arrive_Product__c    = true;
                    codcorderdetail.Sterilization_limit__c      = ass.sterilizationlimitDate;
@@ -3502,7 +3565,8 @@
                    
                    retorddetail.Name                        = consumable_order_ret[0].Name + '-'+ str;
                    retorddetail.RecordTypeId                = System.Label.RT_ConOrderDetail2_Return;
                    retorddetail.Intra_Trade_List_RMB__c     = null;
                    retorddetail.Intra_Trade_List_RMB__c     = ass.Prod.Intra_Trade_List_RMB__c;
                    //gzw 手动入库 默认产品单价 20230307
                    retorddetail.Dealer_Info_IF__c           = accountid;
                    retorddetail.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
                    retorddetail.Direct_Arrive_Product__c    = true;
@@ -3520,11 +3584,11 @@
                    //add by rentx 2020-10-14 start
                    // retorddetail.ContractNo_text__c         = /*ass.esd.ContractNo__c*/;
                    // tcm start
                    // if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
                    //     retorddetail.ContractNo_text__c= ass.esd.ContractNo_text__c;
                    // }else {
                     if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
                        retorddetail.ContractNo_text__c= ass.esd.ContractNo_text__c;
                     }else {
                        retorddetail.ContractNo_text__c= ass.esd.Consumable_order_minor__r.ContractNo__c;
                    // }
                     }
                    // tcm end
                    //add by rentx 2020-10-14 end
@@ -3618,7 +3682,10 @@
            }
        }catch(Exception e){
            //Database.rollback(sp);
            ApexPages.addMessages(e);
            throw new ControllerUtil.myException('e::'+e + '  linenumber::'+e.getLineNumber());
            // ApexPages.addMessages(e);
            // ApexPages.addMessages(e.getLineNumber() + '  11111111111111111');
            //return null;
        }
    }
@@ -3661,12 +3728,18 @@
        public Integer intMark { get; set; }
        public Decimal arriveAmount { get; set; }
        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;
@@ -3678,6 +3751,10 @@
            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) {
@@ -3702,6 +3779,10 @@
            }
            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;