From 6427886a12c3c6cd56c5dde2e3437d0d608da59c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 09 十一月 2026 14:23:48 +0800
Subject: [PATCH] 修复管理员科室病区为空与延续护理任务出院维度过滤
---
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml | 39 +++++++++---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 45 +++++++++++----
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 4 +
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java | 40 +++++++++++--
ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml | 40 ++++++++++++
5 files changed, 137 insertions(+), 31 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
index dfa1ef9..3ea1069 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -63,6 +63,12 @@
@Value("${spring.profiles.active}")
private String active;
+ /**
+ * 绠$悊鍛樼敤鎴稩D鍒楄〃锛堥厤缃」 isAdmin锛夈�傜鐞嗗憳涓嶅彈銆岀敤鎴�-閮ㄩ棬鍏崇郴琛ㄣ�嶉檺鍒讹紝鐩存帴鐪嬫湰鏈烘瀯鍏ㄩ儴绉戝/鐥呭尯銆�
+ */
+ @Value("${isAdmin:1}")
+ private List<Long> isAdmin;
+
// @Value("${wx_appid}")
// private String wxAppid;
//
@@ -240,23 +246,43 @@
ajax.put("user", user);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
- List<SysDept> sysDeptKSs = null;
- List<SysDept> sysDeptBQs = null;
+ // 绉戝/鐥呭尯涓嬫媺鐨勬暟鎹簮锛�
+ // 路 绠$悊鍛橈紙璐﹀彿 admin锛屾垨鍛戒腑閰嶇疆 isAdmin 鐨勭敤鎴稩D锛夛細鐩存帴鏌� sys_dept 鍙栨湰鏈烘瀯鍏ㄩ儴绉戝/鐥呭尯锛�
+ // 涓嶅啀鍏宠仈 sys_user_dept锛屼篃涓嶆寜闄㈠尯杩囨护鈥斺�旂鐞嗗憳澶╃劧鎷ユ湁鍏ㄩ儴绉戝鏉冮檺锛�
+ // 路 鏅�氱敤鎴凤細浠嶇劧鎸夈�岀敤鎴�-閮ㄩ棬鍏崇郴琛ㄣ�嶅彧杩斿洖鑷繁鍚嶄笅鐨勭瀹�/鐥呭尯锛堜繚鎸佸師閫昏緫锛夈��
SysUserDept sysUserDept = new SysUserDept();
- sysUserDept.setUserId(user.getUserId());
- sysUserDept.setDeptType("1");
sysUserDept.setOrgid(user.getOrgid());
- sysUserDept.setCampusid(user.getCampusid());
- sysDeptKSs = sysDeptService.selectLeafSysDeptListBySysUserDept(sysUserDept);
+ if (!isAdminUser(user)) {
+ sysUserDept.setUserId(user.getUserId());
+ sysUserDept.setCampusid(user.getCampusid());
+ }
+ sysUserDept.setDeptType("1");
+ List<SysDept> sysDeptKSs = sysDeptService.selectLeafSysDeptListBySysUserDept(sysUserDept);
ajax.put("belongDepts", sysDeptKSs);
sysUserDept.setDeptType("2");
- sysDeptBQs = sysDeptService.selectLeafSysDeptListBySysUserDept(sysUserDept);
+ List<SysDept> sysDeptBQs = sysDeptService.selectLeafSysDeptListBySysUserDept(sysUserDept);
ajax.put("belongWards", sysDeptBQs);
return ajax;
}
/**
+ * 鏄惁绠$悊鍛橈細璐﹀彿鍚嶄负 admin锛屾垨鐢ㄦ埛ID鍛戒腑閰嶇疆椤� isAdmin銆�
+ * <p>
+ * 绠$悊鍛樺彇绉戝/鐥呭尯鏃朵笉璧� sys_user_dept锛圚IS 閲囬泦鏄庣‘鎺掗櫎 admin锛岃琛ㄩ噷绠$悊鍛樻病鏈夋暟鎹級锛�
+ * 鍚﹀垯浼氬嚭鐜般�岀櫥褰曟垚鍔熶絾绉戝/鐥呭尯涓嬫媺涓虹┖銆嶃��
+ */
+ private boolean isAdminUser(SysUser user) {
+ if (user == null) {
+ return false;
+ }
+ if ("admin".equalsIgnoreCase(user.getUserName())) {
+ return true;
+ }
+ return user.getUserId() != null && isAdmin != null && isAdmin.contains(user.getUserId());
+ }
+
+ /**
* 鑾峰彇璺敱淇℃伅
*
* @return 璺敱淇℃伅
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
index 213b376..60a6159 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -334,6 +334,10 @@
public List<SysDept> selectLeafSysDeptListBySysUserDept(SysUserDept sysUserDept){
List<SysDept> list = deptMapper.selectSysDeptListBySysUserDept(sysUserDept);
+ // userId 涓虹┖ = 绠$悊鍛樺彇鏈満鏋勫叏閲忕瀹�/鐥呭尯锛氳銆屽叏閮ㄣ�嶏紝涓嶈兘鍐嶆寜鍙跺瓙鑺傜偣杩囨护鎺夌埗绾ч儴闂�
+ if (sysUserDept != null && sysUserDept.getUserId() == null) {
+ return list == null ? new ArrayList<>() : list;
+ }
if(CollectionUtils.isNotEmpty(list)){
list = TreeUtils.getLeafDepts(list);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index 29b434b..f8a826b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -146,7 +146,10 @@
deptIds.add(sysDept.getDeptId());
}
SysUserDept sysUserDept = new SysUserDept();
- sysUserDept.setUserId(sysUser.getUserId());
+ // 绠$悊鍛橈細涓嶆寜鐢ㄦ埛杩囨护锛坰ys_user_dept 閲屾病鏈� admin 鐨勬暟鎹級锛岀洿鎺ュ彇鏈満鏋勫叏閮ㄧ瀹�/鐥呭尯
+ if (!isAdminUser(sysUser)) {
+ sysUserDept.setUserId(sysUser.getUserId());
+ }
sysUserDept.setDeptType(sysUser.getSearchscope());
sysUserDept.setOrgid(sysUser.getOrgid());
List<SysUserDept> sysUserDeptKSs = null;
@@ -201,7 +204,7 @@
if (sysUser.getUserType().equals("鎮h��") && StringUtils.isNotEmpty(split[3]) && !split[3].equals("null") && !sysUser.getUserType().equals(split[3].trim()))
throw new BaseException("褰撳墠鐢ㄦ埛绫诲瀷涓庣櫥褰曠敤鎴风被鍨嬩笉涓�鑷�");
- boolean isAdmin = StringUtils.isNotEmpty(split[0]) && "admin".equals(split[0]);
+ boolean isAdmin = isAdminUser(sysUser);
IUserExtInfoService userExtInfoService = SpringUtils.getBean(IUserExtInfoService.class);
Executor executor = SpringUtils.getBean("threadPoolTaskExecutor");
@@ -220,7 +223,7 @@
// 绛夊緟鏈烘瀯淇℃伅
Map<String, String> userOrgInfo = new HashMap<>();
try {
- userOrgInfo = orgInfoFuture.get(5, TimeUnit.SECONDS);
+ userOrgInfo = orgInfoFuture.get(50, TimeUnit.SECONDS);
} catch (Exception e) {
log.warn("鑾峰彇鐢ㄦ埛鏈烘瀯淇℃伅瓒呮椂鎴栧紓甯�", e);
}
@@ -258,8 +261,8 @@
CompletableFuture<List<SysDept>> ksFuture = CompletableFuture.supplyAsync(() -> selectLeafSysDeptForAdmin(deptKS), executor);
CompletableFuture<List<SysDept>> bqFuture = CompletableFuture.supplyAsync(() -> selectLeafSysDeptForAdmin(deptBQ), executor);
try {
- sysUserDeptKSs = distinctByDeptCode(DtoConversionUtils.sourceToTarget(ksFuture.get(5, TimeUnit.SECONDS), SysUserDept.class));
- sysUserDeptBQs = distinctByDeptCode(DtoConversionUtils.sourceToTarget(bqFuture.get(5, TimeUnit.SECONDS), SysUserDept.class));
+ sysUserDeptKSs = distinctByDeptCode(DtoConversionUtils.sourceToTarget(ksFuture.get(50, TimeUnit.SECONDS), SysUserDept.class));
+ sysUserDeptBQs = distinctByDeptCode(DtoConversionUtils.sourceToTarget(bqFuture.get(50, TimeUnit.SECONDS), SysUserDept.class));
} catch (Exception e) {
log.warn("鑾峰彇admin绉戝/鐥呭尯淇℃伅瓒呮椂鎴栧紓甯�", e);
}
@@ -358,6 +361,23 @@
log.warn("鑾峰彇婊℃剰搴﹀垎绫诲け璐ワ紝宸查檷绾т负绌虹粨鏋滐紙涓嶅奖鍝嶇櫥褰曪級銆俹rgid={}", orgid, e);
return Collections.emptyMap();
}
+ }
+
+ /**
+ * 鏄惁绠$悊鍛橈細璐﹀彿鍚嶄负 admin锛屾垨鐢ㄦ埛ID鍛戒腑閰嶇疆椤� isAdmin銆�
+ * <p>
+ * 绠$悊鍛樺彇绉戝/鐥呭尯鏃朵笉鎸� sys_user_dept 杩囨护鈥斺�擧IS 閲囬泦鍐欒琛ㄦ椂鏄庣‘鎺掗櫎浜� admin
+ * 锛圕ollectHISMapper 鐨� yhyksxx/yhybfxx 閮芥湁 {@code ud.user_id != 'admin'}锛夛紝
+ * 璧板叧鑱旀煡璇細寰楀埌绌哄垪琛紝琛ㄧ幇涓恒�岀櫥褰曟垚鍔熶絾鍒涘缓浠诲姟鏃堕�変笉鍒扮瀹ょ梾鍖恒�嶃��
+ */
+ private boolean isAdminUser(SysUser sysUser) {
+ if (sysUser == null) {
+ return false;
+ }
+ if ("admin".equalsIgnoreCase(sysUser.getUserName())) {
+ return true;
+ }
+ return sysUser.getUserId() != null && isAdmin != null && isAdmin.contains(sysUser.getUserId());
}
/**
@@ -1022,8 +1042,11 @@
public List<SysUserDept> selectLeafSysDeptList(SysUserDept sysUserDept){
List<SysDept> list = sysDeptMapper.selectSysDeptListBySysUserDept(sysUserDept);
- if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){
- list = TreeUtils.getLeafDepts(list);
+ // userId 涓虹┖ = 绠$悊鍛樺彇鏈満鏋勫叏閲忥細瑕併�屾墍鏈夌瀹ょ梾鍖恒�嶏紝涓嶈兘鍐嶆寜鍙跺瓙鑺傜偣杩囨护
+ if (sysUserDept == null || sysUserDept.getUserId() != null) {
+ if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){
+ list = TreeUtils.getLeafDepts(list);
+ }
}
List<SysUserDept> list1 = DtoConversionUtils.sourceToTarget(list, SysUserDept.class);
return list1;
@@ -1031,11 +1054,9 @@
public List<SysDept> selectLeafSysDeptForAdmin(SysDept sysDept){
SysUserDept sysUserDept = DtoConversionUtils.sourceToTarget(sysDept, SysUserDept.class);
- List<SysDept> list = sysDeptMapper.selectSysDeptListBySysUserDept(sysUserDept);
- if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){
- list = TreeUtils.getLeafDepts(list);
- }
- return list;
+ // 绠$悊鍛樺垎鏀細sysUserDept 涓嶅甫 userId锛宮apper 浼氱洿鎺ユ煡 sys_dept锛堜笉鍏宠仈 sys_user_dept锛夛紝
+ // 杩斿洖鏈満鏋勫叏閮ㄧ瀹�/鐥呭尯锛涜繖閲屼笉鍐嶅仛鍙跺瓙杩囨护锛屽惁鍒欍�屾墍鏈夌瀹ょ梾鍖恒�嶄細琚爫鎺夌埗绾ч儴闂ㄣ��
+ return sysDeptMapper.selectSysDeptListBySysUserDept(sysUserDept);
}
/**
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 225eac3..cf4e077 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -283,17 +283,36 @@
where dept_id = #{deptId}
</delete>
+ <!--
+ 鏌ヨ绉戝/鐥呭尯锛�
+ 路 userId 鏈夊�硷紙鏅�氱敤鎴� / 鐢ㄦ埛缂栬緫椤碉細鏌ユ煇涓敤鎴峰悕涓嬬殑閮ㄩ棬锛夆啋 鍏宠仈 sys_user_dept锛�
+ 路 userId 涓虹┖锛堢鐞嗗憳锛氱湅鏈満鏋勫叏閮ㄧ瀹�/鐥呭尯锛夆啋 鍙煡 sys_dept锛屼笉鍏宠仈鍏崇郴琛ㄣ��
+ 涓轰粈涔堣鍒嗘敮锛欻IS 閲囬泦鍐� sys_user_dept 鏃舵槑纭帓闄や簡 admin锛圕ollectHISMapper 鐨�
+ yhyksxx/yhybfxx 閮芥湁 ud.user_id != 'admin'锛夛紝绠$悊鍛樺湪鍏崇郴琛ㄩ噷娌℃湁鏁版嵁锛岃蛋 inner join
+ 浼氬緱鍒扮┖鍒楄〃锛岃〃鐜板氨鏄�岀櫥褰曟垚鍔熶絾鍒涘缓浠诲姟鏃堕�変笉鍒扮瀹ょ梾鍖恒�嶃��
+ 鍙﹀涓嶅仛闄㈠尯杩囨护锛堢鐞嗗憳璺ㄩ櫌鍖猴級锛岄櫌鍖洪殧绂诲彧瀵规櫘閫氱敤鎴风敓鏁堛��
+ -->
<select id="selectSysDeptListBySysUserDept" parameterType="com.ruoyi.common.core.domain.entity.SysUserDept"
resultMap="SysDeptResult">
- <include refid="selectDeptVo"/>
- inner join sys_user_dept ud
- on d.dept_code = ud.dept_code
- where 1=1
- and d.del_flag = 0
- and ud.del_flag = 0
- <if test="orgid != null">and d.orgid = #{orgid} and ud.orgid = #{orgid}</if>
- <if test="campusid != null">and d.campusid = #{campusid}</if>
- <if test="userId != null">and ud.user_id = #{userId}</if>
- <if test="deptType != null and deptType != ''">and d.dept_type = #{deptType}</if>
+ <choose>
+ <when test="userId != null">
+ <include refid="selectDeptVo"/>
+ inner join sys_user_dept ud
+ on d.dept_code = ud.dept_code
+ where 1=1
+ and d.del_flag = 0
+ and ud.del_flag = 0
+ <if test="orgid != null">and d.orgid = #{orgid} and ud.orgid = #{orgid}</if>
+ <if test="campusid != null">and d.campusid = #{campusid}</if>
+ <if test="deptType != null and deptType != ''">and d.dept_type = #{deptType}</if>
+ and ud.user_id = #{userId}
+ </when>
+ <otherwise>
+ <include refid="selectDeptVo"/>
+ where d.del_flag = 0
+ <if test="orgid != null">and d.orgid = #{orgid}</if>
+ <if test="deptType != null and deptType != ''">and d.dept_type = #{deptType}</if>
+ </otherwise>
+ </choose>
</select>
</mapper>
diff --git a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
index 89625bb..1eca03b 100644
--- a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
+++ b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -373,16 +373,34 @@
<sql id="filterLeaveDimAnd">
/* f-v3 */
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- AND leavehospitaldistrictcode IN
+ AND (
+ leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
#{lvWardCodeItem}
</foreach>
+ <!-- 寤剁画鎶ょ悊浠诲姟锛坰ervice_type='99'锛夊彲浠ュ湪鎮h�呰繕娌″嚭闄㈡椂鐢熸垚锛�
+ 杩欑被璁板綍鍙湁銆屽湪闄㈢淮搴︺�嶏紙hospitaldistrictcode / deptcode锛夛紝鍑洪櫌缁村害鏄� NULL銆�
+ NULL 涓嶅尮閰嶄换浣� IN锛屼换鍔′細銆屾彁绀虹敓鎴愭垚鍔熴�佸垪琛ㄩ噷鍗存煡涓嶅埌銆嶏紝
+ 鎵�浠ュ嚭闄㈢淮搴︿负绌烘椂鐢ㄥ悓涓�濂楃紪鐮佷綋绯荤殑鍦ㄩ櫌缁村害鍏滃簳銆� -->
+ OR (service_type = '99' AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode = '')
+ AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+ #{lvWardCodeItem}
+ </foreach>)
+ )
</if>
<if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
- AND leaveldeptcode IN
+ AND (
+ leaveldeptcode IN
<foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
#{lvDeptCodeItem}
</foreach>
+ OR (service_type = '99' AND (leaveldeptcode IS NULL OR leaveldeptcode = '')
+ AND deptcode IN
+ <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+ #{lvDeptCodeItem}
+ </foreach>)
+ )
</if>
</sql>
@@ -423,20 +441,38 @@
or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
AND (
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+ (
leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
#{lvWardCodeItem}
</foreach>
+ <!-- 寤剁画鎶ょ悊浠诲姟锛坰ervice_type='99'锛夊彲浠ュ湪鎮h�呰繕娌″嚭闄㈡椂鐢熸垚锛�
+ 杩欑被璁板綍鍙湁銆屽湪闄㈢淮搴︺�嶏紙hospitaldistrictcode / deptcode锛夛紝鍑洪櫌缁村害鏄� NULL銆�
+ NULL 涓嶅尮閰嶄换浣� IN锛屼换鍔′細銆屾彁绀虹敓鎴愭垚鍔熴�佸垪琛ㄩ噷鍗存煡涓嶅埌銆嶏紝
+ 鎵�浠ュ嚭闄㈢淮搴︿负绌烘椂鐢ㄥ悓涓�濂楃紪鐮佷綋绯荤殑鍦ㄩ櫌缁村害鍏滃簳銆� -->
+ OR (service_type = '99' AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode = '')
+ AND hospitaldistrictcode IN
+ <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")">
+ #{lvWardCodeItem}
+ </foreach>)
+ )
</if>
<if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
OR
</if>
<if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+ (
leaveldeptcode IN
<foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
#{lvDeptCodeItem}
</foreach>
+ OR (service_type = '99' AND (leaveldeptcode IS NULL OR leaveldeptcode = '')
+ AND deptcode IN
+ <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")">
+ #{lvDeptCodeItem}
+ </foreach>)
+ )
</if>
)
</if>
--
Gitblit v1.9.3