From dd004276162a2bf9d042ff0aaa569dc30a95d827 Mon Sep 17 00:00:00 2001
From: binxie <137736985@qq.com>
Date: 星期一, 26 六月 2023 14:23:26 +0800
Subject: [PATCH] newbackup0626

---
 force-app/main/default/classes/LexTopPageController.cls |  529 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 299 insertions(+), 230 deletions(-)

diff --git a/force-app/main/default/classes/LexTopPageController.cls b/force-app/main/default/classes/LexTopPageController.cls
index aab986b..955f049 100644
--- a/force-app/main/default/classes/LexTopPageController.cls
+++ b/force-app/main/default/classes/LexTopPageController.cls
@@ -2,7 +2,7 @@
     //缁忛攢鍟嗕俊鎭�
     public static account accountInfo;
     /*****************鐢婚潰琛ㄧずBean******************/
-    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords =new List<ConsumableorderdetailsInfo>();
+    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
     public static List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
     //page
     public static Integer pagesize { get; set; }
@@ -17,7 +17,7 @@
     // public static Boolean hasPrevious;
     // public static Boolean hasNext;
     public static List<ConsumableorderdetailsInfo> pageRecords;
-    public static String soql {get;set;}
+    public static String soql { get; set; }
     // 姹囨�讳娇鐢�
     public static Integer Total_num;
     public static Integer OrderNumber_arrived;
@@ -39,12 +39,12 @@
     public static List<Consumable_order__c> raesList;
     /*****************涓�鍛ㄦ湭鍒拌揣璁㈠崟涓�瑙堝搴攅nd******************/
     //鎺掑簭浣跨敤
-    private static String[] orderby = new String[]{ 'Product2__c.Name__c'};
+    private static String[] orderby = new List<String>{ 'Product2__c.Name__c' };
     //浜у搧涓婁笅闄�
-    public static String[] proLimitAndDate =new String[]{};
+    public static String[] proLimitAndDate = new List<String>{};
     public static String product_Limit;
     //搴撳瓨浜у搧鏈�鏃╂湁鏁堟湡闄�
-    private static Map<String,Date> productkucun = new Map<String,Date>();
+    private static Map<String, Date> productkucun = new Map<String, Date>();
     //娑堣垂鏈熼檺灏忎簬涓�骞寸殑浜у搧
     public static List<ConsumableorderdetailsInfo> overlimitdateorderdetails = new List<ConsumableorderdetailsInfo>();
     public static String accountid;
@@ -72,43 +72,60 @@
     public static Boolean hasHos;
 
     @AuraEnabled
-    public static Results initAgency(){
+    public static Results initAgency() {
         Results results = new Results();
         results.isNoteStay = LexUtility.getIsNoteStay();
         try {
-            User useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:UserInfo.getUserId()];
+            User useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :UserInfo.getUserId()];
             accountid = useracc.accountid;
             List<Account> accList = new List<Account>();
-            accList = [SELECT Name,Ban_On_Use_Reason__c,Deposit_Price__c,
-                    Medical_Equipment_Num__c,Medical_Equipment_Expiration_Date__c,
-                    Ban_On_Use_Date__c,Tax_Practice_No__c,Tax_Practice_Expiration_Date__c,
-                    Business_Authorization_No__c,Business_Paper_Expiration_Date__c,
-                    Credit_Check_No__c,Dealer_discount__c,
-                    Phone,Address_Together__c,Is_Active_Formula__c,
-                    Management_Code__c,Sales_Shop_Class__c,Postal_Code__c,
-                    Fax,Address__c,Deposit_Receipt_Finished__c,
+            accList = [
+                SELECT
+                    Name,
+                    Ban_On_Use_Reason__c,
+                    Deposit_Price__c,
+                    Medical_Equipment_Num__c,
+                    Medical_Equipment_Expiration_Date__c,
+                    Ban_On_Use_Date__c,
+                    Tax_Practice_No__c,
+                    Tax_Practice_Expiration_Date__c,
+                    Business_Authorization_No__c,
+                    Business_Paper_Expiration_Date__c,
+                    Credit_Check_No__c,
+                    Dealer_discount__c,
+                    Phone,
+                    Address_Together__c,
+                    Is_Active_Formula__c,
+                    Management_Code__c,
+                    Sales_Shop_Class__c,
+                    Postal_Code__c,
+                    Fax,
+                    Address__c,
+                    Deposit_Receipt_Finished__c,
                     Deposit_Receipt_Completion_Day__c,
                     Product_Limit_Date__c,
                     Product_Limit_DateENG__c
-                    FROM account WHERE id =:accountid];
-            if(accList.size() == 1){
+                FROM account
+                WHERE id = :accountid
+            ];
+            if (accList.size() == 1) {
                 accountInfo = accList[0];
-            }else{
+            } else {
                 results.result = 'Fail';
                 results.errorMsg = '鏈幏鍙栧埌缁忛攢鍟嗕俊鎭�';
                 return results;
             }
             results.result = 'Success';
             results.accountInfo = accountInfo;
-        }catch(Exception e){
+        } catch (Exception e) {
             results.result = 'Fail';
-            results.errorMsg = e.getLineNumber()+'---'+e.getMessage();
+            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
         return results;
     }
 
     @AuraEnabled
-    public static Results initPage(Integer pageSizeLWC,Integer pageTokenLWC){
+    public static Results initPage(Integer pageSizeLWC, Integer pageTokenLWC) {
         pageSize = pageSizeLWC;
         pageToken = pageTokenLWC;
         Results results = new Results();
@@ -121,91 +138,115 @@
             // pagesize = Integer.valueof(system.label.orderdetLimitsize);
             // currentpage = 0;
 
-            User useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:UserInfo.getUserId()];
+            User useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :UserInfo.getUserId()];
             // String uid = '0051000000E7Pv9AAF';
             // User useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:uid];
             accountid = useracc.accountid;
             userWorkLocation = useracc.Work_Location__c;
             userPro_Type = useracc.UserPro_Type__c;
-            if(String.isBlank(userPro_Type)){
+            if (String.isBlank(userPro_Type)) {
                 userPro_Type = 'ET';
             }
             userPro_Typestr = '%' + userPro_Type + '%';
-            if(userPro_Type == 'ENG'){
+            if (userPro_Type == 'ENG') {
                 EngFlag = true;
-            }else{
+            } else {
                 ETFlag = true;
             }
             //缁忛攢鍟喡峰熀鏈俊鎭幏鍙�
             List<Account> accList = new List<Account>();
-            accList = [SELECT Name,Ban_On_Use_Reason__c,Deposit_Price__c,
-                    Medical_Equipment_Num__c,Medical_Equipment_Expiration_Date__c,
-                    Ban_On_Use_Date__c,Tax_Practice_No__c,Tax_Practice_Expiration_Date__c,
-                    Business_Authorization_No__c,Business_Paper_Expiration_Date__c,
-                    Credit_Check_No__c,Dealer_discount__c,
-                    Phone,Address_Together__c,Is_Active_Formula__c,
-                    Management_Code__c,Sales_Shop_Class__c,Postal_Code__c,
-                    Fax,Address__c,Deposit_Receipt_Finished__c,
+            accList = [
+                SELECT
+                    Name,
+                    Ban_On_Use_Reason__c,
+                    Deposit_Price__c,
+                    Medical_Equipment_Num__c,
+                    Medical_Equipment_Expiration_Date__c,
+                    Ban_On_Use_Date__c,
+                    Tax_Practice_No__c,
+                    Tax_Practice_Expiration_Date__c,
+                    Business_Authorization_No__c,
+                    Business_Paper_Expiration_Date__c,
+                    Credit_Check_No__c,
+                    Dealer_discount__c,
+                    Phone,
+                    Address_Together__c,
+                    Is_Active_Formula__c,
+                    Management_Code__c,
+                    Sales_Shop_Class__c,
+                    Postal_Code__c,
+                    Fax,
+                    Address__c,
+                    Deposit_Receipt_Finished__c,
                     Deposit_Receipt_Completion_Day__c,
                     Product_Limit_Date__c,
                     Product_Limit_DateENG__c
-                    FROM account WHERE id =:accountid];
-            if(accList.size() == 1){
+                FROM account
+                WHERE id = :accountid
+            ];
+            if (accList.size() == 1) {
                 accountInfo = accList[0];
-            }else{
+            } else {
                 results.result = 'Fail';
                 results.errorMsg = '鏈幏鍙栧埌缁忛攢鍟嗕俊鎭�';
                 return results;
             }
             accountName = accountInfo.Name;
-            if(EngFlag){
-                product_Limit = accountInfo.Product_Limit_DateENG__c;    
-            }else if(ETFlag){
+            if (EngFlag) {
+                product_Limit = accountInfo.Product_Limit_DateENG__c;
+            } else if (ETFlag) {
                 product_Limit = accountInfo.Product_Limit_Date__c;
             }
-            if(product_Limit != null && product_Limit !=''){
+            if (product_Limit != null && product_Limit != '') {
                 proLimitAndDate = product_Limit.split(',');
             }
             List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
-             //搴撳瓨鏄庣粏鍙栧緱
+            //搴撳瓨鏄庣粏鍙栧緱
             orderDetZaikuList = new List<String>();
-            List<AggregateResult>  orderDetZaiku = [SELECT count(Id),
-                                                        Consumable_Product__c
-                                                    FROM Consumable_order_details2__c
-                                                    WHERE Dealer_Arrive__c = true
-                                                    AND Dealer_Shipment__c = false
-                                                    AND Dealer_Saled__c = false
-                                                    AND Lose_Flag__c = false
-                                                    AND Dealer_Returned__c = false
-                                                    AND Cancellation_Flag__c = false
-                                                    AND Bar_Code__c !=null
-                                                    AND Product_Type__c like : userPro_Typestr
-                                                    AND Dealer_Info_text__c = :accountName
-                                                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
-                                                    group by Consumable_Product__c];
-            for(AggregateResult zaikuId : orderDetZaiku){
+            List<AggregateResult> orderDetZaiku = [
+                SELECT count(Id), Consumable_Product__c
+                FROM Consumable_order_details2__c
+                WHERE
+                    Dealer_Arrive__c = TRUE
+                    AND Dealer_Shipment__c = FALSE
+                    AND Dealer_Saled__c = FALSE
+                    AND Lose_Flag__c = FALSE
+                    AND Dealer_Returned__c = FALSE
+                    AND Cancellation_Flag__c = FALSE
+                    AND Bar_Code__c != NULL
+                    AND Product_Type__c LIKE :userPro_Typestr
+                    AND Dealer_Info_text__c = :accountName
+                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
+                GROUP BY Consumable_Product__c
+            ];
+            for (AggregateResult zaikuId : orderDetZaiku) {
                 orderDetZaikuList.add(String.valueOf(zaikuId.get('Consumable_Product__c')));
             }
-            Map<String,Product2__c> MidMap = new Map<String,Product2__c>();
-            List<Product2__c> product2Selected = [SELECT Id, Name,
-                                    Name__c,
-                                    Asset_Model_No__c,
-                                    Category3__c,
-                                    Category4__c,
-                                    Category5__c,
-                                    SFDA_Status__c,
-                                    Product2__r.SFDA_Approbation_No__c,
-                                    Product2__r.SFDA_Expiration_Date__c,
-                                    Product2__r.Packing_list_manual__c
-                                FROM Product2__c
-                                WHERE Id in :orderDetZaikuList
-                                ];
+            Map<String, Product2__c> MidMap = new Map<String, Product2__c>();
+            List<Product2__c> product2Selected = [
+                SELECT
+                    Id,
+                    Name,
+                    Name__c,
+                    Asset_Model_No__c,
+                    Category3__c,
+                    Category4__c,
+                    Category5__c,
+                    SFDA_Status__c,
+                    Product2__r.SFDA_Approbation_No__c,
+                    Product2__r.SFDA_Expiration_Date__c,
+                    Product2__r.Packing_list_manual__c
+                FROM Product2__c
+                WHERE Id IN :orderDetZaikuList
+            ];
 
             for (Integer i = 0; i < product2Selected.size(); i++) {
                 MidMap.put(product2Selected[i].Id, product2Selected[i]);
             }
             //杩斿搧搴撳瓨缁熻
-            List<Consumable_order_details2__c> CountDel = [SELECT Id,
+            List<Consumable_order_details2__c> CountDel = [
+                SELECT
+                    Id,
                     Bar_Code__c,
                     Name,
                     Inventory_date__c,
@@ -214,78 +255,86 @@
                     Guarantee_period_for_products__c,
                     Isoverdue__c,
                     Box_Piece__c,
-                    hospitalSpecialOffer__c 
+                    hospitalSpecialOffer__c
                 FROM Consumable_order_details2__c
-                WHERE  Dealer_Arrive__c = true
-                AND Dealer_Shipment__c = false
-                AND Dealer_Saled__c = false
-                AND Dealer_Returned__c = false
-                AND Lose_Flag__c = false
-                AND Cancellation_Flag__c = false
-                AND Bar_Code__c !=null
-                AND Product_Type__c like : userPro_Typestr
-                AND Dealer_Info_text__c = :accountName
-                AND Arrive_Owner_Work_Location__c = :userWorkLocation];
-            Map<String,ConsumableorderdetailsInfo> newMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
-            Map<String,ConsumableorderdetailsInfo> newMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
-            Map<String,ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
-            Map<String,ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
-            for(Integer i = 0 ; i< CountDel.size();i++){
+                WHERE
+                    Dealer_Arrive__c = TRUE
+                    AND Dealer_Shipment__c = FALSE
+                    AND Dealer_Saled__c = FALSE
+                    AND Dealer_Returned__c = FALSE
+                    AND Lose_Flag__c = FALSE
+                    AND Cancellation_Flag__c = FALSE
+                    AND Bar_Code__c != NULL
+                    AND Product_Type__c LIKE :userPro_Typestr
+                    AND Dealer_Info_text__c = :accountName
+                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
+            ];
+            Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+            Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+            Map<String, ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+            Map<String, ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+            for (Integer i = 0; i < CountDel.size(); i++) {
                 //鐒跺悗寰幆CountDel鍋欱ox鍜宲iece2涓猰ap
-                if(MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '鐩�'){
+                if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '鐩�') {
                     String tex = 'A';
                     if (CountDel[i].hospitalSpecialOffer__c) {
                         tex = 'B';
                     }
-                    if(newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex)){
-                        ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex).clone();
-                        Jstage.allnumber = Jstage.allnumber+1 ;
-                        if(CountDel[i].Isoverdue__c == 1){
+                    if (newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
+                        ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(
+                                CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex
+                            )
+                            .clone();
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
                             Jstage.limitCount = Jstage.limitCount + 1;
                         }
                         Jstage.BoxPiece = CountDel[i].Box_Piece__c;
-                        newMidBoxMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
-                    }else{
+                        newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                    } else {
                         ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
-                        Jstage.allnumber = Jstage.allnumber+1 ;
-                        if(CountDel[i].Isoverdue__c == 1){
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
                             Jstage.limitCount = Jstage.limitCount + 1;
                         }
                         Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                         if (CountDel[i].hospitalSpecialOffer__c) {
                             Jstage.hospitalSpecialOffer = true;
-                            newMidBoxMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
-                        }else{
+                            newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                        } else {
                             Jstage.hospitalSpecialOffer = false;
-                            newMidBoxMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
+                            newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                         }
                     }
-                }else if(MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '涓�'){
+                } else if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '涓�') {
                     String tex = 'A';
                     if (CountDel[i].hospitalSpecialOffer__c) {
                         tex = 'B';
                     }
-                    if(newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c+ tex )){
-                        ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c+ tex).clone();
-                        Jstage.allnumber = Jstage.allnumber+1 ;
-                        if(CountDel[i].Isoverdue__c == 1){
+                    if (newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
+                        ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
+                                CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex
+                            )
+                            .clone();
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
                             Jstage.limitCount = Jstage.limitCount + 1;
                         }
                         Jstage.BoxPiece = CountDel[i].Box_Piece__c;
-                        newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
-                    }else{
+                        newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                    } else {
                         ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
-                        Jstage.allnumber = Jstage.allnumber+1 ;
-                        if(CountDel[i].Isoverdue__c == 1){
+                        Jstage.allnumber = Jstage.allnumber + 1;
+                        if (CountDel[i].Isoverdue__c == 1) {
                             Jstage.limitCount = Jstage.limitCount + 1;
                         }
                         Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                         if (CountDel[i].hospitalSpecialOffer__c) {
                             Jstage.hospitalSpecialOffer = true;
-                            newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c+ tex, Jstage);
-                        }else{
+                            newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
+                        } else {
                             Jstage.hospitalSpecialOffer = false;
-                            newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c+ tex, Jstage);
+                            newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                         }
                     }
                 }
@@ -294,8 +343,8 @@
             consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
             List<ConsumableorderdetailsInfo> newHosMidBoxList = new List<ConsumableorderdetailsInfo>();
             //鎶夿oxmap閲岀殑鍊间粠鏂拌祴缁檅oxRecords
-            for(ConsumableorderdetailsInfo bss : newMidBoxMap.values()){
-                if(bss.allnumber>0){
+            for (ConsumableorderdetailsInfo bss : newMidBoxMap.values()) {
+                if (bss.allnumber > 0) {
                     bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
                     bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
                     bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
@@ -304,8 +353,8 @@
                 }
             }
             boxRecords.sort();
-            for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
-                if(bss.allnumber>0){
+            for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+                if (bss.allnumber > 0) {
                     bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
                     bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
                     bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
@@ -316,31 +365,31 @@
             //add by rentx 2020-11-27 鍏堝垽鏂尰闄㈢壒浠风殑鐩� 鍜� 涓�
             //2020-11-27 鏃� 浜� rentx 娉ㄩ噴 start
             String temp = 'A';
-            for(ConsumableorderdetailsInfo bss : boxRecords){
+            for (ConsumableorderdetailsInfo bss : boxRecords) {
                 consumableorderdetailsRecords.add(bss);
                 //璇ヤ骇鍝佹槸鍖婚櫌鐗逛环浜у搧
-                if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id+'涓狟')) {
-                    if (newMidPieceMap.get(bss.Prod.Id+'涓狟').hospitalSpecialOffer) {
-                        consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id+'涓狟'));
-                        newMidPieceMap.remove(bss.Prod.Id+'涓狟');
+                if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '涓狟')) {
+                    if (newMidPieceMap.get(bss.Prod.Id + '涓狟').hospitalSpecialOffer) {
+                        consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狟'));
+                        newMidPieceMap.remove(bss.Prod.Id + '涓狟');
                     }
                 }
 
-                if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id+'涓狝')) {
+                if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '涓狝')) {
                     // if (newMidPieceMap.get(bss.Prod.Id+'涓狝')) {
-                        consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id+'涓狝'));
-                        newMidPieceMap.remove(bss.Prod.Id+'涓狝');
+                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狝'));
+                    newMidPieceMap.remove(bss.Prod.Id + '涓狝');
                     // }
                 }
             }
 
-            for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
-                if (newMidPieceMap.containsKey(bss.Prod.Id+'涓狟')) {
+            for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+                if (newMidPieceMap.containsKey(bss.Prod.Id + '涓狟')) {
                     consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狟'));
                 }
             }
-            for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
-                if (newMidPieceMap.containsKey(bss.Prod.Id+'涓狝')) {
+            for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+                if (newMidPieceMap.containsKey(bss.Prod.Id + '涓狝')) {
                     consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓狝'));
                 }
             }
@@ -348,25 +397,24 @@
             //2020-11-27 鏃� 浜� rentx 娉ㄩ噴 end
             // consumableorderdetailsRecords.addAll(newMidPieceMap.values());
             //2020-11-27 鏃� 浜� rentx 娉ㄩ噴 end
-            
+
             notarriveorder();
             productLimtAndDate();
             datelimitSearch();
             //add by rentx
             Integer ishos = 0;
-            for(ConsumableorderdetailsInfo bss : consumableorderdetailsRecords){
-                if(productkucun.get(bss.Prod.Id) != null){
+            for (ConsumableorderdetailsInfo bss : consumableorderdetailsRecords) {
+                if (productkucun.get(bss.Prod.Id) != null) {
                     bss.guaranteeperiod = productkucun.get(bss.Prod.Id);
                 }
                 //add by rentx 2021-3-10 start
                 if (bss.hospitalSpecialOffer) {
-                    ishos = ishos+1;
+                    ishos = ishos + 1;
                 }
-                
             }
             if (ishos > 0) {
                 hasHos = true;
-            }else{
+            } else {
                 hasHos = false;
             }
             //add by rentx 2021-3-10 end
@@ -381,28 +429,28 @@
             //鎬讳欢鏁�
             totalCount = consumableorderdetailsRecords.size();
             //椤垫暟
-            // pagecount=(totalcount  +  pagesize  - 1) / pagesize; 
+            // pagecount=(totalcount  +  pagesize  - 1) / pagesize;
             //鏄剧ず绗竴椤�
             // moveToFirst();
             makeCurrentPageRecords();
-           //鍒嗛〉
+            //鍒嗛〉
             PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
-            System.debug('pageToken==>'+ pageToken);
-            System.debug('pageSize===>'+ pageSize);
+            System.debug('pageToken==>' + pageToken);
+            System.debug('pageSize===>' + pageSize);
 
             paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
             paginatedAccounts.recordStart = pageToken + 1;
             paginatedAccounts.pageNumber = pageToken / pageSize + 1;
             Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
-            System.debug('paginatedAccounts.recordStart'+  paginatedAccounts.recordStart);
-            System.debug('paginatedAccounts.pageNumber'+  paginatedAccounts.pageNumber);
-            System.debug('paginatedAccounts.nextPageToken===>'+paginatedAccounts.nextPageToken);
-            System.debug('recordEnd'+ recordEnd);
+            System.debug('paginatedAccounts.recordStart' + paginatedAccounts.recordStart);
+            System.debug('paginatedAccounts.pageNumber' + paginatedAccounts.pageNumber);
+            System.debug('paginatedAccounts.nextPageToken===>' + paginatedAccounts.nextPageToken);
+            System.debug('recordEnd' + recordEnd);
 
             paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
             paginatedAccounts.totalRecords = totalCount;
-           //end
-           System.debug('PaginatedAccounts===>'+PaginatedAccounts);
+            //end
+            System.debug('PaginatedAccounts===>' + PaginatedAccounts);
 
             //璧嬪�煎洖浼�
             results.result = 'Success';
@@ -421,36 +469,38 @@
             results.deliveryDetailCount = Delivery_detail_count;
             results.orderNumberNotarrive = OrderNumber_notarrive;
             results.moreThanSevenDays = More_than_seven_days;
-            //add by WangXueqin 2023/05/05       
+            //add by WangXueqin 2023/05/05
             results.userPro_Type = userPro_Type;
             results.paginatedAccounts = paginatedAccounts;
         } catch (Exception e) {
             results.result = 'Fail';
-            results.errorMsg = e.getLineNumber()+'---'+e.getMessage();
+            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
         }
         return results;
     }
 
     //瓒呰繃涓�鍛ㄦ湭鍒拌揣璁㈠崟
-    public static void notarriveorder(){
+    public static void notarriveorder() {
         //over_view = false;
         Date orderdate = Date.today().addDays(-7);
-        
-        List<Consumable_order_details2__c> orderdetails = [SELECT Id,Name,Consumable_order_minor__c
-                                                            FROM Consumable_order_details2__c
-                                                            WHERE Deliver_date__c < :orderdate
-                                                            and Consumable_order_minor__c !=null
-                                                            and Dealer_Info_text__c = :accountName
-                                                            AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                                                            AND Dealer_Arrive__c = false
-                                                            ];
+
+        List<Consumable_order_details2__c> orderdetails = [
+            SELECT Id, Name, Consumable_order_minor__c
+            FROM Consumable_order_details2__c
+            WHERE
+                Deliver_date__c < :orderdate
+                AND Consumable_order_minor__c != NULL
+                AND Dealer_Info_text__c = :accountName
+                AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+                AND Dealer_Arrive__c = FALSE
+        ];
         //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'userPro_Type鈥斺�斺�斺�斺�斺��' + userPro_Type));
         Map<String, String> notarriveorderMap = new Map<String, String>();
         List<String> notarriveorderid = new List<String>();
-        for(Integer i = 0; i < orderdetails.size(); i++){
-            if(notarriveorderMap.containsKey(orderdetails[i].Consumable_order_minor__c)){
+        for (Integer i = 0; i < orderdetails.size(); i++) {
+            if (notarriveorderMap.containsKey(orderdetails[i].Consumable_order_minor__c)) {
                 continue;
-            }else{
+            } else {
                 notarriveorderMap.put(orderdetails[i].Consumable_order_minor__c, orderdetails[i].Consumable_order_minor__c);
                 //notarriveorderid.add('\'' + orderdetails[i].Consumable_order_minor__c +'\'');
                 notarriveorderid.add(orderdetails[i].Consumable_order_minor__c);
@@ -470,115 +520,137 @@
             column.add(fsm.getFieldPath());
             columns.add(fsm.getFieldPath().split('\\.'));
         }
-        system.debug('columns=====================>'+columns);
+        system.debug('columns=====================>' + columns);
         // 鑾峰緱鏄剧ず鏁版嵁
         raesList = new List<Consumable_order__c>();
         String soql = 'select Id';
         for (String s : column) {
             soql += ',' + s;
         }
-        soql += ' from Consumable_order__c where Order_type__c = \''+'璁㈠崟'+'\' and  recordtypeid =\'' + System.Label.RT_ConOrder_Delivery + '\' and Dealer_Info__c =\'' + accountid +'\'  and  Delivery_detail_count__c > 0 and showFalseNotshowTrue__c = false  ';
-        soql += ' and Order_ProType__c = \'' + userPro_Type  + '\' ' ;
+        soql +=
+            ' from Consumable_order__c where Order_type__c = \'' +
+            '璁㈠崟' +
+            '\' and  recordtypeid =\'' +
+            System.Label.RT_ConOrder_Delivery +
+            '\' and Dealer_Info__c =\'' +
+            accountid +
+            '\'  and  Delivery_detail_count__c > 0 and showFalseNotshowTrue__c = false  ';
+        soql += ' and Order_ProType__c = \'' + userPro_Type + '\' ';
         soql += ' and Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
-       
-        if(notarriveorderid.size() < 1){
-            soql +=' AND Id = null ';
-        }else{
+
+        if (notarriveorderid.size() < 1) {
+            soql += ' AND Id = null ';
+        } else {
             String sqlTail = '(\'';
-            for(Integer i = 0 ; i< notarriveorderid.size();i++){
-                if(i<notarriveorderid.size()-1){
-                    sqlTail += notarriveorderid[i]+'\',\'';
-                }else{
-                    sqlTail += notarriveorderid[i]+'\')';
+            for (Integer i = 0; i < notarriveorderid.size(); i++) {
+                if (i < notarriveorderid.size() - 1) {
+                    sqlTail += notarriveorderid[i] + '\',\'';
+                } else {
+                    sqlTail += notarriveorderid[i] + '\')';
                 }
             }
             //over_view = true;
-            soql +=' AND Id in ' + sqlTail;
+            soql += ' AND Id in ' + sqlTail;
         }
         system.debug('soql_____11111__' + soql);
         raesList = Database.query(soql);
-        // update end by vivek2020-01-15 
+        // update end by vivek2020-01-15
         Total_num = 0;
         OrderNumber_arrived = 0;
         Delivery_detail_count = 0;
         OrderNumber_notarrive = 0;
         More_than_seven_days = 0;
-        for(Consumable_order__c conorder :raesList){
-            Total_num += (Integer)conorder.Total_num__c;
-            OrderNumber_arrived += (Integer)conorder.OrderNumber_arrived__c;
-            Delivery_detail_count += (Integer)conorder.Delivery_detail_count__c;
-            OrderNumber_notarrive += (Integer)conorder.OrderNumber_notarrive__c;
-            More_than_seven_days += (Integer)conorder.More_than_seven_days__c;
+        for (Consumable_order__c conorder : raesList) {
+            Total_num += (Integer) conorder.Total_num__c;
+            OrderNumber_arrived += (Integer) conorder.OrderNumber_arrived__c;
+            Delivery_detail_count += (Integer) conorder.Delivery_detail_count__c;
+            OrderNumber_notarrive += (Integer) conorder.OrderNumber_notarrive__c;
+            More_than_seven_days += (Integer) conorder.More_than_seven_days__c;
         }
         // update end by vivek2020-01-15
     }
 
-    public static void productLimtAndDate(){
+    public static void productLimtAndDate() {
         String nowName = null, nowRightAsstModelNo = null;
-        Map<String,String> productLimt = new Map<String,String>();
-        for(Integer i = 0; i < proLimitAndDate.size(); i++){
+        Map<String, String> productLimt = new Map<String, String>();
+        for (Integer i = 0; i < proLimitAndDate.size(); i++) {
             nowName = proLimitAndDate[i];
-            if( nowName.indexOf( '|') >= 0) {
-                nowRightAsstModelNo = nowName.subString( 0, nowName.indexOf( '|'));
-                nowName = nowName.subString( nowName.indexOf( '|')+1);
+            if (nowName.indexOf('|') >= 0) {
+                nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
+                nowName = nowName.subString(nowName.indexOf('|') + 1);
             }
             productLimt.put(nowRightAsstModelNo, nowName);
         }
-        for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
-            if(productLimt.containsKey(ass.Prod.Asset_Model_No__c)){
-                ass.lowerlimit = decimal.valueOf(productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf( '|')));
-                ass.upperlimit = decimal.valueOf(productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf( '|')+1));
-           }
+        for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+            if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
+                ass.lowerlimit = decimal.valueOf(
+                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|'))
+                );
+                ass.upperlimit = decimal.valueOf(
+                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1)
+                );
+            }
         }
     }
 
-    public static void datelimitSearch(){
+    public static void datelimitSearch() {
         Set<String> barcodekucun = new Set<String>();
         //--------UpdateStart-----XHL--------------20180929-------------
-         List<Consumable_order_details2__c> orderkucun = [SELECT Id,Bar_Code__c, Name,Consumable_Product__c,
-                                                        Recordtypeid,Guarantee_period_for_products__c,
-                                                        Sterilization_limit__c,Box_Piece__c
-                                                        FROM Consumable_order_details2__c
-                                                        WHERE Dealer_Arrive__c = true
-                                                        AND Dealer_Shipment__c = false
-                                                        AND Dealer_Saled__c = false
-                                                        AND Dealer_Returned__c = false
-                                                        AND Lose_Flag__c = false
-                                                        AND Bar_Code__c !=null
-                                                        AND Product_Type__c like :userPro_Typestr
-                                                        AND Dealer_Info_text__c = :accountName
-                                                        AND Arrive_Owner_Work_Location__c = :userWorkLocation
-                                                        ORDER BY Consumable_Product__c, Sterilization_limit__c asc ];
+        List<Consumable_order_details2__c> orderkucun = [
+            SELECT
+                Id,
+                Bar_Code__c,
+                Name,
+                Consumable_Product__c,
+                Recordtypeid,
+                Guarantee_period_for_products__c,
+                Sterilization_limit__c,
+                Box_Piece__c
+            FROM Consumable_order_details2__c
+            WHERE
+                Dealer_Arrive__c = TRUE
+                AND Dealer_Shipment__c = FALSE
+                AND Dealer_Saled__c = FALSE
+                AND Dealer_Returned__c = FALSE
+                AND Lose_Flag__c = FALSE
+                AND Bar_Code__c != NULL
+                AND Product_Type__c LIKE :userPro_Typestr
+                AND Dealer_Info_text__c = :accountName
+                AND Arrive_Owner_Work_Location__c = :userWorkLocation
+            ORDER BY Consumable_Product__c, Sterilization_limit__c ASC
+        ];
         //--------UpdateEnd-----XHL--------------20180929-------------
-        for(Integer i = 0 ; i< orderkucun.size();i++){
-            if(productkucun.containsKey(orderkucun[i].Consumable_Product__c)){
+        for (Integer i = 0; i < orderkucun.size(); i++) {
+            if (productkucun.containsKey(orderkucun[i].Consumable_Product__c)) {
                 continue;
-            }else{
+            } else {
                 productkucun.put(orderkucun[i].Consumable_Product__c, orderkucun[i].Sterilization_limit__c);
             }
         }
         barcodekucun.clear();
-        for(Integer i = 0 ; i< orderkucun.size();i++){
-            if(orderkucun[i].Sterilization_limit__c < Date.today().addYears(1)){
-                if(barcodekucun.contains(orderkucun[i].Bar_Code__c)){
+        for (Integer i = 0; i < orderkucun.size(); i++) {
+            if (orderkucun[i].Sterilization_limit__c < Date.today().addYears(1)) {
+                if (barcodekucun.contains(orderkucun[i].Bar_Code__c)) {
                     continue;
-                }else{
+                } else {
                     barcodekucun.add(orderkucun[i].Bar_Code__c);
                 }
             }
         }
-        List<AggregateResult>  overlimitdatedetails = [SELECT Asset_Model_No__c prodName ,
-                                            Box_Piece__c BoxPiece,count(id) countid
-                                        FROM Consumable_order_details2__c
-                                        WHERE Bar_Code__c in :barcodekucun
-                                        AND Dealer_Arrive__c = true
-                                        AND Dealer_Shipment__c = false
-                                        AND Dealer_Saled__c = false
-                                        AND Dealer_Returned__c = false
-                                        AND Lose_Flag__c = false
-                                        GROUP BY Asset_Model_No__c,Box_Piece__c
-                                        ORDER BY Asset_Model_No__c,Box_Piece__c];
-        for(Integer i = 0 ; i< overlimitdatedetails.size();i++){
+        List<AggregateResult> overlimitdatedetails = [
+            SELECT Asset_Model_No__c prodName, Box_Piece__c BoxPiece, count(id) countid
+            FROM Consumable_order_details2__c
+            WHERE
+                Bar_Code__c IN :barcodekucun
+                AND Dealer_Arrive__c = TRUE
+                AND Dealer_Shipment__c = FALSE
+                AND Dealer_Saled__c = FALSE
+                AND Dealer_Returned__c = FALSE
+                AND Lose_Flag__c = FALSE
+            GROUP BY Asset_Model_No__c, Box_Piece__c
+            ORDER BY Asset_Model_No__c, Box_Piece__c
+        ];
+        for (Integer i = 0; i < overlimitdatedetails.size(); i++) {
             overlimitdateorderdetails.add(new ConsumableorderdetailsInfo(overlimitdatedetails[i]));
         }
     }
@@ -599,7 +671,7 @@
     // }
 
     //缂栬緫褰撳墠椤靛唴瀹�
-    public static void makeCurrentPageRecords(){
+    public static void makeCurrentPageRecords() {
         Integer startIdx;
         Integer endIdx;
         pageRecords = new List<ConsumableorderdetailsInfo>();
@@ -661,7 +733,7 @@
         @AuraEnabled
         public String BoxPiece { get; set; }
         @AuraEnabled
-        public Boolean hospitalSpecialOffer { get; set ;}
+        public Boolean hospitalSpecialOffer { get; set; }
 
         public ConsumableorderdetailsInfo(Product2__c e) {
             //check = false;
@@ -672,18 +744,17 @@
             allnumber = 0;
             limitCount = 0;
             overlimitCount = 0;
-
         }
 
         public ConsumableorderdetailsInfo(AggregateResult e) {
-            countid =Integer.valueOf(e.get('countid'));
+            countid = Integer.valueOf(e.get('countid'));
             prodName = String.valueOf(e.get('prodname'));
             BoxPiece = String.valueOf(e.get('BoxPiece'));
         }
 
         // 鎺掑簭
         public Integer compareTo(Object compareTo) {
-            ConsumableorderdetailsInfo compareToesd =(ConsumableorderdetailsInfo)compareTo;
+            ConsumableorderdetailsInfo compareToesd = (ConsumableorderdetailsInfo) compareTo;
             Integer returnValue = 0;
             if (allnumber > compareToesd.allnumber) {
                 returnValue = -1;
@@ -738,7 +809,5 @@
         public List<ConsumableorderdetailsInfo> pageCodeRecords;
         @AuraEnabled
         public PaginatedAccounts paginatedAccounts;
-
-       
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1