From 57d12c99f6f0f1d0ab62b50d3c2aeb1e30a8d6f8 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期五, 16 十月 2026 16:22:46 +0800
Subject: [PATCH] 【丽水】宣教统计院区编码

---
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java |  105 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 81 insertions(+), 24 deletions(-)

diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
index 34ada0f..b7daf8d 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -8,6 +8,7 @@
 import com.google.gson.Gson;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysDept;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.core.service.IDingTalkService;
 import com.ruoyi.common.dx.MessageSend;
@@ -23,6 +24,7 @@
 import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.system.service.ISysDeptService;
+import com.ruoyi.system.service.ISysUserService;
 import com.smartor.common.LSHospTokenUtil;
 import com.smartor.common.MtSubmitSmUtil;
 import com.smartor.common.QwenLLMUtil;
@@ -108,6 +110,9 @@
 
     @Autowired
     private IDingTalkService dingTalkService;
+
+    @Autowired
+    private ISysUserService userService;
 
 
     @Value("${localIP}")
@@ -283,31 +288,67 @@
         subtaskDetailTraceVO.setHandleFlag("0");
         List<ServiceSubtaskDetailTrace> serviceSubtaskDetailTraces =
                 serviceSubtaskDetailTraceService.selectServiceSubtaskDetailTtraceList(subtaskDetailTraceVO);
-        // 鎶� dutyDeptPersonCode 鏁寸悊鍒� list 涓紙濡傛灉澶氫釜浜虹敤閫楀彿鍒嗗壊锛屽垯灞曞紑骞跺幓閲嶏級
-        List<String> dutyDeptPersonCodeList = serviceSubtaskDetailTraces.stream()
-                .map(ServiceSubtaskDetailTrace::getDutyDeptPersonCode)
-                .filter(StringUtils::isNotBlank)
-                .flatMap(code -> Arrays.stream(code.split(",")))
-                .map(String::trim)
-                .filter(StringUtils::isNotBlank).distinct()  // 鍘婚噸
-                .collect(Collectors.toList());
         // 鑾峰彇鈥滃紓甯稿唴瀹规彁閱�"
         SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("send.except.content");
         String exceptContent = sysConfig.getConfigValue();
 
         // 鑾峰彇鈥滃唴瀹规彁閱掓祴璇曚汉宸ュ彿鈥�
-        String testPerson = sysConfigMapper.checkConfigKeyUnique("send.test.person").getConfigValue();
-        if (StringUtils.isNotBlank(testPerson)) {
-            String[] split = testPerson.split(",");
-            if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) dutyDeptPersonCodeList = Arrays.asList(split);
-            else dutyDeptPersonCodeList.addAll(Arrays.asList(split));
-        }
+        SysConfig testPersonConfig = sysConfigMapper.checkConfigKeyUnique("send.test.person");
+        String testPerson = ObjectUtils.isNotEmpty(testPersonConfig) ? testPersonConfig.getConfigValue() : "";
+        if(CollectionUtils.isNotEmpty(serviceSubtaskDetailTraces)){
+            for (ServiceSubtaskDetailTrace serviceSubtaskDetailTrace : serviceSubtaskDetailTraces) {
+                List<String> dutyDeptPersonCodeList = new ArrayList<>();
+                        // 鎶� dutyDeptPersonCode 鏁寸悊鍒� list 涓紙濡傛灉澶氫釜浜虹敤閫楀彿鍒嗗壊锛屽垯灞曞紑骞跺幓閲嶏級
+                String dutyDeptPersonCodeStr = serviceSubtaskDetailTrace.getDutyDeptPersonCode();
+                if(StringUtils.isNotEmpty(dutyDeptPersonCodeStr)){
+                    String[] dutyDeptPersonCodeSplit = dutyDeptPersonCodeStr.split(",");
+                    if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) {
+                        dutyDeptPersonCodeList = new ArrayList<>(Arrays.asList(dutyDeptPersonCodeSplit));
+                    } else {
+                        dutyDeptPersonCodeList.addAll(Arrays.asList(dutyDeptPersonCodeSplit));
+                    }
 
-        if (CollectionUtils.isNotEmpty(dutyDeptPersonCodeList)) {
-            for (String dutyDeptPersonCode : dutyDeptPersonCodeList) {
-                log.info("銆恠endExceptInfo銆戝彂閫佷汉宸ュ彿锛歿}", dutyDeptPersonCode);
-                String dutyDeptPerson = dingTalkService.getDingTalkUserByMobile(dutyDeptPersonCode);
-                dingTalkService.sendDingTalkText(exceptContent, dutyDeptPerson);
+                }
+
+                if (StringUtils.isNotBlank(testPerson)) {
+                    String[] split = testPerson.split(",");
+                    if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) {
+                        dutyDeptPersonCodeList = new ArrayList<>(Arrays.asList(split));
+                    } else {
+                        dutyDeptPersonCodeList.addAll(Arrays.asList(split));
+                    }
+                }
+
+                if (CollectionUtils.isNotEmpty(dutyDeptPersonCodeList)) {
+                    for (String dutyDeptPersonCode : dutyDeptPersonCodeList) {
+                        log.info("銆恠endExceptInfo銆戝彂閫佷汉宸ュ彿锛歿}", dutyDeptPersonCode);
+                        SysUser sysUser = new SysUser();
+                        SysUser sysUserVo = new SysUser();
+                        sysUserVo.setUserName(dutyDeptPersonCode);
+                        sysUserVo.setOrgid(serviceSubtaskDetailTrace.getOrgid());
+                        List<SysUser> users = userService.getUserList(sysUserVo);
+                        String phoneNumber = "";
+                        if(ObjectUtils.isNotEmpty(users)){
+                            sysUser = users.get(0);
+                            phoneNumber = sysUser.getPhonenumber();
+                        }else {
+                            continue;
+                        }
+
+                        if(StringUtils.isEmpty(phoneNumber)){
+                            continue;
+                        }
+                        String dutyDeptPerson = dingTalkService.getDingTalkUserByMobile(phoneNumber);
+                        if(StringUtils.isNotBlank(dutyDeptPerson)){
+                            String context = TemplateUtils.render(exceptContent, serviceSubtaskDetailTrace);
+                            dingTalkService.sendDingTalkText(context, dutyDeptPerson);
+                            //鏇存柊鐘舵��
+                            serviceSubtaskDetailTrace.setHandleFlag("1");
+                            serviceSubtaskDetailTrace.setUpdateTime(new Date());
+                            serviceSubtaskDetailTraceService.updateServiceSubtaskDetailTtrace(serviceSubtaskDetailTrace);
+                        }
+                    }
+                }
             }
         }
     }
@@ -882,6 +923,13 @@
             serviceSubtaskList.addAll(compensateServiceSubtaskList);
         }
         for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
+            //currentPreachform涓虹┖锛岃鏄庤瀛愪换鍔¤繕娌℃湁鎵ц杩囦换浣曚竴绉嶅彂閫佹柟寮�(sendstate=1锛屽睘浜庨娆¤ˉ鍋�)锛�
+            //杩欓噷鐩存帴浜ょ粰sfHandlle澶勭悊锛屽畠浼氭寜sort=1鐨勭涓�绉嶅彂閫佹柟寮忓彂閫侊紝涓巊etSendPreachform涓殑澶勭悊淇濇寔涓�鑷�
+            if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) {
+                log.warn("銆恈ompensateTask銆憇ubid锛歿}锛宑urrentPreachform涓虹┖锛屾寜绗竴绉嶅彂閫佹柟寮忚ˉ鍋垮鐞�", serviceSubtask.getId());
+                sfHandlle(serviceSubtask);
+                continue;
+            }
             //鏍规嵁褰撳墠鐨勬墽琛屾柟寮忥紝鑾峰彇涓嬩竴绉嶆墽琛屾柟寮�
             ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform();
             serviceSubtaskPreachform.setTaskid(serviceSubtask.getTaskid());
@@ -1090,7 +1138,7 @@
                         } else {
                             sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template");
                         }
-                        if (!Objects.isNull(sysConfig)) {
+                        if (!Objects.isNull(sysConfig) && StringUtils.isNotEmpty(sysConfig.getConfigValue())) {
                             String smsContemt = sysConfig.getConfigValue();
 //                            sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
                             sendMagParam.setContent(smsContemt.replace("${wjurl}", sendMagParam.getUrl()));
@@ -1104,7 +1152,7 @@
                             sendMagParam.setUrl(url);
 
                             SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("xj.sms.template");
-                            if (!Objects.isNull(sysConfig)) {
+                            if (!Objects.isNull(sysConfig) && StringUtils.isNotEmpty(sysConfig.getConfigValue())) {
                                 String smsContemt = sysConfig.getConfigValue();
 //                              sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
                                 sendMagParam.setContent(smsContemt.replace("${xjurl}", sendMagParam.getUrl()));
@@ -1118,6 +1166,13 @@
                             sendMagParam.setContent(content);
                         }
 
+                    }
+
+                    //鍐呭涓虹┖璇存槑鐭俊妯℃澘鏈厤缃垨瀹f暀/閫氱煡鍐呭涓虹┖锛岀洿鎺ユ寜鍙戦�佸け璐ュ鐞嗭紝閬垮厤鍚庣画鍙戦�佹椂鍑虹幇绌烘寚閽�
+                    if (StringUtils.isEmpty(sendMagParam.getContent())) {
+                        log.error("銆恠fHandlle銆戦暱鏈熶换鍔$煭淇″唴瀹逛负绌猴紝鏃犳硶鍙戦�侊紝subid锛歿}锛宼askid锛歿}锛宼ype锛歿}锛屾満鏋処D锛歿}", serviceSubtask.getId(), serviceSubtask.getTaskid(), serviceSubtask.getType(), serviceSubtask.getOrgid());
+                        setSuccessPreachForm(serviceSubtask, sendPreachform, "闀挎湡浠诲姟鐭俊鍙戦�佸け璐�:鐭俊鍐呭涓虹┖(鐭俊妯℃澘鏈厤缃垨鍐呭涓虹┖), 鏃堕棿: " + now, "5");
+                        return;
                     }
 
                     serviceOutPath.setRadix(format);
@@ -1707,14 +1762,15 @@
      * @return
      */
     private String getObject(ServiceSubtask serviceSubtask, String scriptContent) {
+        //鍐呭涓虹┖鏃剁洿鎺ヨ繑鍥烇紝閬垮厤涓嬮潰鐨剅eplace鍑虹幇绌烘寚閽�
+        if (StringUtils.isEmpty(scriptContent)) {
+            return scriptContent;
+        }
         Map<String, Map<String, String>> param = getParam(serviceSubtask.getTaskid());
         for (Map<String, String> map : param.values()) {
             for (String key : map.keySet()) {
                 scriptContent = scriptContent.replace(key, StringUtils.isNotEmpty(map.get(key)) ? map.get(key) : "");
             }
-        }
-        if (StringUtils.isEmpty(scriptContent)) {
-            return scriptContent;
         }
         scriptContent = scriptContent.replace("${name}", StringUtils.isNotEmpty(serviceSubtask.getSendname()) ? serviceSubtask.getSendname() : "");
         scriptContent = scriptContent.replace("${dzz}", StringUtils.isNotEmpty(serviceSubtask.getAddr()) ? serviceSubtask.getAddr() : "");
@@ -1846,6 +1902,7 @@
                 PatMedInhosp patMedInhospVo = new PatMedInhosp();
                 patMedInhospVo.setOrgid(serviceSubtask.getOrgid());
                 patMedInhospVo.setInhospid(serviceSubtask.getInhospid());
+                patMedInhospVo.setCry(1);
                 List<PatMedInhosp> patMedInhospList = iPatMedInhospService.selectPatMedInhospList(patMedInhospVo);
                 PatMedInhosp patMedInhosp = new PatMedInhosp();
                 if (!patMedInhospList.isEmpty()) {

--
Gitblit v1.9.3