buli
2023-07-11 80a3f59e2d3df07805bc67e329300b8de90a5b3a
force-app/main/default/classes/LexCancelRemoveBoxController.cls
@@ -11,7 +11,7 @@
    public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
    public static boolean saveFLGbln {get;set;}
    //错误信息
    public static String alertMessage {set;get;}
    public static String alertMessage { get; set; }
    //拆盒明细件数
    public static Integer getinventorysize(){
        return ConsumableorderdetailsRecordsdummy.size();
@@ -21,7 +21,7 @@
    public static Map<String, String> AllMap = new Map<String, String>();
    public static  List<String> BarCodeListP = new List<String>();
    //不符合的barcode和型号
    public static list<String> notInlist = new list<String>();
    public static list<String> notInlist = new List<String>();
    public static  String baseUrl {get;private set;}
    private static String accountid = null;
    private static String accountName = null;
@@ -34,7 +34,7 @@
        ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
        ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
        consumableInventory = new List<ConsumableorderdetailsInfo>();
        saveFLGbln = FALSE;
        saveFLGbln = false;
    }
    @AuraEnabled
@@ -44,8 +44,12 @@
        res.entity = data;
        String userId = UserInfo.getUserId();
        List<user> Useracc = New List<user>();
        Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:userId];
        List<user> Useracc = new List<user>();
        Useracc = [
            SELECT accountid, Work_Location__c, UserPro_Type__c
            FROM user
            WHERE id = :userId
        ];
        accountid = Useracc[0].accountid;
        userWorkLocation = Useracc[0].Work_Location__c;
        agencyProType = Useracc[0].UserPro_Type__c;
@@ -53,7 +57,11 @@
            agencyProType = 'ET';
        }
        userPro_Typestr = '%' + agencyProType + '%';
        List<account> accountInfo = [SELECT Name FROM account WHERE id =:accountid];
        List<account> accountInfo = [
            SELECT Name
            FROM account
            WHERE id = :accountid
        ];
        //String view_product = accountInfo[0].view_product__c;
        accountName = accountInfo[0].Name;
        //proidList = view_product.split(',');
@@ -64,12 +72,11 @@
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    // 将页面或取得BarCode去掉重复的,转换成List
    public static 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){
@@ -85,7 +92,12 @@
    //获取明细
    @AuraEnabled
    public static ResponseBodyLWC searchConsumableorderdetails(String barcode,String accountName,String userWorkLocation,String agencyProType) {
    public static ResponseBodyLWC searchConsumableorderdetails(
        String barcode,
        String accountName,
        String userWorkLocation,
        String agencyProType
    ) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String,object> data = new Map<String,object>();
        res.entity = data;
@@ -97,15 +109,13 @@
        ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
        ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
        notInlist = new list<String>();
        notInlist = 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>();
        saveFLGbln = FALSE;
        saveFLGbln = false;
        alertMessage='';
        //判断barcode是否为空
@@ -122,22 +132,37 @@
        // ConsumableorderdetailsRecordsdummy.clear();
        // 产品类型不同
        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,Product_Type__c,
                        Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                        recordtypeid,Consumable_order_minor__r.Arrive_Order__c, Arrive_Owner_Work_Location__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,
                Product_Type__c,
                Arrive_date__c,
                Send_Date__c,
                Consumable_order_minor__r.Name,
                Consumable_order_minor__c,
                recordtypeid,
                Consumable_order_minor__r.Arrive_Order__c,
                Arrive_Owner_Work_Location__c,
                        //add by rentx 2020-10-13 start
                        ContractNo_text__c
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    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
                    AND   Arrive_Owner_Work_Location__c = : userWorkLocation
                    AND (not Product_Type__c like : userPro_Typestr)
                    ORDER BY Name ];
                AND (NOT Product_Type__c LIKE :userPro_Typestr)
            ORDER BY Name
        ];
        if(reSet1.size() > 0){
            for (Integer i = 0; i < reSet1.size(); i++) {
                if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
@@ -152,26 +177,39 @@
        }
        //没有拆盒
        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,
                        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,
                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-13 start
                        ContractNo_text__c
                         /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    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
            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  Box_Piece__c = '盒'
                    //AND  ProductPacking_list_manual__c > 1
                    AND  Bar_Code__c in :BarCodeListP
                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)){
@@ -186,25 +224,38 @@
        }
        //已出货,未到货
        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,
                        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,
                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-13 start
                        ContractNo_text__c
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 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  Lose_Flag__c = false
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                    AND  Box_Piece__c = '盒'
                    AND   Bar_Code__c in :BarCodeListP
                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)){
@@ -219,25 +270,38 @@
        }
        //拆盒已出货
        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,
                        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,
                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-13 start
                        ContractNo_text__c
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    FROM Consumable_order_details2__c
                    WHERE Dealer_Shipment__c = true
                    AND   Dealer_Arrive__c = true
                    AND   Dealer_Returned__c = false
                    AND   Lose_Flag__c = false
            WHERE
                Dealer_Shipment__c = TRUE
                AND Dealer_Arrive__c = TRUE
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                    AND   Box_Piece__c = '个'
                    AND   RemoveBox_date__c != null
                    AND   Bar_Code__c in :BarCodeListP
                AND RemoveBox_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)){
@@ -252,25 +316,38 @@
        }
        //拆盒已销售
        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,
                        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,
                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-13 start
                        ContractNo_text__c
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    FROM Consumable_order_details2__c
                    WHERE Dealer_Saled__c = true
                    AND   Dealer_Arrive__c = true
                    AND   Dealer_Returned__c = false
                    AND   Lose_Flag__c = false
            WHERE
                Dealer_Saled__c = TRUE
                AND Dealer_Arrive__c = TRUE
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                    AND   Box_Piece__c = '个'
                    AND   RemoveBox_date__c != null
                    AND   Bar_Code__c in :BarCodeListP
                AND RemoveBox_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)){
@@ -285,23 +362,36 @@
        }
        //拆盒返品
        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,
                        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,
                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-13 start
                        ContractNo_text__c
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    FROM Consumable_order_details2__c
                    WHERE Dealer_Returned__c = true
                    AND   Return_date__c != null
            WHERE
                Dealer_Returned__c = TRUE
                AND Return_date__c != NULL
                    AND   Box_Piece__c = '个'
                    AND   RemoveBox_date__c != null
                    AND   Bar_Code__c in :BarCodeListP
                AND RemoveBox_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)){
@@ -315,24 +405,36 @@
            }
        }
        //拆盒后盘点过(盘点日期不为空)
        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,
                        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,
                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-13 start
                        ContractNo_text__c
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    FROM Consumable_order_details2__c
                    WHERE Inventory_date__c != null
            WHERE
                Inventory_date__c != NULL
                    AND   Box_Piece__c = '个'
                    AND   RemoveBox_date__c != null
                    AND   Bar_Code__c in :BarCodeListP
                AND RemoveBox_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)){
@@ -347,21 +449,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,
                        Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
                        recordtypeid,Consumable_order_minor__r.Arrive_Order__c, Arrive_Owner_Work_Location__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,
                Arrive_date__c,
                Send_Date__c,
                Consumable_order_minor__r.Name,
                Consumable_order_minor__c,
                recordtypeid,
                Consumable_order_minor__r.Arrive_Order__c,
                Arrive_Owner_Work_Location__c,
                        //add by rentx 2020-10-13 start
                        ContractNo_text__c
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    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
                    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)){
@@ -375,7 +491,9 @@
            }
        }
        reSet = [SELECT Id,
        reSet = [
            SELECT
                Id,
                        Name,
                        Intra_Trade_List_RMB__c,
                        Asset_Model_No__c,
@@ -400,29 +518,28 @@
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    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
            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 Box_Piece__c = '个'
                    AND RemoveBox_date__c != null
                    AND Bar_Code__c in :BarCodeListP
                AND RemoveBox_date__c != NULL
                AND Bar_Code__c IN :BarCodeListP
                    AND Dealer_Info_text__c = :accountName 
                    AND Arrive_Owner_Work_Location__c =: userWorkLocation
                    AND  Product_Type__c like : userPro_Typestr
                AND Product_Type__c LIKE :userPro_Typestr
                ];
        if(reSet.size()>0){
            for (Integer i = 0; i < reSet.size(); i++) {
                if(ErrorIdMap.containsKey(reSet[i].Bar_Code__c) ){
                    // 跳过错误的消耗品明细
                    continue;
                }
                else if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) ){
                } else if (ExistIdMap.containsKey(reSet[i].Bar_Code__c)) {
                    // 跳过已经处理的消耗品明细
                    continue;
                }
                else{
                } else {
                    ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
                    ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
                }
@@ -452,12 +569,16 @@
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    //取消拆盒确认
    @AuraEnabled
    public static ResponseBodyLWC cancelRemoveBoxConfirm(String saveConsumableorderdetailsRecordsdummy,String accountName,String userWorkLocation,String agencyProType) {
    public static ResponseBodyLWC cancelRemoveBoxConfirm(
        String saveConsumableorderdetailsRecordsdummy,
        String accountName,
        String userWorkLocation,
        String agencyProType
    ) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String,object> data = new Map<String,object>();
        res.entity = data;
@@ -465,10 +586,12 @@
        userPro_Typestr = '%' + agencyProType + '%';
        accountName = accountName;
        userWorkLocation =userWorkLocation;
        List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy = (List<ConsumableorderdetailsInfo>)JSON.deserialize(saveConsumableorderdetailsRecordsdummy,List<ConsumableorderdetailsInfo>.class);
        List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
            saveConsumableorderdetailsRecordsdummy,
            List<ConsumableorderdetailsInfo>.class
        );
        List<Consumable_order_details2__c> ins = New List<Consumable_order_details2__c>();
        List<Consumable_order_details2__c> ins = new List<Consumable_order_details2__c>();
        
        Savepoint sp = Database.setSavepoint();
        if(ConsumableorderdetailsRecordsdummy.size()<1){
@@ -484,7 +607,8 @@
        try{
            //取得通番大于001的在库明细
            List<Consumable_order_details2__c> orderDetails2del =  [SELECT
            List<Consumable_order_details2__c> orderDetails2del = [
                SELECT
                        Id,
                        Box_Piece__c,
                        RemoveBox_date__c,
@@ -495,18 +619,19 @@
                        /*,ContractNo__c*/
                        //add by rentx 2020-10-13 end
                    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
                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 Box_Piece__c = '个'
                    AND RemoveBox_date__c != null
                    AND RemoveBox_date__c != NULL
                    AND RemoveBox_No__c > 1
                    AND Bar_Code__c in :BarCodeList
                    AND Bar_Code__c IN :BarCodeList
                    AND Dealer_Info_text__c = :accountName 
                    AND Arrive_Owner_Work_Location__c =: userWorkLocation
                    AND  Product_Type__c like : userPro_Typestr
                    AND Product_Type__c LIKE :userPro_Typestr
                ];
            List<Consumable_order_details2__c> orderlistdel = new List<Consumable_order_details2__c>();
@@ -522,32 +647,34 @@
            }
            //取得通番001的在库明细
            List<Consumable_order_details2__c> orderDetails2 =  [SELECT
            List<Consumable_order_details2__c> orderDetails2 = [
                SELECT
                        Id,
                        Box_Piece__c,
                        RemoveBox_date__c,
                        RemoveBox_No__c,
                        Bar_Code__c,
                        //add by rentx 2020-10-13 start
                        ContractNo_text__c
                    ContractNo_text__c,
                        /*,ContractNo__c*/
                        //add by rebtx 2020-10-13 end
                    // tcm start
                    ,Consumable_order_minor__r.ContractNo__c
                    Consumable_order_minor__r.ContractNo__c
                    // tcm end
                    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
                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 Box_Piece__c = '个'
                    AND RemoveBox_date__c !=null
                    AND RemoveBox_date__c != NULL
                    AND RemoveBox_No__c = 1
                    AND Bar_Code__c in :BarCodeList
                    AND Bar_Code__c IN :BarCodeList
                    AND Dealer_Info_text__c = :accountName 
                    AND Arrive_Owner_Work_Location__c =: userWorkLocation
                    AND  Product_Type__c like : userPro_Typestr
                    AND Product_Type__c LIKE :userPro_Typestr
                ];
            for (Consumable_order_details2__c detail2tmp : orderDetails2) {
@@ -594,7 +721,7 @@
        }
    }
    @TestVisible
    class ConsumableorderdetailsInfo implements Comparable {
        public Consumable_order_details2__c esd { get; set; }
        public Product2__c Prod { get; set; }