From ab2884ade73fed97d1e7d7daf4b9b5b6dee83fdd Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 29 十月 2026 09:26:12 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java |  101 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 85 insertions(+), 16 deletions(-)

diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java b/ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java
index 4087dd9..0a8d93c 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java
@@ -20,11 +20,8 @@
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.utils.reflect.ReflectUtils;
 import com.ruoyi.common.core.service.TaskOpsTriggerApi;
-import com.ruoyi.task.api.spi.TaskSysConfigPort;
-import com.ruoyi.task.api.spi.TaskSysUserDeptPort;
 import com.ruoyi.satisfaction.api.SatisfactionExportBundle;
 import com.ruoyi.satisfaction.api.SatisfactionFacade;
-import com.ruoyi.task.api.spi.TaskSubtaskRecordPort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -54,6 +51,7 @@
 import com.ruoyi.task.domain.ServiceSubtaskStatistic;
 import com.ruoyi.task.domain.ServiceTask;
 import com.ruoyi.task.domain.VO.ServiceSubtaskCotinueCountVO;
+import com.ruoyi.task.service.IServiceSubtaskRecordService;
 import com.ruoyi.task.service.IServiceSubtaskService;
 import com.ruoyi.task.service.IServiceTaskService;
 import com.ruoyi.task.domain.PatArchiveSrmVO;
@@ -65,6 +63,8 @@
 import com.ruoyi.task.domain.VO.ServiceSubtaskVO;
 import com.ruoyi.task.domain.VO.TransferDeptVO;
 import com.ruoyi.task.domain.ServiceSubtaskExport;
+import com.ruoyi.system.service.ISysConfigService;
+import com.ruoyi.system.service.ISysUserDeptService;
 
 /**
  * 鍗曚竴浠诲姟锛堥殢璁匡級Controller
@@ -104,13 +104,13 @@
     private IServiceTaskService serviceTaskService;
 
     @Autowired
-    private TaskSysUserDeptPort taskSysUserDeptPort;
+    private ISysUserDeptService sysUserDeptService;
 
     @Autowired
-    private TaskSubtaskRecordPort serviceSubtaskRecordService;
+    private IServiceSubtaskRecordService serviceSubtaskRecordService;
 
     @Autowired
-    private TaskSysConfigPort taskSysConfigPort;
+    private ISysConfigService sysConfigService;
 
     /**
      * 浠诲姟杩愮淮瑙﹀彂鑳藉姏銆�
@@ -169,6 +169,7 @@
         LoginUser loginUser = getLoginUser();
         SysUser user = loginUser.getUser();
         serviceSubtaskVO.setOrgid(user.getOrgid());
+        // 闄㈠尯鍙栫櫥褰曚細璇濋噷鐨勫�硷紙鐧诲綍椤甸�夋嫨鐨勯櫌鍖猴紝瑙� SysLoginService#login锛�
         serviceSubtaskVO.setCampusid(user.getCampusid());
         ServiceSubtaskEntity serviceSubtaskEntity = null;
         if (serviceSubtaskVO != null) {
@@ -558,7 +559,7 @@
                         sysUserWard.setOrgid(user.getOrgid());
                         sysUserWard.setCampusid(user.getCampusid());
                         sysUserWard.setDeptType("2");
-                        List<SysUserDept> wardList = taskSysUserDeptPort.selectSysUserDeptList(sysUserWard);
+                        List<SysUserDept> wardList = sysUserDeptService.selectSysUserDeptList(sysUserWard);
                         if (CollectionUtils.isNotEmpty(wardList)) {
                             leavehospitaldistrictcodes = wardList.stream().map(SysUserDept::getDeptCode).collect(Collectors.toList());
                         }
@@ -573,7 +574,7 @@
                         sysUserDept.setOrgid(user.getOrgid());
                         sysUserDept.setCampusid(user.getCampusid());
                         sysUserDept.setDeptType("1");
-                        List<SysUserDept> deptList = taskSysUserDeptPort.selectSysUserDeptList(sysUserDept);
+                        List<SysUserDept> deptList = sysUserDeptService.selectSysUserDeptList(sysUserDept);
                         if (CollectionUtils.isNotEmpty(deptList)) {
                             deptCodes = deptList.stream().map(SysUserDept::getDeptCode).collect(Collectors.toList());
                         }
@@ -583,7 +584,7 @@
             }
         }
 
-        String followUpCountStyle = taskSysConfigPort.selectConfigValue("followUpCountStyle", serviceSubtaskCountReq.getOrgid());
+        String followUpCountStyle = sysConfigService.selectConfigByKey("followUpCountStyle", serviceSubtaskCountReq.getOrgid());
         if (ObjectUtils.isNotEmpty(followUpCountStyle)) {
             serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle);
         } else {
@@ -608,7 +609,7 @@
         Integer offset = PageUtils.getOffset(serviceSubtaskCountReq.getPageNum(), serviceSubtaskCountReq.getPageSize());
         serviceSubtaskCountReq.setPageNum(offset);
 
-        String followUpCountStyle = taskSysConfigPort.selectConfigValue("followUpCountStyle", serviceSubtaskCountReq.getOrgid());
+        String followUpCountStyle = sysConfigService.selectConfigByKey("followUpCountStyle", serviceSubtaskCountReq.getOrgid());
         if (ObjectUtils.isNotEmpty(followUpCountStyle)) {
             serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle);
         } else {
@@ -720,7 +721,7 @@
         String orgid = loginUser.getUser().getOrgid();
         String configKey = serviceSubtaskCountReq.getConfigKey();
         if (StringUtils.isNotEmpty(configKey)) {
-            String configValue = taskSysConfigPort.selectConfigValue(configKey, orgid);
+            String configValue = sysConfigService.selectConfigByKey(configKey, orgid);
             serviceSubtaskCountReq.setConfigValue(configValue);
             if (StringUtils.isEmpty(configValue)) {
                 String logInfo = "getSfStatisticsCount-鍙傛暟 " + configKey + " 鏈厤缃�, 璇烽厤缃ソ鍚庨噸璇�";
@@ -729,7 +730,7 @@
             }
         }
 
-        String followUpCountStyle = taskSysConfigPort.selectConfigValue("followUpCountStyle", orgid);
+        String followUpCountStyle = sysConfigService.selectConfigByKey("followUpCountStyle", orgid);
         if (ObjectUtils.isNotEmpty(followUpCountStyle)) {
             serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle);
         } else {
@@ -769,7 +770,7 @@
         }
         String configKey = serviceSubtaskCountReq.getConfigKey();
         if (StringUtils.isNotEmpty(configKey)) {
-            String configValue = taskSysConfigPort.selectConfigValue(configKey, serviceSubtaskCountReq.getOrgid());
+            String configValue = sysConfigService.selectConfigByKey(configKey, serviceSubtaskCountReq.getOrgid());
             serviceSubtaskCountReq.setConfigValue(configValue);
             if (StringUtils.isEmpty(configValue)) {
                 String logInfo = "getSfStatisticsCount-鍙傛暟 " + configKey + " 鏈厤缃�, 璇烽厤缃ソ鍚庨噸璇�";
@@ -800,7 +801,7 @@
         //澶嶈瘖缁熻
         String configKey = serviceSubtaskCountReq.getConfigKey();
         if (StringUtils.isNotEmpty(configKey)) {
-            String configValue = taskSysConfigPort.selectConfigValue(configKey, serviceSubtaskCountReq.getOrgid());
+            String configValue = sysConfigService.selectConfigByKey(configKey, serviceSubtaskCountReq.getOrgid());
             if (StringUtils.isEmpty(configValue)) {
                 String logInfo = "getSfStatisticsCountDetails-鍙傛暟 " + configKey + " 鏈厤缃�, 璇烽厤缃ソ鍚庨噸璇�";
                 log.error(logInfo);
@@ -856,13 +857,13 @@
         sysUserDept.setOrgid(sysUser.getOrgid());
         sysUserDept.setCampusid(sysUser.getCampusid());
         sysUserDept.setDeptType("1");
-        List<SysUserDept> sysUserDepts = taskSysUserDeptPort.selectSysUserDeptList(sysUserDept);
+        List<SysUserDept> sysUserDepts = sysUserDeptService.selectSysUserDeptList(sysUserDept);
         SysUserDept sysUserWard = new SysUserDept();
         sysUserWard.setUserId(sysUser.getUserId());
         sysUserWard.setOrgid(sysUser.getOrgid());
         sysUserWard.setCampusid(sysUser.getCampusid());
         sysUserWard.setDeptType("2");
-        List<SysUserDept> sysUserWards = taskSysUserDeptPort.selectSysUserDeptList(sysUserWard);
+        List<SysUserDept> sysUserWards = sysUserDeptService.selectSysUserDeptList(sysUserWard);
         List<String> deptCodes = sysUserDepts.stream().map(SysUserDept::getDeptCode).collect(Collectors.toList());
         List<String> wardCodes = sysUserWards.stream().map(SysUserDept::getDeptCode).collect(Collectors.toList());
         ServiceSubtaskEntity entity = new ServiceSubtaskEntity();
@@ -881,6 +882,74 @@
         return map;
     }
 
+    /**
+     * 褰撳墠鐧诲綍浜哄緟澶勭悊闅忚浠诲姟缁熻锛堟寜鍑洪櫌骞存湀鍒嗙粍锛屽嚭闄㈤殢璁裤�侀棬璇婇殢璁垮垎寮�璁℃暟锛�
+     * <p>
+     * 鍙e緞锛歴ervice_subtask 涓�
+     * service_type = '2' 鍑洪櫌闅忚 / '3' 闂ㄨ瘖闅忚
+     * + 寰呴殢璁跨姸鎬侊紙sendstate in 1,2,3,5,7锛�
+     * + 鍑洪櫌婊� 7 澶╋紙鍚��7 澶╁墠閭d竴澶┿�嶅嚭闄㈢殑鎮h�咃級
+     * + 鍙湅鏈�杩� 4 涓嚭闄㈡湀浠斤紙鍚綋鏈堬級锛�
+     * 绉戝/鐥呭尯鏉冮檺鍙� OR锛堜笌闅忚鍒楄〃 deptOrDistrict=2 涓�鑷达級銆�
+     *
+     * @return { userName, nickName, total, months: [{ month: 'yyyy-MM', dischargeCount, outpatientCount }] }
+     * 鍙繑鍥炴湁鏁版嵁鐨勬湀浠斤紝娌℃湁鏁版嵁鐨勬湀浠界敱鍓嶇琛� 0
+     */
+    @ApiOperation("鑾峰彇褰撳墠鐧诲綍浜哄緟澶勭悊闅忚浠诲姟缁熻锛堟寜鍑洪櫌骞存湀锛�")
+    @PostMapping("/pendingTaskMonthStats")
+    public Map<String, Object> pendingTaskMonthStats() {
+        LoginUser loginUser = getLoginUser();
+        SysUser sysUser = loginUser.getUser();
+        Map<String, Object> result = new LinkedHashMap<>();
+        result.put("userName", sysUser.getUserName());
+        result.put("nickName", sysUser.getNickName());
+        result.put("total", 0L);
+        result.put("months", new ArrayList<>());
+
+        // 娉ㄦ剰锛氫笉瑕佺敤 sys_user_dept.campusid 杩囨护鈥斺�旇繖寮犺〃鐨� campusid 澶ч噺涓� NULL锛�
+        // 甯︿笂瀹冧細鐩存帴鏌ヤ笉鍑烘潈闄愶紝缁熻缁撴灉姘歌繙鏄� 0銆傞櫌鍖烘潈闄愮敱 orgid + userId + deptType 宸茶兘瀹氫綅銆�
+        SysUserDept deptQuery = new SysUserDept();
+        deptQuery.setUserId(sysUser.getUserId());
+        deptQuery.setOrgid(sysUser.getOrgid());
+        deptQuery.setDeptType("1");
+        List<SysUserDept> sysUserDepts = sysUserDeptService.selectSysUserDeptList(deptQuery);
+
+        SysUserDept wardQuery = new SysUserDept();
+        wardQuery.setUserId(sysUser.getUserId());
+        wardQuery.setOrgid(sysUser.getOrgid());
+        wardQuery.setDeptType("2");
+        List<SysUserDept> sysUserWards = sysUserDeptService.selectSysUserDeptList(wardQuery);
+
+        boolean isAdmin = "admin".equals(sysUser.getUserName());
+        if (!isAdmin && CollectionUtils.isEmpty(sysUserDepts) && CollectionUtils.isEmpty(sysUserWards)) {
+            // 鏃㈡病鏈夌瀹や篃娌℃湁鐥呭尯鏉冮檺鏃朵笉缁熻锛岄伩鍏嶈秺鏉冪湅鍒板叏鏈烘瀯鏁版嵁
+            return result;
+        }
+
+        // sys_user_dept 閲屽悓涓�绉戝/鐥呭尯浼氶噸澶嶅緢澶氳锛屽幓閲嶅悗鍐嶆嫾 IN锛岄伩鍏� SQL 鍙傛暟杩囧
+        List<String> deptCodes = sysUserDepts.stream()
+                .map(SysUserDept::getDeptCode)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+        List<String> wardCodes = sysUserWards.stream()
+                .map(SysUserDept::getDeptCode)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+
+        ServiceSubtaskEntity entity = new ServiceSubtaskEntity();
+        entity.setOrgid(sysUser.getOrgid());
+        entity.setLeaveldeptcodes(deptCodes);
+        entity.setLeavehospitaldistrictcodes(wardCodes);
+
+        Map<String, Object> stats = serviceSubtaskService.getPendingManualTaskMonthStats(entity);
+        if (stats != null) {
+            result.putAll(stats);
+        }
+        return result;
+    }
+
     @ApiOperation("鑾峰彇褰撳墠鐢ㄦ埛瀹f暀鏁伴噺缁熻")
     @PostMapping("/gethelibraryCount")
     public Map<String, Object> getHeLibraryCount(@RequestBody HeLibraryCountVO heLibraryCountVO) {

--
Gitblit v1.9.3