From 5bbd99ba550aa2e8cd8da36644018981ca1a1921 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 23 九月 2026 16:58:51 +0800
Subject: [PATCH] 【丽水】更新同步

---
 ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java |   93 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 66 insertions(+), 27 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
index b9a4adb..e4e98d3 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -13,10 +13,7 @@
 import com.ruoyi.common.enums.ServiceFromEnum;
 import com.ruoyi.common.enums.WxGZHEnum;
 import com.ruoyi.common.exception.base.BaseException;
-import com.ruoyi.common.utils.HttpUtil;
-import com.ruoyi.common.utils.OkHttpExample;
-import com.ruoyi.common.utils.RSAPublicKeyExample;
-import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.*;
 import com.ruoyi.common.utils.http.HttpUtils;
 import com.ruoyi.common.utils.sign.Md5Utils;
 import com.ruoyi.common.utils.sms.smsUtils;
@@ -361,7 +358,6 @@
 //                                sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "&param2=" + patid + "&param3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "&param5=false");
                         sendMagParam.setPhone(serviceSubtask.getPhone());
                         sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format);
-                        log.info("sendMagParam鐨勫�间负锛歿}", sendMagParam);
                         //濡傛灉type鏄闊抽殢璁跨殑璇濓紙璇存槑琛ュ伩鍙戦�佹柟寮忎腑鏈夌數璇濋殢璁跨殑鏂瑰紡锛岃繖閲岀殑澶栭摼灏卞湴鍧�鍙兘鐢�/sf锛�
                         if (serviceSubtask.getType().equals("1"))
                             sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/sf?p=" + format : ip + "/sf?p=" + format);
@@ -393,15 +389,14 @@
                         serviceOutPath.setDeptName(serviceSubtask.getDeptname());
                         serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
+                        String url = "";
                         String format = String.format("%03X", serviceOutPath.getId());
-                        serviceOutPath.setRadix(format);
-                        serviceOutPath.setUpdateTime(new Date());
-                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                         //闇�瑕侀�氳繃妯℃澘ID鍘诲垽鏂鍙戠殑鍐呭鏄鏁欒繕鏄�氱煡
                         HeLibrary heLibrary = heLibraryMapper.selectHeLibraryById(serviceSubtask.getLibtemplateid());
                         if (heLibrary.getHetype().equals("1")) {
                             sendMagParam.setPhone(serviceSubtask.getPhone());
-                            sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/xj?p=" + format : ip + "/xj?p=" + format);
+                            url = StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/xj?p=" + format : ip + "/xj?p=" + format;
+                            sendMagParam.setUrl(url);
 
 
                             SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("xj.sms.template");
@@ -424,8 +419,12 @@
                             sendMagParam.setPhone(serviceSubtask.getPhone());
                             sendMagParam.setContent(sc);
                         }
+                        serviceOutPath.setRadix(format);
+                        serviceOutPath.setUpdateTime(new Date());
+                        serviceOutPath.setUrl(url);
+                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                     }
-
+                    log.info("sendMagParam鐨勫�间负锛歿}", sendMagParam);
                     //鐭俊杩橀渶瑕佹ā鏉�
                     String s = null;
                     if (active.equals("xh")) {
@@ -493,16 +492,18 @@
                         if (active.equals("sltd")) {
                             data = MessageSend.sendMsg(sendMagParam.getContent(), "6", sendMagParam.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
                             if (StringUtils.isNotEmpty(data)) {
-                                ObjectMapper mapper = new ObjectMapper();
-                                JsonNode root = mapper.readTree(data);
-                                String status = root.get("result").get(0).get("status").asText();
-                                if (status.equals("00000")) {
-                                    s = "true";
-                                } else {
-                                    setFailPreachForm(serviceSubtask, sendPreachform, "鐭俊鍙戦�佸け璐�: " + data, "5");
-                                    throw new BaseException("鐭俊鍙戦�佸け璐�");
+                                String[] pairs = data.split("&");
+                                String resultVal = null;
+                                for (String pair : pairs) {
+                                    String[] kv = pair.split("=", 2);
+                                    if ("result".equals(kv[0])) {
+                                        resultVal = kv.length > 1 ? kv[1] : null;
+                                        break;
+                                    }
                                 }
-
+                                if ("0".equals(resultVal)) {
+                                    s = "true";
+                                }
                             } else {
                                 setFailPreachForm(serviceSubtask, sendPreachform, "鐭俊鍙戦�佸け璐�: " + data, "5");
                                 throw new BaseException("鐭俊鍙戦�佸け璐�");
@@ -599,8 +600,9 @@
                         String format = String.format("%03X", serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
                         serviceOutPath.setUpdateTime(new Date());
-                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                         url = ip + ":" + req_path + "/sf?p=" + format;
+                        serviceOutPath.setUrl(url);
+                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                     } else if (type == 2) {
                         //闂埜
                         ServiceOutPath serviceOutPath = new ServiceOutPath();
@@ -616,13 +618,16 @@
                         serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                         String format = String.format("%03X", serviceOutPath.getId());
-                        serviceOutPath.setRadix(format);
-                        serviceOutPath.setUpdateTime(new Date());
-                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
+
                         url = StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format;
                         //濡傛灉type鏄闊抽殢璁跨殑璇濓紙璇存槑琛ュ伩鍙戦�佹柟寮忎腑鏈夌數璇濋殢璁跨殑鏂瑰紡锛岃繖閲岀殑澶栭摼灏卞湴鍧�鍙兘鐢�/sf锛�
                         if (serviceSubtask.getType().equals("1"))
                             sendMagParam.setUrl(ip + ":" + req_path + "/sf?p=" + format);
+
+                        serviceOutPath.setRadix(format);
+                        serviceOutPath.setUrl(url);
+                        serviceOutPath.setUpdateTime(new Date());
+                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                     } else if (type == 3) {
                         //瀹f暀
                         ServiceOutPath serviceOutPath = new ServiceOutPath();
@@ -638,9 +643,6 @@
                         serviceOutPath.setOrgid(serviceSubtask.getOrgid());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                         String format = String.format("%03X", serviceOutPath.getId());
-                        serviceOutPath.setRadix(format);
-                        serviceOutPath.setUpdateTime(new Date());
-                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
 
                         //闇�瑕侀�氳繃妯℃澘ID鍘诲垽鏂鍙戠殑鍐呭鏄鏁欒繕鏄�氱煡
 //                        HeLibrary heLibrary = heLibraryMapper.selectHeLibraryById(serviceSubtask.getLibtemplateid());
@@ -660,6 +662,10 @@
 //                        }
 
                         url = ip + ":" + req_path + "/xj?p=" + format;
+                        serviceOutPath.setRadix(format);
+                        serviceOutPath.setUpdateTime(new Date());
+                        serviceOutPath.setUrl(url);
+                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                     }
                     if (StringUtils.isEmpty(patArchive.getPatidHis())) {
                         serviceSubtask.setCurrentPreachform(sendPreachform);
@@ -935,7 +941,8 @@
             serviceSubtaskPreachform1.setRemark(remark);
             serviceSubtaskPreachformMapper.updateServiceSubtaskPreachform(serviceSubtaskPreachform1);
             //濡傛灉褰撳墠鐨刾reachform宸茬粡鏄渶鍚庝竴涓簡,骞朵笖鏈杩樻槸鍙戦�佸け璐ワ紝閭g洿鎺ュ皢serviceSubtask鐨剆endstate鐘舵�佹敼鎴�5灏辫浜�(鍏ㄥけ璐ヤ簡)
-            if (CollectionUtils.isNotEmpty(spSize) && serviceSubtaskPreachform1.getSort() == spSize.size()) {
+            if (CollectionUtils.isNotEmpty(spSize) && serviceSubtaskPreachform1.getSort() == spSize.size()
+                    && isSubtaskDeadline(serviceSubtask, serviceSubtaskPreachforms)) {
                 if (serviceSubtaskPreachform1.getSort() == spSize.size()) {
                     if (failSendstate.equals("4") || failSendstate.equals("5")) {
                         serviceSubtask.setCurrentPreachform(preachform);
@@ -1061,6 +1068,7 @@
         String body = new Gson().toJson(map);
 
         String result = null;
+        log.info("銆恎etDXCode銆�-鐭俊鍙戦�佸叆鍙� body = {}", body);
         try {
             result = OkHttpExample.sendPostRequest(address, body, token);
         } catch (IOException e) {
@@ -1087,4 +1095,35 @@
         }
         return toHex(md5.digest());
     }
+
+    /**
+     * 闅忚浠诲姟鏄惁瓒呮椂
+     * @param serviceSubtask
+     * @param serviceSubtaskPreachforms
+     * @return
+     */
+    public boolean isSubtaskDeadline(ServiceSubtask serviceSubtask, List<ServiceSubtaskPreachform> serviceSubtaskPreachforms){
+        if (ObjectUtils.isNotEmpty(serviceSubtask)) {
+            //鍙湁鍑洪櫌闅忚鍜屼笓鐥呴殢璁挎湁瓒呮椂
+            if(StringUtils.isNotEmpty(serviceSubtask.getServiceType()) &&
+                    !serviceSubtask.getServiceType().equals("2") && !serviceSubtask.getServiceType().equals("13")){
+                return true;
+            }
+        }
+        if (Objects.isNull(serviceSubtask) || CollectionUtils.isEmpty(serviceSubtaskPreachforms)) {
+            return false;
+        }
+        // 鍩哄噯鏃跺埢锛氬嚭闄㈡椂闂� + 鍙戦�佹棩锛坰endDay 缂虹渷鎸� 1锛夛紝骞跺厹搴曢伩鍏� NPE/鑴忔暟鎹�
+        ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+        int sendDay = serviceTask != null && serviceTask.getSendDay() != null ? serviceTask.getSendDay().intValue() : 1;
+        Date deadline = DateUtils.addDays(serviceSubtask.getEndtime(), sendDay);
+        int sumCompensateTime = CollectionUtils.isEmpty(serviceSubtaskPreachforms) ? 0 : serviceSubtaskPreachforms.stream()
+                .mapToInt(x -> x.getCompensateTime() == null ? 0 : Integer.parseInt(x.getCompensateTime()))
+                .sum();
+        sumCompensateTime = sumCompensateTime + 1;
+        // 鍙ˉ鍋挎渶鍚庝竴姝ヨ嚜韬殑琛ュ伩鏃堕棿锛堝ぉ锛夛紝鑴忓�间竴寰嬫寜 0 鍏滃簳
+        deadline = DateUtils.addDays(deadline, sumCompensateTime);
+        // 鍑洪櫌(鍙戦��)鏃堕棿 + 鏈琛ュ伩鏃堕棿 灏忎簬褰撳墠鏃堕棿 -> 瓒呮椂
+        return deadline.getTime() < new Date().getTime();
+    }
 }

--
Gitblit v1.9.3