From 28179175bedad0d867f111e7d9f34e4a4b9c9371 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 23 七月 2026 19:05:13 +0800
Subject: [PATCH] (1)同德短信问题处理 (2)同德过滤患者查询问题处理 (3)南华出院随访导出新增(年龄、病历号、性别)

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java |  307 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 280 insertions(+), 27 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index e75d680..ad34f8d 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -6,6 +6,8 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.dx.MessageSend;
 import com.ruoyi.common.exception.base.BaseException;
@@ -14,6 +16,7 @@
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.mapper.SysConfigMapper;
+import com.smartor.common.DeepSeekApi;
 import com.smartor.common.FtpService;
 import com.smartor.common.MtSubmitSmUtil;
 import com.smartor.config.PhoneUtils;
@@ -28,6 +31,7 @@
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.annotation.Cacheable;
@@ -41,11 +45,9 @@
 import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
+import java.time.*;
 import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
@@ -130,6 +132,9 @@
     @Autowired
     private SvyLibScriptCategoryMapper svyLibScriptCategoryMapper;
 
+    @Autowired
+    private IPatMedInhospService patMedInhospService;
+
     @Value("${pri_key}")
     private String pri_key;
 
@@ -176,6 +181,8 @@
 
     @Autowired
     private IPatMedOuthospService patMedOuthospService;
+    @Autowired
+    private SysDept2Mapper sysDept2Mapper;
 
     @Value("${spring.profiles.active}")
     private String active;
@@ -402,9 +409,81 @@
                 serviceSubtaskRes.setSendstateView(1L);
             if (serviceSubtaskRes.getSendstate() == 6) serviceSubtaskRes.setSendstateView(2L);
             if (serviceSubtaskRes.getSendstate() == 4) serviceSubtaskRes.setSendstateView(3L);
+            // 濉厖褰撳墠琛ュ伩
+            if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) {
+                if (StringUtils.isNotEmpty(serviceSubtask.getPreachform())) {
+                    //榛樿鍙栫涓�涓�
+                    serviceSubtaskRes.setCurrentPreachform(serviceSubtask.getPreachform().split(",")[0]);
+                }
+            }
+            PatMedInhosp inhosp = patMedInhospMapper.selectPatMedInhospByInhospid(serviceSubtask.getInhospid());
+            if (ObjectUtils.isNotEmpty(inhosp)) {
+                PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(inhosp.getPatid());
+                if (ObjectUtils.isNotEmpty(patArchive)) {
+                    Map<String, String> stringStringMap = calculateAge(patArchive.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
+                    serviceSubtaskRes.setAge(StringUtils.isNotEmpty(stringStringMap.get("age")) ? Long.valueOf(stringStringMap.get("age")) : null);
+                    serviceSubtaskRes.setSex(patArchive.getSex());
+                    serviceSubtaskRes.setSexName(patArchive.getSex() != null ? (patArchive.getSex() == 1 ? "鐢�" : "濂�") : null);
+                }
+                serviceSubtaskRes.setHospno(inhosp.getInhospno());
+                serviceSubtaskRes.setPatno(inhosp.getPatno());
+            }
+
             serviceSubtaskResList.add(serviceSubtaskRes);
         }
         return serviceSubtaskResList;
+    }
+
+    public Map<String, String> calculateAge(LocalDate birthdate, LocalDate today) {
+        if (birthdate == null || today.isBefore(birthdate)) {
+            return null;
+        }
+        Map<String, String> ageMap = new HashMap<>();
+
+        Period period = Period.between(birthdate, today);
+        long totalDays = ChronoUnit.DAYS.between(birthdate, today);
+        long totalMonths = ChronoUnit.MONTHS.between(birthdate, today);
+
+        int years = period.getYears();
+        int months = period.getMonths();
+        int days = period.getDays();
+
+        String ageUnit;
+        Integer age;
+        String ageUnit2 = null;
+        Integer age2 = null;
+
+        if (totalDays < 90) {
+            // 灏忎簬 1 涓湀锛屾寜澶╄绠�
+            ageUnit = "澶�";
+            age = (int) totalDays;
+            ageMap.put("age", age != null ? age.toString() : null);
+            ageMap.put("ageUnit", ageUnit);
+            ageMap.put("age2", null);
+            ageMap.put("ageUnit2", null);
+        } else if (totalMonths < 36) {
+            // 灏忎簬 1 骞达紝鎸夋湀 + 澶╄绠�
+            ageUnit = "鏈�";
+            age = (int) totalMonths;
+            ageUnit2 = "澶�";
+            age2 = days;
+            ageMap.put("age", age != null ? age.toString() : null);
+            ageMap.put("ageUnit", ageUnit);
+            ageMap.put("age2", age2 != null ? age2.toString() : null);
+            ageMap.put("ageUnit2", ageUnit2);
+        } else {
+            // 澶т簬 1 骞达紝鎸夊勾 + 鏈堣绠�
+            ageUnit = "宀�";
+            age = years;
+            ageUnit2 = "鏈�";
+            age2 = months;
+            ageMap.put("age", age != null ? age.toString() : null);
+            ageMap.put("ageUnit", ageUnit);
+            ageMap.put("age2", age2 != null ? age2.toString() : null);
+            ageMap.put("ageUnit2", ageUnit2);
+        }
+
+        return ageMap;
     }
 
     @Override
@@ -677,7 +756,10 @@
                 serviceTask.setTemplatename(tempName);
             }
             serviceTask.setLeaveldeptcodes(serviceTaskVO.getLeaveldeptcodes());
-            serviceTask.setLeavehospitaldistrictcode(serviceTask.getLeavehospitaldistrictcode());
+            if (StringUtils.isEmpty(serviceTask.getLeavehospitaldistrictname()) && StringUtils.isNotEmpty(serviceTask.getLeavehospitaldistrictcode())) {
+                SysDept sysDept = sysDept2Mapper.selectDeptByCode(serviceTask.getLeavehospitaldistrictcode(), null);
+                serviceTask.setLeavehospitaldistrictname(sysDept.getDeptName());
+            }
             if (serviceTaskVO.getLongTask() == 1) serviceTask.setSendState(2L);
             serviceTask.setCreateTime(new Date());
             serviceTask.setUpdateTime(new Date());
@@ -703,8 +785,8 @@
                     //鍗楀崕闄勪竴鐨刬cd10code鏄湁閲嶅鐨勶紝鎵�浠ヤ笉鑳界敤鍗楀崕闄勪竴鐨刬cd10code鍘绘煡璇�
                     log.info("----serviceTaskdiag鐨勫�间负锛歿}", serviceTaskdiag);
                     if (!StringUtils.isEmpty(serviceTaskVO.getIcd10name())) {
-                        String[] Icd10Names = serviceTaskVO.getIcd10name().split("$");
-                        String[] Icd10codes = serviceTaskVO.getIcd10code().split("$");
+                        String[] Icd10Names = serviceTaskVO.getIcd10name().split(",");
+                        String[] Icd10codes = serviceTaskVO.getIcd10code().split(",");
                         for (int i = 0; i < Icd10Names.length; i++) {
                             serviceTaskdiag.setIcd10code(Icd10codes[i]);
                             serviceTaskdiag.setIcd10name(Icd10Names[i]);
@@ -1648,20 +1730,39 @@
                     if (StringUtils.isEmpty(phoneCallReqYQVO.getAsrtext())) {
                         continue;
                     }
-                    //鍖呭惈
-                    Matcher matcher = null;
-                    if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
-                        Pattern pattern = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex());
-                        matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
+                    //2-AI璇嗗埆
+                    SysConfig configVoiceMatchType = new SysConfig();
+                    configVoiceMatchType.setOrgid(phoneCallReqYQVO.getOrgid());
+                    configVoiceMatchType.setConfigKey("sys.voice.match.type");
+                    SysConfig matchType = sysConfigMapper.selectConfig(configVoiceMatchType);
+                    boolean matchedFlag = false;
+                    if(ObjectUtils.isNotEmpty(matchType) && StringUtils.isNotEmpty(matchType.getConfigValue()) && matchType.getConfigValue().equals("2")){
+                        int checkFlag = DeepSeekApi.matchQuestionAnswer(ivrTaskTemplateScriptVO.getScriptContent(),
+                                phoneCallReqYQVO.getAsrtext(),
+                                ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetvalue());
+                        if(checkFlag == 1){
+                            matchedFlag = true;
+                        }
+                    }else {
+                        //鍖呭惈
+                        Matcher matcher = null;
+                        if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
+                            Pattern pattern = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex());
+                            matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
+                        }
+                        //涓嶅寘鍚�
+                        Matcher matcher2 = null;
+                        if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) {
+                            Pattern pattern2 = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
+                            matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
+                        }
+
+                        if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
+                            matchedFlag = true;
+                        }
                     }
-                    //涓嶅寘鍚�
-                    Matcher matcher2 = null;
-                    if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) {
-                        Pattern pattern2 = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
-                        matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
-                    }
-                    if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
-                        //璇存槑鍖归厤姝g‘浜�
+                    //璇存槑鍖归厤姝g‘浜�
+                    if(matchedFlag){
                         //杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
                         log.info("鍖归厤姝g‘浜嗗悧--------------");
                         ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).setIsUserOperation(1);
@@ -2352,7 +2453,6 @@
             serviceSubtask.setRemark("鐢佃瘽鎺ラ�氭垚鍔燂紝鎮h�呮嫆缁濋殢璁�");
             serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid()));
             serviceSubtask.setSendstate(6L);
-            serviceSubtask.setFinishtime(new Date());
             serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
 //            int startIndex = phoneCallRecordVO.getRecord_path().indexOf("voice") + "voice".length() + 1;  // 鍔�1鏄烦杩�/绗﹀彿
 //            int endIndex = phoneCallRecordVO.getRecord_path().lastIndexOf("/");
@@ -2855,15 +2955,15 @@
                 //棣栨鍑洪櫌闅忚
                 if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
                     //棣栨搴旈殢璁�
-                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
+                    if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L)) {
                         serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
                     }
-                    //棣栨寰呴殢璁�
-                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
-                        serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L);
+                    //棣栨鏃犻渶闅忚
+                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(4L)) {
+                        serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                     }
                     //棣栨闅忚澶辫触(鍖呮嫭闅忚澶辫触+浜哄伐瓒呮椂)
-                    if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 5 || serviceSubtask.getSendstate() == 7)) {
+                    if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(5L) || serviceSubtask.getSendstate().equals(7L))) {
                         serviceSubtaskStatistic.setFollowUpFail(serviceSubtaskStatistic.getFollowUpFail() + 1L);
                     }
                     /**
@@ -2873,6 +2973,10 @@
                         //棣栨闅忚鎴愬姛
                         if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L))) {
                             serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L);
+                        }
+                        //棣栨鏃犻渶闅忚
+                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
+                            serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                         }
                         //棣栨闅忚浜哄伐 (涓嶇粺璁′笉鎵ц)
                         if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
@@ -2895,6 +2999,10 @@
                         if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L))) {
                             serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L);
                         }
+                        //棣栨鏃犻渶闅忚
+                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
+                            serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
+                        }
                         //棣栨闅忚浜哄伐 (鍙粺璁″凡瀹屾垚)
                         if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
                             serviceSubtaskStatistic.setManual(serviceSubtaskStatistic.getManual() + 1L);
@@ -2915,6 +3023,10 @@
                         //棣栨闅忚鎴愬姛 - 缁熻鏃跺�欏姞涓婁笉鎵ц鐨勶紝宸插彂閫佺殑
                         if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L) || serviceSubtask.getSendstate().equals(3L) || serviceSubtask.getSendstate().equals(4L))) {
                             serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L);
+                        }
+                        //棣栨鏃犻渶闅忚
+                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
+                            serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                         }
                         //棣栨闅忚浜哄伐 (缁熻涓嶆墽琛�)
                         if (serviceSubtask.getSendstate() != null && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
@@ -2948,6 +3060,10 @@
                     //鍐嶆搴旈殢璁�
                     if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                         serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
+                    }
+                    //鍐嶆鏃犻渶闅忚
+                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) {
+                        serviceSubtaskStatistic.setNonFollowUpAgain(serviceSubtaskStatistic.getNonFollowUpAgain() + 1L);
                     }
                     //鍐嶆寰呴殢璁�
                     if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
@@ -3099,6 +3215,10 @@
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                     serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
                 }
+                //棣栨鏃犻渶闅忚
+                if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
+                    serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
+                }
                 //棣栨寰呴殢璁�
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
                     serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L);
@@ -3245,6 +3365,10 @@
                 //鍐嶆搴旈殢璁�
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                     serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
+                }
+                //鍐嶆鏃犻渶闅忚
+                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) {
+                    serviceSubtaskStatistic.setNonFollowUpAgain(serviceSubtaskStatistic.getNonFollowUpAgain() + 1L);
                 }
                 //鍐嶆寰呴殢璁�
                 if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
@@ -3667,7 +3791,7 @@
         Map<String, String> map = new HashMap<>();
         map.put("phone", serviceSubtask.getPhone());
         map.put("content", sendMagParam.getContent());
-        String result = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map));
+        HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map));
         redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES);
         if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
             serviceSubtask.setRemark("鐢佃瘽鍙戦�佹嫆鎺�,鐭俊琛ュ伩鍙戦�佹垚鍔�");
@@ -4503,6 +4627,29 @@
     }
 
     @Override
+    public List<ServiceSubtask> gethelibraryCountHyperlink(HeLibraryCountVO heLibraryCountVO) {
+        String hyperLinkInfoType = heLibraryCountVO.getHyperLinkInfoType();
+        if (StringUtils.isNotEmpty(hyperLinkInfoType)) {
+            heLibraryCountVO.setSendstate(null);
+            heLibraryCountVO.setIsFinished(null);
+            switch (hyperLinkInfoType) {
+                case "totalCountInfo":
+                    break;
+                case "sendSuccessCountInfo":
+                    heLibraryCountVO.setSendstate(6L);
+                    break;
+                case "readCountInfo":
+                    heLibraryCountVO.setIsFinished("1");
+                    break;
+                default:
+                    break;
+            }
+        }
+        List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.gethelibraryCountHyperlink(heLibraryCountVO);
+        return serviceSubtasks;
+    }
+
+    @Override
     public Map<String, Object> smsSubTask(Long subid) {
         log.info("smsSubTask鐨勫叆鍙備负锛歿}", subid);
         Map<String, Object> resultMap = new HashMap<>();
@@ -4555,6 +4702,11 @@
             }
         }
         return resultMap;
+    }
+
+    @Override
+    public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startOutHospTime, Date endOutHospTime) {
+        return serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime);
     }
 
     private Boolean saveServiceSubtaskDetail(ServiceSubtask serviceSubtask) {
@@ -4700,4 +4852,105 @@
         }
     }
 
+    public String scanGenerateSubtask(ServiceTask serviceTaskVo) {
+        String content = "";
+        String ip = localIP;
+        ServiceTask serviceTask = new ServiceTask();
+        serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceTaskVo.getTaskid());
+        if (ObjectUtils.isNotEmpty(serviceTask)) {
+            try {
+                ServiceTaskdept serviceTaskdept = new ServiceTaskdept();
+                if (ObjectUtils.isNotEmpty(serviceTaskVo.getDeptcode())) {
+                    serviceTaskdept.setDeptType("1");
+                    serviceTaskdept.setDeptCode(serviceTask.getDeptcode());
+                }
+                if (ObjectUtils.isNotEmpty(serviceTaskVo.getLeavehospitaldistrictcode())) {
+                    serviceTaskdept.setDeptType("2");
+                    serviceTaskdept.setDeptCode(serviceTaskVo.getLeavehospitaldistrictcode());
+                }
+                serviceTaskdept.setServiceType(serviceTask.getServiceType());
+                serviceTaskdept.setOrgid(serviceTask.getOrgid());
+                serviceTaskdept.setTaskId(serviceTaskVo.getTaskid());
+                List<ServiceTaskdept> serviceTaskdepts = serviceTaskdeptService.selectServiceTaskdeptList(serviceTaskdept);
+
+                if (!CollectionUtils.isEmpty(serviceTaskdepts)) {
+                    PatArchive patArchive = new PatArchive();
+                    patArchive.setId(-1L);
+                    patArchive.setName("铏氭嫙鎮h��");
+                    //灏佽serviceSubtask
+                    ServiceSubtask serviceSubtask = boxedServiceSubtask(serviceTask, patArchive);
+                    int i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
+                    //鏍规嵁鐢熸垚澶栭摼
+                    if (ObjectUtils.isNotEmpty(serviceSubtask.getTaskid()) && ObjectUtils.isNotEmpty(serviceSubtask.getPatid()) && ObjectUtils.isNotEmpty(serviceSubtask.getId())) {
+                        RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
+                        String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key);
+                        String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
+                        String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key);
+                        ServiceOutPath serviceOutPath = new ServiceOutPath();
+                        serviceOutPath.setParam1(taskId);
+                        serviceOutPath.setParam2(patid);
+                        serviceOutPath.setParam3(serviceTask.getTaskName());
+                        serviceOutPath.setParam6(subId);
+                        serviceOutPath.setCreateTime(new Date());
+                        serviceOutPath.setOrgid(serviceTask.getOrgid());
+                        iServiceOutPathService.insertServiceOutPath(serviceOutPath);
+                        String format = String.format("%03X", serviceOutPath.getId());
+                        serviceOutPath.setRadix(format);
+                        serviceOutPath.setUpdateTime(new Date());
+                        String url = ip + ":" + req_path + "/wt?p=" + format;
+                        content = url;
+                        serviceOutPath.setUrl(url);
+                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
+
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("銆愭壂鐮佺敓鎴愪换鍔°�戝鐞嗗紓甯革細{}", e.getMessage());
+            }
+        }
+        return content;
+    }
+
+    public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatArchive patArchive) {
+        ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTask, ServiceSubtask.class);
+        serviceSubtask.setTaskid(serviceTask.getTaskid());
+        if (StringUtils.isNotEmpty(serviceTask.getLibtemplateid()))
+            serviceSubtask.setLibtemplateid(Long.valueOf(serviceTask.getLibtemplateid()));
+//        serviceSubtask.setNurseId(patMedInhosp1.getNurseId());
+//        serviceSubtask.setNurseName(patMedInhosp1.getNurseName());
+//        serviceSubtask.setDrcode(patMedInhosp1.getDrcode());
+//        serviceSubtask.setDrname(patMedInhosp1.getDrname());
+        serviceSubtask.setDeptcode(serviceTask.getDeptcode());
+        serviceSubtask.setDeptname(serviceTask.getDeptname());
+        serviceSubtask.setLeavehospitaldistrictcode(serviceTask.getLeavehospitaldistrictcode());
+        serviceSubtask.setLeavehospitaldistrictname(serviceTask.getLeavehospitaldistrictname());
+        serviceSubtask.setTemplateid(serviceTask.getTemplateid());
+        serviceSubtask.setTemplatename(serviceTask.getTemplatename());
+        serviceSubtask.setPatid(patArchive.getId());
+        serviceSubtask.setSendname(patArchive.getName());
+        serviceSubtask.setSfzh(patArchive.getIdcardno());
+        serviceSubtask.setPhone(patArchive.getTelcode());
+        if (StringUtils.isBlank(patArchive.getTelcode())) serviceSubtask.setPhone(patArchive.getRelativetelcode());
+        serviceSubtask.setSex(patArchive.getSex());
+        serviceSubtask.setAge(patArchive.getAge());
+        serviceSubtask.setSendstate(3L);
+//        serviceSubtask.setManagementDoctor(patMedInhosp1.getManagementDoctor());
+//        serviceSubtask.setManagementDoctorCode(patMedInhosp1.getManagementDoctorCode());
+        serviceSubtask.setServiceType(serviceTask.getServiceType());
+        serviceSubtask.setPreachform(serviceTask.getPreachform());
+        serviceSubtask.setHospType("8");
+        serviceSubtask.setCreateTime(new Date());
+        serviceSubtask.setUpdateTime(new Date());
+//        serviceSubtask.setCreateBy(patMedInhosp1.getNurseName());
+//        serviceSubtask.setLeavehospitaldistrictcode(patMedInhosp1.getLeavehospitaldistrictcode());
+//        serviceSubtask.setLeavehospitaldistrictname(patMedInhosp1.getLeavehospitaldistrictname());
+        serviceSubtask.setUpdateBy(serviceTask.getUpdateBy());
+        serviceSubtask.setUpdateTime(new Date());
+        serviceTask.setSendDay(1L);
+        Date newDate = new Date();
+        serviceSubtask.setLongSendTime(newDate);
+        serviceSubtask.setVisitTime(newDate);
+        return serviceSubtask;
+    }
 }

--
Gitblit v1.9.3