From 0c1f8c479065739f3c7a5126de8e667035d00b58 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 12 十月 2026 14:21:52 +0800
Subject: [PATCH] 【丽水】满意度模块化:新增 ruoyi-satisfaction 独立模块

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java |   72 ++++++++++++++++++++++++++---------
 1 files changed, 53 insertions(+), 19 deletions(-)

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 1c28e14..20f6318 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
@@ -4,6 +4,7 @@
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.domain.entity.*;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.DtoConversionUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -15,6 +16,7 @@
 import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.common.core.service.IUserExtInfoService;
+import com.ruoyi.common.core.service.ISatisfactionCategoryService;
 import com.ruoyi.system.mapper.SysUserDeptMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -73,6 +75,10 @@
 
     @Value("${isAdmin}")
     private List<Long> isAdmin;
+
+
+    @Value("${spring.profiles.active}")
+    private String active;
 
     /**
      * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃
@@ -133,6 +139,7 @@
         SysUserDept sysUserDept = new SysUserDept();
         sysUserDept.setUserId(sysUser.getUserId());
         sysUserDept.setDeptType(sysUser.getSearchscope());
+        sysUserDept.setOrgid(sysUser.getOrgid());
         List<SysUserDept> sysUserDeptKSs = null;
         List<SysUserDept> sysUserDeptBQs = null;
         if (StringUtils.isNotEmpty(sysUser.getSearchscope()) && sysUser.getSearchscope().equals("0")) {
@@ -181,14 +188,16 @@
         String[] split = userName.split("&");
         SysUser sysUser = userMapper.selectUserByUserNameByCondition(split[0], split[1], null);
         if (Objects.isNull(sysUser)) return sysUser;
+        //杩欓噷鍙崱鐢ㄦ埛绫诲瀷涓衡�滄偅鑰呪�濈殑
+        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]);
         IUserExtInfoService userExtInfoService = SpringUtils.getBean(IUserExtInfoService.class);
         Executor executor = SpringUtils.getBean("threadPoolTaskExecutor");
 
         // === 骞惰鏌ヨ: 鐢ㄦ埛鏈烘瀯淇℃伅 + 閮ㄩ棬鍒楄〃 ===
-        CompletableFuture<Map<String, String>> orgInfoFuture = CompletableFuture.supplyAsync(() ->
-                userExtInfoService.getUserOrgInfo(sysUser.getUserId().toString(), split[1], split[2]), executor);
+        CompletableFuture<Map<String, String>> orgInfoFuture = CompletableFuture.supplyAsync(() -> userExtInfoService.getUserOrgInfo(sysUser.getUserId().toString(), split[1], split[2]), executor);
 
         CompletableFuture<List<SysDept>> deptsFuture;
         if (isAdmin) {
@@ -306,9 +315,40 @@
             }
             sysUser.setBelongDepts(list);
             // 璁剧疆婊℃剰搴﹀垎绫伙紙璧扮紦瀛橈級
-            sysUser.setSatisfactionCategories(userExtInfoService.getSatisfactionCategories(sysUser.getOrgid()));
+            // 婊℃剰搴︽ā鍧楀寲鍚庯細涓嶅啀缁忕敱 smartor 鐨� IUserExtInfoService锛�
+            // 鏀逛负鎸� ruoyi-common 鐨� ISatisfactionCategoryService 鎺ュ彛鏌ユ壘瀹炵幇
+            // 锛堝疄鐜板湪 ruoyi-satisfaction锛岀敱甯搁┗闂ㄩ潰淇濊瘉"妯″潡鍏抽棴/缂哄け鏃惰繑鍥炵┖ Map"锛�
+            sysUser.setSatisfactionCategories(loadSatisfactionCategories(sysUser.getOrgid()));
         }
         return sysUser;
+    }
+
+    /**
+     * 瀹夊叏鍦拌幏鍙栨弧鎰忓害鍒嗙被銆�
+     * <p>
+     * 婊℃剰搴︽ā鍧楀彲浠ヨ閰嶇疆鍏抽棴锛坽@code sys_config} 鍙傛暟 {@code satisfaction.enabled=false}锛夛紝涔熷彲浠ユ暣浣撲笉鍦ㄤ緷璧栭噷锛�
+     * 杩欎袱绉嶆儏鍐典笅閮藉繀椤�<b>涓嶅奖鍝嶇櫥褰曚富娴佺▼</b>锛屽洜姝よ繖閲岋細
+     * <ul>
+     *   <li>瀹瑰櫒閲屾病鏈� {@code ISatisfactionCategoryService} 瀹炵幇鏃惰繑鍥炵┖ Map锛�</li>
+     *   <li>璋冪敤杩囩▼涓姏浠讳綍寮傚父涔熷彧璁版棩蹇楀苟杩斿洖绌� Map銆�</li>
+     * </ul>
+     *
+     * @param orgid 鏈烘瀯ID
+     * @return 婊℃剰搴﹀垎绫伙紱涓嶅彲鐢ㄦ椂杩斿洖绌� Map锛堜笉浼氳繑鍥� null锛�
+     */
+    private Map<String, Object> loadSatisfactionCategories(String orgid) {
+        try {
+            ISatisfactionCategoryService satisfactionCategoryService =
+                    SpringUtils.getBean(ISatisfactionCategoryService.class);
+            if (satisfactionCategoryService == null) {
+                return Collections.emptyMap();
+            }
+            Map<String, Object> categories = satisfactionCategoryService.getSatisfactionCategories(orgid);
+            return categories == null ? Collections.emptyMap() : categories;
+        } catch (Exception e) {
+            log.warn("鑾峰彇婊℃剰搴﹀垎绫诲け璐ワ紝宸查檷绾т负绌虹粨鏋滐紙涓嶅奖鍝嶇櫥褰曪級銆俹rgid={}", orgid, e);
+            return Collections.emptyMap();
+        }
     }
 
     /**
@@ -333,17 +373,15 @@
     @Override
     public SysUser selectUserByUserNameAndDeptId(String userName) {
         String[] split = userName.split("&");
-        if (split[2].contains("null")) {
+        //鍗楀崕闄勪竴涔熶笉楠岃瘉dept_id浜�
+        if (split[2].contains("null") || active.equals("nhfy")) {
             split[2] = null;
         }
         SysUser sysUser = userMapper.selectUserByUserNameByCondition(split[0], split[1], split[2]);
 
         //鑾峰彇褰撳墠鐧婚檰浜虹殑鏈烘瀯鍜岄櫌锟�?
         IUserExtInfoService userExtInfoService2 = SpringUtils.getBean(IUserExtInfoService.class);
-        Map<String, String> userOrgInfo2 = userExtInfoService2.getUserOrgInfo(
-                sysUser.getUserId().toString(),
-                split[1],
-                split[3]);
+        Map<String, String> userOrgInfo2 = userExtInfoService2.getUserOrgInfo(sysUser.getUserId().toString(), split[1], split[3]);
         if (!userOrgInfo2.isEmpty()) {
             sysUser.setOrgid(userOrgInfo2.get("orgid"));
             sysUser.setCampusid(userOrgInfo2.get("campusid"));
@@ -709,6 +747,12 @@
 //                sysUserDeptMapper.insertSysUserDept(sysUserDep);
 //            }
 //        }
+        //鍒犻櫎鍘熸湁鍏崇郴
+        SysUserDept delSysUserDept = new SysUserDept();
+        delSysUserDept.setUserId(user.getUserId());
+        delSysUserDept.setOrgid(user.getOrgid());
+        sysUserDeptMapper.deleteSysUserDeptByUserId(delSysUserDept);
+
         if (!CollectionUtils.isEmpty(user.getDeptCodes())) {
             for (String deptCode : user.getDeptCodes()) {
                 SysDept sysDept = sysDeptMapper.selectDeptByCode("1", user.getOrgid(), deptCode);
@@ -721,20 +765,15 @@
                 sysUserDept.setOrgid(user.getOrgid());
                 sysUserDept.setDeptCode(deptCode);
                 sysUserDept.setDeptId(sysDept.getDeptId());
-                List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDept);
                 sysUserDept.setDelFlag(0L);
                 sysUserDept.setDeptType("1");
                 sysUserDept.setDeptName(sysDept.getDeptName());
                 sysUserDept.setUpdateTime(new Date());
-                if (!CollectionUtils.isEmpty(sysUserDepts)) {
-                    sysUserDept.setId(sysUserDepts.get(0).getId());
-                    sysUserDeptMapper.updateSysUserDept(sysUserDept);
-                    continue;
-                }
                 sysUserDept.setCreateTime(new Date());
                 sysUserDeptMapper.insertSysUserDept(sysUserDept);
             }
         }
+
         if (!CollectionUtils.isEmpty(user.getWardCodes())) {
             for (String wardCode : user.getWardCodes()) {
                 SysDept sysDept = sysDeptMapper.selectDeptByCode("2", user.getOrgid(), wardCode);
@@ -746,16 +785,11 @@
                 sysUserDept.setDeptCode(wardCode);
                 sysUserDept.setDeptId(sysDept.getDeptId());
                 sysUserDept.setOrgid(user.getOrgid());
-                List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDept);
                 sysUserDept.setDelFlag(0L);
                 sysUserDept.setDeptType("2");
                 sysUserDept.setOrgid(user.getOrgid());
                 sysUserDept.setDeptName(sysDept.getDeptName());
                 sysUserDept.setUpdateTime(new Date());
-                if (!CollectionUtils.isEmpty(sysUserDepts)) {
-                    sysUserDeptMapper.updateSysUserDept(sysUserDept);
-                    continue;
-                }
                 sysUserDept.setCreateTime(new Date());
                 sysUserDeptMapper.insertSysUserDept(sysUserDept);
             }

--
Gitblit v1.9.3