From 6659135780e718758417efde4c8c351c69e3755b Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 11 十二月 2025 15:52:19 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSLTDHealthcareRecordServiceImpl.java |  286 +++++++--
 smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml                           |    3 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java          |   15 
 smartor/src/main/resources/mapper/smartor/IvrLibaTemplateScriptMapper.xml                  |    6 
 smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java             |    2 
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetailVO.java                       |    6 
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailMapper.xml                   |    7 
 smartor/src/main/resources/mapper/smartor/IvrLibScriptMapper.xml                           |    2 
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java        |    5 
 smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScript.java                        |    6 
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SmsRecordsServiceImpl.java        |   31 
 smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml                          |   97 +++
 smartor/src/main/java/com/smartor/common/LSHospTokenUtil.java                              |   11 
 smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScript.java                        |    7 
 ruoyi-admin/src/main/resources/application.yml                                             |    3 
 smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScriptVO.java                      |    6 
 smartor/src/main/resources/mapper/smartor/SvyTaskTemplateMapper.xml                        |    1 
 smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScriptVO.java                      |    8 
 smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java                                |    6 
 smartor/src/main/java/com/smartor/service/impl/SvyTaskSingleServiceImpl.java               |   20 
 smartor/src/main/java/com/smartor/service/IXHGatherPatArchiveService.java                  |    5 
 ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java                     |  137 +++
 ruoyi-common/src/main/java/com/ruoyi/common/enums/MsgLSEnum.java                           |   65 -
 ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java                                   |    5 
 ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java               |    2 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedOuthospController.java    |    3 
 ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml                          |    3 
 smartor/src/main/java/com/smartor/domain/ServiceSubtask.java                               |    4 
 smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java                          |    8 
 ruoyi-admin/src/main/resources/application-sltd.yml                                        |    4 
 smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java                  |    4 
 smartor/src/main/java/com/smartor/service/impl/SvyTaskTemplateServiceImpl.java             |    5 
 smartor/src/main/resources/mapper/smartor/IvrTaskTemplateScriptMapper.xml                  |    6 
 ruoyi-admin/src/main/resources/application-xh.yml                                          |    8 
 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SmsRecordsMapper.java                   |    5 
 smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java               |   84 +-
 smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java                |   60 +
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskDiagname.java                       |   55 +
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java              |  333 +++++++++-
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTaskController.java      |    1 
 smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java                         |    2 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java           |    5 
 smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScript.java                        |    7 
 ruoyi-admin/src/main/resources/application-ls.yml                                          |    8 
 smartor/src/main/java/com/smartor/domain/PatTaskRelevance.java                             |    7 
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java                             |    2 
 ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java                           |    3 
 smartor/src/main/java/com/smartor/service/IServiceSLTDHealthcareRecordService.java         |    4 
 ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml                                  |    2 
 smartor/src/main/resources/mapper/smartor/SvyTaskTemplateTargetoptionMapper.xml            |    5 
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskStatistic.java                      |   20 
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskCountReq.java                       |    7 
 smartor/src/main/resources/mapper/smartor/ServiceTaskMapper.xml                            |   10 
 smartor/src/main/java/com/smartor/domain/SvyLibTemplateScript.java                         |    1 
 smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java                      |    6 
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml                         |   30 
 smartor/src/main/resources/mapper/smartor/IvrLibaScriptMapper.xml                          |    2 
 smartor/src/main/java/com/smartor/service/IPatMedInhospService.java                        |    2 
 ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml                          |   28 
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java                               |  132 +++
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetail.java                         |    7 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java   |   60 +
 smartor/src/main/java/com/smartor/domain/PatMedInhosp.java                                 |    2 
 ruoyi-admin/src/main/resources/application-druid.yml                                       |    8 
 ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java                  |   47 
 smartor/src/main/resources/mapper/smartor/SvyTaskTemplateScriptMapper.xml                  |    6 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatArchiveController.java       |    6 
 smartor/src/main/java/com/smartor/domain/ServiceTaskdiag.java                              |    6 
 68 files changed, 1,360 insertions(+), 390 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 37030a9..25b502e 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
@@ -1,6 +1,8 @@
 package com.ruoyi.web.component;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
@@ -15,6 +17,7 @@
 import com.ruoyi.common.utils.RSAPublicKeyExample;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpUtils;
+import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.service.ISysConfigService;
 import com.smartor.common.LSHospTokenUtil;
 import com.smartor.domain.*;
@@ -79,7 +82,7 @@
     private RedisCache redisCache;
 
     @Autowired
-    private ServiceTaskMapper svyTaskMapper;
+    private ServiceTaskMapper serviceTaskMapper;
 
     @Autowired
     private ServiceSubtaskMapper serviceSubtaskMapper;
@@ -143,7 +146,7 @@
             if (commonTaskcallMQ.getUpdateSendstate() == null || commonTaskcallMQ.getUpdateSendstate() == 1) {
                 serviceTask.setSendState(5L);
                 serviceTask.setFail(1L);
-                svyTaskMapper.updateServiceTask(serviceTask);
+                serviceTaskMapper.updateServiceTask(serviceTask);
             }
         } catch (Exception e) {
             Integer integer = redisCache.getCacheObject(commonTaskcallMQ.getTaskid().toString());
@@ -152,7 +155,7 @@
                 ServiceTask serviceTask = new ServiceTask();
                 serviceTask.setTaskid(Long.valueOf(commonTaskcallMQ.getTaskid().toString()));
                 serviceTask.setFail(0L);
-                svyTaskMapper.updateServiceTask(serviceTask);
+                serviceTaskMapper.updateServiceTask(serviceTask);
                 //灏嗘秷鎭粠闃熷垪涓垹闄�
             } else if (integer == null) {
                 redisCache.setCacheObject(commonTaskcallMQ.getTaskid().toString(), 1, 120, TimeUnit.MINUTES);
@@ -355,8 +358,9 @@
                             }
                         } else if (heLibrary.getHetype().equals("2")) {
                             //閫氱煡
+                            String sc = getSC(serviceSubtask, heLibrary.getPreachcontent());
                             sendMagParam.setPhone(serviceSubtask.getPhone());
-                            sendMagParam.setContent(heLibrary.getPreachcontent());
+                            sendMagParam.setContent(sc);
                         }
                     }
 
@@ -367,28 +371,39 @@
                         Map<String, String> req = new HashMap<>();
                         req.put("phone", sendMagParam.getPhone());
                         req.put("content", sendMagParam.getContent());
+                        log.info("content杩斿洖鍊肩殑鍐呭鏄細{}", sendMagParam.getContent());
                         s = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req));
                     } else if (active.equals("ls")) {
-                        String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid());
-                        log.info("-------00token.360鐨刄RL涓猴細{}", url);
+//                        String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid());
+//                        log.info("-------00token.360鐨刄RL涓猴細{}", url);
+
                         //涓芥按鐨勭煭淇″彂閫佹柟寮�
-                        Map<String, String> map = MsgLSEnum.getAddressByCode(serviceSubtask.getOrgid());
-                        log.info("-----------map鐨勫�间负锛歿}", map);
-                        String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), url);
-                        log.info("-----------token鐨勫�间负锛歿}", token);
-                        if (ObjectUtils.isNotEmpty(map) && StringUtils.isEmpty(map.get("address"))) {
+                        SysConfig config = new SysConfig();
+                        config.setConfigKey("ls.msg.info");
+                        config.setOrgid(serviceSubtask.getOrgid());
+                        List<SysConfig> sysConfigs = configService.selectConfigList(config);
+                        Map<String, String> msgInfo = new HashMap<>();
+                        if (CollectionUtils.isNotEmpty(sysConfigs)) {
+                            String configValue = sysConfigs.get(0).getConfigValue();
+                            ObjectMapper objectMapper = new ObjectMapper();
+                            if (StringUtils.isNotEmpty(configValue)) {
+                                msgInfo = objectMapper.readValue(configValue, Map.class);
+                            }
+                        }
+                        log.info("-----------map鐨勫�间负锛歿}", msgInfo);
+
+                        if (ObjectUtils.isNotEmpty(msgInfo) && StringUtils.isEmpty(msgInfo.get("address"))) {
                             serviceSubtask.setCurrentPreachform(sendPreachform);
                             serviceSubtask.setVisitTime(getNextVisitTime(serviceSubtask.getId(), serviceSubtask.getTaskid(), serviceSubtask.getVisitTime(), serviceSubtask.getCurrentPreachform()));
                             setFailPreachForm(serviceSubtask, descByCode, "鐭俊鍙戦�佸け璐�,璇ユ満鏋勬病鏈夐厤缃煭淇″湴鍧�", "5");
                             serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                             continue;
                         }
-                        log.info("---------mq涓芥按鐭俊鍙戦�佸叆鍙俛ddress锛歿},  sendMagParam:{},  orgid:{}-------", map.get("address"), sendMagParam, serviceSubtask.getOrgid());
-                        String dxCode = getDXCode(map.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), map.get("sendPersonId"), map.get("sendPersonName"), MsgLSEnum.getHeaderByCode(serviceSubtask.getOrgid()), token);
-                        log.info("---------涓芥按鐭俊鍙戦�佺粨鏋滐細{}-------", dxCode);
+
+                        String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), msgInfo.get("tokenUrl"));
+                        String dxCode = getDXCode(msgInfo.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), msgInfo.get("sendPersonId"), msgInfo.get("sendPersonName"), MsgLSEnum.getHeaderByCode(msgInfo), token);
                         ObjectMapper objectMapper = new ObjectMapper();
                         Map<String, Object> textParam = objectMapper.readValue(dxCode, Map.class);
-                        log.info("---------涓芥按鐭俊鍙戦�佺粨鏋�--textParam鐨勫�间负锛歿}-------", textParam);
                         String code = textParam.get("Code").toString();
                         if (code.equals("0")) {
                             s = "true";
@@ -397,9 +412,8 @@
                             throw new BaseException("鐭俊鍙戦�佸け璐�");
                         }
                     } else if (active.equals("sltd")) {
-                        log.info("-------杩涙潵浜嗕笉锛燂紵");
                         //鐪佺珛鍚屽痉鐨勭煭淇″彂閫佹柟寮�
-                        String data = MessageSend.sendMsg(sendMagParam.getContent(), "2", sendMagParam.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
+                        String data = MessageSend.sendMsg(sendMagParam.getContent(), "6", sendMagParam.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
                         if (StringUtils.isNotEmpty(data) && data.contains("result=0")) {
                             s = "true";
                         } else {
@@ -493,6 +507,24 @@
                         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(ip + ":" + req_path + "/xj?p=" + format);
+//                            if (active.equals("ls") || active.equals("sltd")) {
+//                                sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+//                            } else if (active.equals("xh")) {
+//                                sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+//                            }
+//                        } else if (heLibrary.getHetype().equals("2")) {
+//                            //閫氱煡
+//                            String sc = getSC(serviceSubtask, heLibrary.getPreachcontent());
+//                            sendMagParam.setPhone(serviceSubtask.getPhone());
+//                            sendMagParam.setContent(sc);
+//                        }
+
                         url = ip + ":" + req_path + "/xj?p=" + format;
                     }
                     if (StringUtils.isEmpty(patArchive.getPatidHis())) {
@@ -581,6 +613,32 @@
 
     }
 
+    private String getSC(ServiceSubtask serviceSubtask, String 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, org.apache.commons.lang3.StringUtils.isNotEmpty(map.get(key)) ? map.get(key) : "");
+            }
+        }
+        scriptContent = scriptContent.replace("${name}", org.apache.commons.lang3.StringUtils.isNotEmpty(serviceSubtask.getSendname()) ? serviceSubtask.getSendname() : "");
+        scriptContent = scriptContent.replace("${dzz}", org.apache.commons.lang3.StringUtils.isNotEmpty(serviceSubtask.getAddr()) ? serviceSubtask.getAddr() : "");
+        scriptContent = scriptContent.replace("${phone}", org.apache.commons.lang3.StringUtils.isNotEmpty(serviceSubtask.getTelcode()) ? serviceSubtask.getTelcode() : "");
+
+        return scriptContent;
+    }
+
+    private Map<String, Map<String, String>> getParam(Long taskId) {
+        ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(taskId);
+        ObjectMapper objectMapper = new ObjectMapper();
+        Map<String, Map<String, String>> serviceTaskMap = null;
+        try {
+            serviceTaskMap = objectMapper.readValue(serviceTask.getTextParam(), Map.class);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+        return serviceTaskMap;
+    }
+
     private Date getNextVisitTime(Long subid, Long taskid, Date visitTime, String currentPreachform) {
         ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform();
         serviceSubtaskPreachform.setSubid(subid);
@@ -604,6 +662,16 @@
     private String getSendPreachform(ServiceSubtaskPreachform serviceSubtaskPreachform, ServiceSubtask serviceSubtask) {
         log.info("-----getSendPreachform鐨剆erviceSubtaskPreachform鍏ュ弬锛歿},------serviceSubtask:{}", serviceSubtaskPreachform, serviceSubtask);
         List<ServiceSubtaskPreachform> serviceSubtaskPreachforms = serviceSubtaskPreachformMapper.selectServiceSubtaskPreachformList(serviceSubtaskPreachform);
+        if (CollectionUtils.isEmpty(serviceSubtaskPreachforms)) {
+            //濡傛灉serviceSubtaskPreachforms涓虹┖鐨勮瘽锛屽垯闇�瑕佽繘琛屾柊澧炰竴涓�
+            List<ServiceSubtaskPreachform> serviceSubtaskPreachformList = addServiceSubtaskPreachform(serviceSubtask, "1");
+            if (CollectionUtils.isEmpty(serviceSubtaskPreachformList)) {
+                log.error("鍙戦�佹柟寮忓け璐ヤ簡serviceSubtask鐨勫叆鍙備负锛歿}", serviceSubtask);
+                return null;
+            }
+            serviceSubtaskPreachforms = serviceSubtaskPreachformList;
+        }
+
 
         // 鎯呭喌1锛歝urrentPreachform涓虹┖锛屽彇sort涓�1鐨刾reachform
         if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) {
@@ -637,6 +705,35 @@
         return null;
     }
 
+    private List<ServiceSubtaskPreachform> addServiceSubtaskPreachform(ServiceSubtask serviceSubtask, String sendstate) {
+        //灏唒reachformDesc鐨刯son瀵硅薄锛屾斁鍒發ist闆嗗悎涓�
+        ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+        String preachformDesc = serviceTask.getPreachformDesc();
+
+        List<ServiceSubtaskPreachform> sspl = null;
+        ObjectMapper objectMapper = new ObjectMapper();
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(preachformDesc)) {
+            try {
+                sspl = objectMapper.readValue(preachformDesc, new TypeReference<List<ServiceSubtaskPreachform>>() {
+                });
+            } catch (JsonProcessingException e) {
+                log.error("mq--preachform杞琇ist<ServiceSubtaskPreachform>鎶ラ敊浜嗭細{}", e.getMessage());
+            }
+            for (ServiceSubtaskPreachform serviceSubtaskPreachform : sspl) {
+                serviceSubtaskPreachform.setTaskid(serviceSubtask.getTaskid());
+                serviceSubtaskPreachform.setSubid(serviceSubtask.getId());
+                //杩欎釜sendstate闇�瑕佸湪鏁版嵁搴撹缃竴涓粯璁ゅ�间负鈥�1鈥�
+                serviceSubtaskPreachform.setSendstate("1");
+                if (StringUtils.isNotEmpty(sendstate)) serviceSubtaskPreachform.setSendstate(sendstate);
+
+                serviceSubtaskPreachform.setOrgid(serviceSubtask.getOrgid());
+                serviceSubtaskPreachformMapper.insertServiceSubtaskPreachform(serviceSubtaskPreachform);
+            }
+
+        }
+
+        return sspl;
+    }
 
     /**
      * @param serviceSubtask
@@ -674,8 +771,9 @@
         serviceSubtaskPreachform.setPreachform(preachform);
         //1:鏈彂閫佺姸鎬�
         serviceSubtaskPreachform.setSendstate("1");
-        log.error("---serviceSubtaskPreachform鍏ュ弬涓猴細{}", serviceSubtaskPreachform);
+        log.info("---serviceSubtaskPreachform鍏ュ弬涓猴細{}", serviceSubtaskPreachform);
         List<ServiceSubtaskPreachform> serviceSubtaskPreachforms = serviceSubtaskPreachformMapper.selectServiceSubtaskPreachformList(serviceSubtaskPreachform);
+        log.info("---serviceSubtaskPreachform杩斿弬涓猴細{}", serviceSubtaskPreachforms);
         //鐢佃瘽鐨勬湭鍙戦�佺姸鎬侊紝闇�瑕佹煡2锛屽洜涓猴紝鏁版嵁鍙兘鍗″湪闃熷垪閲屼簡(涔熸湁鍙兘娌℃湁鎷夊彇锛宻endstate=1,鎵�浠ュ鏋滄槸鐢佃瘽鐘舵�佸垽鏂璼erviceSubtaskPreachforms鏄笉鏄负绌�)
         if (preachform.equals("3") && CollectionUtils.isEmpty(serviceSubtaskPreachforms)) {
             serviceSubtaskPreachform.setSendstate("2");
@@ -814,14 +912,13 @@
 
         String body = new Gson().toJson(map);
 
-//        String result = HttpUtils.sendPost(address, body);
         String result = null;
         try {
             result = OkHttpExample.sendPostRequest(address, body, token);
         } catch (IOException e) {
             e.printStackTrace();
         }
-        log.error("--------result鐨勫�间负锛歿}-----", result);
+        log.info("--------result鐨勫�间负锛歿}-----", result);
 
         JSONObject jsonObject = JSONObject.parseObject(result);
         String code = (String) jsonObject.toString();
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatArchiveController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatArchiveController.java
index 88f998c..a5318fe 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatArchiveController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatArchiveController.java
@@ -277,12 +277,6 @@
         patArchiveReq.setPageNum(null);
         List<PatArchiveOthreInfo> patientInfoQC = patArchiveService.getPatientInfoQC(patArchiveReq);
 
-//        long count = PageUtils.count(new ISelect() {
-//            @Override
-//            public void doSelect() {
-//                patArchiveService.getPatientInfoQC(patArchiveReq);
-//            }
-//        });
         return getDataTable3(patientInfoQC.size(), patientInfo);
     }
 
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedOuthospController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedOuthospController.java
index c0d92e0..344cba0 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedOuthospController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedOuthospController.java
@@ -2,13 +2,16 @@
 
 import java.lang.reflect.Array;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.common.constant.HttpStatus;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.PageUtils;
+import com.smartor.domain.PatArchiveOthreInfo;
 import com.smartor.domain.PatMedReq;
 import com.smartor.domain.PatMedRes;
 import io.netty.util.internal.ObjectUtil;
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
index 2fb4c59..4326803 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
@@ -29,9 +29,12 @@
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.text.DecimalFormat;
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -56,6 +59,9 @@
 
     @Autowired
     private IServiceSubtaskRecordService serviceSubtaskRecordService;
+
+    @Value("${spring.profiles.active}")
+    private String active;
 
     /**
      * 鏌ヨ鎮h�呴殢璁夸俊鎭�
@@ -209,6 +215,48 @@
     }
 
     /**
+     * 鏍规嵁鐤剧梾妯$硦鏌ヨ
+     */
+    //@PreAuthorize("@ss.hasPermi('system:taskcall:query')")
+    @PostMapping(value = "/getSubtaskByDiagname")
+    public Map<String, Object> getSubtaskByDiagname(@RequestBody ServiceSubtask serviceSubtask) {
+        LoginUser loginUser = getLoginUser();
+        SysUser user = loginUser.getUser();
+        serviceSubtask.setOrgid(user.getOrgid());
+        serviceSubtask.setPageNum(PageUtils.getOffset(serviceSubtask.getPageNum(), serviceSubtask.getPageSize()));
+        List<ServiceSubtask> serviceSubtaskList = serviceSubtaskService.selectServiceSubtaskByDiagname(serviceSubtask);
+        Map<String, Object> rspData = new HashMap();
+        rspData.put("code", HttpStatus.SUCCESS);
+        rspData.put("msg", "鏌ヨ鎴愬姛");
+        rspData.put("rows", serviceSubtaskList);
+
+        serviceSubtask.setPageNum(null);
+        serviceSubtask.setPageSize(null);
+        List<ServiceSubtask> total = serviceSubtaskService.selectServiceSubtaskByDiagname(serviceSubtask);
+        if (CollectionUtils.isNotEmpty(total)) rspData.put("total", total.size());
+        else rspData.put("total", 0);
+        return rspData;
+    }
+
+
+    /**
+     * 闅忚缁熻瀵煎嚭
+     */
+    //@PreAuthorize("@ss.hasPermi('system:taskcall:export')")
+    @Log(title = "闅忚缁熻瀵煎嚭锛�", businessType = BusinessType.EXPORT)
+    @PostMapping("/getSubtaskByDiagnameExport")
+    public void getSubtaskByDiagnameExport(HttpServletResponse response, List<ServiceSubtaskDiagname> serviceSubtaskDiagnameList) {
+        ExcelUtil<ServiceSubtaskDiagname> util = new ExcelUtil<ServiceSubtaskDiagname>(ServiceSubtaskDiagname.class);
+
+        if (active.equals("ls") || active.equals("druid")) {
+            util.exportExcel(response, serviceSubtaskDiagnameList, LocalDate.now().getMonthValue() + "闅忚缁熻瀵煎嚭");
+        } else {
+            util.exportExcel(response, serviceSubtaskDiagnameList, "闅忚缁熻瀵煎嚭");
+        }
+    }
+
+
+    /**
      * 鏂板鎴栦慨鏀瑰垹闄ゅ崟涓�浠诲姟
      */
     @ApiOperation("鏂板鎴栦慨鏀瑰垹闄ゅ崟涓�浠诲姟")
@@ -347,7 +395,7 @@
      */
     @ApiOperation("鑾峰彇闅忚婊℃剰搴︾粺璁�")
     @PostMapping("/getSfStatisticsJoy")
-    public AjaxResult getSfStatisticsJoy(@RequestBody ServiceSubtaskCountReq serviceSubtaskCountReq) {
+    public Map<String, Object> getSfStatisticsJoy(@RequestBody ServiceSubtaskCountReq serviceSubtaskCountReq) {
         if (CollectionUtils.isEmpty(serviceSubtaskCountReq.getServiceType())) {
             return error("鏈嶅姟绫诲瀷涓嶈兘涓虹┖");
         }
@@ -361,9 +409,15 @@
     @Log(title = "闅忚缁熻瀵煎嚭锛�", businessType = BusinessType.EXPORT)
     @PostMapping("/getSfStatisticsExport")
     public void export(HttpServletResponse response, ServiceSubtaskCountReq serviceSubtaskCountReq) {
-        List<ServiceSubtaskStatistic> sfStatistics = serviceSubtaskService.getSfStatistics(serviceSubtaskCountReq);
+        List<ServiceSubtaskStatistic> sfStatistics = serviceSubtaskService.getSfStatisticsExport(serviceSubtaskCountReq);
+
         ExcelUtil<ServiceSubtaskStatistic> util = new ExcelUtil<ServiceSubtaskStatistic>(ServiceSubtaskStatistic.class);
-        util.exportExcel(response, sfStatistics, "闅忚缁熻瀵煎嚭");
+
+        if (active.equals("ls") || active.equals("druid")) {
+            util.exportExcel(response, sfStatistics, LocalDate.now().getMonthValue() + "鏈堝嚭闄㈤殢璁跨粺璁¤〃");
+        } else {
+            util.exportExcel(response, sfStatistics, "闅忚缁熻瀵煎嚭");
+        }
     }
 
     /**
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTaskController.java
index 7f2c848..a66e113 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTaskController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTaskController.java
@@ -24,6 +24,7 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
index 4aebae5..397e99c 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -16,6 +16,7 @@
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.ISysMenuService;
 import com.smartor.mapper.SysUserDeptMapper;
+import com.smartor.service.IServiceSLTDHealthcareRecordService;
 import com.smartor.service.impl.ServiceSLTDHealthcareRecordServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,6 +54,8 @@
 
     @Autowired
     private ISysConfigService sysConfigService;
+    @Autowired
+    private IServiceSLTDHealthcareRecordService iServiceSLTDHealthcareRecordService;
 
 
     @Value("${pri_key}")
@@ -87,6 +90,18 @@
         return ajax;
     }
 
+
+    /**
+     * 鐧诲綍鏂规硶
+     *
+     * @param loginBody 鐧诲綍淇℃伅
+     * @return 缁撴灉
+     */
+    @PostMapping("/test")
+    public void test(@RequestBody Map<String, Object> map) {
+        iServiceSLTDHealthcareRecordService.aa(map);
+    }
+
     /**
      * 鍗曠偣鐧诲綍鏂规硶(闇�瑕侀厤缃甀P鐧藉悕鍗�)
      * 闇�瑕佸湪sys_config琛ㄧ殑sys.ip.whitelis涓紝鍔犲叆IP鎵嶈兘璁块棶璇ユ柟娉�
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
index 4a7f264..3ec9a80 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -21,6 +21,7 @@
 import com.ruoyi.system.service.ISysUserService;
 import com.smartor.mapper.SysUserDeptMapper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,8 +84,8 @@
         user.setPageNum(null);
         user.setPageSize(null);
         List<SysUser> total = userService.getUserList(user);
-        rspData.put("total", total.size());
-
+        if (CollectionUtils.isNotEmpty(total)) rspData.put("total", total.size());
+        else rspData.put("total", 0);
         return rspData;
     }
 
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java b/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
index 4330ec2..c0e379d 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
@@ -65,10 +65,13 @@
     @Test
     public void cc() {
         RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
-        String s = rsaPublicKeyExample.encryptedData("20250815001094", "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALQzqW1EIXBKGMu+2oEYSB5gM7Ox/ihyYTeeoE0yPX1qtt4++5yNOeTBVd6EEM4iKzVEzWj6REIWVwaSNPn/SvUCAwEAAQ==");
+        String s = rsaPublicKeyExample.encryptedData("865", "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALQzqW1EIXBKGMu+2oEYSB5gM7Ox/ihyYTeeoE0yPX1qtt4++5yNOeTBVd6EEM4iKzVEzWj6REIWVwaSNPn/SvUCAwEAAQ==");
         System.out.println("鍔犲瘑缁撴灉涓猴細" + s);
         String s1 = rsaPublicKeyExample.decryptedData(s, "MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAtDOpbUQhcEoYy77agRhIHmAzs7H+KHJhN56gTTI9fWq23j77nI055MFV3oQQziIrNUTNaPpEQhZXBpI0+f9K9QIDAQABAkB3n0fcWfrcoMN/FU3VnrnZOEF6CzFNxkgU9P8y36QECWKZ9JhYQkNpKrMC9oXlN3VSaRigV7B+L/I/a0Rs1W+tAiEA4jx7xcXJ4y4BNwAmVHt6NNiEkzIwWnwC/0qsEu8NsOsCIQDL6MMn1D2uznC6OuOWpxDCkBh1JL1NzZTZeH2G+hj7nwIgKGAC9tjFnvWm4dn0/T7MIIJDpsFeP8fCAS2iZ/6hwuECIAS/eLvWr1EAsZNEh8QcQ8GkBU3E+ztyjAK8UX/xFt/VAiBf79/1tDErX4/DChecM8w3c3DhbBcjuE3fHZn7p6/UKg==");
         System.out.println("瑙e瘑缁撴灉涓猴細"+s1);
+
+        String format = String.format("%03X", 202);
+        System.out.println("format缁撴灉涓猴細"+format);
     }
 
     public void aa(MultipartFile file) throws IOException {
diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml
index 9f56348..1c9eda3 100644
--- a/ruoyi-admin/src/main/resources/application-druid.yml
+++ b/ruoyi-admin/src/main/resources/application-druid.yml
@@ -34,7 +34,7 @@
         #        password: Hxerp2000
         #        driverClassName: com.mysql.cj.jdbc.Driver
         #  鍏徃鏈湴
-        url: jdbc:mysql://haiershi.a1.luyouxia.net:23844/smartor_xinhua?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://haiershi.a1.luyouxia.net:23844/smartor_lishui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: smartor
         password: Smartor.2023
         driverClassName: com.mysql.cj.jdbc.Driver
@@ -103,9 +103,9 @@
         login-password: Lihu@1363419#$
       filter:
         stat:
-          enabled: true
+          enabled: false
           # 鎱QL璁板綍
-          log-slow-sql: true
+          log-slow-sql: false
           slow-sql-millis: 1000
           merge-sql: true
         wall:
@@ -138,7 +138,7 @@
     prefix: /api
     readonly: false
   sql-column-case: camel
-  show-sql: true #閰嶇疆鎵撳嵃SQL
+  show-sql: false #閰嶇疆鎵撳嵃SQL
   page-config:
     size: size
     page: page
diff --git a/ruoyi-admin/src/main/resources/application-ls.yml b/ruoyi-admin/src/main/resources/application-ls.yml
index 4353cb7..95cabf1 100644
--- a/ruoyi-admin/src/main/resources/application-ls.yml
+++ b/ruoyi-admin/src/main/resources/application-ls.yml
@@ -15,6 +15,10 @@
         username: root@sfxx#other_cluster
         password: Y5oapyS8
         driverClassName: com.mysql.cj.jdbc.Driver
+      #        url: jdbc:mysql://cluster02.db.lsjky.cn:2883/smartor-lisui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+      #        username: root@sfxx#other_cluster02
+      #        password: Y5oapyS8
+      #        driverClassName: com.mysql.cj.jdbc.Driver
 
       #        # 楂樻柉鏁版嵁搴撻厤缃�
       #        url: jdbc:postgresql://127.0.0.1:5432/smartorlishui
@@ -70,9 +74,9 @@
         login-password: Lihu@1363419#$
       filter:
         stat:
-          enabled: true
+          enabled: false
           # 鎱QL璁板綍
-          log-slow-sql: true
+          log-slow-sql: false
           slow-sql-millis: 1000
           merge-sql: true
         wall:
diff --git a/ruoyi-admin/src/main/resources/application-sltd.yml b/ruoyi-admin/src/main/resources/application-sltd.yml
index c97807b..d14aafb 100644
--- a/ruoyi-admin/src/main/resources/application-sltd.yml
+++ b/ruoyi-admin/src/main/resources/application-sltd.yml
@@ -66,9 +66,9 @@
         login-password: Lihu@1363419#$
       filter:
         stat:
-          enabled: true
+          enabled: false
           # 鎱QL璁板綍
-          log-slow-sql: true
+          log-slow-sql: false
           slow-sql-millis: 1000
           merge-sql: true
         wall:
diff --git a/ruoyi-admin/src/main/resources/application-xh.yml b/ruoyi-admin/src/main/resources/application-xh.yml
index a3afd8a..fbeb09e 100644
--- a/ruoyi-admin/src/main/resources/application-xh.yml
+++ b/ruoyi-admin/src/main/resources/application-xh.yml
@@ -112,10 +112,10 @@
     default-size: 10
 
 # PageHelper鍒嗛〉鎻掍欢
-pagehelper:
-  helperDialect: mysql
-  supportMethodsArguments: true
-  params: count=countSql
+##pagehelper:
+#  helperDialect: mysql
+#  supportMethodsArguments: true
+#  params: count=countSql
 
 #閽夐拤鐨勫瘑閽�
 dingAppid: dingn8iip5ubj7clrrsv
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index e418f3f..0f69eba 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -74,7 +74,8 @@
     # 鍥介檯鍖栬祫婧愭枃浠惰矾寰�
     basename: i18n/messages
   profiles:
-    active: sltd
+    active: ls
+
   # 鏂囦欢涓婁紶
   servlet:
     multipart:
diff --git a/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml b/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml
index 65f42ed..f97eebc 100644
--- a/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml
+++ b/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml
@@ -11,7 +11,7 @@
         <setting name="useGeneratedKeys" value="true"/>
         <!-- 閰嶇疆榛樿鐨勬墽琛屽櫒.SIMPLE灏辨槸鏅�氭墽琛屽櫒;REUSE鎵ц鍣ㄤ細閲嶇敤棰勫鐞嗚鍙�(prepared statements);BATCH鎵ц鍣ㄥ皢閲嶇敤璇彞骞舵墽琛屾壒閲忔洿鏂� -->
         <setting name="defaultExecutorType" value="SIMPLE"/>
-        <!-- 鎸囧畾 MyBatis 鎵�鐢ㄦ棩蹇楃殑鍏蜂綋瀹炵幇 -->
+        <!-- 鎸囧畾 MyBatis 鎵�鐢ㄦ棩蹇楃殑鍏蜂綋瀹炵幇(鏄惁鎵撳嵃SQL) -->
 <!--        <setting name="logImpl" value="STDOUT_LOGGING"/>-->
         <!-- 浣跨敤椹煎嘲鍛藉悕娉曡浆鎹㈠瓧娈� -->
         <!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/MsgLSEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/MsgLSEnum.java
index 602d6d5..66aca93 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/MsgLSEnum.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/MsgLSEnum.java
@@ -13,10 +13,10 @@
  * XiaoXiLX    FZ_PT_DuanXinFS
  * XiaoXiMC    鐭俊鍙戦��
  */
-public enum MsgLSEnum {
-    ZYY("47231022633110211A2101", "https://9.0.124.104:13011/mediinfo-grus-fuwuzxwg/api/esb/lyraAsyncRun", "1400360867068907520", "涓芥按甯備腑鍖婚櫌", "2361", "閮戠弽鎱�"),
-    JN("47255004333112711A1001", null, "1400361376454545408", "鏅畞鐣叉棌鑷不鍘夸汉姘戝尰闄�", "", "");
-
+public class MsgLSEnum {
+    //    ZYY("47231022633110211A2101", "https://9.0.124.104:13011/mediinfo-grus-fuwuzxwg/api/esb/lyraAsyncRun", "1400360867068907520", "涓芥按甯備腑鍖婚櫌", "2361", "閮戠弽鎱�"),
+//    JN("47255004333112711A1001", "", "1400361376454545408", "鏅畞鐣叉棌鑷不鍘夸汉姘戝尰闄�", "0073", "鍛ㄧ編濯�");
+//
     private String orgid;
     private String address;
     private String ZuHuID;
@@ -33,46 +33,27 @@
         this.sendPersonName = sendPersonName;
     }
 
-    public static Map<String, Object> getHeaderByCode(String orgid) {
+    public static Map<String, Object> getHeaderByCode(Map<String, String> srmInfo) {
         Map<String, Object> map = new LinkedHashMap<>();
-        MsgLSEnum[] organEnums = values();
-        for (int i = 0; i < organEnums.length; i++) {
-            MsgLSEnum organEnum = organEnums[i];
-            //鑾峰彇鏃堕棿
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            String formattedDate = sdf.format(new Date());
-            if (organEnum.getOrgid().equals(orgid)) {
-                map.put("XiaoXiID", IdUtils.simpleUUID());
-                map.put("FaSongSJ", formattedDate);
-                map.put("ZuHuID", organEnum.getZuHuID());
-                map.put("ZuHuMC", organEnum.getZuHuMC());
-                map.put("FaSongJGID", organEnum.getOrgid());
-                map.put("FaSongJGMC", organEnum.getZuHuMC());
-                //map.put("FaSongXTJC", "闅忚绯荤粺");
-                map.put("FaSongXTJC", "SUIFANGXT");
-                map.put("FaSongXTMC", "闅忚绯荤粺");
-                //map.put("FaSongFCSJC", "浜ュ皵鏃�");
-                map.put("FaSongFCSJC", "ZJHES");
-                map.put("XiaoXiLX", "FZ_PT_DuanXinFS");
-                map.put("XiaoXiMC", "鐭俊鍙戦��");
-            }
-        }
-        return map;
-    }
 
-    public static Map<String, String> getAddressByCode(String orgid) {
-        MsgLSEnum[] organEnums = values();
-        Map<String, String> map = new HashMap<>();
-        for (int i = 0; i < organEnums.length; i++) {
-            MsgLSEnum organEnum = organEnums[i];
-            if (organEnum.getOrgid().equals(orgid)) {
-                map.put("address", organEnum.getAddress());
-                map.put("sendPersonId", organEnum.getSendPersonId());
-                map.put("sendPersonName", organEnum.getSendPersonName());
-                return map;
-            }
-        }
-        return null;
+        //鑾峰彇鏃堕棿
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String formattedDate = sdf.format(new Date());
+        map.put("XiaoXiID", IdUtils.simpleUUID());
+        map.put("FaSongSJ", formattedDate);
+        map.put("ZuHuID", srmInfo.get("ZuHuID"));
+        map.put("ZuHuMC", srmInfo.get("ZuHuMC"));
+        map.put("FaSongJGID", srmInfo.get("orgid"));
+        map.put("FaSongJGMC", srmInfo.get("ZuHuMC"));
+        //map.put("FaSongXTJC", "闅忚绯荤粺");
+        map.put("FaSongXTJC", "SUIFANGXT");
+        map.put("FaSongXTMC", "闅忚绯荤粺");
+        //map.put("FaSongFCSJC", "浜ュ皵鏃�");
+        map.put("FaSongFCSJC", "ZJHES");
+        map.put("XiaoXiLX", "FZ_PT_DuanXinFS");
+        map.put("XiaoXiMC", "鐭俊鍙戦��");
+
+        return map;
     }
 
     public String getOrgid() {
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
index 0140c8e..ab33599 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
@@ -43,9 +43,8 @@
      * 璁$畻鍋忕Щ閲�
      */
     public static Integer getOffset(Integer pageNum, Integer pageSize) {
-        if (pageNum == null) pageNum = 1;
+        if (pageNum == null || pageNum == 0) pageNum = 1;
         if (pageSize == null) pageSize = 10;
         return (pageNum - 1) * pageSize;
-
     }
 }
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
index 3f4f485..032ee22 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
@@ -4,24 +4,28 @@
 import org.springframework.cache.annotation.EnableCaching;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.script.DefaultRedisScript;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * redis閰嶇疆
- * 
+ *
  * @author ruoyi
  */
 @Configuration
 @EnableCaching
-public class RedisConfig extends CachingConfigurerSupport
-{
+public class RedisConfig extends CachingConfigurerSupport {
     @Bean
-    @SuppressWarnings(value = { "unchecked", "rawtypes" })
-    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
-    {
+    @SuppressWarnings(value = {"unchecked", "rawtypes"})
+    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
         RedisTemplate<Object, Object> template = new RedisTemplate<>();
         template.setConnectionFactory(connectionFactory);
 
@@ -40,8 +44,19 @@
     }
 
     @Bean
-    public DefaultRedisScript<Long> limitScript()
-    {
+    public RedisCacheManager cacheManager(RedisConnectionFactory connectionFactory) {
+        // 榛樿缂撳瓨閰嶇疆锛堝叾浠� cache 浣跨敤锛�
+        RedisCacheConfiguration defaultConfig = RedisCacheConfiguration.defaultCacheConfig();
+        // 鍗曠嫭涓� sfStatistics 璁剧疆 20 鍒嗛挓 TTL
+        Map<String, RedisCacheConfiguration> configMap = new HashMap<>();
+        configMap.put("sfStatistics", defaultConfig.entryTtl(Duration.ofMinutes(20)));
+        configMap.put("sfStatisticsJoy", defaultConfig.entryTtl(Duration.ofMinutes(20)));
+        configMap.put("selectPatMedOuthospList", defaultConfig.entryTtl(Duration.ofMinutes(20)));
+        return RedisCacheManager.builder(connectionFactory).cacheDefaults(defaultConfig).withInitialCacheConfigurations(configMap).build();
+    }
+
+    @Bean
+    public DefaultRedisScript<Long> limitScript() {
         DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();
         redisScript.setScriptText(limitScriptText());
         redisScript.setResultType(Long.class);
@@ -51,19 +66,7 @@
     /**
      * 闄愭祦鑴氭湰
      */
-    private String limitScriptText()
-    {
-        return "local key = KEYS[1]\n" +
-                "local count = tonumber(ARGV[1])\n" +
-                "local time = tonumber(ARGV[2])\n" +
-                "local current = redis.call('get', key);\n" +
-                "if current and tonumber(current) > count then\n" +
-                "    return tonumber(current);\n" +
-                "end\n" +
-                "current = redis.call('incr', key)\n" +
-                "if tonumber(current) == 1 then\n" +
-                "    redis.call('expire', key, time)\n" +
-                "end\n" +
-                "return tonumber(current);";
+    private String limitScriptText() {
+        return "local key = KEYS[1]\n" + "local count = tonumber(ARGV[1])\n" + "local time = tonumber(ARGV[2])\n" + "local current = redis.call('get', key);\n" + "if current and tonumber(current) > count then\n" + "    return tonumber(current);\n" + "end\n" + "current = redis.call('incr', key)\n" + "if tonumber(current) == 1 then\n" + "    redis.call('expire', key, time)\n" + "end\n" + "return tonumber(current);";
     }
 }
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
index 51eafa9..13a880b 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -108,7 +108,7 @@
                 // 杩囨护璇锋眰
                 .authorizeRequests()
                 // 瀵逛簬鐧诲綍login 娉ㄥ唽register 楠岃瘉鐮乧aptchaImage 鍏佽鍖垮悕璁块棶
-                .antMatchers("/login", "/register", "/captchaImage", "/qrcode/generateStaticHtml", "/qrcode/getQRcode", "/qrcode/getFormDate", "/chat", "/system/file/admin/uploadFile", "/smartor/dingtalk/sendNotification", "/patient/read/patientInfo", "/socket", "/API_ESB_Service", "/API_ESB_Service/Run", "/magic/web/**", "/smartor/serviceSubtask/phoneCallBack", "/smartor/serviceSubtask/taskPull", "/smartor/serviceSubtask/phoneCallBackYQ", "/smartor/robot/callstatus", "/smartor/robot/aidialog", "/smartor/robot/cdrinfo", "/getToken", "/smartor/subtaskAnswer/getQuestionCache", "/smartor/subtaskAnswer/saveQuestionCache", "/smartor/servicetask/getScriptInfoByCondition", "/smartor/subtaskAnswer/saveQuestionAnswer", "/smartor/import/download", "/smartor/serviceSubtask/recordAccept", "/smartor/outPath/getInfoByParam", "/smartor/serviceExternal/addDeptInfo", "/smartor/serviceExternal/**", "/sso/**","/smartor/sltdHealthcareRecord/**","/smartor/servicetask/getScriptByCondition","/smartor/subtaskAnswer/saveMYDQuestionAnswer").permitAll()
+                .antMatchers("/login","/test", "/register", "/captchaImage", "/qrcode/generateStaticHtml", "/qrcode/getQRcode", "/qrcode/getFormDate", "/chat", "/system/file/admin/uploadFile", "/smartor/dingtalk/sendNotification", "/patient/read/patientInfo", "/socket", "/API_ESB_Service", "/API_ESB_Service/Run", "/magic/web/**", "/smartor/serviceSubtask/phoneCallBack", "/smartor/serviceSubtask/taskPull", "/smartor/serviceSubtask/phoneCallBackYQ", "/smartor/robot/callstatus", "/smartor/robot/aidialog", "/smartor/robot/cdrinfo", "/getToken", "/smartor/subtaskAnswer/getQuestionCache", "/smartor/subtaskAnswer/saveQuestionCache", "/smartor/servicetask/getScriptInfoByCondition", "/smartor/subtaskAnswer/saveQuestionAnswer", "/smartor/import/download", "/smartor/serviceSubtask/recordAccept", "/smartor/outPath/getInfoByParam", "/smartor/serviceExternal/addDeptInfo", "/smartor/serviceExternal/**", "/sso/**","/smartor/sltdHealthcareRecord/**","/smartor/servicetask/getScriptByCondition","/smartor/subtaskAnswer/saveMYDQuestionAnswer").permitAll()
                 // 闈欐�佽祫婧愶紝鍙尶鍚嶈闂�
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**","/getDept/*","/SSOLogin/**").permitAll().antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                 .antMatchers("/smartor/organization/list").permitAll()
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 7b40fc6..451eb72 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
@@ -1,6 +1,8 @@
 package com.ruoyi.quartz.task;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
@@ -35,7 +37,6 @@
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.security.MessageDigest;
-import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
@@ -204,14 +205,12 @@
     }
 
     public void analysisData() {
-        System.out.println("---------------------------");
         //鏁版嵁瑙f瀽
         ServiceThirdData serviceThirdData = new ServiceThirdData();
         serviceThirdData.setDataType("ADT^A03");
         serviceThirdData.setIsDeal(0);
         serviceThirdData.setCreateTime(new Date());
         iServiceThirdDataService.queryList(serviceThirdData);
-
     }
 
     /**
@@ -311,46 +310,68 @@
 
                 // 鐪佺珛鍚屽痉鏁版嵁閲囬泦
                 for (Long cid : campusidList) {
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滃叆闄⑩�濆紑濮嬮噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滈鍏ラ櫌鈥濆紑濮嬮噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
+                    String yesterday = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                     String nowTime = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                     ServiceSLTDInhospReqVO serviceSLTDInhospReqVO = new ServiceSLTDInhospReqVO();
                     serviceSLTDInhospReqVO.setOrgId("20001001");
                     serviceSLTDInhospReqVO.setCampusId(cid);
+                    serviceSLTDInhospReqVO.setEncounterTimeStart(nowTime);
+                    serviceSLTDInhospReqVO.setEncounterTimeEnd(nowTime);
+                    List<String> list = new ArrayList<>();
+//                    list.add("FH0108.02");
+                    list.add("FH0109.22");
+                    list.add("FH0109.23");
+                    list.add("FH0109.53");
+                    serviceSLTDInhospReqVO.setStatusList(list);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滈鍏ラ櫌鈥濋噰闆嗘暟鎹叆鍙傦細{}", serviceSLTDInhospReqVO);
+                    serviceSLTDHealthcareRecordService.queryHealthcareRecordList(serviceSLTDInhospReqVO);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滈鍏ラ櫌鈥濈祼鏉熼噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
+
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滃叆闄⑩�濆紑濮嬮噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
+                    serviceSLTDInhospReqVO.setOrgId("20001001");
+                    serviceSLTDInhospReqVO.setCampusId(cid);
+                    serviceSLTDInhospReqVO.setEncounterTimeStart(null);
+                    serviceSLTDInhospReqVO.setEncounterTimeEnd(null);
                     serviceSLTDInhospReqVO.setStartHeadTime(nowTime);
                     serviceSLTDInhospReqVO.setStartTailTime(nowTime);
-                    List<String> list = new ArrayList<>();
-                    list.add("FH0108.02");
-                    serviceSLTDInhospReqVO.setHealthcareRecordTypeList(list);
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滃叆闄⑩�濋噰闆嗘暟鎹叆鍙傦細{}", serviceSLTDInhospReqVO);
+                    List<String> listStr = new ArrayList<>();
+//                    list.add("FH0108.02");
+                    listStr.add("FH0109.26");
+                    serviceSLTDInhospReqVO.setStatusList(listStr);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滃叆闄⑩�濋噰闆嗘暟鎹叆鍙傦細{}", serviceSLTDInhospReqVO);
                     serviceSLTDHealthcareRecordService.queryHealthcareRecordList(serviceSLTDInhospReqVO);
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滃叆闄⑩�濈祼鏉熼噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滃叆闄⑩�濈祼鏉熼噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
 
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滈棬鎬ヨ瘖鈥濆紑濮嬮噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滈棬鎬ヨ瘖鈥濆紑濮嬮噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
                     serviceSLTDInhospReqVO.setStartHeadTime(null);
                     serviceSLTDInhospReqVO.setStartTailTime(null);
                     serviceSLTDInhospReqVO.setEncounterTimeStart(nowTime);
                     serviceSLTDInhospReqVO.setEncounterTimeEnd(nowTime);
+                    serviceSLTDInhospReqVO.setStatusList(null);
                     List<String> list1 = new ArrayList<>();
                     list1.add("FH0108.01");
                     list1.add("FH0108.03");
                     serviceSLTDInhospReqVO.setHealthcareRecordTypeList(list1);
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滈棬鎬ヨ瘖鈥濋噰闆嗘暟鎹叆鍙傦細{}", serviceSLTDInhospReqVO);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滈棬鎬ヨ瘖鈥濋噰闆嗘暟鎹叆鍙傦細{}", serviceSLTDInhospReqVO);
                     serviceSLTDHealthcareRecordService.queryHealthcareRecordList(serviceSLTDInhospReqVO);
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滈棬鎬ヨ瘖鈥濇潫閲囬泦鏁版嵁锛岄櫌鍖猴細{}", cid);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滈棬鎬ヨ瘖鈥濇潫閲囬泦鏁版嵁锛岄櫌鍖猴細{}", cid);
 
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滃嚭闄⑩�濆紑濮嬮噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滃嚭闄⑩�濆紑濮嬮噰闆嗘暟鎹紝闄㈠尯锛歿}", cid);
                     serviceSLTDInhospReqVO.setStartHeadTime(null);
                     serviceSLTDInhospReqVO.setStartTailTime(null);
                     serviceSLTDInhospReqVO.setEncounterTimeStart(null);
                     serviceSLTDInhospReqVO.setEncounterTimeEnd(null);
                     serviceSLTDInhospReqVO.setPreOutHospitalHeadDate(nowTime);
                     serviceSLTDInhospReqVO.setPreOutHospitalTailDate(nowTime);
+                    serviceSLTDInhospReqVO.setHealthcareRecordTypeList(null);
                     List<String> list2 = new ArrayList<>();
-                    list2.add("FH0108.02");
-                    serviceSLTDInhospReqVO.setHealthcareRecordTypeList(list2);
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滃嚭闄⑩�濋噰闆嗘暟鎹叆鍙傦細{}", serviceSLTDInhospReqVO);
+//                    list2.add("FH0108.02");
+                    list2.add("FH0109.27");
+                    serviceSLTDInhospReqVO.setStatusList(list2);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滃嚭闄⑩�濋噰闆嗘暟鎹叆鍙傦細{}", serviceSLTDInhospReqVO);
                     serviceSLTDHealthcareRecordService.queryHealthcareRecordList(serviceSLTDInhospReqVO);
-                    log.info("銆恉ealHisData銆戠渷绔嬪悓寰封�滃嚭闄⑩�濇潫閲囬泦鏁版嵁锛岄櫌鍖猴細{}", cid);
+                    log.debug("銆恉ealHisData銆戠渷绔嬪悓寰封�滃嚭闄⑩�濇潫閲囬泦鏁版嵁锛岄櫌鍖猴細{}", cid);
                 }
 //                SysConfig sysConfig = sysConfigs.get(0);
 //                sysConfig.setConfigValue(nowTime);
@@ -386,11 +407,12 @@
      * 澶勭悊鎮h�呬俊鎭紝杩涘叆瀛愪换鍔¤〃
      */
     public void dealOutHospInfo() {
+        String config = configService.selectConfigByKey("visit.early.day");
         if (port.equals("8095")) {
             //鍑洪櫌琛�
-            iPatMedInhospService.dealOutHospInfo();
-            //闂ㄨ瘖琛�
-            if (active.equals("xh")) {
+            iPatMedInhospService.dealOutHospInfo(config);
+            //闂ㄨ瘖琛�(鏂板崕鐨勬殏鏃朵笉鍋氶棬璇婇殢璁�)
+            if (!active.equals("xh")) {
                 iPatMedOuthospService.dealOutpatientInfo();
             }
         }
@@ -418,7 +440,7 @@
 
 
     /**
-     * 闀挎湡浠诲姟鎵ц
+     *
      */
     public void longTaskSend() {
         //鑾峰彇浠诲姟淇℃伅
@@ -656,16 +678,29 @@
                         req.put("content", sendMagParam.getContent());
                         isSuccess = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req));
                     } else if (active.equals("ls")) {
-                        String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid());
-                        //涓芥按鐨勭煭淇″彂閫佹柟寮�
-                        Map<String, String> map = MsgLSEnum.getAddressByCode(serviceSubtask.getOrgid());
-                        String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), url);
-                        if (ObjectUtils.isNotEmpty(map) && StringUtils.isEmpty(map.get("address"))) {
+//                        String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid());
+//                        //涓芥按鐨勭煭淇″彂閫佹柟寮�
+//                        Map<String, String> map = MsgLSEnum.getAddressByCode(serviceSubtask.getOrgid());
+                        SysConfig config = new SysConfig();
+                        config.setConfigKey("ls.msg.info");
+                        config.setOrgid(serviceSubtask.getOrgid());
+                        List<SysConfig> sysConfigs = configService.selectConfigList(config);
+                        Map<String, String> msgInfo = new HashMap<>();
+                        if (CollectionUtils.isNotEmpty(sysConfigs)) {
+                            String configValue = sysConfigs.get(0).getConfigValue();
+                            ObjectMapper objectMapper = new ObjectMapper();
+                            if (StringUtils.isNotEmpty(configValue)) {
+                                msgInfo = objectMapper.readValue(configValue, Map.class);
+                            }
+                        }
+                        log.info("-----------map鐨勫�间负锛歿}", msgInfo);
+                        String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), msgInfo.get("tokenUrl"));
+                        if (ObjectUtils.isNotEmpty(msgInfo) && StringUtils.isEmpty(msgInfo.get("address"))) {
                             setSuccessPreachForm(serviceSubtask, sendPreachform, "鐭俊鍙戦�佸け璐�,璇ユ満鏋勬病鏈夐厤缃煭淇″湴鍧�", "5");
                             return;
                         }
-                        log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫侊紝鍦板潃锛歿}锛屽弬鏁帮細{}锛屾満鏋処D锛歿}", map.get("address"), sendMagParam, serviceSubtask.getOrgid());
-                        String dxCode = getDXCode(map.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), map.get("sendPersonId"), map.get("sendPersonName"), MsgLSEnum.getHeaderByCode(serviceSubtask.getOrgid()), token);
+                        log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫侊紝鍦板潃锛歿}锛屽弬鏁帮細{}锛屾満鏋処D锛歿}", msgInfo.get("address"), sendMagParam, serviceSubtask.getOrgid());
+                        String dxCode = getDXCode(msgInfo.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), msgInfo.get("sendPersonId"), msgInfo.get("sendPersonName"), MsgLSEnum.getHeaderByCode(msgInfo), token);
                         log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫佺粨鏋滐細{}", dxCode);
                         ObjectMapper objectMapper = new ObjectMapper();
                         Map<String, Object> textParam = objectMapper.readValue(dxCode, Map.class);
@@ -676,7 +711,7 @@
                     } else if (active.equals("sltd")) {
                         log.info("sltd杩涙潵浜嗗悧锛焮}   ,---sendMagParam.getContent()鐨勫弬鏁颁负锛歿}", active, sendMagParam.getContent());
                         //鐪佺珛鍚屽痉鐨勭煭淇″彂閫佹柟寮�
-                        String data = MessageSend.sendMsg(sendMagParam.getContent(), "2", sendMagParam.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
+                        String data = MessageSend.sendMsg(sendMagParam.getContent(), "6", sendMagParam.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
                         if (StringUtils.isNotEmpty(data) && data.contains("result=0")) {
                             isSuccess = "true";
                         }
@@ -804,6 +839,16 @@
     private String getSendPreachform(ServiceSubtaskPreachform serviceSubtaskPreachform, ServiceSubtask serviceSubtask) {
         List<ServiceSubtaskPreachform> serviceSubtaskPreachforms = serviceSubtaskPreachformMapper.selectServiceSubtaskPreachformList(serviceSubtaskPreachform);
 
+        if (CollectionUtils.isEmpty(serviceSubtaskPreachforms)) {
+            //濡傛灉serviceSubtaskPreachforms涓虹┖鐨勮瘽锛屽垯闇�瑕佽繘琛屾柊澧炰竴涓�
+            List<ServiceSubtaskPreachform> serviceSubtaskPreachformList = addServiceSubtaskPreachform(serviceSubtask, "1");
+            if (CollectionUtils.isEmpty(serviceSubtaskPreachformList)) {
+                log.error("ryTask--鍙戦�佹柟寮忓け璐ヤ簡serviceSubtask鐨勫叆鍙備负锛歿}", serviceSubtask);
+                return null;
+            }
+            serviceSubtaskPreachforms = serviceSubtaskPreachformList;
+        }
+
         // 鎯呭喌1锛歝urrentPreachform涓虹┖锛屽彇sort涓�1鐨刾reachform
         if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) {
             return serviceSubtaskPreachforms.stream().filter(item -> item.getSort() == 1L).map(ServiceSubtaskPreachform::getPreachform).findFirst().orElse(null);
@@ -850,6 +895,35 @@
         return null;
     }
 
+    private List<ServiceSubtaskPreachform> addServiceSubtaskPreachform(ServiceSubtask serviceSubtask, String sendstate) {
+        //灏唒reachformDesc鐨刯son瀵硅薄锛屾斁鍒發ist闆嗗悎涓�
+        ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+        String preachformDesc = serviceTask.getPreachformDesc();
+
+        List<ServiceSubtaskPreachform> sspl = null;
+        ObjectMapper objectMapper = new ObjectMapper();
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(preachformDesc)) {
+            try {
+                sspl = objectMapper.readValue(preachformDesc, new TypeReference<List<ServiceSubtaskPreachform>>() {
+                });
+            } catch (JsonProcessingException e) {
+                log.error("ryTask--preachform杞琇ist<ServiceSubtaskPreachform>鎶ラ敊浜嗭細{}", e.getMessage());
+            }
+            for (ServiceSubtaskPreachform serviceSubtaskPreachform : sspl) {
+                serviceSubtaskPreachform.setTaskid(serviceSubtask.getTaskid());
+                serviceSubtaskPreachform.setSubid(serviceSubtask.getId());
+                //杩欎釜sendstate闇�瑕佸湪鏁版嵁搴撹缃竴涓粯璁ゅ�间负鈥�1鈥�
+                serviceSubtaskPreachform.setSendstate("1");
+                if (StringUtils.isNotEmpty(sendstate)) serviceSubtaskPreachform.setSendstate(sendstate);
+                serviceSubtaskPreachform.setOrgid(serviceSubtask.getOrgid());
+                serviceSubtaskPreachformMapper.insertServiceSubtaskPreachform(serviceSubtaskPreachform);
+            }
+
+        }
+
+        return sspl;
+    }
+
     private Integer setFail(List<ServiceSubtaskPreachform> serviceSubtaskPreachforms, ServiceSubtask serviceSubtask) {
         Optional<Long> id = serviceSubtaskPreachforms.stream().filter(item -> serviceSubtask.getCurrentPreachform().equals(item.getPreachform())).map(ServiceSubtaskPreachform::getId).findFirst();
         if (id.isPresent()) {
diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
index e608e42..6353674 100644
--- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
+++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
@@ -4,7 +4,7 @@
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.quartz.mapper.SysJobLogMapper">
 
-	<resultMap type="SysJobLog" id="SysJobLogResult">
+	<resultMap type="com.ruoyi.quartz.domain.SysJobLog" id="SysJobLogResult">
 		<id     property="jobLogId"       column="job_log_id"      />
 		<result property="jobName"        column="job_name"        />
 		<result property="jobGroup"       column="job_group"       />
@@ -14,13 +14,13 @@
 		<result property="exceptionInfo"  column="exception_info"  />
 		<result property="createTime"     column="create_time"     />
 	</resultMap>
-	
+
 	<sql id="selectJobLogVo">
-        select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time 
+        select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
 		from sys_job_log
     </sql>
-	
-	<select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult">
+
+	<select id="selectJobLogList" parameterType="com.ruoyi.quartz.domain.SysJobLog" resultMap="SysJobLogResult">
 		<include refid="selectJobLogVo"/>
 		<where>
 			<if test="jobName != null and jobName != ''">
@@ -43,32 +43,32 @@
 			</if>
 		</where>
 	</select>
-	
+
 	<select id="selectJobLogAll" resultMap="SysJobLogResult">
 		<include refid="selectJobLogVo"/>
 	</select>
-	
+
 	<select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult">
 		<include refid="selectJobLogVo"/>
 		where job_log_id = #{jobLogId}
 	</select>
-	
+
 	<delete id="deleteJobLogById" parameterType="Long">
  		delete from sys_job_log where job_log_id = #{jobLogId}
  	</delete>
- 	
+
  	<delete id="deleteJobLogByIds" parameterType="Long">
  		delete from sys_job_log where job_log_id in
  		<foreach collection="array" item="jobLogId" open="(" separator="," close=")">
  			#{jobLogId}
-        </foreach> 
+        </foreach>
  	</delete>
- 	
+
  	<update id="cleanJobLog">
         truncate table sys_job_log
     </update>
- 	
- 	<insert id="insertJobLog" parameterType="SysJobLog">
+
+ 	<insert id="insertJobLog" parameterType="com.ruoyi.quartz.domain.SysJobLog">
  		insert into sys_job_log(
  			<if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
  			<if test="jobName != null and jobName != ''">job_name,</if>
@@ -90,4 +90,4 @@
  		)
 	</insert>
 
-</mapper> 
\ No newline at end of file
+</mapper>
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SmsRecordsMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SmsRecordsMapper.java
index c5636ca..d5602ee 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SmsRecordsMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SmsRecordsMapper.java
@@ -1,6 +1,7 @@
 package com.ruoyi.system.mapper;
 
 import com.ruoyi.system.domain.SmsRecords;
+import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
 
@@ -10,8 +11,8 @@
  * @author smartor
  * @date 2023-03-06
  */
-public interface SmsRecordsMapper
-{
+@Mapper
+public interface SmsRecordsMapper {
     /**
      * 鏌ヨ鐭俊璁板綍
      *
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SmsRecordsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SmsRecordsServiceImpl.java
index bb0db11..e2802c7 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SmsRecordsServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SmsRecordsServiceImpl.java
@@ -3,10 +3,7 @@
 import java.io.IOException;
 import java.sql.Date;
 import java.time.LocalDate;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -16,11 +13,13 @@
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.OkHttpExample;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.service.ISysConfigService;
 import com.smartor.common.LSHospTokenUtil;
 import com.smartor.domain.ServiceSubtask;
 import com.smartor.mapper.ServiceSubtaskMapper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -124,11 +123,25 @@
         //涓芥按鐨勭煭淇″彂閫佹柟寮�
         Boolean isSuccess = false;
         try {
-            String url = configService.selectConfigByKey("token.360",orgid);
-            Map<String, String> map = MsgLSEnum.getAddressByCode(orgid);
-            String token = LSHospTokenUtil.getToken(orgid,url);
-            log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫侊紝鍦板潃锛歿}锛屽弬鏁帮細{}锛屾満鏋処D锛歿}", map.get("address"), orgid);
-            String dxCode = getDXCode(map.get("address"), phone, content, map.get("sendPersonId"), map.get("sendPersonName"), MsgLSEnum.getHeaderByCode(orgid), token);
+            SysConfig config = new SysConfig();
+            config.setConfigKey("ls.msg.info");
+            config.setOrgid(orgid);
+            List<SysConfig> sysConfigs = configService.selectConfigList(config);
+            Map<String, String> msgInfo = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(sysConfigs)) {
+                String configValue = sysConfigs.get(0).getConfigValue();
+                ObjectMapper objectMapper = new ObjectMapper();
+                if (StringUtils.isNotEmpty(configValue)) {
+                    msgInfo = objectMapper.readValue(configValue, Map.class);
+                }
+            }
+            log.info("-----------map鐨勫�间负锛歿}", msgInfo);
+//
+//            String url = configService.selectConfigByKey("token.360",orgid);
+//            Map<String, String> map = MsgLSEnum.getAddressByCode(orgid);
+            String token = LSHospTokenUtil.getToken(orgid,msgInfo.get("tokenUrl"));
+            log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫侊紝鍦板潃锛歿}锛屽弬鏁帮細{}锛屾満鏋処D锛歿}", msgInfo.get("address"), orgid);
+            String dxCode = getDXCode(msgInfo.get("address"), phone, content, msgInfo.get("sendPersonId"), msgInfo.get("sendPersonName"), MsgLSEnum.getHeaderByCode(msgInfo), token);
             log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫佺粨鏋滐細{}", dxCode);
             ObjectMapper objectMapper = new ObjectMapper();
             Map<String, Object> textParam = null;
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml
index 78f092b..2c1a4f2 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml
@@ -66,6 +66,9 @@
             <if test="configKey != null and configKey != ''">
                 AND config_key like concat('%', #{configKey}, '%')
             </if>
+            <if test="orgid != null and orgid != ''">
+                AND orgid = #{orgid}
+            </if>
             <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
                 and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
             </if>
diff --git a/smartor/src/main/java/com/smartor/common/LSHospTokenUtil.java b/smartor/src/main/java/com/smartor/common/LSHospTokenUtil.java
index b916078..2f5c56a 100644
--- a/smartor/src/main/java/com/smartor/common/LSHospTokenUtil.java
+++ b/smartor/src/main/java/com/smartor/common/LSHospTokenUtil.java
@@ -13,12 +13,13 @@
         if(ObjectUtils.isNotEmpty(url)){
             lyraTokenUtil = LyraTokenUtil.createLyraTokenUtil(url, "zjhes.suifangxt", "OIjdJvx2ALjFVGZoCZO4I8O");
             log.info("token.360璋冪敤缁撴灉"+url+";鏈烘瀯浠g爜锛�"+orgid+"");
-        }else {
-            if (orgid.equals("47255004333112711A1001"))  //鏅畞
-                lyraTokenUtil = LyraTokenUtil.createLyraTokenUtil("https://9.0.124.104:13021/mediinfo-lyra-authserver/connect/token", "zjhes.suifangxt", "OIjdJvx2ALjFVGZoCZO4I8O");
-            if (orgid.equals("47231022633110211A2101"))  //涓尰闄�
-                lyraTokenUtil = LyraTokenUtil.createLyraTokenUtil("https://9.0.124.104:13011/mediinfo-lyra-authserver/connect/token", "zjhes.suifangxt", "OIjdJvx2ALjFVGZoCZO4I8O");
         }
+//        else {
+//            if (orgid.equals("47255004333112711A1001"))  //鏅畞+
+//                lyraTokenUtil = LyraTokenUtil.createLyraTokenUtil("https://9.0.124.104:13021/mediinfo-lyra-authserver/connect/token", "zjhes.suifangxt", "OIjdJvx2ALjFVGZoCZO4I8O");
+//            if (orgid.equals("47231022633110211A2101"))  //涓尰闄�
+//                lyraTokenUtil = LyraTokenUtil.createLyraTokenUtil("https://9.0.124.104:13011/mediinfo-lyra-authserver/connect/token", "zjhes.suifangxt", "OIjdJvx2ALjFVGZoCZO4I8O");
+//        }
         try {
             token = lyraTokenUtil.getToken();
         } catch (IOException e) {
diff --git a/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScript.java b/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScript.java
index fbe550c..fb596fc 100644
--- a/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScript.java
+++ b/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScript.java
@@ -37,6 +37,13 @@
     private Long scriptno;
 
     /**
+     * 绫诲埆ID
+     */
+    @Excel(name = "绫诲埆ID")
+    @ApiModelProperty(value = "绫诲埆ID")
+    private Long assortid;
+
+    /**
      * 閫夐」鍒嗘敮鏍囪瘑(0:鏃犲垎鏀�1:鏈夊垎鏀�)
      */
     @Excel(name = "閫夐」鍒嗘敮鏍囪瘑(0:鏃犲垎鏀�1:鏈夊垎鏀�)")
diff --git a/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScriptVO.java b/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScriptVO.java
index 4bfbb67..1d4423f 100644
--- a/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScriptVO.java
+++ b/smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScriptVO.java
@@ -35,6 +35,7 @@
     @ApiModelProperty(value = "妯℃澘璇濇湳缂栧彿")
     private Long scriptno;
 
+
     /**
      * 妯℃澘ID
      */
@@ -181,6 +182,13 @@
     @ApiModelProperty(value = "绫诲埆鍚�")
     private String categoryName;
 
+    /**
+     * 绫诲埆ID
+     */
+    @Excel(name = "绫诲埆ID")
+    @ApiModelProperty(value = "绫诲埆ID")
+    private Long assortid;
+
 //    /**
 //     * 鎸囨爣閫夐」
 //     */
diff --git a/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScript.java b/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScript.java
index f684fd2..3c20b85 100644
--- a/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScript.java
+++ b/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScript.java
@@ -151,6 +151,13 @@
     private String categoryName;
 
     /**
+     * 绫诲埆ID
+     */
+    @Excel(name = "绫诲埆ID")
+    @ApiModelProperty(value = "绫诲埆ID")
+    private Long assortid;
+
+    /**
      * 鎸囨爣閫夐」
      */
     @Excel(name = "鎸囨爣閫夐」")
diff --git a/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScriptVO.java b/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScriptVO.java
index f1d08d0..b47a625 100644
--- a/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScriptVO.java
+++ b/smartor/src/main/java/com/smartor/domain/IvrTaskTemplateScriptVO.java
@@ -180,6 +180,12 @@
     private String categoryName;
 
     /**
+     * 绫诲埆ID
+     */
+    @Excel(name = "绫诲埆ID")
+    @ApiModelProperty(value = "绫诲埆ID")
+    private Long assortid;
+    /**
      * 鎸囨爣閫夐」
      */
     @Excel(name = "鎸囨爣閫夐」")
diff --git a/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java b/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
index ee5065a..2e130fc 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
@@ -278,7 +278,7 @@
     /**
      * 浣忛櫌鏍囪瘑锛� 0锛氬湪闄�  1锛氬嚭闄�    2锛氳浆绉�
      */
-    @ApiModelProperty(value = "浣忛櫌鏍囪瘑锛� 0锛氬湪闄�  1锛氬嚭闄�    2锛氳浆绉�")
+    @ApiModelProperty(value = "浣忛櫌鏍囪瘑锛� 0锛氬湪闄�  1锛氬嚭闄�    2锛氳浆绉�  3寰呭叆闄�")
     private String inhospstate;
 
     /**
diff --git a/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java b/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java
index 6ad2c36..0632196 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMedOuthosp.java
@@ -211,6 +211,12 @@
     @ApiModelProperty(value = "鐤剧梾闀挎湡浠诲姟锛屾槸鍚﹀鐞嗭細0鏈鐞�   1澶勭悊鎴愬姛    2澶勭悊澶辫触 ")
     private String diagcheckFlag;
 
+    /**
+     * 閮ㄩ棬闀挎湡浠诲姟锛屾槸鍚﹀鐞嗭細0鏈鐞�   1澶勭悊
+     */
+    @ApiModelProperty(value = "閮ㄩ棬闀挎湡浠诲姟锛屾槸鍚﹀鐞嗭細0鏈鐞�   1澶勭悊鎴愬姛    2澶勭悊澶辫触 ")
+    private String deptcheckFlag;
+
 
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "  ", width = 30, dateFormat = "yyyy-MM-dd")
diff --git a/smartor/src/main/java/com/smartor/domain/PatTaskRelevance.java b/smartor/src/main/java/com/smartor/domain/PatTaskRelevance.java
index b8251cf..92bb225 100644
--- a/smartor/src/main/java/com/smartor/domain/PatTaskRelevance.java
+++ b/smartor/src/main/java/com/smartor/domain/PatTaskRelevance.java
@@ -234,6 +234,13 @@
     @ApiModelProperty("灏辫瘖绫诲瀷锛�1闂ㄨ瘖  2鍑洪櫌锛�")
     private String hospType;
 
+    /**
+     * 灏辫瘖绫诲瀷锛�1闂ㄨ瘖  2鍑洪櫌锛�
+     */
+    @Excel(name = "灏辫瘖id锛�1闂ㄨ瘖  2鍑洪櫌锛�")
+    @ApiModelProperty("灏辫瘖id锛�1闂ㄨ瘖  2鍑洪櫌锛�")
+    private Long hospid;
+
 
     /**
      * 鎺ユ敹鏃堕棿
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
index def5cf1..1032473 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
@@ -647,9 +647,9 @@
     @ApiModelProperty(value = "缁忕鍖荤敓")
     private String managementDoctor;
 
-    @ApiModelProperty(value = "闅忚鎯呭喌:1姝e父璇煶,2鎮h�呮嫆鎺ユ垨鎷掕,3闈㈣鎴栬�呮帴璇�,4寰俊闅忚,5闅忚鐢佃瘽涓嶆纭�,6鍏朵粬")
+    @ApiModelProperty(value = "闅忚鎯呭喌:1姝e父璇煶,2鎮h�呮嫆鎺ユ垨鎷掕,3闈㈣鎴栬�呮帴璇�,4寰俊闅忚,5闅忚鐢佃瘽涓嶆纭�,6琚繃婊�,7鍏跺畠")
     private Integer taskSituation;
 
-    @ApiModelProperty(value = "寮傚父棰勮锛�0缁胯壊锛�1绾㈣壊锛�2榛勮壊")
+    @ApiModelProperty(value = "寮傚父棰勮锛�0缁胯壊锛�1绾㈣壊锛�2榛勮壊; 3宸插鐞�")
     private Integer isabnormal;
 }
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskCountReq.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskCountReq.java
index 3ad9f22..e747b86 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskCountReq.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskCountReq.java
@@ -55,4 +55,11 @@
     @ApiModelProperty(value = "鍖荤敓缂栫爜")
     private String drcode;
 
+    @ApiModelProperty(value = "璇煶鍒嗙被缂栫爜")
+    private Long ivrCategoryid;
+
+    @ApiModelProperty(value = "闂嵎鍒嗙被缂栫爜")
+    private Long svyCategoryid;
+
+
 }
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetail.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetail.java
index eb084f8..afcde78 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetail.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetail.java
@@ -112,6 +112,13 @@
     @ApiModelProperty(value = "绫诲埆")
     private String categoryname;
 
+    /**
+     * 绫诲埆ID
+     */
+    @Excel(name = "绫诲埆ID")
+    @ApiModelProperty(value = "绫诲埆ID")
+    private Long categoryid;
+
 
     @ApiModelProperty(value = "鎸囨爣ID(浠庨棶棰樹笂鑾峰彇)")
     private Integer targetid;
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetailVO.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetailVO.java
index 9435e38..5a4029c 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetailVO.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDetailVO.java
@@ -163,6 +163,12 @@
 
     @ApiModelProperty(value = "鎮h�匢D")
     private Long patid;
+    /**
+     * 绫诲埆ID
+     */
+    @Excel(name = "绫诲埆ID")
+    @ApiModelProperty(value = "绫诲埆ID")
+    private Long categoryid;
 
     private List<SvyTaskTemplateTargetoption> svyTaskTemplateTargetoptions;
 }
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDiagname.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDiagname.java
new file mode 100644
index 0000000..ea0b470
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskDiagname.java
@@ -0,0 +1,55 @@
+package com.smartor.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 鐤剧梾鑾峰彇鎮h�呬俊鎭�
+ *
+ * @author ruoyi
+ * @date 2024-12-11
+ */
+@ApiModel(value = "ServiceSubtaskDiagname", description = "")
+@Data
+public class ServiceSubtaskDiagname implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty(value = "鏈嶅姟鍚嶇О")
+    private String taskName;
+
+    @ApiModelProperty(value = "鎮h�呭鍚�")
+    private String sendname;
+
+    @ApiModelProperty(value = "鐢佃瘽")
+    private String phone;
+
+    @ApiModelProperty(value = "鎬у埆")
+    private String sex;
+
+
+    @ApiModelProperty(value = "鐤剧梾鍚嶇О")
+    private String leavediagname;
+
+    @ApiModelProperty(value = "闅忚鐘舵��")
+    private Long sendstate;
+
+    @ApiModelProperty(value = "鍏ラ櫌鏃堕棿")
+    private Date starttime;
+
+    @ApiModelProperty(value = "鍑洪櫌鏃堕棿")
+    private Date endtime;
+
+    @ApiModelProperty(value = "闅忚鏃堕棿")
+    private Date visitTime;
+
+    @ApiModelProperty(value = "鎶ゅ+濮撳悕")
+    private String nurseName;
+
+
+}
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskStatistic.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskStatistic.java
index eabcd62..3d6597e 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskStatistic.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskStatistic.java
@@ -5,6 +5,9 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
+import java.util.List;
+
 /**
  * 鍚勭梾鍖洪殢璁跨粺璁℃瘮渚�
  *
@@ -13,7 +16,7 @@
  */
 @ApiModel(value = "ServiceSubtaskStatistic", description = "鍚勭梾鍖洪殢璁跨粺璁℃瘮渚�")
 @Data
-public class ServiceSubtaskStatistic {
+public class ServiceSubtaskStatistic implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty(value = "鏈嶅姟鎬婚噺")
@@ -90,6 +93,10 @@
     @ApiModelProperty(value = "鏃犻渶闅忚浜烘")
     @Excel(name = " 鏃犻渶闅忚浜烘 ")
     private Long nonFollowUp = 0L;
+
+    @ApiModelProperty(value = "杩囨护鎮h��")
+    @Excel(name = " 杩囨护鎮h�� ")
+    private Long filterCount = 0L;
 
     @ApiModelProperty(value = "搴旈殢璁夸汉娆�")
     @Excel(name = " 搴旈殢璁夸汉娆� ")
@@ -181,13 +188,13 @@
     private String drname;
 
     @ApiModelProperty(value = "濉啓婊℃剰搴︽暟閲�")
-    private Integer joyCount=0;
+    private Integer joyCount = 0;
 
     @ApiModelProperty(value = "鎵�鏈夋弧鎰忓害鏁伴噺")
-    private Integer joyAllCount=0;
+    private Integer joyAllCount = 0;
 
     @ApiModelProperty(value = "婊℃剰搴︽瘮渚�")
-    private String joyTotal="";
+    private Double joyTotal = 0.00;
 
     @ApiModelProperty(value = "闅忚鎯呭喌:1姝e父璇煶")
     private Integer taskSituation1 = 0;
@@ -204,7 +211,10 @@
     @ApiModelProperty(value = "闅忚鎯呭喌:5闅忚鐢佃瘽涓嶆纭�")
     private Integer taskSituation5 = 0;
 
-    @ApiModelProperty(value = "闅忚鎯呭喌:6鍏朵粬")
+    @ApiModelProperty(value = "闅忚鎯呭喌:7鍏朵粬")
     private Integer taskSituation6 = 0;
 
+    @ApiModelProperty(value = "杩囨护鎮h�呰鎯�")
+    private List<ServiceSubtask> filterCountList;
+
 }
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
index a2c3c76..c913b52 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
@@ -729,7 +729,7 @@
     @ApiModelProperty(value = "闅忚閮ㄩ棬鍚嶇О")
     private String visitDeptName;
 
-    @ApiModelProperty(value = "寮傚父棰勮锛�0缁胯壊锛�1绾㈣壊锛�2榛勮壊")
+    @ApiModelProperty(value = "寮傚父棰勮锛�0缁胯壊锛�1绾㈣壊锛�2榛勮壊;3宸插鐞�")
     private Integer isabnormal;
 
     @ApiModelProperty(value = "闅忚閮ㄩ棬缂栫爜闆嗗悎")
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceTaskdiag.java b/smartor/src/main/java/com/smartor/domain/ServiceTaskdiag.java
index b3e76f2..9697a7b 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceTaskdiag.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceTaskdiag.java
@@ -7,20 +7,20 @@
 import lombok.Data;
 
 /**
- * 妯℃澘绉戝鍏宠仈瀵硅薄 service_taskdiag
+ * 妯℃澘鐤剧梾鍏宠仈瀵硅薄 service_taskdiag
  *
  * @author lihu
  * @date 2025-02-24
  */
 @Data
-@ApiModel("妯℃澘绉戝鍏宠仈")
+@ApiModel("妯℃澘鐤剧梾鍏宠仈")
 public class ServiceTaskdiag extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
     /**
      * 妯℃澘搴撳拰绉戝鍏宠仈id
      */
-    @ApiModelProperty("妯℃澘搴撳拰绉戝鍏宠仈id")
+    @ApiModelProperty("妯℃澘搴撳拰鐤剧梾鍏宠仈id")
     //鏁版嵁搴撹嚜澧炴敼鎴怈TableId(type = IdType.AUTO)
     private Long id;
 
diff --git a/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScript.java b/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScript.java
index 3b2e373..4e50611 100644
--- a/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScript.java
+++ b/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScript.java
@@ -156,7 +156,6 @@
     @Excel(name = "鍒嗙被id")
     @ApiModelProperty("鍒嗙被id")
     private Long categoryid;
-
     /**
      * 棰樼洰鍐呭
      */
diff --git a/smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScript.java b/smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScript.java
index 77f29c6..f3aef10 100644
--- a/smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScript.java
+++ b/smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScript.java
@@ -89,6 +89,12 @@
     private String categoryName;
 
     /**
+     * 绫诲埆ID
+     */
+    @Excel(name = "绫诲埆ID")
+    @ApiModelProperty(value = "绫诲埆ID")
+    private Long categoryid;
+    /**
      * 璇濇湳鍐呭
      */
     @ApiModelProperty(value = "璇濇湳鍐呭")
diff --git a/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java b/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java
index 266b9e9..b80f83e 100644
--- a/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java
@@ -43,6 +43,14 @@
     public int batchPatMedOuthosp(List<PatMedOuthosp> patMedOuthosps);
 
     /**
+     * 鎵归噺鎻掑叆锛屽拷鐣ラ噸澶嶏紙INSERT IGNORE锛�
+     *
+     * @param patMedOuthosps 闂ㄦ�ヨ瘖璁板綍鍒楄〃
+     * @return 瀹為檯鎻掑叆鏁伴噺
+     */
+    public int batchInsertIgnore(List<PatMedOuthosp> patMedOuthosps);
+
+    /**
      * 淇敼鎮h�呴棬璇婅褰�
      *
      * @param patMedOuthosp 鎮h�呴棬璇婅褰�
diff --git a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
index 7fbdf87..587b2d0 100644
--- a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
@@ -31,6 +31,8 @@
      */
     public List<ServiceSubtask> selectServiceSubtaskList(ServiceSubtaskVO serviceSubtaskVO);
 
+    public List<ServiceSubtask> selectServiceSubtaskByDiagname(ServiceSubtask serviceSubtask);
+
     public List<ServiceSubtask> queryServiceSubtaskList(ServiceSubtaskVO serviceSubtaskVO);
 
     public List<ServiceSubtask> selectServiceSubtaskBySendstate(ServiceSubtaskVO serviceSubtaskVO);
diff --git a/smartor/src/main/java/com/smartor/service/IPatMedInhospService.java b/smartor/src/main/java/com/smartor/service/IPatMedInhospService.java
index 6f94251..3d5c568 100644
--- a/smartor/src/main/java/com/smartor/service/IPatMedInhospService.java
+++ b/smartor/src/main/java/com/smartor/service/IPatMedInhospService.java
@@ -90,7 +90,7 @@
      * @param
      * @return 缁撴灉
      */
-    public int dealOutHospInfo();
+    public int dealOutHospInfo(String config);
 
     /**
      * 鑾峰彇鍑洪櫌锛屼綇闄紝闂ㄨ瘖鏈嶅姟浜烘
diff --git a/smartor/src/main/java/com/smartor/service/IServiceSLTDHealthcareRecordService.java b/smartor/src/main/java/com/smartor/service/IServiceSLTDHealthcareRecordService.java
index a06fa67..cb822b1 100644
--- a/smartor/src/main/java/com/smartor/service/IServiceSLTDHealthcareRecordService.java
+++ b/smartor/src/main/java/com/smartor/service/IServiceSLTDHealthcareRecordService.java
@@ -1,10 +1,12 @@
 package com.smartor.service;
 
+import afu.org.checkerframework.checker.oigj.qual.O;
 import com.smartor.domain.ServiceSLTDDeptReqVO;
 import com.smartor.domain.ServiceSLTDInhospReqVO;
 import com.smartor.domain.ServiceSLTDInhospResDTO;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 鐪佺珛鍚屽痉鍋ュ悍璁板綍鏌ヨService鎺ュ彛
@@ -69,5 +71,7 @@
      */
     Boolean queryDeptWardAreaInfoList(ServiceSLTDDeptReqVO serviceSLTDDeptReqVO);
 
+    public void aa(Map<String, Object> map);
+
 
 }
diff --git a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
index 59af7b6..178b04e 100644
--- a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
+++ b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
@@ -23,6 +23,8 @@
      */
     public ServiceSubtask selectServiceSubtaskById(Long id);
 
+    public List<ServiceSubtask> selectServiceSubtaskByDiagname(ServiceSubtask serviceSubtask);
+
     /**
      * 鏌ヨ鍗曚竴浠诲姟锛堥殢璁匡級鍒楄〃
      *
@@ -128,6 +130,8 @@
     public List<ServiceSubtaskCount> getSfFzInfoEveryMonth(ServiceSubtaskCountReq serviceSubtaskCountReq);
 
     public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq);
+    //瀵煎嚭闅忚
+    public List<ServiceSubtaskStatistic> getSfStatisticsExport(ServiceSubtaskCountReq serviceSubtaskCountReq);
 
     public List<ServiceSubtaskStatistic> getSfStatisticsJoy(ServiceSubtaskCountReq serviceSubtaskCountReq);
 
@@ -135,5 +139,5 @@
 
     public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest request);
 
-    public  List<PatArchiveSrmVO> sendMsgTemplate(List<PatArchiveSrmVO> patArchiveSrmVOS);
+    public List<PatArchiveSrmVO> sendMsgTemplate(List<PatArchiveSrmVO> patArchiveSrmVOS);
 }
diff --git a/smartor/src/main/java/com/smartor/service/IXHGatherPatArchiveService.java b/smartor/src/main/java/com/smartor/service/IXHGatherPatArchiveService.java
index b5ac057..f3dccd3 100644
--- a/smartor/src/main/java/com/smartor/service/IXHGatherPatArchiveService.java
+++ b/smartor/src/main/java/com/smartor/service/IXHGatherPatArchiveService.java
@@ -1,11 +1,6 @@
 package com.smartor.service;
 
-import com.ruoyi.common.core.domain.entity.SysDept;
-import com.ruoyi.common.core.domain.entity.SysUser;
-import com.smartor.domain.*;
-
 import java.time.LocalDateTime;
-import java.util.List;
 
 /**
  * 娌冲崡閲囬泦鎮h�呬俊鎭帴鍙�
diff --git a/smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java
index a96cb46..d6f27db 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java
@@ -139,7 +139,7 @@
 
         //瀵规ā鏉胯瘽鏈拰閫夐」杩涜澶勭悊锛堣瘽鏈〃涓庢寚鏍囪〃杩涜鍚堝苟浜嗭紝锛�
         if (CollectionUtils.isNotEmpty(ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList())) {
-            log.error("ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList()鏄惁鏈夋暟鎹搱锛歿}", ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList());
+//            log.error("ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList()鏄惁鏈夋暟鎹搱锛歿}", ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList());
             for (IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO : ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList()) {
                 ivrTaskTemplateScriptVO.setGuid(ivrTaskTemplateVO.getGuid());
                 ivrTaskTemplateScriptVO.setOrgid(ivrTaskTemplateVO.getOrgid());
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
index a3ad4d2..52072b3 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
@@ -792,9 +792,9 @@
         } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 4) {
             //  鏌ョ湅浣忛櫌  1  鏌ョ湅闂ㄨ瘖  2   鏌ョ湅浣撴  3   鏌ョ湅鍑洪櫌 4
             patArchiveReq.setCry(1);
-            log.warn("--------鏌ョ湅鍑洪櫌鐨勫叆鍙傚�间负锛歿}", patArchiveReq);
+            log.info("--------鏌ョ湅鍑洪櫌鐨勫叆鍙傚�间负锛歿}", patArchiveReq);
             List<PatArchiveOthreInfo> patArchives1 = patArchiveMapper.selectPatArchiveInfoByInhospQC(patArchiveReq);
-            log.warn("--------鏌ョ湅鍑洪櫌鐨勮繑鍙傚�间负锛歿}", patArchives1.size());
+            log.info("--------鏌ョ湅鍑洪櫌鐨勮繑鍙傚�间负锛歿}", patArchives1.size());
             if (CollectionUtils.isNotEmpty(patArchives1)) {
                 patArchiveList.addAll(patArchives1);
             }
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
index 885a99e..27de461 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
@@ -33,13 +33,10 @@
 public class PatMedInhospServiceImpl implements IPatMedInhospService {
     @Autowired
     private PatMedInhospMapper patMedInhospMapper;
-
     @Autowired
     private ServiceTaskdeptMapper serviceTaskdeptMapper;
-
     @Autowired
     private ServiceTaskdiagMapper serviceTaskdiagMapper;
-
     @Autowired
     private PatArchiveMapper patArchiveMapper;
     @Autowired
@@ -50,7 +47,6 @@
     private ServiceSubtaskMapper serviceSubtaskMapper;
     @Autowired
     private ServiceSubtaskPreachformMapper serviceSubtaskPreachformMapper;
-
     @Value("${spring.profiles.active}")
     private String active;
 
@@ -213,7 +209,7 @@
     }
 
     @Override
-    public int dealOutHospInfo() {
+    public int dealOutHospInfo(String config) {
 
         PatMedInhosp pmks = new PatMedInhosp();
         //鑾峰彇闇�瑕佸嚭闄㈤儴闂ㄩ殢璁匡紝鏈鐞嗙殑鏁版嵁
@@ -253,7 +249,7 @@
                     patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
                 } else {
                     for (ServiceTaskdept serviceTaskdept1 : serviceTaskdepts) {
-                        writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedInhosp1, patArchive, 1);
+                        writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedInhosp1, patArchive, 1, config);
                     }
                     patMedInhosp1.setDeptcheckFlag("1");
                     patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
@@ -304,7 +300,7 @@
                         patMedInhospMapper.updatePatMedInhosp(pmiBQ1);
                     } else {
                         for (ServiceTaskdept serviceTaskdept1 : serviceTaskdeptList) {
-                            writeInSubTask(serviceTaskdept1.getTaskId(), true, pmiBQ1, patArchive, 2);
+                            writeInSubTask(serviceTaskdept1.getTaskId(), true, pmiBQ1, patArchive, 2, config);
                         }
                         pmiBQ1.setWardcheckFlag("1");
                         patMedInhospMapper.updatePatMedInhosp(pmiBQ1);
@@ -357,7 +353,7 @@
                         patMedInhospMapper.updatePatMedInhosp(pmiJB);
                     } else {
                         for (ServiceTaskdiag serviceTaskdept1 : serviceTaskdiags) {
-                            writeInSubTask(serviceTaskdept1.getTaskId(), true, pmiJB, patArchive, 3);
+                            writeInSubTask(serviceTaskdept1.getTaskId(), true, pmiJB, patArchive, 3, config);
                         }
                         pmiJB.setDiagcheckFlag("1");
                         patMedInhospMapper.updatePatMedInhosp(pmiJB);
@@ -541,7 +537,7 @@
     }
 
     //灏嗘偅鑰呮斁鍒皊ubtask涓�
-    private void writeInSubTask(Long taskid, Boolean check, PatMedInhosp patMedInhosp1, PatArchive patArchive, Integer type) {
+    private void writeInSubTask(Long taskid, Boolean check, PatMedInhosp patMedInhosp1, PatArchive patArchive, Integer type, String config) {
         String longTaskReason = patMedInhosp1.getLongTaskReason();
         if (StringUtils.isEmpty(longTaskReason)) longTaskReason = "";
         ServiceTask st = new ServiceTask();
@@ -571,7 +567,7 @@
             return;
         }
         //灏佽serviceSubtask
-        ServiceSubtask serviceSubtask = boxedServiceSubtask(serviceTask, patMedInhosp1, patArchive);
+        ServiceSubtask serviceSubtask = boxedServiceSubtask(serviceTask, patMedInhosp1, patArchive, config);
         if (type != 2) {
             //绉戝鍜岀柧鐥� 閮界敤 绉戝濉厖
             serviceSubtask.setVisitDeptCode(patMedInhosp1.getLeaveldeptcode());
@@ -584,7 +580,7 @@
 
         Integer i = 0;
         //鍏堝垽鏂竴涓嬶紝鏄惁闇�瑕佹牎楠�
-        if (check) {
+        if (check && serviceSubtask.getTaskSituation() != 6) {
             //鍦ㄦ柊澧炰箣鍓嶏紝鍏堥�氳繃鎮h�匢D锛宻endstate=2鏌ヨ涓�涓嬶紝鍦ㄦ墍鏈夐暱鏈熶换鍔′腑锛屾槸涓嶆槸杩樻湁璇ユ偅鑰呭緟鎵ц鐨勪换鍔★紝鏈夌殑璇�,姣旇緝涔嬪墠鐨別ndtime鏄惁灏忎簬褰撳墠鐨別ndtaime,濡傛灉涔嬪墠鐨勫皬浜庣幇鍦ㄧ殑锛屽垯鐩存帴灏嗕箣鍓嶇殑鍋滄帀锛堝師鍥犲啀鍏ラ櫌锛�
             ServiceSubtaskVO subtask = new ServiceSubtaskVO();
             subtask.setPatid(patArchive.getId());
@@ -603,7 +599,9 @@
                         if (serviceSubtask1.getEndtime().before(serviceSubtask.getEndtime()) && serviceSubtask1.getServiceType().equals("2")) {
                             //濡傛灉褰撳墠寰幆鐨勫瓙浠诲姟鐨勫嚭闄㈡椂闂村湪鈥滃噯澶囨柊澧炵殑瀛愪换鍔♀�濈殑鍑洪櫌鏃堕棿涔嬪墠锛屽垯灏嗗惊鐜殑瀛愪换鍔″仠鎺�
                             serviceSubtask1.setSendstate(4L);
-                            serviceSubtask1.setRemark("鎮h�呭啀鍏ラ櫌");
+                            if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
+                                serviceSubtask.setRemark(serviceSubtask.getRemark() + ",鐤剧梾鎮h�呭啀鍏ラ櫌");
+                            else serviceSubtask.setRemark("鐤剧梾鎮h�呭啀鍏ラ櫌");
                             serviceSubtask1.setResult("error");
 //                            serviceSubtask1.setFinishtime(new Date());
                             serviceSubtask1.setUpdateBy(serviceTask.getUpdateBy());
@@ -615,7 +613,9 @@
                             serviceSubtask.setResult("error");
 //                            serviceSubtask.setFinishtime(new Date());
                             serviceSubtask.setSendstate(4L);
-                            serviceSubtask.setRemark("褰撳墠鎮h�呭嚭闄㈡椂闂村悗鏈夊緟鎵ц鐨勫嚭闄㈤殢璁块暱鏈熶换鍔�");
+                            if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
+                                serviceSubtask.setRemark(serviceSubtask.getRemark() + ",褰撳墠鎮h�呭嚭闄㈡椂闂村悗鏈夊緟鎵ц鐨勫嚭闄㈤殢璁块暱鏈熶换鍔�");
+                            else serviceSubtask.setRemark("褰撳墠鎮h�呭嚭闄㈡椂闂村悗鏈夊緟鎵ц鐨勫嚭闄㈤殢璁块暱鏈熶换鍔�");
                             serviceSubtask.setCreateBy(serviceTask.getCreateBy());
                             serviceSubtask.setCreateTime(new Date());
                             i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
@@ -624,7 +624,9 @@
                         //type=3 琛ㄧず鐤剧梾
                         //灏嗕箣鍓嶇殑鍋滄帀
                         serviceSubtask1.setSendstate(4L);
-                        serviceSubtask1.setRemark("鐤剧梾鎮h�呭啀鍏ラ櫌");
+                        if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
+                            serviceSubtask.setRemark(serviceSubtask.getRemark() + ",鐤剧梾鎮h�呭啀鍏ラ櫌");
+                        else serviceSubtask.setRemark("鐤剧梾鎮h�呭啀鍏ラ櫌");
                         serviceSubtask1.setResult("error");
 //                        serviceSubtask1.setFinishtime(new Date());
                         serviceSubtask1.setUpdateBy(serviceTask.getUpdateBy());
@@ -638,7 +640,9 @@
                 }
             } else {
                 if (StringUtils.isEmpty(serviceSubtask.getPhone())) {
-                    serviceSubtask.setRemark("鎵嬫満鍙蜂负绌�");
+                    if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
+                        serviceSubtask.setRemark(serviceSubtask.getRemark() + ",鎵嬫満鍙蜂负绌�");
+                    else serviceSubtask.setRemark("鎵嬫満鍙蜂负绌�");
                     serviceSubtask.setSendstate(4L);
                     serviceSubtask.setResult("error");
                 }
@@ -647,9 +651,16 @@
                 i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
                 addServiceSubtaskPreachform(serviceSubtask, null);
             }
+        } else if (serviceSubtask.getTaskSituation() == 6) {
+            //璇存槑璇ユ偅鑰呮槸琚繃婊ょ殑锛屼笉鐢ㄥ啀鎵ц浜�
+            serviceSubtask.setCreateBy(serviceTask.getCreateBy());
+            serviceSubtask.setCreateTime(new Date());
+            i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
         } else {
             if (StringUtils.isEmpty(serviceSubtask.getPhone())) {
-                serviceSubtask.setRemark("鎵嬫満鍙蜂负绌�");
+                if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
+                    serviceSubtask.setRemark(serviceSubtask.getRemark() + ",鎵嬫満鍙蜂负绌�");
+                else serviceSubtask.setRemark("鎵嬫満鍙蜂负绌�");
                 serviceSubtask.setSendstate(4L);
                 serviceSubtask.setResult("error");
             }
@@ -669,7 +680,7 @@
             patMedInhospMapper.updatePatMedInhosp(patMedInhosp2);
         } else {
             //鐢熸垚瀛愪换鍔″け璐ワ紝
-            log.info("鐢熸垚瀛愪换鍔″け璐erviceSubtask鐨則askid涓猴細{},patid涓猴細{}", serviceSubtask.getTaskid(),serviceSubtask.getPatid());
+            log.info("鐢熸垚瀛愪换鍔″け璐erviceSubtask鐨則askid涓猴細{},patid涓猴細{}", serviceSubtask.getTaskid(), serviceSubtask.getPatid());
             PatMedInhosp patMedInhosp2 = new PatMedInhosp();
             patMedInhosp2.setInhospid(patMedInhosp1.getInhospid());
             if (type == 1) patMedInhosp2.setDeptcheckFlag("2");
@@ -697,6 +708,11 @@
             for (ServiceSubtaskPreachform serviceSubtaskPreachform : serviceSubtaskPreachformList) {
                 serviceSubtaskPreachform.setTaskid(serviceSubtask.getTaskid());
                 serviceSubtaskPreachform.setSubid(serviceSubtask.getId());
+
+                //鍏堟煡璇竴涓嬶紝鏄惁瀛樺湪锛屽鏋滃凡缁忓瓨鍦紝灏变笉鏂板浜�
+                List<ServiceSubtaskPreachform> serviceSubtaskPreachformList1 = serviceSubtaskPreachformMapper.selectServiceSubtaskPreachformList(serviceSubtaskPreachform);
+                if (CollectionUtils.isNotEmpty(serviceSubtaskPreachformList1)) continue;
+
                 //杩欎釜sendstate闇�瑕佸湪鏁版嵁搴撹缃竴涓粯璁ゅ�间负鈥�1鈥�
                 serviceSubtaskPreachform.setSendstate("1");
                 if (StringUtils.isNotEmpty(sendstate)) serviceSubtaskPreachform.setSendstate(sendstate);
@@ -712,7 +728,7 @@
 
 
     //灏佽serviceSubtask
-    private ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatMedInhosp patMedInhosp1, PatArchive patArchive) {
+    private ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatMedInhosp patMedInhosp1, PatArchive patArchive, String config) {
         ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTask, ServiceSubtask.class);
         serviceSubtask.setTaskid(serviceTask.getTaskid());
         if (StringUtils.isNotEmpty(serviceTask.getLibtemplateid()))
@@ -761,17 +777,21 @@
         }
         serviceSubtask.setLongSendTime(newDate);
         serviceSubtask.setVisitTime(newDate);
+        if (patMedInhosp1.getFudate() != null) serviceSubtask.setVisitTime(patMedInhosp1.getFudate());
         //濡傛灉鏄�氱煡鐨勮瘽锛岄渶瑕佹彁鍓嶅嚑澶╁皢閫氳繃鐭俊鍙戝嚭鍘伙紙鍏蜂綋鍑犲ぉ锛岃繖涓彲浠ラ厤缃湪sys_conf琛ㄤ腑锛�
         if ("3".equals(serviceTask.getType())) {
-            serviceSubtask.setVisitTime(minusDay(newDate, 2));
+            serviceSubtask.setVisitTime(minusDay(newDate, StringUtils.isNotEmpty(config) ? Integer.parseInt(config) : 0));
+            //濡傛灉璇ュ嚭闄㈣褰曟湁闅忚鏃堕棿锛屽垯鐢ㄤ粬鑷繁鐨勯殢璁挎椂闂�
+            if (patMedInhosp1.getFudate() != null)
+                serviceSubtask.setVisitTime(minusDay(patMedInhosp1.getFudate(), StringUtils.isNotEmpty(config) ? Integer.parseInt(config) : 0));
         }
-
 
         //鎮h�呭彂閫佹椂闂�
         if (StringUtils.isNotEmpty(patArchive.getNotrequiredFlag()) && patArchive.getNotrequiredFlag().equals("1")) {
             String remark = patArchive.getNotrequiredreason();
             serviceSubtask.setRemark(remark);
             serviceSubtask.setResult("error");
+            serviceSubtask.setTaskSituation(6);
             //涓嶆墽琛�
             serviceSubtask.setSendstate(4L);
         }
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
index e3c8297..988b5af 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
@@ -17,6 +17,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import com.smartor.service.IPatMedOuthospService;
 import org.springframework.util.CollectionUtils;
@@ -46,6 +47,9 @@
     private ServiceTaskdiagMapper serviceTaskdiagMapper;
 
     @Autowired
+    private ServiceTaskdeptMapper serviceTaskdeptMapper;
+
+    @Autowired
     private PatArchiveMapper patArchiveMapper;
 
 
@@ -67,6 +71,7 @@
      * @return 鎮h�呴棬璇婅褰�
      */
     @Override
+    @Cacheable(value = "selectPatMedOuthospList", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#patMedOuthosp.toString().getBytes())", unless = "#result == null or #result.isEmpty()")
     public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
         List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp);
         for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
@@ -81,6 +86,16 @@
                 patMedOuthosp1.setTelcode(patArchive.getTelcode());
                 patMedOuthosp1.setIdcardno(patArchive.getIdcardno());
             }
+            ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO();
+            serviceSubtaskVO.setPatid(patMedOuthosp1.getPatid());
+            List<Long> sendstates = new ArrayList<>();
+            sendstates.add(1L);
+            sendstates.add(2L);
+            sendstates.add(3L);
+            serviceSubtaskVO.setSendstates(sendstates);
+            serviceSubtaskVO.setServiceType("3");
+            List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO);
+            if (!CollectionUtils.isEmpty(serviceSubtaskList)) patMedOuthosp1.setServerState("1");
         }
         return patMedOuthosps;
     }
@@ -221,21 +236,19 @@
         for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
             PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
 
-            //璇ユ偅鑰呮湁鍙兘鎻愬墠鏉ュ璇婁簡锛岄偅浠栧悗闈㈢殑鏈瀹ょ殑閫氱煡灏卞彲浠ヤ笉鐢ㄥ啀鍙戠煭淇′簡
-            ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO();
-            if (StringUtils.isNotEmpty(patMedOuthosp1.getDeptcode())) {
-                serviceSubtaskVO.setDeptcode(patMedOuthosp1.getDeptcode());
-                serviceSubtaskVO.setSfzh(patArchive.getIdcardno());
-                serviceSubtaskVO.setType("3");
-                serviceSubtaskVO.setSendstate(2L);
-                serviceSubtaskVO.setPreachform("4");
-                List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
-                if (!CollectionUtils.isEmpty(serviceSubtaskList)) {
-                    for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
-                        serviceSubtask.setSendstate(6L);
-                        serviceSubtask.setRemark("宸插洖鏉ュ璇婏紝鏃犻渶鍐嶈繘琛岀煭淇¢�氱煡");
-                        serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
-                    }
+            //鏍规嵁鎮h�呯瀹わ紝鑾峰彇璇ョ柧鐥呯殑闀挎湡浠诲姟
+            ServiceTaskdept serviceTaskdept = new ServiceTaskdept();
+            serviceTaskdept.setLongtask(1L);
+            serviceTaskdept.setDeptCode(patMedOuthosp1.getDeptcode());
+            serviceTaskdept.setServiceType("3");
+            List<ServiceTaskdept> serviceTaskdeptList = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept);
+            if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTaskdeptList) || serviceTaskdeptList.size() == 0) {
+                patMedOuthosp1.setDeptcheckFlag("2");
+                patMedOuthosp1.setRemark("閫氳繃閮ㄩ棬,娌℃湁鎵惧埌闂ㄨ瘖闅忚浠诲姟ID");
+                patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
+            } else {
+                for (ServiceTaskdept serviceTaskdept1 : serviceTaskdeptList) {
+                    writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive, 1);
                 }
             }
 
@@ -247,11 +260,11 @@
             //濡傛灉閮ㄩ棬妯℃澘涓虹┖锛堝皢deptIsNull璁剧疆涓簍rue锛�
             if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTaskdiags) || serviceTaskdiags.size() == 0) {
                 patMedOuthosp1.setDiagcheckFlag("2");
-                patMedOuthosp1.setRemark("閫氳繃icd10,娌℃湁鎵惧埌闅忚浠诲姟ID");
+                patMedOuthosp1.setRemark("閫氳繃icd10,娌℃湁鎵惧埌闂ㄨ瘖闅忚浠诲姟ID");
                 patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
             } else {
                 for (ServiceTaskdiag serviceTaskdept1 : serviceTaskdiags) {
-                    writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive);
+                    writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive, 2);
                 }
             }
 
@@ -259,16 +272,24 @@
         return 1;
     }
 
-    private void writeInSubTask(Long taskid, Boolean check, PatMedOuthosp patMedOuthosp, PatArchive patArchive) {
+    /**
+     * @param taskid
+     * @param check
+     * @param patMedOuthosp
+     * @param patArchive
+     * @param type          1 绉戝 2 鐤剧梾
+     */
+    private void writeInSubTask(Long taskid, Boolean check, PatMedOuthosp patMedOuthosp, PatArchive patArchive, Integer type) {
 
         ServiceTask st = new ServiceTask();
         st.setTaskid(taskid);
         st.setSendState(2L);
         List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st);
         if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTasks)) {
-            log.error("璇ユ偅鑰呯柧鐥呴殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓猴細{}", taskid);
-            patMedOuthosp.setDiagcheckFlag("2");
-            patMedOuthosp.setRemark("璇ユ偅鑰呯柧鐥呴殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓�:" + taskid);
+            log.info("璇ユ偅鑰呯柧鐥呴殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓猴細{}", taskid);
+            if (type == 1) patMedOuthosp.setDiagcheckFlag("2");
+            if (type == 2) patMedOuthosp.setDeptcheckFlag("2");
+            patMedOuthosp.setRemark("璇ユ偅鑰呴棬璇婇殢璁块暱鏈熶换鍔′笉瀛樺湪,浠诲姟ID涓�:" + taskid);
             patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp);
             return;
         }
@@ -284,7 +305,7 @@
             subtask.setSendstate(2L);
             subtask.setTaskid(taskid);
             List<ServiceSubtask> selectServiceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(subtask);
-            log.error("璇ユ偅鑰呭緟鎵ц鐨勪换鍔�:{}", CollectionUtils.isEmpty(selectServiceSubtaskList) ? null : selectServiceSubtaskList.size());
+            log.info("璇ユ偅鑰呭緟鎵ц鐨勪换鍔�:{}", CollectionUtils.isEmpty(selectServiceSubtaskList) ? null : selectServiceSubtaskList.size());
             if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(selectServiceSubtaskList) && selectServiceSubtaskList.size() > 0) {
                 for (ServiceSubtask serviceSubtask1 : selectServiceSubtaskList) {
                     if (Objects.isNull(serviceSubtask1.getLongSendTime())) {
@@ -293,15 +314,14 @@
                     }
 
                     //灏嗕箣鍓嶇殑鍋滄帀
-                    serviceSubtask1.setSendstate(4L);
-                    serviceSubtask1.setRemark("鐤剧梾鎮h�呭啀鍏ラ櫌");
-                    serviceSubtask1.setResult("error");
-//                    serviceSubtask1.setFinishtime(new Date());
+                    serviceSubtask1.setSendstate(6L);
+                    serviceSubtask1.setRemark("鎮h�呭凡缁忓洖闄㈠璇�");
+                    serviceSubtask1.setResult("success");
+                    serviceSubtask1.setFinishtime(new Date());
                     serviceSubtask1.setUpdateBy(serviceTask.getUpdateBy());
                     serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1);
                     //閲嶆柊鏂板瀛愪换鍔�
                     i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
-
                 }
             } else {
                 if (StringUtils.isEmpty(serviceSubtask.getPhone())) {
@@ -330,14 +350,16 @@
             //灏哻heck_flag鏀规垚1锛堝凡澶勭悊锛�
             PatMedOuthosp patMedOuthosp1 = new PatMedOuthosp();
             patMedOuthosp1.setId(patMedOuthosp.getId());
-            patMedOuthosp1.setDiagcheckFlag("1");
+            if (type == 1) patMedOuthosp1.setDiagcheckFlag("2");
+            if (type == 2) patMedOuthosp1.setDeptcheckFlag("2");
             patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
         } else {
             //鐢熸垚瀛愪换鍔″け璐ワ紝
-            log.error("鐢熸垚瀛愪换鍔″け璐erviceSubtask鐨則askid涓猴細{},patid涓猴細{}", serviceSubtask.getTaskid(), serviceSubtask.getPatid());
+            log.info("鐢熸垚瀛愪换鍔″け璐erviceSubtask鐨則askid涓猴細{},patid涓猴細{}", serviceSubtask.getTaskid(), serviceSubtask.getPatid());
             PatMedOuthosp pmo = new PatMedOuthosp();
             pmo.setId(patMedOuthosp.getId());
-            pmo.setDiagcheckFlag("2");
+            if (type == 1) pmo.setDiagcheckFlag("2");
+            if (type == 2) pmo.setDeptcheckFlag("2");
             pmo.setRemark("鐢熸垚瀛愪换鍔″け璐�");
             patMedOuthospMapper.updatePatMedOuthosp(pmo);
         }
@@ -352,6 +374,8 @@
         serviceSubtask.setDrcode(patMedOuthosp.getDrcode());
         serviceSubtask.setDrname(patMedOuthosp.getDrname());
         serviceSubtask.setDeptcode(patMedOuthosp.getDeptcode());
+        serviceSubtask.setInhospid(patMedOuthosp.getId());
+        serviceSubtask.setHospno(patMedOuthosp.getOuthospno());
         serviceSubtask.setDeptname(patMedOuthosp.getDeptname());
         serviceSubtask.setTemplateid(serviceTask.getTemplateid());
         serviceSubtask.setTemplatename(serviceTask.getTemplatename());
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSLTDHealthcareRecordServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSLTDHealthcareRecordServiceImpl.java
index ced4367..1d3a0a4 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSLTDHealthcareRecordServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSLTDHealthcareRecordServiceImpl.java
@@ -1,12 +1,13 @@
 package com.smartor.service.impl;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.SysUserDept;
 import com.ruoyi.common.core.domain.entity.SysUserRole;
-import com.ruoyi.common.utils.DtoConversionUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpUtils;
 import com.smartor.domain.*;
@@ -14,21 +15,21 @@
 import com.smartor.service.IPatArchiveService;
 import com.smartor.service.IPatMedInhospService;
 import com.smartor.service.IServiceSLTDHealthcareRecordService;
-import com.sun.org.apache.bcel.internal.generic.NEW;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 
-import java.lang.reflect.Array;
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @Service
@@ -58,6 +59,9 @@
     @Autowired
     private SysUserRole2Mapper sysUserRoleMapper;
 
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
     @Value("${sltd_pub_path}")
     private String sltdPubPath;
 
@@ -67,15 +71,15 @@
     @Override
     public List<ServiceSLTDInhospResDTO> queryHealthcareRecordList(ServiceSLTDInhospReqVO reqVO) {
         try {
-            log.info("銆恞ueryHealthcareRecordList銆戝紑濮嬭皟鐢ㄧ渷绔嬪悓寰峰仴搴疯褰曟煡璇㈡帴鍙o紝璇锋眰鍙傛暟锛歿}", reqVO);
             Map<String, Object> requestParams = buildRequestParams(reqVO);
             Map<String, String> headers = buildRequestHeaders();
-
             String result = HttpUtils.sendPostByHeader(sltdPubPath + "osj/hbos-thirdparty-integration/standard/common/healthcareRecord/dtcQueryHealthcareRecordList", new Gson().toJson(requestParams), headers);
-            log.info("銆恞ueryHealthcareRecordList銆戞帴鍙e搷搴旂粨鏋滐細{}", result);
 
             String cry = determineCry(reqVO);
-            return parseResponseData(result, reqVO.getHealthcareRecordTypeList(), cry, reqVO.getCampusId());
+            log.info("cry鐨勫�间负锛歿}", cry);
+            List<ServiceSLTDInhospResDTO> serviceSLTDInhospResDTOS = parseResponseData(result, CollectionUtils.isNotEmpty(reqVO.getStatusList()) ? reqVO.getStatusList() : reqVO.getHealthcareRecordTypeList(), cry, reqVO.getCampusId() != null ? reqVO.getCampusId().toString() : null);
+            log.info("serviceSLTDInhospResDTOS鏄惁杩斿洖鐨勬湁鍊硷細{}", CollectionUtils.isNotEmpty(serviceSLTDInhospResDTOS) ? "鏈�" : "娌℃湁");
+            return serviceSLTDInhospResDTOS;
         } catch (Exception e) {
             log.error("銆恞ueryHealthcareRecordList銆戣皟鐢ㄧ渷绔嬪悓寰峰仴搴疯褰曟煡璇㈡帴鍙e紓甯革紝璇锋眰鍙傛暟锛歿}", reqVO, e);
             throw new RuntimeException("璋冪敤鐪佺珛鍚屽痉鍋ュ悍璁板綍鏌ヨ鎺ュ彛澶辫触", e);
@@ -120,7 +124,7 @@
 
             Map<String, String> headers = buildRequestHeaders();
             String result = HttpUtils.sendPostByHeader(sltdPubPath + "/osj/hbos-thirdparty-integration/standard/common/dept/queryDeptList", new Gson().toJson(params), headers);
-            log.info("銆恞ueryDeptWardAreaInfoList銆戞帴鍙e搷搴旂粨鏋滐細{}", result);
+            log.info("銆恞ueryDeptWardAreaInfoList銆戞帴鍙e搷搴旂粨鏋滐細{}", StringUtils.isEmpty(result) ? "绌虹殑" : "涓嶇┖");
             List<Map<String, Object>> dataList = getDataList(result);
             log.info("-----------dataList鎺ュ彛鍝嶅簲缁撴灉锛歿}", dataList.size());
             for (Map<String, Object> dataItem : dataList) {
@@ -172,6 +176,20 @@
         return true;
     }
 
+    @Override
+    public void aa(Map<String, Object> map) {
+        List<String> types = new ArrayList<>();
+        types.add("FH0109.27");
+        ObjectMapper objectMapper = new ObjectMapper();
+        try {
+            String jsonString = objectMapper.writeValueAsString(map);
+            parseResponseData(jsonString, types, "1", "20001001");
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+
+    }
+
 
     /**
      * 閲囬泦鍖婚櫌鐢ㄦ埛淇℃伅
@@ -184,7 +202,7 @@
         Map<String, Object> requestParams = buildRequestParams(reqVO);
         Map<String, String> headers = buildRequestHeaders();
         String result = HttpUtils.sendPostByHeader(sltdPubPath + "/osj/hbos-thirdparty-integration/standard/common/staff/queryStaffList", new Gson().toJson(requestParams), headers);
-        log.info("銆恞ueryHealthcareRecordList銆戞帴鍙e搷搴旂粨鏋滐細{}", result);
+        log.info("銆恞ueryHealthcareRecordList銆戞帴鍙e搷搴旂粨鏋滄槸鍚︽湁鍊硷細{}", StringUtils.isEmpty(result) ? "娌″��" : "鏈夊��");
         List<Map<String, Object>> dataList = getDataList(result);
         for (Map<String, Object> dataItem : dataList) {
             SysUser sysUser = new SysUser();
@@ -314,12 +332,17 @@
     }
 
     private String determineCry(ServiceSLTDInhospReqVO reqVO) {
-        if (reqVO.getHealthcareRecordTypeList().contains("FH0108.02")) {
-            if (reqVO.getStartHeadTime() != null && reqVO.getStartTailTime() != null) {
-                return "0";
-            } else if (StringUtils.isNotEmpty(reqVO.getPreOutHospitalHeadDate()) && StringUtils.isNotEmpty(reqVO.getPreOutHospitalTailDate())) {
-                return "1";
-            }
+        if (CollectionUtils.isEmpty(reqVO.getStatusList())) return null;
+
+        if (reqVO.getStatusList().contains("FH0109.26")) {
+            //鍏ラ櫌
+            return "0";
+        } else if (reqVO.getStatusList().contains("FH0109.27")) {
+            //鍑洪櫌
+            return "1";
+        } else if (reqVO.getStatusList().contains("FH0109.22") || reqVO.getStatusList().contains("FH0109.23") || reqVO.getStatusList().contains("FH0109.53")) {
+            //棰勫叆闄�
+            return "3";
         }
         return null;
     }
@@ -353,6 +376,9 @@
         if (reqVO.getHealthcareRecordTypeList() != null && !reqVO.getHealthcareRecordTypeList().isEmpty()) {
             params.put("healthcareRecordTypeList", reqVO.getHealthcareRecordTypeList());
         }
+        if (reqVO.getStatusList() != null && !reqVO.getStatusList().isEmpty()) {
+            params.put("statusList", reqVO.getStatusList());
+        }
         params.put("subjectCode", reqVO.getPatientName());
         params.put("healthcareRecordNo", reqVO.getHealthcareRecordNo());
         params.put("orgSubjectCode", reqVO.getIdCardNo());
@@ -361,7 +387,8 @@
         }
         params.put("serviceScopes", null);
         params.put("inpatientArea", null);
-        params.put("status", reqVO.getStatusList() != null && !reqVO.getStatusList().isEmpty() ? reqVO.getStatusList().get(0) : null);
+//        params.put("status", reqVO.getStatusList() != null && !reqVO.getStatusList().isEmpty() ? reqVO.getStatusList().get(0) : null);
+        params.put("status", null);
         return params;
     }
 
@@ -372,9 +399,8 @@
         return headers;
     }
 
-    private List<ServiceSLTDInhospResDTO> parseResponseData(String result, List<String> types, String cry, Long orgid) {
+    private List<ServiceSLTDInhospResDTO> parseResponseData(String result, List<String> types, String cry, String campusId) {
         try {
-
             List<Map<String, Object>> dataList = getDataList(result);
             List<ServiceSLTDInhospResDTO> resultList = new ArrayList<>();
             for (Map<String, Object> dataItem : dataList) {
@@ -382,7 +408,7 @@
             }
             log.info("銆恜arseResponseData銆戞垚鍔熻В鏋恵}鏉″仴搴疯褰曟暟鎹�", resultList.size());
 
-            processResultList(resultList, types, cry, orgid);
+            processResultList(resultList, types, cry, campusId);
             return resultList;
         } catch (Exception e) {
             log.error("銆恜arseResponseData銆戣В鏋愬搷搴旀暟鎹紓甯革紝鍝嶅簲鍐呭锛歿}", result, e);
@@ -412,48 +438,83 @@
         Type listType = new TypeToken<List<Map<String, Object>>>() {
         }.getType();
         List<Map<String, Object>> dataList = gson.fromJson(dataJson, listType);
+
+        // 浣跨敤 Set 鍘婚噸锛岀‘淇濇病鏈夐噸澶嶇殑鏁版嵁
+        Set<Map<String, Object>> uniqueDataSet = new HashSet<>(dataList);
+        dataList = new ArrayList<>(uniqueDataSet);
         return dataList;
     }
 
-    private void processResultList(List<ServiceSLTDInhospResDTO> resultList, List<String> types, String cry, Long orgid) {
+    private void processResultList(List<ServiceSLTDInhospResDTO> resultList, List<String> types, String cry, String campusId) {
         for (String type : types)
             switch (type) {
                 case "FH0108.01":
                     log.info("銆恜arseResponseData銆戣В鏋愰棬璇婃暟鎹�");
-                    outHospitalDate(resultList, orgid);
+                    outHospitalDate(resultList);
                     break;
-                case "FH0108.02":
+                case "FH0109.26":
                     log.info("銆恜arseResponseData銆戣В鏋愪綇闄㈡暟鎹�");
-                    inHospitalDate(resultList, cry, orgid);
+                    inHospitalDate(resultList, cry);
                     break;
-                case "FH0108.03":
-                    log.info("銆恜arseResponseData銆戣В鏋愭�ヨ瘖鏁版嵁");
-                    outHospitalDate(resultList, orgid);
+                case "FH0109.22":
+                    log.info("銆恜arseResponseData銆戣В鏋愰浣忛櫌鏁版嵁");
+                    inHospitalDate(resultList, cry);
                     break;
+                case "FH0109.23":
+                    log.info("銆恜arseResponseData銆戣В鏋愰浣忛櫌锛堝緟瀹夊簥锛夋暟鎹�");
+                    inHospitalDate(resultList, cry);
+                    break;
+                case "FH0109.27":
+                    log.info("銆恜arseResponseData銆戣В鏋愬嚭闄㈡暟鎹�");
+                    inHospitalDate(resultList, cry);
+                    break;
+                case "FH0109.53":
+                    log.info("銆恜arseResponseData銆戣В鏋愰浣忛櫌锛堝叾浠栵級鏁版嵁");
+                    inHospitalDate(resultList, cry);
+                    break;
+//                case "FH0108.03":
+//                    log.info("銆恜arseResponseData銆戣В鏋愭�ヨ瘖鏁版嵁");
+//                    outHospitalDate(resultList);
+//                    break;
                 default:
                     log.warn("銆恜arseResponseData銆戞湭鐭ョ殑鏁版嵁绫诲瀷锛歿}", type);
                     break;
             }
     }
 
-    private Boolean outHospitalDate(List<ServiceSLTDInhospResDTO> resultList, Long orgid) {
+    private Boolean outHospitalDate(List<ServiceSLTDInhospResDTO> resultList) {
+        List<PatMedOuthosp> batchList = new ArrayList<>();
+        
         for (ServiceSLTDInhospResDTO dto : resultList) {
-            if (Objects.isNull(dto)) continue;
-            PatArchive patArchive = processPatientArchive(dto, orgid);
-            PatMedOuthosp patMedOuthosp = buildPatMedOuthosp(dto, patArchive, orgid);
-//            //鏌ヨ褰撳墠鏂板鐨勯棬鎬ヨ瘖鏁版嵁锛屾槸鍚﹀湪杩囨浮琛ㄤ腑鏄惁瀛樺湪锛屽鏋滃瓨鍦紝灏变笉寰�闂ㄦ�ヨ瘖琛ㄩ噷鏂板浜�(杩欎釜鍏堜笉鍐欎簡锛屾娊绌轰簡鍐嶅啓)
-//            PatMedOuthospProvisional pmop = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatMedOuthospProvisional.class);
-
-            //鍏堟煡璇竴涓嬶紝鏄笉鏄凡缁忓瓨鍦ㄨ娴佹按鍙蜂簡锛屽鏋滃瓨鍦紝灏变笉鏂板浜�
-            PatMedOuthosp pmo2 = new PatMedOuthosp();
-            pmo2.setSerialnum(patMedOuthosp.getSerialnum());
-            List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(pmo2);
-            if (CollectionUtils.isEmpty(patMedOuthosps)) patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp);
+            if (Objects.isNull(dto)) {
+                continue;
+            }
+            PatArchive patArchive = processPatientArchive(dto);
+            PatMedOuthosp patMedOuthosp = buildPatMedOuthosp(dto, patArchive);
+            batchList.add(patMedOuthosp);
+        }
+        
+        // 鎵归噺鎻掑叆锛岃嚜鍔ㄥ拷鐣ラ噸澶�
+        if (CollectionUtils.isNotEmpty(batchList)) {
+            try {
+                int insertCount = patMedOuthospMapper.batchInsertIgnore(batchList);
+                log.info("鎵归噺鎻掑叆闂ㄦ�ヨ瘖璁板綍锛屾�绘暟锛歿}, 瀹為檯鎻掑叆锛歿}", batchList.size(), insertCount);
+            } catch (Exception e) {
+                log.error("鎵归噺鎻掑叆闂ㄦ�ヨ瘖璁板綍澶辫触", e);
+                // 闄嶇骇涓洪�愭潯鎻掑叆
+                for (PatMedOuthosp patMedOuthosp : batchList) {
+                    try {
+                        patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp);
+                    } catch (Exception ex) {
+                        log.warn("鍗曟潯鎻掑叆澶辫触锛歴erialnum={}", patMedOuthosp.getSerialnum());
+                    }
+                }
+            }
         }
         return true;
     }
 
-    private PatMedOuthosp buildPatMedOuthosp(ServiceSLTDInhospResDTO dto, PatArchive patArchive, Long orgid) {
+    private PatMedOuthosp buildPatMedOuthosp(ServiceSLTDInhospResDTO dto, PatArchive patArchive) {
         PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
         patMedOuthosp.setOuthospno(dto.getHealthcareRecordNo());
         patMedOuthosp.setSerialnum(dto.getHealthcareRecordNo());
@@ -488,46 +549,134 @@
         }
     }
 
-    private Boolean inHospitalDate(List<ServiceSLTDInhospResDTO> resultList, String cry, Long orgid) {
+    private Boolean inHospitalDate(List<ServiceSLTDInhospResDTO> resultList, String cry) {
         for (ServiceSLTDInhospResDTO dto : resultList) {
             if (Objects.isNull(dto)) continue;
-            PatArchive patArchive = processPatientArchive(dto, orgid);
-            processPatientInhospInfo(dto, patArchive, cry, orgid);
+            PatArchive patArchive = processPatientArchive(dto);
+            processPatientInhospInfo(dto, patArchive, cry);
         }
         return true;
     }
 
-    private void processPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry, Long orgid) {
-        PatMedInhosp patMedInhosp = buildPatientInhospInfo(dto, patArchive, cry, orgid);
+    private void processPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry) {
+        PatMedInhosp patMedInhosp = buildPatientInhospInfo(dto, patArchive, cry);
         PatMedInhosp queryInhosp = new PatMedInhosp();
-        queryInhosp.setPatno(patArchive.getPatientno());
-        queryInhosp.setSerialnum(patMedInhosp.getSerialnum());
-        queryInhosp.setOrgid(dto.getOrgId());
-        queryInhosp.setCampusid(dto.getCampusId());
+        queryInhosp.setPatno(StringUtils.trim(patArchive.getPatientno()));
+        queryInhosp.setSerialnum(StringUtils.trim(patMedInhosp.getSerialnum()));
+        queryInhosp.setOrgid(StringUtils.trim(dto.getOrgId()));
         queryInhosp.setInhospstate(cry);
-        log.info("----------------杩欓噷鐨勫叆鍙備负锛歿}", queryInhosp);
+        log.info("----------------杩欓噷鐨勫叆鍙備负锛歿},{}", queryInhosp.getPatno(), queryInhosp.getSerialnum());
         List<PatMedInhosp> existingInhosps = patMedInhospService.selectPatMedInhosp(queryInhosp);
 
-        if (cry.equals("0") && CollectionUtils.isNotEmpty(existingInhosps)) {
-            //鏂板杩囩殑鍏ラ櫌鏁版嵁锛屼笉鍐嶅鐞�
-            return;
-        } else if (cry.equals("1") && CollectionUtils.isNotEmpty(existingInhosps)) {
-            //鏂板杩囩殑鍑洪櫌鏁版嵁锛屼篃涓嶅啀澶勭悊
-            return;
-        }
+        if (cry.equals("0")) {
+            //鍏ラ櫌鏁版嵁澶勭悊
+            if (CollectionUtils.isEmpty(existingInhosps)) {
+                //濡傛灉涓虹┖锛岃鍏堝垽鏂紝棰勫叆闄㈡槸鍚︽湁鍊硷紝鏈夊�肩殑璇濆垯鏇存柊
+                queryInhosp.setInhospstate("3");
+                List<PatMedInhosp> patMedInhospList = patMedInhospService.selectPatMedInhosp(queryInhosp);
+                if (CollectionUtils.isNotEmpty(patMedInhospList)) {
+                    //濡傛灉棰勫叆闄笉涓虹┖锛屽垯杩涜淇敼
+                    patMedInhospService.updatePatMedInhosp(patMedInhosp);
+                } else {
+                    //濡傛灉鍑洪櫌涓嶄负绌猴紝鍒欎笉杩涜澶勭悊
+                    queryInhosp.setInhospstate("1");
+                    patMedInhospList = patMedInhospService.selectPatMedInhosp(queryInhosp);
+                    if (CollectionUtils.isNotEmpty(patMedInhospList)) {
+                        return;
+                    }
+                }
 
-        log.info("----------------杩欓噷鐨勮繑鍙備负锛歿}", existingInhosps);
-        if (CollectionUtils.isNotEmpty(existingInhosps)) {
-            patMedInhosp.setInhospid(existingInhosps.get(0).getInhospid());
-            patMedInhospService.updatePatMedInhosp(patMedInhosp);
-            log.debug("銆恜rocessPatientInhospInfo銆戞洿鏂颁綇闄俊鎭紝鎮h�呯紪鍙凤細{}锛屾祦姘村彿锛歿}", patArchive.getPatientno(), patMedInhosp.getSerialnum());
-        } else {
-            patMedInhospService.insertPatMedInhosp(patMedInhosp);
-            log.debug("銆恜rocessPatientInhospInfo銆戞柊澧炰綇闄俊鎭紝鎮h�呯紪鍙凤細{}锛屾祦姘村彿锛歿}", patArchive.getPatientno(), patMedInhosp.getSerialnum());
+                //濡傛灉閮戒负绌猴紝鍒欒繘琛屾柊澧�
+                if (CollectionUtils.isEmpty(patMedInhospList)) {
+                    try {
+                        patMedInhospService.insertPatMedInhosp(patMedInhosp);
+                    } catch (org.springframework.dao.DuplicateKeyException e) {
+                        log.warn("鍏ラ櫌璁板綍宸插瓨鍦紝璺宠繃锛歴erialnum={}, orgid={}, state={}", patMedInhosp.getSerialnum(), patMedInhosp.getOrgid(), patMedInhosp.getInhospstate());
+                    }
+                }
+            }
+
+        } else if (cry.equals("1")) {
+//           鍑洪櫌鏁版嵁澶勭悊
+            if (CollectionUtils.isEmpty(existingInhosps)) {
+                //濡傛灉涓虹┖锛岃鍏堝垽鏂紝棰勫叆闄㈡槸鍚︽湁鍊硷紝鏈夊�肩殑璇濆垯鏇存柊
+                queryInhosp.setInhospstate("3");
+                log.info("-----patMedInhospList杩涙潵浜嗕笉锛熷叆鍙備负锛歿}", queryInhosp);
+                List<PatMedInhosp> patMedInhospList = patMedInhospService.selectPatMedInhosp(queryInhosp);
+                log.info("----patMedInhospList杩涙潵浜嗕笉锛熻繑鍙備负锛歿}", CollectionUtils.isEmpty(patMedInhospList) ? null : patMedInhospList.get(0).getSerialnum());
+                if (CollectionUtils.isNotEmpty(patMedInhospList)) {
+                    //濡傛灉棰勫叆闄笉涓虹┖锛屽垯杩涜淇敼
+                    patMedInhospService.updatePatMedInhosp(patMedInhosp);
+                } else {
+                    //濡傛灉鍏ラ櫌涓嶄负绌猴紝鍒欒繘琛屼慨鏀�
+                    queryInhosp.setInhospstate("0");
+                    patMedInhospList = patMedInhospService.selectPatMedInhosp(queryInhosp);
+                    if (CollectionUtils.isNotEmpty(patMedInhospList)) {
+                        patMedInhospService.updatePatMedInhosp(patMedInhosp);
+                    }
+                }
+
+                //濡傛灉閮戒负绌猴紝鍒欒繘琛屾柊澧�
+                if (CollectionUtils.isEmpty(patMedInhospList)) {
+                    //濡傛灉鍏ラ櫌涓嶄负绌猴紝鍒欒繘琛屼慨鏀�
+                    queryInhosp.setInhospstate("0");
+                    log.debug("鍑洪櫌queryInhosp鍏ュ弬涓猴細{}", queryInhosp);
+                    List<PatMedInhosp> patMedInhosps = patMedInhospService.selectPatMedInhosp(queryInhosp);
+                    log.debug("鍑洪櫌patMedInhospList杩斿弬涓猴細{}", CollectionUtils.isEmpty(patMedInhosps) ? null : patMedInhosps.size());
+                    if (CollectionUtils.isNotEmpty(patMedInhosps)) {
+                        patMedInhospService.updatePatMedInhosp(patMedInhosp);
+                    } else {
+                        try {
+                            patMedInhospService.insertPatMedInhosp(patMedInhosp);
+                        } catch (org.springframework.dao.DuplicateKeyException e) {
+                            log.warn("鍑洪櫌璁板綍宸插瓨鍦紝璺宠繃锛歴erialnum={}, orgid={}, state={}", patMedInhosp.getSerialnum(), patMedInhosp.getOrgid(), patMedInhosp.getInhospstate());
+                        }
+                    }
+                }
+            }
+        } else if ("3".equals(cry)) {
+            //棰勫叆闄㈡暟鎹鐞嗭細浠讳竴鐘舵�佸瓨鍦ㄥ垯涓嶆柊澧烇紱閮戒笉瀛樺湪鎵嶆柊澧�
+            String serialnum = patMedInhosp.getSerialnum() == null ? "" : patMedInhosp.getSerialnum().trim();
+            String orgid = patMedInhosp.getOrgid() == null ? "" : patMedInhosp.getOrgid().trim();
+            String state = patMedInhosp.getInhospstate() == null ? "" : patMedInhosp.getInhospstate();
+            String lockKey = "inhosp:lock:" + serialnum + ":" + orgid + ":" + state;
+
+            Boolean locked = false;
+            try {
+                locked = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", 10, TimeUnit.SECONDS);
+            } catch (Exception e) {
+                log.warn("Redis閿佽幏鍙栧け璐ワ紝闄嶇骇涓虹洿鎺ユ彃鍏ワ細{}", e.getMessage());
+                locked = null; // 鏍囪Redis涓嶅彲鐢�
+            }
+
+            if (locked == null || Boolean.TRUE.equals(locked)) {
+                try {
+                    queryInhosp.setInhospstate(null);
+                    List<PatMedInhosp> patMedInhospList3 = patMedInhospService.selectPatMedInhosp(queryInhosp);
+                    if (CollectionUtils.isEmpty(patMedInhospList3)) {
+                        try {
+                            patMedInhospService.insertPatMedInhosp(patMedInhosp);
+                            log.debug("鎴愬姛鎻掑叆棰勫叆闄㈣褰曪細serialnum={}", patMedInhosp.getSerialnum());
+                        } catch (Exception e) {
+                            log.warn("棰勫叆闄㈣褰曟彃鍏ュけ璐ワ紙鍙兘宸插瓨鍦級锛歴erialnum={}, orgid={}, state={}, 閿欒锛歿}", patMedInhosp.getSerialnum(), patMedInhosp.getOrgid(), patMedInhosp.getInhospstate(), e.getMessage());
+                        }
+                    }
+                } finally {
+                    if (Boolean.TRUE.equals(locked)) {
+                        try {
+                            redisTemplate.delete(lockKey);
+                        } catch (Exception e) {
+                            log.warn("Redis閿侀噴鏀惧け璐ワ細{}", e.getMessage());
+                        }
+                    }
+                }
+            } else {
+                log.debug("棰勫叆闄㈣褰曟鍦ㄨ鍏朵粬绾跨▼澶勭悊锛岃烦杩囷細serialnum={}", patMedInhosp.getSerialnum());
+            }
         }
     }
 
-    private PatMedInhosp buildPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry, Long orgid) {
+    private PatMedInhosp buildPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry) {
         log.info("----------------buildPatientInhospInfo杩欓噷杩涙潵浜嗗悧锛焮}", cry);
         PatMedInhosp patMedInhosp = new PatMedInhosp();
         patMedInhosp.setPatid(patArchive.getId());
@@ -539,6 +688,7 @@
         patMedInhosp.setFuflag("1");
         if ("0".equals(cry)) patMedInhosp.setInhospstate("0");
         if ("1".equals(cry)) patMedInhosp.setInhospstate("1");
+        if ("3".equals(cry)) patMedInhosp.setInhospstate("3");
         patMedInhosp.setHospitalcode(dto.getOrgId());
         patMedInhosp.setBedNo(dto.getBedNumber());
         patMedInhosp.setStarttime(parseDate(dto.getStartTime()));
@@ -582,12 +732,12 @@
         patMedInhosp.setHospitaldistrictname(dto.getAreaName());
     }
 
-    private PatArchive processPatientArchive(ServiceSLTDInhospResDTO dto, Long orgid) {
+    private PatArchive processPatientArchive(ServiceSLTDInhospResDTO dto) {
         PatArchive queryArchive = new PatArchive();
         queryArchive.setIdcardno(StringUtils.isEmpty(dto.getIdCardNo()) ? "" + dto.getMedicalCardId() : dto.getIdCardNo().trim());
         List<PatArchive> existingArchives = patArchiveService.selectPatArchiveList(queryArchive);
 
-        PatArchive patArchive = buildPatientArchive(dto, orgid);
+        PatArchive patArchive = buildPatientArchive(dto);
 
         if (CollectionUtils.isEmpty(existingArchives)) {
             patArchiveService.insertPatArchive(patArchive);
@@ -601,7 +751,7 @@
         return patArchive;
     }
 
-    private PatArchive buildPatientArchive(ServiceSLTDInhospResDTO dto, Long orgid) {
+    private PatArchive buildPatientArchive(ServiceSLTDInhospResDTO dto) {
         PatArchive patArchive = new PatArchive();
         patArchive.setPatientno("" + dto.getPatientId());
         patArchive.setIdcardno(StringUtils.isEmpty(dto.getIdCardNo()) ? "" + dto.getMedicalCardId() : dto.getIdCardNo().trim());
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
index 2b8408b..4b0e5c3 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
@@ -177,7 +177,7 @@
             if (key.contains("-WJscriptCache")) {
                 List<SvyTaskTemplateScriptVO> cacheList = redisCache.getCacheList(key);
                 cacheList.sort(Comparator.comparingLong(SvyTaskTemplateScriptVO::getSort));
-                log.error("闂嵎鍥炵瓟缁撴灉锛歿}", cacheList);
+                log.info("闂嵎鍥炵瓟缁撴灉锛歿}", cacheList);
                 for (int i = 0; i < cacheList.size(); i++) {
                     if (i == 0) {
                         //杩欎釜鏃堕棿瑕佹壘鍒扮涓�棰�
@@ -683,6 +683,7 @@
         }
         ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(taskid);
         serviceSubtaskDetailVO.setQuestiontext(svyTaskTemplateScriptVO.getScriptContent());
+        serviceSubtaskDetailVO.setCategoryid(svyTaskTemplateScriptVO.getCategoryid());
         serviceSubtaskDetailVO.setTaskid(Long.valueOf(taskid));
         serviceSubtaskDetailVO.setTargetid(svyTaskTemplateScriptVO.getTargetid() != null ? svyTaskTemplateScriptVO.getTargetid().intValue() : null);
         serviceSubtaskDetailVO.setPatid(Long.valueOf(patid));
@@ -717,6 +718,8 @@
     private Boolean sendTaskIds(List<Integer> sendTaskids, ServiceSubtask serviceSubtask) {
         for (Integer taskId : sendTaskids) {
             ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(Long.valueOf(taskId));
+            if (Objects.isNull(serviceTask)) return false;
+
             String content = sendMQContent(serviceTask, null);
             //鍏堟煡璇竴涓嬶紝璇ユ偅鑰呭湪璇ervice_task涓紝鏄惁宸茬粡瀛樺湪,濡傛灉宸茬粡瀛樺湪锛屽垯涓嶇敤鍐嶄繚瀛樹簡
             ServiceSubtask ss = new ServiceSubtask();
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 f7f9db7..3c14caa 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -1,7 +1,6 @@
 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.ObjectMapper;
 import com.google.gson.Gson;
@@ -14,20 +13,26 @@
 import com.smartor.domain.*;
 import com.smartor.mapper.*;
 import com.smartor.service.*;
+import com.sun.org.apache.bcel.internal.generic.NEW;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.redis.core.ListOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
-import java.time.*;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -76,6 +81,9 @@
 
     @Autowired
     private IvrLibaExtemplatescriptMapper ivrLibaExtemplatescriptMapper;
+
+    @Autowired
+    private ISvyTaskTemplateScriptService svyTaskTemplateScriptService;
 
     @Autowired
     private IIvrTaskTemplateService ivrTaskTemplateService;
@@ -145,6 +153,11 @@
     @Override
     public ServiceSubtask selectServiceSubtaskById(Long id) {
         return serviceSubtaskMapper.selectServiceSubtaskById(id);
+    }
+
+    @Override
+    public List<ServiceSubtask> selectServiceSubtaskByDiagname(ServiceSubtask serviceSubtask) {
+        return serviceSubtaskMapper.selectServiceSubtaskByDiagname(serviceSubtask);
     }
 
     /**
@@ -369,15 +382,18 @@
 
         if (patMedInhospList.size() > 0) {
             serviceSubtask1.setIsVisitAgain(2);
+            serviceSubtask1.setRemark(serviceSubtask1.getRemark()+";鎮h�呭啀鍏ラ櫌浜�");
             serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1);
             return "鏃犻渶鍐嶆闅忚锛屾偅鑰呭啀鍏ラ櫌浜�";
         } else if (serviceSubtask1.getSendstate() == 4L) {
             serviceSubtask1.setIsVisitAgain(2);
+            serviceSubtask1.setRemark(serviceSubtask1.getRemark()+";鏃犻渶鍐嶆闅忚锛屼换鍔¤鏍囪涓嶅湪鎵ц");
             serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1);
             return "鏃犻渶鍐嶆闅忚锛屼换鍔¤鏍囪涓嶅湪鎵ц";
         } else if (StringUtils.isNotEmpty(patArchive.getNotrequiredFlag()) && patArchive.getNotrequiredFlag().equals("1")) {
             serviceSubtask1.setIsVisitAgain(2);
             serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1);
+            serviceSubtask1.setRemark(serviceSubtask1.getRemark()+";鏃犻渶鍐嶆闅忚锛屾偅鑰呰鏍囪涓嶉渶瑕佽鏈嶅姟");
             return "鏃犻渶鍐嶆闅忚锛屾偅鑰呰鏍囪涓嶉渶瑕佽鏈嶅姟";
         } else if (ObjectUtils.isNotEmpty(serviceSubtask1.getIsVisitAgain()) && serviceSubtask1.getIsVisitAgain() == 2) {
             return "鏃犻渶鍐嶆闅忚锛岃浠诲姟宸茬粡鍐嶆闅忚杩囦簡";
@@ -586,6 +602,7 @@
                     serviceSubtask.setAddr(patTaskRelevance.getAddr());
                     serviceSubtask.setPatid(patTaskRelevance.getPatid());
                     serviceSubtask.setCreateTime(DateUtils.getNowDate());
+                    serviceSubtask.setInhospid(patTaskRelevance.getHospid());
                     serviceSubtask.setSendstate(1L);
                     if (serviceTaskVO.getLongTask() != null && serviceTaskVO.getLongTask() == 1)
                         serviceSubtask.setSendstate(2L);
@@ -654,7 +671,7 @@
                 for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
                     log.error("sfSend闇�瑕佺Щ闄ょ殑subId涓猴細{}", serviceSubtask.getId().toString());
                     serviceSubtaskMapper.deleteServiceSubtaskById(serviceSubtask.getId());
-                    redisCache.removeElementFromList("cache-exist", serviceSubtask.getId().toString());
+//                    redisCache.removeElementFromList("cache-exist", serviceSubtask.getId().toString());
                     redisCache.removeElementFromList("cache-0", serviceSubtask.getId().toString());
                     redisCache.removeElementFromList("cache-1", serviceSubtask.getId().toString());
                     redisCache.removeElementFromList("cache-2", serviceSubtask.getId().toString());
@@ -1134,7 +1151,7 @@
     @Override
     public PhoneCallBackYQVO phoneCallBackYQ(PhoneCallReqYQVO phoneCallReqYQVO) {
         //鍏堟妸璇ubId浠巆ache_exist涓墧闄わ紝鍙鏈夊洖璋冨氨鍓旈櫎锛堢洰鐨勬槸锛屽敖蹇cache-exist涓虹┖锛屽幓缂撳瓨涓嬩竴鎵硅鎵撶殑鐢佃瘽;杩欓噷鍓旈櫎涓嶅奖鍝嶇數璇濈殑姝e父涓氬姟锛�
-        redisCache.removeElementFromList("cache-exist", phoneCallReqYQVO.getTaskid());
+//        redisCache.removeElementFromList("cache-exist", phoneCallReqYQVO.getTaskid());
 
         //鍒ゆ柇鏄惁鎸傛満
         String hangupState = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- hangup");
@@ -1793,8 +1810,8 @@
         List<String> cacheList = new ArrayList<>();
         ListOperations<String, String> listOps = redisTemplate.opsForList();
         //蹇呴』绛塧che-exist鍏ㄩ儴鎵撳畬鎵嶈兘鎷夊彇涓嬩竴鎵癸紙涓昏鏄�曟墍鏈夌殑鏁版嵁閮藉爢鍦ㄧ數璇濈殑缂撳瓨閲岋紝鍦ㄨ瀹氱殑鏃堕棿鎵撲笉瀹岋級
-        long existSize = listOps.size("cache-exist");
-        if (existSize > 0) return pullTaskVOList;
+//        long existSize = listOps.size("cache-exist");
+//        if (existSize > 0) return pullTaskVOList;
         int count = 0;
         long size = listOps.size("cache-0");
         log.error("---------鎵撶數璇濅箣鍓嶇紦瀛樹腑鐨勬暟鎹噺锛歿}", size);
@@ -1804,17 +1821,18 @@
             count = Math.min(phoneCount(), (int) size);
             if (count != 0) {
                 cacheList = listOps.range("cache-0", 0, count - 1);
+            } else {
+                return null;
             }
         }
 
-
-        log.error("浠诲姟鎷夊彇cache-0鐨勫�兼槸澶氬皯锛歿}", cacheList);
+        log.info("浠诲姟鎷夊彇cache-0鐨勫�兼槸澶氬皯锛歿}", cacheList);
         //  cache-0涓虹珛鍗冲彂璧风殑,鍏跺畠鐨勫厛鎺ㄨ繜
         if (!CollectionUtils.isEmpty(cacheList)) {
             pullTaskVOList = getPullTaskList(cacheList, "cache-0");
             // 鍒犻櫎宸插鐞嗙殑鏁版嵁
             listOps.trim("cache-0", count, -1);
-            log.error("鎵撶數璇濅箣鍚庣紦瀛樹腑鐨勬暟鎹噺---------锛歿}", listOps.size("cache-0"));
+            log.info("鎵撶數璇濅箣鍚庣紦瀛樹腑鐨勬暟鎹噺---------锛歿}", listOps.size("cache-0"));
         } else {
             for (int i = 1; i < 6; i++) {
                 //鍙栧嚭浠巆ache-1 鍒� cache-5鐨勭涓�涓瓙浠诲姟淇℃伅
@@ -1836,15 +1854,15 @@
             }
         }
         //existList鐢ㄦ潵璁板綍鎺ヤ笅鏉ラ渶瑕佹墽琛岀殑瀛愪换鍔D
-        List<String> existList = new ArrayList<>();
+//        List<String> existList = new ArrayList<>();
         if (CollectionUtils.isNotEmpty(pullTaskVOList)) {
             //缁欏洖璋冨弬鏁拌祴鍊�
             for (PullTaskVO pullTaskVO : pullTaskVOList) {
-                existList.add(pullTaskVO.getTaskid());
+//                existList.add(pullTaskVO.getTaskid());
                 pullTaskVO.setAsrcallback(ASRCallBackPath);
             }
         }
-        if (existList.size() != 0) redisCache.setCacheListRight("cache-exist", existList);
+//        if (existList.size() != 0) redisCache.setCacheListRight("cache-exist", existList);
         log.error("-----------瀹為檯鎷夊彇鐨勭數璇濇暟鎹噺锛歿}", CollectionUtils.isNotEmpty(pullTaskVOList) ? pullTaskVOList.size() : null);
         return pullTaskVOList;
     }
@@ -1938,6 +1956,13 @@
             }
             //闅忚
             for (ServiceSubtaskDetail serviceSubtaskDetail : serviceSubTaskDetailReq.getServiceSubtaskDetailList()) {
+                if (serviceSubtaskDetail.getScriptid() != null) {
+                    //璁剧疆涓�涓嬮棶棰樺垎绫�
+                    IvrTaskTemplateScript ivrTaskTemplateScript = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptByID(serviceSubtaskDetail.getScriptid());
+                    if (ivrTaskTemplateScript != null)
+                        serviceSubtaskDetail.setCategoryid(ivrTaskTemplateScript.getAssortid());
+                }
+
                 serviceSubtaskDetail.setSubId(selectServiceSubtaskList.get(0).getId());
 //                serviceSubtaskDetail.setId(UUID.randomUUID().toString());
                 serviceSubtaskDetail.setCreateTime(new Date());
@@ -1949,6 +1974,12 @@
         } else {
             if (serviceSubTaskDetailReq != null && CollectionUtils.isNotEmpty(serviceSubTaskDetailReq.getServiceSubtaskDetailList())) {
                 for (ServiceSubtaskDetail serviceSubtaskDetail : serviceSubTaskDetailReq.getServiceSubtaskDetailList()) {
+                    if (serviceSubtaskDetail.getScriptid() != null) {
+                        //璁剧疆涓�涓嬮棶棰樺垎绫�
+                        IvrTaskTemplateScript ivrTaskTemplateScript = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptByID(serviceSubtaskDetail.getScriptid());
+                        if (ivrTaskTemplateScript != null)
+                            serviceSubtaskDetail.setCategoryid(ivrTaskTemplateScript.getAssortid());
+                    }
                     serviceSubtaskDetail.setCreateTime(new Date());
                     serviceSubtaskDetail.setGuid(serviceSubTaskDetailReq.getGuid());
                     serviceSubtaskDetail.setOrgid(serviceSubTaskDetailReq.getOrgid());
@@ -1991,7 +2022,7 @@
             //杩涜鐭俊琛ュ伩
 //            getSmsCompensate(Long.valueOf(phoneCallRecordVO.getTaskid()));
             redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup");
-            redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid());
+//            redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid());
         } else if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("2")) {
 //        if (phoneCallRecordVO.getAnswered() != null && phoneCallRecordVO.getAnswered() == true) {
             log.error("鏈変汉鎺ョ數璇濅簡锛屽苟涓斿畬浜�");
@@ -2014,7 +2045,7 @@
         } else {
             //鎮h�呮嫆缁濋殢璁�
             //鍏堟妸璇ubId浠巆ache_exist涓墧闄わ紝鍙鏈夊洖璋冨氨鍓旈櫎锛堢洰鐨勬槸锛屽敖蹇cache-exist涓虹┖锛屽幓缂撳瓨涓嬩竴鎵硅鎵撶殑鐢佃瘽;杩欓噷鍓旈櫎涓嶅奖鍝嶇數璇濈殑姝e父涓氬姟锛�
-            redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid());
+//            redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid());
             ServiceSubtask serviceSubtask = new ServiceSubtask();
             serviceSubtask.setRemark("鐢佃瘽鎺ラ�氭垚鍔燂紝鎮h�呮嫆缁濋殢璁�");
             serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid()));
@@ -2118,7 +2149,7 @@
             stringBuilder.append(timestamp + "涔嬪墠鎼哄甫鍖讳繚鍗℃垨鐢靛瓙鍖讳繚鍗¤韩浠借瘉鍑鏉$煭淇″埌1鍙锋ゼ3妤煎崡鍏ラ櫌鍑嗗涓績鍏ラ櫌鐧昏绐楀彛锛屽姙鐞嗘寮忎綇闄㈡墜缁紝瀹屾垚鍚勯」妫�鏌ュ悗鍐嶅埌鐩稿簲鐥呭尯鎶ゅ+绔欐姤鍒般��");
             stringBuilder.append("鍏ラ櫌鍑嗗涓績鐢佃瘽锛�89975977銆傚叆闄㈠姙鐞嗛』鐭�:https://mp.weixin.qq.com/s/OCkotuRyQ8Ld2owFF0YErw");
 
-            String data = MessageSend.sendMsg(stringBuilder.toString(), "2", patArchiveSrmVO.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
+            String data = MessageSend.sendMsg(stringBuilder.toString(), "6", patArchiveSrmVO.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
             if (StringUtils.isNotEmpty(data) && data.contains("result=0")) {
                 sendError.add(patArchiveSrmVO);
             }
@@ -2134,8 +2165,9 @@
      * @return
      */
     @Override
+    @Cacheable(value = "sfStatistics", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()")
     public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) {
-        log.error("getSfStatistics鐨勫叆鍙備负锛歿}", serviceSubtaskCountReq);
+        log.info("getSfStatistics鐨勫叆鍙備负锛歿}", serviceSubtaskCountReq);
         List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>();
 //        List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq);
 
@@ -2192,6 +2224,20 @@
         return serviceSubtaskStatistics;
     }
 
+    @Override
+    public List<ServiceSubtaskStatistic> getSfStatisticsExport(ServiceSubtaskCountReq serviceSubtaskCountReq) {
+        List<ServiceSubtaskStatistic> sfStatistics = getSfStatistics(serviceSubtaskCountReq);
+        // 娣诲姞鎬昏琛�
+        if (CollectionUtils.isNotEmpty(sfStatistics)) {
+            ServiceSubtaskStatistic totalRow = calculateTotalRow(sfStatistics);
+            totalRow.setLeavehospitaldistrictname("鎬昏");
+            totalRow.setDeptname("鎬昏");
+            sfStatistics.add(totalRow);
+        }
+
+        return sfStatistics;
+    }
+
     /**
      * 鑾峰彇闅忚缁熻姣斾緥
      *
@@ -2199,12 +2245,14 @@
      * @return
      */
     @Override
+    @Cacheable(value = "sfStatisticsJoy", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()")
     public List<ServiceSubtaskStatistic> getSfStatisticsJoy(ServiceSubtaskCountReq serviceSubtaskCountReq) {
         log.error("getSfStatistics鐨勫叆鍙備负锛歿}", serviceSubtaskCountReq);
         List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>();
 
         // 鏍规嵁鏉′欢杩涜鍒嗙粍
         Map<String, List<ServiceSubtask>> collect = new HashMap<>();
+        String orgid = null;
 
         if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && serviceSubtaskCountReq.getLeavehospitaldistrictcodes().size() > 0) {
             if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
@@ -2226,13 +2274,10 @@
                 continue;
             }
             ServiceSubtaskStatistic statistic = getStatisticJoy(serviceSubtaskList, joySubCount);
-            if (statistic.getJoyCount() != 0 && statistic.getJoyAllCount() != 0) {
-                Double joyTotal = Double.parseDouble(statistic.getJoyCount() + "") / Double.parseDouble(statistic.getJoyAllCount() + "") * 100;
-                statistic.setJoyTotal(String.format("%.2f", joyTotal) + "%");
-            }
             //鍙婃椂鐜�
             ServiceSubtask ss = new ServiceSubtask();
-            ss.setOrgid(serviceSubtaskList.get(0).getOrgid());
+            orgid = serviceSubtaskList.get(0).getOrgid();
+            ss.setOrgid(orgid);
 
             // 濡傛灉鏈夊尰鐢熺紪鐮侊紝璁剧疆鍖荤敓缂栫爜鐢ㄤ簬鍙婃椂鐜囨煡璇�
             if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
@@ -2252,13 +2297,125 @@
             }
             Double jsRate = serviceSubtaskMapper.selectTimelyRate(ss);
             statistic.setRate(jsRate);
-
             if (ObjectUtils.isNotEmpty(statistic)) {
                 serviceSubtaskStatistics.add(statistic);
             }
         }
+        if (CollectionUtils.isNotEmpty(serviceSubtaskStatistics)) {
+            for (ServiceSubtaskStatistic serviceSubtaskStatistic : serviceSubtaskStatistics) {
+                //鎵�鏈夋弧鎰忓害鏁伴噺
+                if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getDeptcodes())) {
+                    Map<String, Object> satisfactionIndex = getSatisfactionIndex("1", serviceSubtaskStatistic.getDeptcode(), orgid, serviceSubtaskCountReq.getIvrCategoryid(), serviceSubtaskCountReq.getSvyCategoryid());
+                    serviceSubtaskStatistic.setJoyAllCount(satisfactionIndex.get("mydtmzl") != null ? (Integer) satisfactionIndex.get("mydtmzl") : 0);
+                    serviceSubtaskStatistic.setJoyCount(satisfactionIndex.get("mydtbl") != null ? (Integer) satisfactionIndex.get("mydtbl") : 0);
+                    serviceSubtaskStatistic.setJoyTotal((Double) satisfactionIndex.get("wcbl"));
+                } else if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getLeavehospitaldistrictcodes())) {
+                    Map<String, Object> satisfactionIndex = getSatisfactionIndex("2", serviceSubtaskStatistic.getLeavehospitaldistrictcode(), orgid, serviceSubtaskCountReq.getIvrCategoryid(), serviceSubtaskCountReq.getSvyCategoryid());
+                    serviceSubtaskStatistic.setJoyAllCount(satisfactionIndex.get("mydtmzl") != null ? (Integer) satisfactionIndex.get("mydtmzl") : 0);
+                    serviceSubtaskStatistic.setJoyCount(satisfactionIndex.get("mydtbl") != null ? (Integer) satisfactionIndex.get("mydtbl") : 0);
+                    serviceSubtaskStatistic.setJoyTotal((Double) satisfactionIndex.get("wcbl"));
+                }
+            }
+        }
+
         return serviceSubtaskStatistics;
     }
+
+    /**
+     * 鑾峰彇婊℃剰搴﹂鐩�婚噺
+     * type : 1-绉戝   2鐥呭尯
+     * code: 绉戝鎴栫梾鍖篶ode
+     *
+     * @return
+     */
+    private Map<String, Object> getSatisfactionIndex(String type, String code, String orgid, Long ivrCategoryid, Long svyCategoryid) {
+        Map<String, Object> map = new HashMap<>();
+        List<ServiceTask> serviceTasks = null;
+        if (type.equals("1")) {
+            ServiceTask serviceTask = new ServiceTask();
+            serviceTask.setDeptcode(code);
+            serviceTask.setOrgid(orgid);
+            serviceTasks = serviceTaskService.selectServiceTaskList(serviceTask);
+        } else if (type.equals("2")) {
+            ServiceTask serviceTask = new ServiceTask();
+            serviceTask.setLeavehospitaldistrictcode(code);
+            serviceTask.setOrgid(orgid);
+            serviceTasks = serviceTaskService.selectServiceTaskList(serviceTask);
+        }
+
+        //鑾峰彇婊℃剰搴﹂鐩�婚噺
+        BigDecimal mydtmzlsum = new BigDecimal(0);
+        //鑾峰彇婊℃剰搴﹂鐩~鎶ラ噺
+        BigDecimal mydtblsum = new BigDecimal(0);
+        if (CollectionUtils.isNotEmpty(serviceTasks)) {
+            //鑾峰彇婊℃剰搴﹂鐩�婚噺
+            for (ServiceTask serviceTask : serviceTasks) {
+                if (serviceTask.getType().equals("1")) {
+                    //璇煶
+                    Long templateid = serviceTask.getTemplateid();
+                    IvrTaskTemplateScript ivrTaskTemplateScript = new IvrTaskTemplateScript();
+                    ivrTaskTemplateScript.setTemplateID(templateid);
+                    ivrTaskTemplateScript.setOrgid(serviceTask.getOrgid());
+                    //鍏堥粯璁や负1鍚э紝assortid=1  浠h〃鏄弧鎰忓害
+                    ivrTaskTemplateScript.setAssortid(ivrCategoryid);
+                    List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript);
+                    if (CollectionUtils.isNotEmpty(ivrTaskTemplateScripts)) {
+                        //闇�瑕佸厛璁$畻鍑哄彂閫侀噺锛屽啀涔樹互鍗曚釜闂埜婊℃剰搴﹂鐩暟閲忥紝寰楀埌婊℃剰搴﹂鐩�婚噺锛堝寘鍚簡鏈仛鐨勶級
+                        ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO();
+                        serviceSubtaskVO.setTaskid(serviceTask.getTaskid());
+                        List<Long> sendstates = new ArrayList<>(Arrays.asList(3L, 5L, 6L));
+                        serviceSubtaskVO.setSendstates(sendstates);
+                        List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO);
+                        if (CollectionUtils.isNotEmpty(serviceSubtaskList)) {
+                            int mydtmzlCount = ivrTaskTemplateScripts.size() * serviceSubtaskList.size();
+                            mydtmzlsum.add(new BigDecimal(mydtmzlCount));
+                        }
+
+                    }
+                } else if (serviceTask.getType().equals("2")) {
+                    //闂嵎
+                    SvyTaskTemplateScript svyTaskTemplateScript = new SvyTaskTemplateScript();
+                    svyTaskTemplateScript.setTemplateID(serviceTask.getTemplateid());
+                    svyTaskTemplateScript.setOrgid(serviceTask.getOrgid());
+                    svyTaskTemplateScript.setCategoryid(svyCategoryid);
+                    List<SvyTaskTemplateScript> svyTaskTemplateScriptList = svyTaskTemplateScriptService.selectSvyTaskTemplateScriptList(svyTaskTemplateScript);
+                    if (CollectionUtils.isNotEmpty(svyTaskTemplateScriptList)) {
+                        ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO();
+                        serviceSubtaskVO.setTaskid(serviceTask.getTaskid());
+                        List<Long> sendstates = new ArrayList<>(Arrays.asList(3L, 5L, 6L));
+                        serviceSubtaskVO.setSendstates(sendstates);
+                        List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO);
+                        if (CollectionUtils.isNotEmpty(serviceSubtaskList)) {
+                            int mydtmzlCount = svyTaskTemplateScriptList.size() * serviceSubtaskList.size();
+                            mydtmzlsum.add(new BigDecimal(mydtmzlCount));
+                        }
+                    }
+                }
+
+                //鑾峰彇婊℃剰搴﹂鐩~鎶ラ噺
+                ServiceSubtaskDetail serviceSubtaskDetail = new ServiceSubtaskDetail();
+                serviceSubtaskDetail.setTaskid(serviceTask.getTaskid());
+                if (serviceTask.getType().equals("1")) serviceSubtaskDetail.setCategoryid(ivrCategoryid);
+                if (serviceTask.getType().equals("2")) serviceSubtaskDetail.setCategoryid(svyCategoryid);
+                serviceSubtaskDetail.setOrgid(serviceTask.getOrgid());
+                List<ServiceSubtaskDetail> serviceSubtaskDetails = serviceSubtaskDetailMapper.selectServiceSubtaskDetailList(serviceSubtaskDetail);
+                if (CollectionUtils.isNotEmpty(serviceSubtaskDetails))
+                    mydtblsum.add(new BigDecimal(serviceSubtaskDetails.size()));
+            }
+
+
+        }
+        //婊℃剰搴﹂鐩�婚噺
+        map.put("mydtmzl", mydtmzlsum.intValue());
+        map.put("mydtbl", mydtblsum.intValue());
+        map.put("wcbl", 0.0);
+        if (mydtmzlsum.intValue() != 0) {
+            map.put("wcbl", mydtblsum.divide(mydtmzlsum, 2, RoundingMode.HALF_UP).doubleValue());
+        }
+
+        return map;
+    }
+
 
     private ServiceSubtaskStatistic getStatistic(List<ServiceSubtask> serviceSubtaskList) {
         ServiceSubtaskStatistic serviceSubtaskStatistic = new ServiceSubtaskStatistic();
@@ -2272,10 +2429,16 @@
         serviceSubtaskStatistic.setDrname(serviceSubtaskList.get(0).getDrname());
         //鍑洪櫌浜烘
         serviceSubtaskStatistic.setDischargeCount(serviceSubtaskList.size());
+        //璁板綍杩囨护鎮h�呰鎯�
+        List<ServiceSubtask> filterServiceSubtasks = new ArrayList<>();
         for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
             //鏃犻渶闅忚浜烘
             if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) {
                 serviceSubtaskStatistic.setNonFollowUp(serviceSubtaskStatistic.getNonFollowUp() + 1L);
+                if (serviceSubtask.getTaskSituation() !=null && serviceSubtask.getTaskSituation() == 6) {
+                    serviceSubtaskStatistic.setFilterCount(serviceSubtaskStatistic.getFilterCount() + 1L);
+                    filterServiceSubtasks.add(serviceSubtask);
+                }
             }
             //搴旈殢璁夸汉娆�
             if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
@@ -2363,11 +2526,11 @@
             if (serviceSubtask.getTaskSituation() != null && serviceSubtask.getTaskSituation() == 5) {
                 serviceSubtaskStatistic.setTaskSituation5(serviceSubtaskStatistic.getTaskSituation5() + 1);
             }
-            if (serviceSubtask.getTaskSituation() != null && serviceSubtask.getTaskSituation() == 6) {
+            if (serviceSubtask.getTaskSituation() != null && serviceSubtask.getTaskSituation() == 7) {
                 serviceSubtaskStatistic.setTaskSituation6(serviceSubtaskStatistic.getTaskSituation6() + 1);
             }
         }
-
+        serviceSubtaskStatistic.setFilterCountList(filterServiceSubtasks);
 
         return serviceSubtaskStatistic;
     }
@@ -2470,9 +2633,7 @@
                 }
             }
 
-
         }
-
 
         return serviceSubtaskStatistic;
     }
@@ -2506,6 +2667,7 @@
         serviceSubtaskDetail.setAssigntime(System.currentTimeMillis());
         serviceSubtaskDetail.setStarttime(System.currentTimeMillis());
         serviceSubtaskDetail.setAnswertime(System.currentTimeMillis());
+        serviceSubtaskDetail.setCategoryid(ivrTaskTemplateScriptVO.getAssortid());
         serviceSubtaskDetail.setAsrtext("鏃犲簲绛�");
         if (StringUtils.isNotEmpty(phoneCallReqYQVO.getAsrtext()))
             serviceSubtaskDetail.setAsrtext(phoneCallReqYQVO.getAsrtext());
@@ -2608,19 +2770,24 @@
         LocalTime currentTime = LocalTime.now();
         // 鐩爣鏃堕棿锛堟櫄涓� 8 鐐癸級
         LocalTime targetTime = LocalTime.of(phoneEndHour, 0);
-        // 璁$畻褰撳墠鏃堕棿鍒扮洰鏍囨椂闂寸殑鏃堕暱
-        Duration duration = Duration.between(currentTime, targetTime);
-        // 鑾峰彇鍓╀綑鏃堕棿鐨勫皬鏃舵暟
-        long remainingHours = 0;
-        long remainingMinutes = duration.toMinutes();
-        //濡傛灉瓒呰繃8鐐�,灏辫缃负0
-        //璺濈缁撴潫鏃堕棿灏忎簬20鍒嗛挓锛屽氨涓嶆媺鍙栦簡
-        if (remainingMinutes < 20) remainingHours = 0;
-        else if (remainingMinutes < 60 && remainingMinutes > 20) remainingHours = 1;
-        else if (remainingMinutes > 60) remainingHours = remainingMinutes / 60;
-        // 璁$畻鍓╀綑鍙互鎵撶殑鐢佃瘽鏁�
-        int remainingCalls = (int) (remainingHours * phoneUpEveryHour);
-        return remainingCalls;
+//        // 璁$畻褰撳墠鏃堕棿鍒扮洰鏍囨椂闂寸殑鏃堕暱
+//        Duration duration = Duration.between(currentTime, targetTime);
+//        // 鑾峰彇鍓╀綑鏃堕棿鐨勫皬鏃舵暟
+//        long remainingHours = 0;
+//        long remainingMinutes = duration.toMinutes();
+//        //濡傛灉瓒呰繃8鐐�,灏辫缃负0
+//        //璺濈缁撴潫鏃堕棿灏忎簬20鍒嗛挓锛屽氨涓嶆媺鍙栦簡
+//        if (remainingMinutes < 20) remainingHours = 0;
+//        else if (remainingMinutes < 60 && remainingMinutes > 20) remainingHours = 1;
+//        else if (remainingMinutes > 60) remainingHours = remainingMinutes / 60;
+//        // 璁$畻鍓╀綑鍙互鎵撶殑鐢佃瘽鏁�
+//        int remainingCalls = (int) (remainingHours * phoneUpEveryHour);
+//        return remainingCalls;
+        if (currentTime.isBefore(targetTime)) {
+            //濡傛灉褰撳墠鏃堕棿杩樺湪鎴鏃堕棿鍐咃紝鍒欑户缁彂
+            return phoneUpEveryHour;
+        }
+        return 0;
     }
 
     public List<ServiceSubtaskCount> getSfStatisticsJoydetails(ServiceSubtaskCountReq serviceSubtaskCountReq) {
@@ -2692,4 +2859,92 @@
         }
         return visitTime;
     }
+
+
+    /**
+     * 璁$畻鎬昏琛�
+     * @param statistics 缁熻鏁版嵁鍒楄〃
+     * @return 鎬昏琛屾暟鎹�
+     */
+    private ServiceSubtaskStatistic calculateTotalRow(List<ServiceSubtaskStatistic> statistics) {
+        ServiceSubtaskStatistic total = new ServiceSubtaskStatistic();
+
+        // 鍒濆鍖栨暟鍊煎瓧娈�
+        total.setDischargeCount(0);
+        total.setNonFollowUp(0L);
+        total.setFilterCount(0L);
+        total.setFollowUpNeeded(0L);
+        total.setNeedFollowUp(0L);
+        total.setPendingFollowUp(0L);
+        total.setFollowUpSuccess(0L);
+        total.setFollowUpFail(0L);
+        total.setManual(0L);
+        total.setSms(0L);
+        total.setWeChat(0L);
+        total.setAbnormal(0L);
+        total.setNeedFollowUpAgain(0L);
+        total.setPendingFollowUpAgain(0L);
+        total.setFollowUpSuccessAgain(0L);
+        total.setFollowUpFailAgain(0L);
+        total.setManualAgain(0L);
+        total.setSmsAgain(0L);
+        total.setWeChatAgain(0L);
+        total.setAbnormalAgain(0L);
+        total.setTaskSituation1(0);
+        total.setTaskSituation2(0);
+        total.setTaskSituation3(0);
+        total.setTaskSituation4(0);
+        total.setTaskSituation5(0);
+        total.setTaskSituation6(0);
+
+        // 绱姞鍚勪釜瀛楁鐨勫��
+        for (ServiceSubtaskStatistic stat : statistics) {
+            if (stat.getDischargeCount() != null) {
+                total.setDischargeCount(total.getDischargeCount() + stat.getDischargeCount());
+            }
+            total.setNonFollowUp(total.getNonFollowUp() + (stat.getNonFollowUp() != null ? stat.getNonFollowUp() : 0L));
+            total.setFilterCount(total.getFilterCount() + (stat.getFilterCount() != null ? stat.getFilterCount() : 0L));
+            total.setFollowUpNeeded(total.getFollowUpNeeded() + (stat.getFollowUpNeeded() != null ? stat.getFollowUpNeeded() : 0L));
+            total.setNeedFollowUp(total.getNeedFollowUp() + (stat.getNeedFollowUp() != null ? stat.getNeedFollowUp() : 0L));
+            total.setPendingFollowUp(total.getPendingFollowUp() + (stat.getPendingFollowUp() != null ? stat.getPendingFollowUp() : 0L));
+            total.setFollowUpSuccess(total.getFollowUpSuccess() + (stat.getFollowUpSuccess() != null ? stat.getFollowUpSuccess() : 0L));
+            total.setFollowUpFail(total.getFollowUpFail() + (stat.getFollowUpFail() != null ? stat.getFollowUpFail() : 0L));
+            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.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));
+            total.setFollowUpSuccessAgain(total.getFollowUpSuccessAgain() + (stat.getFollowUpSuccessAgain() != null ? stat.getFollowUpSuccessAgain() : 0L));
+            total.setFollowUpFailAgain(total.getFollowUpFailAgain() + (stat.getFollowUpFailAgain() != null ? stat.getFollowUpFailAgain() : 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));
+            total.setAbnormalAgain(total.getAbnormalAgain() + (stat.getAbnormalAgain() != null ? stat.getAbnormalAgain() : 0L));
+            total.setTaskSituation1(total.getTaskSituation1() + (stat.getTaskSituation1() != null ? stat.getTaskSituation1() : 0));
+            total.setTaskSituation2(total.getTaskSituation2() + (stat.getTaskSituation2() != null ? stat.getTaskSituation2() : 0));
+            total.setTaskSituation3(total.getTaskSituation3() + (stat.getTaskSituation3() != null ? stat.getTaskSituation3() : 0));
+            total.setTaskSituation4(total.getTaskSituation4() + (stat.getTaskSituation4() != null ? stat.getTaskSituation4() : 0));
+            total.setTaskSituation5(total.getTaskSituation5() + (stat.getTaskSituation5() != null ? stat.getTaskSituation5() : 0));
+            total.setTaskSituation6(total.getTaskSituation6() + (stat.getTaskSituation6() != null ? stat.getTaskSituation6() : 0));
+        }
+
+        // 璁$畻鎬昏琛岀殑姣旂巼瀛楁
+        DecimalFormat percentFormat = new DecimalFormat("##.##%");
+        if (total.getNeedFollowUp() > 0) {
+            double rate = (double) (total.getFollowUpSuccess() + total.getFollowUpFail()) / total.getNeedFollowUp();
+            total.setFollowUpRate(percentFormat.format(rate));
+        } else {
+            total.setFollowUpRate("0.00%");
+        }
+
+        if (total.getNeedFollowUpAgain() > 0) {
+            double rateAgain = (double) (total.getFollowUpSuccessAgain() + total.getFollowUpFailAgain()) / total.getNeedFollowUpAgain();
+            total.setFollowUpRateAgain(percentFormat.format(rateAgain));
+        } else {
+            total.setFollowUpRateAgain("0.00%");
+        }
+
+        return total;
+    }
 }
diff --git a/smartor/src/main/java/com/smartor/service/impl/SvyTaskSingleServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/SvyTaskSingleServiceImpl.java
index f52638e..543439b 100644
--- a/smartor/src/main/java/com/smartor/service/impl/SvyTaskSingleServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/SvyTaskSingleServiceImpl.java
@@ -294,7 +294,7 @@
             serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
         }
         Integer integer = serviceSubtask.getId().intValue();
-        log.error("鎻掑叆鐨処D鏄細{}", integer);
+        log.info("鎻掑叆鐨処D鏄細{}", integer);
         return integer;
     }
 
@@ -302,21 +302,10 @@
     @Override
     public Map query360PatInfo(ServiceQueryInfo serviceQueryInfo) {
         if (ObjectUtils.isEmpty(serviceQueryInfo)) {
-            log.info("360鏌ヨ鏉′欢涓虹┖");
+            log.error("360鏌ヨ鏉′欢涓虹┖");
             throw new BaseException("360鏌ヨ鏉′欢涓虹┖");
         }
         String token = LSHospTokenUtil.getToken(serviceQueryInfo.getXiaoXiTou().getFaSongJGID(),serviceQueryInfo.getUrl());
-//        LyraTokenUtil lyraTokenUtil = null;
-//        if (serviceQueryInfo.getXiaoXiTou().getFaSongJGID().equals("47255004333112711A1001"))  //鏅畞
-//            lyraTokenUtil = LyraTokenUtil.createLyraTokenUtil("https://9.0.124.104:13021/mediinfo-lyra-authserver/connect/token", "zjhes.suifangxt", "OIjdJvx2ALjFVGZoCZO4I8O");
-//        if (serviceQueryInfo.getXiaoXiTou().getFaSongJGID().equals("47231022633110211A2101"))  //涓尰闄�
-//            lyraTokenUtil = LyraTokenUtil.createLyraTokenUtil("https://9.0.124.104:13011/mediinfo-lyra-authserver/connect/token", "zjhes.suifangxt", "OIjdJvx2ALjFVGZoCZO4I8O");
-//
-//        try {
-//            token = lyraTokenUtil.getToken();
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
 
         //鐢ㄦ埛淇℃伅锛岄�氳繃ZuZhiJGID鍘籦se_organization涓幏鍙栨満鏋勪俊鎭�
         if (StringUtils.isBlank(serviceQueryInfo.getYeWuXX().getYongHuXX().getZuZhiJGID()))
@@ -335,14 +324,13 @@
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
         serviceQueryInfo.getXiaoXiTou().setFaSongSJ(simpleDateFormat.format(new Date()));
 
-        log.error(new Gson().toJson(serviceQueryInfo));
-        log.error("serviceQueryInfo鐨勭粨鏋滀负锛歿}", serviceQueryInfo);
+        log.info("serviceQueryInfo鐨勭粨鏋滀负锛歿}", serviceQueryInfo);
         ObjectMapper objectMapper = new ObjectMapper();
         String result = null;
         Map map = new HashMap();
         try {
             String jsonString = objectMapper.writeValueAsString(serviceQueryInfo);
-            log.error("token鐨勫�间负锛歿}", token);
+            log.info("token鐨勫�间负锛歿}", token);
             if (serviceQueryInfo.getXiaoXiTou().getFaSongJGID().equals("47255004333112711A1001")) {  //鏅畞
                 result = OkHttpExample.sendPostRequest("https://9.0.124.104:13021/mediinfo-grus-fuwuzxwg/api/esb/lyraSyncRun", jsonString, token);
             }else if (serviceQueryInfo.getXiaoXiTou().getFaSongJGID().equals("47231022633110211A2101")) {  //涓尰闄�
diff --git a/smartor/src/main/java/com/smartor/service/impl/SvyTaskTemplateServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/SvyTaskTemplateServiceImpl.java
index 1c3138d..65e1ae4 100644
--- a/smartor/src/main/java/com/smartor/service/impl/SvyTaskTemplateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/SvyTaskTemplateServiceImpl.java
@@ -133,7 +133,7 @@
 
         //瀵规ā鏉胯瘽鏈拰閫夐」杩涜澶勭悊锛堣瘽鏈〃涓庢寚鏍囪〃杩涜鍚堝苟浜嗭紝锛�
         if (CollectionUtils.isNotEmpty(svyTaskTemplateVO.getSvyTaskTemplateScriptVOS())) {
-            log.error("ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList()鏄惁鏈夋暟鎹搱锛歿}", svyTaskTemplateVO.getSvyTaskTemplateScriptVOS());
+//            log.error("ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList()鏄惁鏈夋暟鎹搱锛歿}", svyTaskTemplateVO.getSvyTaskTemplateScriptVOS());
             for (SvyTaskTemplateScriptVO svyTaskTemplateScriptVO : svyTaskTemplateVO.getSvyTaskTemplateScriptVOS()) {
                 svyTaskTemplateScriptVO.setGuid(svyTaskTemplateVO.getGuid());
                 svyTaskTemplateScriptVO.setOrgid(svyTaskTemplateVO.getOrgid());
@@ -179,6 +179,7 @@
             log.info("svyLibaTemplateScriptVO鐨勪富閿甶d涓猴細{}", svyTaskTemplateScriptVO.getId());
             SvyTaskTemplateTargetoption svyTaskTemplateTargetoption = new SvyTaskTemplateTargetoption();
             svyTaskTemplateTargetoption.setScriptid(svyTaskTemplateScriptVO.getId());
+            svyTaskTemplateTargetoption.setOrgid(svyTaskTemplateScriptVO.getOrgid());
             List<SvyTaskTemplateTargetoption> svyTaskTemplateTargetoptions = svyTaskTemplateTargetoptionMapper.selectSvyTaskTemplateTargetoptionList(svyTaskTemplateTargetoption);
             for (SvyTaskTemplateTargetoption svyTaskTemplateTargetoption1 : svyTaskTemplateTargetoptions) {
                 ObjectMapper mapper = new ObjectMapper();
@@ -201,7 +202,7 @@
             }
             svyTaskTemplateScriptVO.setSvyTaskTemplateTargetoptions(svyTaskTemplateTargetoptions);
         }
-        Collections.sort(svyTaskTemplateScriptVOS, Comparator.comparing(SvyTaskTemplateScriptVO::getTargetid));
+//        Collections.sort(svyTaskTemplateScriptVOS, Comparator.comparing(SvyTaskTemplateScriptVO::getTargetid));
         //鏁版嵁缁勮
         templateVO.setSvyTaskTemplateScriptVOS(svyTaskTemplateScriptVOS);
         return templateVO;
diff --git a/smartor/src/main/resources/mapper/smartor/IvrLibScriptMapper.xml b/smartor/src/main/resources/mapper/smartor/IvrLibScriptMapper.xml
index 7e2e5df..fe2191c 100644
--- a/smartor/src/main/resources/mapper/smartor/IvrLibScriptMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/IvrLibScriptMapper.xml
@@ -4,7 +4,7 @@
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.smartor.mapper.IvrLibScriptMapper">
 
-    <resultMap type="IvrLibScript" id="IvrLibScriptResult">
+    <resultMap type="com.smartor.domain.IvrLibScript" id="IvrLibScriptResult">
         <result property="scriptid"    column="scriptid"    />
         <result property="orgid"    column="orgid"    />
         <result property="categoryid"    column="categoryid"    />
diff --git a/smartor/src/main/resources/mapper/smartor/IvrLibaScriptMapper.xml b/smartor/src/main/resources/mapper/smartor/IvrLibaScriptMapper.xml
index db40df2..abf54a3 100644
--- a/smartor/src/main/resources/mapper/smartor/IvrLibaScriptMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/IvrLibaScriptMapper.xml
@@ -6,6 +6,7 @@
 
     <resultMap type="com.smartor.domain.IvrLibaScript" id="IvrLibaScriptResult">
         <result property="id" column="id"/>
+        <result property="assortid" column="assortid"/>
         <result property="scriptTopic" column="script_topic"/>
         <result property="scriptContent" column="script_content"/>
         <result property="ivrVoice" column="ivr_voice"/>
@@ -57,6 +58,7 @@
     <sql id="selectIvrLibaScriptVo">
         select id,
                suitway,
+               assortid,
                targetdesc,
                campus,
                deptNames,
diff --git a/smartor/src/main/resources/mapper/smartor/IvrLibaTemplateScriptMapper.xml b/smartor/src/main/resources/mapper/smartor/IvrLibaTemplateScriptMapper.xml
index 255d283..31351c6 100644
--- a/smartor/src/main/resources/mapper/smartor/IvrLibaTemplateScriptMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/IvrLibaTemplateScriptMapper.xml
@@ -48,12 +48,14 @@
         <result property="sort" column="sort"/>
         <result property="score" column="score"/>
         <result property="groupName" column="group_name"/>
+        <result property="assortid" column="assortid"/>
     </resultMap>
 
     <sql id="selectIvrLibaTemplateScriptVo">
         select id,
                scriptno,
                sort,
+               assortid,
                group_name,
                branch_flag,
                branch_nextscriptno,
@@ -102,6 +104,7 @@
         <where>
             del_flag=0
             <if test="scriptno != null ">and scriptno = #{scriptno}</if>
+            <if test="assortid != null ">and assortid = #{assortid}</if>
             <if test="groupName != null ">and group_name = #{groupName}</if>
             <if test="scriptDesc != null ">and script_desc = #{scriptDesc}</if>
             <if test="templateid != null ">and templateid = #{templateid}</if>
@@ -196,6 +199,7 @@
             <if test="score != null ">score,</if>
             <if test="ivrtext != null ">ivrtext,</if>
             <if test="groupName != null ">group_name,</if>
+            <if test="assortid != null ">assortid,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="scriptno != null">#{scriptno},</if>
@@ -239,6 +243,7 @@
             <if test="score != null ">#{score},</if>
             <if test="ivrtext != null ">#{ivrtext},</if>
             <if test="groupName != null ">#{groupName},</if>
+            <if test="assortid != null ">#{assortid},</if>
         </trim>
     </insert>
 
@@ -284,6 +289,7 @@
             <if test="branchFlag != null  and branchFlag != ''">branch_flag = #{branchFlag},</if>
             <if test="score != null ">score = #{score},</if>
             <if test="groupName != null ">group_name = #{groupName},</if>
+            <if test="assortid != null ">assortid = #{assortid},</if>
             <if test="branchNextscriptno != null  and branchNextscriptno != ''">branch_nextscriptno =
                 #{branchNextscriptno},
             </if>
diff --git a/smartor/src/main/resources/mapper/smartor/IvrTaskTemplateScriptMapper.xml b/smartor/src/main/resources/mapper/smartor/IvrTaskTemplateScriptMapper.xml
index d2aafeb..7db4ec5 100644
--- a/smartor/src/main/resources/mapper/smartor/IvrTaskTemplateScriptMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/IvrTaskTemplateScriptMapper.xml
@@ -48,11 +48,13 @@
         <result property="ivrtext" column="ivrtext"/>
         <result property="groupName" column="group_name"/>
         <result property="scriptTopic" column="script_topic"/>
+        <result property="assortid" column="assortid"/>
     </resultMap>
 
     <sql id="selectIvrTaskTemplateScriptVo">
         select id,
                taskid,
+               assortid,
                sort,
                ivrtext,
                script_type,
@@ -83,6 +85,7 @@
         <where>
             del_flag=0
             <if test="taskid != null ">and taskid = #{taskid}</if>
+            <if test="assortid != null ">and assortid = #{assortid}</if>
             <if test="score != null ">and score = #{score}</if>
             <if test="scriptTopic != null ">and script_topic = #{scriptTopic}</if>
             <if test="ivrtext != null ">and ivrtext = #{ivrtext}</if>
@@ -175,6 +178,7 @@
             <if test="score != null ">score,</if>
             <if test="ivrtext != null ">ivrtext,</if>
             <if test="scriptTopic != null ">script_topic,</if>
+            <if test="assortid != null ">assortid,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="taskid != null">#{taskid},</if>
@@ -218,6 +222,7 @@
             <if test="score != null ">#{score},</if>
             <if test="ivrtext != null ">#{ivrtext},</if>
             <if test="scriptTopic != null ">#{scriptTopic},</if>
+            <if test="assortid != null ">#{assortid},</if>
         </trim>
     </insert>
 
@@ -267,6 +272,7 @@
             <if test="score != null">score = #{score},</if>
             <if test="ivrtext != null">ivrtext = #{ivrtext},</if>
             <if test="scriptTopic != null ">script_topic = #{scriptTopic},</if>
+            <if test="assortid != null ">assortid = #{assortid},</if>
         </trim>
         where id = #{id}
     </update>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 5682971..f873005 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -513,8 +513,9 @@
     <select id="selectPatMedInhosp" parameterType="Long" resultMap="PatMedInhospResult">
         <include refid="selectPatMedInhospVo"/>
         where del_flag=0
-        <if test="cry != null and cry == 0 ">and endtime is null</if>
+        <if test="cry != null and cry == 0 ">and inhospstate=0</if>
         <if test="cry != null and cry == 1 ">and inhospstate=1</if>
+        <if test="cry != null and cry == 3 ">and inhospstate=3</if>
         <if test="serialnum != null">and serialnum = #{serialnum}</if>
         <if test="hospitalname != null">and hospitalname = #{hospitalname}</if>
         <if test="hospitalcode != null">and hospitalcode = #{hospitalcode}</if>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
index 50b0bf2..68bc33f 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
@@ -39,6 +39,7 @@
         <result property="idcardno" column="idcardno"/>
         <result property="remark" column="remark"/>
         <result property="fudate" column="fudate"/>
+        <result property="serverState" column="server_state"/>
         <result property="campusid" column="campusid"/>
     </resultMap>
 
@@ -46,6 +47,7 @@
         select id,
                outhospno,
                campusid,
+               server_state,
                diagcheck_flag,
                patno,
                remark,
@@ -87,6 +89,7 @@
         pmo.campusid,
         pmo.remark,
         pmo.fudate,
+        pmo.server_state,
         pmo.outhospno,
         pmo.diagcheck_flag,
         pmo.patno,
@@ -121,19 +124,19 @@
         <where>
             pmo.del_flag=0
             <if test="orgid != null ">and pmo.orgid = #{orgid}</if>
+            <if test="serialnum != null ">and pmo.serialnum = #{serialnum}</if>
+            <if test="serverState != null ">and pmo.server_state = #{serverState}</if>
             <if test="hospitalname != null  and hospitalname != ''">and pmo.hospitalname like concat('%',
                 #{hospitalname},
                 '%')
             </if>
             <if test="deptcodes != null and deptcodes.size()>0">
-                AND  pmo.deptcode IN
+                AND pmo.deptcode IN
                 <foreach collection="deptcodes" item="deptcode" open="(" separator=","
                          close=")">
                     #{deptcode}
                 </foreach>
             </if>
-
-
             <if test="deptname != null  and deptname != ''">and pmo.deptname like concat('%', #{deptname}, '%')</if>
             <if test="drname != null  and drname != ''">and pmo.drname like concat('%', #{drname}, '%')</if>
             <if test="patname != null  and patname != ''">and pmo.patname like concat('%', #{patname}, '%')</if>
@@ -196,6 +199,7 @@
             <if test="fuflag != null">fuflag,</if>
             <if test="fudate != null">fudate,</if>
             <if test="campusid != null">campusid,</if>
+            <if test="serverState != null">server_state,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="serialnum != null">#{serialnum},</if>
@@ -231,6 +235,7 @@
             <if test="fuflag != null">#{fuflag},</if>
             <if test="fudate != null">#{fudate},</if>
             <if test="campusid != null">#{campusid},</if>
+            <if test="serverState != null">#{serverState},</if>
         </trim>
     </insert>
 
@@ -269,6 +274,7 @@
         fuflag,
         fudate,
         campusid,
+        server_state,
         remark)
         values
         <foreach collection="list" item="item" separator=",">
@@ -305,6 +311,85 @@
             #{item.fuflag},
             #{item.fudate},
             #{item.campusid},
+            #{item.serverState},
+            #{item.remark}
+            )
+        </foreach>
+    </insert>
+
+    <insert id="batchInsertIgnore">
+        insert ignore into pat_med_outhosp
+        (
+        serialnum,
+        patid,
+        hospitalname,
+        hospitalcode,
+        icd10code,
+        diagname,
+        deptcode,
+        deptname,
+        drcode,
+        drname,
+        admitdate,
+        orgid,
+        del_flag,
+        update_by,
+        update_time,
+        create_by,
+        create_time,
+        isupload,
+        upload_time,
+        schemestatus,
+        deptid,
+        schemetime,
+        hpi,
+        mainsuit,
+        outhospno,
+        patname,
+        guid,
+        patno,
+        diagcheck_flag,
+        fuflag,
+        fudate,
+        campusid,
+        server_state,
+        remark)
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.serialnum},
+            #{item.patid},
+            #{item.hospitalname},
+            #{item.hospitalcode},
+            #{item.icd10code},
+            #{item.diagname},
+            #{item.deptcode},
+            #{item.deptname},
+            #{item.drcode},
+            #{item.drname},
+            #{item.admitdate},
+            #{item.orgid},
+            #{item.delFlag},
+            #{item.updateBy},
+            #{item.updateTime},
+            #{item.createBy},
+            #{item.createTime},
+            #{item.isupload},
+            #{item.uploadTime},
+            #{item.schemestatus},
+            #{item.deptid},
+            #{item.schemetime},
+            #{item.hpi},
+            #{item.mainsuit},
+            #{item.outhospno},
+            #{item.patname},
+            #{item.guid},
+            #{item.patno},
+            #{item.diagcheckFlag},
+            #{item.fuflag},
+            #{item.fudate},
+            #{item.campusid},
+            #{item.serverState},
             #{item.remark}
             )
         </foreach>
@@ -347,6 +432,7 @@
             <if test="fuflag != null">fuflag = #{fuflag},</if>
             <if test="fudate != null">fudate = #{fudate},</if>
             <if test="campusid != null">campusid = #{campusid},</if>
+            <if test="serverState != null">server_state = #{serverState},</if>
         </trim>
         where id = #{id}
     </update>
@@ -421,9 +507,12 @@
         FROM pat_med_outhosp
         <where>
             del_flag=0
-            <if test="inhospstate != inhospstate">
+            <if test="inhospstate != null">
                 and inhospstate= #{inhospstate}
             </if>
+            <if test="serverState != null">
+                and server_state= #{inhospstate}
+            </if>
             <if test="deptcodeList != null and deptcodeList.size()>0">
                 and deptcode in
                 <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailMapper.xml
index 011efb7..dd283ea 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailMapper.xml
@@ -35,6 +35,7 @@
         <result property="questiontext" column="questiontext"/>
         <result property="questionvoice" column="questionvoice"/>
         <result property="categoryname" column="categoryname"/>
+        <result property="categoryid" column="categoryid"/>
         <result property="targetoptions" column="targetoptions"/>
         <result property="targetvalue" column="targetvalue"/>
         <result property="matchedtext" column="matchedtext"/>
@@ -99,6 +100,7 @@
                questiontext,
                questionvoice,
                categoryname,
+               categoryid,
                targetoptions,
                targetvalue,
                matchedtext,
@@ -146,6 +148,7 @@
             <if test="templateid != null  and templateid != ''">and templateid = #{templateid}</if>
             <if test="templatequestionnum != null ">and templatequestionnum = #{templatequestionnum}</if>
             <if test="switchid != null ">and switchid = #{switchid}</if>
+            <if test="categoryid != null ">and categoryid = #{categoryid}</if>
             <if test="questiontext != null  and questiontext != ''">and questiontext = #{questiontext}</if>
             <if test="questionvoice != null  and questionvoice != ''">and questionvoice = #{questionvoice}</if>
             <if test="categoryname != null  and categoryname != ''">and categoryname like concat('%', #{categoryname},
@@ -225,6 +228,7 @@
             <if test=" patid != null">patid,</if>
             <if test=" extemplateText != null">extemplate_text,</if>
             <if test=" guid != null">guid,</if>
+            <if test=" categoryid != null">categoryid,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -276,6 +280,7 @@
             <if test="patid != null">#{patid},</if>
             <if test="extemplateText != null">#{extemplateText},</if>
             <if test="guid != null">#{guid},</if>
+            <if test="categoryid != null">#{categoryid},</if>
         </trim>
     </insert>
 
@@ -330,6 +335,7 @@
             <if test=" patid != null">patid = #{patid},</if>
             <if test=" extemplateText != null">extemplate_text = #{extemplateText},</if>
             <if test=" guid != null">guid = #{guid},</if>
+            <if test=" categoryid != null">categoryid = #{categoryid},</if>
         </trim>
         where id = #{id}
     </update>
@@ -386,6 +392,7 @@
             <if test=" patid != null">patid = #{patid},</if>
             <if test=" extemplateText != null">extemplate_text = #{extemplateText},</if>
             <if test=" guid != null">guid = #{guid},</if>
+            <if test=" categoryid != null">categoryid = #{categoryid},</if>
         </trim>
         where patid = #{patid} and scriptid = #{scriptid} and sub_id = #{subId}
     </update>
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 0979503..9efefee 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -197,12 +197,16 @@
         <include refid="selectServiceSubtaskVo"/>
         <where>
             del_flag=0
-            and taskid = #{taskid}
-            AND sendstate IN
-            <foreach collection="sendstates" item="sendstate" open="(" separator=","
-                     close=")">
-                #{sendstate}
-            </foreach>
+            <if test="taskid != null ">and taskid = #{taskid}</if>
+            <if test="serviceType != null ">and service_type = #{serviceType}</if>
+            <if test="patid != null ">and patid = #{patid}</if>
+            <if test="sendstates!=null">
+                AND sendstate IN
+                <foreach collection="sendstates" item="sendstate" open="(" separator=","
+                         close=")">
+                    #{sendstate}
+                </foreach>
+            </if>
         </where>
     </select>
 
@@ -552,6 +556,20 @@
         where id = #{id}
     </select>
 
+    <select id="selectServiceSubtaskByDiagname" parameterType="com.smartor.domain.ServiceSubtask"
+            resultMap="ServiceSubtaskResult">
+        select sendstate,starttime,endtime,nurse_name,phone,sex,task_name,sendname,leavediagname,visit_time FROM
+        service_subtask WHERE del_flag=0
+        <if test="leavediagname != null">and leavediagname like concat('%',#{leavediagname}, '%')</if>
+        <if test="sendname != null">and sendname like concat('%',#{sendname}, '%')</if>
+        <if test="taskName != null">and task_name like concat('%',#{taskName}, '%')</if>
+        <if test="sendstate != null">and sendstate = #{sendstate}</if>
+        <if test="orgid != null">and orgid =#{orgid}</if>
+        GROUP BY sendname,sendstate,starttime,endtime,nurse_name,phone,sex,task_name,leavediagname,visit_time ORDER BY
+        visit_time
+        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
+    </select>
+
     <insert id="insertServiceSubtask" parameterType="com.smartor.domain.ServiceSubtask" useGeneratedKeys="true"
             keyProperty="id">
         insert into service_subtask
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceTaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceTaskMapper.xml
index 5110723..f1bca5b 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceTaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceTaskMapper.xml
@@ -152,8 +152,9 @@
             </if>
             <if test="endTime != null ">and date_format(update_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
             </if>
-
-            <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
+            <if test="deptcode != null  and deptcode != ''">
+                and deptcode REGEXP CONCAT('(^|,)', #{deptcode}, '(,|$)')
+            </if>
             <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>
             <if test="isupload != null ">and isupload = #{isupload}</if>
             <if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
@@ -173,10 +174,9 @@
             <if test="leavehospitaldistrictname != null  ">and leavehospitaldistrictname =
                 #{leavehospitaldistrictname}
             </if>
-            <if test="leavehospitaldistrictcode != null  ">and leavehospitaldistrictcode =
-                #{leavehospitaldistrictcode}
+            <if test="leavehospitaldistrictcode != null  and leavehospitaldistrictcode != ''">
+                and leavehospitaldistrictcode REGEXP CONCAT('(^|,)', #{leavehospitaldistrictcode}, '(,|$)')
             </if>
-
             <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0">
                 AND leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
diff --git a/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateMapper.xml b/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateMapper.xml
index 2dfc0ba..4091b73 100644
--- a/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateMapper.xml
@@ -95,6 +95,7 @@
         <where>
             del_flag=0
             <if test="templateid != null ">and templateid = #{templateid}</if>
+            <if test="id != null ">and id = #{id}</if>
             <if test="categoryid != null ">and categoryid = #{categoryid}</if>
             <if test="svycode != null  and svycode != ''">and svycode = #{svycode}</if>
             <if test="svyname != null  and svyname != ''">and svyname like concat('%', #{svyname}, '%')</if>
diff --git a/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateScriptMapper.xml b/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateScriptMapper.xml
index 1c723d2..f0737c4 100644
--- a/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateScriptMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateScriptMapper.xml
@@ -44,6 +44,7 @@
         <result property="score" column="score"/>
         <result property="prompt" column="prompt"/>
         <result property="groupName" column="group_name"/>
+        <result property="categoryid" column="categoryid"/>
 
     </resultMap>
 
@@ -52,6 +53,7 @@
                sort,
                ishide,
                prompt,
+               categoryid,
                group_name,
                branch_flag,
                branch_nextscriptno,
@@ -72,6 +74,7 @@
         <include refid="selectSvyTaskTemplateScriptVo"/>
         <where>
             <if test="taskid != null ">and taskid = #{taskid}</if>
+            <if test="categoryid != null ">and categoryid = #{categoryid}</if>
             <if test="ishide != null ">and ishide = #{ishide}</if>
             <if test="scriptno != null ">and scriptno = #{scriptno}</if>
             <if test="templateID != null ">and templateID = #{templateID}</if>
@@ -157,6 +160,7 @@
             <if test="prompt != null ">prompt,</if>
             <if test="groupName != null ">group_name,</if>
             <if test="ishide != null ">ishide,</if>
+            <if test="categoryid != null ">categoryid,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="taskid != null">#{taskid},</if>
@@ -197,6 +201,7 @@
             <if test="prompt != null ">#{prompt},</if>
             <if test="groupName != null ">#{groupName},</if>
             <if test="ishide != null ">#{ishide},</if>
+            <if test="categoryid != null ">#{categoryid},</if>
         </trim>
     </insert>
 
@@ -243,6 +248,7 @@
             <if test="prompt != null">prompt = #{prompt},</if>
             <if test="groupName != null ">group_name = #{groupName},</if>
             <if test="ishide != null ">ishide = #{ishide},</if>
+            <if test="categoryid != null ">categoryid = #{categoryid},</if>
         </trim>
         where id = #{d}
     </update>
diff --git a/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateTargetoptionMapper.xml b/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateTargetoptionMapper.xml
index 707a75f..46702b3 100644
--- a/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateTargetoptionMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/SvyTaskTemplateTargetoptionMapper.xml
@@ -73,6 +73,7 @@
             resultMap="SvyTaskTemplateTargetoptionResult">
         <include refid="selectSvyTaskTemplateTargetoptionVo"/>
         <where>
+            del_flag=0
             <if test="taskid != null ">and taskid = #{taskid}</if>
             <if test="score != null ">and score = #{score}</if>
             <if test="prompt != null ">and prompt = #{prompt}</if>
@@ -99,8 +100,8 @@
             <if test="pid != null ">and pid = #{pid}</if>
             <if test="guid != null  and guid != ''">and guid = #{guid}</if>
             <if test="scriptid != null ">and scriptid = #{scriptid}</if>
-            <if test="nodynamiccruxs != null ">and nodynamiccruxs = #{nodynamiccruxsJson}</if>
-            <if test="dynamiccruxs != null ">and dynamiccruxs = #{dynamiccruxsJson}</if>
+<!--            <if test="nodynamiccruxs != null ">and nodynamiccruxs = #{nodynamiccruxsJson}</if>-->
+<!--            <if test="dynamiccruxs != null ">and dynamiccruxs = #{dynamiccruxsJson}</if>-->
             <if test="nextQuestion != null ">and next_question = #{nextQuestion}</if>
             <if test="picturePath != null  and picturePath != ''">and picture_path = #{picturePath}</if>
             <if test="optionCode != null">and option_code = #{optionCode}</if>

--
Gitblit v1.9.3