From 80a3f59e2d3df07805bc67e329300b8de90a5b3a Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 11 七月 2023 14:13:08 +0800
Subject: [PATCH] Merge branch 'LEXCommunityLiJun' into LEXUpgrade2023-Deloitte

---
 force-app/main/default/classes/ArriveGoodsController.cls | 5071 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 2,938 insertions(+), 2,133 deletions(-)

diff --git a/force-app/main/default/classes/ArriveGoodsController.cls b/force-app/main/default/classes/ArriveGoodsController.cls
index 256f301..6371001 100644
--- a/force-app/main/default/classes/ArriveGoodsController.cls
+++ b/force-app/main/default/classes/ArriveGoodsController.cls
@@ -10,14 +10,14 @@
     //鏇存柊鏄庣粏鍙栨秷鏃堕棿
     public List<Consumable_order_details2__c> consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
     // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-    Map<String,Consumable_order_details2__c> orderdetails2trMap = new Map<String,Consumable_order_details2__c>();
+    Map<String, Consumable_order_details2__c> orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
     // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-    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<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 transient List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
-    public List<ConsumableorderdetailsInfo> ShowGoodsofReturnList{get;set;}
-    public List<ConsumableorderdetailsInfo> ShowGoodsofRemoveBoxReturnList{get;set;}
+    public List<ConsumableorderdetailsInfo> ShowGoodsofReturnList { get; set; }
+    public List<ConsumableorderdetailsInfo> ShowGoodsofRemoveBoxReturnList { get; set; }
     //add by rentx 20210602 CHAN-C3K4ZQ
     public List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview { get; set; }
     //add by rentx 20210602 CHAN-C3K4ZQ
@@ -26,11 +26,11 @@
     //瓒呭嚭瀹氳揣鏁伴噺鐨勪骇鍝�
     public List<String> cancellationProList = new List<String>();
     //閿欒淇℃伅
-    public String alertMessage {set;get;}
-    public integer getinventorysize(){
+    public String alertMessage { get; set; }
+    public integer getinventorysize() {
         return consumableInventory.size();
     }
-    public integer geterrorsize(){
+    public integer geterrorsize() {
         return ConsumableorderdetailsRecordserror.size();
     }
     Set<String> noboxBarcodeList = new Set<String>();
@@ -51,25 +51,24 @@
     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>();
     //涓嶉�夋嫨璁㈠崟鏃朵繚瀛樿鍗旾D銆佷骇鍝佸瀷鍙风敤
     //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>();
+    Map<String, String> HosErrorMap = new Map<String, String>();
     List<String> HosErrorList = new List<String>();
-    public String baseUrl {get;private set;}
+    public String baseUrl { get; private set; }
     public String ESetId { get; set; }
     public String arriveId = '';
     private String accountid = null;
@@ -79,9 +78,9 @@
     public Decimal orderCountNotarrive = 0;
     private id return_Order_id = null;
     private id inventory_Order_id = null;
-    public boolean ReturnFLGbln {get;set;}
-    public boolean saveFLGbln {get;set;}
-    public String ArrType{get;set;}
+    public boolean ReturnFLGbln { get; set; }
+    public boolean saveFLGbln { get; set; }
+    public String ArrType { get; set; }
     // 鐧诲綍鑰呭伐浣滃湴
     private String userWorkLocation;
 
@@ -91,7 +90,7 @@
     public String product_Type = null;
     public Boolean EngFlag = false;
     public Boolean ETFlag = false;
-    public ArriveGoodsController(){
+    public ArriveGoodsController() {
         baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
         ESetId = ApexPages.currentPage().getParameters().get('esetId');
         ArrType = ApexPages.currentPage().getParameters().get('ArrType');
@@ -102,21 +101,21 @@
         consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
         consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
         consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
-        orderdetails2trMap = new Map<String,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 
+        //add by rentx 20210602 CHAN-C3K4ZQ start
         consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
-        //add by rentx 20210602 CHAN-C3K4ZQ end 
+        //add by rentx 20210602 CHAN-C3K4ZQ end
         // OrderAllMap = new Map<String, String>();
     }
 
     //add by rentx 20210602 CHAN-C3K4ZQ start 鍑洪敊鐨勫師鍥犳槸椤甸潰鏈�澶氬睍绀�1000鏉℃暟鎹�,浣嗘槸闇�瑕佸睍绀虹殑鏁版嵁瓒呰繃浜�1000鏉�,鐜板湪鎶婂睍绀轰笂绾挎敼涓�1000 * 1000
-    public void makeRecordsView(List<ConsumableorderdetailsInfo> recordsdummy){
+    public void makeRecordsView(List<ConsumableorderdetailsInfo> recordsdummy) {
         consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
 
-        if(recordsdummy.size() > 1000){
+        if (recordsdummy.size() > 1000) {
             List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
             List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
             ConsumableorderdetailsInfo c = null;
@@ -126,24 +125,24 @@
             //閫夋嫨浜у搧view
             ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
             ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
-            if(recordsdummy.size() > 1000){
-                for(Integer i = 0; i < recordsdummy.size(); i++){
-                    if(i < 1000){
+            if (recordsdummy.size() > 1000) {
+                for (Integer i = 0; i < recordsdummy.size(); i++) {
+                    if (i < 1000) {
                         c = recordsdummy.get(i);
                         ConsumableorderdetailsRecordsbreak.add(c);
-                    }else{
+                    } else {
                         c = recordsdummy.get(i);
                         ConsumableorderdetailsRecordsbreakover.add(c);
                     }
                 }
                 consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreak);
                 consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreakover);
-            }else{
+            } else {
                 consumableorderdetailsRecordsview.add(recordsdummy);
             }
 
-      // Integer count = recordsdummy.size() / 1000;
-      // Integer last = recordsdummy.size() - (1000*count);
+            // Integer count = recordsdummy.size() / 1000;
+            // Integer last = recordsdummy.size() - (1000*count);
 
             // for(Integer i = 0; i < count ; i++){
             //     List<ConsumableorderdetailsInfo> tempList = new List<ConsumableorderdetailsInfo>();
@@ -161,7 +160,7 @@
             //     }
             //     consumableorderdetailsRecordsview.add(tempList);
             // }
-        }else{
+        } else {
             consumableorderdetailsRecordsview.add(recordsdummy);
         }
     }
@@ -169,108 +168,128 @@
     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];
+        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-------------
         userPro_Type = Useracc[0].UserPro_Type__c;
-        if(String.isBlank(userPro_Type)){
+        if (String.isBlank(userPro_Type)) {
             userPro_Type = 'ET';
         }
 
-        if(userPro_Type == 'ENG'){
+        if (userPro_Type == 'ENG') {
             product_Type = 'ET';
             EngFlag = true;
-        }else{
+        } else {
             product_Type = 'ENG';
             ETFlag = true;
         }
         userPro_Typestr = '%' + userPro_Type + '%';
         //--------AddEnd-----XHL--------------20181008-------------
         userWorkLocation = Useracc[0].Work_Location__c;
-        system.debug('userWorkLocation'+ userWorkLocation);
-        List<account> accountInfo = [SELECT Name FROM account WHERE id =:accountid];
+        system.debug('userWorkLocation' + userWorkLocation);
+        List<account> accountInfo = [SELECT Name FROM account WHERE id = :accountid];
         accountName = accountInfo[0].Name;
-        system.debug('accountName'+ accountName);
+        system.debug('accountName' + accountName);
         coc = new Consumable_order__c();
-        if(ArrType=='ReG'){
+        if (ArrType == 'ReG') {
             ReturnFLGbln = true;
-        }else{
+        } 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){
+        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];
+            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);
+                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);
                 //overOrderCunMap.put(reSet[i].Asset_Model_No__c,0);
             }
             //
-            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
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c1*/
-                            // tcm start
-                            ,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 Arrive_Owner_Work_Location__c = : userWorkLocation
-                        AND Consumable_order_minor__c = :ESetId
-                        AND Dealer_Arrive__c = true
-                        AND Box_Piece__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,
+                    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,
+                    //add by rentx 2020-10-14 start
+                    ContractNo_text__c /*,ContractNo__c1*/,
+                    // tcm start
+                    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 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++) {
                 // 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);
+                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
@@ -281,53 +300,53 @@
     //========20160311======ADD_Start================================
     // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
     //========20160311======ADD_Start================================
-    public List<String> ParseBarCode(String Code){
-        String[] Cache = new String[]{};
+    public List<String> ParseBarCode(String Code) {
+        String[] Cache = new List<String>{};
         Cache = Code.split('\n');
-        Set <String> Buff = new Set<String>();
-        for(String A : Cache){
+        Set<String> Buff = new Set<String>();
+        for (String A : Cache) {
             Buff.add(A.toUpperCase());
         }
         List<String> outPut = new List<String>();
-        for(String B :Buff){
+        for (String B : Buff) {
             B = B.trim();
-            if(B.length() > 8){
-               String tracingCode = B.substring(B.length() - 5,B.length());
-               barMcodeMap.put(B,tracingCode);
+            if (B.length() > 8) {
+                String tracingCode = B.substring(B.length() - 5, B.length());
+                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>();
         consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
         consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
-        orderdetails2trMap = new Map<String,Consumable_order_details2__c>();
+        orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
         //add by rentx 2021-01-27 start
         HosErrorList = new List<String>();
-        HosErrorMap = new Map<String,String>();
+        HosErrorMap = new Map<String, String>();
         //add by rentx 2021-01-27 end
 
-    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 != ''){
+        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 != ''){
             List<Consumable_order_details2__c> reSet1 = [SELECT Id,
                             Name,
                             Intra_Trade_List_RMB__c,
@@ -378,334 +397,467 @@
         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() ==''){
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'璇疯緭鍏arCode鍙枫��'));
+        if (barcode == null || barcode.trim() == '') {
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '璇疯緭鍏arCode鍙枫��'));
             return;
         }
         //瀵规瘮鍏ㄩ儴搴撳瓨涓槸鍚﹀瓨鍦ㄧ鐞嗙紪鐮佷竴鏍凤紝barcode鍙蜂笉涓�鏍风殑浜у搧
-        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()
-                    AND Dealer_Info_text__c = :accountName
-                    AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                    ORDER BY Name ];
-        if(reSet1.size()>0){
+        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()
+                AND Dealer_Info_text__c = :accountName
+                AND Arrive_Owner_Work_Location__c = :userWorkLocation
+            ORDER BY Name
+        ];
+        if (reSet1.size() > 0) {
             for (Integer i = 0; i < reSet1.size(); i++) {
-                if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                     // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                     continue;
-                }else{
-                    for(String str : barMcodeMap.keySet()){
-                        if(barMcodeMap.get(str) == reSet1[i].TracingCode__c){
-                            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);
+                } else {
+                    for (String str : barMcodeMap.keySet()) {
+                        if (barMcodeMap.get(str) == reSet1[i].TracingCode__c) {
+                            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);
                         }
                     }
                 }
             }
         }
         //绠$悊缂栫爜涓虹┖鐨勪骇鍝�
-        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
-                    AND Dealer_Info_text__c = :accountName
-                    //AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                    AND (TracingCode__c = null
-                         OR TracingCode__c = '')
-                    ORDER BY Name ];
+        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
+                AND Dealer_Info_text__c = :accountName
+                //AND Arrive_Owner_Work_Location__c =: userWorkLocation
+                AND (TracingCode__c = NULL
+                OR TracingCode__c = '')
+            ORDER BY Name
+        ];
 
-        if(reSet1.size()>0){
+        if (reSet1.size() > 0) {
             for (Integer i = 0; i < reSet1.size(); i++) {
-                if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                     // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                     continue;
-                }else{
+                } else {
                     String str = '璇ヤ骇鍝佹病鏈夌鐞嗙紪鐮侊紝鏃犳硶鍏ュ簱';
-                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                    ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
+                    ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
                 }
             }
         }
         //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '绠$悊缂栫爜涓虹┖鐨勪骇鍝� ' + ErrorIdMap));
         //鏁翠綋鍒拌揣
-        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*/
-                                // tcm start
-                                ,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)
+        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*/,
+                        // tcm start
+                        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)
                         AND Dealer_Info_text__c = :accountName
-                        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 ];
+                        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
+                ];
 
-                if(reSet1.size()>0){
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
-                            String str = '浜у搧绫诲瀷['+reSet1[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                        } else {
+                            String str = '浜у搧绫诲瀷[' + reSet1[i].Product_Type__c + ']涓庣敤鎴风殑绫诲瀷[' + userPro_Type + ']涓嶇';
+                            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,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
-                            AND Dealer_Info_text__c = :accountName
-                            AND (Arrive_Owner_Work_Location__c =: userWorkLocation
-                                OR OwnerId = :System.Label.User_OlympusSystem)
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
+                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
+                        AND Dealer_Info_text__c = :accountName
+                        AND (Arrive_Owner_Work_Location__c = :userWorkLocation
+                        OR OwnerId = :System.Label.User_OlympusSystem)
+                    ORDER BY Name
+                ];
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
+                        } else {
                             String str = '';
                             if (reSet1[i].OwnerId == System.Label.User_OlympusSystem) {
                                 str = '璇ュ晢鍝佹槸鐩撮攢浜у搧璇峰厛杩斿搧';
-                            }else{
+                            } else {
                                 str = '璇ュ晢鍝佸凡缁忛攢鍞�';
                             }
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                            
+                            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
-                            FROM Consumable_order_details2__c
-                            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 ];
-                if(reSet1.size()>0){
+                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
+                        AND Dealer_Info_text__c = :accountName
+                        AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                    ORDER BY Name
+                ];
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
+                        } else {
                             String str = '璇ュ晢鍝佸凡缁忓嚭搴�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                            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,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
-                            AND Dealer_Info_text__c = :accountName
-                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
+                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
+                        AND Dealer_Info_text__c = :accountName
+                        AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                    ORDER BY Name
+                ];
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
+                        } 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));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                            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 
-                            FROM Consumable_order_details2__c
-                            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 ];
-                if(reSet1.size()>0){
+                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
+                        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
+                ];
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
+                        } else {
                             String str = '宸叉媶鐩掔殑浜у搧涓嶈兘鍏ュ簱';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                            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,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
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
-                                ,Agencyinfo_fromSAP__c,Frist_Storage_Agency__c 
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
+                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,
+                        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                        // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
+                        Agencyinfo_fromSAP__c,
+                        Frist_Storage_Agency__c,
+                        // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
 
-                                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-                                ,ContractNo_text__c/*,ContractNo__c */
-                                // tcm start
-                                ,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
-                                //add by rentx 2021-03-22 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  Cancellation_Flag__c = FALSE
-                            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)
-                            )
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                            order by Bar_Code__c, Transfer_Time__c desc
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                            ];
-                if(reSet1.size()>0){
+                        //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+                        ContractNo_text__c /*,ContractNo__c */,
+                        // tcm start
+                        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
+                    //add by rentx 2021-03-22 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 Cancellation_Flag__c = FALSE
+                        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))
+                    // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                    ORDER BY Bar_Code__c, Transfer_Time__c DESC
+                    // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+                ];
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
-                            if(otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)){
+                        } else {
+                            if (otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)) {
                                 continue;
-                            }else{
+                            } else {
                                 //鍏朵粬缁忛攢鍟嗗嚭搴撲骇鍝佸彲浠ュ叆搴�
                                 List<String> barcodedetList = new List<String>();
                                 barcodedetList.add(reSet1[i].Bar_Code__c);
                                 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
-                                consumableInventory.add(new ConsumableorderdetailsInfo(reSet1[i],barcodedetList));
+                                consumableInventory.add(new ConsumableorderdetailsInfo(reSet1[i], barcodedetList));
                                 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;
+                                codsIns.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+                                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;
-                                codsIns.Consumable_Product__c       = reSet1[i].Consumable_Product__c;
-                                codsIns.Bar_Code__c                 = reSet1[i].Bar_Code__c;
-                                codsIns.SerialLotNo__c              = reSet1[i].SerialLotNo__c;
-                                codsIns.TracingCode__c              = reSet1[i].TracingCode__c;
+                                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;
+                                codsIns.Consumable_Product__c = reSet1[i].Consumable_Product__c;
+                                codsIns.Bar_Code__c = reSet1[i].Bar_Code__c;
+                                codsIns.SerialLotNo__c = reSet1[i].SerialLotNo__c;
+                                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.Agency_Transfer__c          = true;
+                                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.Agency_Transfer__c = true;
                                 // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                                 
+
                                 // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                                codsIns.Agencyinfo_fromSAP__c       = reSet1[i].Agencyinfo_fromSAP__c;
-                                codsIns.Frist_Storage_Agency__c     = reSet1[i].Frist_Storage_Agency__c;
+                                codsIns.Agencyinfo_fromSAP__c = reSet1[i].Agencyinfo_fromSAP__c;
+                                codsIns.Frist_Storage_Agency__c = reSet1[i].Frist_Storage_Agency__c;
                                 // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
 
                                 //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,璁板綍SAP鍚堝悓鍙�
                                 // update tcm start
                                 if (String.isBlank(reSet1[i].Consumable_order_minor__r.ContractNo__c)) {
-                                    codsIns.ContractNo_text__c= reSet1[i].ContractNo_text__c;
-                                }else {
-                                    codsIns.ContractNo_text__c= reSet1[i].Consumable_order_minor__r.ContractNo__c;
+                                    codsIns.ContractNo_text__c = reSet1[i].ContractNo_text__c;
+                                } else {
+                                    codsIns.ContractNo_text__c = reSet1[i].Consumable_order_minor__r.ContractNo__c;
                                 }
                                 // update tcm end
                                 //add by rentx 2020-10-13 end
 
                                 //add by rentx 2021-03-22 start
                                 // if (reSet1[i].Lose_Flag__c == true){
-                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣'){
+                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣') {
                                     codsIns.exchangeOutPattern__c = true;
                                 }
                                 //add by rentx 2021-03-22 end
 
                                 consumableorderdetails2Insert.add(codsIns);
-                                otherAgencyMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                                otherAgencyMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
                                 //String str = '璇ュ晢鍝佸湪鍏朵粬缁忛攢鍟嗗簱瀛�';
                                 //ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
                                 //ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
@@ -714,56 +866,81 @@
                     }
                 }
 
-                 //鍙戦敊搴� 鏈埌璐�
-                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
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
-                                ,Agencyinfo_fromSAP__c,Frist_Storage_Agency__c 
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
-                                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-                                ,ContractNo_text__c/*,ContractNo__c*/ 
-                                // tcm start
-                                ,Consumable_order_minor__r.ContractNo__c
-                                // tcm end
-                                //add by rentx 2020-10-13 end   浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-                                ,hospitalSpecialOffer__c
-                                ,exchangeOutPattern__c
-                                ,Lose_Flag__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            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  (Dealer_Info_text__c != :accountName
-                                OR (Dealer_Info_text__c = :accountName 
-                                    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)))
-                            )
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                            order by Bar_Code__c, Transfer_Time__c desc
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                            ];
-                if(reSet1.size()>0){
+                //鍙戦敊搴� 鏈埌璐�
+                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,
+                        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                        // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
+                        Agencyinfo_fromSAP__c,
+                        Frist_Storage_Agency__c,
+                        // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
+                        //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+                        ContractNo_text__c /*,ContractNo__c*/,
+                        // tcm start
+                        Consumable_order_minor__r.ContractNo__c,
+                        // tcm end
+                        //add by rentx 2020-10-13 end   浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+                        hospitalSpecialOffer__c,
+                        exchangeOutPattern__c,
+                        Lose_Flag__c,
+                        Report_Product_Expiration__c
+                    FROM Consumable_order_details2__c
+                    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 (Dealer_Info_text__c != :accountName
+                        OR (Dealer_Info_text__c = :accountName
+                        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))))
+                    // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                    ORDER BY Bar_Code__c, Transfer_Time__c DESC
+                    // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+                ];
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
-                            if(otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)){
+                        } else {
+                            if (otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)) {
                                 continue;
-                            }else{
+                            } else {
                                 //鍙栨秷鏄庣粏
                                 List<String> barcodedetList = new List<String>();
                                 barcodedetList.add(reSet1[i].Bar_Code__c);
@@ -772,189 +949,243 @@
                                 barcodedetList.add(reSet1[i].TracingCode__c);
                                 // 鍙戦敊搴撳瓨鏃讹紝鑷姩鍙栨秷 update by gzw 2020-04-15 start
                                 //if (reSet1[i].Consumable_order_minor__c == null) {
-                                    consumableorderdetails2Cancle.add(reSet1[i]);
+                                consumableorderdetails2Cancle.add(reSet1[i]);
                                 //}
                                 // 鍙戦敊搴撳瓨鏃讹紝鑷姩鍙栨秷 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
-                                consumableInventory.add(new ConsumableorderdetailsInfo(reSet1[i],barcodedetList));
+                                consumableInventory.add(new ConsumableorderdetailsInfo(reSet1[i], barcodedetList));
                                 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;
+                                codsIns.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+                                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;
-                                codsIns.Consumable_Product__c       = reSet1[i].Consumable_Product__c;
-                                codsIns.Bar_Code__c                 = reSet1[i].Bar_Code__c;
-                                codsIns.SerialLotNo__c              = reSet1[i].SerialLotNo__c;
-                                codsIns.TracingCode__c              = reSet1[i].TracingCode__c;
+                                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;
+                                codsIns.Consumable_Product__c = reSet1[i].Consumable_Product__c;
+                                codsIns.Bar_Code__c = reSet1[i].Bar_Code__c;
+                                codsIns.SerialLotNo__c = reSet1[i].SerialLotNo__c;
+                                codsIns.TracingCode__c = reSet1[i].TracingCode__c;
                                 // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
                                 // 娌℃湁鍏ュ簱鏃讹紝娌℃湁鍊熻皟淇℃伅
-                                codsIns.Transfer_Time__c            = reSet1[i].Transfer_Time__c;
-                                codsIns.Frist_Transfer_Agency__c    = reSet1[i].Frist_Transfer_Agency__c;
-                                codsIns.Agency_Transfer__c          = reSet1[i].Agency_Transfer__c;
+                                codsIns.Transfer_Time__c = reSet1[i].Transfer_Time__c;
+                                codsIns.Frist_Transfer_Agency__c = reSet1[i].Frist_Transfer_Agency__c;
+                                codsIns.Agency_Transfer__c = reSet1[i].Agency_Transfer__c;
                                 // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                                
+
                                 // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                                codsIns.Agencyinfo_fromSAP__c       = reSet1[i].Agencyinfo_fromSAP__c;
-                                codsIns.Frist_Storage_Agency__c     = reSet1[i].Frist_Storage_Agency__c;
+                                codsIns.Agencyinfo_fromSAP__c = reSet1[i].Agencyinfo_fromSAP__c;
+                                codsIns.Frist_Storage_Agency__c = reSet1[i].Frist_Storage_Agency__c;
                                 // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
 
                                 //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
                                 // update tcm start
                                 if (String.isBlank(reSet1[i].Consumable_order_minor__r.ContractNo__c)) {
-                                    codsIns.ContractNo_text__c= reSet1[i].ContractNo_text__c;
-                                }else {
-                                    codsIns.ContractNo_text__c= reSet1[i].Consumable_order_minor__r.ContractNo__c;
+                                    codsIns.ContractNo_text__c = reSet1[i].ContractNo_text__c;
+                                } else {
+                                    codsIns.ContractNo_text__c = reSet1[i].Consumable_order_minor__r.ContractNo__c;
                                 }
                                 // update tcm end
                                 //add by rentx 2020-10-13 end   浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
 
                                 //add by rentx 2021-03-22 start
                                 // if (reSet1[i].Lose_Flag__c == true){
-                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣'){
+                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣') {
                                     codsIns.exchangeOutPattern__c = true;
                                 }
                                 //add by rentx 2021-03-22 end
 
                                 consumableorderdetails2Insert.add(codsIns);
-                                otherAgencyMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                                otherAgencyMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
                             }
                         }
                     }
                 }
-            }else{
+            } 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
-                                //add by rentx 2020-10-14 start
-                                ,ContractNo_text__c/*,ContractNo__c*/
-                                // tcm start
-                            ,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)
+                //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�
+                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*/,
+                        // tcm start
+                        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)
                         AND Dealer_Info_text__c = :accountName
-                        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 ];
+                        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
+                ];
 
-                if(reSet1.size()>0){
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
-                            String str = '浜у搧绫诲瀷['+reSet1[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                        } else {
+                            String str = '浜у搧绫诲瀷[' + reSet1[i].Product_Type__c + ']涓庣敤鎴风殑绫诲瀷[' + userPro_Type + ']涓嶇';
+                            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
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // 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 
-                        AND  Dealer_Shipment__c= FALSE
-                        AND  Dealer_Saled__c = FALSE
-                        AND  Dealer_Returned__c = false
-                        AND  Bar_Code__c in :BarCodeListP
+                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*/,
+                        // 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
+                        AND Dealer_Shipment__c = FALSE
+                        AND Dealer_Saled__c = FALSE
+                        AND Dealer_Returned__c = FALSE
+                        AND Bar_Code__c IN :BarCodeListP
                         AND Dealer_Info_text__c = :accountName
-                        ORDER BY Name ];//娌″埌璐�
-                if(reSet1.size()>0){
+                    ORDER BY Name
+                ]; //娌″埌璐�
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
+                        } else {
                             String str = '璇ュ晢鍝佸皻鏈叆搴�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                            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,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*/
-                                // 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
-                            AND  Dealer_Shipment__c= FALSE
-                            AND  Dealer_Saled__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
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                            AND Dealer_Info_text__c = :accountName
-                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                            // Gzw 20201215淇锛屾媶鐩掍骇鍝佷笉鍒ゆ柇
-                            AND Box_Piece__c = '鐩�'
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                            ORDER BY Name ];//娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
-                if(reSet1.size()>0){
+                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*/,
+                        // 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
+                        AND Dealer_Shipment__c = FALSE
+                        AND Dealer_Saled__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
+                        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+                        AND Dealer_Info_text__c = :accountName
+                        AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+                        // Gzw 20201215淇锛屾媶鐩掍骇鍝佷笉鍒ゆ柇
+                        AND Box_Piece__c = '鐩�'
+                    // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+                    ORDER BY Name
+                ]; //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
+                if (reSet1.size() > 0) {
                     for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                             // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                             continue;
-                        }else{
-                            
+                        } else {
                             // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
                             // String str = '璇ュ晢鍝佸湪搴�';
                             // if (reSet1[i].Lose_Flag__c) {
                             //     str = '璇ュ晢鍝佷涪澶�';
                             // }
                             String str = '';
-                            if(reSet1[i].Lose_Flag__c == false){
-                                str = '璇ュ晢鍝佸湪搴�';//娌″嚭搴� 锛屾病閿�鍞紝娌′涪澶卞氨鏄湪搴撱��
+                            if (reSet1[i].Lose_Flag__c == false) {
+                                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+'瀛樺湪涓㈠け璁板綍'));//濡傛灉涓㈠け浜у搧灏辩粰鎻愮ず銆�
+                            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 + '瀛樺湪涓㈠け璁板綍'
+                                    )
+                                ); //濡傛灉涓㈠け浜у搧灏辩粰鎻愮ず銆�
                             }
                             if (reSet1[i].Lose_Flag__c == true && reSet1[i].ToDueDateDays__c < 0) {
                                 str = '杩囨湡宸查攢瀛樹骇鍝侊紝涓嶅厑璁歌繑鍝�';
                             }
-                            if(str != ''){
-                                ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                                ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                            if (str != '') {
+                                ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
+                                ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
                             }
                             // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
                             // ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
@@ -964,82 +1195,82 @@
                 }
             }
 
-            
-            
-            
             //鍒拌揣姝g‘淇℃伅
-            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,
-                            Box_Piece__c,
-                            Rrturn_count__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,
-                            Consumable_Product__r.Pro2_Dealer_ENG__c,
-                            Consumable_Product__r.Pro2_Dealer_Object__c,
-                            TracingCode__c,
-                            Agencyinfo_fromSAP__c,
-                            Frist_Storage_Agency__c,
-                            Dealer_Info_text__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,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
-                        AND Dealer_Info_text__c = :accountName
-                        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 ];
+            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,
+                    Box_Piece__c,
+                    Rrturn_count__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,
+                    Consumable_Product__r.Pro2_Dealer_ENG__c,
+                    Consumable_Product__r.Pro2_Dealer_Object__c,
+                    TracingCode__c,
+                    Agencyinfo_fromSAP__c,
+                    Frist_Storage_Agency__c,
+                    Dealer_Info_text__c,
+                    //add by rentx 2020-10-14 start
+                    ContractNo_text__c /*,ContractNo__c*/,
+                    // tcm start
+                    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
+                    AND Dealer_Info_text__c = :accountName
+                    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
+            ];
 
-            if(reSet.size()>0){
+            if (reSet.size() > 0) {
                 //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'ErrorIdMap+++ '+ ErrorIdMap.keyset()));
-                Map<String,String> errorMap = new Map<String,String>();
+                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)){
+                    if (ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)) {
                         // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                         continue;
-                    }else{
+                    } else {
                         Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){
+                        if (n.find()) {
                             String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i], str));
+                            ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
                             continue;
                         }
-                        if(otherAgencyMap.containsKey(reSet[i].Bar_Code__c)){
-                            for (Integer j=0; j<consumableInventory.size(); j++) {
+                        if (otherAgencyMap.containsKey(reSet[i].Bar_Code__c)) {
+                            for (Integer j = 0; j < consumableInventory.size(); j++) {
                                 ConsumableorderdetailsInfo codInfo = consumableInventory.get(j);
                                 if (codInfo.barCodeNo == reSet[i].Bar_Code__c) {
                                     consumableInventory.remove(j);
                                     break;
                                 }
                             }
-                            for (Integer m=0; m<consumableorderdetails2Insert.size(); m++) {
+                            for (Integer m = 0; m < consumableorderdetails2Insert.size(); m++) {
                                 Consumable_order_details2__c cod2 = consumableorderdetails2Insert.get(m);
                                 if (cod2.Bar_Code__c == reSet[i].Bar_Code__c) {
                                     consumableorderdetails2Insert.remove(m);
@@ -1051,84 +1282,92 @@
                         //prodName.add(reSet[i].Consumable_Product__r.Name);
                         ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
                         ConsumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+                        ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
                     }
                 }
             }
             //barcode涓嶄竴鑷达紝绠$悊缂栫爜涓�鑷�
-            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
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c */
-                            // tcm start
-                            ,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 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)
-                        //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 ];
+            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,
+                    //add by rentx 2020-10-14 start
+                    ContractNo_text__c /*,ContractNo__c */,
+                    // tcm start
+                    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 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)
+                    //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
+            ];
 
-            if(reSet.size()>0){
+            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)){
+                    if (ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)) {
                         // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                         continue;
-                    }else{
+                    } else {
                         Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){
+                        if (n.find()) {
                             String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i], str));
+                            ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
                             continue;
                         }
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                        for(String str : barMcodeMap.keySet()){
+                        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)){
+                            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){
+                            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);
+                                ExistIdMap.put(str, str);
                             }
                         }
                         ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
@@ -1137,360 +1376,488 @@
                 }
             }
 
-
             // CHAN-BD43NK 鍏抽棴鐩存帴杩斿搧鍔熻兘  杩藉姞 barcode涓嶄竴鑷村垽鏂�
-            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()
-                        AND Dealer_Info_text__c = :accountName
-                        AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                        ORDER BY Name ];
-            if(reSet1.size()>0){
+            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()
+                    AND Dealer_Info_text__c = :accountName
+                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                ORDER BY Name
+            ];
+            if (reSet1.size() > 0) {
                 for (Integer i = 0; i < reSet1.size(); i++) {
-                    if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
+                    if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
                         // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                         continue;
-                    }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 + ' 涓殑绠$悊缂栫爜涓�鑷达紝浣咮arcode涓嶅悓锛岃纭鍏蜂綋鏁版嵁銆�'));
-                                ErrorIdMap.put(str,str);
-                                ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+                    } 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 +
+                                            ' 涓殑绠$悊缂栫爜涓�鑷达紝浣咮arcode涓嶅悓锛岃纭鍏蜂綋鏁版嵁銆�'
+                                    )
+                                );
+                                ErrorIdMap.put(str, str);
+                                ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
                             }
                         }
                     }
                 }
             }
-            integer RGcnt =  GoodsReturnCheck();
+            integer RGcnt = GoodsReturnCheck();
             AllMap.putAll(ErrorIdMap);
             AllMap.putAll(ExistIdMap);
-            if(RGcnt>0){
-                for(String str:GrList){
-                    AllMap.put(str,str);
+            if (RGcnt > 0) {
+                for (String str : GrList) {
+                    AllMap.put(str, str);
                 }
             }
             //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
             //return;
-            for(Integer i = 0; i < BarCodeListP.size(); i++){
-                if(AllMap.containsKey(BarCodeListP[i])){
+            for (Integer i = 0; i < BarCodeListP.size(); i++) {
+                if (AllMap.containsKey(BarCodeListP[i])) {
                     continue;
-                }else if(otherAgencyMap.containsKey(BarCodeListP[i])){
+                } else if (otherAgencyMap.containsKey(BarCodeListP[i])) {
                     continue;
                 }
                 //add by rentx 2021-01-27 start
-                else if (coc!= null && coc.orderPattern__c == 'hospitalorder') {
+                else if (coc != null && coc.orderPattern__c == 'hospitalorder') {
                     HosErrorList.add(BarCodeListP[i]);
                     continue;
                 }
                 //add by rentx 2021-01-27 end
-                else{
+                else {
                     notInlist.add(BarCodeListP[i]);
-                    otherAgencyMap.put(BarCodeListP[i],BarCodeListP[i]);
+                    otherAgencyMap.put(BarCodeListP[i], BarCodeListP[i]);
                 }
             }
             //  CHAN-BD43NK 鍏抽棴鐩存帴杩斿搧鍔熻兘
-            if(notInlist.size()>0){
-                if(ArrType!='ReG'){
+            if (notInlist.size() > 0) {
+                if (ArrType != 'ReG') {
                     inventoryEntryNoESetId(notInlist);
-                    if(notInStorelist.size() > 0){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notInStorelist + '涓嶅瓨鍦ㄣ��'));
+                    if (notInStorelist.size() > 0) {
+                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'BarCode鍙�' + notInStorelist + '涓嶅瓨鍦ㄣ��'));
                         return;
                     }
-                }else{
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notInlist + '涓嶅瓨鍦紝鏃犲搴旂殑鍑哄簱鍗曪紝璇峰厛鎿嶄綔浜у搧鍏ュ簱銆�'));
+                } else {
+                    ApexPages.addmessage(
+                        new ApexPages.message(
+                            ApexPages.severity.ERROR,
+                            'BarCode鍙�' + notInlist + '涓嶅瓨鍦紝鏃犲搴旂殑鍑哄簱鍗曪紝璇峰厛鎿嶄綔浜у搧鍏ュ簱銆�'
+                        )
+                    );
                     return;
                 }
             }
 
-        //add by rentx 2021-01-27 start
-        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 start
+            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 
-                            FROM Consumable_order_details2__c
-                            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_Info_text__c = :accountName
-                            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{
-                            String str = '璇ュ晢鍝佸彇娑�';
-                            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 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Saled__c = true
-                            AND  Dealer_Returned__c =false
-                            AND  Dealer_Info_text__c = :accountName
-                            AND  Bar_Code__c in :BarCodeListP 
-                            AND  Arrive_Owner_Work_Location__c =: userWorkLocation 
-                            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{
-                            String str = '璇ュ晢鍝佸凡缁忛攢鍞�';
-                            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 
-                            FROM Consumable_order_details2__c
-                            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 ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸凡缁忓嚭搴�';
-                            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,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
-                            AND Dealer_Info_text__c = :accountName
-                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                            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{
-                            String str = '璇ュ晢鍝佸凡缁忓埌璐�';
-                            if (reSet1[i].Lose_Flag__c == TRUE) {
-                                str = '璇ュ晢鍝佸凡缁忎涪澶�';
-                            }
-                            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 
-                            FROM Consumable_order_details2__c
-                            WHERE Consumable_order_minor__c != :ESetId
-                            AND  Bar_Code__c in :BarCodeListP
-                            //AND Dealer_Info_text__c = :accountName
-                            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{
-                            String str = '璇ユ秷鑰楀搧涓嶅睘浜庢湰璁㈠崟';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__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
-                            // tcm end
-                        FROM Consumable_order_details2__c
-                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Dealer_Info_text__c = :accountName
-                        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 ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '浜у搧绫诲瀷['+reSet1[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-
-            //鍒拌揣姝g‘淇℃伅
-            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*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                        FROM Consumable_order_details2__c
-                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Dealer_Info_text__c = :accountName
-                        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 ];
-            if(reSet.size()>0){
-                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)){
+            //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
+                FROM Consumable_order_details2__c
+                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_Info_text__c = :accountName
+                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{
+                    } else {
+                        String str = '璇ュ晢鍝佸彇娑�';
+                        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
+                FROM Consumable_order_details2__c
+                WHERE
+                    Dealer_Saled__c = TRUE
+                    AND Dealer_Returned__c = FALSE
+                    AND Dealer_Info_text__c = :accountName
+                    AND Bar_Code__c IN :BarCodeListP
+                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                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 {
+                        String str = '璇ュ晢鍝佸凡缁忛攢鍞�';
+                        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
+                FROM Consumable_order_details2__c
+                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
+            ];
+            if (reSet1.size() > 0) {
+                for (Integer i = 0; i < reSet1.size(); i++) {
+                    if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+                        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+                        continue;
+                    } else {
+                        String str = '璇ュ晢鍝佸凡缁忓嚭搴�';
+                        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,
+                    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
+                    AND Dealer_Info_text__c = :accountName
+                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                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 {
+                        String str = '璇ュ晢鍝佸凡缁忓埌璐�';
+                        if (reSet1[i].Lose_Flag__c == true) {
+                            str = '璇ュ晢鍝佸凡缁忎涪澶�';
+                        }
+                        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
+                FROM Consumable_order_details2__c
+                WHERE Consumable_order_minor__c != :ESetId AND Bar_Code__c IN :BarCodeListP
+                //AND Dealer_Info_text__c = :accountName
+                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 {
+                        String str = '璇ユ秷鑰楀搧涓嶅睘浜庢湰璁㈠崟';
+                        ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
+                        ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__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
+                // tcm end
+                FROM Consumable_order_details2__c
+                WHERE
+                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                    AND Dealer_Info_text__c = :accountName
+                    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
+            ];
+            if (reSet1.size() > 0) {
+                for (Integer i = 0; i < reSet1.size(); i++) {
+                    if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+                        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+                        continue;
+                    } else {
+                        String str = '浜у搧绫诲瀷[' + reSet1[i].Product_Type__c + ']涓庣敤鎴风殑绫诲瀷[' + userPro_Type + ']涓嶇';
+                        ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
+                        ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+                    }
+                }
+            }
+
+            //鍒拌揣姝g‘淇℃伅
+            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*/,
+                    // tcm start
+                    Consumable_order_minor__r.ContractNo__c
+                // tcm end
+                FROM Consumable_order_details2__c
+                WHERE
+                    recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                    AND Dealer_Info_text__c = :accountName
+                    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
+            ];
+            if (reSet.size() > 0) {
+                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;
+                    } else {
                         Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){
+                        if (n.find()) {
                             String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i], str));
+                            ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
                             continue;
                         }
                         ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
                         ConsumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+                        ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
                     }
                 }
             }
 
             //barcode涓嶄竴鑷达紝绠$悊缂栫爜涓�鑷�
-            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,
-                            Box_Piece__c,
-                            Rrturn_count__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,
-                            TracingCode__c
-                            ,Agencyinfo_fromSAP__c
-                            ,Frist_Storage_Agency__c
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,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()
-                        AND Dealer_Info_text__c = :accountName
-                        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 ];
-            if(reSet.size()>0){
+            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,
+                    Box_Piece__c,
+                    Rrturn_count__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,
+                    TracingCode__c,
+                    Agencyinfo_fromSAP__c,
+                    Frist_Storage_Agency__c,
+                    ContractNo_text__c /*,ContractNo__c*/,
+                    // tcm start
+                    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()
+                    AND Dealer_Info_text__c = :accountName
+                    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
+            ];
+            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)){
+                    if (ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)) {
                         // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                         continue;
-                    }else{
+                    } else {
                         Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){
+                        if (n.find()) {
                             String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i], str));
+                            ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
                             continue;
                         }
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                        for(String str : barMcodeMap.keySet()){
-                            if(barMcodeMap.get(str) == reSet[i].TracingCode__c){
+                        ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+                        for (String str : barMcodeMap.keySet()) {
+                            if (barMcodeMap.get(str) == reSet[i].TracingCode__c) {
                                 reSet[i].Bar_Code__c = str;
-                                ExistIdMap.put(str,str);
+                                ExistIdMap.put(str, str);
                             }
                         }
                         ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
@@ -1501,28 +1868,27 @@
             AllMap.putAll(ErrorIdMap);
             AllMap.putAll(ExistIdMap);
             //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
-            for(Integer i = 0; i < BarCodeListP.size(); i++){
-                if(AllMap.containsKey(BarCodeListP[i])){
+            for (Integer i = 0; i < BarCodeListP.size(); i++) {
+                if (AllMap.containsKey(BarCodeListP[i])) {
                     continue;
-                }else if(otherAgencyMap.containsKey(BarCodeListP[i])){
+                } else if (otherAgencyMap.containsKey(BarCodeListP[i])) {
                     continue;
                 }
                 //add by rentx 2021-01-27 start
-                else if (coc!= null && coc.orderPattern__c == 'hospitalorder') {
+                else if (coc != null && coc.orderPattern__c == 'hospitalorder') {
                     HosErrorList.add(BarCodeListP[i]);
                     continue;
-                    
                 }
                 //add by rentx 2021-01-27 end
-                else{
+                else {
                     notInlist.add(BarCodeListP[i]);
-                    otherAgencyMap.put(BarCodeListP[i],BarCodeListP[i]);
+                    otherAgencyMap.put(BarCodeListP[i], BarCodeListP[i]);
                 }
             }
-            if(notInlist.size()>0){
+            if (notInlist.size() > 0) {
                 inventoryEntry(notInlist);
-                if(notInStorelist.size() > 0){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notInStorelist + '涓嶅瓨鍦ㄣ��'));
+                if (notInStorelist.size() > 0) {
+                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'BarCode鍙�' + notInStorelist + '涓嶅瓨鍦ㄣ��'));
                     return;
                 }
             }
@@ -1531,135 +1897,188 @@
         //add by rentx 2021-01-27 start 褰撹鍗曚负鍖婚櫌鐗逛环绫诲瀷鐨勮鍗曟椂,濡傛灉鎵句笉鍒癰arcode,涓嶈В鏋�,骞朵笖榛樿璇arcode瀵瑰簲鐨勬槑缁�2涓洪潪鍖婚櫌鐗逛环浜у搧,鐩存帴鎶ラ敊
         if (HosErrorList.size() > 0) {
             for (String str : HosErrorList) {
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�:' + str +'鏄潪鍖婚櫌鐗逛环浜у搧'));
-                
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'BarCode鍙�:' + str + '鏄潪鍖婚櫌鐗逛环浜у搧'));
             }
         }
         //add by rentx 2021-01-27 end
 
-    makeArrivedSummary();
-
+        makeArrivedSummary();
 
         //add by rentx 20210602 start CHAN-C3K4ZQ
         makeRecordsView(ConsumableorderdetailsRecordsdummy);
         //add by rentx 20210602 end CHAN-C3K4ZQ
     }
 
-
-    public void inventoryEntryNoESetId (List<String> barCodeList){
+    public void inventoryEntryNoESetId(List<String> barCodeList) {
         //鎵�鏈塨arcode瑙f瀽鍒扮殑Jancode
         List<String> alljanCodeList = new List<String>();
         List<String> allotCodeList = new List<String>();
         List<String> barCode01List = new List<String>();
         List<String> barCode241List = new List<String>();
-        Map<String,Map<String,String>> barJancodeMap = new  Map<String,Map<String,String>>();
-        Map<String,Map<String,String>> barOtcodeMap = new  Map<String,Map<String,String>>();
-        Map<String,List<String>> barcodeinfoMap = new  Map<String,List<String>>();
-        Map<String,String> barcoderightMap = new  Map<String,String>();
+        Map<String, Map<String, String>> barJancodeMap = new Map<String, Map<String, String>>();
+        Map<String, Map<String, String>> barOtcodeMap = new Map<String, Map<String, String>>();
+        Map<String, List<String>> barcodeinfoMap = new Map<String, List<String>>();
+        Map<String, String> barcoderightMap = new Map<String, String>();
         notInStorelist.clear();
-        for(Integer i = 0; i < barCodeList.size(); i++){
-            Date expirationDate = null ;
+        for (Integer i = 0; i < barCodeList.size(); i++) {
+            Date expirationDate = null;
             String serialNoorLotNo = '';
             String tracingCode = '';
             String productDateStr = '';
-            Date productionDate = null ;
+            Date productionDate = null;
             String expirationDateStr = '';
-            if(barCodeList[i].length() >= 3){
-                if(barCodeList[i].substring(0,2) =='01'){
+            if (barCodeList[i].length() >= 3) {
+                if (barCodeList[i].substring(0, 2) == '01') {
                     String janCodeMark = '';
                     //鐢熶骇鏃ユ湡
                     List<String> janCode = new List<String>();
-                    if(barCodeList[i].length() < 16){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
+                    if (barCodeList[i].length() < 16) {
+                        ApexPages.addmessage(
+                            new ApexPages.message(
+                                ApexPages.severity.ERROR,
+                                '浜у搧BarCode(' + barCodeList[i] + ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+                            )
+                        );
                         continue;
-                    }else {
+                    } else {
                         //if(barCodeList[i].substring(0,2) !='01'){
                         //    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')娌℃湁janCode锛屼笉绗﹀悎瑕佹眰锛�'));
                         //    return;
                         //}
-                        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] + ')鐨刯anCode閿欒锛�'));
+                        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] + ')鐨刯anCode閿欒锛�')
+                            );
                             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] + ')娌℃湁绠$悊缂栫爜锛�'));
+                    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] + ')娌℃湁绠$悊缂栫爜锛�')
+                            );
                             continue;
                         }
-                        if( barCodeList[i].substring(16,18) =='11'){
-                            try{
-                                productDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01' ;
+                        if (barCodeList[i].substring(16, 18) == '11') {
+                            try {
+                                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 + '閿欒锛�'));
+                            } catch (Exception e) {
+                                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' ;
+                            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';
                                             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) ;
-                                        expirationDate = Date.valueOf(expirationDateStr);
+                                        } else {
+                                            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 + '閿欒锛�'));
+                                    } catch (Exception e) {
+                                        ApexPages.addmessage(
+                                            new ApexPages.message(
+                                                ApexPages.severity.ERROR,
+                                                '浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'
+                                            )
+                                        );
                                         continue;
                                     }
-                                    if(barCodeList[i].length() >= 42){
-                                        if(barCodeList[i].substring(32,34) =='10' || barCodeList[i].substring(32,34) =='21'){
-                                            serialNoorLotNo = barCodeList[i].substring(34,barCodeList[i].length() - 8) ;
+                                    if (barCodeList[i].length() >= 42) {
+                                        if (barCodeList[i].substring(32, 34) == '10' || barCodeList[i].substring(32, 34) == '21') {
+                                            serialNoorLotNo = barCodeList[i].substring(34, barCodeList[i].length() - 8);
                                         }
                                     }
-                                }else if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                    serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
+                                } else if (barCodeList[i].substring(24, 26) == '10' || barCodeList[i].substring(24, 26) == '21') {
+                                    serialNoorLotNo = barCodeList[i].substring(26, barCodeList[i].length() - 8);
                                 }
                             }
-                        }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';
+                        } 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';
                                     //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);
+                                } else {
+                                    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 + '閿欒锛�'));
+                            } catch (Exception e) {
+                                ApexPages.addmessage(
+                                    new ApexPages.message(
+                                        ApexPages.severity.ERROR,
+                                        '浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'
+                                    )
+                                );
                                 continue;
                             }
-                            if(barCodeList[i].length() >= 34){
-                                if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                    serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
+                            if (barCodeList[i].length() >= 34) {
+                                if (barCodeList[i].substring(24, 26) == '10' || barCodeList[i].substring(24, 26) == '21') {
+                                    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) ;
+                        } 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].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
-                            tracingCode = barCodeList[i].substring(barCodeList[i].length() - 5,barCodeList[i].length());
+                    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()){
+                            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] + ')鐨則racingCode閿欒锛�'));
+                        } else {
+                            ApexPages.addmessage(
+                                new ApexPages.message(ApexPages.severity.ERROR, '浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�')
+                            );
                             continue;
                         }
                     }
@@ -1668,404 +2087,590 @@
                     barcodedetList.add(String.valueOf(expirationDate));
                     barcodedetList.add(serialNoorLotNo);
                     barcodedetList.add(tracingCode);
-                    Integer jan1  = Integer.valueOf(janCodeMark.substring(0, 1));
-                    Integer jan2  = Integer.valueOf(janCodeMark.substring(1, 2));
-                    Integer jan3  = Integer.valueOf(janCodeMark.substring(2, 3));
-                    Integer jan4  = Integer.valueOf(janCodeMark.substring(3, 4));
-                    Integer jan5  = Integer.valueOf(janCodeMark.substring(4, 5));
-                    Integer jan6  = Integer.valueOf(janCodeMark.substring(5, 6));
-                    Integer jan7  = Integer.valueOf(janCodeMark.substring(6, 7));
-                    Integer jan8  = Integer.valueOf(janCodeMark.substring(7, 8));
-                    Integer jan9  = Integer.valueOf(janCodeMark.substring(8, 9));
+                    Integer jan1 = Integer.valueOf(janCodeMark.substring(0, 1));
+                    Integer jan2 = Integer.valueOf(janCodeMark.substring(1, 2));
+                    Integer jan3 = Integer.valueOf(janCodeMark.substring(2, 3));
+                    Integer jan4 = Integer.valueOf(janCodeMark.substring(3, 4));
+                    Integer jan5 = Integer.valueOf(janCodeMark.substring(4, 5));
+                    Integer jan6 = Integer.valueOf(janCodeMark.substring(5, 6));
+                    Integer jan7 = Integer.valueOf(janCodeMark.substring(6, 7));
+                    Integer jan8 = Integer.valueOf(janCodeMark.substring(7, 8));
+                    Integer jan9 = Integer.valueOf(janCodeMark.substring(8, 9));
                     Integer jan10 = Integer.valueOf(janCodeMark.substring(9, 10));
                     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 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);
+                    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);
                     janCode.add(janCodeMark.substring(0, 13) + frost13);
                     alljanCodeList.addAll(janCode);
-                    Map<String,String> janCodeMap = new Map<String,String>();
-                    janCodeMap.put(janCodeMark.substring(1, 13) + frost12,barCodeList[i]);
-                    janCodeMap.put(janCodeMark.substring(0, 13) + frost12,barCodeList[i]);
-                    janCodeMap.put(janCodeMark.substring(1, 13) + frost13,barCodeList[i]);
-                    janCodeMap.put(janCodeMark.substring(0, 13) + frost13,barCodeList[i]);
+                    Map<String, String> janCodeMap = new Map<String, String>();
+                    janCodeMap.put(janCodeMark.substring(1, 13) + frost12, barCodeList[i]);
+                    janCodeMap.put(janCodeMark.substring(0, 13) + frost12, barCodeList[i]);
+                    janCodeMap.put(janCodeMark.substring(1, 13) + frost13, barCodeList[i]);
+                    janCodeMap.put(janCodeMark.substring(0, 13) + frost13, barCodeList[i]);
                     barJancodeMap.put(barCodeList[i], janCodeMap);
                     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] + ')娌℃湁绠$悊缂栫爜锛�'));
+                } 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] + ')娌℃湁绠$悊缂栫爜锛�')
+                        );
                         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锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
+                    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锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+                            )
+                        );
                         continue;
-                    }else if(barCodeList[i].length() == 11){
-                        String otCode4 = barCodeList[i].substring(3,7);
-                        String otCode5 = barCodeList[i].substring(3,8);
-                        String otCode6 = barCodeList[i].substring(3,9);
-                        String otCode7 = barCodeList[i].substring(3,10);
-                        String otCode8 = barCodeList[i].substring(3,11);
+                    } else if (barCodeList[i].length() == 11) {
+                        String otCode4 = barCodeList[i].substring(3, 7);
+                        String otCode5 = barCodeList[i].substring(3, 8);
+                        String otCode6 = barCodeList[i].substring(3, 9);
+                        String otCode7 = barCodeList[i].substring(3, 10);
+                        String otCode8 = barCodeList[i].substring(3, 11);
                         otCodeList.add(otCode4);
                         otCodeList.add(otCode5);
                         otCodeList.add(otCode6);
                         otCodeList.add(otCode7);
                         otCodeList.add(otCode8);
-                        otCodeMap.put(otCode4,barCodeList[i]);
-                        otCodeMap.put(otCode5,barCodeList[i]);
-                        otCodeMap.put(otCode6,barCodeList[i]);
-                        otCodeMap.put(otCode7,barCodeList[i]);
-                        otCodeMap.put(otCode8,barCodeList[i]);
-                    }else if(barCodeList[i].length() >= 12){
-                        String otCode4 = barCodeList[i].substring(3,7);
-                        String otCode5 = barCodeList[i].substring(3,8);
-                        String otCode6 = barCodeList[i].substring(3,9);
-                        String otCode7 = barCodeList[i].substring(3,10);
-                        String otCode8 = barCodeList[i].substring(3,11);
-                        String otCode9 = barCodeList[i].substring(3,12);
+                        otCodeMap.put(otCode4, barCodeList[i]);
+                        otCodeMap.put(otCode5, barCodeList[i]);
+                        otCodeMap.put(otCode6, barCodeList[i]);
+                        otCodeMap.put(otCode7, barCodeList[i]);
+                        otCodeMap.put(otCode8, barCodeList[i]);
+                    } else if (barCodeList[i].length() >= 12) {
+                        String otCode4 = barCodeList[i].substring(3, 7);
+                        String otCode5 = barCodeList[i].substring(3, 8);
+                        String otCode6 = barCodeList[i].substring(3, 9);
+                        String otCode7 = barCodeList[i].substring(3, 10);
+                        String otCode8 = barCodeList[i].substring(3, 11);
+                        String otCode9 = barCodeList[i].substring(3, 12);
                         otCodeList.add(otCode4);
                         otCodeList.add(otCode5);
                         otCodeList.add(otCode6);
                         otCodeList.add(otCode7);
                         otCodeList.add(otCode8);
                         otCodeList.add(otCode9);
-                        otCodeMap.put(otCode4,barCodeList[i]);
-                        otCodeMap.put(otCode5,barCodeList[i]);
-                        otCodeMap.put(otCode6,barCodeList[i]);
-                        otCodeMap.put(otCode7,barCodeList[i]);
-                        otCodeMap.put(otCode8,barCodeList[i]);
-                        otCodeMap.put(otCode9,barCodeList[i]);
+                        otCodeMap.put(otCode4, barCodeList[i]);
+                        otCodeMap.put(otCode5, barCodeList[i]);
+                        otCodeMap.put(otCode6, barCodeList[i]);
+                        otCodeMap.put(otCode7, barCodeList[i]);
+                        otCodeMap.put(otCode8, barCodeList[i]);
+                        otCodeMap.put(otCode9, barCodeList[i]);
                     }
                     allotCodeList.addAll(otCodeList);
                     barOtcodeMap.put(barCodeList[i], otCodeMap);
                     barCode241List.add(barCodeList[i]);
-                }else{
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒'));
+                } else {
+                    ApexPages.addmessage(
+                        new ApexPages.message(ApexPages.severity.ERROR, '浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒')
+                    );
                     continue;
                 }
-            }else{
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒'));
+            } else {
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒'));
                 continue;
             }
         }
         //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
+        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
                 FROM Product2__c
-                WHERE Product2_Jancode__c in :alljanCodeList
-                order by SFDA_Expiration_Date__c  desc ] ;
-            if(product2InStore.size() > 0){
+                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>();
-                Map<String,String> errorMap = new Map<String,String>();
-                for(String bar: barJancodeMap.keySet() ){
+                Map<String, String> rightBar = new Map<String, String>();
+                Map<String, String> errorMap = new Map<String, String>();
+                for (String bar : barJancodeMap.keySet()) {
                     Integer cou = 0;
-                    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){
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
+                    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) {
+                                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){   
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
+                            } 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);
-                            }else{
+                            } else {
                                 errorMap.put(bar, bar);
                             }
                         }
-                        
                     }
-                    if(cou <= 0 ){
+                    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+']涓嶇'));
+                if (errorMap.size() > 0) {
+                    ApexPages.addmessage(
+                        new ApexPages.message(
+                            ApexPages.severity.ERROR,
+                            'BarCode鍙穂' + errorMap.values() + ']浜у搧绫诲瀷[' + product_Type + ']涓庣敤鎴风被鍨媅' + userPro_Type + ']涓嶇'
+                        )
+                    );
                 }
             }
         }
-        
+
         //241閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
-        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
+        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
                 FROM Product2__c
-                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)){
-                            exitBarCodeMap.put(bar,bar);
+                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)) {
+                            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+']绫诲瀷涓嶇'));
+            if (errorMap.size() > 0) {
+                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] ;
-            
-            if(product2InStore.size() > 0){
-                
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barOtcodeMap.keySet() ){
-                        Date expirationDate = null ;
+                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;
                         String serialNoorLotNo = '';
                         String tracingCode = '';
                         String productDateStr = '';
-                        Date productionDate = null ;
+                        Date productionDate = null;
                         String expirationDateStr = '';
-                        if(barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)){
+                        if (barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)) {
                             Integer oTcodeLength = produ.OT_CODE__c.length();
-                                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' ;
-                                            productionDate = Date.valueOf(productDateStr);
-                                        }catch(Exception e){
-                                            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' ;
-                                                        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) ;
-                                                    expirationDate = Date.valueOf(expirationDateStr);
-                                                    }
-                                                }catch(Exception e){
-                                                    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'){
-                                                        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'){
-                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
-                                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
-                                            }
-                                        }
-                                    }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';
-                                                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);
-                                                expirationDate = Date.valueOf(expirationDateStr);
-                                            }
-                                        }catch(Exception e){
-                                            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'){
-                                                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'){
-                                            serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2,bar.length() - 8) ;
-                                        }
-                                    }
-                                }
-                                if(bar.length() >= oTcodeLength + 3 + 8 && bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                                    if(bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                                        tracingCode = bar.substring(bar.length() - 5,bar.length());
-                                        Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
-                                        if(n.find()){
-                                            String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
-                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
-                                            continue;
-                                        }
-                                    }else{
-                                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�'));
+                            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';
+                                        productionDate = Date.valueOf(productDateStr);
+                                    } catch (Exception e) {
+                                        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';
+                                                    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);
+                                                    expirationDate = Date.valueOf(expirationDateStr);
+                                                }
+                                            } catch (Exception e) {
+                                                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'
+                                                ) {
+                                                    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'
+                                        ) {
+                                            serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10, bar.length() - 8);
+                                            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
+                                        }
+                                    }
+                                } 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';
+                                            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);
+                                            expirationDate = Date.valueOf(expirationDateStr);
+                                        }
+                                    } catch (Exception e) {
+                                        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'
+                                        ) {
+                                            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'
+                                    ) {
+                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2, bar.length() - 8);
+                                    }
                                 }
-                                exitBarCodeMap.put(bar,bar);
-                                List<String> barcodedetList = new List<String>();
-                                barcodedetList.add(bar);
-                                barcodedetList.add(String.valueOf(expirationDate));
-                                barcodedetList.add(serialNoorLotNo);
-                                barcodedetList.add(tracingCode);
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                            
+                            }
+                            if (bar.length() >= oTcodeLength + 3 + 8 && bar.substring(bar.length() - 8, bar.length() - 5) == '250') {
+                                if (bar.substring(bar.length() - 8, bar.length() - 5) == '250') {
+                                    tracingCode = bar.substring(bar.length() - 5, bar.length());
+                                    Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
+                                    if (n.find()) {
+                                        String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
+                                        ApexPages.addmessage(
+                                            new ApexPages.message(
+                                                ApexPages.severity.ERROR,
+                                                '浜у搧BarCode(' + bar + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'
+                                            )
+                                        );
+                                        continue;
+                                    }
+                                } else {
+                                    ApexPages.addmessage(
+                                        new ApexPages.message(ApexPages.severity.ERROR, '浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�')
+                                    );
+                                    continue;
+                                }
+                            }
+                            exitBarCodeMap.put(bar, bar);
+                            List<String> barcodedetList = new List<String>();
+                            barcodedetList.add(bar);
+                            barcodedetList.add(String.valueOf(expirationDate));
+                            barcodedetList.add(serialNoorLotNo);
+                            barcodedetList.add(tracingCode);
+                            consumableInventory.add(new ConsumableorderdetailsInfo(produ, barcodedetList));
+                            consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ, barcodedetList));
                         }
                     }
-
                 }
             }
-            for(String bartxt :barCode241List){
-               if(!exitBarCodeMap.containsKey(bartxt)){
-                 if(!errorMap.containsKey(bartxt)){
-                    notInStorelist.add(bartxt);
-                 } 
-               }
+            for (String bartxt : barCode241List) {
+                if (!exitBarCodeMap.containsKey(bartxt)) {
+                    if (!errorMap.containsKey(bartxt)) {
+                        notInStorelist.add(bartxt);
+                    }
+                }
             }
         }
-
     }
 
-
-    public void inventoryEntry (List<String> barCodeList){
+    public void inventoryEntry(List<String> barCodeList) {
         //鎵�鏈塨arcode瑙f瀽鍒扮殑Jancode
         List<String> alljanCodeList = new List<String>();
         List<String> allotCodeList = new List<String>();
         List<String> barCode01List = new List<String>();
         List<String> barCode241List = new List<String>();
-        Map<String,Map<String,String>> barJancodeMap = new  Map<String,Map<String,String>>();
-        Map<String,Map<String,String>> barOtcodeMap = new  Map<String,Map<String,String>>();
-        Map<String,List<String>> barcodeinfoMap = new  Map<String,List<String>>();
+        Map<String, Map<String, String>> barJancodeMap = new Map<String, Map<String, String>>();
+        Map<String, Map<String, String>> barOtcodeMap = new Map<String, Map<String, String>>();
+        Map<String, List<String>> barcodeinfoMap = new Map<String, List<String>>();
         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
-                        FROM Consumable_Orderdetails__c
-                        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 ];
-        for(Integer i = 0; i < orderdetail.size(); i++){
+        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
+            FROM Consumable_Orderdetails__c
+            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
+        ];
+        for (Integer i = 0; i < orderdetail.size(); i++) {
             orderdetailMap.put(orderdetail[i].Consumable_Product__c, orderdetail[i].Consumable_Product__c);
         }
 
-        for(Integer i = 0; i < barCodeList.size(); i++){
-            Date expirationDate = null ;
+        for (Integer i = 0; i < barCodeList.size(); i++) {
+            Date expirationDate = null;
             String serialNoorLotNo = '';
             String tracingCode = '';
             String productDateStr = '';
-            Date productionDate = null ;
+            Date productionDate = null;
             String expirationDateStr = '';
 
-            if(barCodeList[i].substring(0,2) =='01'){
+            if (barCodeList[i].substring(0, 2) == '01') {
                 String janCodeMark = '';
                 //鐢熶骇鏃ユ湡
                 List<String> janCode = new List<String>();
-                if(barCodeList[i].length() < 16){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
+                if (barCodeList[i].length() < 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] + ')鐨刯anCode閿欒锛�'));
+                } 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] + ')鐨刯anCode閿欒锛�')
+                        );
                         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] + ')娌℃湁绠$悊缂栫爜锛�'));
+                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] + ')娌℃湁绠$悊缂栫爜锛�')
+                        );
                         continue;
                     }
-                    if( barCodeList[i].substring(16,18) =='11'){
-                        try{
-                            productDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01' ;
+                    if (barCodeList[i].substring(16, 18) == '11') {
+                        try {
+                            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 + '閿欒锛�'));
+                        } catch (Exception e) {
+                            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' ;
+                        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';
                                         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) ;
-                                    expirationDate = Date.valueOf(expirationDateStr);
+                                    } else {
+                                        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 + '閿欒锛�'));
+                                } catch (Exception e) {
+                                    ApexPages.addmessage(
+                                        new ApexPages.message(
+                                            ApexPages.severity.ERROR,
+                                            '浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'
+                                        )
+                                    );
                                     continue;
                                 }
-                                if(barCodeList[i].length() >= 42){
-                                    if(barCodeList[i].substring(32,34) =='10' || barCodeList[i].substring(32,34) =='21'){
-                                        serialNoorLotNo = barCodeList[i].substring(34,barCodeList[i].length() - 8) ;
+                                if (barCodeList[i].length() >= 42) {
+                                    if (barCodeList[i].substring(32, 34) == '10' || barCodeList[i].substring(32, 34) == '21') {
+                                        serialNoorLotNo = barCodeList[i].substring(34, barCodeList[i].length() - 8);
                                     }
                                 }
-                            }else if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
+                            } else if (barCodeList[i].substring(24, 26) == '10' || barCodeList[i].substring(24, 26) == '21') {
+                                serialNoorLotNo = barCodeList[i].substring(26, barCodeList[i].length() - 8);
                             }
                         }
-                    }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';
+                    } 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';
                                 //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);
+                            } else {
+                                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 + '閿欒锛�'));
+                        } catch (Exception e) {
+                            ApexPages.addmessage(
+                                new ApexPages.message(
+                                    ApexPages.severity.ERROR,
+                                    '浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'
+                                )
+                            );
                             continue;
                         }
-                        if(barCodeList[i].length() >= 34){
-                            if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
+                        if (barCodeList[i].length() >= 34) {
+                            if (barCodeList[i].substring(24, 26) == '10' || barCodeList[i].substring(24, 26) == '21') {
+                                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) ;
+                    } 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].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
-                        tracingCode = barCodeList[i].substring(barCodeList[i].length() - 5,barCodeList[i].length());
+                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()){
+                        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] + ')鐨則racingCode閿欒锛�'));
+                    } else {
+                        ApexPages.addmessage(
+                            new ApexPages.message(ApexPages.severity.ERROR, '浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�')
+                        );
                         continue;
                     }
                 }
@@ -2074,275 +2679,397 @@
                 barcodedetList.add(String.valueOf(expirationDate));
                 barcodedetList.add(serialNoorLotNo);
                 barcodedetList.add(tracingCode);
-                Integer jan1  = Integer.valueOf(janCodeMark.substring(0, 1));
-                Integer jan2  = Integer.valueOf(janCodeMark.substring(1, 2));
-                Integer jan3  = Integer.valueOf(janCodeMark.substring(2, 3));
-                Integer jan4  = Integer.valueOf(janCodeMark.substring(3, 4));
-                Integer jan5  = Integer.valueOf(janCodeMark.substring(4, 5));
-                Integer jan6  = Integer.valueOf(janCodeMark.substring(5, 6));
-                Integer jan7  = Integer.valueOf(janCodeMark.substring(6, 7));
-                Integer jan8  = Integer.valueOf(janCodeMark.substring(7, 8));
-                Integer jan9  = Integer.valueOf(janCodeMark.substring(8, 9));
+                Integer jan1 = Integer.valueOf(janCodeMark.substring(0, 1));
+                Integer jan2 = Integer.valueOf(janCodeMark.substring(1, 2));
+                Integer jan3 = Integer.valueOf(janCodeMark.substring(2, 3));
+                Integer jan4 = Integer.valueOf(janCodeMark.substring(3, 4));
+                Integer jan5 = Integer.valueOf(janCodeMark.substring(4, 5));
+                Integer jan6 = Integer.valueOf(janCodeMark.substring(5, 6));
+                Integer jan7 = Integer.valueOf(janCodeMark.substring(6, 7));
+                Integer jan8 = Integer.valueOf(janCodeMark.substring(7, 8));
+                Integer jan9 = Integer.valueOf(janCodeMark.substring(8, 9));
                 Integer jan10 = Integer.valueOf(janCodeMark.substring(9, 10));
                 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 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);
+                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浣嶄釜浣�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);
                 janCode.add(janCodeMark.substring(1, 13) + frost13);
                 janCode.add(janCodeMark.substring(0, 13) + frost13);
                 alljanCodeList.addAll(janCode);
-                Map<String,String> janCodeMap = new Map<String,String>();
-                janCodeMap.put(janCodeMark.substring(1, 13) + frost12,barCodeList[i]);
-                janCodeMap.put(janCodeMark.substring(0, 13) + frost12,barCodeList[i]);
-                janCodeMap.put(janCodeMark.substring(1, 13) + frost13,barCodeList[i]);
-                janCodeMap.put(janCodeMark.substring(0, 13) + frost13,barCodeList[i]);
+                Map<String, String> janCodeMap = new Map<String, String>();
+                janCodeMap.put(janCodeMark.substring(1, 13) + frost12, barCodeList[i]);
+                janCodeMap.put(janCodeMark.substring(0, 13) + frost12, barCodeList[i]);
+                janCodeMap.put(janCodeMark.substring(1, 13) + frost13, barCodeList[i]);
+                janCodeMap.put(janCodeMark.substring(0, 13) + frost13, barCodeList[i]);
                 barJancodeMap.put(barCodeList[i], janCodeMap);
                 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] + ')娌℃湁绠$悊缂栫爜锛�'));
+            } 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] + ')娌℃湁绠$悊缂栫爜锛�')
+                    );
                     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锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
+                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锛屼笉绗﹀悎瑕佹眰閿欒锛�')
+                    );
                     continue;
-                }else if(barCodeList[i].length() == 11){
-                    String otCode4 = barCodeList[i].substring(3,7);
-                    String otCode5 = barCodeList[i].substring(3,8);
-                    String otCode6 = barCodeList[i].substring(3,9);
-                    String otCode7 = barCodeList[i].substring(3,10);
-                    String otCode8 = barCodeList[i].substring(3,11);
+                } else if (barCodeList[i].length() == 11) {
+                    String otCode4 = barCodeList[i].substring(3, 7);
+                    String otCode5 = barCodeList[i].substring(3, 8);
+                    String otCode6 = barCodeList[i].substring(3, 9);
+                    String otCode7 = barCodeList[i].substring(3, 10);
+                    String otCode8 = barCodeList[i].substring(3, 11);
                     otCodeList.add(otCode4);
                     otCodeList.add(otCode5);
                     otCodeList.add(otCode6);
                     otCodeList.add(otCode7);
                     otCodeList.add(otCode8);
-                    otCodeMap.put(otCode4,barCodeList[i]);
-                    otCodeMap.put(otCode5,barCodeList[i]);
-                    otCodeMap.put(otCode6,barCodeList[i]);
-                    otCodeMap.put(otCode7,barCodeList[i]);
-                    otCodeMap.put(otCode8,barCodeList[i]);
-                }else if(barCodeList[i].length() >= 12){
-                    String otCode4 = barCodeList[i].substring(3,7);
-                    String otCode5 = barCodeList[i].substring(3,8);
-                    String otCode6 = barCodeList[i].substring(3,9);
-                    String otCode7 = barCodeList[i].substring(3,10);
-                    String otCode8 = barCodeList[i].substring(3,11);
-                    String otCode9 = barCodeList[i].substring(3,12);
+                    otCodeMap.put(otCode4, barCodeList[i]);
+                    otCodeMap.put(otCode5, barCodeList[i]);
+                    otCodeMap.put(otCode6, barCodeList[i]);
+                    otCodeMap.put(otCode7, barCodeList[i]);
+                    otCodeMap.put(otCode8, barCodeList[i]);
+                } else if (barCodeList[i].length() >= 12) {
+                    String otCode4 = barCodeList[i].substring(3, 7);
+                    String otCode5 = barCodeList[i].substring(3, 8);
+                    String otCode6 = barCodeList[i].substring(3, 9);
+                    String otCode7 = barCodeList[i].substring(3, 10);
+                    String otCode8 = barCodeList[i].substring(3, 11);
+                    String otCode9 = barCodeList[i].substring(3, 12);
                     otCodeList.add(otCode4);
                     otCodeList.add(otCode5);
                     otCodeList.add(otCode6);
                     otCodeList.add(otCode7);
                     otCodeList.add(otCode8);
                     otCodeList.add(otCode9);
-                    otCodeMap.put(otCode4,barCodeList[i]);
-                    otCodeMap.put(otCode5,barCodeList[i]);
-                    otCodeMap.put(otCode6,barCodeList[i]);
-                    otCodeMap.put(otCode7,barCodeList[i]);
-                    otCodeMap.put(otCode8,barCodeList[i]);
-                    otCodeMap.put(otCode9,barCodeList[i]);
+                    otCodeMap.put(otCode4, barCodeList[i]);
+                    otCodeMap.put(otCode5, barCodeList[i]);
+                    otCodeMap.put(otCode6, barCodeList[i]);
+                    otCodeMap.put(otCode7, barCodeList[i]);
+                    otCodeMap.put(otCode8, barCodeList[i]);
+                    otCodeMap.put(otCode9, barCodeList[i]);
                 }
                 allotCodeList.addAll(otCodeList);
                 barOtcodeMap.put(barCodeList[i], otCodeMap);
                 barCode241List.add(barCodeList[i]);
-            }else{
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')娌℃湁janCode鎴朞Tcode锛屼笉绗﹀悎瑕佹眰锛�'));
+            } else {
+                ApexPages.addmessage(
+                    new ApexPages.message(ApexPages.severity.ERROR, '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁janCode鎴朞Tcode锛屼笉绗﹀悎瑕佹眰锛�')
+                );
                 continue;
             }
         }
         //01閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
-        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,
-                                            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 ] ;
-            if(product2InStore.size() > 0){
-                Map<String,String> errorMap = new Map<String,String>();
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barJancodeMap.keySet() ){
-                        if(barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)){
-                            exitBarCodeMap.put(bar,bar);
+        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,
+                    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
+            ];
+            if (product2InStore.size() > 0) {
+                Map<String, String> errorMap = new Map<String, String>();
+                for (Product2__c produ : product2InStore) {
+                    for (String bar : barJancodeMap.keySet()) {
+                        if (barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)) {
+                            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+']涓嶇'));
+                if (errorMap.size() > 0) {
+                    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,
-                                            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 ] ;
-            if(product2InStore.size() > 0){
-                Map<String,String> errorMap = new Map<String,String>();
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barJancodeMap.keySet() ){
-                        if(barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)){
-                            exitBarCodeMap.put(bar,bar); 
-                            if(orderdetailMap.containsKey(produ.Id)){
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
+            }
+            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
+            ];
+            if (product2InStore.size() > 0) {
+                Map<String, String> errorMap = new Map<String, String>();
+                for (Product2__c produ : product2InStore) {
+                    for (String bar : barJancodeMap.keySet()) {
+                        if (barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)) {
+                            exitBarCodeMap.put(bar, bar);
+                            if (orderdetailMap.containsKey(produ.Id)) {
+                                consumableInventory.add(new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar)));
                                 rightBar.put(bar, bar);
-                            }else{
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
+                            } else {
+                                consumableInventory.add(new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar)));
                                 rightBar.put(bar, bar);
-                                list<String> overOrderBARcodeCunList = new list<String>();
-                                if(notEqualBARcodeCunMap.containsKey(produ.Id)){
+                                list<String> overOrderBARcodeCunList = new List<String>();
+                                if (notEqualBARcodeCunMap.containsKey(produ.Id)) {
                                     overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id).clone();
                                     overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
-                                }else{
+                                    notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
+                                } else {
                                     overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
+                                    notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
                                 }
                             }
-                            
                         }
                     }
                 }
             }
-            for(String bartxt :barCode01List){
-               if(!exitBarCodeMap.containsKey(bartxt)){
-                  notInStorelist.add(bartxt);
-               }
+            for (String bartxt : barCode01List) {
+                if (!exitBarCodeMap.containsKey(bartxt)) {
+                    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
-                                                     FROM Product2__c
-                                                     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)){
-                            exitBarCodeMap.put(bar,bar);
+        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
+                FROM Product2__c
+                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)) {
+                            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+']绫诲瀷涓嶇'));
+            if (errorMap.size() > 0) {
+                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
-                                                     FROM Product2__c
-                                                     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 ;
+            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
+            ];
+
+            if (product2InStore.size() > 0) {
+                for (Product2__c produ : product2InStore) {
+                    for (String bar : barOtcodeMap.keySet()) {
+                        Date expirationDate = null;
                         String serialNoorLotNo = '';
                         String tracingCode = '';
                         String productDateStr = '';
-                        Date productionDate = null ;
+                        Date productionDate = null;
                         String expirationDateStr = '';
                         Integer oTcodeLength = produ.OT_CODE__c.length();
 
-                        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' ;
+                        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';
                                     productionDate = Date.valueOf(productDateStr);
-                                }catch(Exception e){
-                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + bar + ')鐨勭敓浜ф棩鏈�' + productDateStr + '閿欒锛�'));
+                                } catch (Exception e) {
+                                    ApexPages.addmessage(
+                                        new ApexPages.message(
+                                            ApexPages.severity.ERROR,
+                                            '浜у搧BarCode(' + bar + ')鐨勭敓浜ф棩鏈�' + productDateStr + '閿欒锛�'
+                                        )
+                                    );
                                     continue;
                                 }
-                                if(bar.length() >=oTcodeLength + 3 + 16){
+                                if (bar.length() >= oTcodeLength + 3 + 16) {
                                     //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode17' + bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10)));
-                                    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' ;
+                                    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';
                                                 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) ;
-                                            expirationDate = Date.valueOf(expirationDateStr);
+                                            } 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);
+                                                expirationDate = Date.valueOf(expirationDateStr);
                                             }
-                                        }catch(Exception e){
-                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
+                                        } catch (Exception e) {
+                                            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'){
-                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 18,bar.length() - 8) ;
+                                        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'
+                                            ) {
+                                                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'){
-                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
+                                    } 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));
                                     }
                                 }
-                            }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';
+                            } 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';
                                         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);
+                                    } 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);
                                         expirationDate = Date.valueOf(expirationDateStr);
                                     }
-                                }catch(Exception e){
-                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
+                                } catch (Exception e) {
+                                    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'){
-                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
+                                if (bar.length() >= oTcodeLength + 20) {
+                                    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'){
-                                    serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2,bar.length() - 8) ;
+                            } else if (bar.length() >= oTcodeLength + 12) {
+                                if (
+                                    bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '10' ||
+                                    bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '21'
+                                ) {
+                                    serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2, bar.length() - 8);
                                 }
                             }
                         }
-                        if(bar.length() >= oTcodeLength + 3 + 8 && bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                            if(bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                                tracingCode = bar.substring(bar.length() - 5,bar.length());
+                        if (bar.length() >= oTcodeLength + 3 + 8 && bar.substring(bar.length() - 8, bar.length() - 5) == '250') {
+                            if (bar.substring(bar.length() - 8, bar.length() - 5) == '250') {
+                                tracingCode = bar.substring(bar.length() - 5, bar.length());
                                 Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
-                                if(n.find()){
+                                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 + ')鐨則racingCode閿欒锛�'));
+                            } else {
+                                ApexPages.addmessage(
+                                    new ApexPages.message(ApexPages.severity.ERROR, '浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�')
+                                );
                                 continue;
                             }
                         }
@@ -2351,43 +3078,42 @@
                         barcodedetList.add(String.valueOf(expirationDate));
                         barcodedetList.add(serialNoorLotNo);
                         barcodedetList.add(tracingCode);
-                        if(barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)){
-                            exitBarCodeMap.put(bar,bar);
-                            
-                            if(orderdetailMap.containsKey(produ.Id)){
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                            }else{
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                                list<String> overOrderBARcodeCunList = new list<String>();
-                                if(notEqualBARcodeCunMap.containsKey(produ.Id)){
+                        if (barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)) {
+                            exitBarCodeMap.put(bar, bar);
+
+                            if (orderdetailMap.containsKey(produ.Id)) {
+                                consumableInventory.add(new ConsumableorderdetailsInfo(produ, barcodedetList));
+                            } else {
+                                consumableInventory.add(new ConsumableorderdetailsInfo(produ, barcodedetList));
+                                list<String> overOrderBARcodeCunList = new List<String>();
+                                if (notEqualBARcodeCunMap.containsKey(produ.Id)) {
                                     overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id).clone();
                                     overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
-                                }else{
+                                    notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
+                                } else {
                                     overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
+                                    notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
                                 }
-                            } 
- 
+                            }
                         }
                     }
                 }
             }
 
-            for(String bartxt :barCode241List){
-               if(!exitBarCodeMap.containsKey(bartxt)){
-                    if(!errorMap.containsKey(bartxt)){
+            for (String bartxt : barCode241List) {
+                if (!exitBarCodeMap.containsKey(bartxt)) {
+                    if (!errorMap.containsKey(bartxt)) {
                         notInStorelist.add(bartxt);
                     }
-               }
+                }
             }
         }
         //鍒ゆ柇浜у搧鏄惁涓�鑷�
-        if(notEqualBARcodeCunMap.size() > 0){
-            for(String widget : notEqualBARcodeCunMap.keySet()) {
-                if(notEqualBARcodeCunMap.get(widget).size() >0){
+        if (notEqualBARcodeCunMap.size() > 0) {
+            for (String widget : notEqualBARcodeCunMap.keySet()) {
+                if (notEqualBARcodeCunMap.get(widget).size() > 0) {
                     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '浠ヤ笅barcode浜у搧涓庤璐т骇鍝佷笉涓�鑷淬��'));
-                    for(String barcodeListTTT : (List<String>)notEqualBARcodeCunMap.get(widget)) {
+                    for (String barcodeListTTT : (List<String>) notEqualBARcodeCunMap.get(widget)) {
                         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, barcodeListTTT));
                     }
                 }
@@ -2396,68 +3122,77 @@
     }
 
     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){
+        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
+            ) {
                 // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
-                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);
+                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{
+            } else {
                 consumableorderdetailsRecordsUse.add(ass);
             }
-            orderWantArriveCunMap.put(ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c)+1);
+            orderWantArriveCunMap.put(ass.esd.Asset_Model_No__c, orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + 1);
         }
-        for(ConsumableorderdetailsInfo ass : consumableInventory){
+        for (ConsumableorderdetailsInfo ass : consumableInventory) {
             if (!orderWantArriveCunMap.containsKey(ass.Prod.Asset_Model_No__c)) {
                 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);
                 //鏇存柊map
-                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);
+                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{
+            } else {
                 consumableInventoryUse.add(ass);
             }
-            orderWantArriveCunMap.put(ass.Prod.Asset_Model_No__c,orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c)+1);
+            orderWantArriveCunMap.put(ass.Prod.Asset_Model_No__c, orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + 1);
         }
         for (Integer i = 0; i < productList.size(); i++) {
-            if(overOrderBARcodeCunMap.get(productList[i]).size() > 0){
+            if (overOrderBARcodeCunMap.get(productList[i]).size() > 0) {
                 // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
                 overOrderproList.add(productList[i]);
             }
         }
-        if(overOrderproList.size() > 0){
+        if (overOrderproList.size() > 0) {
             return '浜у搧' + overOrderproList + '鏈鍒拌揣鏁伴噺鍜屽凡鍒拌揣鏁伴噺宸茬粡瓒呰繃璁㈣揣鏁伴噺!';
-        }else{
+        } else {
             return '';
         }
-
     }
 
-  public void confimResultWithoutOrder() {
-    /*list<String> overOrderproList = new list<String>();
+    public void confimResultWithoutOrder() {
+        /*list<String> overOrderproList = new list<String>();
         list<String> overOrderBARcodeCunList = new list<String>();
         orderProductCunMap.clear();
         orderProductArrivedCunMap.clear();
@@ -2494,7 +3229,7 @@
         }*/
 
         //瑕佸埌璐т骇鍝佹暟閲�
-        for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords)  {
+        for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords) {
             /*if(orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c) > orderProductCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)-1){
                 // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
                 overOrderproList.add('浜у搧' + ass.esd.Asset_Model_No__c + '鍦ㄨ鍗�' + ass.esd.Consumable_order_minor__r.Name + '涓秴杩囪璐ф暟閲�!\n');
@@ -2506,23 +3241,23 @@
                 consumableorderdetailsRecordsUse.add(ass);
                 orderWantArriveCunMap.put(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)+1);
             }else{*/
-                consumableorderdetailsRecordsUse.add(ass);
-            }
-            /*orderWantArriveCunMap.put(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)+1);
+            consumableorderdetailsRecordsUse.add(ass);
+        }
+        /*orderWantArriveCunMap.put(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)+1);
         }
         return overOrderproList;*/
-  }
+    }
 
     // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
     // 铏氭嫙鐩樼偣鍗曟秷鑰楀搧鏄庣粏1鍒涘缓宸″洖
-    public void addInventoryDetails1(List<Consumable_order_details2__c> addList){
+    public void addInventoryDetails1(List<Consumable_order_details2__c> addList) {
         Map<String, List<Consumable_order_details2__c>> accountGroupMap = new Map<String, List<Consumable_order_details2__c>>();
-        Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>> ();
-        List<Id> orderIdList = new List<Id> ();
+        Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>>();
+        List<Id> orderIdList = new List<Id>();
         // 浠ョ粡閿�鍟嗗悕灏嗚鐢熸垚鍑哄簱鍗曠殑鏁版嵁鍒嗙粍
         for (Consumable_order_details2__c cod : addList) {
-            List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c> ();
-            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
+            List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c>();
+            Map<Id, Integer> pNumMap = new Map<Id, Integer>();
             Integer num = 1;
             if (accountGroupMap.containsKey(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c)) {
                 accGroupList = accountGroupMap.get(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c);
@@ -2531,16 +3266,20 @@
                     num = pNumMap.get(cod.Consumable_Product__c) + 1;
                 }
             }
-            orderIdList.add(cod.Consumable_Inventory_order__c); 
+            orderIdList.add(cod.Consumable_Inventory_order__c);
             pNumMap.put(cod.Consumable_Product__c, num);
             accGroupList.add(cod);
             productMap.put(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c, pNumMap);
             accountGroupMap.put(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c, accGroupList);
-            System.debug('======accGroupList'+accGroupList);
+            System.debug('======accGroupList' + accGroupList);
         }
-        
-        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];
+
+        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
+        ];
 
         // 鐢熸垚鍚勭粡閿�鍟嗗嚭搴撹鍗昄ist
         // List<Consumable_order__c> orderList = new List<Consumable_order__c> ();
@@ -2548,19 +3287,19 @@
         for (String acc : accountGroupMap.keySet()) {
             Consumable_order_details2__c arriveAccount = accountGroupMap.get(acc)[0];
             List<Consumable_order_details2__c> prodPriceList = accountGroupMap.get(acc);
-            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
+            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();
-                
+
                 //InsAfterDel.Consumable_order__c = p.id;
                 ins.Product_Refind__c = pNumMap.get(id);
                 ins.inventory_sum__c = pNumMap.get(id);
                 ins.Consumable_Product__c = id;
                 for (Consumable_order_details2__c pri : prodPriceList) {
                     if (pri.Consumable_Product__c == id) {
-                        ins.Intra_Trade_List_RMB__c =pri.Intra_Trade_List_RMB__c;
+                        ins.Intra_Trade_List_RMB__c = pri.Intra_Trade_List_RMB__c;
                         break;
                     }
                 }
@@ -2575,11 +3314,11 @@
 
                 insDetail1.add(ins);
             }
-            System.debug('======insDetail1'+insDetail1);
+            System.debug('======insDetail1' + insDetail1);
             insDetail1Map.put(acc, insDetail1);
-            System.debug('======insDetail1Map'+insDetail1Map);
+            System.debug('======insDetail1Map' + insDetail1Map);
         }
-        List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c> ();
+        List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c>();
         for (Consumable_order__c setId : orderList) {
             // 鏄庣粏1
             List<Consumable_orderdetails__c> d1list = insDetail1Map.get(setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c);
@@ -2587,24 +3326,23 @@
             for (Consumable_orderdetails__c dtl1 : d1list) {
                 String str = ('000' + i).right(4);
                 dtl1.Consumable_order__c = setId.Id;
-                dtl1.Name = setId.Name + '-'+ str;
+                dtl1.Name = setId.Name + '-' + str;
                 insDetail1List.add(dtl1);
             }
-        } 
-        System.debug('======insDetail1List'+insDetail1List);
+        }
+        System.debug('======insDetail1List' + insDetail1List);
         insert insDetail1List;
     }
     // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
 
-
     // 缁忛攢鍟嗙殑涓嶅悓宸ヤ綔鍦拌皟璐ц嚜鍔ㄧ敓鎴愬嚭搴撳崟
-    public void addSaleOrderAuto (List<Consumable_order_details2__c> addList) {
+    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>>();
-        Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>> ();
+        Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>>();
         // 浠ョ粡閿�鍟嗗悕灏嗚鐢熸垚鍑哄簱鍗曠殑鏁版嵁鍒嗙粍
         for (Consumable_order_details2__c cod : addList) {
-            List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c> ();
-            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
+            List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c>();
+            Map<Id, Integer> pNumMap = new Map<Id, Integer>();
             Integer num = 1;
             if (accountGroupMap.containsKey(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c)) {
                 accGroupList = accountGroupMap.get(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c);
@@ -2612,7 +3350,7 @@
                 if (pNumMap.containsKey(cod.Consumable_Product__c)) {
                     num = pNumMap.get(cod.Consumable_Product__c) + 1;
                 }
-            } 
+            }
             pNumMap.put(cod.Consumable_Product__c, num);
             accGroupList.add(cod);
             productMap.put(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c, pNumMap);
@@ -2620,7 +3358,7 @@
         }
 
         // 鐢熸垚鍚勭粡閿�鍟嗗嚭搴撹鍗昄ist
-        List<Consumable_order__c> orderList = new List<Consumable_order__c> ();
+        List<Consumable_order__c> orderList = new List<Consumable_order__c>();
         Map<String, List<Consumable_orderdetails__c>> insDetail1Map = new Map<String, List<Consumable_orderdetails__c>>();
         for (String acc : accountGroupMap.keySet()) {
             Consumable_order_details2__c arriveAccount = accountGroupMap.get(acc)[0];
@@ -2635,22 +3373,22 @@
             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> ();
+            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();
-                
+
                 //InsAfterDel.Consumable_order__c = p.id;
                 ins.Shipment_Count__c = pNumMap.get(id);
                 ins.Consumable_Product__c = id;
                 for (Consumable_order_details2__c pri : prodPriceList) {
                     if (pri.Consumable_Product__c == id) {
-                        ins.Intra_Trade_List_RMB__c =pri.Intra_Trade_List_RMB__c;
+                        ins.Intra_Trade_List_RMB__c = pri.Intra_Trade_List_RMB__c;
                         break;
                     }
                 }
@@ -2663,23 +3401,23 @@
                 ins.Used_date__c = Date.today();
                 ins.OwnerId = arriveAccount.OwnerId;
 
-        insDetail1.add(ins);
-      }
-      insDetail1Map.put(acc, insDetail1);
-    }
-    insert orderList;
+                insDetail1.add(ins);
+            }
+            insDetail1Map.put(acc, insDetail1);
+        }
+        insert orderList;
 
-        List<Id> orderIdList = new List<Id> ();
+        List<Id> orderIdList = new List<Id>();
         for (Consumable_order__c co : orderList) {
             orderIdList.add(co.Id);
         }
 
-        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 = 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];
 
         // 璁剧疆鏄庣粏1 鍜� 鏄庣粏2 鐨� 璁㈠崟ID
-        List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c> ();
-        List<Consumable_order_details2__c> updDetail2List = new List<Consumable_order_details2__c> ();
+        List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c>();
+        List<Consumable_order_details2__c> updDetail2List = new List<Consumable_order_details2__c>();
         for (Consumable_order__c setId : orderList) {
             // 鏄庣粏1
             List<Consumable_orderdetails__c> d1list = insDetail1Map.get(setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c);
@@ -2690,35 +3428,33 @@
                 //     str = '0' + str;
                 // }
                 dtl1.Consumable_order__c = setId.Id;
-                dtl1.Name = setId.Name + '-'+ str;
+                dtl1.Name = setId.Name + '-' + str;
                 insDetail1List.add(dtl1);
             }
 
-      // 鏄庣粏2
-      List<Consumable_order_details2__c> d2list = accountGroupMap.get(
-        setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c
-      );
-      for (Consumable_order_details2__c dtl2 : d2list) {
-        dtl2.Send_Date__c = Date.today();
-        dtl2.Consumable_Sale_order__c = null;
-        dtl2.Consumable_Return_order__c = null;
-        dtl2.Consumable_ZS_order__c = setId.Id;
-        //dtl2.Delivery_List_RMB__c = null;
-        dtl2.Return_date__c = null;
-        dtl2.Return_reason__c = null;
-        dtl2.Consumable_Shipment_order__c = setId.Id;
-        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-        dtl2.Transfer_Time__c = 1;
-        dtl2.Agency_Transfer__c = true;
-        dtl2.Frist_Transfer_Agency__c = dtl2.Dealer_Info_text__c;
-        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-        updDetail2List.add(dtl2);
-      }
-    }
+            // 鏄庣粏2
+            List<Consumable_order_details2__c> d2list = accountGroupMap.get(setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c);
+            for (Consumable_order_details2__c dtl2 : d2list) {
+                dtl2.Send_Date__c = Date.today();
+                dtl2.Consumable_Sale_order__c = null;
+                dtl2.Consumable_Return_order__c = null;
+                dtl2.Consumable_ZS_order__c = setId.Id;
+                //dtl2.Delivery_List_RMB__c = null;
+                dtl2.Return_date__c = null;
+                dtl2.Return_reason__c = null;
+                dtl2.Consumable_Shipment_order__c = setId.Id;
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                dtl2.Transfer_Time__c = 1;
+                dtl2.Agency_Transfer__c = true;
+                dtl2.Frist_Transfer_Agency__c = dtl2.Dealer_Info_text__c;
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+                updDetail2List.add(dtl2);
+            }
+        }
 
-    insert insDetail1List;
-    update updDetail2List;
-  }
+        insert insDetail1List;
+        update updDetail2List;
+    }
 
     //鍒拌揣纭
     public PageReference ArriveGoodsConfim() {
@@ -2726,82 +3462,91 @@
         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();
 
-        if(ConsumableorderdetailsRecords.size()<1 && consumableInventory.size()<1){
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'涓嶅瓨鍦ㄥ埌璐ф槑缁�'));
+        if (ConsumableorderdetailsRecords.size() < 1 && consumableInventory.size() < 1) {
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '涓嶅瓨鍦ㄥ埌璐ф槑缁�'));
             return null;
         }
-        if(EsetId != null && EsetId != ''){
+        if (EsetId != null && EsetId != '') {
             resultcheck = ConfimResult();
-            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() +'涓璐х殑鏁伴噺銆�'));
-                        for(String barcodeListTTT : (List<String>)overOrderBARcodeCunMap.get(widget)) {
+            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() + '涓璐х殑鏁伴噺銆�'
+                            )
+                        );
+                        for (String barcodeListTTT : (List<String>) overOrderBARcodeCunMap.get(widget)) {
                             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, barcodeListTTT));
                         }
                     }
                 }
             }
-        }else{
+        } else {
             confimResultWithoutOrder();
         }
-        try{
+        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>();
             //鍒拌揣姝g‘淇℃伅
-            orderMain.Name            = '*';
+            orderMain.Name = '*';
             orderMain.Order_status__c = '鎵瑰噯';
-            orderMain.Dealer_Info__c  = accountid;
+            orderMain.Dealer_Info__c = accountid;
             orderMain.Deliver_date__c = Date.today();
-            orderMain.Order_date__c   = Date.today();
-            orderMain.Order_type__c   = '鍒拌揣';
+            orderMain.Order_date__c = Date.today();
+            orderMain.Order_type__c = '鍒拌揣';
             orderMain.Order_ProType__c = userPro_Type;
-            if(EsetId != null && EsetId != ''){
+            if (EsetId != null && EsetId != '') {
                 orderMain.Arrive_Order__c = coc.Id;
             }
             orderMain.RecordTypeid = System.Label.RT_ConOrder_Arrive;
             insert orderMain;
 
-            List<Consumable_order__c> consumable_order = [SELECT Name FROM Consumable_order__c WHERE id =:orderMain.id];
+            List<Consumable_order__c> consumable_order = [SELECT Name FROM Consumable_order__c WHERE id = :orderMain.id];
             arriveId = orderMain.id;
-            Decimal arriveAmount =0;
-            for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsUse)  {
+            Decimal arriveAmount = 0;
+            for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsUse) {
                 Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
-                insDetails.Id                           = ass.esd.Id;
-                insDetails.Consumable_Arrived_order__c  = orderMain.id;
-                insDetails.Arrive_date__c               = Date.today();
-                insDetails.Bar_Code__c                  = ass.esd.Bar_Code__c;
-                insDetails.OwnerId                      = UserInfo.getUserId();
+                insDetails.Id = ass.esd.Id;
+                insDetails.Consumable_Arrived_order__c = orderMain.id;
+                insDetails.Arrive_date__c = Date.today();
+                insDetails.Bar_Code__c = ass.esd.Bar_Code__c;
+                insDetails.OwnerId = UserInfo.getUserId();
                 // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
                 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;
+                arriveAmount += ass.esd.Intra_Trade_List_RMB__c;
                 orderdetails.add(insDetails);
             }
             Integer i = 1;
-            for(ConsumableorderdetailsInfo ass : consumableInventoryUse){
+            for (ConsumableorderdetailsInfo ass : consumableInventoryUse) {
                 //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------2------'));
                 Consumable_order_details2__c insAfterDel = new Consumable_order_details2__c();
                 String str = ('000' + i).right(4);
                 // if(str.length() == 1){
                 //     str = '0' + str;
                 // }
-                insAfterDel.Name                        = consumable_order[0].Name + '-'+ str;
-                insAfterDel.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
+                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;
@@ -2810,62 +3555,65 @@
                 // }
                 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;
+                insAfterDel.Asset_Model_No__c = ass.Prod.Asset_Model_No__c;
+                if (EsetId != null && EsetId != '') {
+                    insAfterDel.Consumable_order_minor__c = ESetId;
                 }
-                insAfterDel.Deliver_date__c             = Date.today();
-                insAfterDel.Direct_Arrive_Product__c    = true;
+                insAfterDel.Deliver_date__c = Date.today();
+                insAfterDel.Direct_Arrive_Product__c = true;
                 //TODO寰呯‘璁�
-                insAfterDel.Sterilization_limit__c      = ass.sterilizationlimitDate;
-                insAfterDel.Consumable_Product__c       = ass.Prod.id;
-                insAfterDel.Bar_Code__c                 = ass.barCodeNo;
-                insAfterDel.Used_account__c             = accountid;
+                insAfterDel.Sterilization_limit__c = ass.sterilizationlimitDate;
+                insAfterDel.Consumable_Product__c = ass.Prod.id;
+                insAfterDel.Bar_Code__c = ass.barCodeNo;
+                insAfterDel.Used_account__c = accountid;
                 //TODO寰呯‘璁�
-                insAfterDel.SerialLotNo__c              = ass.serialNoorLotNo;
-                insAfterDel.TracingCode__c              = ass.tracingCodeNo;
+                insAfterDel.SerialLotNo__c = ass.serialNoorLotNo;
+                insAfterDel.TracingCode__c = ass.tracingCodeNo;
 
                 //insAfterDel.Dealer_Arrive__c                = true;
                 insAfterDel.Consumable_Arrived_order__c = orderMain.id;
-                insAfterDel.Arrive_date__c              = Date.today();
-                insAfterDel.OwnerId                      = UserInfo.getUserId();
+                insAfterDel.Arrive_date__c = Date.today();
+                insAfterDel.OwnerId = UserInfo.getUserId();
                 // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
                 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
                 //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;
-                }else {
-                    insAfterDel.ContractNo_text__c= ass.esd.Consumable_order_minor__r.ContractNo__c;
+                    insAfterDel.ContractNo_text__c = ass.esd.ContractNo_text__c;
+                } else {
+                    insAfterDel.ContractNo_text__c = ass.esd.Consumable_order_minor__r.ContractNo__c;
                 }
                 // tcm end
                 //add by rentx 2020-10-14 end
                 i++;
 
                 ins.add(insAfterDel);
-
             }
             orderMain.Arrive_total_amount__c = arriveAmount;
             update orderMain;
             List<Consumable_order_details2__c> updateconsumableorderdetails2 = new List<Consumable_order_details2__c>();
             //鏇存柊鏄庣粏鍙栨秷鏃堕棿 => 鏈埌璐у彇娑堬紝鍒拌揣鑷姩鐢熸垚鍑哄簱娴佺▼
-            List<Consumable_order_details2__c> addSaleOrderList = new List<Consumable_order_details2__c> ();
-            for(Consumable_order_details2__c Cod : consumableorderdetails2Cancle){
+            List<Consumable_order_details2__c> addSaleOrderList = new List<Consumable_order_details2__c>();
+            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 {
@@ -2875,26 +3623,26 @@
                 }
             }
 
-      if (addSaleOrderList.size() > 0) {
-        addSaleOrderAuto(addSaleOrderList);
-      }
+            if (addSaleOrderList.size() > 0) {
+                addSaleOrderAuto(addSaleOrderList);
+            }
 
-            if(updateconsumableorderdetails2.size() > 0){
+            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){
+            for (Consumable_order_details2__c Cod2 : consumableorderdetails2Insert) {
                 //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4------'));
                 String str = ('000' + i).right(4);
                 // if(str.length() == 1){
                 //     str = '0' + str;
                 // }
-                Cod2.Name                        = consumable_order[0].Name + '-'+ str;
-                Cod2.Consumable_order_minor__c   = null;
-                Cod2.Deliver_date__c             = Date.today();
-                Cod2.Used_account__c             = accountid;
+                Cod2.Name = consumable_order[0].Name + '-' + str;
+                Cod2.Consumable_order_minor__c = null;
+                Cod2.Deliver_date__c = Date.today();
+                Cod2.Used_account__c = accountid;
                 Cod2.Consumable_Arrived_order__c = orderMain.id;
-                Cod2.Arrive_date__c              = Date.today();
+                Cod2.Arrive_date__c = Date.today();
                 // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
                 if (orderdetails2trMap.containsKey(Cod2.Bar_Code__c)) {
                     //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4++++++' + Cod2.Frist_Storage_Agency__c));
@@ -2903,11 +3651,11 @@
                     Cod2.Frist_Transfer_Agency__c = Cod2.Frist_Transfer_Agency__c == null ? accountName : Cod2.Frist_Transfer_Agency__c;
                 }
                 // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                 
+
                 // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                Cod2.Agencyinfo_fromSAP__c        = Cod2.Agencyinfo_fromSAP__c;
+                Cod2.Agencyinfo_fromSAP__c = Cod2.Agencyinfo_fromSAP__c;
                 //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4------' + Cod2.Frist_Storage_Agency__c));
-                Cod2.Frist_Storage_Agency__c      = Cod2.Frist_Storage_Agency__c == null ? accountName : Cod2.Frist_Storage_Agency__c;
+                Cod2.Frist_Storage_Agency__c = Cod2.Frist_Storage_Agency__c == null ? accountName : Cod2.Frist_Storage_Agency__c;
                 // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
                 insertconsumableorderdetails2.add(Cod2);
                 i++;
@@ -2915,340 +3663,386 @@
 
             // return null;
 
-            if(insertconsumableorderdetails2.size() >0){
+            if (insertconsumableorderdetails2.size() > 0) {
                 insert insertconsumableorderdetails2;
             }
 
-            if(ins.size()>0){
+            if (ins.size() > 0) {
                 insert ins;
             }
-            if(orderdetails.size()>0){
+            if (orderdetails.size() > 0) {
                 ControllerUtil.updateOrderDetailsSatus(orderdetails);
             }
             //瓒呭嚭鍒拌揣鏁伴噺浜у搧鍙栨秷鏃ユ湡鏇存柊
             List<Consumable_order_details2__c> needcanceldet = new List<Consumable_order_details2__c>();
-            if(cancellationProList.size() > 0){
-                needcanceldet = [SELECT Id,
-                                    Cancellation_Date__c
-                                FROM Consumable_order_details2__c
-                                WHERE Asset_Model_No__c in :cancellationProList
-                                AND Consumable_order_minor__c = :ESetId
-                                AND Dealer_Arrive__c = FALSE
-                                AND Cancellation_Date__c = null ];
-                if(needcanceldet.size() >0){
-                    for(Integer a = 0; a < needcanceldet.size(); a++){
+            if (cancellationProList.size() > 0) {
+                needcanceldet = [
+                    SELECT Id, Cancellation_Date__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Asset_Model_No__c IN :cancellationProList
+                        AND Consumable_order_minor__c = :ESetId
+                        AND Dealer_Arrive__c = FALSE
+                        AND Cancellation_Date__c = NULL
+                ];
+                if (needcanceldet.size() > 0) {
+                    for (Integer a = 0; a < needcanceldet.size(); a++) {
                         needcanceldet[a].Cancellation_Date__c = Date.today();
                         needcanceldet[a].Cancellation_Flag__c = true;
                     }
                     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
-                    FROM Consumable_order__c
-                    WHERE Id =:ESetId
-                    AND Dealer_Info__c = :accountid];
-            if (qs.size()>0){
+            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
+            ];
+            if (qs.size() > 0) {
                 coc = qs[0];
             }
             saveFLGbln = true;
             alertMessage = '鍒拌揣瀹屾垚銆�';
             // Integer a = 1/0;
-        }catch(Exception e){
+        } catch (Exception e) {
             Database.rollback(sp);
             ApexPages.addMessages(e);
             return null;
         }
-        if(resultcheck.length() > 0){
+        if (resultcheck.length() > 0) {
             return null;
-        }else if(resultcheckWithoutOrder.size() >0){
+        } else if (resultcheckWithoutOrder.size() > 0) {
             return null;
-        } else{
+        } else {
             return UnabletoEdit();
             // return null;
         }
     }
-    
+
     // 杩斿搧妫�鏌ワ紝鍚庡洖搴�
-    public integer GoodsReturnCheck(){
-        List<String> GrListIn  =   ParseBarCode(   barcode );
+    public integer GoodsReturnCheck() {
+        List<String> GrListIn = ParseBarCode(barcode);
         GrList = new List<String>();
-        Map<String,String>  CheckBarcodeResult  =   new Map<String,String>();
-        for(    String  Str :   GrListIn  ){
-            CheckBarcodeResult.put( str , 'UnFind');
+        Map<String, String> CheckBarcodeResult = new Map<String, String>();
+        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
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,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
-                                    //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
-                                  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     Arrive_Owner_Work_Location__c =: userWorkLocation
-                    ORDER BY Box_Piece__c desc,Name ];
-        if(BarcodeRetrunResult.size()>0){
+        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*/,
+                // tcm start
+                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
+                //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
+                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 Arrive_Owner_Work_Location__c = :userWorkLocation
+            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{
-                    String str = '浜у搧绫诲瀷['+BarcodeRetrunResult[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(BarcodeRetrunResult[i],str));
-                    ErrorIdMap.put(BarcodeRetrunResult[i].Bar_Code__c,BarcodeRetrunResult[i].Bar_Code__c);
+                } else {
+                    String str = '浜у搧绫诲瀷[' + BarcodeRetrunResult[i].Product_Type__c + ']涓庣敤鎴风殑绫诲瀷[' + userPro_Type + ']涓嶇';
+                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(BarcodeRetrunResult[i], str));
+                    ErrorIdMap.put(BarcodeRetrunResult[i].Bar_Code__c, BarcodeRetrunResult[i].Bar_Code__c);
                 }
             }
         }
         AllMap.putAll(ErrorIdMap);
-        BarcodeRetrunResult =
-                 [  SELECT  Id,
-                            Consumable_order_minor__c,
-                            Deliver_date__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Name,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Dealer_Shipment__c,
-                            Lose_Flag__c,
-                            Dealer_Saled__c,
-                            Return_reason__c,
-                            Consumable_Shipment_order__c,
-                            Consumable_Shipment_order__r.Name,
-                            Send_date__c,
-                            Consumable_Sale_order__c,
-                            Consumable_Sale_order__r.Name,
-                            Used_date__c,
-                            SerialLotNo__c,
-                            TracingCode__c,
-                            Sterilization_limit__c,
-                            Consumable_ZS_order__c,
-                            Consumable_ZS_order__r.Name,
-                            Product_OutDate__c,
-                            Invoice_Date__c,
-                            recordtypeid,
-                            Consumable_Arrived_order__c,
-                            Box_Piece__c,
-                            Rrturn_count__c,
-                            Intra_Trade_List_RMB__c,
-                            OwnerId,
-                            SummonsForDirction_det__c,
-                            Order_Dealer_Info__c,
-                            HospItal_Name__c,
-                            Agencyinfo_fromSAP__c,
-                            Frist_Storage_Agency__c,
-                            Dealer_Info_text__c,
-                            Used_account__c,
-                            Transfer_Time__c,
-                            Frist_Transfer_Agency__c,
-                            Arrive_Owner_Work_Location__c,
-                            Agency_Transfer__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,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
-                                    //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
-                                  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)
-                                  // 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     (Arrive_Owner_Work_Location__c =: userWorkLocation
-                        OR OwnerId = :System.Label.User_OlympusSystem)
-                    ORDER BY Box_Piece__c desc,Name ];
-        ShowGoodsofReturnList   =   new List<ConsumableorderdetailsInfo>();
+        BarcodeRetrunResult = [
+            SELECT
+                Id,
+                Consumable_order_minor__c,
+                Deliver_date__c,
+                Asset_Model_No__c,
+                Consumable_Product__c,
+                Consumable_Product__r.Name,
+                Consumable_Product__r.Name__c,
+                Name,
+                Bar_Code__c,
+                Arrive_date__c,
+                Dealer_Shipment__c,
+                Lose_Flag__c,
+                Dealer_Saled__c,
+                Return_reason__c,
+                Consumable_Shipment_order__c,
+                Consumable_Shipment_order__r.Name,
+                Send_date__c,
+                Consumable_Sale_order__c,
+                Consumable_Sale_order__r.Name,
+                Used_date__c,
+                SerialLotNo__c,
+                TracingCode__c,
+                Sterilization_limit__c,
+                Consumable_ZS_order__c,
+                Consumable_ZS_order__r.Name,
+                Product_OutDate__c,
+                Invoice_Date__c,
+                recordtypeid,
+                Consumable_Arrived_order__c,
+                Box_Piece__c,
+                Rrturn_count__c,
+                Intra_Trade_List_RMB__c,
+                OwnerId,
+                SummonsForDirction_det__c,
+                Order_Dealer_Info__c,
+                HospItal_Name__c,
+                Agencyinfo_fromSAP__c,
+                Frist_Storage_Agency__c,
+                Dealer_Info_text__c,
+                Used_account__c,
+                Transfer_Time__c,
+                Frist_Transfer_Agency__c,
+                Arrive_Owner_Work_Location__c,
+                Agency_Transfer__c,
+                //add by rentx 2020-10-14 start
+                ContractNo_text__c /*,ContractNo__c*/,
+                // tcm start
+                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
+                //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
+                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))
+                // 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 (Arrive_Owner_Work_Location__c = :userWorkLocation
+                OR OwnerId = :System.Label.User_OlympusSystem)
+            ORDER BY Box_Piece__c DESC, Name
+        ];
+        ShowGoodsofReturnList = new List<ConsumableorderdetailsInfo>();
 
         //杩斿搧鏃秈stinct澶勭悊
-        if(ArrType=='ReG'){
+        if (ArrType == 'ReG') {
             BarcodeRetrunResult = getDistinctZSOrder(BarcodeRetrunResult);
         }
 
-        for(    Consumable_order_details2__c codc    :   BarcodeRetrunResult ){
-            if(ErrorIdMap.containsKey(codc.Bar_Code__c) || ExistIdMap.containsKey(codc.Bar_Code__c)){
+        for (Consumable_order_details2__c codc : BarcodeRetrunResult) {
+            if (ErrorIdMap.containsKey(codc.Bar_Code__c) || ExistIdMap.containsKey(codc.Bar_Code__c)) {
                 // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
                 continue;
-            }else{
-
+            } else {
                 Matcher n = Pattern.compile('[0-9]').matcher(codc.TracingCode__c);
-                if(n.find()){
+                if (n.find()) {
                     String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(codc,str));
-                    ErrorIdMap.put(codc.Bar_Code__c,codc.Bar_Code__c);
+                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(codc, str));
+                    ErrorIdMap.put(codc.Bar_Code__c, codc.Bar_Code__c);
                     continue;
                 }
-                if( CheckBarcodeResult.containsKey( codc.Bar_Code__c    )){
+                if (CheckBarcodeResult.containsKey(codc.Bar_Code__c)) {
                     GrList.add(codc.Bar_Code__c);
-                    if( codc.Dealer_Shipment__c ==  true){
-                        CheckBarcodeResult.put( codc.Bar_Code__c,   '宸插嚭搴�'   );
-                        ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
+                    if (codc.Dealer_Shipment__c == true) {
+                        CheckBarcodeResult.put(codc.Bar_Code__c, '宸插嚭搴�');
+                        ShowGoodsofReturnList.add(new ConsumableorderdetailsInfo(codc));
                     }
                     // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
                     // else{
                     //     CheckBarcodeResult.put( codc.Bar_Code__c, '宸查攢鍞�');
                     //     ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
                     // }
-                    else if( codc.Dealer_Saled__c == true ){
-                        CheckBarcodeResult.put( codc.Bar_Code__c, '宸查攢鍞�');
-                        ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
-                    }else{
-                        CheckBarcodeResult.put( codc.Bar_Code__c, '宸蹭涪澶�');
-                        ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
+                    else if (codc.Dealer_Saled__c == true) {
+                        CheckBarcodeResult.put(codc.Bar_Code__c, '宸查攢鍞�');
+                        ShowGoodsofReturnList.add(new ConsumableorderdetailsInfo(codc));
+                    } else {
+                        CheckBarcodeResult.put(codc.Bar_Code__c, '宸蹭涪澶�');
+                        ShowGoodsofReturnList.add(new ConsumableorderdetailsInfo(codc));
                     }
                     // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                }else{
+                } else {
                     continue;
                 }
             }
         }
 
-    return BarcodeRetrunResult.size();
-  }
+        return BarcodeRetrunResult.size();
+    }
 
     // 鍗曚綅涓轰釜鐨凚arcode瀵瑰簲鐨勫嚭搴撳崟
-    public integer Getconsumableorderdetails2Nobox(){
+    public integer Getconsumableorderdetails2Nobox() {
         consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
         BarcodeCntMap.clear();
-        consumableorderdetails2Nobox =
-                 [  SELECT  Id,
-                            Consumable_order_minor__c,
-                            Deliver_date__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Name,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Dealer_Shipment__c,
-                            Dealer_Saled__c,
-                            Return_reason__c,
-                            Consumable_Shipment_order__c,
-                            Send_date__c,
-                            Consumable_Sale_order__c,
-                            Used_date__c,
-                            SerialLotNo__c,
-                            TracingCode__c,
-                            Sterilization_limit__c,
-                            Consumable_ZS_order__c,
-                            Consumable_ZS_order__r.Name,
-                            Product_OutDate__c,
-                            Invoice_Date__c,
-                            recordtypeid,
-                            Consumable_Arrived_order__c,
-                            Box_Piece__c,
-                            RemoveBox_No__c,
-                            RemoveBox_date__c,
-                            Rrturn_count__c,
-                            Dealer_Info_text__c,
-                            Arrive_Owner_Work_Location__c,
-                            Intra_Trade_List_RMB__c
-                            //add by rentx 2020-10-13 start 杩斿搧鏃� 鏂版暟鎹褰昐AP鍚堝悓鍙�
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                             // 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
-                            // (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))
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                    AND     Dealer_Info_text__c = :accountName
-                    AND     Bar_Code__c in :noboxBarcodeList
-                    AND     Arrive_Owner_Work_Location__c =: userWorkLocation
-                    AND     Dealer_Returned__c = false
-                    AND     Box_Piece__c = '涓�'
-                    ORDER BY Consumable_ZS_order__c,RemoveBox_No__c];
+        consumableorderdetails2Nobox = [
+            SELECT
+                Id,
+                Consumable_order_minor__c,
+                Deliver_date__c,
+                Asset_Model_No__c,
+                Consumable_Product__c,
+                Consumable_Product__r.Name,
+                Consumable_Product__r.Name__c,
+                Name,
+                Bar_Code__c,
+                Arrive_date__c,
+                Dealer_Shipment__c,
+                Dealer_Saled__c,
+                Return_reason__c,
+                Consumable_Shipment_order__c,
+                Send_date__c,
+                Consumable_Sale_order__c,
+                Used_date__c,
+                SerialLotNo__c,
+                TracingCode__c,
+                Sterilization_limit__c,
+                Consumable_ZS_order__c,
+                Consumable_ZS_order__r.Name,
+                Product_OutDate__c,
+                Invoice_Date__c,
+                recordtypeid,
+                Consumable_Arrived_order__c,
+                Box_Piece__c,
+                RemoveBox_No__c,
+                RemoveBox_date__c,
+                Rrturn_count__c,
+                Dealer_Info_text__c,
+                Arrive_Owner_Work_Location__c,
+                Intra_Trade_List_RMB__c,
+                //add by rentx 2020-10-13 start 杩斿搧鏃� 鏂版暟鎹褰昐AP鍚堝悓鍙�
+                ContractNo_text__c /*,ContractNo__c*/,
+                // 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
+                // (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))
+                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+                AND Dealer_Info_text__c = :accountName
+                AND Bar_Code__c IN :noboxBarcodeList
+                AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                AND Dealer_Returned__c = FALSE
+                AND Box_Piece__c = '涓�'
+            ORDER BY Consumable_ZS_order__c, RemoveBox_No__c
+        ];
 
-         AggregateResult[] results = [SELECT  Consumable_ZS_order__c,Bar_Code__c,count(Id) recordCount 
-                                      FROM Consumable_order_details2__c 
-                                      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))
-                                      // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                                      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];
+        AggregateResult[] results = [
+            SELECT Consumable_ZS_order__c, Bar_Code__c, count(Id) recordCount
+            FROM Consumable_order_details2__c
+            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))
+                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+                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
+        ];
 
-        for(AggregateResult ar: results){               
+        for (AggregateResult ar : results) {
             String key = '' + ar.get('Consumable_ZS_order__c') + ar.get('Bar_Code__c');
             BarcodeCntMap.put(key, Integer.valueOf(ar.get('recordCount')));
         }
-                                         
+
         return consumableorderdetails2Nobox.size();
     }
 
     //distinct
-    public List<Consumable_order_details2__c>  getDistinctZSOrder(List<Consumable_order_details2__c>  duplicates){
-        List<Consumable_order_details2__c>  distinctOrder = new List<Consumable_order_details2__c>();
-        
-        for(Consumable_order_details2__c details2 : duplicates){
+    public List<Consumable_order_details2__c> getDistinctZSOrder(List<Consumable_order_details2__c> duplicates) {
+        List<Consumable_order_details2__c> distinctOrder = new List<Consumable_order_details2__c>();
+
+        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){
+            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) {
                     found = true;
                     break;
                 }
             }
 
-            if(!found){
+            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;
     }
 
-        // Update杩斿搧鏄庣粏淇℃伅
-    public Pagereference UpdateGoodsOfReturn(){
-        if( ShowGoodsofReturnList==null){
+    // Update杩斿搧鏄庣粏淇℃伅
+    public Pagereference UpdateGoodsOfReturn() {
+        if (ShowGoodsofReturnList == null) {
             GoodsReturnCheck();
         }
         Getconsumableorderdetails2Nobox();
@@ -3256,260 +4050,277 @@
         Savepoint sp = Database.setSavepoint();
         boolean hasReturnGoods = false;
         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         = '鎵瑰噯';
+        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 = '鎵瑰噯';
                 Return_Order_Sheet.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
                 Return_Order_Sheet.ReturnGs_Upload_Date__c = Date.today();
-                Return_Order_Sheet.Order_type__c           = '杩斿搧';
-                Return_Order_Sheet.RecordTypeid            =System.Label.Dealer_Returned_Label;
-                Return_Order_Sheet.Order_ProType__c        = userPro_Type;
+                Return_Order_Sheet.Order_type__c = '杩斿搧';
+                Return_Order_Sheet.RecordTypeid = System.Label.Dealer_Returned_Label;
+                Return_Order_Sheet.Order_ProType__c = userPro_Type;
                 insert Return_Order_Sheet;
                 return_Order_id = Return_Order_Sheet.id;
-                List<Consumable_order__c> consumable_order_ret = [SELECT Name FROM Consumable_order__c WHERE id =:Return_Order_Sheet.id];
-                
+                List<Consumable_order__c> consumable_order_ret = [SELECT Name FROM Consumable_order__c WHERE id = :Return_Order_Sheet.id];
+
                 //2017-07-03 鍒拌揣璁㈠崟
-                Consumable_order__c Arrived_Order_Sheet     = new Consumable_order__c();
-                Arrived_Order_Sheet.Name                    ='*';
-                Arrived_Order_Sheet.Order_status__c         = '鎵瑰噯';
-                Arrived_Order_Sheet.Order_type__c           = '鍒拌揣';
-                Arrived_Order_Sheet.Dealer_Info__c          =accountid;
-                Arrived_Order_Sheet.RecordTypeid            =System.Label.RT_ConOrder_Arrive;
-                Arrived_Order_Sheet.Order_ProType__c        = userPro_Type;
+                Consumable_order__c Arrived_Order_Sheet = new Consumable_order__c();
+                Arrived_Order_Sheet.Name = '*';
+                Arrived_Order_Sheet.Order_status__c = '鎵瑰噯';
+                Arrived_Order_Sheet.Order_type__c = '鍒拌揣';
+                Arrived_Order_Sheet.Dealer_Info__c = accountid;
+                Arrived_Order_Sheet.RecordTypeid = System.Label.RT_ConOrder_Arrive;
+                Arrived_Order_Sheet.Order_ProType__c = userPro_Type;
                 insert Arrived_Order_Sheet;
-                List<Consumable_order__c> consumable_order_arr = [SELECT Name FROM Consumable_order__c WHERE id =:Arrived_Order_Sheet.id];
+                List<Consumable_order__c> consumable_order_arr = [SELECT Name FROM Consumable_order__c WHERE id = :Arrived_Order_Sheet.id];
 
                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
                 // 铏氭嫙鐩樼偣鍗�
-                Consumable_order__c Inventory_Order_Sheet     = new Consumable_order__c();
-                Inventory_Order_Sheet.Name                    ='*';
-                Inventory_Order_Sheet.Order_status__c         = '鎵瑰噯';
+                Consumable_order__c Inventory_Order_Sheet = new Consumable_order__c();
+                Inventory_Order_Sheet.Name = '*';
+                Inventory_Order_Sheet.Order_status__c = '鎵瑰噯';
                 Inventory_Order_Sheet.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
-                Inventory_Order_Sheet.Inventory_date__c       = Date.today();
-                Inventory_Order_Sheet.Dealer_Info__c          =accountid;
+                Inventory_Order_Sheet.Inventory_date__c = Date.today();
+                Inventory_Order_Sheet.Dealer_Info__c = accountid;
                 Inventory_Order_Sheet.ReturnGs_Upload_Date__c = Date.today();
-                Inventory_Order_Sheet.Order_type__c           = '鐩樼偣';
-                Inventory_Order_Sheet.RecordTypeid            = System.Label.RT_ConOrder_Inventory;
-                Inventory_Order_Sheet.Order_ProType__c        = userPro_Type;
+                Inventory_Order_Sheet.Order_type__c = '鐩樼偣';
+                Inventory_Order_Sheet.RecordTypeid = System.Label.RT_ConOrder_Inventory;
+                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>();
+                List<Consumable_order_details2__c> codcList = new List<Consumable_order_details2__c>();
                 //鏂拌杩斿搧瀵瑰簲鐨勪骇鍝佹槑缁�
-                List<Consumable_order_details2__c>   codcorderdetList    =   new List<Consumable_order_details2__c>();
+                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 || 
-                        String.valueof(codi.esd.Rrturn_count__c) =='' || 
-                        codi.esd.Rrturn_count__c <= 0)){
+                for (ConsumableorderdetailsInfo codi : ShowGoodsofReturnList) {
+                    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)
+                    ) {
                         continue;
                     }
 
-                    if(codi.esd.Return_reason__c==null||codi.esd.Return_reason__c==''){
+                    if (codi.esd.Return_reason__c == null || codi.esd.Return_reason__c == '') {
                         codi.esd.Return_reason__c.addError('璇疯ˉ鍏呰繑鍝佸師鍥�');
                         return null;
                     }
 
-
-                    if(codi.esd.Box_Piece__c=='涓�' && codi.esd.Rrturn_count__c > 0){
+                    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;
                         Integer deliverycnt = BarcodeCntMap.get(key);
-                        if(codi.esd.Rrturn_count__c > deliverycnt){
+                        if (codi.esd.Rrturn_count__c > deliverycnt) {
                             codi.esd.Rrturn_count__c.addError('瓒呭嚭鍑哄簱鏁伴噺');
                             return null;
-                        }  
+                        }
                     }
                 }
 
-                Integer tempNo=0;
+                Integer tempNo = 0;
                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
                 List<Consumable_order_details2__c> conOrderDetail2InList = new List<Consumable_order_details2__c>();
                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                for( ConsumableorderdetailsInfo  codi    :   ShowGoodsofReturnList ){
+                for (ConsumableorderdetailsInfo codi : ShowGoodsofReturnList) {
                     Consumable_order_details2__c codcorderdet = new Consumable_order_details2__c();
-                    
+
                     //鍗曚綅=涓�
-                    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)){
+                    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)
+                    ) {
                         continue;
                     }
 
-                    if(codi.esd.Box_Piece__c=='涓�' && codi.esd.Rrturn_count__c > 0){
+                    if (codi.esd.Box_Piece__c == '涓�' && codi.esd.Rrturn_count__c > 0) {
                         hasReturnGoods = true;
 
                         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){
+                        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
+                            ) {
                                 Consumable_order_details2__c esd = codctmp;
                                 // esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
-                                esd.Return_reason__c                = codi.esd.Return_reason__c;
-                                esd.Return_date__c                  = Date.today();
+                                esd.Return_reason__c = codi.esd.Return_reason__c;
+                                esd.Return_date__c = Date.today();
                                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
                                 // 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;
-                                    
+                                    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();
-                                
+                                esd.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
+
                                 //淇敼杩斿搧鎵�鏈変汉
-                                esd.OwnerId                         = UserInfo.getUserId();
-                                esd.RecordTypeId                    = System.Label.RT_ConOrderDetail2_Return;
-                               
+                                esd.OwnerId = UserInfo.getUserId();
+                                esd.RecordTypeId = System.Label.RT_ConOrderDetail2_Return;
+
                                 //Consumable_order__c coc = [select name from Consumable_order__c where Id =:Arrived_Order_Sheet.id];
                                 codcorderdet = new Consumable_order_details2__c();
-                                codcorderdet.Name                        = consumable_order_arr[0].name + '-' + String.valueOf(++tempNo).leftPad(4,'0');
-                                codcorderdet.Consumable_order_minor__c   = codi.esd.Consumable_order_minor__c;
+                                codcorderdet.Name = consumable_order_arr[0].name + '-' + String.valueOf(++tempNo).leftPad(4, '0');
+                                codcorderdet.Consumable_order_minor__c = codi.esd.Consumable_order_minor__c;
                                 codcorderdet.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
                                 //淇敼鍒拌揣鎵�鏈変汉
-                                codcorderdet.OwnerId                     = UserInfo.getUserId();
-                                codcorderdet.Arrive_date__c              = Date.today();
-                                codcorderdet.Consumable_Product__c       = codi.esd.Consumable_Product__c;
-                                codcorderdet.Asset_Model_No__c           = codi.esd.Asset_Model_No__c;
-                                codcorderdet.Bar_Code__c                 = codi.esd.Bar_Code__c;
-                                codcorderdet.Deliver_date__c             = codi.esd.Deliver_date__c;
-                                codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
-                                codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
-                                codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
+                                codcorderdet.OwnerId = UserInfo.getUserId();
+                                codcorderdet.Arrive_date__c = Date.today();
+                                codcorderdet.Consumable_Product__c = codi.esd.Consumable_Product__c;
+                                codcorderdet.Asset_Model_No__c = codi.esd.Asset_Model_No__c;
+                                codcorderdet.Bar_Code__c = codi.esd.Bar_Code__c;
+                                codcorderdet.Deliver_date__c = codi.esd.Deliver_date__c;
+                                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.RemoveBox_No__c             = codctmp.RemoveBox_No__c;
-                                codcorderdet.RemoveBox_date__c           = codctmp.RemoveBox_date__c;
-                                codcorderdet.Box_Piece__c                = codctmp.Box_Piece__c;
+                                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;
 
                                 //add by rentx 2020-10-13 start 杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
                                 // codcorderdet.ContractNo_text__c= codctmp.ContractNo__c;
                                 // tcm start
                                 if (String.isBlank(codctmp.Consumable_order_minor__r.ContractNo__c)) {
-                                    codcorderdet.ContractNo_text__c= codctmp.ContractNo_text__c;
-                                }else {
-                                    codcorderdet.ContractNo_text__c= codctmp.Consumable_order_minor__r.ContractNo__c;
+                                    codcorderdet.ContractNo_text__c = codctmp.ContractNo_text__c;
+                                } else {
+                                    codcorderdet.ContractNo_text__c = codctmp.Consumable_order_minor__r.ContractNo__c;
                                 }
                                 // tcm end
                                 //add by rentx 2020-10-13 end   杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
 
-
                                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                                if(hasLoseGoods){
+                                if (hasLoseGoods) {
                                     codcorderdet.loseInventory__c = true;
                                 }
                                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                                 
+
                                 // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
                                 // 杩斿搧鏃讹紝鈶犺拷鍔犲�熻皟鍊熷嚭鏂逛俊鎭� 鈶′繚鐣欏�熻皟淇℃伅 鈶繚瀛楽AP鍜岀粡閿�鍟嗛娆″彂璐х粡閿�鍟�
-                                codcorderdet.Used_account__c             = codi.esd.Used_account__c;
-                                codcorderdet.Transfer_Time__c            = codi.esd.Transfer_Time__c;
-                                codcorderdet.Frist_Transfer_Agency__c    = codi.esd.Frist_Transfer_Agency__c;
-                                codcorderdet.Agency_Transfer__c          = codi.esd.Agency_Transfer__c;
+                                codcorderdet.Used_account__c = codi.esd.Used_account__c;
+                                codcorderdet.Transfer_Time__c = codi.esd.Transfer_Time__c;
+                                codcorderdet.Frist_Transfer_Agency__c = codi.esd.Frist_Transfer_Agency__c;
+                                codcorderdet.Agency_Transfer__c = codi.esd.Agency_Transfer__c;
 
-                                codcorderdet.Agencyinfo_fromSAP__c       = codi.esd.Agencyinfo_fromSAP__c;
+                                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    );
+                                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);
                         //Consumable_order__c coc = [select name from Consumable_order__c where Id =:Arrived_Order_Sheet.id];
                         // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                        codi.esd.Return_date__c                  = Date.today();
+                        codi.esd.Return_date__c = Date.today();
                         // codi.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) {
                             codi.esd.Lose_Flag__c = false;
                             codi.esd.Return_reason__c = '';
-                            codi.esd.Consumable_Inventory_order__c      = Inventory_Order_Sheet.id;
+                            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;
-                            
+                            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();
+                        codi.esd.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
                         // codi.esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
                         //淇敼杩斿搧鎵�鏈変汉
-                        codi.esd.OwnerId                             = UserInfo.getUserId();
-                        codi.esd.RecordTypeId                    = System.Label.RT_ConOrderDetail2_Return;
-                        codcorderdet.Name                        = consumable_order_arr[0].name + '-' + String.valueOf(++tempNo).leftPad(4,'0');
-                        codcorderdet.Consumable_order_minor__c   = codi.esd.Consumable_order_minor__c;
+                        codi.esd.OwnerId = UserInfo.getUserId();
+                        codi.esd.RecordTypeId = System.Label.RT_ConOrderDetail2_Return;
+                        codcorderdet.Name = consumable_order_arr[0].name + '-' + String.valueOf(++tempNo).leftPad(4, '0');
+                        codcorderdet.Consumable_order_minor__c = codi.esd.Consumable_order_minor__c;
                         codcorderdet.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
                         //淇敼鍒拌揣鎵�鏈変汉
-                        codcorderdet.OwnerId                     = UserInfo.getUserId();
-                        codcorderdet.Arrive_date__c              = Date.today();
-                        codcorderdet.Consumable_Product__c       = codi.esd.Consumable_Product__c;
-                        codcorderdet.Asset_Model_No__c           = codi.esd.Asset_Model_No__c;
-                        codcorderdet.Bar_Code__c                 = codi.esd.Bar_Code__c;
-                        codcorderdet.Deliver_date__c             = codi.esd.Deliver_date__c;
-                        codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
-                        codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
-                        codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
+                        codcorderdet.OwnerId = UserInfo.getUserId();
+                        codcorderdet.Arrive_date__c = Date.today();
+                        codcorderdet.Consumable_Product__c = codi.esd.Consumable_Product__c;
+                        codcorderdet.Asset_Model_No__c = codi.esd.Asset_Model_No__c;
+                        codcorderdet.Bar_Code__c = codi.esd.Bar_Code__c;
+                        codcorderdet.Deliver_date__c = codi.esd.Deliver_date__c;
+                        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 == 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){
+                        if (hasLoseGoods) {
                             codcorderdet.loseInventory__c = true;
                         }
                         // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
                         // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
                         // 杩斿搧鏃讹紝鈶犺拷鍔犲�熻皟鍊熷嚭鏂逛俊鎭� 鈶′繚鐣欏�熻皟淇℃伅 鈶繚瀛楽AP鍜岀粡閿�鍟嗛娆″彂璐х粡閿�鍟�
-                        codcorderdet.Used_account__c             = codi.esd.Used_account__c;
-                        codcorderdet.Transfer_Time__c            = codi.esd.Transfer_Time__c;
-                        codcorderdet.Frist_Transfer_Agency__c    = codi.esd.Frist_Transfer_Agency__c;
-                        codcorderdet.Agency_Transfer__c          = codi.esd.Agency_Transfer__c;
+                        codcorderdet.Used_account__c = codi.esd.Used_account__c;
+                        codcorderdet.Transfer_Time__c = codi.esd.Transfer_Time__c;
+                        codcorderdet.Frist_Transfer_Agency__c = codi.esd.Frist_Transfer_Agency__c;
+                        codcorderdet.Agency_Transfer__c = codi.esd.Agency_Transfer__c;
 
-                        codcorderdet.Agencyinfo_fromSAP__c        = codi.esd.Agencyinfo_fromSAP__c;
+                        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鍚堝悓鍙�
                         // codcorderdet.ContractNo_text__c          = /*codi.esd.ContractNo__c*/;
                         // tcm start
                         if (String.isBlank(codi.esd.Consumable_order_minor__r.ContractNo__c)) {
-                            codcorderdet.ContractNo_text__c= codi.esd.ContractNo_text__c;
-                        }else {
-                            codcorderdet.ContractNo_text__c= codi.esd.Consumable_order_minor__r.ContractNo__c;
+                            codcorderdet.ContractNo_text__c = codi.esd.ContractNo_text__c;
+                        } else {
+                            codcorderdet.ContractNo_text__c = codi.esd.Consumable_order_minor__r.ContractNo__c;
                         }
                         // tcm end
                         //add by rentx 2020-10-13 end   杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
 
                         codcorderdetList.add(codcorderdet);
-                        codcList.add(   codi.esd    );
+                        codcList.add(codi.esd);
                     }
                 }
                 //鏄庣粏2涓嶅瓨鍦ㄧ殑瀵瑰簲鐨勫埌璐ц鍗曟槑缁� 2017-07-05
                 Integer i = 1;
                 //for(ConsumableorderdetailsInfo ass : consumableInventoryUse){
-                for(ConsumableorderdetailsInfo ass : consumableInventory){
+                for (ConsumableorderdetailsInfo ass : consumableInventory) {
                     hasReturnGoods = true;
                     Consumable_order_details2__c codcorderdetail = new Consumable_order_details2__c();
                     Consumable_order_details2__c retorddetail = new Consumable_order_details2__c();
@@ -3518,253 +4329,248 @@
                     //     str = '0' + str;
                     // }
 
-                    if(ass.ReturnReason==null || ass.ReturnReason==''){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇疯ˉ鍏呰繑鍝佸師鍥�'));
+                    if (ass.ReturnReason == null || ass.ReturnReason == '') {
+                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璇疯ˉ鍏呰繑鍝佸師鍥�'));
                         return null;
                     }
 
                     //鍒拌揣鏄庣粏
-                    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;
+                    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.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
-                    codcorderdetail.Direct_Arrive_Product__c    = true;
-                    codcorderdetail.Sterilization_limit__c      = ass.sterilizationlimitDate;
-                    codcorderdetail.Consumable_Product__c       = ass.Prod.id;
-                    codcorderdetail.Bar_Code__c                 = ass.barCodeNo;
-                    codcorderdetail.SerialLotNo__c              = ass.serialNoorLotNo;
-                    codcorderdetail.TracingCode__c              = ass.tracingCodeNo;
+                    codcorderdetail.Asset_Model_No__c = ass.Prod.Asset_Model_No__c;
+                    codcorderdetail.Direct_Arrive_Product__c = true;
+                    codcorderdetail.Sterilization_limit__c = ass.sterilizationlimitDate;
+                    codcorderdetail.Consumable_Product__c = ass.Prod.id;
+                    codcorderdetail.Bar_Code__c = ass.barCodeNo;
+                    codcorderdetail.SerialLotNo__c = ass.serialNoorLotNo;
+                    codcorderdetail.TracingCode__c = ass.tracingCodeNo;
                     codcorderdetail.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
-                    codcorderdetail.Arrive_date__c              = Date.today();
+                    codcorderdetail.Arrive_date__c = Date.today();
 
                     //add by rentx 2020-10-14 start
                     // codcorderdetail.ContractNo_text__c          = /*ass.esd.ContractNo__c*/;
                     // tcm start
                     if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
-                        codcorderdetail.ContractNo_text__c= ass.esd.ContractNo_text__c;
-                    }else {
-                        codcorderdetail.ContractNo_text__c= ass.esd.Consumable_order_minor__r.ContractNo__c;
+                        codcorderdetail.ContractNo_text__c = ass.esd.ContractNo_text__c;
+                    } else {
+                        codcorderdetail.ContractNo_text__c = ass.esd.Consumable_order_minor__r.ContractNo__c;
                     }
                     // tcm end
                     //add by rentx 2020-10-14 end
 
-          codcorderdetList.add(codcorderdetail);
+                    codcorderdetList.add(codcorderdetail);
 
                     //杩斿搧鏄庣粏
-                    retorddetail.Return_reason__c            = ass.ReturnReason;
-                    retorddetail.Return_date__c              = Date.today();
-                    retorddetail.ReturnGs_Uploader_ID__c     = UserInfo.getUserId();
+                    retorddetail.Return_reason__c = ass.ReturnReason;
+                    retorddetail.Return_date__c = Date.today();
+                    retorddetail.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
 
                     // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
                     // if(ass.esd.Dealer_Saled__c == false && ass.esd.Dealer_Shipment__c == false && ass.esd.Lose_Flag__c == true){
                     //     retorddetail.Consumable_Inventory_order__c  = Inventory_Order_Sheet.id;
                     //     retorddetail.loseInventory__c = true;
                     // }
-                    retorddetail.Consumable_Return_order__c  = Return_Order_Sheet.id;
+                    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;
+                    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.Dealer_Info_IF__c           = accountid;
-                    retorddetail.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
-                    retorddetail.Direct_Arrive_Product__c    = true;
-                    retorddetail.Sterilization_limit__c      = ass.sterilizationlimitDate;
-                    retorddetail.Consumable_Product__c       = ass.Prod.id;
-                    retorddetail.Bar_Code__c                 = ass.barCodeNo;
-                    retorddetail.SerialLotNo__c              = ass.serialNoorLotNo;
-                    retorddetail.TracingCode__c              = ass.tracingCodeNo;
-                    retorddetail.Arrive_date__c              = Date.today();
-                    retorddetail.Deliver_date__c             = Date.today();
+                    retorddetail.Dealer_Info_IF__c = accountid;
+                    retorddetail.Asset_Model_No__c = ass.Prod.Asset_Model_No__c;
+                    retorddetail.Direct_Arrive_Product__c = true;
+                    retorddetail.Sterilization_limit__c = ass.sterilizationlimitDate;
+                    retorddetail.Consumable_Product__c = ass.Prod.id;
+                    retorddetail.Bar_Code__c = ass.barCodeNo;
+                    retorddetail.SerialLotNo__c = ass.serialNoorLotNo;
+                    retorddetail.TracingCode__c = ass.tracingCodeNo;
+                    retorddetail.Arrive_date__c = Date.today();
+                    retorddetail.Deliver_date__c = Date.today();
                     // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                    retorddetail.Frist_Storage_Agency__c      = accountName;
+                    retorddetail.Frist_Storage_Agency__c = accountName;
                     // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
 
                     //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 {
-                        retorddetail.ContractNo_text__c= ass.esd.Consumable_order_minor__r.ContractNo__c;
-                     }
+                    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
 
-          codcorderdetList.add(retorddetail);
-          i++;
-        }
+                    codcorderdetList.add(retorddetail);
+                    i++;
+                }
 
-        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------end------'));
-        // return null;
+                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------end------'));
+                // return null;
 
-                if(codcList.size()>0){
-                    ControllerUtil.updateOrderDetailsSatus(   codcList    );
+                if (codcList.size() > 0) {
+                    ControllerUtil.updateOrderDetailsSatus(codcList);
                     //insert codcorderdetList;
                 }
-                if (codcorderdetList.size()>0){
-                    System.debug('codcorderdetList +++++ '+ codcorderdetList);
+                if (codcorderdetList.size() > 0) {
+                    System.debug('codcorderdetList +++++ ' + codcorderdetList);
                     insert codcorderdetList;
                 }
                 // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-                if(conOrderDetail2InList.size() > 0){
+                if (conOrderDetail2InList.size() > 0) {
                     addInventoryDetails1(conOrderDetail2InList);
                 }
                 // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
 
-                if(hasReturnGoods){
+                if (hasReturnGoods) {
                     // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
                     // return ToReturnGoodsPage();
-                    if(hasLoseGoods){
+                    if (hasLoseGoods) {
                         return ToInventoryGoodsPage();
                         // return null;
-                    }else{
+                    } else {
                         return ToReturnGoodsPage();
                         // return null;
                     }
                     // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-                }
-                else{
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'));
+                } else {
+                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'));
                     return null;
                 }
-
-            }else{
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'));
+            } else {
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'));
                 return null;
             }
-        }catch(Exception e){
+        } catch (Exception e) {
             Database.rollback(sp);
             ApexPages.addMessages(e);
             return null;
         }
     }
 
-    public void makeArrivedSummary(){
+    public void makeArrivedSummary() {
         detailsSummary = new List<ConsumableorderdetailsInfo>();
         //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'consumableInventory   ' + consumableInventory));
-        try{
+        try {
             ConsumableorderdetailsInfo arriveDdetailsSummary = null;
-            Map<String,ConsumableorderdetailsInfo> detailsSummaryMap = new Map<String,ConsumableorderdetailsInfo>();
-            for(ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords){
-                if(detailsSummaryMap.containsKey(ass.Prod.Id)){
-                    detailsSummaryMap.get(ass.Prod.Id).arrivedCount ++;
+            Map<String, ConsumableorderdetailsInfo> detailsSummaryMap = new Map<String, ConsumableorderdetailsInfo>();
+            for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords) {
+                if (detailsSummaryMap.containsKey(ass.Prod.Id)) {
+                    detailsSummaryMap.get(ass.Prod.Id).arrivedCount++;
                     detailsSummaryMap.get(ass.Prod.Id).arriveAmount += ass.esd.Intra_Trade_List_RMB__c;
-                }else{
+                } else {
                     arriveDdetailsSummary = new ConsumableorderdetailsInfo(ass.Prod);
                     arriveDdetailsSummary.arrivedCount = 1;
                     arriveDdetailsSummary.arriveAmount = ass.esd.Intra_Trade_List_RMB__c;
                     detailsSummaryMap.put(ass.Prod.Id, arriveDdetailsSummary);
                 }
             }
-            for(ConsumableorderdetailsInfo ass : consumableInventory){
-                if(detailsSummaryMap.containsKey(ass.Prod.Id)){
-                    detailsSummaryMap.get(ass.Prod.Id).arrivedCount ++;
-                    if(EsetId != null && EsetId != ''){
+            for (ConsumableorderdetailsInfo ass : consumableInventory) {
+                if (detailsSummaryMap.containsKey(ass.Prod.Id)) {
+                    detailsSummaryMap.get(ass.Prod.Id).arrivedCount++;
+                    if (EsetId != null && EsetId != '') {
                         detailsSummaryMap.get(ass.Prod.Id).arriveAmount += ass.Prod.Intra_Trade_List_RMB__c;
-                    }else{
+                    } else {
                         detailsSummaryMap.get(ass.Prod.Id).arriveAmount += 0;
                     }
-                }else{
+                } else {
                     arriveDdetailsSummary = new ConsumableorderdetailsInfo(ass.Prod);
                     arriveDdetailsSummary.arrivedCount = 1;
-                    if(EsetId != null && EsetId != ''){
+                    if (EsetId != null && EsetId != '') {
                         arriveDdetailsSummary.arriveAmount = ass.Prod.Intra_Trade_List_RMB__c;
-                    }else{
+                    } else {
                         arriveDdetailsSummary.arriveAmount = 0;
                     }
                     detailsSummaryMap.put(ass.Prod.Id, arriveDdetailsSummary);
                 }
             }
-            for(String key : detailsSummaryMap.keySet()){
+            for (String key : detailsSummaryMap.keySet()) {
                 detailsSummary.add(detailsSummaryMap.get(key));
             }
-        }catch(Exception e){
+        } catch (Exception e) {
             //Database.rollback(sp);
-            throw new ControllerUtil.myException('e::'+e + '  linenumber::'+e.getLineNumber());
+            throw new ControllerUtil.myException('e::' + e + '  linenumber::' + e.getLineNumber());
             // ApexPages.addMessages(e);
             // ApexPages.addMessages(e.getLineNumber() + '  11111111111111111');
 
-      //return null;
+            //return null;
+        }
     }
-  }
 
     //璺宠浆鍒拌繑鍝侀〉闈�
-    public Pagereference ToReturnGoodsPage(){
-        PageReference ref = new Pagereference('/'+return_Order_id);
-            ref.setRedirect(true);
-            return ref;
-    }
-    
-    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-    public Pagereference ToInventoryGoodsPage(){
-        PageReference ref = new Pagereference('/'+inventory_Order_id);
-            ref.setRedirect(true);
-            return ref;
-    }
-    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 end
-
-        // 璺宠浆鍒板埌璐ц鍗曟槑缁�
-    public PageReference UnabletoEdit(){
-        PageReference ref = new Pagereference('/ArriveGsDetails?EsetId='+arriveId);
+    public Pagereference ToReturnGoodsPage() {
+        PageReference ref = new Pagereference('/' + return_Order_id);
         ref.setRedirect(true);
         return ref;
     }
 
-  public class ConsumableorderdetailsInfo implements Comparable {
-    public Consumable_order_details2__c esd { get; set; }
-    public Product2__c Prod { get; set; }
-    public String ProductName { get; set; }
-    //public Boolean canSELECT { get; set; }
-    public String barCodeNo { get; set; }
-    public Date sterilizationlimitDate { get; set; }
-    public String serialNoorLotNo { get; set; }
-    public String tracingCodeNo { get; set; }
-    public String ReturnReason { get; set; }
-    public String oldConsumableCount { get; set; }
-    public String ErrorReason { get; set; }
-    public boolean canEdit { get; set; }
-    public Integer intMark { get; set; }
-    public Decimal arriveAmount { get; set; }
-    public Decimal arrivedCount { get; set; }
+    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
+    public Pagereference ToInventoryGoodsPage() {
+        PageReference ref = new Pagereference('/' + inventory_Order_id);
+        ref.setRedirect(true);
+        return ref;
+    }
+    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 end
 
-        public String ReportProductExpirationDate {get;set;}
-        public ConsumableorderdetailsInfo(Consumable_order_details2__c e,string str) {
-            esd                = e;
-            Prod               = e.Consumable_Product__r;
+    // 璺宠浆鍒板埌璐ц鍗曟槑缁�
+    public PageReference UnabletoEdit() {
+        PageReference ref = new Pagereference('/ArriveGsDetails?EsetId=' + arriveId);
+        ref.setRedirect(true);
+        return ref;
+    }
+
+    public class ConsumableorderdetailsInfo implements Comparable {
+        public Consumable_order_details2__c esd { get; set; }
+        public Product2__c Prod { get; set; }
+        public String ProductName { get; set; }
+        //public Boolean canSELECT { get; set; }
+        public String barCodeNo { get; set; }
+        public Date sterilizationlimitDate { get; set; }
+        public String serialNoorLotNo { get; set; }
+        public String tracingCodeNo { get; set; }
+        public String ReturnReason { get; set; }
+        public String oldConsumableCount { get; set; }
+        public String ErrorReason { get; set; }
+        public boolean canEdit { get; set; }
+        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;
+            ErrorReason = str;
             intMark = 1;
             if (e.Report_Product_Expiration__c != null) {
-                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();  
+                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
             }
-
         }
         public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
             canEdit = false;
-            if(e.Box_Piece__c=='鐩�'){
+            if (e.Box_Piece__c == '鐩�') {
                 e.Rrturn_count__c = 1;
                 canEdit = true;
             }
 
-            esd                = e;
-            Prod               = e.Consumable_Product__r;
+            esd = e;
+            Prod = e.Consumable_Product__r;
             oldConsumableCount = e.name;
             if (e.Report_Product_Expiration__c != null) {
-                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();  
+                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
             }
-
         }
 
-        public ConsumableorderdetailsInfo(Product2__c e,List<String> barinfoL) {
+        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])){
+            if (String.isNotBlank(barinfoL[1])) {
                 sterilizationlimitDate = Date.valueOf(barinfoL[1]);
             }
             serialNoorLotNo = barinfoL[2];
@@ -3772,19 +4578,18 @@
             ReturnReason = '';
         }
 
-        public ConsumableorderdetailsInfo(Consumable_order_details2__c e,List<String> barinfoL) {
+        public ConsumableorderdetailsInfo(Consumable_order_details2__c e, List<String> barinfoL) {
             esd = e;
-            Prod               = e.Consumable_Product__r;
+            Prod = e.Consumable_Product__r;
             barCodeNo = barinfoL[0];
-            if(String.isNotBlank(barinfoL[1])){
+            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();  
+                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
             }
-
         }
         public ConsumableorderdetailsInfo(Product2__c e) {
             Prod = e;

--
Gitblit v1.9.1