From e14d6d0619330cad423f06493e3aa2371faa2a8f Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期六, 09 九月 2023 14:02:23 +0800
Subject: [PATCH] Sit期间修改

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

diff --git a/force-app/main/default/classes/Xin_SearchVisitorPlace.cls b/force-app/main/default/classes/Xin_SearchVisitorPlace.cls
index 70e366c..6af633e 100644
--- a/force-app/main/default/classes/Xin_SearchVisitorPlace.cls
+++ b/force-app/main/default/classes/Xin_SearchVisitorPlace.cls
@@ -47,7 +47,7 @@
         Map<Id, Account> accMap = new Map<Id, Account>((List<Account>) Database.query(queryString));
 	    if (accMap.size() <= 50) {
 	        // 銇曘倝銇渷鍗樹綅銇儑銉笺偪銈掓绱�
-	        Map<Id, Account> stateDepartmentMap = ControllerUtil.selectDepartByHospitalState(nameCondition, reporterState, 51 - accMap.size());
+	        Map<Id, Account> stateDepartmentMap = selectDepartByHospitalState(nameCondition, reporterState, 51 - accMap.size());
 	        if (stateDepartmentMap.size() > 0) {
 	            for (Id accId : stateDepartmentMap.keySet()) {
 	                if (!accMap.containsKey(accId)) {
@@ -60,4 +60,23 @@
 	    this.results.sort();                                    // order by Name
 	    //this.results = Database.Query('select id, Name from Account where Name like ' + nameCondition + ' AND Id NOT IN (select AccountId From AccountShare where UserOrGroupId = \'00510000000gaBh\' and RowCause = \'ImplicitParent\' ) order by Name limit 30');
 	}
+	// 鐪佸崢浣� or 鍏ㄥ浗銇ê鐧傜銈掓绱紝鏈�鍒濄伄50浠�
+    public Map<Id, Account> selectDepartByHospitalState(String nameCondition, String reporterState, Integer limitCnt) {
+        User loginUser = [Select Id, State_Hospital__c, Job_Category__c from User where Id =: UserInfo.getUserId()];
+        String queryString = 'select Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name from Account where' + nameCondition + ' Hospital__r.RecordType.DeveloperName = \'HP\' and Is_Active__c <> \'鐒″姽\'';
+        if (loginUser.Job_Category__c == 'GI甯傚満'
+                || loginUser.Job_Category__c == 'SP甯傚満'
+                || loginUser.Job_Category__c == '鏈嶅姟鏈儴'
+                || loginUser.Job_Category__c == '鍩硅'
+        ) {
+            // 鍏ㄥ浗绡勫洸銆併仾銇倐銇椼仾銇�
+        } else {
+            // 鐪佸崢浣嶃伄鏉′欢杩藉姞
+            system.debug('selectDepartByHospitalState reporterState=' + reporterState);
+            queryString += ' and Parent.Parent.State_Master__r.Name = :reporterState';
+        }
+        queryString += ' order by Name limit :limitCnt';
+        system.debug('selectDepartByHospitalState queryString=' + queryString);
+        return new Map<Id, Account>((List<Account>) Database.query(queryString));
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1