From 38955eba4ef0e86bac6b1993b6b03abbbec2a929 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 25 十一月 2026 17:55:06 +0800
Subject: [PATCH] Merge branch '20261118市一随访' into smartor_ls_merge

---
 ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java |  589 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 531 insertions(+), 58 deletions(-)

diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java b/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
index eb6683c..2491df4 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
@@ -280,6 +280,9 @@
     private static final String AGAIN_LOCK_KEY_PREFIX = "smartor:again:lock:";
     private static final long AGAIN_LOCK_SECONDS = 30L;
 
+    /** 缂欎簯鍘夸汉姘戝尰闄㈡満鏋勭紪鐮� */
+    private static final String JINYUN_PEOPLES_HOSPITAL_ORGID = "47246116333112211A1001";
+
     /**
      * 鏌ヨ鍗曚竴浠诲姟锛堥殢璁匡級
      *
@@ -885,6 +888,39 @@
     }
 
     /**
+     * 鍏煎銆岀瀹�/鐥呭尯銆嶅瓧娈甸噸鍛藉悕鍓嶇殑鏃у叆鍙傘��
+     *
+     * <p>2026-11 璧凤細{@code deptcode/deptname} = 鍦ㄩ櫌绉戝锛寋@code leaveldeptcode/leaveldeptname} = 绂婚櫌绉戝銆�
+     * 浣嗗墠绔�/鏃ц皟鐢ㄦ柟锛坽@code /serviceSubtask/addSubTask}锛変粛鍙兘鎶婄瀹ゆ斁鍦� {@code deptcode/deptname} 閲屻��
+     * 鑻ヤ笉褰掍綅锛屽瓙浠诲姟浼氳惤鍒般�屽湪闄㈢淮搴︺�嶏紝鍒楄〃鎸夌闄㈢瀹ょ瓫閫夋椂鏌ヤ笉鍒帮紙鏈绾夸笂 2654501/2663019 鍗虫闂锛夈��
+     *
+     * <p>瑙勫垯锛�
+     * <ul>
+     *   <li>鍙闈炲欢缁姢鐞嗭紙{@code service_type != '99'}锛夌敓鏁堬紱99 鍏佽浣跨敤鍦ㄩ櫌缁村害锛�</li>
+     *   <li>绂婚櫌绉戝涓虹┖涓� {@code deptcode} 鏈夊�兼椂锛屾妸 {@code deptcode/deptname} 杩佸埌绂婚櫌缁村害锛�</li>
+     *   <li>娓呯┖鍦ㄩ櫌缁村害锛岄伩鍏嶅悓涓�浠界瀹ゅ悓鏃跺懡涓袱缁勭瓫閫夛紙涓� {@code toSubtaskFromTaskVO} 鐨勫彛寰勪竴鑷达級銆�</li>
+     * </ul>
+     */
+    private void alignLeaveDeptFromLegacyDept(ServiceSubtask serviceSubtask) {
+        if (serviceSubtask == null || "99".equals(serviceSubtask.getServiceType())) {
+            return;
+        }
+        if (StringUtils.isEmpty(serviceSubtask.getLeaveldeptcode())
+                && StringUtils.isNotEmpty(serviceSubtask.getDeptcode())) {
+            serviceSubtask.setLeaveldeptcode(serviceSubtask.getDeptcode());
+        }
+        if (StringUtils.isEmpty(serviceSubtask.getLeaveldeptname())
+                && StringUtils.isNotEmpty(serviceSubtask.getDeptname())) {
+            serviceSubtask.setLeaveldeptname(serviceSubtask.getDeptname());
+        }
+        // 鎵嬪伐鏂板鍏ュ彛娌℃湁銆屽湪闄㈢淮搴︺�嶇殑鍙潬鏉ユ簮锛涗换鍔¢厤缃噷鐨勭瀹や笉鏄偅鑰呮湰浜虹殑鍦ㄩ櫌绉戝銆�
+        serviceSubtask.setDeptcode(null);
+        serviceSubtask.setDeptname(null);
+        serviceSubtask.setHospitaldistrictcode(null);
+        serviceSubtask.setHospitaldistrictname(null);
+    }
+
+    /**
      * 鏂板鍗曚竴浠诲姟锛堥殢璁匡級
      *
      * @param serviceSubtask 鍗曚竴浠诲姟锛堥殢璁匡級
@@ -892,6 +928,8 @@
      */
     @Override
     public Map<String, Object> insertServiceSubtask(ServiceSubtask serviceSubtask) {
+        // 鍏煎 2026-11 瀛楁閲嶅懡鍚嶅墠鐨勬棫鍏ュ弬锛�/addSubTask 浠嶅彲鑳芥妸绉戝鏀惧湪 deptcode/deptname 閲�
+        alignLeaveDeptFromLegacyDept(serviceSubtask);
         List<ServiceSubtask> serviceSubtasks = null;
         //鍏堟煡璇竴涓嬭鎮h�呮槸鍚﹀凡缁忓垱寤烘牴鎹畇erviceType,sendstate,inhospid,patid,orgid
         //杩欐牱鍒ゆ柇涓昏鏄负浜嗘兂璁╂柊鍗庡尰闄㈢殑澶栭儴瀵煎叆鎮h�呭垱寤轰换鍔★紝涔熻兘鐢ㄨ繖涓帴鍙�
@@ -913,7 +951,7 @@
             serviceOutPath.setSubId(serviceSubtask1.getId());
             List<ServiceOutPath> serviceOutPaths = serviceOutPathMapper.selectServiceOutPathList(serviceOutPath);
             if (CollectionUtils.isNotEmpty(serviceOutPaths))
-                format = String.format("%03X", serviceOutPaths.get(0).getId());
+                format = ShortCode.encode(serviceOutPaths.get(0).getId());
             else format = getOutPath(serviceSubtask1, rsaPublicKeyExample);
             serviceSubtask = serviceSubtask1;
         } else {
@@ -965,7 +1003,7 @@
         serviceOutPath.setSubId(serviceSubtask.getId());
         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
         //杞垚16杩涘埗
-        format = String.format("%03X", serviceOutPath.getId());
+        format = ShortCode.encode(serviceOutPath.getId());
         serviceOutPath.setRadix(format);
         serviceOutPath.setUpdateTime(new Date());
         iServiceOutPathService.updateServiceOutPath(serviceOutPath);
@@ -1599,6 +1637,61 @@
     }
 
     /**
+     * 鍙栭�楀彿涓查噷鐨勭涓�涓�硷紙浠诲姟涓婄瀹�/鐥呭尯鏄閫夛紝鑰� {@code service_subtask} 涓婇兘鏄崟鍊煎垪锛夈��
+     */
+    private String firstValue(String value) {
+        if (StringUtils.isEmpty(value)) {
+            return null;
+        }
+        for (String item : value.split(",")) {
+            if (StringUtils.isNotEmpty(item.trim())) {
+                return item.trim();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 浠诲姟閰嶇疆锛坽@link ServiceTaskVO}锛夆啋 瀛愪换鍔★紙{@link ServiceSubtask}锛夌殑瀛楁鎼繍銆�
+     * <p>
+     * <b>涓轰粈涔堜笉鑳界洿鎺� {@code DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class)}锛�</b>
+     * 瀹冩槸绾悓鍚嶆嫹璐濓紝鑰屼袱杈瑰悓鍚嶇殑 {@code deptcode / deptname} <b>璇箟涓嶅悓</b>锛�
+     * <ul>
+     *   <li>{@code ServiceTaskVO.deptcode / deptname} = 浠诲姟鐨勩�岄�傜敤绉戝銆嶏紝
+     *       鍑洪櫌闅忚锛坰erviceType=2锛�/ 鍑洪櫌瀹f暀锛�4锛�/ 闂ㄨ瘖闅忚锛�3锛夌瓑鍦烘櫙涓嬪氨鏄�<b>绂婚櫌绉戝</b>锛�</li>
+     *   <li>{@code ServiceSubtask.deptcode / deptname} = <b>鍦ㄩ櫌绉戝</b>
+     *       锛�2026-11 鐢卞師 sendlimitpbegin/pend 澶嶇敤鑰屾潵锛岃 {@code ServiceSubtask} 瀛楁娉ㄩ噴锛夈��</li>
+     * </ul>
+     * 浜庢槸绾悓鍚嶆嫹璐濅細鎶娿�岀闄㈢瀹ゃ�嶅啓杩涖�屽湪闄㈢瀹ゃ�嶅垪锛屽悗鏋滄湁涓や釜锛�
+     * <ol>
+     *   <li>鎸夊湪闄㈢淮搴︾瓫锛坽@code deptcodes} 鈫� {@code service_subtask.deptcode}锛変細璇懡涓繖浜涘瓙浠诲姟锛�</li>
+     *   <li>鎸夌闄㈢淮搴︾瓫锛坽@code leaveldeptcodes} 鈫� {@code service_subtask.leaveldeptcode}锛夋椂锛�
+     *       鎮h�呰嚜宸辨病甯︾瀹ょ殑閭d簺锛堝墠绔墜鍔ㄥ嬀閫夋偅鑰呭緢甯歌锛変細鍥犱负 {@code leaveldeptcode} 涓虹┖鑰屾煡涓嶅埌銆�</li>
+     * </ol>
+     * 鍥犳杩欓噷鎸夐」鐩棦瀹氬彛寰勶紙{@code doc/service_subtask_瀛楁鏀瑰悕_鏀瑰姩娓呭崟.md} 搂8锛氳繖鍑犳潯
+     * 銆岄暱鏈熶换鍔� / 浠诲姟缁� / 鎵嬪姩寤轰换鍔°�嶈矾寰�<b>涓嶅~鍦ㄩ櫌缁村害</b>锛夌粺涓�澶勭悊锛�
+     * <b>鍦ㄩ櫌缁村害 4 鍒楁竻绌�</b>锛堝湪闄㈢瀹�/鍦ㄩ櫌鐥呭尯鍙湁 HIS 閾捐矾鑳戒粠 {@code pat_med_inhosp} 鎷垮埌锛夛紝
+     * <b>绉戝 / 鐥呭尯涓�寰嬭惤绂婚櫌缁村害</b>锛坽@code leaveldeptcode/name}銆亄@code leavehospitaldistrictcode/name}锛夈��
+     *
+     * @param serviceTaskVO 寤轰换鍔″叆鍙�
+     * @return 宸叉寜绂婚櫌缁村害褰掍綅鐨勫瓙浠诲姟瀵硅薄锛堝湪闄㈢淮搴︿负绌猴級
+     */
+    private ServiceSubtask toSubtaskFromTaskVO(ServiceTaskVO serviceTaskVO) {
+        ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class);
+        // 鈶� 鍦ㄩ櫌缁村害蹇呴』娓呯┖锛氫换鍔¢厤缃殑绉戝涓嶆槸鎮h�呮湰浜虹殑鍦ㄩ櫌绉戝
+        serviceSubtask.setDeptcode(null);
+        serviceSubtask.setDeptname(null);
+        serviceSubtask.setHospitaldistrictcode(null);
+        serviceSubtask.setHospitaldistrictname(null);
+        // 鈶� 绉戝 / 鐥呭尯 鈫� 绂婚櫌缁村害锛堝閫変覆鍙栫涓�涓紝瀛愪换鍔℃槸鍗曞�煎垪锛�
+        serviceSubtask.setLeaveldeptcode(firstValue(serviceTaskVO.getDeptcode()));
+        serviceSubtask.setLeaveldeptname(firstValue(serviceTaskVO.getDeptname()));
+        serviceSubtask.setLeavehospitaldistrictcode(firstValue(serviceTaskVO.getLeavehospitaldistrictcode()));
+        serviceSubtask.setLeavehospitaldistrictname(firstValue(serviceTaskVO.getLeavehospitaldistrictname()));
+        return serviceSubtask;
+    }
+
+    /**
      * 鍗曚竴浠诲姟
      *
      * @return 缁撴灉
@@ -1815,6 +1908,25 @@
                             serviceTaskdeptService.insertServiceTaskdept(serviceTaskdept);
                         }
                     }
+                    // 鐐逛綅琛岋紙2026-11锛宎ppltype=7锛夛細绉戝 / 鐥呭尯 / 鐐逛綅鍦� service_taskdept 閲屾槸
+                    // **鍚勮嚜鐙珛鐨勮**锛屽彲浠ュ叡瀛樹篃鍙互涓嶅叡瀛� 鈥斺�� 鎵�浠ョ偣浣嶈鏄�"棰濆杩藉姞"锛�
+                    // 涓嶆浛鎹笂闈㈢殑绉戝/鐥呭尯琛屻�傜偣浣嶈鐨� dept_code/dept_name 鐣欑┖锛岀紪鐮佸彧钀� point_location銆�
+                    if ("7".equals(serviceTaskVO.getAppltype())) {
+                        String pointLocation = firstNonBlank(serviceTaskVO.getPointLocation(),
+                                serviceTask.getPointLocation());
+                        if (StringUtils.isNotEmpty(pointLocation)) {
+                            ServiceTaskdept pointDept = new ServiceTaskdept();
+                            pointDept.setTaskId(serviceTask.getTaskid());
+                            pointDept.setTaskName(serviceTask.getTaskName());
+                            pointDept.setOrgid(serviceTask.getOrgid());
+                            pointDept.setLongtask(serviceTask.getLongTask() == null ? null
+                                    : Long.valueOf(serviceTask.getLongTask()));
+                            pointDept.setServiceType(serviceTaskVO.getServiceType());
+                            pointDept.setDeptType("3");
+                            pointDept.setPointLocation(pointLocation);
+                            serviceTaskdeptService.insertServiceTaskdept(pointDept);
+                        }
+                    }
                 }
             }
 //闀挎湡浠诲姟锛屼篃鍏佽鍔犱汉浜�
@@ -1825,7 +1937,8 @@
 //            }
 
             //灏嗕换鍔′俊鎭斁鍒版湇鍔¤〃涓�
-            ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class);
+            // 绉戝/鐥呭尯鎸夈�岀闄㈢淮搴︺�嶅綊浣嶏紙鍑洪櫌闅忚鐨勭瀹ょ梾鍖哄氨鏄闄㈢瀹�/鐥呭尯锛夛紝瑙� toSubtaskFromTaskVO
+            ServiceSubtask serviceSubtask = toSubtaskFromTaskVO(serviceTaskVO);
             serviceSubtask.setTaskid(serviceTask.getTaskid().longValue());
             serviceSubtask.setTemplatename(ObjectUtils.isNotEmpty(tempid) ? tempName : serviceTask.getTemplatename());
             serviceSubtask.setTemplateid(ObjectUtils.isNotEmpty(tempid) ? tempid : serviceTask.getTemplateid());
@@ -1846,15 +1959,18 @@
                     serviceSubtask.setInhospid(patTaskRelevance.getHospid());
                     //鏂板缓瀹屾垚灏辨槸寰呭彂閫佺姸鎬�
                     serviceSubtask.setSendstate(2L);
-                    String subtaskDeptCode = patTaskRelevance.getDeptcode();
-                    if (StringUtils.isEmpty(subtaskDeptCode) && StringUtils.isNotEmpty(serviceTaskVO.getDeptcode())) {
-                        // service_subtask.leaveldeptcode 涓哄崟鍊煎瓧娈碉紝涓嶈兘鍐欏叆浠诲姟鐨勫绉戝鎷兼帴涓诧紝鍙栫涓�涓瀹ゅ厹搴�
-                        subtaskDeptCode = serviceTaskVO.getDeptcode().split(",")[0].trim();
-                    }
-                    serviceSubtask.setLeaveldeptcode(subtaskDeptCode);
-                    serviceSubtask.setLeaveldeptname(StringUtils.isNotEmpty(patTaskRelevance.getDeptName()) ? patTaskRelevance.getDeptName() : serviceTaskVO.getDeptname());
-                    serviceSubtask.setLeavehospitaldistrictcode(patTaskRelevance.getLeavehospitaldistrictcode());
-                    serviceSubtask.setLeavehospitaldistrictname(patTaskRelevance.getLeavehospitaldistrictname());
+                    // 绂婚櫌缁村害锛堝嚭闄㈤殢璁� = 鍑洪櫌绉戝 / 鍑洪櫌鐥呭尯锛夛細
+                    // 鎮h�呰嚜甯︾殑鍑洪櫌绉戝/鐥呭尯浼樺厛锛屾偅鑰呬晶娌″甫锛堝墠绔墜鍔ㄥ嬀閫夊緢甯歌锛夋椂鍥為��鍒颁换鍔¢厤缃紝
+                    // 涓嶈兘鏃犳潯浠惰鐩� 鈥斺�� 鍚﹀垯浼氭妸 toSubtaskFromTaskVO 鎸変换鍔¢厤缃厹濂界殑绂婚櫌缁村害鎶规垚 null锛�
+                    // 缁撴灉銆屼换鍔¢厤浜嗙瀹ょ梾鍖恒�佺敓鎴愬嚭鏉ョ殑瀛愪换鍔$闄㈢瀹�/鐥呭尯鍗存槸绌恒�嶃��
+                    serviceSubtask.setLeaveldeptcode(firstNonBlank(patTaskRelevance.getDeptcode(),
+                            firstValue(serviceTaskVO.getDeptcode())));
+                    serviceSubtask.setLeaveldeptname(firstNonBlank(patTaskRelevance.getDeptName(),
+                            firstValue(serviceTaskVO.getDeptname())));
+                    serviceSubtask.setLeavehospitaldistrictcode(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictcode(),
+                            firstValue(serviceTaskVO.getLeavehospitaldistrictcode())));
+                    serviceSubtask.setLeavehospitaldistrictname(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictname(),
+                            firstValue(serviceTaskVO.getLeavehospitaldistrictname())));
                     serviceSubtask.setType(serviceTaskVO.getType());
                     serviceSubtask.setHospType(patTaskRelevance.getHospType());
                     serviceSubtask.setOpenid(patTaskRelevance.getOpenid());
@@ -2190,6 +2306,27 @@
                     scheduleVO.setOplevelCodes(serviceTaskVO.getOplevelcode());
                     scheduleVO.setCreateBy(serviceTask.getUpdateBy());
                     serviceTaskScheduleService.saveScheduleWithDetail(scheduleVO);
+                } else if (serviceTaskVO.getAppltype().equals("7")) {
+                    // 鎸夌偣浣嶏紙鍚屽痉闇�姹傦級锛氬厛杞垹璇ヤ换鍔℃棫鐨� dept_type='3' 琛岋紝鍐嶆寜鍏ュ弬閲嶅缓
+                    //   锛堜笌绉戝/鐥呭尯銆屽厛鍒犲悗鎻掋�嶅悓鍙e緞锛涚偣浣嶈 dept_code/dept_name 鐣欑┖锛�
+                    ServiceTaskdept oldPoint = new ServiceTaskdept();
+                    oldPoint.setTaskId(serviceTask.getTaskid());
+                    oldPoint.setDeptType("3");
+                    serviceTaskdeptService.deleteServiceTaskdeptByTaskId(oldPoint);
+                    String pointLocation = StringUtils.isNotEmpty(serviceTaskVO.getPointLocation())
+                            ? serviceTaskVO.getPointLocation() : serviceTask.getPointLocation();
+                    if (StringUtils.isNotEmpty(pointLocation)) {
+                        ServiceTaskdept pointDept = new ServiceTaskdept();
+                        pointDept.setTaskId(serviceTask.getTaskid());
+                        pointDept.setTaskName(serviceTask.getTaskName());
+                        pointDept.setOrgid(serviceTaskVO.getOrgid());
+                        pointDept.setLongtask(serviceTask.getLongTask() == null ? null
+                                : Long.valueOf(serviceTask.getLongTask()));
+                        pointDept.setServiceType(serviceTaskVO.getServiceType());
+                        pointDept.setDeptType("3");
+                        pointDept.setPointLocation(pointLocation);
+                        serviceTaskdeptService.insertServiceTaskdept(pointDept);
+                    }
                 }
             }
             if (ObjectUtils.isNotEmpty(serviceTaskVO.getIvrTaskTemplateVO())) {
@@ -2212,7 +2349,8 @@
             }
             if (CollectionUtils.isNotEmpty(serviceTaskVO.getPatTaskRelevances())) {
                 for (PatTaskRelevance patTaskRelevance : serviceTaskVO.getPatTaskRelevances()) {
-                    ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class);
+                    // 绉戝/鐥呭尯鎸夈�岀闄㈢淮搴︺�嶅綊浣嶏紙鍑洪櫌闅忚鐨勭瀹ょ梾鍖哄氨鏄闄㈢瀹�/鐥呭尯锛夛紝瑙� toSubtaskFromTaskVO
+                    ServiceSubtask serviceSubtask = toSubtaskFromTaskVO(serviceTaskVO);
                     serviceSubtask.setLibtemplateid(ObjectUtils.isEmpty(serviceTaskVO.getLibtemplateid()) ? null : Long.valueOf(serviceTaskVO.getLibtemplateid()));
                     serviceSubtask.setLibtemplatename(serviceTaskVO.getLibtemplatename());
                     serviceSubtask.setTemplateid(serviceTask.getTemplateid());
@@ -2224,10 +2362,16 @@
                     serviceSubtask.setAddr(patTaskRelevance.getAddr());
                     serviceSubtask.setPatid(patTaskRelevance.getPatid());
                     serviceSubtask.setOpenid(patTaskRelevance.getOpenid());
-                    serviceSubtask.setLeaveldeptcode(patTaskRelevance.getDeptcode());
-                    serviceSubtask.setLeavehospitaldistrictname(patTaskRelevance.getLeavehospitaldistrictname());
-                    serviceSubtask.setLeavehospitaldistrictcode(patTaskRelevance.getLeavehospitaldistrictcode());
-                    serviceSubtask.setLeaveldeptname(patTaskRelevance.getDeptName());
+                    // 绂婚櫌缁村害锛氭偅鑰呰嚜甯︾殑鍑洪櫌绉戝/鐥呭尯浼樺厛锛屾病甯︽椂鍥為��鍒颁换鍔¢厤缃紙鍚﹀垯浼氭妸
+                    // toSubtaskFromTaskVO 鎸変换鍔¢厤缃厹濂界殑鍊兼姽鎴� null锛屽嚭闄㈤殢璁垮氨鎴愩�岀闄㈢瀹�/鐥呭尯涓虹┖銆嶏級
+                    serviceSubtask.setLeaveldeptcode(firstNonBlank(patTaskRelevance.getDeptcode(),
+                            firstValue(serviceTaskVO.getDeptcode())));
+                    serviceSubtask.setLeaveldeptname(firstNonBlank(patTaskRelevance.getDeptName(),
+                            firstValue(serviceTaskVO.getDeptname())));
+                    serviceSubtask.setLeavehospitaldistrictcode(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictcode(),
+                            firstValue(serviceTaskVO.getLeavehospitaldistrictcode())));
+                    serviceSubtask.setLeavehospitaldistrictname(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictname(),
+                            firstValue(serviceTaskVO.getLeavehospitaldistrictname())));
                     serviceSubtask.setType(serviceTaskVO.getType());
                     serviceSubtask.setCreateTime(DateUtils.getNowDate());
                     serviceSubtask.setDrname(patTaskRelevance.getDrname());
@@ -2445,7 +2589,8 @@
         log.info("getSfStatistics鐨勫叆鍙備负锛歿}", serviceSubtaskCountReq);
         String drcode = "drcode";
         //缂欎簯浜烘皯 鏍规嵁缁忕鍖荤敓鍒嗙粍
-        if (serviceSubtaskCountReq.getOrgid().equals("47246116333112211A1001")) {
+        boolean jinyunHospital = JINYUN_PEOPLES_HOSPITAL_ORGID.equals(serviceSubtaskCountReq.getOrgid());
+        if (jinyunHospital) {
             drcode = "management_doctor_code";
         }
         String groupKey = drcode;
@@ -2459,7 +2604,10 @@
             if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
                 groupKey = drcode;
             } else {
-                groupKey = "deptcode";
+                // 2026-11 瀛楁閲嶅懡鍚嶅悗锛歞eptcode 鏄湪闄㈢瀹わ紙鍘嗗彶鏁版嵁涓虹┖锛夛紝
+                // 鍑洪櫌绉戝宸叉敼鍚嶄负 leaveldeptcode锛屽垎缁勫繀椤荤敤鍚庤�咃紝
+                // 鍚﹀垯 getSfStatisticsGroupKey 浼氳繑鍥� NULL锛屾嫾鎴� IN (NULL) 瀵艰嚧鏁磋〃鏌ョ┖銆�
+                groupKey = "leaveldeptcode";
             }
         } else if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 3) {
             // 鐥呯缁熻锛氭寜浠诲姟ID鍒嗙粍锛屾瘡涓换鍔″嵆涓�涓梾绉嶉殢璁夸换鍔�
@@ -2470,6 +2618,17 @@
         Map<String, List<ServiceSubtask>> collect = new HashMap<>();
         serviceSubtaskCountReq.setGroupKey(groupKey);
         List<String> groupKeyList = serviceSubtaskMapper.getSfStatisticsGroupKey(serviceSubtaskCountReq);
+        /*
+         * 鍒嗙粍閿彲鑳戒负 NULL锛堝巻鍙叉暟鎹�佹垨閲嶅懡鍚嶅悗灏氭湭鍥炲~鐨勫湪闄㈢淮搴﹀垪锛夛紝
+         * 鐩存帴鎷艰繘 SQL 浼氬彉鎴� `AND IFNULL(鍒�,'Unknown') IN (NULL)`锛屾亽涓嶆垚绔嬶紝鏁村紶缁熻琛ㄤ负绌恒��
+         * 杩欓噷缁熶竴鎴� 'Unknown'锛屼笌鑱氬悎 SQL 鐨� IFNULL(鍒�,'Unknown') 鍙e緞瀵归綈銆�
+         */
+        if (groupKeyList != null) {
+            groupKeyList = groupKeyList.stream()
+                    .map(key -> key == null ? "Unknown" : key)
+                    .distinct()
+                    .collect(Collectors.toList());
+        }
         serviceSubtaskCountReq.setGroupKeyList(groupKeyList);
         List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq);
         switch (groupKey) {
@@ -2484,6 +2643,7 @@
                 collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getManagementDoctorCode()).orElse("Unknown")));
                 break;
             case "deptcode":
+            case "leaveldeptcode":
                 collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeaveldeptcode()).orElse("Unknown")));
                 break;
             case "leavehospitaldistrictcode":
@@ -2496,18 +2656,30 @@
                 collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown")));
                 break;
         }
-        //鑾峰彇鍙婃椂鐜囩粺璁″悎闆�
-        Map<String, Map<String, Object>> jsRates = getSsRateForSfStatistics(serviceSubtaskCountReq, collect);
+        /*
+         * 缂欎簯鍘夸汉姘戝尰闄㈢殑鈥滃強鏃剁巼鈥濆彛寰勬槸鈥滃強鏃堕殢璁夸汉娆� / 搴旈殢璁夸汉娆♀�濓紝
+         * 蹇呴』鍜屽悓涓�鎵圭粺璁¤閲岀殑 timelyFollowUp / followUpNeeded 淇濇寔涓�鑷淬��
+         * 涓嶈兘鍐嶈蛋 selectTimelyRateBatch锛氳 SQL 鍦ㄦ湭浼犲簲闅忚鏃堕棿鑼冨洿鏃惰繕浼氳拷鍔�
+         * visit_time < NOW()锛屽彧鎸夊嚭闄㈡椂闂寸粺璁℃椂浼氭妸鏈埌鏈熶换鍔℃帓闄ゅ湪鍒嗘瘝澶栵紝
+         * 瀵艰嚧椤甸潰涓婄殑鍙婃椂鐜囧拰鈥滃強鏃堕殢璁夸汉娆�/搴旈殢璁夸汉娆♀�濆涓嶄笂銆�
+         */
+        Map<String, Map<String, Object>> jsRates = jinyunHospital
+                ? Collections.emptyMap()
+                : getSsRateForSfStatistics(serviceSubtaskCountReq, collect);
         for (String collectKey : collect.keySet()) {
             List<ServiceSubtask> serviceSubtaskList = collect.get(collectKey);
             if (CollectionUtils.isEmpty(serviceSubtaskList)) {
                 continue;
             }
             ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList, serviceSubtaskCountReq.getFollowUpCountStyle(), serviceSubtaskCountReq.getVisitCount());
+            // hzszlyy锛氬墠绔笉鏀瑰瓧娈碉紝鐩存帴鎶婄疮璁″�煎洖濉埌鍘� manual/voice/sms/weChat 鍙� Again 瀛楁
+            applySiteCumulativeOverride(statistic);
             if ("taskid".equals(groupKey)) {
                 applyTaskGroupInfo(statistic, serviceSubtaskList);
             }
-            if (ObjectUtils.isNotEmpty(jsRates)) {
+            if (jinyunHospital) {
+                statistic.setRate(calculateJinyunTimelyRate(statistic));
+            } else if (ObjectUtils.isNotEmpty(jsRates)) {
                 Map<String, Object> jsRateMap = jsRates.get(collectKey);
                 BigDecimal jsRate = new BigDecimal("0");
                 if (ObjectUtils.isNotEmpty(jsRateMap) && ObjectUtils.isNotEmpty(jsRateMap.get("rate"))) {
@@ -2612,6 +2784,23 @@
      */
     private long nvlLong(Long value) {
         return value == null ? 0L : value;
+    }
+
+    /**
+     * 缂欎簯鍘夸汉姘戝尰闄㈠強鏃剁巼锛氬強鏃堕殢璁夸汉娆� / 搴旈殢璁夸汉娆°��
+     * <p>
+     * 涓よ�呴兘鍙栬嚜鍚屼竴鏉$粺璁$粨鏋滐紝淇濊瘉椤甸潰涓婄殑鍙婃椂鐜囦笌杩欎袱鍒楀彲浠ヤ簰鐩搁獙绠椼��
+     * 搴旈殢璁夸汉娆′负 0 鏃惰繑鍥� 0锛屽墠绔寜 0.00% 灞曠ず銆�
+     */
+    private double calculateJinyunTimelyRate(ServiceSubtaskStatistic statistic) {
+        long followUpNeeded = nvlLong(statistic.getFollowUpNeeded());
+        if (followUpNeeded <= 0) {
+            return 0D;
+        }
+        long timelyFollowUp = nvlLong(statistic.getTimelyFollowUp());
+        return BigDecimal.valueOf(timelyFollowUp)
+                .divide(BigDecimal.valueOf(followUpNeeded), 4, RoundingMode.HALF_UP)
+                .doubleValue();
     }
 
     /**
@@ -2802,6 +2991,7 @@
                 //棣栨鍑洪櫌闅忚
                 if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
                     applyFirstFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask);
+                    applyFirstCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                     //棣栨搴旈殢璁�
                     if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L)) {
                         serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
@@ -2924,6 +3114,7 @@
                 }//浜屾鍑洪櫌闅忚
                 else if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) {
                     applyAgainFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask);
+                    applyAgainCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                     //鍐嶆搴旈殢璁�
                     if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                         serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
@@ -3100,7 +3291,7 @@
     }
 
     /**
-     * 鍐嶆闅忚闄勫姞缁熻锛氬緟闅忚銆佸凡鍙戦�併�佷汉宸ョ數璇濊秴鏃跺強鍥為櫌澶嶈瘖澶嶆煡锛坰uggest=6锛夈��
+     * 鍐嶆闅忚闄勫姞缁熻锛氬緟闅忚銆佸凡鍙戦�併�佷汉宸ョ數璇濊秴鏃跺強鍥為櫌澶嶈瘖澶嶆煡锛坰uggest=7锛夈��
      */
     private void applyAgainFollowUpExtraStatistics(ServiceSubtaskStatistic statistic, ServiceSubtask serviceSubtask) {
         if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() <= 1) {
@@ -3110,9 +3301,9 @@
             return;
         }
         Long sendstate = serviceSubtask.getSendstate();
-        // 鍥為櫌澶嶈瘖澶嶆煡锛氬啀娆¢殢璁夸腑鎸夊鐞嗘剰瑙� suggest=6 缁熻
-        if (StringUtils.equals("6", StringUtils.trim(serviceSubtask.getSuggest()))) {
-            statistic.setSuggest6CountAgain(statistic.getSuggest6CountAgain() + 1L);
+        // 鍥為櫌澶嶈瘖澶嶆煡锛氬啀娆¢殢璁夸腑鎸夊鐞嗘剰瑙� suggest=7 缁熻
+        if (StringUtils.equals("7", StringUtils.trim(serviceSubtask.getSuggest()))) {
+            statistic.setSuggest7CountAgain(statistic.getSuggest7CountAgain() + 1L);
         }
         if (sendstate.equals(3L)) {
             statistic.setSentAgain(statistic.getSentAgain() + 1L);
@@ -3133,6 +3324,220 @@
 
     private boolean isManuallyNotCalled(ServiceSubtask serviceSubtask) {
         return serviceSubtask.getIsManuallyCalled() != null && serviceSubtask.getIsManuallyCalled().equals(0L);
+    }
+
+    /** 鍙戦�佹柟寮忕紪鐮侊細浜哄伐 */
+    private static final String PREACHFORM_MANUAL = "1";
+    /** 鍙戦�佹柟寮忕紪鐮侊細璇煶 */
+    private static final String PREACHFORM_VOICE = "3";
+    /** 鍙戦�佹柟寮忕紪鐮侊細鐭俊 */
+    private static final String PREACHFORM_SMS = "4";
+    /** 鍙戦�佹柟寮忕紪鐮侊細寰俊 */
+    private static final String PREACHFORM_WECHAT = "5";
+
+    /** 绱浣嶅浘锛氳闊� */
+    private static final int CUMULATIVE_MASK_VOICE = 1;
+    /** 绱浣嶅浘锛氬井淇� */
+    private static final int CUMULATIVE_MASK_WECHAT = 1 << 1;
+    /** 绱浣嶅浘锛氱煭淇� */
+    private static final int CUMULATIVE_MASK_SMS = 1 << 2;
+    /** 绱浣嶅浘锛氫汉宸� */
+    private static final int CUMULATIVE_MASK_MANUAL = 1 << 3;
+    /** 闇�瑕佹妸绱鍊煎洖濉埌鍘熷瓧娈电殑绔欑偣 */
+    private static final String SITE_HZSZLYY = "hzszlyy";
+
+    /**
+     * 棣栨闅忚銆岀疮璁″彂閫佹柟寮忋�嶇粺璁°��
+     * <p>
+     * 鍘熷彛寰勫彧鐪� current_preachform 绛変簬鏌愪釜鏂瑰紡锛氫緥濡� current_preachform=5锛堝井淇★級鏃讹紝
+     * 鍓嶉潰宸茬粡鎵ц杩囩殑璇煶涓嶅啀璁″叆璇煶鏁般�傛湰鏂规硶鎸� service_subtask.preachform 淇濆瓨鐨�
+     * 椤哄簭鎺ㄧ畻锛歝urrent_preachform 鍦ㄩ『搴忎腑鐨勪綅缃箣鍓嶇殑鍙戦�佹柟寮忥紝閮界畻鈥滅疮璁″凡杩涘叆杩団�濄��
+     * <p>
+     * 渚嬶細preachform = 3,5,4,1锛堣闊斥啋寰俊鈫掔煭淇♀啋浜哄伐锛夛細
+     * <ul>
+     *   <li>current=3锛氱疮璁¤闊�=1锛涘井淇�/鐭俊/浜哄伐=0</li>
+     *   <li>current=5锛氱疮璁¤闊�=1銆佸井淇�=1锛涚煭淇�/浜哄伐=0</li>
+     *   <li>current=4锛氱疮璁¤闊�=1銆佸井淇�=1銆佺煭淇�=1锛涗汉宸�=0</li>
+     *   <li>current=1锛氬洓椤归兘=1</li>
+     * </ul>
+     * 绾﹀畾锛歝urrent_preachform 涓虹┖鏃跺彇 preachform 绗竴涓柟寮忥紱current_preachform=-1 鏃舵寜
+     * 鏈�鍚庝竴涓綅缃鐞嗭紱current_preachform 涓嶅湪椤哄簭涓椂鍙仛绮剧‘鍖归厤鍏滃簳锛岄伩鍏嶅巻鍙茶剰鏁版嵁璇畻銆�
+     * <p>
+     * sendstate 杩囨护涓庡師鏈� manual/voice/sms/weChat 淇濇寔涓�鑷达細
+     * followUpCountStyle=1 鎺掗櫎 sendstate=4锛�=3 鍙粺璁� sendstate=6锛涘叾瀹冪粺璁℃墍鏈夐潪绌� sendstate銆�
+     */
+    private void applyFirstCumulativePreachformStatistics(ServiceSubtaskStatistic statistic,
+                                                          ServiceSubtask serviceSubtask,
+                                                          String followUpCountStyle) {
+        if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() != 1) {
+            return;
+        }
+        if (!isCumulativePreachformCountable(serviceSubtask, followUpCountStyle)) {
+            return;
+        }
+        int mask = resolveCumulativePreachformMask(serviceSubtask);
+        if ((mask & CUMULATIVE_MASK_VOICE) != 0) {
+            statistic.setVoiceCumulative(statistic.getVoiceCumulative() + 1L);
+        }
+        if ((mask & CUMULATIVE_MASK_WECHAT) != 0) {
+            statistic.setWeChatCumulative(statistic.getWeChatCumulative() + 1L);
+        }
+        if ((mask & CUMULATIVE_MASK_SMS) != 0) {
+            statistic.setSmsCumulative(statistic.getSmsCumulative() + 1L);
+        }
+        if ((mask & CUMULATIVE_MASK_MANUAL) != 0) {
+            statistic.setManualCumulative(statistic.getManualCumulative() + 1L);
+        }
+    }
+
+    /**
+     * 鍐嶆闅忚銆岀疮璁″彂閫佹柟寮忋�嶇粺璁★紝鍙e緞涓� {@link #applyFirstCumulativePreachformStatistics} 涓�鑷淬��
+     */
+    private void applyAgainCumulativePreachformStatistics(ServiceSubtaskStatistic statistic,
+                                                          ServiceSubtask serviceSubtask,
+                                                          String followUpCountStyle) {
+        if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() <= 1) {
+            return;
+        }
+        if (!isCumulativePreachformCountable(serviceSubtask, followUpCountStyle)) {
+            return;
+        }
+        int mask = resolveCumulativePreachformMask(serviceSubtask);
+        if ((mask & CUMULATIVE_MASK_VOICE) != 0) {
+            statistic.setVoiceAgainCumulative(statistic.getVoiceAgainCumulative() + 1L);
+        }
+        if ((mask & CUMULATIVE_MASK_WECHAT) != 0) {
+            statistic.setWeChatAgainCumulative(statistic.getWeChatAgainCumulative() + 1L);
+        }
+        if ((mask & CUMULATIVE_MASK_SMS) != 0) {
+            statistic.setSmsAgainCumulative(statistic.getSmsAgainCumulative() + 1L);
+        }
+        if ((mask & CUMULATIVE_MASK_MANUAL) != 0) {
+            statistic.setManualAgainCumulative(statistic.getManualAgainCumulative() + 1L);
+        }
+    }
+
+    /**
+     * 璁$畻鏌愭潯瀛愪换鍔♀�滃凡杩涘叆杩団�濈殑鍙戦�佹柟寮忎綅鍥俱��
+     * <p>
+     * current_preachform 涓虹┖鍙栫涓�涓紱= -1 瑙嗕负鍏ㄩ儴閬嶅巻瀹岋紱涓嶅湪椤哄簭閲屾椂閫�鍖栦负绮剧‘鍖归厤銆�
+     */
+    private int resolveCumulativePreachformMask(ServiceSubtask serviceSubtask) {
+        List<String> order = splitPreachformOrder(serviceSubtask.getPreachform());
+        String current = StringUtils.isNotBlank(serviceSubtask.getCurrentPreachform())
+                ? serviceSubtask.getCurrentPreachform().trim()
+                : (order.isEmpty() ? null : order.get(0));
+        if (order.isEmpty()) {
+            return exactCumulativeMask(current);
+        }
+        int currentPosition;
+        if ("-1".equals(current)) {
+            currentPosition = order.size();
+        } else {
+            int currentIndex = order.indexOf(current);
+            if (currentIndex < 0) {
+                return exactCumulativeMask(current);
+            }
+            currentPosition = currentIndex + 1;
+        }
+        int mask = 0;
+        if (reachedPreachform(order, PREACHFORM_VOICE, currentPosition)) {
+            mask |= CUMULATIVE_MASK_VOICE;
+        }
+        if (reachedPreachform(order, PREACHFORM_WECHAT, currentPosition)) {
+            mask |= CUMULATIVE_MASK_WECHAT;
+        }
+        if (reachedPreachform(order, PREACHFORM_SMS, currentPosition)) {
+            mask |= CUMULATIVE_MASK_SMS;
+        }
+        if (reachedPreachform(order, PREACHFORM_MANUAL, currentPosition)) {
+            mask |= CUMULATIVE_MASK_MANUAL;
+        }
+        return mask;
+    }
+
+    private int exactCumulativeMask(String current) {
+        if (PREACHFORM_MANUAL.equals(current)) {
+            return CUMULATIVE_MASK_MANUAL;
+        }
+        if (PREACHFORM_VOICE.equals(current)) {
+            return CUMULATIVE_MASK_VOICE;
+        }
+        if (PREACHFORM_SMS.equals(current)) {
+            return CUMULATIVE_MASK_SMS;
+        }
+        if (PREACHFORM_WECHAT.equals(current)) {
+            return CUMULATIVE_MASK_WECHAT;
+        }
+        return 0;
+    }
+
+    private boolean isCumulativePreachformCountable(ServiceSubtask serviceSubtask, String followUpCountStyle) {
+        if (serviceSubtask.getSendstate() == null) {
+            return false;
+        }
+        if ("1".equals(followUpCountStyle)) {
+            return !Long.valueOf(4L).equals(serviceSubtask.getSendstate());
+        }
+        if ("3".equals(followUpCountStyle)) {
+            return Long.valueOf(6L).equals(serviceSubtask.getSendstate());
+        }
+        return true;
+    }
+
+    /**
+     * 鎷嗗垎 preachform 鎵ц椤哄簭銆傚吋瀹硅嫳鏂囬�楀彿銆佷腑鏂囬�楀彿鍜岀┖鏍硷紝鍘婚噸骞朵繚鎸佸師椤哄簭銆�
+     */
+    private List<String> splitPreachformOrder(String preachform) {
+        if (StringUtils.isEmpty(preachform)) {
+            return Collections.emptyList();
+        }
+        return Arrays.stream(preachform.split("[,锛宂"))
+                .map(String::trim)
+                .filter(StringUtils::isNotEmpty)
+                .distinct()
+                .collect(Collectors.toList());
+    }
+
+    private boolean reachedPreachform(List<String> order, String preachform, int currentPosition) {
+        int position = order.indexOf(preachform);
+        return position >= 0 && currentPosition >= position + 1;
+    }
+
+    /**
+     * hzszlyy 绔欑偣淇濇寔鍓嶇瀛楁涓嶅彉锛氭妸绱鍊煎洖濉埌鍘� manual/voice/sms/weChat 鍙� Again 瀛楁銆�
+     * <p>
+     * 鍏跺畠绔欑偣涓嶈鐩栵紝缁х画浣跨敤鍘熸潵鐨勨�滃綋鍓嶆柟寮忕簿纭尮閰嶁�濆彛寰勩��
+     */
+    private void applySiteCumulativeOverride(ServiceSubtaskStatistic statistic) {
+        if (!SITE_HZSZLYY.equals(active)) {
+            return;
+        }
+        statistic.setManual(nvlLong(statistic.getManualCumulative()));
+        statistic.setVoice(nvlLong(statistic.getVoiceCumulative()));
+        statistic.setSms(nvlLong(statistic.getSmsCumulative()));
+        statistic.setWeChat(nvlLong(statistic.getWeChatCumulative()));
+        statistic.setManualAgain(nvlLong(statistic.getManualAgainCumulative()));
+        statistic.setVoiceAgain(nvlLong(statistic.getVoiceAgainCumulative()));
+        statistic.setSmsAgain(nvlLong(statistic.getSmsAgainCumulative()));
+        statistic.setWeChatAgain(nvlLong(statistic.getWeChatAgainCumulative()));
+    }
+
+    /**
+     * 瓒呴摼鎺ヤ笅閽荤殑鍙戦�佹柟寮忔潯浠躲��
+     * <p>
+     * hzszlyy 绔欑偣鐨勫墠绔笉鏀瑰瓧娈碉紝浠嶇偣鍘熸潵鐨� manualInfo/voiceInfo/...锛�
+     * 鍚庣鏀圭敤绱鍙e緞锛涘叾瀹冪珯鐐逛繚鎸� current_preachform 绮剧‘鍖归厤銆�
+     */
+    private void applyPreachformInfoCondition(ServiceSubtaskCountReq serviceSubtaskCountReq,
+                                              int visitCount,
+                                              String preachform) {
+        serviceSubtaskCountReq.setVisitCount(visitCount);
+        if (SITE_HZSZLYY.equals(active)) {
+            serviceSubtaskCountReq.setCumulativePreachform(preachform);
+        } else {
+            serviceSubtaskCountReq.setCurrentPreachform(preachform);
+        }
     }
 
     /**
@@ -3175,6 +3580,7 @@
 
             //棣栨鍑洪櫌闅忚
             if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
+                applyFirstCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                 //棣栨搴旈殢璁�
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                     serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
@@ -3349,6 +3755,7 @@
 
             //鍐嶆鍑洪櫌闅忚
             if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) {
+                applyAgainCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                 //鍐嶆搴旈殢璁�
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                     serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
@@ -3727,6 +4134,10 @@
      * voiceSuccessInfo - visitCount = 1 && currentPreachForm = "3" && sendstate = 6
      * smsSuccessInfo - visitCount = 1 && currentPreachForm = "4" && sendstate = 6
      * wechatSuccessInfo - visitCount = 1 && currentPreachForm = "5" && sendstate = 6
+     * voiceCumulativeInfo - visitCount = 1 && currentPreachForm 浣嶄簬 preachform 椤哄簭涓殑璇煶鍙婁箣鍚�
+     * weChatCumulativeInfo - visitCount = 1 && currentPreachForm 浣嶄簬 preachform 椤哄簭涓殑寰俊鍙婁箣鍚�
+     * smsCumulativeInfo - visitCount = 1 && currentPreachForm 浣嶄簬 preachform 椤哄簭涓殑鐭俊鍙婁箣鍚�
+     * manualCumulativeInfo - visitCount = 1 && currentPreachForm 浣嶄簬 preachform 椤哄簭涓殑浜哄伐鍙婁箣鍚�
      * abnormalInfo - visitCount = 1 && excep = "1"
      * needFollowUpAgainInfo - visitCount > 1 && sendstate != 4
      * pendingFollowUpAgainInfo -  visitCount > 1 && sendstate = 2
@@ -3758,7 +4169,7 @@
      * pendingFollowUpSentAgainInfo - visitCount > 1 && sendstate in (3,7)
      * sentInfo - visitCount = 1 && sendstate = 3
      * sentAgainInfo - visitCount > 1 && sendstate = 3
-     * suggest6CountAgainInfo - visitCount > 1 && suggest = 6
+     * suggest7CountAgainInfo - visitCount > 1 && suggest = 7
      * filterCountList - taskSituation = 6 && sendstate = 4
      *
      */
@@ -3796,6 +4207,7 @@
         serviceSubtaskCountReq.setVisitCount(null);
         serviceSubtaskCountReq.setSendstates(null);
         serviceSubtaskCountReq.setCurrentPreachform(null);
+        serviceSubtaskCountReq.setCumulativePreachform(null);
         serviceSubtaskCountReq.setExcep(null);
         serviceSubtaskCountReq.setTaskSituation(null);
         serviceSubtaskCountReq.setFinishState(null);
@@ -3848,20 +4260,33 @@
                 serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(5L, 7L)));
                 break;
             case "manualInfo":
-                serviceSubtaskCountReq.setVisitCount(1);
-                serviceSubtaskCountReq.setCurrentPreachform("1");
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_MANUAL);
                 break;
             case "voiceInfo":
-                serviceSubtaskCountReq.setVisitCount(1);
-                serviceSubtaskCountReq.setCurrentPreachform("3");
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_VOICE);
                 break;
             case "smsInfo":
-                serviceSubtaskCountReq.setVisitCount(1);
-                serviceSubtaskCountReq.setCurrentPreachform("4");
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_SMS);
                 break;
             case "weChatInfo":
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_WECHAT);
+                break;
+            // 绱鍙e緞锛氭寜 preachform 鐨勬墽琛岄『搴忥紝current_preachform 浣嶄簬璇ユ柟寮忓強涔嬪悗鍗宠鍏�
+            case "voiceCumulativeInfo":
                 serviceSubtaskCountReq.setVisitCount(1);
-                serviceSubtaskCountReq.setCurrentPreachform("5");
+                serviceSubtaskCountReq.setCumulativePreachform("3");
+                break;
+            case "weChatCumulativeInfo":
+                serviceSubtaskCountReq.setVisitCount(1);
+                serviceSubtaskCountReq.setCumulativePreachform("5");
+                break;
+            case "smsCumulativeInfo":
+                serviceSubtaskCountReq.setVisitCount(1);
+                serviceSubtaskCountReq.setCumulativePreachform("4");
+                break;
+            case "manualCumulativeInfo":
+                serviceSubtaskCountReq.setVisitCount(1);
+                serviceSubtaskCountReq.setCumulativePreachform("1");
                 break;
             case "manualSuccessInfo":
                 serviceSubtaskCountReq.setVisitCount(1);
@@ -3904,20 +4329,16 @@
                 serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(5L, 7L)));
                 break;
             case "manualAgainInfo":
-                serviceSubtaskCountReq.setVisitCount(2);
-                serviceSubtaskCountReq.setCurrentPreachform("1");
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_MANUAL);
                 break;
             case "voiceAgainInfo":
-                serviceSubtaskCountReq.setVisitCount(2);
-                serviceSubtaskCountReq.setCurrentPreachform("3");
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_VOICE);
                 break;
             case "smsAgainInfo":
-                serviceSubtaskCountReq.setVisitCount(2);
-                serviceSubtaskCountReq.setCurrentPreachform("4");
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_SMS);
                 break;
             case "weChatAgainInfo":
-                serviceSubtaskCountReq.setVisitCount(2);
-                serviceSubtaskCountReq.setCurrentPreachform("5");
+                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_WECHAT);
                 break;
             case "manualAgainSuccessInfo":
                 serviceSubtaskCountReq.setVisitCount(1);
@@ -3943,10 +4364,10 @@
                 serviceSubtaskCountReq.setVisitCount(2);
                 serviceSubtaskCountReq.setExcep("1");
                 break;
-            case "suggest6CountAgainInfo":
-                // 鍐嶆闅忚鍥為櫌澶嶈瘖澶嶆煡锛歷isitCount > 1 涓� suggest = 6
+            case "suggest7CountAgainInfo":
+                // 鍐嶆闅忚鍥為櫌澶嶈瘖澶嶆煡锛歷isitCount > 1 涓� suggest = 7
                 serviceSubtaskCountReq.setVisitCount(2);
-                serviceSubtaskCountReq.setSuggest("6");
+                serviceSubtaskCountReq.setSuggest("7");
                 break;
             case "taskSituation1Info":
                 serviceSubtaskCountReq.setTaskSituation(1);
@@ -4490,6 +4911,10 @@
         total.setManual(0L);
         total.setSms(0L);
         total.setWeChat(0L);
+        total.setVoiceCumulative(0L);
+        total.setWeChatCumulative(0L);
+        total.setSmsCumulative(0L);
+        total.setManualCumulative(0L);
         total.setAbnormal(0L);
         total.setNeedFollowUpAgain(0L);
         total.setPendingFollowUpAgain(0L);
@@ -4505,7 +4930,7 @@
         total.setSentAgain(0L);
         total.setFollowUpSuccessAgain(0L);
         total.setFollowUpFailAgain(0L);
-        total.setSuggest6CountAgain(0L);
+        total.setSuggest7CountAgain(0L);
         total.setManualAgain(0L);
         total.setSmsAgain(0L);
         total.setWeChatAgain(0L);
@@ -4535,6 +4960,10 @@
             total.setManual(total.getManual() + (stat.getManual() != null ? stat.getManual() : 0L));
             total.setSms(total.getSms() + (stat.getSms() != null ? stat.getSms() : 0L));
             total.setWeChat(total.getWeChat() + (stat.getWeChat() != null ? stat.getWeChat() : 0L));
+            total.setVoiceCumulative(total.getVoiceCumulative() + (stat.getVoiceCumulative() != null ? stat.getVoiceCumulative() : 0L));
+            total.setWeChatCumulative(total.getWeChatCumulative() + (stat.getWeChatCumulative() != null ? stat.getWeChatCumulative() : 0L));
+            total.setSmsCumulative(total.getSmsCumulative() + (stat.getSmsCumulative() != null ? stat.getSmsCumulative() : 0L));
+            total.setManualCumulative(total.getManualCumulative() + (stat.getManualCumulative() != null ? stat.getManualCumulative() : 0L));
             total.setAbnormal(total.getAbnormal() + (stat.getAbnormal() != null ? stat.getAbnormal() : 0L));
             total.setNeedFollowUpAgain(total.getNeedFollowUpAgain() + (stat.getNeedFollowUpAgain() != null ? stat.getNeedFollowUpAgain() : 0L));
             total.setPendingFollowUpAgain(total.getPendingFollowUpAgain() + (stat.getPendingFollowUpAgain() != null ? stat.getPendingFollowUpAgain() : 0L));
@@ -4550,7 +4979,7 @@
             total.setSentAgain(total.getSentAgain() + (stat.getSentAgain() != null ? stat.getSentAgain() : 0L));
             total.setFollowUpSuccessAgain(total.getFollowUpSuccessAgain() + (stat.getFollowUpSuccessAgain() != null ? stat.getFollowUpSuccessAgain() : 0L));
             total.setFollowUpFailAgain(total.getFollowUpFailAgain() + (stat.getFollowUpFailAgain() != null ? stat.getFollowUpFailAgain() : 0L));
-            total.setSuggest6CountAgain(total.getSuggest6CountAgain() + (stat.getSuggest6CountAgain() != null ? stat.getSuggest6CountAgain() : 0L));
+            total.setSuggest7CountAgain(total.getSuggest7CountAgain() + (stat.getSuggest7CountAgain() != null ? stat.getSuggest7CountAgain() : 0L));
             total.setManualAgain(total.getManualAgain() + (stat.getManualAgain() != null ? stat.getManualAgain() : 0L));
             total.setSmsAgain(total.getSmsAgain() + (stat.getSmsAgain() != null ? stat.getSmsAgain() : 0L));
             total.setWeChatAgain(total.getWeChatAgain() + (stat.getWeChatAgain() != null ? stat.getWeChatAgain() : 0L));
@@ -5128,7 +5557,7 @@
         serviceOutPath.setCreateTime(new Date());
         serviceOutPath.setOrgid(serviceSubtask.getOrgid());
         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
-        String format = String.format("%03X", serviceOutPath.getId());
+        String format = ShortCode.encode(serviceOutPath.getId());
         String url = "";
         SendMagParam sendMagParam = new SendMagParam();
         sendMagParam.setType("4");
@@ -5212,7 +5641,7 @@
             serviceOutPath.setCreateTime(new Date());
             serviceOutPath.setOrgid(serviceSubtask.getOrgid());
             iServiceOutPathService.insertServiceOutPath(serviceOutPath);
-            String format = String.format("%03X", serviceOutPath.getId());
+            String format = ShortCode.encode(serviceOutPath.getId());
             serviceOutPath.setRadix(format);
             serviceOutPath.setUpdateTime(new Date());
             serviceOutPath.setUrl(url);
@@ -5390,16 +5819,46 @@
         String ip = localIP;
         ServiceTask serviceTask = new ServiceTask();
         serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceTaskVo.getTaskid());
+        if (ObjectUtils.isEmpty(serviceTask)) {
+            // 浠诲姟涓嶅瓨鍦� 鈫� 涓嶅彲鑳芥湁 data锛岀洿鎺ユ姏涓氬姟寮傚父锛堟帴鍙e眰浼氳浆鎴� code=500锛�
+            throw new BaseException("鎵爜鐢熸垚浠诲姟澶辫触锛氫换鍔′笉瀛樺湪鎴栧凡鍒犻櫎锛坱askid=" + serviceTaskVo.getTaskid() + "锛�");
+        }
         if (ObjectUtils.isNotEmpty(serviceTask)) {
             try {
                 ServiceTaskdept serviceTaskdept = new ServiceTaskdept();
-                if (ObjectUtils.isNotEmpty(serviceTaskVo.getDeptcode())) {
-                    serviceTaskdept.setDeptType("1");
-                    serviceTaskdept.setDeptCode(serviceTaskVo.getDeptcode());
-                }
-                if (ObjectUtils.isNotEmpty(serviceTaskVo.getLeavehospitaldistrictcode())) {
+                // 缁村害锛堢瀹�/鐥呭尯/鐐逛綅锛夌敱浠诲姟鐨� appltype 鍐冲畾锛�1=绉戝銆�2=鐥呭尯銆�7=鐐逛綅銆�
+                //   涓夌缁村害鍦� service_taskdept 閲屾槸**鍚勮嚜鐙珛鐨勮**锛堝悇鑷殑鍒楋級锛屽彲浠ュ叡瀛樸�佷篃鍙互涓嶅叡瀛橈紱
+                //   浣嗘煡琛屾椂蹇呴』鍙甫涓�涓淮搴� 鈥斺�� 鍚﹀垯浼氱敤 A 缁村害鐨勭紪鐮佸幓鎾� B 缁村害鐨勮锛�
+                //   鑰岀偣浣嶈鐨� dept_code 鏈潵灏辨槸绌虹殑銆�
+                String appltype = serviceTask.getAppltype();
+                if ("7".equals(appltype)) {
+                    serviceTaskdept.setDeptType("3");
+                    serviceTaskdept.setPointLocation(firstNonBlank(serviceTaskVo.getPointLocation(),
+                            serviceTask.getPointLocation()));
+                } else if ("2".equals(appltype)) {
                     serviceTaskdept.setDeptType("2");
-                    serviceTaskdept.setDeptCode(serviceTaskVo.getLeavehospitaldistrictcode());
+                    // 浠诲姟涓婄殑绉戝/鐥呭尯鍙兘鏄�楀彿澶氶�夛紝鏌� service_taskdept 瑕佺敤鍗曞�硷紙鍙栫涓�涓級
+                    serviceTaskdept.setDeptCode(firstNonBlank(serviceTaskVo.getLeavehospitaldistrictcode(),
+                            firstValue(serviceTask.getLeavehospitaldistrictcode())));
+                } else if ("1".equals(appltype)) {
+                    serviceTaskdept.setDeptType("1");
+                    serviceTaskdept.setDeptCode(firstNonBlank(serviceTaskVo.getDeptcode(),
+                            firstValue(serviceTask.getDeptcode())));
+                } else {
+                    // appltype 涓虹┖鐨勫巻鍙蹭换鍔★細娌跨敤鏀归�犲墠鐨勫彛寰勶紙绉戝 鈫� 鐥呭尯锛屽悗鍐欑殑瑕嗙洊鍏堝啓鐨勶級锛�
+                    // 鐐逛綅浣滀负绗笁缁达紝鍙湪浼犱簡鐐逛綅鏃惰ˉ涓娿��
+                    if (ObjectUtils.isNotEmpty(serviceTaskVo.getDeptcode())) {
+                        serviceTaskdept.setDeptType("1");
+                        serviceTaskdept.setDeptCode(serviceTaskVo.getDeptcode());
+                    }
+                    if (ObjectUtils.isNotEmpty(serviceTaskVo.getLeavehospitaldistrictcode())) {
+                        serviceTaskdept.setDeptType("2");
+                        serviceTaskdept.setDeptCode(serviceTaskVo.getLeavehospitaldistrictcode());
+                    }
+                    if (ObjectUtils.isNotEmpty(serviceTaskVo.getPointLocation())) {
+                        serviceTaskdept.setDeptType("3");
+                        serviceTaskdept.setPointLocation(serviceTaskVo.getPointLocation());
+                    }
                 }
                 serviceTaskdept.setServiceType(serviceTask.getServiceType());
                 serviceTaskdept.setOrgid(serviceTask.getOrgid());
@@ -5427,7 +5886,7 @@
                         serviceOutPath.setCreateTime(new Date());
                         serviceOutPath.setOrgid(serviceTask.getOrgid());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
-                        String format = String.format("%03X", serviceOutPath.getId());
+                        String format = ShortCode.encode(serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
                         serviceOutPath.setUpdateTime(new Date());
                         String url = StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format;
@@ -5436,10 +5895,21 @@
                         iServiceOutPathService.updateServiceOutPath(serviceOutPath);
 
                     }
+                } else {
+                    // 閰嶇疆缂哄け灞炪�屼笟鍔″彲棰勬湡銆嶆儏鍐碉細甯︿笂鎺掓煡淇℃伅鎶涘嚭鍘伙紙涓嶅悶锛夛紝
+                    // 鎺ュ彛灞傛嵁姝よ繑鍥� code=500 + 鏄庣‘ msg锛岄伩鍏嶃��200 + 绌� data銆嶃��
+                    throw new BaseException("鎵爜鐢熸垚浠诲姟澶辫触锛氭湭鍖归厤鍒颁换鍔$淮搴﹂厤缃紙taskid=" + serviceTaskVo.getTaskid()
+                            + "锛宎ppltype=" + appltype
+                            + "锛宒eptType=" + serviceTaskdept.getDeptType()
+                            + "锛宒eptCode=" + serviceTaskdept.getDeptCode()
+                            + "锛宲ointLocation=" + serviceTaskdept.getPointLocation() + "锛�");
                 }
+            } catch (BaseException be) {
+                // 鈿狅笍 蹇呴』鎺掑湪 catch (Exception) 涔嬪墠锛欱aseException 鏄� RuntimeException锛�
+                //    鍚﹀垯鍒氭姏鍑虹殑涓氬姟寮傚父浼氳涓嬮潰鏁存鍚炴帀锛屾帴鍙e張鍙樻垚 200 + 绌� data銆�
+                throw be;
             } catch (Exception e) {
-                e.printStackTrace();
-                log.error("銆愭壂鐮佺敓鎴愪换鍔°�戝鐞嗗紓甯革細{}", e.getMessage());
+                log.error("銆愭壂鐮佺敓鎴愪换鍔°�戝鐞嗗紓甯革細taskid={}锛寋}", serviceTaskVo.getTaskid(), e.getMessage(), e);
             }
         }
         return content;
@@ -5457,6 +5927,9 @@
         if (StringUtils.isNotEmpty(serviceTaskdept.getDeptType()) && serviceTaskdept.getDeptType().equals("1")) {
             serviceSubtask.setLeaveldeptcode(serviceTaskdept.getDeptCode());
             serviceSubtask.setLeaveldeptname(serviceTaskdept.getDeptName());
+        } else if (StringUtils.isNotEmpty(serviceTaskdept.getDeptType()) && serviceTaskdept.getDeptType().equals("3")) {
+            // 鐐逛綅琛岋紙dept_type='3'锛夛細dept_code/dept_name 涓虹┖锛岀偣浣嶅彧钀� point_location
+            serviceSubtask.setPointLocation(serviceTaskdept.getPointLocation());
         } else {
             serviceSubtask.setLeavehospitaldistrictcode(serviceTaskdept.getDeptCode());
             serviceSubtask.setLeavehospitaldistrictname(serviceTaskdept.getDeptName());

--
Gitblit v1.9.3