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/LexConsumableGoodsInfo.cls |  781 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 470 insertions(+), 311 deletions(-)

diff --git a/force-app/main/default/classes/LexConsumableGoodsInfo.cls b/force-app/main/default/classes/LexConsumableGoodsInfo.cls
index e60bfdd..331cfbb 100644
--- a/force-app/main/default/classes/LexConsumableGoodsInfo.cls
+++ b/force-app/main/default/classes/LexConsumableGoodsInfo.cls
@@ -1,71 +1,87 @@
 public without sharing class LexConsumableGoodsInfo {
-    
     //鎵�鏈変骇鍝佷竴瑙�
     @AuraEnabled
-    public static Results initTotalNum(String ordId, String type){
+    public static Results initTotalNum(String ordId, String type) {
         Results results = new Results();
         List<ShowRecords> allOtherDetIifo = new List<ShowRecords>();
         Set<String> orderId = new Set<String>();
-        if(ordId != '1'){
-        	orderId.add(ordId);
+        if (ordId != '1') {
+            orderId.add(ordId);
         }
         try {
-            if(!(orderId.size() > 0)){
+            if (!(orderId.size() > 0)) {
                 String userId = UserInfo.getUserId();
-                List<User> userList = [SELECT accountid, Work_Location__c,UserPro_Type__c
-                                FROM user
-                                WHERE id = :userId ];
+                List<User> userList = [
+                    SELECT accountid, Work_Location__c, UserPro_Type__c
+                    FROM user
+                    WHERE id = :userId
+                ];
                 String accountid = userList[0].accountid;
                 String userPro_Type = userList[0].UserPro_Type__c;
                 String userWorklocation = userList[0].Work_Location__c;
                 String rtTypeDelivery = System.Label.RT_ConOrder_Delivery;
                 List<Consumable_order__c> conorderlist = new List<Consumable_order__c>();
                 //20200916 ljh update start
-                if(Test.isRunningTest()){
-                    if(type !=null && type.equals('all')){
-                        conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c >= 0 or Delivery_detail_count__c >=0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                    }else{
-                        conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                    }
-                    
-                }else{
-                    if(type !=null && type.equals('all')){
-                        conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                    }else{
-                        conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                    }
+                if (type != null && type.equals('all')) {
+                    conorderlist = [
+                        SELECT id, Owner.Name
+                        FROM Consumable_order__c
+                        WHERE
+                            Order_type__c = '璁㈠崟'
+                            AND recordtypeid = :rtTypeDelivery
+                            AND Dealer_Info__c = :accountid
+                            AND (OrderNumber_notarrive__c > 0
+                            OR Delivery_detail_count__c > 0)
+                            AND Order_ProType__c = :userPro_Type
+                            AND Order_Owner_WorkLocal__c = :userWorklocation
+                            AND showFalseNotshowTrue__c = FALSE
+                    ];
+                } else {
+                    conorderlist = [
+                        SELECT id, Owner.Name
+                        FROM Consumable_order__c
+                        WHERE
+                            Order_type__c = '璁㈠崟'
+                            AND recordtypeid = :rtTypeDelivery
+                            AND Dealer_Info__c = :accountid
+                            AND Delivery_detail_count__c > 0
+                            AND Order_ProType__c = :userPro_Type
+                            AND Order_Owner_WorkLocal__c = :userWorklocation
+                            AND showFalseNotshowTrue__c = FALSE
+                    ];
                 }
-                for(Consumable_order__c conorder : conorderlist){
-                    String temp = (String)conorder.Id;
+                for (Consumable_order__c conorder : conorderlist) {
+                    String temp = (String) conorder.Id;
                     orderId.add(temp);
                 }
-                System.debug('ANY o'+orderId);
+                System.debug('ANY o' + orderId);
             }
             List<Consumable_Orderdetails__c> conOrderList1 = new List<Consumable_Orderdetails__c>();
-            if(Test.isRunningTest()){
-                conOrderList1 = [SELECT Asset_Model_No__c ,Consumable_count__c FROM Consumable_Orderdetails__c];
-            }else{
-                conOrderList1 = [SELECT Asset_Model_No__c ,Consumable_count__c FROM Consumable_Orderdetails__c WHERE Consumable_order__c =:orderId];
-            }
-            
-            Map<String,Decimal> allConOrderMap = new Map<String,Decimal>();
-            for(Consumable_Orderdetails__c con : conOrderList1){
-                if(con.Consumable_count__c == null){
+
+            conOrderList1 = [
+                SELECT Asset_Model_No__c, Consumable_count__c
+                FROM Consumable_Orderdetails__c
+                WHERE Consumable_order__c = :orderId
+            ];
+
+            Map<String, Decimal> allConOrderMap = new Map<String, Decimal>();
+            for (Consumable_Orderdetails__c con : conOrderList1) {
+                if (con.Consumable_count__c == null) {
                     con.Consumable_count__c = 0;
                 }
-                if(allConOrderMap.containsKey(con.Asset_Model_No__c)){
-                    allConOrderMap.put(con.Asset_Model_No__c,allConOrderMap.get(con.Asset_Model_No__c)+con.Consumable_count__c);
-                }else{
+                if (allConOrderMap.containsKey(con.Asset_Model_No__c)) {
+                    allConOrderMap.put(con.Asset_Model_No__c, allConOrderMap.get(con.Asset_Model_No__c) + con.Consumable_count__c);
+                } else {
                     allConOrderMap.put(con.Asset_Model_No__c, con.Consumable_count__c);
                 }
             }
-            for(String pmodel : allConOrderMap.keySet()){
-                if(allConOrderMap.get(pmodel) > 0){
+            for (String pmodel : allConOrderMap.keySet()) {
+                if (allConOrderMap.get(pmodel) > 0) {
                     ShowRecords showrecord2 = new ShowRecords();
                     showrecord2.recordCount = allConOrderMap.get(pmodel);
                     showrecord2.prodModel = pmodel;
                     allOtherDetIifo.add(showrecord2);
-                }	
+                }
             }
             results.result = 'Success';
             results.recordList = allOtherDetIifo;
@@ -78,28 +94,35 @@
 
     //宸插埌璐т骇鍝佷竴瑙�
     @AuraEnabled
-    public static Results initArrDet(String orderId){
+    public static Results initArrDet(String orderId) {
         Results results = new Results();
         List<ShowRecords> arrDetIifo = new List<ShowRecords>();
-        try{
-            List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId];
-            Map<String,String> srtMap = new Map<String,String>();
-            for(Consumable_order_details2__c con : conList){
+        try {
+            List<Consumable_order_details2__c> conList = [
+                SELECT id, Bar_Code__c
+                FROM Consumable_order_details2__c
+                WHERE Dealer_Arrive__c = TRUE AND Consumable_order_minor__c = :orderId
+            ];
+            Map<String, String> srtMap = new Map<String, String>();
+            for (Consumable_order_details2__c con : conList) {
                 srtMap.put(con.Bar_Code__c, con.Id);
             }
             List<String> str = new List<String>();
-            for(String s : srtMap.keySet()){
+            for (String s : srtMap.keySet()) {
                 str.add(srtMap.get(s));
             }
-            List<AggregateResult> arrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Id =: str
-                            GROUP BY Asset_Model_No__c];
-            for(Integer i = 0 ; i< arrDetList.size();i++){
+            List<AggregateResult> arrDetList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE Id = :str
+                GROUP BY Asset_Model_No__c
+            ];
+            for (Integer i = 0; i < arrDetList.size(); i++) {
                 arrDetIifo.add(new showRecords(arrDetList[i]));
             }
             results.recordList = arrDetIifo;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -108,14 +131,16 @@
 
     //宸插埌璐т骇鍝佷竴瑙圓ll
     @AuraEnabled
-    public static Results initArrDetAll(String type){
+    public static Results initArrDetAll(String type) {
         Results results = new Results();
         List<ShowRecords> allArrDetIifo = new List<ShowRecords>();
-        try{
+        try {
             String userId = UserInfo.getUserId();
-            List<User> userList = [SELECT accountid, Work_Location__c,UserPro_Type__c
-                            FROM user
-                            WHERE id = :userId ];
+            List<User> userList = [
+                SELECT accountid, Work_Location__c, UserPro_Type__c
+                FROM user
+                WHERE id = :userId
+            ];
             String accountid = userList[0].accountid;
             String userPro_Type = userList[0].UserPro_Type__c;
             String userWorklocation = userList[0].Work_Location__c;
@@ -123,65 +148,92 @@
             String rtTypeDelivery = System.Label.RT_ConOrder_Delivery;
             List<Consumable_order__c> conorderlist = new List<Consumable_order__c>();
             //20200916 ljh update start
-            if(Test.isRunningTest()){
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c >= 0 or Delivery_detail_count__c >=0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
-                
-            }else{
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
+            //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
+            if (type != null && type.equals('all')) {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND (OrderNumber_notarrive__c > 0
+                        OR Delivery_detail_count__c > 0)
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
+            } else {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND Delivery_detail_count__c > 0
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
             }
             //20200916 ljh update end
             // List<Consumable_order__c> conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c > 0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-            System.debug('======'+conorderlist+'daxiao:'+conorderlist.size());
-            for(Consumable_order__c conorder : conorderlist){
-                System.debug('======'+conorder.Owner.Name+'======');
+            System.debug('======' + conorderlist + 'daxiao:' + conorderlist.size());
+            for (Consumable_order__c conorder : conorderlist) {
+                System.debug('======' + conorder.Owner.Name + '======');
             }
             Set<String> orderId = new Set<String>();
-            for(Consumable_order__c conorder : conorderlist){
+            for (Consumable_order__c conorder : conorderlist) {
                 orderId.add(conorder.Id);
             }
-            System.debug('ANY o'+orderId);
+            System.debug('ANY o' + orderId);
             List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
-            if(Test.isRunningTest()){
-                conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c ];
-            }else{
-                //20200916 ljh update start
-                //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                if(type !=null && type.equals('all')){
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                }else{
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                }
-                //20200916 ljh update end  
+            //20200916 ljh update start
+            //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
+            if (type != null && type.equals('all')) {
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Dealer_Arrive__c = TRUE
+                        AND Consumable_order_minor__c = :orderId
+                        AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
+            } else {
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Dealer_Arrive__c = TRUE
+                        AND Consumable_order_minor__c = :orderId
+                        AND Deliver_date__c < :orderdate
+                        AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
             }
+            //20200916 ljh update end
             // List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-            Map<String,String> srtMap = new Map<String,String>();
-            for(Consumable_order_details2__c con : conList){
+            Map<String, String> srtMap = new Map<String, String>();
+            for (Consumable_order_details2__c con : conList) {
                 srtMap.put(con.Bar_Code__c, con.Id);
             }
             List<String> str = new List<String>();
-            for(String s : srtMap.keySet()){
+            for (String s : srtMap.keySet()) {
                 str.add(srtMap.get(s));
             }
-            List<AggregateResult> arrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Id =: str 
-                            GROUP BY Asset_Model_No__c];
+            List<AggregateResult> arrDetList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE Id = :str
+                GROUP BY Asset_Model_No__c
+            ];
             // List<showRecords> allArrDetIifo = new List<showRecords>();
-            for(Integer i = 0 ; i< arrDetList.size();i++){
+            for (Integer i = 0; i < arrDetList.size(); i++) {
                 allArrDetIifo.add(new showRecords(arrDetList[i]));
             }
             results.recordList = allArrDetIifo;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -190,20 +242,22 @@
 
     //鏈埌璐т骇鍝佷竴瑙�
     @AuraEnabled
-    public static Results initDeliveryDet(String orderId){
+    public static Results initDeliveryDet(String orderId) {
         Results results = new Results();
         List<ShowRecords> notArrDetIifo = new List<ShowRecords>();
-        try{
-            List<AggregateResult> notArrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                        WHERE Dealer_Arrive__c = false
-                        AND Consumable_order_minor__c = :orderId
-                        GROUP BY Asset_Model_No__c];
-            for(Integer i = 0 ; i< notArrDetList.size();i++){
+        try {
+            List<AggregateResult> notArrDetList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE Dealer_Arrive__c = FALSE AND Consumable_order_minor__c = :orderId
+                GROUP BY Asset_Model_No__c
+            ];
+            for (Integer i = 0; i < notArrDetList.size(); i++) {
                 notArrDetIifo.add(new showRecords(notArrDetList[i]));
             }
             results.recordList = notArrDetIifo;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -212,14 +266,16 @@
 
     //鏈埌璐т骇鍝佷竴瑙圓ll
     @AuraEnabled
-    public static Results initDeliveryDetAll(String type){
+    public static Results initDeliveryDetAll(String type) {
         Results results = new Results();
         List<ShowRecords> allNotArrDetIifo = new List<ShowRecords>();
-        try{
+        try {
             String userId = UserInfo.getUserId();
-            List<User> userList = [SELECT accountid, Work_Location__c,UserPro_Type__c
-                            FROM user
-                            WHERE id = :userId ];
+            List<User> userList = [
+                SELECT accountid, Work_Location__c, UserPro_Type__c
+                FROM user
+                WHERE id = :userId
+            ];
             String accountid = userList[0].accountid;
             String userPro_Type = userList[0].UserPro_Type__c;
             String userWorklocation = userList[0].Work_Location__c;
@@ -227,65 +283,92 @@
             String rtTypeDelivery = System.Label.RT_ConOrder_Delivery;
             List<Consumable_order__c> conorderlist = new List<Consumable_order__c>();
             //20200916 ljh update start
-            if(Test.isRunningTest()){
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c >= 0 or Delivery_detail_count__c >=0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation  and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
-                
-            }else{
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
+            //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
+            if (type != null && type.equals('all')) {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND (OrderNumber_notarrive__c > 0
+                        OR Delivery_detail_count__c > 0)
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
+            } else {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND Delivery_detail_count__c > 0
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
             }
             //20200916 ljh update end
             // List<Consumable_order__c> conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c > 0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-            System.debug('======'+conorderlist+'daxiao:'+conorderlist.size());
-            for(Consumable_order__c conorder : conorderlist){
-                System.debug('======'+conorder.Owner.Name+'======');
+            System.debug('======' + conorderlist + 'daxiao:' + conorderlist.size());
+            for (Consumable_order__c conorder : conorderlist) {
+                System.debug('======' + conorder.Owner.Name + '======');
             }
             Set<String> orderId = new Set<String>();
-            for(Consumable_order__c conorder : conorderlist){
+            for (Consumable_order__c conorder : conorderlist) {
                 orderId.add(conorder.Id);
             }
-            System.debug('ANY o'+orderId);
+            System.debug('ANY o' + orderId);
             List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
-            if(Test.isRunningTest()){
-                conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c ];
-            }else{
-                //20200916 ljh update start
-                //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                if(type !=null && type.equals('all')){
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                }else{
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                }
-                //20200916 ljh update end   
+            //20200916 ljh update start
+            //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
+            if (type != null && type.equals('all')) {
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Dealer_Arrive__c = FALSE
+                        AND Consumable_order_minor__c = :orderId
+                        AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
+            } else {
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Dealer_Arrive__c = FALSE
+                        AND Consumable_order_minor__c = :orderId
+                        AND Deliver_date__c < :orderdate
+                        AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
             }
+            //20200916 ljh update end
             // List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-            Map<String,String> srtMap = new Map<String,String>();
-            for(Consumable_order_details2__c con : conList){
+            Map<String, String> srtMap = new Map<String, String>();
+            for (Consumable_order_details2__c con : conList) {
                 srtMap.put(con.Bar_Code__c, con.Id);
             }
             List<String> str = new List<String>();
-            for(String s : srtMap.keySet()){
+            for (String s : srtMap.keySet()) {
                 str.add(srtMap.get(s));
             }
-            List<AggregateResult> arrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Id =: str and Cancellation_Flag__c = false
-                            GROUP BY Asset_Model_No__c];
+            List<AggregateResult> arrDetList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE Id = :str AND Cancellation_Flag__c = FALSE
+                GROUP BY Asset_Model_No__c
+            ];
             // List<showRecords> allArrDetIifo = new List<showRecords>();
-            for(Integer i = 0 ; i< arrDetList.size();i++){
+            for (Integer i = 0; i < arrDetList.size(); i++) {
                 allNotArrDetIifo.add(new showRecords(arrDetList[i]));
             }
             results.recordList = allNotArrDetIifo;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -294,77 +377,89 @@
 
     //杩樻病鍙戣揣鏁伴噺
     @AuraEnabled
-    public static Results initNotArrDet(String orderId){
+    public static Results initNotArrDet(String orderId) {
         Results results = new Results();
         List<Consumable_Orderdetails__c> otherArrDetIifo = new List<Consumable_Orderdetails__c>();
         List<ShowRecords> otherArrList = new List<ShowRecords>();
-        try{
+        try {
             List<showRecords> arrDetIifo = new List<showRecords>();
             List<showRecords> notArrDetIifo = new List<showRecords>();
             List<showRecords> allArrDetIifo = new List<showRecords>();
             // List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId];
-            List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Consumable_order_minor__c = :orderId];
-            Map<String,String> srtMap = new Map<String,String>();
-            for(Consumable_order_details2__c con : conList){
+            List<Consumable_order_details2__c> conList = [
+                SELECT id, Bar_Code__c
+                FROM Consumable_order_details2__c
+                WHERE Consumable_order_minor__c = :orderId
+            ];
+            Map<String, String> srtMap = new Map<String, String>();
+            for (Consumable_order_details2__c con : conList) {
                 srtMap.put(con.Bar_Code__c, con.Id);
             }
             List<String> str = new List<String>();
-            for(String s : srtMap.keySet()){
+            for (String s : srtMap.keySet()) {
                 str.add(srtMap.get(s));
             }
-            List<AggregateResult> arrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Id =: str AND Dealer_Arrive__c = true
-                            GROUP BY Asset_Model_No__c];
-            for(Integer i = 0 ; i< arrDetList.size();i++){
+            List<AggregateResult> arrDetList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE Id = :str AND Dealer_Arrive__c = TRUE
+                GROUP BY Asset_Model_No__c
+            ];
+            for (Integer i = 0; i < arrDetList.size(); i++) {
                 arrDetIifo.add(new showRecords(arrDetList[i]));
             }
 
-            List<AggregateResult> notArrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = false
-                            AND Consumable_order_minor__c = :orderId
-                            GROUP BY Asset_Model_No__c];
-            for(Integer i = 0 ; i< notArrDetList.size();i++){
+            List<AggregateResult> notArrDetList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE Dealer_Arrive__c = FALSE AND Consumable_order_minor__c = :orderId
+                GROUP BY Asset_Model_No__c
+            ];
+            for (Integer i = 0; i < notArrDetList.size(); i++) {
                 notArrDetIifo.add(new showRecords(notArrDetList[i]));
             }
 
             // List<AggregateResult> allArrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
             //                 WHERE Id =: str
             //                 GROUP BY Asset_Model_No__c];
-            List<Consumable_Orderdetails__c> allArrDetList = [SELECT Asset_Model_No__c,Consumable_count__c FROM Consumable_Orderdetails__c
-                            WHERE Consumable_order__c =: orderId];
+            List<Consumable_Orderdetails__c> allArrDetList = [
+                SELECT Asset_Model_No__c, Consumable_count__c
+                FROM Consumable_Orderdetails__c
+                WHERE Consumable_order__c = :orderId
+            ];
             // for(Integer i = 0 ; i< allArrDetList.size();i++){
             //     allArrDetIifo.add(new showRecords(notArrDetList[i]));
             // }
-            Map<String,Decimal> arrDetMap = new Map<String,Decimal>();
-            for(showRecords arr : arrDetIifo){
+            Map<String, Decimal> arrDetMap = new Map<String, Decimal>();
+            for (showRecords arr : arrDetIifo) {
                 arrDetMap.put(arr.prodModel, arr.recordCount);
             }
-            for(showRecords notarr : notArrDetIifo){
-                if(arrDetMap.containsKey(notarr.prodModel)){
-                    arrDetMap.put(notarr.prodModel, arrDetMap.get(notarr.prodModel)+notarr.recordCount);
-                }else{
+            for (showRecords notarr : notArrDetIifo) {
+                if (arrDetMap.containsKey(notarr.prodModel)) {
+                    arrDetMap.put(notarr.prodModel, arrDetMap.get(notarr.prodModel) + notarr.recordCount);
+                } else {
                     arrDetMap.put(notarr.prodModel, notarr.recordCount);
                 }
             }
-            List<String> AssetModelNoEdList = new List<String>();//20200904 ljh add 
-            for(Consumable_Orderdetails__c allarr : allArrDetList){
-                for(String promodel : arrDetMap.keySet()){
-                    if(allarr.Asset_Model_No__c == promodel){
-                        if((allarr.Consumable_count__c - arrDetMap.get(promodel)) > 0){
+            List<String> AssetModelNoEdList = new List<String>(); //20200904 ljh add
+            for (Consumable_Orderdetails__c allarr : allArrDetList) {
+                for (String promodel : arrDetMap.keySet()) {
+                    if (allarr.Asset_Model_No__c == promodel) {
+                        if ((allarr.Consumable_count__c - arrDetMap.get(promodel)) > 0) {
                             allarr.Consumable_count__c = (allarr.Consumable_count__c - arrDetMap.get(promodel));
                             otherArrDetIifo.add(allarr);
                         }
-                        AssetModelNoEdList.add(promodel);//20200904 ljh add 
+                        AssetModelNoEdList.add(promodel); //20200904 ljh add
                     }
                 }
             }
             //20200904 ljh add  start
-            for(Consumable_Orderdetails__c allarr1 : allArrDetList){
-                if(!AssetModelNoEdList.contains(allarr1.Asset_Model_No__c)){
+            for (Consumable_Orderdetails__c allarr1 : allArrDetList) {
+                if (!AssetModelNoEdList.contains(allarr1.Asset_Model_No__c)) {
                     otherArrDetIifo.add(allarr1);
                 }
             }
-            for(Consumable_Orderdetails__c conOrderDetail : otherArrDetIifo){
+            for (Consumable_Orderdetails__c conOrderDetail : otherArrDetIifo) {
                 ShowRecords record = new ShowRecords();
                 record.prodModel = conOrderDetail.Asset_Model_No__c;
                 record.recordCount = conOrderDetail.Consumable_count__c;
@@ -372,7 +467,7 @@
             }
             results.recordList = otherArrList;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -381,14 +476,16 @@
 
     //杩樻病鍙戣揣鏁伴噺All
     @AuraEnabled
-    public static Results initNotArrDetAll(String type){
+    public static Results initNotArrDetAll(String type) {
         Results results = new Results();
         List<ShowRecords> allOtherDetIifo = new List<ShowRecords>();
-        try{
+        try {
             String userId = UserInfo.getUserId();
-            List<User> userList = [SELECT accountid, Work_Location__c,UserPro_Type__c
-                            FROM user
-                            WHERE id = :userId ];
+            List<User> userList = [
+                SELECT accountid, Work_Location__c, UserPro_Type__c
+                FROM user
+                WHERE id = :userId
+            ];
             String accountid = userList[0].accountid;
             String userPro_Type = userList[0].UserPro_Type__c;
             String userWorklocation = userList[0].Work_Location__c;
@@ -396,84 +493,111 @@
             String rtTypeDelivery = System.Label.RT_ConOrder_Delivery;
             List<Consumable_order__c> conorderlist = new List<Consumable_order__c>();
             //20200916 ljh update start
-            if(Test.isRunningTest()){
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c >= 0 or Delivery_detail_count__c >=0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
-                
-            }else{
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
+            //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
+            if (type != null && type.equals('all')) {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND (OrderNumber_notarrive__c > 0
+                        OR Delivery_detail_count__c > 0)
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
+            } else {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND Delivery_detail_count__c > 0
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
             }
             //20200916 ljh update end
             // List<Consumable_order__c> conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c > 0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-            System.debug('======'+conorderlist+'daxiao:'+conorderlist.size());
-            for(Consumable_order__c conorder : conorderlist){
-                System.debug('======'+conorder.Owner.Name+'======');
+            System.debug('======' + conorderlist + 'daxiao:' + conorderlist.size());
+            for (Consumable_order__c conorder : conorderlist) {
+                System.debug('======' + conorder.Owner.Name + '======');
             }
             Set<String> orderId = new Set<String>();
-            for(Consumable_order__c conorder : conorderlist){
+            for (Consumable_order__c conorder : conorderlist) {
                 orderId.add(conorder.Id);
             }
-            System.debug('ANY o'+orderId);
+            System.debug('ANY o' + orderId);
             List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
-            if(Test.isRunningTest()){
-                conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c ];
-            }else{
-                //20200916 ljh update start
-                //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE  Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                if(type !=null && type.equals('all')){
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE  Consumable_order_minor__c = :orderId  AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                }else{
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE  Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                }
-                //20200916 ljh update end	
+            //20200916 ljh update start
+            //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE  Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
+            if (type != null && type.equals('all')) {
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE Consumable_order_minor__c = :orderId AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
+            } else {
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Consumable_order_minor__c = :orderId
+                        AND Deliver_date__c < :orderdate
+                        AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
             }
+            //20200916 ljh update end
             // List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-            Map<String,String> srtMap = new Map<String,String>();
-            for(Consumable_order_details2__c con : conList){
+            Map<String, String> srtMap = new Map<String, String>();
+            for (Consumable_order_details2__c con : conList) {
                 srtMap.put(con.Bar_Code__c, con.Id);
             }
             List<String> str = new List<String>();
-            for(String s : srtMap.keySet()){
+            for (String s : srtMap.keySet()) {
                 str.add(srtMap.get(s));
             }
-            List<AggregateResult> arrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Id =: str and Cancellation_Flag__c = false
-                            GROUP BY Asset_Model_No__c];
-            Map<String,Decimal> conOrderMap = new Map<String,Decimal>();
-            for(AggregateResult agg : arrDetList){
+            List<AggregateResult> arrDetList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE Id = :str AND Cancellation_Flag__c = FALSE
+                GROUP BY Asset_Model_No__c
+            ];
+            Map<String, Decimal> conOrderMap = new Map<String, Decimal>();
+            for (AggregateResult agg : arrDetList) {
                 conOrderMap.put(String.valueOf(agg.get('prodModel')), Integer.valueOf(agg.get('recordCount')));
             }
 
-            List<Consumable_Orderdetails__c> conOrderList1 = [SELECT Asset_Model_No__c ,Consumable_count__c FROM Consumable_Orderdetails__c WHERE Consumable_order__c =: orderId ];
-            Map<String,Decimal> allConOrderMap = new Map<String,Decimal>();
-            for(Consumable_Orderdetails__c con : conOrderList1){
-                if(con.Consumable_count__c == null){
+            List<Consumable_Orderdetails__c> conOrderList1 = [
+                SELECT Asset_Model_No__c, Consumable_count__c
+                FROM Consumable_Orderdetails__c
+                WHERE Consumable_order__c = :orderId
+            ];
+            Map<String, Decimal> allConOrderMap = new Map<String, Decimal>();
+            for (Consumable_Orderdetails__c con : conOrderList1) {
+                if (con.Consumable_count__c == null) {
                     con.Consumable_count__c = 0;
                 }
-                if(allConOrderMap.containsKey(con.Asset_Model_No__c)){
-                    allConOrderMap.put(con.Asset_Model_No__c,allConOrderMap.get(con.Asset_Model_No__c)+con.Consumable_count__c);
-                }else{
+                if (allConOrderMap.containsKey(con.Asset_Model_No__c)) {
+                    allConOrderMap.put(con.Asset_Model_No__c, allConOrderMap.get(con.Asset_Model_No__c) + con.Consumable_count__c);
+                } else {
                     allConOrderMap.put(con.Asset_Model_No__c, con.Consumable_count__c);
                 }
             }
-            for(String pmodel : allConOrderMap.keySet()){
-                if(conOrderMap.containsKey(pmodel)){
-                    if(allConOrderMap.get(pmodel) - conOrderMap.get(pmodel) > 0){
+            for (String pmodel : allConOrderMap.keySet()) {
+                if (conOrderMap.containsKey(pmodel)) {
+                    if (allConOrderMap.get(pmodel) - conOrderMap.get(pmodel) > 0) {
                         showRecords showrecord1 = new showRecords();
                         showrecord1.recordCount = allConOrderMap.get(pmodel) - conOrderMap.get(pmodel);
                         showrecord1.prodModel = pmodel;
                         allOtherDetIifo.add(showrecord1);
                     }
-                }else{
+                } else {
                     showRecords showrecord2 = new showRecords();
                     showrecord2.recordCount = allConOrderMap.get(pmodel);
                     showrecord2.prodModel = pmodel;
@@ -482,7 +606,7 @@
             }
             results.recordList = allOtherDetIifo;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -491,26 +615,30 @@
 
     //鍙戣揣涓冨ぉ杩樻湭鍒拌揣鏁�
     @AuraEnabled
-    public static Results initMoreThan7(String orderId){
+    public static Results initMoreThan7(String orderId) {
         Results results = new Results();
         List<ShowRecords> morethansevendaysIifo = new List<ShowRecords>();
-        try{
-            List<AggregateResult> morethan7daysList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Consumable_order_minor__c != null 
-                            AND Dealer_Shipment__c = false 
-                            AND Dealer_Arrive__c = false 
-                            AND Dealer_Saled__c = false 
-                            AND Consumable_order_minor__r.showFalseNotshowTrue__c = false 
-                            AND Deliver_date__c < LAST_N_DAYS:7
-                            AND Consumable_order_minor__c = :orderId
-                            GROUP BY Asset_Model_No__c];
-                            
-            for(Integer i = 0 ; i< morethan7daysList.size() ; i++){
+        try {
+            List<AggregateResult> morethan7daysList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE
+                    Consumable_order_minor__c != NULL
+                    AND Dealer_Shipment__c = FALSE
+                    AND Dealer_Arrive__c = FALSE
+                    AND Dealer_Saled__c = FALSE
+                    AND Consumable_order_minor__r.showFalseNotshowTrue__c = FALSE
+                    AND Deliver_date__c < LAST_N_DAYS:7
+                    AND Consumable_order_minor__c = :orderId
+                GROUP BY Asset_Model_No__c
+            ];
+
+            for (Integer i = 0; i < morethan7daysList.size(); i++) {
                 morethansevendaysIifo.add(new showRecords(morethan7daysList[i]));
             }
             results.recordList = morethansevendaysIifo;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -519,14 +647,16 @@
 
     //鍙戣揣涓冨ぉ杩樻湭鍒拌揣鏁癆ll
     @AuraEnabled
-    public static Results initMoreThan7All(String type){
+    public static Results initMoreThan7All(String type) {
         Results results = new Results();
         List<ShowRecords> morethansevendaysIifo = new List<ShowRecords>();
-        try{
+        try {
             String userId = UserInfo.getUserId();
-            List<User> userList = [SELECT accountid, Work_Location__c,UserPro_Type__c
-                            FROM user
-                            WHERE id = :userId ];
+            List<User> userList = [
+                SELECT accountid, Work_Location__c, UserPro_Type__c
+                FROM user
+                WHERE id = :userId
+            ];
             String accountid = userList[0].accountid;
             String userPro_Type = userList[0].UserPro_Type__c;
             String userWorklocation = userList[0].Work_Location__c;
@@ -534,78 +664,107 @@
             String rtTypeDelivery = System.Label.RT_ConOrder_Delivery;
             List<Consumable_order__c> conorderlist = new List<Consumable_order__c>();
             //20200916 ljh update start
-            if(Test.isRunningTest()){
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c >= 0 or Delivery_detail_count__c >=0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation  and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >=0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
-                
-            }else{
-                //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-                if(type !=null && type.equals('all')){
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0)  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }else{
-                    conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false];
-                }
+            //conorderlist  = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and  Delivery_detail_count__c >0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
+            if (type != null && type.equals('all')) {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND (OrderNumber_notarrive__c > 0
+                        OR Delivery_detail_count__c > 0)
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
+            } else {
+                conorderlist = [
+                    SELECT id, Owner.Name
+                    FROM Consumable_order__c
+                    WHERE
+                        Order_type__c = '璁㈠崟'
+                        AND recordtypeid = :rtTypeDelivery
+                        AND Dealer_Info__c = :accountid
+                        AND Delivery_detail_count__c > 0
+                        AND Order_ProType__c = :userPro_Type
+                        AND Order_Owner_WorkLocal__c = :userWorklocation
+                        AND showFalseNotshowTrue__c = FALSE
+                ];
             }
-            system.debug('==============>conorderlist'+conorderlist);
-            system.debug('==============>conorderlist'+conorderlist.size());
+            system.debug('==============>conorderlist' + conorderlist);
+            system.debug('==============>conorderlist' + conorderlist.size());
             //20200916 ljh update end
             // List<Consumable_order__c> conorderlist  = [select id,Owner.Name from Consumable_order__c where Order_type__c = '璁㈠崟' and  recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c > 0  and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation];
-            System.debug('======'+conorderlist+'daxiao:'+conorderlist.size());
-            for(Consumable_order__c conorder : conorderlist){
-                System.debug('======'+conorder.Owner.Name+'======');
+            System.debug('======' + conorderlist + 'daxiao:' + conorderlist.size());
+            for (Consumable_order__c conorder : conorderlist) {
+                System.debug('======' + conorder.Owner.Name + '======');
             }
             Set<String> orderId = new Set<String>();
-            for(Consumable_order__c conorder : conorderlist){
+            for (Consumable_order__c conorder : conorderlist) {
                 orderId.add(conorder.Id);
             }
-            System.debug('ANY o'+orderId);
+            System.debug('ANY o' + orderId);
             List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
-            if(Test.isRunningTest()){
-                conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c ];
-            }else{
-                //20200916 ljh update start
-                //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                if(type !=null && type.equals('all')){
-                    system.debug('all============');
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                    system.debug('allconList==========='+conList.size());
-                }else{
-                    system.debug('notall=============');
-                    conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-                    system.debug('notallconList==========='+conList.size());
-                }
-                //20200916 ljh update end   
+            //20200916 ljh update start
+            //conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
+            if (type != null && type.equals('all')) {
+                system.debug('all============');
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Dealer_Arrive__c = FALSE
+                        AND Consumable_order_minor__c = :orderId
+                        AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
+                system.debug('allconList===========' + conList.size());
+            } else {
+                system.debug('notall=============');
+                conList = [
+                    SELECT id, Bar_Code__c
+                    FROM Consumable_order_details2__c
+                    WHERE
+                        Dealer_Arrive__c = FALSE
+                        AND Consumable_order_minor__c = :orderId
+                        AND Deliver_date__c < :orderdate
+                        AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                ];
+                system.debug('notallconList===========' + conList.size());
             }
+            //20200916 ljh update end
             // List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = false AND Consumable_order_minor__c = :orderId AND Deliver_date__c < :orderdate AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery];
-            Map<String,String> srtMap = new Map<String,String>();
-            for(Consumable_order_details2__c con : conList){
+            Map<String, String> srtMap = new Map<String, String>();
+            for (Consumable_order_details2__c con : conList) {
                 srtMap.put(con.Bar_Code__c, con.Id);
             }
             List<String> str = new List<String>();
-            for(String s : srtMap.keySet()){
+            for (String s : srtMap.keySet()) {
                 str.add(srtMap.get(s));
             }
-            List<AggregateResult> morethan7daysList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
-                            WHERE Id =: str and Cancellation_Flag__c = false 
-                            AND Consumable_order_minor__c != null 
-                            AND Dealer_Shipment__c = false 
-                            AND Dealer_Arrive__c = false 
-                            AND Dealer_Saled__c = false 
-                            AND Consumable_order_minor__r.showFalseNotshowTrue__c = false 
-                            AND Deliver_date__c < LAST_N_DAYS:7
-                            GROUP BY Asset_Model_No__c];
-            system.debug('Morethan7daysList================>'+morethan7daysList.size());
-            for(Integer i = 0 ; i< morethan7daysList.size() ; i++){
+            List<AggregateResult> morethan7daysList = [
+                SELECT Asset_Model_No__c prodModel, count(Id) recordCount
+                FROM Consumable_order_details2__c
+                WHERE
+                    Id = :str
+                    AND Cancellation_Flag__c = FALSE
+                    AND Consumable_order_minor__c != NULL
+                    AND Dealer_Shipment__c = FALSE
+                    AND Dealer_Arrive__c = FALSE
+                    AND Dealer_Saled__c = FALSE
+                    AND Consumable_order_minor__r.showFalseNotshowTrue__c = FALSE
+                    AND Deliver_date__c < LAST_N_DAYS:7
+                GROUP BY Asset_Model_No__c
+            ];
+            system.debug('Morethan7daysList================>' + morethan7daysList.size());
+            for (Integer i = 0; i < morethan7daysList.size(); i++) {
                 morethansevendaysIifo.add(new showRecords(morethan7daysList[i]));
-                system.debug('MorethansevendaysIifo+++++++'+morethansevendaysIifo);
+                system.debug('MorethansevendaysIifo+++++++' + morethansevendaysIifo);
             }
             results.recordList = morethansevendaysIifo;
             results.result = 'Success';
-        }catch (Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
             results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
@@ -621,17 +780,17 @@
         public List<ShowRecords> recordList;
     }
 
-
     public class ShowRecords implements Comparable {
         @AuraEnabled
         public Decimal recordCount { get; set; }
         @AuraEnabled
         public String prodModel { get; set; }
 
-        public ShowRecords() {}
+        public ShowRecords() {
+        }
 
         public ShowRecords(AggregateResult e) {
-            recordCount =Integer.valueOf(e.get('recordCount'));
+            recordCount = Integer.valueOf(e.get('recordCount'));
             prodModel = String.valueOf(e.get('prodModel'));
         }
         // 鎺掑簭
@@ -639,4 +798,4 @@
             return null;
         }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.1