From 41ad0c0840a6135b7acf2280f0eebdc29bf6479b Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 30 五月 2023 14:25:11 +0800
Subject: [PATCH] backup0530

---
 force-app/main/default/classes/LexConsumableController.cls |   80 ++++++++++++++++++++++++++++++----------
 1 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/force-app/main/default/classes/LexConsumableController.cls b/force-app/main/default/classes/LexConsumableController.cls
index cf82fc8..ae8b99b 100644
--- a/force-app/main/default/classes/LexConsumableController.cls
+++ b/force-app/main/default/classes/LexConsumableController.cls
@@ -105,6 +105,8 @@
     // 鐧诲綍鑰呭伐浣滃湴
     private static String userWorkLocation;
     public static String agencyProType { get; set; }
+    public static String agencyProType1 {get;set;}  //lt 20230526 瀹夊窘涓ょエ鍒� add
+    private static Boolean OSHFLG;//lt 20230517 瀹夊窘涓ょエ鍒� add
     public static String methodType { get; set; }
     public static String hospitalName { get; set; }
     public static String hospitalId { get; set; }
@@ -165,9 +167,11 @@
             if (selectedIdMap.containsKey(consumableorderdetailsRecords[i].Prod.Id)) {
                 addNo++;
                 //continue;
-            } else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
-                break;
-            } else {
+            } 
+            // else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
+            //     break;
+            // } 
+            else {
                 if (consumableorderdetailsRecords[i].check == false) {
                     consumableorderdetailsRecords[i].esd = orderdetails1;
                 }
@@ -175,8 +179,8 @@
                 consumableorderdetailsRecordsview.add(consumableorderdetailsRecords[i]);
                 addNo++;
             }
-            if (addNo >= size)
-                break;
+            // if (addNo >= size)
+            //     break;
         }
         return consumableorderdetailsRecordsview;
     }
@@ -227,10 +231,21 @@
             }
             userId = UserInfo.getUserId();
             List<user> Useracc = new List<user>();
-            Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
+            //lt 20230517 瀹夊窘涓ょエ鍒� add ,OSHFLG__c
+            Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c,OSHFLG__c FROM user WHERE id = :userId ];
             accountid = Useracc[0].accountid;
             userWorkLocation = Useracc[0].Work_Location__c;
             agencyProType = Useracc[0].UserPro_Type__c;
+            agencyProType1 = Useracc[0].UserPro_Type__c; //lt 20230526 瀹夊窘涓ょエ鍒� add
+            //lt 20230526 瀹夊窘涓ょエ鍒� start
+            OSHFLG = Useracc[0].OSHFLG__c; //lt 20230517 瀹夊窘涓ょエ鍒� add
+            if(OSHFLG){
+                agencyProType1 = 'OSH';
+            }
+            else if(String.isBlank(Useracc[0].UserPro_Type__c)){
+                agencyProType1 = 'ET';
+            }
+            //lt 20230526 瀹夊窘涓ょエ鍒� end
             if (String.isBlank(Useracc[0].UserPro_Type__c)) {
                 agencyProType = 'ET';
             }
@@ -249,8 +264,9 @@
                     RecordType.DeveloperName = 'AgencyContract'
                     AND Contract_Decide_Start_Date__c <= :dateToday
                     AND Contract_Decide_End_Date__c >= :dateToday
-                    AND Contact_Type__c LIKE :agencyProType
-                    AND Agent_Ref__c = :accountid
+                    and Contact_Type__c like :agencyProType1//lt 20230517 瀹夊窘涓ょエ鍒� add 1
+                    and Agent_Ref__c =:accountid
+                    and OSH_Dealer__c =: OSHFLG  //lt 20230517 瀹夊窘涓ょエ鍒� add
             ];
             for (Account contract : contractList) {
                 contactDealer.add(contract.Id);
@@ -314,9 +330,10 @@
                     FROM Account
                     WHERE
                         ParentId = :accountid
-                        AND Contact_Type__c LIKE :agencyProType
+                        AND Contact_Type__c like :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
                         AND Contract_Decide_Start_Date__c <= :Date.Today()
                         AND Contract_Decide_End_Date__c >= :Date.Today()
+                        AND OSH_Dealer__c =: OSHFLG  //lt 20230517 瀹夊窘涓ょエ鍒� add
                 ];
                 if (contract.size() == 1) {
                     contractName = contract[0].Name;
@@ -612,6 +629,8 @@
             results.attachmentRecoeds = attachmentRecoeds;
             results.cansee = cansee;
             results.agencyProType = agencyProType;
+            results.agencyProType1 = agencyProType1;
+            results.OSHFLG = OSHFLG;
             results.userWorkLocation = userWorkLocation;
             results.accountName = accountName;
             results.category_Goods = category_Goods;
@@ -1259,18 +1278,20 @@
             if (selectedIdMap.containsKey(consumableorderdetailsRecords[i].Prod.Id)) {
                 addNo++;
                 //continue;
-            } else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
-                break;
-            } else {
+            } 
+            // else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
+            //     break;
+            // } 
+            else {
                 if (consumableorderdetailsRecords[i].check == false) {
                     consumableorderdetailsRecords[i].esd = orderdetails1;
                 }
                 consumableorderdetailsRecordsview.add(consumableorderdetailsRecords[i]);
                 addNo++;
             }
-            if (addNo >= size){
-                break;
-            }
+            // if (addNo >= size){
+            //     break;
+            // }
         }
         return consumableorderdetailsRecordsview;
     }
@@ -1591,10 +1612,13 @@
         String consumableorderdetailsRecordsviewStr,
         String contactDealerStr,
         String methodTypeStr,
-        String hospitalIdStr
+        String hospitalIdStr,
+        String contractIdStr,
+        String agencyProType1Str,
+        Boolean OSHFLGStr
     ) {
         ESetId = '';
-        return save(contractNameStr,cocStr,agencyProTypeStr,accountidStr,consumableorderdetailsRecordsviewStr,contactDealerStr,methodTypeStr,ESetId,hospitalIdStr);
+        return save(contractNameStr,cocStr,agencyProTypeStr,accountidStr,consumableorderdetailsRecordsviewStr,contactDealerStr,methodTypeStr,ESetId,hospitalIdStr,contractIdStr,agencyProType1Str,OSHFLGStr);
     }
 
     //淇濆瓨鎸夐挳 
@@ -1608,7 +1632,10 @@
         String contactDealerStr,
         String methodTypeStr,
         String eSetIdStr,
-        String hospitalIdStr
+        String hospitalIdStr,
+        String contractIdStr,
+        String agencyProType1Str,
+        Boolean OSHFLGStr
     ){
         Results results = new Results();
         errorMsgList = new List<String>();
@@ -1619,6 +1646,9 @@
         methodType = methodTypeStr;
         ESetId = eSetIdStr;
         hospitalId = hospitalIdStr;
+        contractId = contractIdStr;
+        agencyProType1 = agencyProType1Str;
+        OSHFLG = OSHFLGStr;
         coc = (Consumable_order__c)JSON.deserialize(cocStr, Consumable_order__c.class);
         contactDealer = (List<String>)JSON.deserialize(contactDealerStr, List<String>.class);
         consumableorderdetailsRecordsview = (List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetailsRecordsviewStr, List<ConsumableorderdetailsInfo>.class);
@@ -1639,10 +1669,12 @@
                 FROM account
                 WHERE
                     Name = :contractName
+                    AND Id =: contractId   //lt 20230517 瀹夊窘涓ょエ鍒� add
                     AND Contract_Decide_Start_Date__c <= :Date.Today()
                     AND Contract_Decide_End_Date__c >= :Date.Today()
-                    AND Contact_Type__c LIKE :agencyProType
-                    AND Agent_Ref__c = :accountid
+                    AND Contact_Type__c like :agencyProType1  //lt 20230517 瀹夊窘涓ょエ鍒� add 1
+                    AND Agent_Ref__c =:accountid
+                    AND OSH_Dealer__c =: OSHFLG  //lt 20230517 瀹夊窘涓ょエ鍒� add
             ];
             if (contract.size() <= 0) {
                 // coc.Order_effective_contact__c.addError('涓嶅瓨鍦ㄧ殑鍚堝悓锛岃閲嶆柊纭銆�');
@@ -1783,9 +1815,13 @@
                 FROM Account
                 WHERE
                     Name = :contractName
+                    AND Id =: contractId   //lt 20230517 瀹夊窘涓ょエ鍒� add
+                    AND Contact_Type__c like :agencyProType1  //lt 20230517 瀹夊窘涓ょエ鍒� add  1
                     AND Contact_Type__c LIKE :agencyProType
                     AND Contract_Decide_Start_Date__c <= :Date.Today()
                     AND Contract_Decide_End_Date__c >= :Date.Today()
+                    AND Contract_Decide_End_Date__c >= :Date.Today()
+                    AND OSH_Dealer__c =: OSHFLG  //lt 20230517 瀹夊窘涓ょエ鍒� add
             ];
             if (at.size() > 0 && at[0].Dealer_discount__c != null) {
                 disCount = at[0].Dealer_discount__c;
@@ -2208,6 +2244,10 @@
         public List<String> proLimitAndDate;
         @AuraEnabled
         public Boolean isNoteStay;
+        @AuraEnabled
+        public Boolean OSHFLG;
+        @AuraEnabled
+        public String agencyProType1;
     }
 
     public class CusOption {

--
Gitblit v1.9.1