From 4b81304e73c093795ae418cfb4ce537b603660c9 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 16 四月 2026 09:36:46 +0800
Subject: [PATCH] 修改任务模板的基本templateid不存在,去基本模板查询

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java |  114 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 92 insertions(+), 22 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index 650928f..61869a6 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -1,6 +1,7 @@
 package com.smartor.service.impl;
 
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -12,6 +13,7 @@
 import com.smartor.common.FtpService;
 import com.smartor.config.PhoneUtils;
 import com.smartor.domain.*;
+import com.smartor.domain.VO.ServiceSubtaskCotinueCountVO;
 import com.smartor.domain.entity.ServiceSubtaskEntity;
 import com.smartor.mapper.*;
 import com.smartor.service.*;
@@ -410,18 +412,18 @@
         // 澶勭悊绌哄紓甯�
         if (MapUtils.isEmpty(result)) {
             result = new HashMap<>();
+            // 纭繚鎵�鏈� key 閮芥湁鍊硷紝閬垮厤绌烘寚閽堝紓甯�
+            // MyBatis 鐨� SUM 鍦ㄦ病鏈夊尮閰嶈鏃朵細杩斿洖 null
+            result.putIfAbsent("wzx", 0);
+            result.putIfAbsent("ysf", 0);
+            result.putIfAbsent("yc", 0);
+            result.putIfAbsent("jg", 0);
+            result.putIfAbsent("fssb", 0);
+            result.putIfAbsent("yfs", 0);
+            result.putIfAbsent("blq", 0);
+            result.putIfAbsent("dsf", 0);
+            result.putIfAbsent("total", 0);
         }
-        // 纭繚鎵�鏈� key 閮芥湁鍊硷紝閬垮厤绌烘寚閽堝紓甯�
-        // MyBatis 鐨� SUM 鍦ㄦ病鏈夊尮閰嶈鏃朵細杩斿洖 null
-        result.putIfAbsent("wzx", 0);
-        result.putIfAbsent("ysf", 0);
-        result.putIfAbsent("yc", 0);
-        result.putIfAbsent("jg", 0);
-        result.putIfAbsent("fssb", 0);
-        result.putIfAbsent("yfs", 0);
-        result.putIfAbsent("blq", 0);
-        result.putIfAbsent("dsf", 0);
-
         return result;
     }
 
@@ -576,14 +578,14 @@
             if (StringUtils.isNotEmpty(serviceTaskVO.getLibtemplateid())) {
                 serviceTask.setLibtemplateid(serviceTaskVO.getLibtemplateid());
                 serviceTask.setLibtemplatename(serviceTaskVO.getLibtemplatename());
-            }else {
+            } else {
                 if (ObjectUtils.isNotEmpty(serviceTaskVO.getSvyTaskTemplateVO())) {
-                    serviceTask.setLibtemplateid(""+serviceTaskVO.getSvyTaskTemplateVO().getTemplateid());
-                    serviceTask.setLibtemplatename(""+serviceTaskVO.getLibtemplatename());
+                    serviceTask.setLibtemplateid("" + serviceTaskVO.getSvyTaskTemplateVO().getTemplateid());
+                    serviceTask.setLibtemplatename("" + serviceTaskVO.getLibtemplatename());
                 }
                 if (ObjectUtils.isNotEmpty(serviceTaskVO.getIvrTaskTemplateVO())) {
-                    serviceTask.setLibtemplateid(""+serviceTaskVO.getIvrTaskTemplateVO().getLibtemplateid());
-                    serviceTask.setLibtemplatename(""+serviceTaskVO.getIvrTaskTemplateVO().getLibtemplatename());
+                    serviceTask.setLibtemplateid("" + serviceTaskVO.getIvrTaskTemplateVO().getLibtemplateid());
+                    serviceTask.setLibtemplatename("" + serviceTaskVO.getIvrTaskTemplateVO().getLibtemplatename());
                 }
             }
             if (serviceTaskVO.getTemplateid() != null) {
@@ -1591,7 +1593,12 @@
                             subtaskDetailTrace.setAsrtext(phoneCallReqYQVO.getAsrtext());
                             subtaskDetailTrace.setRecordpath(phoneCallReqYQVO.getRecordpath());
                             subtaskDetailTrace.setPatid(serviceSubtask.getPatid());
-                            subtaskDetailTrace.setPatdesc(serviceSubtask.getSendname() + "," + serviceSubtask.getPhone() + "," + serviceSubtask.getDeptname());
+                            JSONObject patdescJson = new JSONObject();
+                            patdescJson.put("sendname", serviceSubtask.getSendname());
+                            patdescJson.put("phone", serviceSubtask.getPhone());
+                            patdescJson.put("age", serviceSubtask.getAge());
+                            patdescJson.put("sex", serviceSubtask.getSex() != null ? serviceSubtask.getSex() == 1 ? "鐢�" : "濂�" : null);
+                            subtaskDetailTrace.setPatdesc(patdescJson.toJSONString());
                             subtaskDetailTrace.setTodeptcode(ivrTaskTemplateScriptVO.getDutyDeptCode());
                             subtaskDetailTrace.setTodeptname(ivrTaskTemplateScriptVO.getDutyDeptName());
                             subtaskDetailTrace.setOrgid(serviceSubtask.getOrgid());
@@ -1976,7 +1983,7 @@
 //        if (existSize > 0) return pullTaskVOList;
         int count = 0;
         long size = listOps.size("cache-0");
-        log.error("---------鎵撶數璇濅箣鍓嶇紦瀛樹腑鐨勬暟鎹噺锛歿}", size);
+        log.info("---------鎵撶數璇濅箣鍓嶇紦瀛樹腑鐨勬暟鎹噺锛歿}", size);
         if (size > 0) {
             //phoneCount()  閫氳繃缁欏嚭鐨勬瘡涓皬鏃堕渶瑕佹墦鍑虹殑鐢佃瘽閲忥紝绠楀嚭鍒版櫄涓�8鐐逛竴鐐硅兘鎵撳嚭澶氬皯涓數璇濓紝鑾峰彇鍒版�婚噺
             //濡傛灉闇�瑕佺珛鍗虫墽琛岀殑鏁版嵁閲忓ぇ浜庝竴澶╄鎵ц鐨勪笂闄愶紝鍒欏彧鍙栦笂闄愮殑鏁伴噺锛屽叾瀹冪殑鍒欐斁鍥瀝edis涓�
@@ -2025,7 +2032,7 @@
             }
         }
 //        if (existList.size() != 0) redisCache.setCacheListRight("cache-exist", existList);
-        log.error("-----------瀹為檯鎷夊彇鐨勭數璇濇暟鎹噺锛歿}", CollectionUtils.isNotEmpty(pullTaskVOList) ? pullTaskVOList.size() : null);
+        log.info("-----------瀹為檯鎷夊彇鐨勭數璇濇暟鎹噺锛歿}", CollectionUtils.isNotEmpty(pullTaskVOList) ? pullTaskVOList.size() : null);
         return pullTaskVOList;
     }
 
@@ -2659,9 +2666,9 @@
 
         if (visitCount != null && visitCount > 1) {
             serviceSubtaskStatistic = getStatisticAgain(serviceSubtaskList, followUpCountStyle);
-        }else if(visitCount != null && visitCount == 1){
+        } else if (visitCount != null && visitCount == 1) {
             serviceSubtaskStatistic = getStatisticFirst(serviceSubtaskList, followUpCountStyle);
-        }else {
+        } else {
             //鏍煎紡鍖栦负涓や綅灏忔暟鐨勭櫨鍒嗘瘮
             DecimalFormat percentFormat = new DecimalFormat("##.##%");
             serviceSubtaskStatistic.setDeptname(serviceSubtaskList.get(0).getDeptname());
@@ -2921,6 +2928,7 @@
 
     /**
      * 棣栨闅忚缁熻
+     *
      * @param serviceSubtaskList
      * @param followUpCountStyle
      * @return
@@ -3082,6 +3090,7 @@
 
     /**
      * 鍐嶆闅忚缁熻
+     *
      * @param serviceSubtaskList
      * @param followUpCountStyle
      * @return
@@ -3839,7 +3848,7 @@
             if (serviceSubtaskPreachform1.getSort() == spSize.size() && failSendstate.equals("4")) {
                 serviceSubtask.setCurrentPreachform(preachform);
                 serviceSubtask.setSendstate(5L);
-                serviceSubtask.setRemark("setFailPreachForm鏂规硶 褰撳墠鐨刾reachform宸茬粡鏄渶鍚庝竴涓簡锛屽叏澶辫触浜�");
+                serviceSubtask.setRemark("鎵�鏈夊彂閫佹柟寮忓潎鏈幏鍙栫粨鏋滐紝浠诲姟澶辫触");
                 serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                 return true;
             }
@@ -4009,4 +4018,65 @@
     public Map<String, Object> getCurrentUserServiceSubtaskCount(ServiceSubtaskEntity entity) {
         return serviceSubtaskMapper.getCurrentUserServiceSubtaskCount(entity);
     }
+
+    @Override
+    public Map<String, Object> getContinueNurseCount(ServiceSubtaskCotinueCountVO vo) {
+        boolean hasDistrict = !CollectionUtils.isEmpty(vo.getLeavehospitaldistrictcodes());
+        boolean hasDept = !CollectionUtils.isEmpty(vo.getDeptcodes());
+
+        List<Map<String, Object>> districtRows;
+        List<Map<String, Object>> deptRows;
+
+        if (hasDistrict) {
+            // 鍙紶浜嗙梾鍖猴細浠呮寜鐥呭尯缁村害缁熻
+            districtRows = serviceSubtaskMapper.getContinueNurseCount(vo);
+            deptRows = Collections.emptyList();
+        } else if (hasDept) {
+            // 鍙紶浜嗙瀹わ細浠呮寜绉戝缁村害缁熻
+            districtRows = Collections.emptyList();
+            deptRows = serviceSubtaskMapper.getContinueNurseCountByDept(vo);
+        } else {
+            // 閮芥湭浼狅細鐥呭尯鍜岀瀹ゅ悇缁熻涓�閬�
+            districtRows = serviceSubtaskMapper.getContinueNurseCount(vo);
+            deptRows = serviceSubtaskMapper.getContinueNurseCountByDept(vo);
+        }
+
+        long totalNoContinue = 0L;
+        long totalContinue = 0L;
+        List<Map<String, Object>> detail = new ArrayList<>();
+
+        for (Map<String, Object> row : districtRows) {
+            String groupName = row.get("groupName") == null
+                    ? (row.get("groupCode") == null ? "" : row.get("groupCode").toString())
+                    : row.get("groupName").toString();
+            long noCnt = row.get("noContinueCnt") == null ? 0L : Long.parseLong(row.get("noContinueCnt").toString());
+            long yesCnt = row.get("continueCnt") == null ? 0L : Long.parseLong(row.get("continueCnt").toString());
+            totalNoContinue += noCnt;
+            totalContinue += yesCnt;
+            Map<String, Object> item = new LinkedHashMap<>();
+            item.put("鏈欢缁璤" + groupName, noCnt);
+            item.put("宸插欢缁璤"+groupName, yesCnt);
+            detail.add(item);
+        }
+
+        for (Map<String, Object> row : deptRows) {
+            String groupName = row.get("groupName") == null
+                    ? (row.get("groupCode") == null ? "" : row.get("groupCode").toString())
+                    : row.get("groupName").toString();
+            long noCnt = row.get("noContinueCnt") == null ? 0L : Long.parseLong(row.get("noContinueCnt").toString());
+            long yesCnt = row.get("continueCnt") == null ? 0L : Long.parseLong(row.get("continueCnt").toString());
+            totalNoContinue += noCnt;
+            totalContinue += yesCnt;
+            Map<String, Object> item = new LinkedHashMap<>();
+            item.put("鏈欢缁璤" + groupName, noCnt);
+            item.put("宸插欢缁璤" + groupName, yesCnt);
+            detail.add(item);
+        }
+
+        Map<String, Object> result = new LinkedHashMap<>();
+        result.put("鏈欢缁�绘暟閲�", totalNoContinue);
+        result.put("宸插欢缁�绘暟閲�", totalContinue);
+        result.put("璇︽儏", detail);
+        return result;
+    }
 }

--
Gitblit v1.9.3