From 144f9e4fce6a6d3bc01e2e6c723762d74e8d694a Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 14 十月 2026 15:50:59 +0800
Subject: [PATCH] 【丽水】getCurrentUserServiceSubtaskCount 和 patItem对不上总数

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java |   49 ++++++++++++++++++++++++-------------------------
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml                       |    2 +-
 2 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
index 986a89d..c3a17ac 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
@@ -843,39 +843,38 @@
     @ApiOperation("鑾峰彇褰撳墠鐢ㄦ埛闅忚鏁伴噺缁熻")
     @PostMapping("/getCurrentUserServiceSubtaskCount")
     public Map<String, Object> getCurrentUserServiceSubtaskCount() {
-        Map<String, Object> map = new HashMap<>();
-        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
-        SysUserDept sysUserDept = new SysUserDept();
-        sysUserDept.setUserId(sysUser.getUserId());
-        sysUserDept.setOrgid(sysUser.getOrgid());
-        sysUserDept.setCampusid(sysUser.getCampusid());
-        sysUserDept.setDeptType("1");
-        List<Map<String, Object>> deptCodesMap = sysUser.getBelongDepts();
-        List<Map<String, Object>> wardCodesMap = sysUser.getBelongWards();
-        List<String> deptCodes = deptCodesMap.stream()
-                        .map(item -> item.get("deptCode"))
-                        .filter(obj -> obj != null) // 鍓旈櫎null
-                        .map(Object::toString)
-                        .collect(Collectors.toList());
-        List<String> wardCodes = wardCodesMap.stream()
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        if (loginUser == null || loginUser.getUser() == null) {
+            return new HashMap<>();
+        }
+        SysUser sysUser = loginUser.getUser();
+        List<String> deptCodes = CollectionUtils.emptyIfNull(sysUser.getBelongDepts()).stream()
+                .map(item -> item.get("deptCode"))
+                .filter(Objects::nonNull) // 鍓旈櫎null
+                .map(Object::toString)
+                .collect(Collectors.toList());
+        List<String> wardCodes = CollectionUtils.emptyIfNull(sysUser.getBelongWards()).stream()
                 .map(item -> item.get("districtCode"))
-                .filter(obj -> obj != null) // 鍓旈櫎null
+                .filter(Objects::nonNull) // 鍓旈櫎null
                 .map(Object::toString)
                 .collect(Collectors.toList());
         ServiceSubtaskEntity entity = new ServiceSubtaskEntity();
         entity.setOrgid(sysUser.getOrgid());
         entity.setLeaveldeptcodes(deptCodes);
         entity.setLeavehospitaldistrictcodes(wardCodes);
-        if (ObjectUtils.isNotEmpty(sysUser)) {
-            if (!("admin").equals(sysUser.getUserName())) {
-                if (CollectionUtils.isNotEmpty(deptCodes) && CollectionUtils.isNotEmpty(wardCodes)) {
-                    map = serviceSubtaskService.getCurrentUserServiceSubtaskCount(entity);
-                }
-            } else {
-                map = serviceSubtaskService.getCurrentUserServiceSubtaskCount(entity);
-            }
+        // admin 鏌ョ湅鍏ㄩ櫌锛涢潪 admin 鍙閰嶇疆浜嗙瀹ゆ垨鐥呭尯浠讳竴缁村害鍗冲彲鏌ヨ锛圫QL 涓负 OR 鍏崇郴锛�
+        boolean isAdmin = "admin".equals(sysUser.getUserName());
+        if (isAdmin || CollectionUtils.isNotEmpty(deptCodes) || CollectionUtils.isNotEmpty(wardCodes)) {
+            return serviceSubtaskService.getCurrentUserServiceSubtaskCount(entity);
         }
-        return map;
+        // 闈� admin 涓旀湭閰嶇疆浠讳綍绉戝/鐥呭尯鏉冮檺鏃讹紝杩斿洖榛樿 0 鍊硷紝閬垮厤鍓嶇鍙栦笉鍒� key
+        Map<String, Object> empty = new HashMap<>();
+        empty.put("pendingVisitCount", 0);
+        empty.put("failedVisitCount", 0);
+        empty.put("abnormalVisitCount", 0);
+        empty.put("warnningVisitCount", 0);
+        empty.put("allVisitCount", 0);
+        return empty;
     }
 
     @ApiOperation("鑾峰彇褰撳墠鐢ㄦ埛瀹f暀鏁伴噺缁熻")
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 28ad277..3ff5f5a 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -2854,7 +2854,7 @@
         </if>
         <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
                 or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
-            AND(
+            AND (
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
                 leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("

--
Gitblit v1.9.3