From c111e3eff1191b29d2d2baf2f485a4bf3a2edc00 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期六, 16 八月 2025 14:34:07 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateServiceImpl.java                 |   21 
 ruoyi-common/src/main/java/com/ruoyi/common/utils/RSAPublicKeyExample.java                    |   95 +-
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatBabyGrowthController.java       |    4 
 smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java                             |    6 
 smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml                              |   52 +
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SchemeAutofinshruleController.java |    2 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java             |   55 +
 smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java                |   14 
 smartor/src/main/java/com/smartor/service/impl/ServiceTaskServiceImpl.java                    |    2 
 smartor/src/main/java/com/smartor/domain/PatArchiveVO.java                                    |    6 
 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java                         |    2 
 smartor/src/main/java/com/smartor/domain/ExternalPatientInfo.java                             |    3 
 smartor/src/main/java/com/smartor/domain/PatBabyGrowth.java                                   |    2 
 smartor/src/main/java/com/smartor/service/impl/ExternalInfoServiceImpl.java                   |    6 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java        |    2 
 smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml                             |   41 +
 ruoyi-admin/src/main/resources/application.yml                                                |    5 
 ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java     |   22 
 smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml                                |   68 +
 smartor/src/main/java/com/smartor/domain/PatArchiveOut.java                                   |    1 
 ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java                        |    7 
 .idea/compiler.xml                                                                            |    1 
 ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java                                      |    9 
 ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java                  |    2 
 smartor/src/main/java/com/smartor/domain/ServiceStatisticsRequest.java                        |   45 +
 smartor/src/main/java/com/smartor/domain/PatArchiveReq.java                                   |   11 
 smartor/src/main/java/com/smartor/domain/ServiceSubtask.java                                  |    3 
 ruoyi-admin/src/main/resources/application-druid-linshi.yml                                   |    6 
 ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml                               |    5 
 smartor/src/main/java/com/smartor/domain/ServiceStatisticsResponse.java                       |   39 +
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java               |   22 
 smartor/src/main/java/com/smartor/domain/PatArchive.java                                      |    7 
 smartor/src/main/java/com/smartor/mapper/SchemeAutofinshruleMapper.java                       |   20 
 smartor/src/main/java/com/smartor/service/ISchemeAutofinshruleService.java                    |   18 
 smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java                  |   18 
 smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java                   |   22 
 ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java            |   76 +-
 smartor/src/main/resources/mapper/smartor/ExternallInfoMapper.xml                             |    1 
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java                 |   33 +
 ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java                      |    3 
 smartor/src/main/resources/mapper/smartor/SchemeAutofinshruleMapper.xml                       |   22 
 smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java                            |    7 
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java                                |  109 +++
 ruoyi-admin/src/main/resources/application-local.yml                                          |   20 
 smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java                         |    6 
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml                            |  602 +++++++++++++--------
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java                                  |    5 
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java              |    7 
 smartor/src/main/java/com/smartor/service/impl/IvrLibaTemplateServiceImpl.java                |   16 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java      |   12 
 smartor/src/main/java/com/smartor/service/impl/SchemeAutofinshruleServiceImpl.java            |   46 
 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java                  |   42 
 52 files changed, 1,097 insertions(+), 554 deletions(-)

diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 47c11f7..45a1d4f 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -7,6 +7,7 @@
         <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
         <outputRelativeToContentRoot value="true" />
         <module name="ruoyi-framework" />
+        <module name="smartor-wuxi" />
         <module name="ruoyi-system" />
         <module name="smartor" />
         <module name="ruoyi-generator" />
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 49130ff..6e2e9fe 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
@@ -295,6 +295,7 @@
 
                     for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
                         //鍏堝垽鏂竴涓嬶紝subIds鏄惁涓虹┖锛屽鏋滀笉涓虹┖锛屽彧鎵цsubIds閲岀殑鎮h��
+                        log.info("-----subIds鐨勫�间负锛歿}", subIds);
                         if (CollectionUtils.isNotEmpty(subIds)) {
                             boolean contains = subIds.contains(serviceSubtask.getId());
                             //濡傛灉contains涓嶄负true,璇存槑褰撳墠鐨勬偅鑰呭凡缁忓彂閫佹垚鍔燂紝鐩存帴寰幆涓嬩竴涓汉灏辫
@@ -321,7 +322,7 @@
                                 sendMagParam.setPhone(serviceSubtask.getPhone());
                                 sendMagParam.setUrl(ip + ":" + req_path + "/sf?p=" + format);
                                 sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "   濉啓銆傛劅璋㈡偍閰嶅悎锛�");
-                                log.info("888888888888:{}",sendMagParam);
+                                log.info("888888888888:{}", sendMagParam);
                             } else if (type == 2) {
                                 //闂埜锛堥棶棰橈級
                                 ServiceOutPath serviceOutPath = new ServiceOutPath();
@@ -340,7 +341,7 @@
                                 sendMagParam.setPhone(serviceSubtask.getPhone());
                                 sendMagParam.setUrl(ip + ":" + req_path + "/wt?p=" + format);
                                 sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "   濉啓銆傛劅璋㈡偍閰嶅悎锛�");
-                                log.info("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�,{}",sendMagParam.getUrl());
+                                log.info("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�,{}", sendMagParam.getUrl());
                             } else if (type == 3) {
                                 //瀹f暀
                                 ServiceOutPath serviceOutPath = new ServiceOutPath();
@@ -358,6 +359,7 @@
                                 sendMagParam.setPhone(serviceSubtask.getPhone());
                                 sendMagParam.setUrl(ip + ":" + req_path + "/xj?p=" + format);
                                 sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+                                log.info("-----------sendMagParam鐨勫�间负锛歿}", sendMagParam);
                             }
                             //鐭俊杩橀渶瑕佹ā鏉�
 //                            Map<String, String> req = new HashMap<>();
@@ -374,6 +376,7 @@
                             SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmsszzz"); // 杈撳嚭鏃ユ湡鏍煎紡
                             strb.append("&send_time=" + dateFormat.format(new Date()));
                             String isSuccess = HttpUtil.postFormRequest(xhsmsPath, strb.toString());
+                            log.info("-----------sisSuccess鐨勫�间负锛歿}", isSuccess);
                             if (StringUtils.isNotEmpty(isSuccess) && isSuccess.contains("200")) {
                                 ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord();
                                 serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString());
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
index 8ad8488..6e219b2 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -59,6 +59,12 @@
     @Value("${uploadSwitch}")
     private Integer uploadSwitch;
 
+    @Value("${req_path}")
+    private String reqPath;
+
+    @Value("${localIP}")
+    private String localIP;
+
     /**
      * 閫氱敤涓嬭浇璇锋眰
      *
@@ -108,7 +114,10 @@
             String fileName = FileUploadUtils.uploadSort(filePath, file);
             String url = null;
             //鏂板崕鍖婚櫌鐗规畩锛岃繖涓棰戠殑璁块棶寰楄浆
-            String xhPath = "http://218.108.11.22:8093/profile-api";
+            String xhPath = localIP + ":" + reqPath + "/profile-api";
+            if (localIP.contains("127.0.0.1") || localIP.contains("localhost")) {
+                xhPath = localIP + ":8095" + "/profile";
+            }
             if (uploadSwitch == 1) {
                 String fn = fileName.replaceAll("/profile", "");
                 url = xhPath + fn;
@@ -143,7 +152,10 @@
             convertDocToHtml(filePath + "\\" + file.getOriginalFilename(), filePath + "\\" + file.getOriginalFilename().split("\\.", 2)[0] + ".html");
 
             String url = null;
-            String xhPath = "http://218.108.11.22:8093/profile-api";
+            String xhPath = localIP + ":" + reqPath + "/profile-api";
+            if (localIP.contains("127.0.0.1") || localIP.contains("localhost")) {
+                xhPath = localIP + ":8095" + "/profile";
+            }
             if (uploadSwitch == 1) {
                 String fn = fileName.replaceAll("\\.[^.]*$", ".html").replaceAll("/profile", "");
                 url = xhPath + fn;
@@ -269,7 +281,10 @@
             e.printStackTrace();
         }
         String url = null;
-        String xhPath = "http://218.108.11.22:8093/profile-api";
+        String xhPath = localIP + ":" + reqPath + "/profile-api";
+        if (localIP.contains("127.0.0.1") || localIP.contains("localhost")) {
+            xhPath = localIP + ":8095" + "/profile";
+        }
         if (uploadSwitch == 1) {
             url = xhPath + "/upload/show/" + fileName.split("\\.", 2)[0] + "/" + fileName;
         } else {
@@ -313,6 +328,5 @@
         System.out.println("word杞琱tml鎴愬姛");
 
     }
-
 
 }
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatBabyGrowthController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatBabyGrowthController.java
index fd2e91a..5ec70ff 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatBabyGrowthController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatBabyGrowthController.java
@@ -52,9 +52,9 @@
 
 
     /**
-     * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛�
+     * 鏌ヨ濠村効鎴愰暱璁板綍鍙�
      */
-    @ApiOperation("鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛�")
+    @ApiOperation("鏌ヨ濠村効鎴愰暱璁板綍鍙�")
     //@PreAuthorize("@ss.hasPermi('smartor:growth:list')")
     @PostMapping("/dateLine")
     public TableDataInfo dateLine(@RequestBody PatBabyGrowth patBabyGrowth)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java
index 778baac..d18f398 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java
@@ -93,6 +93,8 @@
     @PostMapping("/selectPatMedInhospListCount")
     @ApiOperation("鏌ヨ鍑恒�佸叆闄㈢湅鐥呬汉娆″拰浜烘暟")
     public AjaxResult selectPatMedInhospListCount(PatMedReq patMedReq) {
+        SysUser user = getLoginUser().getUser();
+        patMedReq.setOrgid(user.getOrgid());
         return success(patMedInhospService.selectPatMedInhospListCount(patMedReq));
     }
 
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SchemeAutofinshruleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SchemeAutofinshruleController.java
index 61238b2..435d84f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SchemeAutofinshruleController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SchemeAutofinshruleController.java
@@ -18,7 +18,7 @@
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.smartor.domain.SchemeAutofinshrule;
-import com.ruoyi.smartor.service.ISchemeAutofinshruleService;
+import com.smartor.service.ISchemeAutofinshruleService;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.page.TableDataInfo;
 
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 93bc9de..63bf27b 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
@@ -268,4 +268,16 @@
         return success(serviceSubtaskService.getSfStatistics(serviceSubtaskCountReq));
     }
 
+    /**
+     * 闅忚缁熻瀵煎嚭
+     */
+    @ApiOperation("鏈嶅姟缁熻鏌ヨ-鎸夋椂闂寸淮搴︾粺璁″嚭闄�/闂ㄨ瘖闅忚鏁版嵁")
+    @PostMapping("/getServiceStatistics")
+    public AjaxResult getServiceStatistics(@RequestBody ServiceStatisticsRequest serviceStatisticsRequest) {
+        SysUser user = getLoginUser().getUser();
+        serviceStatisticsRequest.setOrgid(user.getOrgid());
+        List<ServiceStatisticsResponse> serviceStatistics = serviceSubtaskService.getServiceStatistics(serviceStatisticsRequest);
+        return success(serviceStatistics);
+    }
+
 }
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 ff19edc..ba801bf 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
@@ -2,10 +2,17 @@
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Map;
+import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.system.mapper.SysUserMapper;
+import com.smartor.domain.BaseSmsRequest;
+import com.smartor.service.IBaseSmsaccountService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -41,6 +48,17 @@
     @Autowired
     private SysUserMapper sysUserMapper;
 
+    @Autowired
+    private RedisCache redisCache;
+
+    @Autowired
+    private IBaseSmsaccountService baseSmsaccountService;
+
+
+    @Value("${spring.profiles.active}")
+    private String active;
+
+
     /**
      * 鐧诲綍鏂规硶
      *
@@ -50,8 +68,14 @@
     @PostMapping("/login")
     public AjaxResult login(@RequestBody LoginBody loginBody) {
         AjaxResult ajax = AjaxResult.success();
-        // 鐢熸垚浠ょ墝
-        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid());
+        String token = null;
+        if (loginBody.getPhoneCode() != null) {
+            String phone = redisCache.getCacheObject(loginBody.getPhoneCode());
+            token = loginService.loginByPhone(phone);
+        } else {
+            // 鐢熸垚浠ょ墝
+            token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid());
+        }
         ajax.put(Constants.TOKEN, token);
         return ajax;
     }
@@ -102,4 +126,31 @@
         List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
         return AjaxResult.success(menuService.buildMenus(menus));
     }
+
+    /**
+     * 楠岃瘉鐮佸彂閫�
+     *
+     * @param payload
+     * @return
+     */
+    @PostMapping("/phoneLogin")
+    public AjaxResult sendCode(@RequestBody Map<String, String> payload) {
+        String phone = payload.get("phone");
+        String code = String.format("%06d", new Random().nextInt(999999));
+
+        // 瀛樺叆 Redis锛屾湁鏁堟湡2鍒嗛挓
+        redisCache.setCacheObject(code, phone, 2, TimeUnit.MINUTES);
+
+        //鏃犻敗绾夸笂鐜鎵嶅彂鐭俊
+        if (active.equals("wx")) {
+            BaseSmsRequest baseSmsRequest = new BaseSmsRequest();
+            baseSmsRequest.setPhoneNumber(phone);
+            baseSmsRequest.setContent("鐧婚檰楠岃瘉鐮侊細" + code + " 锛�2鍒嗛挓鍐呮晥锛屽垏鍕垮皢楠岃瘉鐮佹彁渚涚粰浠栦汉锛岃皑闃茶楠椼��");
+            baseSmsaccountService.sendMsg(baseSmsRequest);
+        }
+        // 璋冪敤鐭俊鏈嶅姟鍙戦�侀獙璇佺爜
+        System.out.println("鐧婚檰楠岃瘉鐮侊細" + code);
+
+        return AjaxResult.success(true);
+    }
 }
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 663e117..7c40ee1 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
@@ -2,6 +2,7 @@
 
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.RSAPublicKeyExample;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.FileUtils;
 import com.smartor.domain.ServiceSubtaskDetail;
@@ -48,9 +49,11 @@
 
     @Test
     public void bb() {
-        String key="1-9-WJscriptCache";
-        String[] split = key.split("-");
-        System.out.println(split.clone());
+        RSAPublicKeyExample rsaPublicKeyExample=new RSAPublicKeyExample();
+//        String s1 = rsaPublicKeyExample.encryptedData("123456", "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALQzqW1EIXBKGMu+2oEYSB5gM7Ox/ihyYTeeoE0yPX1qtt4++5yNOeTBVd6EEM4iKzVEzWj6REIWVwaSNPn/SvUCAwEAAQ==");
+
+        String s = rsaPublicKeyExample.decryptedData("J7V6yb5WHW63bQMbMyzxeT07HGesIXJwy9w77zBa6KG4PnWe7uaZh00vX21w%2Bn5FW8%2BjUAAU1HatqRWzFp7fvA%3D%3D", "MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAtDOpbUQhcEoYy77agRhIHmAzs7H+KHJhN56gTTI9fWq23j77nI055MFV3oQQziIrNUTNaPpEQhZXBpI0+f9K9QIDAQABAkB3n0fcWfrcoMN/FU3VnrnZOEF6CzFNxkgU9P8y36QECWKZ9JhYQkNpKrMC9oXlN3VSaRigV7B+L/I/a0Rs1W+tAiEA4jx7xcXJ4y4BNwAmVHt6NNiEkzIwWnwC/0qsEu8NsOsCIQDL6MMn1D2uznC6OuOWpxDCkBh1JL1NzZTZeH2G+hj7nwIgKGAC9tjFnvWm4dn0/T7MIIJDpsFeP8fCAS2iZ/6hwuECIAS/eLvWr1EAsZNEh8QcQ8GkBU3E+ztyjAK8UX/xFt/VAiBf79/1tDErX4/DChecM8w3c3DhbBcjuE3fHZn7p6/UKg==");
+    System.out.println(s);
     }
 
     public void aa(MultipartFile file) throws IOException {
diff --git a/ruoyi-admin/src/main/resources/application-druid-linshi.yml b/ruoyi-admin/src/main/resources/application-druid-linshi.yml
index 636364d..3fdb921 100644
--- a/ruoyi-admin/src/main/resources/application-druid-linshi.yml
+++ b/ruoyi-admin/src/main/resources/application-druid-linshi.yml
@@ -144,9 +144,9 @@
 #req_path: 8095
 #localIP: 192.168.2.10
 
-#鏂板崕鍖婚櫌澶栭摼璇锋眰IP鍜岀鍙e彿
-req_path: 8093
-localIP: 218.108.11.22
+#澶栭摼璇锋眰IP鍜岀鍙e彿
+req_path: 8092
+localIP: 192.16.4.220
 
 #鑾峰彇鎮h�呬俊鎭疷RL(鍗庡崜鎻愪緵)
 hosp_info_url: http://esb-core-rest.wowjoy.cn/esb/exchange
diff --git a/ruoyi-admin/src/main/resources/application-local.yml b/ruoyi-admin/src/main/resources/application-local.yml
index c03a5b5..02158fe 100644
--- a/ruoyi-admin/src/main/resources/application-local.yml
+++ b/ruoyi-admin/src/main/resources/application-local.yml
@@ -19,15 +19,15 @@
         #        password: csbsbxt@123
         #        driver-class-name: org.postgresql.Driver
         #      鏈湴楂樻柉
-        url: jdbc:postgresql://192.168.100.138:5432/postgres
+        url: jdbc:postgresql://192.168.100.126:5432/postgres
         username: gaussdb
         password: Ls@123456
         driver-class-name: org.postgresql.Driver
         #      楂樻柉鏁版嵁搴撻摼鎺�
-#        url: jdbc:postgresql://172.20.32.115:15400/smartorwx?prepareThreshold=0
-#        username: shuifang
-#        password: Shuifang@51868
-#        driver-class-name: org.postgresql.Driver
+      #        url: jdbc:postgresql://172.20.32.115:15400/smartorwx?prepareThreshold=0
+      #        username: shuifang
+      #        password: Shuifang@51868
+      #        driver-class-name: org.postgresql.Driver
 
       #        鍏徃浜�
       #        url: jdbc:mysql://116.62.18.175:6002/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
@@ -79,15 +79,15 @@
           # 鎱QL璁板綍
           log-slow-sql: true
           slow-sql-millis: 1000
-          merge-sql: false
+          merge-sql: true
         wall:
           config:
             multi-statement-allow: true
   # redis 閰嶇疆
   redis:
     #    # 鍦板潃锛堟棤閿′汉姘戝尰闄級
-#    host: 127.0.0.1
-#    port: 6020
+    #    host: 127.0.0.1
+    #    port: 6020
 
     # 鍦板潃锛堝叕鍙革級
     host: 127.0.0.1
@@ -181,8 +181,8 @@
 qrpath: D:\qrcode
 
 #鏃犻敗鍐呭閾捐姹侷P鍜岀鍙e彿
-req_path: 8092/wxsf
-localIP: 192.168.100.128
+req_path: 8093
+localIP: 127.0.0.1
 #req_path: 8092
 #localIP: http://61.160.111.174
 
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index 386cd22..ab6c255 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -9,7 +9,8 @@
   # 瀹炰緥婕旂ず寮�鍏�
   demoEnabled: true
   # 鏂囦欢璺緞 绀轰緥锛� Windows閰嶇疆D:/ruoyi/uploadPath锛孡inux閰嶇疆 /home/ruoyi/uploadPath锛�
-  profile: D:/ruoyi/uploadPath
+#  profile: D:/ruoyi/uploadPath
+  profile: /home/software/uploadPath
   # 鑾峰彇ip鍦板潃寮�鍏�
   addressEnabled: false
   # 楠岃瘉鐮佺被鍨� math 鏁扮粍璁$畻 char 瀛楃楠岃瘉
@@ -74,7 +75,7 @@
     # 鍥介檯鍖栬祫婧愭枃浠惰矾寰�
     basename: i18n/messages
   profiles:
-    active: wx
+    active: local
   # 鏂囦欢涓婁紶
   servlet:
     multipart:
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java
index b5bc8c8..319ed7a 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java
@@ -2,11 +2,10 @@
 
 /**
  * 鐢ㄦ埛鐧诲綍瀵硅薄
- * 
+ *
  * @author ruoyi
  */
-public class LoginBody
-{
+public class LoginBody {
     /**
      * 鐢ㄦ埛鍚�
      */
@@ -23,47 +22,52 @@
     private String code;
 
     /**
+     * 鎵嬫満楠岃瘉鐮�
+     */
+    private String phoneCode;
+
+    /**
      * 鍞竴鏍囪瘑
      */
     private String uuid;
 
-    public String getUsername()
-    {
+    public String getUsername() {
         return username;
     }
 
-    public void setUsername(String username)
-    {
+    public void setUsername(String username) {
         this.username = username;
     }
 
-    public String getPassword()
-    {
+    public String getPassword() {
         return password;
     }
 
-    public void setPassword(String password)
-    {
+    public void setPassword(String password) {
         this.password = password;
     }
 
-    public String getCode()
-    {
+    public String getCode() {
         return code;
     }
 
-    public void setCode(String code)
-    {
+    public void setCode(String code) {
         this.code = code;
     }
 
-    public String getUuid()
-    {
+    public String getUuid() {
         return uuid;
     }
 
-    public void setUuid(String uuid)
-    {
+    public void setUuid(String uuid) {
         this.uuid = uuid;
     }
+
+    public String getPhoneCode() {
+        return phoneCode;
+    }
+
+    public void setPhoneCode(String phoneCode) {
+        this.phoneCode = phoneCode;
+    }
 }
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/RSAPublicKeyExample.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/RSAPublicKeyExample.java
index 2159f6d..4570e97 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/RSAPublicKeyExample.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/RSAPublicKeyExample.java
@@ -20,71 +20,58 @@
 public class RSAPublicKeyExample {
 
 
-    /**
-     * 鏁版嵁瑙e瘑
-     *
-     * @param encryptedData
-     * @return
-     */
-    public String decryptedData(String encryptedData, String pri_key) {
-        String privateKeyString = "绉侀挜鐨凚ase64缂栫爜瀛楃涓�"; // 鍚庣绉侀挜鐨凚ase64缂栫爜瀛楃涓�
-
+    public static String encryptedData(String plainText, String pubKey) {
         try {
-            // 灏嗙閽ase64缂栫爜瀛楃涓茶浆鎹负PrivateKey瀵硅薄
-            byte[] privateKeyBytes = Base64.getDecoder().decode(pri_key);
-            PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
-            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
-            PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
-
-            // 浣跨敤绉侀挜瑙e瘑鏁版嵁
-            Cipher decryptCipher = Cipher.getInstance("RSA");
-            decryptCipher.init(Cipher.DECRYPT_MODE, privateKey);
-            byte[] decryptedBytes = decryptCipher.doFinal(Base64.getDecoder().decode(encryptedData));
-
-            // 瑙e瘑鍚庣殑鏁版嵁
-            String decryptedData = new String(decryptedBytes);
-            System.out.println("瑙e瘑鍚庣殑鏁版嵁锛�" + decryptedData);
-            return decryptedData;
-        } catch (Exception e) {
-            log.error("瑙e瘑鎶ラ敊浜�:{}", e.getMessage());
-        }
-        return null;
-    }
-
-    /**
-     * 瑕佸姞瀵嗙殑鏄庢枃鏁版嵁
-     *
-     * @param plainText
-     * @return
-     */
-    public String encryptedData(String plainText, String pub_key) {
-        log.error("闇�瑕佸姞瀵嗙殑鏁版嵁锛歿}", plainText);
-        try {
-
-            byte[] publicKeyBytes = Base64.getDecoder().decode(pub_key);
+            byte[] publicKeyBytes = Base64.getDecoder().decode(pubKey);
             X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyBytes);
             KeyFactory keyFactory = KeyFactory.getInstance("RSA");
             PublicKey publicKey = keyFactory.generatePublic(keySpec);
 
-            // 浣跨敤鍏挜鍔犲瘑鏁版嵁
-            Cipher encryptCipher = Cipher.getInstance("RSA");
-            encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey);
-            byte[] encryptedBytes = encryptCipher.doFinal(plainText.getBytes());
+            Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
+            cipher.init(Cipher.ENCRYPT_MODE, publicKey);
+            byte[] encryptedBytes = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8));
 
-            // 灏嗗姞瀵嗗悗鐨勬暟鎹浆鎹负Base64缂栫爜鐨勫瓧绗︿覆
+            // Base64 缂栫爜锛堝繀椤讳繚鐣欙級
             String encryptedText = Base64.getEncoder().encodeToString(encryptedBytes);
-            log.error("Base64鍔犲瘑鍚庣殑鏁版嵁锛歿}", encryptedText);
-            encryptedText = URLEncoder.encode(encryptedText, StandardCharsets.UTF_8.toString());
-            log.error("URLEncoder缂栫爜鍚庣殑鏁版嵁锛歿}", encryptedText);
-            String decodedString = URLDecoder.decode(encryptedText, "UTF-8");
-            log.error("URLEncoder瑙g爜鍚庣殑鏁版嵁锛歿}", decodedString);
-            return encryptedText;
+
+            // 鍙�夛細濡傛灉鐢ㄤ簬 URL 浼犺緭锛屽啀杩涜 URL 缂栫爜
+            return URLEncoder.encode(encryptedText, StandardCharsets.UTF_8.toString());
         } catch (Exception e) {
-            log.error("鍔犲瘑澶辫触浜�:{}", e.getMessage());
+            System.err.println("鍔犲瘑澶辫触: " + e.getMessage());
+            e.printStackTrace();
+            return null;
         }
-        return null;
     }
 
+    /**
+     * RSA 绉侀挜瑙e瘑锛堣В瀵� Base64 缂栫爜鍚庣殑瀵嗘枃锛屾敮鎸� URL 瑙g爜锛�
+     */
+    public static String decryptedData(String encryptedData, String priKey) {
+        try {
+            // 鍙�夛細鍏� URL 瑙g爜锛堝鏋滃姞瀵嗗墠鍋氫簡 URLEncoder锛�
+            String base64Encrypted = URLDecoder.decode(encryptedData, StandardCharsets.UTF_8.toString());
+
+            // Base64 瑙g爜
+            byte[] encryptedBytes = Base64.getDecoder().decode(base64Encrypted);
+
+            byte[] privateKeyBytes = Base64.getDecoder().decode(priKey);
+            PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
+            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+            PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
+
+            Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
+            cipher.init(Cipher.DECRYPT_MODE, privateKey);
+            byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
+
+            return new String(decryptedBytes, StandardCharsets.UTF_8);
+        } catch (Exception e) {
+            System.err.println("瑙e瘑澶辫触: " + e.getMessage());
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
     public static void main(String[] args) {
         String decodedString = null;
         try {
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 baadebb..e596e61 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").permitAll()
+                .antMatchers("/login","/phoneLogin", "/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").permitAll()
                 // 闈欐�佽祫婧愶紝鍙尶鍚嶈闂�
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll().antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                 // 闄や笂闈㈠鐨勬墍鏈夎姹傚叏閮ㄩ渶瑕侀壌鏉冭璇�
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
index 2e15267..afa9240 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -1,6 +1,9 @@
 package com.ruoyi.framework.web.service;
 
 import javax.annotation.Resource;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -27,14 +30,15 @@
 import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.system.service.ISysUserService;
 
+import java.util.List;
+
 /**
  * 鐧诲綍鏍¢獙鏂规硶
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class SysLoginService
-{
+public class SysLoginService {
     @Autowired
     private TokenService tokenService;
 
@@ -43,7 +47,7 @@
 
     @Autowired
     private RedisCache redisCache;
-    
+
     @Autowired
     private ISysUserService userService;
 
@@ -52,45 +56,35 @@
 
     /**
      * 鐧诲綍楠岃瘉
-     * 
+     *
      * @param username 鐢ㄦ埛鍚�
      * @param password 瀵嗙爜
-     * @param code 楠岃瘉鐮�
-     * @param uuid 鍞竴鏍囪瘑
+     * @param code     楠岃瘉鐮�
+     * @param uuid     鍞竴鏍囪瘑
      * @return 缁撴灉
      */
-    public String login(String username, String password, String code, String uuid)
-    {
+    public String login(String username, String password, String code, String uuid) {
         boolean captchaEnabled = configService.selectCaptchaEnabled();
         // 楠岃瘉鐮佸紑鍏�
-        if (captchaEnabled)
-        {
+        if (captchaEnabled) {
             validateCaptcha(username, code, uuid);
         }
         // 鐢ㄦ埛楠岃瘉
         Authentication authentication = null;
-        try
-        {
+        try {
             UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
             AuthenticationContextHolder.setContext(authenticationToken);
             // 璇ユ柟娉曚細鍘昏皟鐢║serDetailsServiceImpl.loadUserByUsername
             authentication = authenticationManager.authenticate(authenticationToken);
-        }
-        catch (Exception e)
-        {
-            if (e instanceof BadCredentialsException)
-            {
+        } catch (Exception e) {
+            if (e instanceof BadCredentialsException) {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
                 throw new UserPasswordNotMatchException();
-            }
-            else
-            {
+            } else {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
                 throw new ServiceException(e.getMessage());
             }
-        }
-        finally
-        {
+        } finally {
             AuthenticationContextHolder.clearContext();
         }
         AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
@@ -100,26 +94,39 @@
         return tokenService.createToken(loginUser);
     }
 
+
+    public String loginByPhone(String phone) {
+        SysUser sysUser = userService.selectUserByPhone(phone);
+        if (ObjectUtils.isNotEmpty(sysUser)) {
+            // 鏋勫缓鐧诲綍鐢ㄦ埛瀵硅薄
+            LoginUser loginUser = new LoginUser();
+            loginUser.setUser(sysUser);
+            loginUser.setUserId(sysUser.getUserId());
+            // 鍒涘缓 token
+            String token = tokenService.createToken(loginUser);
+            // 鐢熸垚token
+            return token;
+        }
+        return null;
+    }
+
     /**
      * 鏍¢獙楠岃瘉鐮�
-     * 
+     *
      * @param username 鐢ㄦ埛鍚�
-     * @param code 楠岃瘉鐮�
-     * @param uuid 鍞竴鏍囪瘑
+     * @param code     楠岃瘉鐮�
+     * @param uuid     鍞竴鏍囪瘑
      * @return 缁撴灉
      */
-    public void validateCaptcha(String username, String code, String uuid)
-    {
+    public void validateCaptcha(String username, String code, String uuid) {
         String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
         String captcha = redisCache.getCacheObject(verifyKey);
         redisCache.deleteObject(verifyKey);
-        if (captcha == null)
-        {
+        if (captcha == null) {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
             throw new CaptchaExpireException();
         }
-        if (!code.equalsIgnoreCase(captcha))
-        {
+        if (!code.equalsIgnoreCase(captcha)) {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
             throw new CaptchaException();
         }
@@ -130,8 +137,7 @@
      *
      * @param userId 鐢ㄦ埛ID
      */
-    public void recordLoginInfo(Long userId)
-    {
+    public void recordLoginInfo(Long userId) {
         SysUser sysUser = new SysUser();
         sysUser.setUserId(userId);
         sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
index 1950cb7..cc0e1b3 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
@@ -20,13 +20,12 @@
  * @author ruoyi
  */
 @Service
-public class UserDetailsServiceImpl implements UserDetailsService
-{
+public class UserDetailsServiceImpl implements UserDetailsService {
     private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
 
     @Autowired
     private ISysUserService userService;
-    
+
     @Autowired
     private SysPasswordService passwordService;
 
@@ -34,21 +33,15 @@
     private SysPermissionService permissionService;
 
     @Override
-    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
-    {
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
         SysUser user = userService.selectUserByUserName(username);
-        if (StringUtils.isNull(user))
-        {
+        if (StringUtils.isNull(user)) {
             log.info("鐧诲綍鐢ㄦ埛锛歿} 涓嶅瓨鍦�.", username);
             throw new ServiceException("鐧诲綍鐢ㄦ埛锛�" + username + " 涓嶅瓨鍦�");
-        }
-        else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
-        {
+        } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
             log.info("鐧诲綍鐢ㄦ埛锛歿} 宸茶鍒犻櫎.", username);
             throw new ServiceException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿锛�" + username + " 宸茶鍒犻櫎");
-        }
-        else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
-        {
+        } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
             log.info("鐧诲綍鐢ㄦ埛锛歿} 宸茶鍋滅敤.", username);
             throw new ServiceException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿锛�" + username + " 宸插仠鐢�");
         }
@@ -58,8 +51,7 @@
         return createLoginUser(user);
     }
 
-    public UserDetails createLoginUser(SysUser user)
-    {
+    public UserDetails createLoginUser(SysUser user) {
         return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
     }
 }
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 04ba330..3cd0be3 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
@@ -161,17 +161,13 @@
             JsonNode resultListNode = rootNode.path("results").path("resultList");
             // 閬嶅巻resultList涓殑姣忎釜瀵硅薄
             for (JsonNode item : resultListNode) {
-
                 SysUserImport person = objectMapper.treeToValue(item, SysUserImport.class);
                 person.setStaffPhoto("");
                 sysUserImportMapper.insertSysUserImport(person);
-
             }
-
         } catch (IOException e) {
             e.printStackTrace();
         }
-
     }
 
     public void analysisData() {
@@ -208,7 +204,6 @@
         } catch (Exception e) {
             log.error("閲囬泦鍑洪櫌鏁版嵁鍑洪棶棰樹簡锛歿}", e.getMessage());
         }
-
     }
 //
 //    public void dealHisData2() {
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
index ef29761..57037fc 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
@@ -45,6 +45,8 @@
      */
     public SysUser selectUserByUserName(String userName);
 
+    public SysUser selectUserByPhone(String phone);
+
     /**
      * 閫氳繃鐢ㄦ埛ID鏌ヨ鐢ㄦ埛
      *
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
index d588a5e..90d2f7d 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
@@ -42,6 +42,9 @@
      */
     public SysUser selectUserByUserName(String userName);
 
+    public SysUser selectUserByPhone(String phone);
+
+
     /**
      * 閫氳繃鐢ㄦ埛ID鏌ヨ鐢ㄦ埛
      *
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index 52295ea..07b4dde 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -104,6 +104,11 @@
      * @return 鐢ㄦ埛瀵硅薄淇℃伅
      */
     @Override
+    public SysUser selectUserByPhone(String phone) {
+        return userMapper.selectUserByPhone(phone);
+    }
+
+    @Override
     public SysUser selectUserByUserName(String userName) {
         SysUser sysUser = userMapper.selectUserByUserName(userName);
         List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(sysUser.getUserId());
@@ -142,7 +147,7 @@
             }
             sysUser.setBelongWards(list);
         }
-        log.error("娼樺鐨勭瀹ゆ槸锛歿}",sysUserDeptKSs);
+        log.error("娼樺鐨勭瀹ゆ槸锛歿}", sysUserDeptKSs);
         if (!CollectionUtils.isEmpty(sysUserDeptKSs)) {
             List<Map<String, Object>> list = new ArrayList<>();
             for (SysUserDept sud : sysUserDeptKSs) {
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index 649cd71..1acf6dd 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -210,6 +210,11 @@
         where u.user_name = #{userName} and u.del_flag = '0'
     </select>
 
+    <select id="selectUserByPhone" parameterType="String" resultMap="SysUserResult">
+        <include refid="selectUserVo"/>
+        where u.phonenumber = #{phone} and u.del_flag = '0'
+    </select>
+
     <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
         <include refid="selectUserVo"/>
         where u.user_id = #{userId}
diff --git a/smartor/src/main/java/com/smartor/domain/ExternalPatientInfo.java b/smartor/src/main/java/com/smartor/domain/ExternalPatientInfo.java
index 3c26723..e201bb1 100644
--- a/smartor/src/main/java/com/smartor/domain/ExternalPatientInfo.java
+++ b/smartor/src/main/java/com/smartor/domain/ExternalPatientInfo.java
@@ -66,6 +66,9 @@
     @ApiModelProperty(value = "瀹跺涵鐢佃瘽")
     private String jtdh;
 
+    @ApiModelProperty(value = "棰勭暀鐢佃瘽")
+    private String yldh;
+
     @ApiModelProperty(value = "鎴峰彛鍦板潃")
     private String hkdz;
 
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchive.java b/smartor/src/main/java/com/smartor/domain/PatArchive.java
index a11633e..0c117d8 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchive.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchive.java
@@ -214,6 +214,13 @@
     private String relativetelcode;
 
     /**
+     * 棰勭暀鍙风爜
+     */
+    @ApiModelProperty("棰勭暀鍙风爜")
+    @Excel(name = " 棰勭暀鍙风爜 ")
+    private String reservedPhone;
+
+    /**
      * 姘戞棌
      */
     @ApiModelProperty("姘戞棌")
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java b/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java
index 95fc786..89c7696 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java
@@ -221,6 +221,12 @@
     @Excel(name = " 鎵嬫満鍙风爜 ")
     private String telcode;
 
+    /**
+     * 棰勭暀鍙风爜
+     */
+    @ApiModelProperty("棰勭暀鍙风爜")
+    @Excel(name = " 棰勭暀鍙风爜 ")
+    private String reservedPhone;
 
     /**
      * 浜插睘鍙风爜
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchiveOut.java b/smartor/src/main/java/com/smartor/domain/PatArchiveOut.java
index 6894c20..259cdea 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchiveOut.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchiveOut.java
@@ -129,6 +129,7 @@
     @ApiModelProperty("鎵嬫満鍙风爜")
     private String telcode;
 
+
     /**
      * 浜插睘鍙风爜
      */
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java b/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java
index c833922..3d748a6 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java
@@ -74,6 +74,13 @@
     private String telcode;
 
     /**
+     * 棰勭暀鍙风爜
+     */
+    @ApiModelProperty("棰勭暀鍙风爜")
+    @Excel(name = " 棰勭暀鍙风爜 ")
+    private String reservedPhone;
+
+    /**
      * 鎵嬫満鍙风爜
      */
     @ApiModelProperty("鎵嬫満鍙风爜")
@@ -199,9 +206,9 @@
     private List<String> leaveldeptcodes;
 
     /**
-     * 鐥呭尯缂栧彿
+     * 鐥呭尯缂栧彿闆嗗悎
      */
-    @ApiModelProperty(value = "鐥呭尯缂栧彿")
+    @ApiModelProperty(value = "鐥呭尯缂栧彿闆嗗悎")
     private List<String> hospitaldistrictcodes;
 
     /**
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchiveVO.java b/smartor/src/main/java/com/smartor/domain/PatArchiveVO.java
index a6be5e7..0e2e82d 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchiveVO.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchiveVO.java
@@ -134,6 +134,12 @@
     @Excel(name = " 鎵嬫満鍙风爜 ")
     private String telcode;
 
+    /**
+     * 棰勭暀鍙风爜
+     */
+    @ApiModelProperty("棰勭暀鍙风爜")
+    @Excel(name = " 棰勭暀鍙风爜 ")
+    private String reservedPhone;
 
     /**
      * 浜插睘鍙风爜
diff --git a/smartor/src/main/java/com/smartor/domain/PatBabyGrowth.java b/smartor/src/main/java/com/smartor/domain/PatBabyGrowth.java
index 8f29a6c..a56dade 100644
--- a/smartor/src/main/java/com/smartor/domain/PatBabyGrowth.java
+++ b/smartor/src/main/java/com/smartor/domain/PatBabyGrowth.java
@@ -57,7 +57,7 @@
      */
     @ApiModelProperty("鑳庨緞锛堝懆锛�")
     @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
-    private Long age;
+    private String age;
 
     /**
      * $column.columnComment
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceStatisticsRequest.java b/smartor/src/main/java/com/smartor/domain/ServiceStatisticsRequest.java
new file mode 100644
index 0000000..82f376c
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/ServiceStatisticsRequest.java
@@ -0,0 +1,45 @@
+package com.smartor.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 鏈嶅姟缁熻璇锋眰鍙傛暟
+ *
+ * @author smartor
+ * @date 2025-01-14
+ */
+@ApiModel(value = "ServiceStatisticsRequest", description = "鏈嶅姟缁熻璇锋眰鍙傛暟")
+@Data
+public class ServiceStatisticsRequest {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "寮�濮嬫棩鏈�", required = true, example = "2025-08-01")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date startDate;
+
+    @ApiModelProperty(value = "缁撴潫鏃ユ湡", required = true, example = "2025-08-05")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date endDate;
+
+    @ApiModelProperty(value = "缁熻缁村害锛歞ay-鎸夊ぉ, month-鎸夋湀, year-鎸夊勾", example = "day")
+    private String timeType = "day";
+
+    @ApiModelProperty(value = "鏈烘瀯ID锛屼负绌哄垯鏌ヨ鎵�鏈�")
+    private String orgid;
+
+    @ApiModelProperty(value = "绉戝缂栫爜鍒楄〃锛屼负绌哄垯鏌ヨ鎵�鏈�")
+    private List<String> deptcodes;
+
+    @ApiModelProperty(value = "鐥呭尯缂栫爜鍒楄〃锛屼负绌哄垯鏌ヨ鎵�鏈�")
+    private List<String> leavehospitaldistrictcodes;
+
+    @ApiModelProperty(value = "鏈嶅姟绫诲瀷鍒楄〃锛屼负绌哄垯鏌ヨ鎵�鏈� (2-鍑洪櫌闅忚, 3-闂ㄨ瘖闅忚)")
+    private List<String> serviceTypes;
+
+}
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceStatisticsResponse.java b/smartor/src/main/java/com/smartor/domain/ServiceStatisticsResponse.java
new file mode 100644
index 0000000..abdbd21
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/ServiceStatisticsResponse.java
@@ -0,0 +1,39 @@
+package com.smartor.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 鏈嶅姟缁熻鍝嶅簲缁撴灉
+ *
+ * @author smartor
+ * @date 2025-01-14
+ */
+@ApiModel(value = "ServiceStatisticsResponse", description = "鏈嶅姟缁熻鍝嶅簲缁撴灉")
+@Data
+public class ServiceStatisticsResponse {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "鏃堕棿鍛ㄦ湡")
+    @Excel(name = "鏃堕棿鍛ㄦ湡")
+    private String timePeriod;
+
+    @ApiModelProperty(value = "鍑洪櫌闅忚閲�")
+    @Excel(name = "鍑洪櫌闅忚閲�")
+    private Long dischargeFollowCount = 0L;
+
+    @ApiModelProperty(value = "闂ㄨ瘖闅忚閲�")
+    @Excel(name = "闂ㄨ瘖闅忚閲�")
+    private Long outpatientFollowCount = 0L;
+
+
+    @ApiModelProperty(value = "鍑洪櫌浜烘")
+    @Excel(name = "鍑洪櫌浜烘")
+    private Long pmiCount = 0L;
+
+    @ApiModelProperty(value = "闂ㄨ瘖浜烘")
+    @Excel(name = "闂ㄨ瘖浜烘")
+    private Long pmoCount = 0L;
+}
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
index 2a32633..f8bf4ce 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
@@ -40,6 +40,9 @@
     @ApiModelProperty(value = "澶囨敞")
     private String remark;
 
+    @ApiModelProperty(value = "绂婚櫌璇婃柇鍚嶇О")
+    private String leavediagname;
+
     /**
      * 澶囨敞
      */
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
index 47d9bdf..edb7f5f 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
@@ -15,7 +15,6 @@
  * 鍗曚竴浠诲姟锛堥殢璁匡級瀵硅薄 ivr_taskcall
  *
  * @author ruoyi
- * @date 2024-02-02
  */
 @ApiModel(value = "ServiceSubtaskVO", description = "鍗曚竴闅忚浠诲姟鍏ュ弬")
 @Data
@@ -26,7 +25,39 @@
      *
      */
     @ApiModelProperty(value = "涓婚敭id")
-    private Long id;
+    private Long subId;
+
+
+    /**
+     * 闅忚娆℃暟
+     */
+    @ApiModelProperty(value = "闅忚娆℃暟")
+    private Integer visitCount;
+
+    /**
+     * 鏄惁鍦ㄦ闅忚锛�1鍚�    2鏄�
+     */
+    @ApiModelProperty(value = "鏄惁鍦ㄦ闅忚锛�1鏄�    2鍚�")
+    private Integer isVisitAgain;
+    /**
+     * 鎮h�匢D
+     */
+    @Excel(name = "  鎮h�匢D")
+    @ApiModelProperty(value = "鎮h�匢D")
+    private String patguid;
+
+    /**
+     * 澶嶈瘖閫氱煡锛�0宸查�氱煡    1鏈�氱煡
+     */
+    @ApiModelProperty(value = "澶嶈瘖閫氱煡锛�0宸查�氱煡    1鏈�氱煡")
+    private Integer visitNotice;
+
+    /**
+     * 鍑洪櫌璇婃柇鍚嶇О
+     */
+    @Excel(name = "  鍑洪櫌璇婃柇鍚嶇О")
+    @ApiModelProperty(value = "鍑洪櫌璇婃柇鍚嶇О")
+    private String leavediagname;
 
     /**
      * 鍑洪櫌鐥呬汉璁板綍ID
@@ -600,17 +631,91 @@
     /**
      * 寮�濮嬪嚭闄㈡棩鏈�
      */
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "寮�濮嬪嚭闄㈡棩鏈�")
     private Date startOutHospTime;
 
     /**
      * 缁撴潫鍑洪櫌鏃ユ湡
      */
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "缁撴潫鍑洪櫌鏃ユ湡")
     private Date endOutHospTime;
 
+    /**
+     * 鎺掑簭锛堬級
+     */
+    @ApiModelProperty(value = "鎺掑簭锛�0 鍑洪櫌鏃堕棿(姝e簭)    1 鍑洪櫌鏃堕棿(鍊掑簭)   2 鍙戦�佹椂闂�(姝e簭)    3 鍙戦�佹椂闂�(鍊掑簭) ")
+    private Integer sort;
+
+    /**
+     * 绗笁鏂逛换鍔D
+     */
+    @ApiModelProperty(value = "绗笁鏂逛换鍔D")
+    private String taskGuid;
+
+
+    /**
+     * 鍒涘缓寮�濮嬫椂闂�
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createStartTime;
+
+    /**
+     * 鍒涘缓缁撴潫鏃堕棿
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createEndTime;
+
+
+    /**
+     * 绉戝涓庣梾鍖虹殑鏌ヨ鏄痮r杩樻槸and:   1:and(榛樿)     2:or
+     */
+    @ApiModelProperty(value = "绉戝涓庣梾鍖虹殑鏌ヨ鏄痮r杩樻槸and:   1:and(榛樿)     2:or  ")
+    private String deptOrDistrict = "1";
+
+    /**
+     * 鎮h�呮潵婧�
+     */
+    @ApiModelProperty(value = "鎮h�呮潵婧愶細0鏈湴鎮h�呰〃    1澶栭儴鎮h�呰〃")
+    private String patfrom;
+
+
+    /**
+     * 寮�濮嬪彂閫佹棩鏈�
+     */
+    @ApiModelProperty(value = "寮�濮嬪彂閫佹棩鏈�")
+    private Date startSendDateTime;
+
+    /**
+     * 缁撴潫鍙戦�佹棩鏈�
+     */
+    @ApiModelProperty(value = "缁撴潫鍙戦�佹棩鏈�")
+    private Date endSendDateTime;
+
+
+    /**
+     * /**
+     * 鎮h�呬笂娆¢殢璁跨殑subId
+     */
+    @ApiModelProperty(value = "鎮h�呬笂娆¢殢璁跨殑subId")
+    private Integer upid;
+
     @ApiModelProperty(value = "闅忚鏃堕棿")
     private Date visitTime;
+    /**
+     * 闅忚鏂瑰紡
+     */
+    @ApiModelProperty(value = "闅忚鏂瑰紡")
+    private String visitType;
 
+    @ApiModelProperty(value = "闅忚閮ㄩ棬缂栫爜")
+    private String visitDeptCode;
+
+    @ApiModelProperty(value = "闅忚閮ㄩ棬鍚嶇О")
+    private String visitDeptName;
+
+    @ApiModelProperty(value = "闅忚閮ㄩ棬缂栫爜闆嗗悎")
+    private List<String> visitDeptCodes;
 
 }
diff --git a/smartor/src/main/java/com/smartor/mapper/SchemeAutofinshruleMapper.java b/smartor/src/main/java/com/smartor/mapper/SchemeAutofinshruleMapper.java
index 68c0c53..880cde8 100644
--- a/smartor/src/main/java/com/smartor/mapper/SchemeAutofinshruleMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/SchemeAutofinshruleMapper.java
@@ -1,19 +1,19 @@
-package com.ruoyi.smartor.mapper;
+package com.smartor.mapper;
 
 import java.util.List;
-import com.ruoyi.smartor.domain.SchemeAutofinshrule;
+import com.smartor.domain.SchemeAutofinshrule;
 
 /**
  * 鏂规缁撴瑙勫垯Mapper鎺ュ彛
- * 
+ *
  * @author smartor
  * @date 2023-03-04
  */
-public interface SchemeAutofinshruleMapper 
+public interface SchemeAutofinshruleMapper
 {
     /**
      * 鏌ヨ鏂规缁撴瑙勫垯
-     * 
+     *
      * @param id 鏂规缁撴瑙勫垯涓婚敭
      * @return 鏂规缁撴瑙勫垯
      */
@@ -21,7 +21,7 @@
 
     /**
      * 鏌ヨ鏂规缁撴瑙勫垯鍒楄〃
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 鏂规缁撴瑙勫垯闆嗗悎
      */
@@ -29,7 +29,7 @@
 
     /**
      * 鏂板鏂规缁撴瑙勫垯
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 缁撴灉
      */
@@ -37,7 +37,7 @@
 
     /**
      * 淇敼鏂规缁撴瑙勫垯
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 缁撴灉
      */
@@ -45,7 +45,7 @@
 
     /**
      * 鍒犻櫎鏂规缁撴瑙勫垯
-     * 
+     *
      * @param id 鏂规缁撴瑙勫垯涓婚敭
      * @return 缁撴灉
      */
@@ -53,7 +53,7 @@
 
     /**
      * 鎵归噺鍒犻櫎鏂规缁撴瑙勫垯
-     * 
+     *
      * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎
      * @return 缁撴灉
      */
diff --git a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
index 5ad0a2d..7eba4a2 100644
--- a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
@@ -1,9 +1,6 @@
 package com.smartor.mapper;
 
-import com.smartor.domain.ServiceSubtask;
-import com.smartor.domain.ServiceSubtaskCount;
-import com.smartor.domain.ServiceSubtaskCountReq;
-import com.smartor.domain.ServiceSubtaskVO;
+import com.smartor.domain.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -75,4 +72,6 @@
 
     public List<ServiceSubtask> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq);
 
+    public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest serviceStatisticsRequest);
+
 }
diff --git a/smartor/src/main/java/com/smartor/service/ISchemeAutofinshruleService.java b/smartor/src/main/java/com/smartor/service/ISchemeAutofinshruleService.java
index 960c86a..eeb78d6 100644
--- a/smartor/src/main/java/com/smartor/service/ISchemeAutofinshruleService.java
+++ b/smartor/src/main/java/com/smartor/service/ISchemeAutofinshruleService.java
@@ -1,19 +1,19 @@
-package com.ruoyi.smartor.service;
+package com.smartor.service;
 
 import java.util.List;
 import com.ruoyi.smartor.domain.SchemeAutofinshrule;
 
 /**
  * 鏂规缁撴瑙勫垯Service鎺ュ彛
- * 
+ *
  * @author smartor
  * @date 2023-03-04
  */
-public interface ISchemeAutofinshruleService 
+public interface ISchemeAutofinshruleService
 {
     /**
      * 鏌ヨ鏂规缁撴瑙勫垯
-     * 
+     *
      * @param id 鏂规缁撴瑙勫垯涓婚敭
      * @return 鏂规缁撴瑙勫垯
      */
@@ -21,7 +21,7 @@
 
     /**
      * 鏌ヨ鏂规缁撴瑙勫垯鍒楄〃
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 鏂规缁撴瑙勫垯闆嗗悎
      */
@@ -29,7 +29,7 @@
 
     /**
      * 鏂板鏂规缁撴瑙勫垯
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 缁撴灉
      */
@@ -37,7 +37,7 @@
 
     /**
      * 淇敼鏂规缁撴瑙勫垯
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 缁撴灉
      */
@@ -45,7 +45,7 @@
 
     /**
      * 鎵归噺鍒犻櫎鏂规缁撴瑙勫垯
-     * 
+     *
      * @param ids 闇�瑕佸垹闄ょ殑鏂规缁撴瑙勫垯涓婚敭闆嗗悎
      * @return 缁撴灉
      */
@@ -53,7 +53,7 @@
 
     /**
      * 鍒犻櫎鏂规缁撴瑙勫垯淇℃伅
-     * 
+     *
      * @param id 鏂规缁撴瑙勫垯涓婚敭
      * @return 缁撴灉
      */
diff --git a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
index d1a2fd4..515f77d 100644
--- a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
+++ b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
@@ -1,9 +1,6 @@
 package com.smartor.service;
 
-import com.ruoyi.common.core.domain.AjaxResult;
 import com.smartor.domain.*;
-import com.smartor.domain.ServiceSubtask;
-import org.springframework.web.bind.annotation.RequestBody;
 
 import java.util.List;
 import java.util.Map;
@@ -119,9 +116,12 @@
 
     /**
      * 鑾峰彇闅忚缁熻姣斾緥
+     *
      * @param serviceSubtaskCountReq
      * @return
      */
     public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq);
 
+    public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest request);
+
 }
diff --git a/smartor/src/main/java/com/smartor/service/impl/ExternalInfoServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ExternalInfoServiceImpl.java
index 32b1d12..dd8f3d2 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ExternalInfoServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ExternalInfoServiceImpl.java
@@ -595,7 +595,8 @@
     public Boolean getExternalLeaveHospPatientInfo30Day() {
         try {
             // 鍥哄畾寮�濮嬫椂闂�
-            String fixedStartTime = "2025-03-25";
+//            String fixedStartTime = "2025-03-25";
+            String fixedStartTime = "2025-02-01";
             SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
             String today = formatter.format(new Date());
 
@@ -608,7 +609,8 @@
 
             try {
                 startCal.setTime(formatter.parse(fixedStartTime));
-                endCal.setTime(formatter.parse(today));
+                endCal.setTime(formatter.parse("2025-06-08"));
+//                endCal.setTime(formatter.parse(today));
             } catch (ParseException e) {
                 log.error("鏃ユ湡瑙f瀽澶辫触锛歿}", e.getMessage(), e);
                 return false;
diff --git a/smartor/src/main/java/com/smartor/service/impl/IvrLibaTemplateServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/IvrLibaTemplateServiceImpl.java
index 7c1d89d..30ac240 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrLibaTemplateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrLibaTemplateServiceImpl.java
@@ -39,8 +39,6 @@
     @Autowired
     private IvrLibaTemplateScriptMapper ivrLibaTemplateScriptMapper;
 
-    @Autowired
-    private TemplateDeptMapper tempDetpRelevanceMapper;
 
     /**
      * 鏌ヨ妯℃澘搴�
@@ -172,20 +170,6 @@
                     IvrLibaTemplateScript ivrLibaTemplateScript = scriptHandle(ivrLibaTemplate, ivrLibaTemplateScriptVO, ivrLibaTemplateVO.getIsoperation());
 //                    dealOption(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList(), ivrLibaTemplateScript, ivrLibaTemplate.getId(), ivrLibaTemplateVO.getIsoperation());
                 }
-            }
-        }
-
-        //瀵圭瀹よ繘琛屽鐞�
-        for (TemplateDept tempDetpRelevance : ivrLibaTemplateVO.getTempDetpRelevances()) {
-            if (tempDetpRelevance.getId() == null) {
-                //鏂板
-                tempDetpRelevance.setTempid(ivrLibaTemplate.getId());
-                tempDetpRelevance.setType(2L);
-                tempDetpRelevance.setCreateTime(new Date());
-                tempDetpRelevanceMapper.insertTemplateDept(tempDetpRelevance);
-            } else {
-                tempDetpRelevance.setUpdateTime(new Date());
-                tempDetpRelevanceMapper.updateTemplateDept(tempDetpRelevance);
             }
         }
 
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 34966d0..0e39bcb 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrTaskTemplateServiceImpl.java
@@ -11,7 +11,6 @@
 import com.smartor.mapper.IvrTaskTemplateMapper;
 import com.smartor.mapper.IvrTaskTemplateScriptMapper;
 import com.smartor.mapper.IvrTaskTemplateTargetoptionMapper;
-import com.smartor.mapper.TemplateDeptMapper;
 import com.smartor.service.IIvrTaskTemplateService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -41,8 +40,6 @@
     @Autowired
     private IvrTaskTemplateTargetoptionMapper ivrTaskTemplateTargetoptionMapper;
 
-    @Autowired
-    private TemplateDeptMapper templateDeptMapper;
 
     /**
      * 鏌ヨ闅忚浠诲姟闅忚妯℃澘搴�
@@ -175,16 +172,7 @@
      */
     @Override
     public int deleteIvrTaskTemplateByIDs(Long[] IDs) {
-        if (IDs[0] != null) {
-            IvrTaskTemplate ivrTaskTemplate = selectIvrTaskTemplateByID(IDs[0]);
-            if (StringUtils.isNotEmpty(ivrTaskTemplate.getLongTemp()) && ivrTaskTemplate.getLongTemp().equals("1")) {
-                //濡傛灉杩欎釜妯℃澘鏄暱鏈熶换鍔★紝鍒欓渶瑕佸垹闄ゆā鏉夸笌閮ㄩ棬鐨勫叧鑱�
-                TemplateDept templateDept = new TemplateDept();
-                templateDept.setType(21L);
-                templateDept.setTempid(IDs[0]);
-                templateDeptMapper.deleteTemplateDeptByTemplateId(templateDept);
-            }
-        }
+
         return ivrTaskTemplateMapper.deleteIvrTaskTemplateByIDs(IDs);
     }
 
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 b833b1a..79115c7 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
@@ -127,17 +127,17 @@
     @Override
     public PatMedRes selectPatMedInhospListCount(PatMedReq patMedReq) {
         PatMedRes patMedRes = null;
-        // 鑾峰彇褰撳墠鐧婚檰浜虹殑閮ㄩ棬鏉冮檺
-        if (org.springframework.util.CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) {
-            Long userId = SecurityUtils.getUserId();
-            List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId);
-            List<String> deptCode = new ArrayList<>();
-            for (SysDept sysDept : sysDepts) {
-                deptCode.add(sysDept.getDeptId().toString());
-            }
-            patMedReq.setDeptcodeList(deptCode);
-            patMedRes = patMedInhospMapper.selectPatMedInhospCount(patMedReq);
-        }
+//        // 鑾峰彇褰撳墠鐧婚檰浜虹殑閮ㄩ棬鏉冮檺
+//        if (org.springframework.util.CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) {
+//            Long userId = SecurityUtils.getUserId();
+//            List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId);
+//            List<String> deptCode = new ArrayList<>();
+//            for (SysDept sysDept : sysDepts) {
+//                deptCode.add(sysDept.getDeptId().toString());
+//            }
+//            patMedReq.setDeptcodeList(deptCode);
+//        }
+        patMedRes = patMedInhospMapper.selectPatMedInhospCount(patMedReq);
         return patMedRes;
     }
 
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 537374f..a3e5107 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
@@ -106,15 +106,15 @@
     @Override
     public PatMedRes selectPatMedOuthospCount(PatMedReq patMedReq) {
         // 鑾峰彇褰撳墠鐧婚檰浜虹殑閮ㄩ棬鏉冮檺
-        if (CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) {
-            Long userId = SecurityUtils.getUserId();
-            List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId);
-            List<String> deptCode = new ArrayList<>();
-            for (SysDept sysDept : sysDepts) {
-                deptCode.add(sysDept.getDeptId().toString());
-            }
-            patMedReq.setDeptcodeList(deptCode);
-        }
+//        if (CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) {
+//            Long userId = SecurityUtils.getUserId();
+//            List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId);
+//            List<String> deptCode = new ArrayList<>();
+//            for (SysDept sysDept : sysDepts) {
+//                deptCode.add(sysDept.getDeptId().toString());
+//            }
+//            patMedReq.setDeptcodeList(deptCode);
+//        }
         return patMedOuthospMapper.selectPatMedOuthospCount(patMedReq);
     }
 
diff --git a/smartor/src/main/java/com/smartor/service/impl/SchemeAutofinshruleServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/SchemeAutofinshruleServiceImpl.java
index 17b1366..aa9e0d1 100644
--- a/smartor/src/main/java/com/smartor/service/impl/SchemeAutofinshruleServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/SchemeAutofinshruleServiceImpl.java
@@ -1,96 +1,90 @@
-package com.ruoyi.smartor.service.impl;
+package com.smartor.service.impl;
 
-import java.util.List;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.smartor.domain.SchemeAutofinshrule;
+import com.smartor.mapper.SchemeAutofinshruleMapper;
+import com.smartor.service.ISchemeAutofinshruleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.smartor.mapper.SchemeAutofinshruleMapper;
-import com.ruoyi.smartor.domain.SchemeAutofinshrule;
-import com.ruoyi.smartor.service.ISchemeAutofinshruleService;
+
+import java.util.List;
 
 /**
  * 鏂规缁撴瑙勫垯Service涓氬姟灞傚鐞�
- * 
+ *
  * @author smartor
  * @date 2023-03-04
  */
 @Service
-public class SchemeAutofinshruleServiceImpl implements ISchemeAutofinshruleService 
-{
+public class SchemeAutofinshruleServiceImpl implements ISchemeAutofinshruleService {
     @Autowired
     private SchemeAutofinshruleMapper schemeAutofinshruleMapper;
 
     /**
      * 鏌ヨ鏂规缁撴瑙勫垯
-     * 
+     *
      * @param id 鏂规缁撴瑙勫垯涓婚敭
      * @return 鏂规缁撴瑙勫垯
      */
     @Override
-    public SchemeAutofinshrule selectSchemeAutofinshruleById(Long id)
-    {
+    public SchemeAutofinshrule selectSchemeAutofinshruleById(Long id) {
         return schemeAutofinshruleMapper.selectSchemeAutofinshruleById(id);
     }
 
     /**
      * 鏌ヨ鏂规缁撴瑙勫垯鍒楄〃
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 鏂规缁撴瑙勫垯
      */
     @Override
-    public List<SchemeAutofinshrule> selectSchemeAutofinshruleList(SchemeAutofinshrule schemeAutofinshrule)
-    {
+    public List<SchemeAutofinshrule> selectSchemeAutofinshruleList(SchemeAutofinshrule schemeAutofinshrule) {
         return schemeAutofinshruleMapper.selectSchemeAutofinshruleList(schemeAutofinshrule);
     }
 
     /**
      * 鏂板鏂规缁撴瑙勫垯
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 缁撴灉
      */
     @Override
-    public int insertSchemeAutofinshrule(SchemeAutofinshrule schemeAutofinshrule)
-    {
+    public int insertSchemeAutofinshrule(SchemeAutofinshrule schemeAutofinshrule) {
         schemeAutofinshrule.setCreateTime(DateUtils.getNowDate());
         return schemeAutofinshruleMapper.insertSchemeAutofinshrule(schemeAutofinshrule);
     }
 
     /**
      * 淇敼鏂规缁撴瑙勫垯
-     * 
+     *
      * @param schemeAutofinshrule 鏂规缁撴瑙勫垯
      * @return 缁撴灉
      */
     @Override
-    public int updateSchemeAutofinshrule(SchemeAutofinshrule schemeAutofinshrule)
-    {
+    public int updateSchemeAutofinshrule(SchemeAutofinshrule schemeAutofinshrule) {
         schemeAutofinshrule.setUpdateTime(DateUtils.getNowDate());
         return schemeAutofinshruleMapper.updateSchemeAutofinshrule(schemeAutofinshrule);
     }
 
     /**
      * 鎵归噺鍒犻櫎鏂规缁撴瑙勫垯
-     * 
+     *
      * @param ids 闇�瑕佸垹闄ょ殑鏂规缁撴瑙勫垯涓婚敭
      * @return 缁撴灉
      */
     @Override
-    public int deleteSchemeAutofinshruleByIds(Long[] ids)
-    {
+    public int deleteSchemeAutofinshruleByIds(Long[] ids) {
         return schemeAutofinshruleMapper.deleteSchemeAutofinshruleByIds(ids);
     }
 
     /**
      * 鍒犻櫎鏂规缁撴瑙勫垯淇℃伅
-     * 
+     *
      * @param id 鏂规缁撴瑙勫垯涓婚敭
      * @return 缁撴灉
      */
     @Override
-    public int deleteSchemeAutofinshruleById(Long id)
-    {
+    public int deleteSchemeAutofinshruleById(Long id) {
         return schemeAutofinshruleMapper.deleteSchemeAutofinshruleById(id);
     }
 }
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 54a8f50..c82b7cf 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -1977,6 +1977,39 @@
         return serviceSubtaskStatistics;
     }
 
+    /**
+     * 鏈嶅姟缁熻鏌ヨ - 鎸夋椂闂寸淮搴︾粺璁″嚭闄�/闂ㄨ瘖闅忚鏁版嵁
+     *
+     * @param request 缁熻璇锋眰鍙傛暟
+     * @return 缁熻缁撴灉鍒楄〃
+     */
+    @Override
+    public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest request) {
+        log.info("getServiceStatistics鐨勫叆鍙備负锛歿}", request);
+
+        // 鍙傛暟鏍¢獙
+        if (request.getStartDate() == null || request.getEndDate() == null) {
+            throw new IllegalArgumentException("寮�濮嬫棩鏈熷拰缁撴潫鏃ユ湡涓嶈兘涓虹┖");
+        }
+
+        if (request.getStartDate().after(request.getEndDate())) {
+            throw new IllegalArgumentException("寮�濮嬫棩鏈熶笉鑳芥櫄浜庣粨鏉熸棩鏈�");
+        }
+
+        // 濡傛灉timeType涓虹┖锛岄粯璁ゆ寜澶╃粺璁�
+        if (com.ruoyi.common.utils.StringUtils.isEmpty(request.getTimeType())) {
+            request.setTimeType("day");
+        }
+
+        List<ServiceStatisticsResponse> result = serviceSubtaskMapper.getServiceStatistics(request);
+
+
+        log.info("getServiceStatistics杩斿洖缁撴灉鏁伴噺锛歿}", result.size());
+        return result;
+    }
+
+
+
     private ServiceSubtaskStatistic getStatistic(List<ServiceSubtask> serviceSubtaskList) {
         log.error("-------------serviceSubtaskList鐨勫�间负锛歿}", serviceSubtaskList);
         ServiceSubtaskStatistic serviceSubtaskStatistic = new ServiceSubtaskStatistic();
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceTaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceTaskServiceImpl.java
index fa1ca32..4d71e2e 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceTaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceTaskServiceImpl.java
@@ -211,7 +211,7 @@
             info = wjInfo(serviceTask, patid, isFinish);
         } else {
             //瀹f暀
-            info = xjInfo(Long.valueOf(serviceTask.getLibtemplateid()), taskid, patid, isFinish);
+            info = xjInfo(Long.valueOf(serviceTask.getTemplateid()), taskid, patid, isFinish);
         }
 
         SvyTaskTemplate svyTaskTemplate = svyTaskTemplateMapper.selectSvyTaskTemplateBySvyid(serviceTask.getTemplateid());
diff --git a/smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateServiceImpl.java
index bb9bc5f..5349ac0 100644
--- a/smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateServiceImpl.java
@@ -33,8 +33,6 @@
     @Autowired
     private SvyLibTemplateTargetoptionMapper svyLibTemplateTargetoptionMapper;
     @Autowired
-    private TemplateDeptMapper templateDeptMapper;
-    @Autowired
     private SvyLibTemplateTagMapper svyLibTemplateTagMapper;
     @Autowired
     private Icd10AssociationMapper icd10AssociationMapper;
@@ -110,11 +108,6 @@
             //灏嗛鐩斁鍒伴棶鍗峰垪琛ㄤ腑
             svyLibTemplateVOS.get(i).setSvyTemplateLibScripts(svyLibTemplateScripts);
 
-            //鑾峰彇姣忎釜闂嵎瀵瑰簲鐨勭瀹�
-            TemplateDept templateDept = new TemplateDept();
-            templateDept.setTempid(svyLibTemplateVOS.get(i).getSvyid());
-            List<TemplateDept> tempDetpRelevances = templateDeptMapper.selectTemplateDeptList(templateDept);
-            svyLibTemplateVOS.get(i).setTempDetpRelevances(CollectionUtils.isNotEmpty(tempDetpRelevances) ? tempDetpRelevances : new ArrayList<>());
 
             //鑾峰彇鏍囩
             SvyLibTemplateTag svyLibTemplateTag = new SvyLibTemplateTag();
@@ -208,20 +201,6 @@
                     }
                 }
             }
-        }
-
-        if (CollectionUtils.isNotEmpty(svyLibTemplate.getTempDetpRelevances())) {
-            for (TemplateDept tempDetpRelevance : svyLibTemplate.getTempDetpRelevances()) {
-                if (tempDetpRelevance.getId() == null) {
-                    //鏂板
-                    tempDetpRelevance.setTempid(svyLibTemplate.getSvyid());
-                    tempDetpRelevance.setType(1L);
-                    templateDeptMapper.insertTemplateDept(tempDetpRelevance);
-                } else {
-                    templateDeptMapper.updateTemplateDept(tempDetpRelevance);
-                }
-            }
-
         }
 
         //鏍囩澶勭悊
diff --git a/smartor/src/main/resources/mapper/smartor/ExternallInfoMapper.xml b/smartor/src/main/resources/mapper/smartor/ExternallInfoMapper.xml
index bd5b2b2..19a7e2c 100644
--- a/smartor/src/main/resources/mapper/smartor/ExternallInfoMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ExternallInfoMapper.xml
@@ -151,6 +151,7 @@
                DWMC,
                RYRQ,
                SFZH,
+               YLDH,
                JDR
         from HIT.HF_RYJDXX
     </sql>
diff --git a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
index 5e154e3..c75a219 100644
--- a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
@@ -59,6 +59,7 @@
         <result property="medicareType" column="medicare_type"/>
         <result property="carePerson" column="care_person"/>
         <result property="casePersonAge" column="case_person_age"/>
+        <result property="reservedPhone" column="reserved_phone"/>
     </resultMap>
 
 
@@ -117,6 +118,7 @@
         <result property="leavehospitaldistrictname" column="leavehospitaldistrictname"/>
         <result property="leavehospitaldistrictcode" column="leavehospitaldistrictcode"/>
         <result property="admitdate" column="admitdate"/>
+        <result property="reservedPhone" column="reserved_phone"/>
     </resultMap>
 
     <sql id="selectPatArchiveVo">
@@ -143,6 +145,7 @@
                archivetime,
                archiveby,
                telcode,
+               reserved_phone,
                relativetelcode,
                idcardtype,
                orgid,
@@ -198,6 +201,7 @@
             <if test="medicareType != null ">and medicare_type = #{medicareType}</if>
             <if test="carePerson != null ">and care_person = #{carePerson}</if>
             <if test="casePersonAge != null ">and case_person_age = #{casePersonAge}</if>
+            <if test="reservedPhone != null ">and reserved_phone = #{reservedPhone}</if>
         </where>
     </select>
 
@@ -232,11 +236,13 @@
         a.income,
         a.medicare_type,
         a.care_person,
+        a.reserved_phone,
         a.case_person_age
         from pat_archive a,pat_archivetag b ,base_tag c
         <where>
             a.del_flag=0 and
             a.id = b.patid and b.tagid = c.tagid
+            <if test="reservedPhone != null ">and reserved_phone = #{reservedPhone}</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and idcardno = #{idcardno}</if>
             <if test="telcode != null  and telcode != ''">and telcode = #{telcode}</if>
@@ -302,6 +308,7 @@
             <if test="medicareType != null ">medicare_type,</if>
             <if test="carePerson != null ">care_person,</if>
             <if test="casePersonAge != null ">case_person_age,</if>
+            <if test="reservedPhone != null ">reserved_phone,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="patientno != null">#{patientno},</if>
@@ -349,6 +356,7 @@
             <if test="medicareType != null ">#{medicareType},</if>
             <if test="carePerson != null ">#{carePerson},</if>
             <if test="casePersonAge != null ">#{casePersonAge},</if>
+            <if test="reservedPhone != null ">#{reservedPhone},</if>
         </trim>
     </insert>
 
@@ -356,14 +364,14 @@
         insert into
         pat_archive(name,viptype,sex,idcardno,birthdate,place_of_residence,age,age2,sourcefrom,archivetime,archiveby,telcode,relativetelcode,idcardtype,orgid,openid,dduserid,update_by,update_time
         ,create_by,create_time,isupload,upload_time,pattype,nation,birthplace,native_place,patientno,patid_his,sd_flag,age_unit,age_unit2,notrequired_flag,notrequiredreason,care_facilities,case_path,
-        degree_of_education,marital_status,income,medicare_type,care_person,case_person_age)
+        degree_of_education,marital_status,income,medicare_type,care_person,case_person_age,reserved_phone)
         values
         <foreach item="item" index="index" collection="list" separator=",">
             (#{item.name},#{item.viptype},#{item.sex},#{item.idcardno},#{item.birthdate},#{item.placeOfResidence},#{item.age},#{item.age2},#{item.sourcefrom},#{item.archivetime},#{item.archiveby}
             ,#{item.telcode},#{item.archiveby},#{item.idcardtype},#{item.orgid},#{item.openid},#{item.dduserid},#{item.updateBy},
             #{item.updateTime},#{item.createBy},#{item.createTime},#{item.isupload},#{item.uploadTime},#{item.pattype},#{item.nation},#{item.birthplace},#{item.nativePlace},#{item.patientno},
             #{item.patidHis},#{item.sdFlag},#{item.ageUnit},#{item.ageUnit2},#{item.notrequiredFlag},#{item.notrequiredreason}
-            ,#{item.careFacilities},#{item.casePath},#{item.degreeOfEducation},#{item.maritalStatus},#{item.income},#{item.medicareType},#{item.carePerson},#{item.casePersonAge})
+            ,#{item.careFacilities},#{item.casePath},#{item.degreeOfEducation},#{item.maritalStatus},#{item.income},#{item.medicareType},#{item.carePerson},#{item.casePersonAge},#{item.reservedPhone})
         </foreach>
     </insert>
 
@@ -394,9 +402,9 @@
             <if test="isupload != null">isupload = #{isupload},</if>
             <if test="uploadTime != null">upload_time = #{uploadTime},</if>
             <if test="viptype != null">viptype = #{viptype},</if>
-            <if test="viptype != null">patientno = #{patientno},</if>
-            <if test="viptype != null">patid_his = #{patidHis},</if>
-            <if test="viptype != null">sd_flag = #{sdFlag},</if>
+            <if test="patientno != null">patientno = #{patientno},</if>
+            <if test="patidHis != null">patid_his = #{patidHis},</if>
+            <if test="sdFlag != null">sd_flag = #{sdFlag},</if>
             <if test="ageUnit != null">age_unit = #{ageUnit},</if>
             <if test="ageUnit2 != null">age_unit2 = #{ageUnit2},</if>
             <if test="notrequiredFlag != null ">notrequired_flag = #{notrequiredFlag},</if>
@@ -409,6 +417,7 @@
             <if test="medicareType != null ">medicare_type = #{medicareType},</if>
             <if test="carePerson != null ">care_person = #{carePerson},</if>
             <if test="casePersonAge != null ">case_person_age = #{casePersonAge},</if>
+            <if test="reservedPhone != null ">reserved_phone = #{reservedPhone},</if>
         </trim>
         where id = #{id}
     </update>
@@ -466,6 +475,7 @@
         a.upload_time,
         a.viptype,
         a.pattype,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(d.tagname, ', ')
         FROM pat_archivetag d
@@ -479,6 +489,7 @@
         LEFT JOIN pat_archivetag b ON a.id = b.patid AND b.del_flag = 0
         <where>
             a.del_flag = 0
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
             <if test="tagname != null  and tagname != ''">and b.tagname like concat('%', #{tagname}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and a.idcardno = #{idcardno}</if>
@@ -539,6 +550,7 @@
         a.create_by,
         a.create_time,
         a.isupload,
+        a.reserved_phone,
         a.upload_time,
         a.pattype,
         d.bed_no,
@@ -560,11 +572,11 @@
         pat_med_inhosp d
         JOIN pat_archive a ON a.id = d.patid
         LEFT JOIN ( SELECT patid, GROUP_CONCAT( tagname ) AS tagname FROM pat_archivetag where del_flag=0 GROUP BY patid
-        ) t ON t.patid =
-        d.patid
+        ) t ON t.patid = d.patid
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and a.idcardno = #{idcardno}</if>
@@ -614,14 +626,15 @@
                 </foreach>
             </if>
 
-            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0">
+            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0 and deptcodes == null ">
                 AND d.hospitaldistrictcode IN
                 <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
                          close=")">
                     #{hospitaldistrictcode}
                 </foreach>
             </if>
-            <if test="deptcodes != null and deptcodes.size() > 0">
+
+            <if test="deptcodes != null and deptcodes.size() > 0 and hospitaldistrictcodes == null">
                 AND d.deptcode IN
                 <foreach collection="deptcodes" item="deptcode" open="(" separator=","
                          close=")">
@@ -629,6 +642,20 @@
                 </foreach>
             </if>
 
+            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0 and deptcodes != null ">
+                AND (d.hospitaldistrictcode IN
+                <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+                         close=")">
+                    #{hospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test="hospitaldistrictcodes != null and deptcodes != null and deptcodes.size() > 0">
+                OR d.deptcode IN
+                <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+                         close="))">
+                    #{deptcode}
+                </foreach>
+            </if>
 
             <if test="patids != null">
                 AND a.id NOT IN
@@ -685,8 +712,7 @@
         a.create_time,
         a.isupload,
         a.upload_time,
-        d.leavehospitaldistrictcode AS leavehospitaldistrictcode,
-        d.leavehospitaldistrictname AS leavehospitaldistrictname,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(dd.tagname, ', ')
         FROM pat_archivetag dd
@@ -701,6 +727,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="patid != null  and patid != ''">and a.id = #{patid}</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
@@ -784,6 +811,7 @@
         a.create_time,
         a.isupload,
         a.upload_time,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(dd.tagname, ', ')
         FROM pat_archivetag dd
@@ -798,6 +826,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="patid != null  and patid != ''">and a.id = #{patid}</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
@@ -880,6 +909,7 @@
         a.isupload,
         a.upload_time,
         a.pattype,
+        a.reserved_phone,
         d.bed_no,
         d.starttime,
         d.endtime,
@@ -899,6 +929,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="name != null  and name != ''">AND a.name LIKE concat('%', #{name}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">AND a.idcardno = #{idcardno}</if>
             <if test="tagname != null  and tagname != ''">
@@ -925,8 +956,15 @@
             <if test="deptname != null and deptname != ''">AND d.deptname LIKE concat('%', #{deptname}, '%')</if>
             <if test="drname != null and drname != ''">AND d.drname LIKE concat('%',#{drname}, '%')</if>
             <if test="diagname != null and diagname != ''">AND d.diagname LIKE concat('%',#{diagname}, '%')</if>
-            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0">
+            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0 and leaveldeptcodes == null">
                 AND d.leavehospitaldistrictcode IN
+                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+                         close=")">
+                    #{leavehospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0 and leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+                AND (d.leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
                          close=")">
                     #{leavehospitaldistrictcode}
@@ -934,7 +972,7 @@
             </if>
             <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0 and leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0">
                 OR d.leaveldeptcode IN
-                <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close=")">
+                <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close="))">
                     #{leaveldeptcode}
                 </foreach>
             </if>
@@ -1018,6 +1056,7 @@
         a.create_by,
         a.create_time,
         a.isupload,
+        a.reserved_phone,
         a.upload_time,
         rt.tagname,
         ROW_NUMBER() OVER (PARTITION BY a.idcardno ORDER BY a.update_time DESC) AS rn,
@@ -1030,6 +1069,7 @@
             AND a.del_flag != 1
             AND d.admitdate >= CURRENT_DATE - INTERVAL '90 days' <!-- 寮虹儓鎺ㄨ崘鍔犳椂闂撮檺鍒� -->
             <if test="patid != null and patid != ''">AND a.id = #{patid}</if>
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="tagname != null and tagname != ''">AND rt.tagname LIKE concat('%', #{tagname}, '%')</if>
             <if test="name != null and name != ''">AND a.name LIKE concat('%', #{name}, '%')</if>
             <if test="idcardno != null and idcardno != ''">AND a.idcardno = #{idcardno}</if>
@@ -1129,6 +1169,7 @@
         a.create_time,
         a.isupload,
         a.upload_time,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(dd.tagname, ', ')
         FROM pat_archivetag dd
@@ -1144,6 +1185,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="patid != null  and patid != ''">and a.id = #{patid}</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 9c9ec38..3409748 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -743,30 +743,70 @@
     </select>
     <select id="selectPatMedInhospCount" parameterType="com.smartor.domain.PatMedReq"
             resultType="com.smartor.domain.PatMedRes">
+        SELECT SUM( rs ) AS rs,
+        SUM( rc ) AS rc
+        FROM (
         SELECT
         COUNT(1) AS rc,
-        COUNT(DISTINCT patid) AS rs
+        0 AS rs
         FROM
         pat_med_inhosp
         <where>
             del_flag=0
+            <if test="orgid != null">
+                AND orgid = #{orgid}
+            </if>
             <if test="zy != null">
                 and inhospstate=0
-                and TO_DATE(starttime,'YYYY-MM-DD') &gt;= TO_DATE(#{startDate},'YYYY-MM-DD')
-                and TO_DATE(starttime,'YYYY-MM-DD') &lt;= TO_DATE(#{endDate},'YYYY-MM-DD')
+                and starttime &gt;= #{startDate}
+                and starttime &gt;= #{endDate}
+                <if test="deptcodeList != null   and deptcodeList.size() > 0">
+                    and deptcode in
+                    <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+                        #{deptcode}
+                    </foreach>
+                </if>
             </if>
             <if test="cy != null">
                 and inhospstate=1
-                and TO_DATE(endtime,'YYYY-MM-DD') &gt;= TO_DATE(#{startDate},'YYYY-MM-DD')
-                and TO_DATE(endtime,'YYYY-MM-DD') &lt;= TO_DATE(#{endDate},'YYYY-MM-DD')
+                and endtime &gt;= #{startDate}
+                and endtime &lt;= #{endDate}
+                <if test="deptcodeList != null   and deptcodeList.size() > 0">
+                    and leaveldeptcode in
+                    <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+                        #{deptcode}
+                    </foreach>
+                </if>
             </if>
-            <if test="deptcodeList != null">
+
+        </where>
+        union all
+        select
+        0 AS rc,
+        count(1) AS rs
+        FROM
+        service_subtask
+        <where>
+            del_flag = 0
+            and service_type=2
+            <if test="orgid != null">
+                AND orgid = #{orgid}
+            </if>
+            <if test="startDate != null">
+                and visit_time &gt;= #{startDate}
+            </if>
+            <if test="endDate != null">
+                and visit_time &lt;= #{endDate}
+            </if>
+            <if test="deptcodeList != null   and deptcodeList.size() > 0">
                 and deptcode in
                 <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
                     #{deptcode}
                 </foreach>
             </if>
         </where>
+        ) AS combined_data
+
     </select>
 
     <select id="selectEndtimeMax" resultType="java.util.Date">
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
index b7b643c..a263451 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
@@ -252,22 +252,55 @@
 
     <select id="selectPatMedOuthospCount" parameterType="com.smartor.domain.PatMedReq"
             resultType="com.smartor.domain.PatMedRes">
+
+        SELECT SUM( rs ) AS rs,
+        SUM( rc ) AS rc
+        FROM (
         SELECT
         COUNT(id) AS rc,
-        COUNT(DISTINCT patid) AS rs
+        0 AS rs
         FROM
         pat_med_outhosp
         <where>
             del_flag=0
-            and TO_DATE(admitdate,'YYYY-MM-DD') &gt;= TO_DATE(#{startDate},'YYYY-MM-DD')
-            and TO_DATE(admitdate,'YYYY-MM-DD') &lt;= TO_DATE(#{endDate},'YYYY-MM-DD')
-            <if test="deptcodeList != null">
+            <if test="orgid != null">
+                and orgid = #{orgid}
+            </if>
+            and admitdate &gt;= #{startDate}
+            and admitdate &lt;= #{endDate}
+            <if test="deptcodeList != null and deptcodeList.size()>0">
                 and deptcode in
                 <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
                     #{deptcode}
                 </foreach>
             </if>
         </where>
+        union all
+        select
+        0 AS rc,
+        count(1) AS rs
+        FROM
+        service_subtask
+        <where>
+            del_flag = 0
+            and service_type=3
+            <if test="orgid != null">
+                and orgid = #{orgid}
+            </if>
+            <if test="startDate != null">
+                and visit_time &gt;=#{startDate}
+            </if>
+            <if test="endDate != null">
+                and visit_time &lt;= #{endDate}
+            </if>
+            <if test="deptcodeList != null and deptcodeList.size()>0">
+                and deptcode in
+                <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+                    #{deptcode}
+                </foreach>
+            </if>
+        </where>
+        ) AS combined_data
     </select>
 
     <select id="selectAdmitdateMax" resultType="java.util.Date">
diff --git a/smartor/src/main/resources/mapper/smartor/SchemeAutofinshruleMapper.xml b/smartor/src/main/resources/mapper/smartor/SchemeAutofinshruleMapper.xml
index da3a2cf..993fb7b 100644
--- a/smartor/src/main/resources/mapper/smartor/SchemeAutofinshruleMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/SchemeAutofinshruleMapper.xml
@@ -2,9 +2,9 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.ruoyi.smartor.mapper.SchemeAutofinshruleMapper">
-    
-    <resultMap type="SchemeAutofinshrule" id="SchemeAutofinshruleResult">
+<mapper namespace="com.smartor.mapper.SchemeAutofinshruleMapper">
+
+    <resultMap type="com.smartor.domain.SchemeAutofinshrule" id="SchemeAutofinshruleResult">
         <result property="id"    column="id"    />
         <result property="schemeid"    column="schemeid"    />
         <result property="ruletype"    column="ruletype"    />
@@ -23,22 +23,22 @@
         select id, schemeid, ruletype, rulevalue, orgid, del_flag, create_by, create_time, update_by, update_time, isupload, upload_time from scheme_autofinshrule
     </sql>
 
-    <select id="selectSchemeAutofinshruleList" parameterType="SchemeAutofinshrule" resultMap="SchemeAutofinshruleResult">
+    <select id="selectSchemeAutofinshruleList" parameterType="com.smartor.domain.SchemeAutofinshrule" resultMap="SchemeAutofinshruleResult">
         <include refid="selectSchemeAutofinshruleVo"/>
-        <where>  
+        <where>
             <if test="schemeid != null "> and schemeid = #{schemeid}</if>
             <if test="ruletype != null "> and ruletype = #{ruletype}</if>
             <if test="rulevalue != null  and rulevalue != ''"> and rulevalue = #{rulevalue}</if>
             <if test="orgid != null  and orgid != ''"> and orgid = #{orgid}</if>
         </where>
     </select>
-    
+
     <select id="selectSchemeAutofinshruleById" parameterType="Long" resultMap="SchemeAutofinshruleResult">
         <include refid="selectSchemeAutofinshruleVo"/>
         where id = #{id}
     </select>
-        
-    <insert id="insertSchemeAutofinshrule" parameterType="SchemeAutofinshrule" useGeneratedKeys="true" keyProperty="id">
+
+    <insert id="insertSchemeAutofinshrule" parameterType="com.smartor.domain.SchemeAutofinshrule" useGeneratedKeys="true" keyProperty="id">
         insert into scheme_autofinshrule
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="schemeid != null">schemeid,</if>
@@ -68,7 +68,7 @@
          </trim>
     </insert>
 
-    <update id="updateSchemeAutofinshrule" parameterType="SchemeAutofinshrule">
+    <update id="updateSchemeAutofinshrule" parameterType="com.smartor.domain.SchemeAutofinshrule">
         update scheme_autofinshrule
         <trim prefix="SET" suffixOverrides=",">
             <if test="schemeid != null">schemeid = #{schemeid},</if>
@@ -91,9 +91,9 @@
     </delete>
 
     <delete id="deleteSchemeAutofinshruleByIds" parameterType="String">
-        delete from scheme_autofinshrule where id in 
+        delete from scheme_autofinshrule where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
\ No newline at end of file
+</mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 31c47bc..24ea5d6 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -74,6 +74,7 @@
         <result property="sendstate" column="sendstate"/>
         <result property="tagname" column="tagname"/>
         <result property="visitTime" column="visit_time"/>
+        <result property="leavediagname" column="leavediagname"/>
     </resultMap>
 
     <resultMap type="com.smartor.domain.ServiceSubtaskCount" id="ServiceSubtaskResult2">
@@ -123,6 +124,7 @@
                recordid,
                exrecallcount,
                pulltime,
+               leavediagname,
                deptcode,
                labelstatus,
                del_flag,
@@ -158,250 +160,160 @@
 
     <select id="selectServiceSubtaskList" parameterType="com.smartor.domain.ServiceSubtaskVO"
             resultMap="ServiceSubtaskResult">
-        select a.id,
-        a.hosp_type,
-        a.suggest,
-        a.sendstate,
-        a.endtime,
-        a.nurse_id,
-        a.nurse_name,
-        a.starttime,
-        a.submit,
-        a.inhospid,
-        a.drname,
-        a.excep,
-        a.drcode,
-        a.long_send_time,
-        a.openid,
-        a.remark,
-        a.service_type,
-        a.libtemplateid,
-        a.libtemplatename,
-        a.hospno,
-        a.score,
-        a.phone,
-        a.sex,
-        a.age,
-        a.patid,
-        a.sfzh,
-        a.addr,
-        a.senderdetail,
-        a.type,
-        a.taskid,
-        a.templateid,
-        a.templatename,
-        a.senddate,
-        a.senduuid,
-        a.result,
-        a.finishtime,
-        a.recordid,
-        a.exrecallcount,
-        a.pulltime,
-        a.deptcode,
-        a.labelstatus,
-        a.del_flag,
-        a.update_by,
-        a.update_time,
-        a.create_by,
-        a.create_time,
-        a.isupload,
-        a.upload_time,
-        a.orgid,
-        a.pid,
-        a.guid,
-        a.text_param,
-        a.preachform,
-        a.bed_no,
-        a.send_type,
-        a.task_name,
-        a.task_desc,
-        a.operator_no,
-        a.operator,
-        a.wechat,
-        a.sendname,
-        a.roomno,
-        a.admindate,
-        a.deptname,
-        a.stop_state,
-        a.visit_time,
-        a.leavehospitaldistrictcode,
-        a.leavehospitaldistrictname,
-        a.diagname,
-        COALESCE((
-        SELECT string_agg(d.tagname, ', ')
-        FROM pat_archivetag d
-        WHERE d.patid = a.patid
-        AND d.del_flag = 0
-        ), '') AS tagname
-        from service_subtask a
-        LEFT JOIN pat_archivetag c ON c.patid = a.patid
+        <include refid="selectServiceSubtaskVo"/>
         <where>
-            a.del_flag=0
-            -- and c.del_flag=0
-            <if test="sendname != null  and sendname != ''">and a.sendname like concat('%', #{sendname}, '%')</if>
-            <if test="tagname != null  and tagname != ''">and c.tagname like concat('%', #{tagname}, '%')</if>
+            del_flag=0
+            <if test="sendname != null  and sendname != ''">and sendname like concat('%', #{sendname}, '%')</if>
             <if test="phone != null  and phone != ''">and phone = #{phone}</if>
             <if test="leavehospitaldistrictcode != null  and leavehospitaldistrictcode != ''">and
-                a.leavehospitaldistrictcode = #{leavehospitaldistrictcode}
+                leavehospitaldistrictcode = #{leavehospitaldistrictcode}
             </if>
             <if test="leavehospitaldistrictname != null  and leavehospitaldistrictname != ''">and
-                a.leavehospitaldistrictname = #{leavehospitaldistrictname}
+                leavehospitaldistrictname = #{leavehospitaldistrictname}
             </if>
-            <if test="sex != null  and sex != ''">and a.sex = #{sex}</if>
-            <if test="age != null ">and a.age = #{age}</if>
-            <if test="submit != null ">and a.submit = #{submit}</if>
-            <if test="serviceType != null ">and a.service_type = #{serviceType}</if>
-            <if test="patid != null ">and a.patid = #{patid}</if>
-            <if test="sfzh != null  and sfzh != ''">and a.sfzh = #{sfzh}</if>
-            <if test="addr != null  and addr != ''">and a.addr = #{addr}</if>
-            <if test="senderdetail != null  and senderdetail != ''">and a.senderdetail = #{senderdetail}</if>
-            <if test="type != null  and type != ''">and a.type = #{type}</if>
-            <if test="taskid != null ">and a.taskid = #{taskid}</if>
-            <if test="templateid != null  and templateid != ''">and a.templateid = #{templateid}</if>
-            <if test="templatename != null  and templatename != ''">and a.templatename like concat('%', #{templatename},
+            <if test="leavediagname != null  and leavediagname != ''">and leavediagname like concat('%',
+                #{leavediagname}, '%')
+            </if>
+            <if test="sex != null  and sex != ''">and sex = #{sex}</if>
+            <if test="age != null ">and age = #{age}</if>
+            <if test="patguid != null ">and patguid = #{patguid}</if>
+            <if test="subId != null ">and id = #{subId}</if>
+            <if test="inhospid != null ">and inhospid = #{inhospid}</if>
+            <if test="submit != null ">and submit = #{submit}</if>
+            <if test="upid != null ">and upid = #{upid}</if>
+            <if test="patfrom != null ">and patfrom = #{patfrom}</if>
+            <if test="serviceType != null ">and service_type = #{serviceType}</if>
+            <if test="patid != null ">and patid = #{patid}</if>
+            <if test="sfzh != null  and sfzh != ''">and sfzh = #{sfzh}</if>
+            <if test="addr != null  and addr != ''">and addr = #{addr}</if>
+            <if test="senderdetail != null  and senderdetail != ''">and senderdetail = #{senderdetail}</if>
+            <if test="type != null  and type != ''">and type = #{type}</if>
+            <if test="taskid != null ">and taskid = #{taskid}</if>
+            <if test="templateid != null  and templateid != ''">and templateid = #{templateid}</if>
+            <if test="templatename != null  and templatename != ''">and templatename like concat('%', #{templatename},
                 '%')
             </if>
             <if test="startOutHospTime != null">
-                AND TO_DATE( a.endtime,'YYYY-MM-DD') &gt;= TO_DATE(#{startOutHospTime},'YYYY-MM-DD')
+                AND to_char(endtime, 'YYMMDD') &gt;= to_char(#{startOutHospTime}::timestamp, 'YYMMDD')
             </if>
             <if test="endOutHospTime != null">
-                AND TO_DATE( a.endtime,'YYYY-MM-DD') &lt;= TO_DATE(#{endOutHospTime},'YYYY-MM-DD')
+                AND to_char(endtime, 'YYMMDD') &lt;= to_char(#{endOutHospTime}::timestamp, 'YYMMDD')
             </if>
-            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
-                AND a.leavehospitaldistrictcode IN
-                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
-                         close=")">
-                    #{leavehospitaldistrictcode}
-                </foreach>
+            <if test="startSendDateTime != null">
+                AND to_char(long_send_time, 'YYMMDD') >= to_char(#{startSendDateTime}::timestamp, 'YYMMDD')
             </if>
-            <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
-                AND a.deptcode IN
-                <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
-                         close=")">
-                    #{leaveldeptcode}
-                </foreach>
+            <if test="endSendDateTime != null">
+                AND to_char(long_send_time, 'YYMMDD') &lt;= to_char(#{endSendDateTime}::timestamp, 'YYMMDD')
+            </if>
+            <if test="longSendTime != null">
+                AND to_char(long_send_time, 'YYMMDD') &lt;= to_char(#{longSendTime}::timestamp, 'YYMMDD')
+            </if>
+            <if test="deptOrDistrict==1">
+                <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+                    AND leavehospitaldistrictcode IN
+                    <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
+                             separator=","
+                             close=")">
+                        #{leavehospitaldistrictcode}
+                    </foreach>
+                </if>
+                <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
+                    AND deptcode IN
+                    <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+                             close=")">
+                        #{leaveldeptcode}
+                    </foreach>
+                </if>
+            </if>
+            <if test="deptOrDistrict==2">
+                <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+                    AND (leavehospitaldistrictcode IN
+                    <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
+                             separator=","
+                             close=")">
+                        #{leavehospitaldistrictcode}
+                    </foreach>
+                </if>
+                <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
+                    OR deptcode IN
+                    <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
+                             close="))">
+                        #{leaveldeptcode}
+                    </foreach>
+                </if>
             </if>
 
-            <if test="senddate != null ">and a.senddate = #{senddate}</if>
-            <if test="senduuid != null  and senduuid != ''">and a.senduuid = #{senduuid}</if>
-            <if test="result != null  and result != ''">and a.result = #{result}</if>
-            <if test="finishtime != null ">and a.finishtime = #{finishtime}</if>
-            <if test="recordid != null ">and a.recordid = #{recordid}</if>
-            <if test="exrecallcount != null ">and a.exrecallcount = #{exrecallcount}</if>
-            <if test="pulltime != null ">and a.pulltime = #{pulltime}</if>
-            <if test="deptcode != null  and deptcode != ''">and a.deptcode = #{deptcode}</if>
-            <if test="deptname != null  and deptname != ''">and a.deptname = #{deptname}</if>
-            <if test="labelstatus != null ">and a.labelstatus = #{labelstatus}</if>
-            <if test="isupload != null ">and a.isupload = #{isupload}</if>
-            <if test="uploadTime != null ">and a.upload_time = #{uploadTime}</if>
-            <if test="orgid != null  and orgid != ''">and a.orgid = #{orgid}</if>
-            <if test="pid != null ">and a.pid = #{pid}</if>
-            <if test="inhospid != null ">and a.inhospid = #{inhospid}</if>
-            <if test="preachform != null ">and a.preachform = #{preachform}</if>
-            <if test="guid != null  and guid != ''">and a.guid = #{guid}</if>
-            <if test="textParam != null  and textParam != ''">and a.text_param = #{textParam}</if>
-            <if test="bedNo != null">and a.bed_no = #{bedNo}</if>
-            <if test="sendType != null  and sendType != ''">and a.send_type = #{sendType}</if>
-            <if test="operator != null  and operator != ''">and a.operator = #{operator}</if>
-            <if test="operatorNo != null  and operatorNo != ''">and a.operator_no = #{operatorNo}</if>
-            <if test="wechat != null  and wechat != ''">and a.wechat = #{wechat}</if>
-            <if test="hospType != null  and hospType != ''">and a.hosp_type = #{hospType}</if>
-            <if test="libtemplateid != null ">and a.libtemplateid = #{libtemplateid}</if>
-            <if test="libtemplatename != null ">and a.libtemplatename = #{libtemplatename}</if>
-            <if test="openid != null ">and a.openid = #{openid}</if>
-            <if test="longSendTime != null ">and a.long_send_time = #{longSendTime}</if>
-            <if test="sendstate != null ">and a.sendstate = #{sendstate}</if>
-            <if test="drname != null  and drname != ''">and a.drname like concat('%', #{drname}, '%')</if>
-            <if test="drcode != null ">and a.drcode = #{drcode}</if>
-            <if test="starttime != null ">and a.starttime = #{starttime}</if>
-            <if test="endtime != null ">and a.endtime = #{endtime}</if>
-            <if test="excep != null ">and a.excep = #{excep}</if>
-            <if test="nurseId != null ">and a.nurse_id = #{nurseId}</if>
-            <if test="nurseName != null ">and a.nurse_name = #{nurseName}</if>
-            <if test="score != null">and a.score = #{score}</if>
-            <if test="remark != null">and a.remark = #{remark}</if>
-            <if test="suggest != null">and a.suggest = #{suggest}</if>
-            <if test="createBy != null">and a.create_by = #{createBy}</if>
-            <if test="visitTime != null">and a.visit_time = #{visitTime}</if>
+            <if test="senddate != null ">and senddate = #{senddate}</if>
+            <if test="senduuid != null  and senduuid != ''">and senduuid = #{senduuid}</if>
+            <if test="result != null  and result != ''">and result = #{result}</if>
+            <if test="finishtime != null ">and finishtime = #{finishtime}</if>
+            <if test="recordid != null ">and recordid = #{recordid}</if>
+            <if test="exrecallcount != null ">and exrecallcount = #{exrecallcount}</if>
+            <if test="pulltime != null ">and pulltime = #{pulltime}</if>
+            <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
+            <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>
+            <if test="labelstatus != null ">and labelstatus = #{labelstatus}</if>
+            <if test="isupload != null ">and isupload = #{isupload}</if>
+            <if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
+            <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+            <if test="pid != null ">and pid = #{pid}</if>
+            <if test="preachform != null ">and preachform = #{preachform}</if>
+            <if test="guid != null  and guid != ''">and guid = #{guid}</if>
+            <if test="textParam != null  and textParam != ''">and text_param = #{textParam}</if>
+            <if test="bedNo != null">and bed_no = #{bedNo}</if>
+            <if test="sendType != null  and sendType != ''">and send_type = #{sendType}</if>
+            <if test="operator != null  and operator != ''">and operator = #{operator}</if>
+            <if test="operatorNo != null  and operatorNo != ''">and operator_no = #{operatorNo}</if>
+            <if test="wechat != null  and wechat != ''">and wechat = #{wechat}</if>
+            <if test="hospType != null  and hospType != ''">and hosp_type = #{hospType}</if>
+            <if test="libtemplateid != null ">and libtemplateid = #{libtemplateid}</if>
+            <if test="libtemplatename != null ">and libtemplatename = #{libtemplatename}</if>
+            <if test="openid != null ">and openid = #{openid}</if>
+            <if test="longSendTime != null ">and long_send_time = #{longSendTime}</if>
+            <if test="sendstate != null ">and sendstate = #{sendstate}</if>
+            <if test="drname != null  and drname != ''">and drname like concat('%', #{drname}, '%')</if>
+            <if test="taskName != null  and taskName != ''">and task_name like concat('%', #{taskName}, '%')</if>
+            <if test="drcode != null and drcode != ''">and (drcode = #{drcode}</if>
+            <if test="nurseId != null  and nurseId != ''">or nurse_id = #{nurseId})</if>
+            <if test="starttime != null ">and starttime = #{starttime}</if>
+            <if test="endtime != null ">and endtime = #{endtime}</if>
+            <if test="excep != null ">and excep = #{excep}</if>
+            <if test="nurseName != null ">and nurse_name = #{nurseName}</if>
+            <if test="score != null">and score = #{score}</if>
+            <!--            <if test="visitCount != null">and visit_count = #{visitCount}</if>-->
+            <if test="visitCount != null and visitCount == 1">
+                AND visit_count = 1
+            </if>
+            <if test="visitCount != null and visitCount > 1">
+                AND visit_count > 1
+            </if>
+            <if test="remark != null">and remark = #{remark}</if>
+            <if test="suggest != null">and suggest = #{suggest}</if>
+            <if test="createBy != null">and create_by = #{createBy}</if>
+            <if test="taskGuid != null">and task_guid = #{taskGuid}</if>
+            <if test="isVisitAgain != null">and is_visit_again = #{isVisitAgain}</if>
+            <if test="visitTime != null">and visit_time = #{visitTime}</if>
+            <!--<if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
+            <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>-->
+            <if test="visitCount != null and visitCount > 1 and visitDeptCodes != null and visitDeptCodes.size() > 0">
+                AND visit_dept_code IN
+                <foreach collection="visitDeptCodes" item="visitDeptCodes" open="("
+                         separator=","
+                         close=")">
+                    #{visitDeptCodes}
+                </foreach>
+            </if>
         </where>
-        GROUP BY a.id,
-        a.hosp_type,
-        a.suggest,
-        a.sendstate,
-        a.endtime,
-        a.nurse_id,
-        a.nurse_name,
-        a.starttime,
-        a.submit,
-        a.inhospid,
-        a.drname,
-        a.excep,
-        a.drcode,
-        a.long_send_time,
-        a.openid,
-        a.remark,
-        a.service_type,
-        a.libtemplateid,
-        a.libtemplatename,
-        a.hospno,
-        a.score,
-        a.phone,
-        a.sex,
-        a.age,
-        a.patid,
-        a.sfzh,
-        a.addr,
-        a.senderdetail,
-        a.type,
-        a.taskid,
-        a.templateid,
-        a.templatename,
-        a.senddate,
-        a.visit_time,
-        a.senduuid,
-        a.result,
-        a.finishtime,
-        a.recordid,
-        a.exrecallcount,
-        a.pulltime,
-        a.deptcode,
-        a.labelstatus,
-        a.del_flag,
-        a.update_by,
-        a.update_time,
-        a.create_by,
-        a.create_time,
-        a.isupload,
-        a.upload_time,
-        a.orgid,
-        a.pid,
-        a.guid,
-        a.text_param,
-        a.preachform,
-        a.bed_no,
-        a.send_type,
-        a.task_name,
-        a.task_desc,
-        a.operator_no,
-        a.operator,
-        a.wechat,
-        a.sendname,
-        a.roomno,
-        a.admindate,
-        a.deptname,
-        a.stop_state,
-        a.leavehospitaldistrictcode,
-        a.leavehospitaldistrictname,
-        a.diagname
-        order by a.visit_time desc
-        <if test="serviceType != null  and serviceType != ''and serviceType != '2'and serviceType != '3'">
-            ,a.long_send_time desc
-        </if>
-        <if test="serviceType != null  and serviceType != ''and serviceType == '2'">,a.endtime desc</if>
-        <if test="serviceType != null  and serviceType != ''and serviceType == '3'">,a.admindate desc</if>
+        <if test="sort != null  and sort==0">order by endtime asc</if>
+        <if test="sort != null  and sort==1">order by endtime desc</if>
+        <if test="sort != null  and sort==2">order by long_send_time asc</if>
+        <if test="sort != null  and sort==3">order by long_send_time desc</if>
+        <if test="sort != null  and sort==5">order by admindate asc</if>
+        <if test="sort != null  and sort==6">order by admindate desc</if>
 
-
+        <!-- order by update_time desc,id desc -->
     </select>
+
 
     <select id="selectServiceSubtaskById" parameterType="Long" resultMap="ServiceSubtaskResult">
         <include refid="selectServiceSubtaskVo"/>
@@ -491,6 +403,7 @@
             <if test="sendstate != null ">sendstate,</if>
             <if test="inhospid != null ">inhospid,</if>
             <if test="visitTime != null ">visit_time,</if>
+            <if test="leavediagname != null ">leavediagname,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="sendname != null">#{sendname},</if>
@@ -563,6 +476,7 @@
             <if test="sendstate != null ">#{sendstate},</if>
             <if test="inhospid != null ">#{inhospid},</if>
             <if test="visitTime != null ">#{visitTime},</if>
+            <if test="leavediagname != null ">#{leavediagname},</if>
         </trim>
     </insert>
 
@@ -639,6 +553,7 @@
             <if test="suggest != null ">suggest=#{suggest},</if>
             <if test="inhospid != null ">inhospid=#{inhospid},</if>
             <if test="visitTime != null ">visit_time=#{visitTime},</if>
+            <if test="leavediagname != null ">leavediagname=#{leavediagname},</if>
         </trim>
         where id = #{id}
     </update>
@@ -721,6 +636,7 @@
         <where>
             <if test="patid != null ">patid=#{patid}</if>
             <if test="taskid != null ">and taskid=#{taskid}</if>
+            <if test="leavediagname != null ">and leavediagname=#{leavediagname}</if>
         </where>
     </update>
 
@@ -797,6 +713,7 @@
             <if test="suggest != null ">suggest=#{suggest},</if>
             <if test="inhospid != null ">inhospid=#{inhospid},</if>
             <if test="visitTime != null ">visit_time=#{visitTime},</if>
+            <if test="leavediagname != null ">leavediagname=#{leavediagname},</if>
         </trim>
         where patid = #{patid} and taskid = #{taskid}
     </update>
@@ -908,6 +825,7 @@
                nurse_name,
                remark,
                visit_time,
+               leavediagname,
                diagname
         FROM service_subtask,
              JSON_TABLE(send_time_slot, '$[*]' COLUMNS (
@@ -922,7 +840,7 @@
     <!--    鑾峰彇闅忚闂ㄨ瘖姣忔湀鐨勬暟閲�-->
     <select id="getSfFzInfoEveryMonth" parameterType="com.smartor.domain.ServiceSubtaskCountReq"
             resultMap="ServiceSubtaskResult2">
-        SELECT TO_DATE(st.finishtime, '%Y-%m') AS month,
+        SELECT to_char(st.finishtime, 'YYYY-MM') AS month,
               st.service_type as service_type,
 		      st.id as subTaskId,
     COUNT(*) AS count
@@ -934,14 +852,236 @@
         WHERE
             dd.user_id =#{userId}
           AND st.finishtime IS NOT NULL
-          and TO_DATE(st.finishtime
-            , '%Y-%m') &gt;= #{startTime}
-          and TO_DATE(st.finishtime
-            , '%Y-%m') &lt;= #{endTime}
+          and to_char(st.finishtime
+            , 'YYYY-MM') &gt;= #{startTime}
+          and to_char(st.finishtime
+            , 'YYYY-MM') &lt;= #{endTime}
         GROUP BY
             month, st.service_type, st.id
         ORDER BY
             month, st.service_type, st.id;
     </select>
 
+
+    <!-- 鏈嶅姟缁熻鏌ヨ - 鎸夋椂闂寸淮搴︾粺璁″嚭闄�/闂ㄨ瘖闅忚鏁版嵁 -->
+    <select id="getServiceStatistics" parameterType="com.smartor.domain.ServiceStatisticsRequest"
+            resultType="com.smartor.domain.ServiceStatisticsResponse">
+        SELECT
+        timePeriod,
+        SUM(dischargeFollowCount) AS dischargeFollowCount,
+        SUM(outpatientFollowCount) AS outpatientFollowCount,
+        SUM(pmiCount) AS pmiCount,
+        SUM(pmoCount) AS pmoCount
+        FROM (
+        -- 闅忚鏁版嵁
+        SELECT
+        <choose>
+            <when test="timeType == 'day'">
+                to_char(visit_time, 'YYYY-MM-DD') AS timePeriod,
+            </when>
+            <when test="timeType == 'month'">
+                to_char(visit_time, 'YYYY-MM') AS timePeriod,
+            </when>
+            <when test="timeType == 'year'">
+                to_char(visit_time, 'YYYY') AS timePeriod,
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(visit_time), '-W', LPAD(WEEK(visit_time, 1), 2, '0')) AS timePeriod,
+            </when>
+            <otherwise>
+                to_char(visit_time, 'YYYY-MM-DD') AS timePeriod,
+            </otherwise>
+        </choose>
+        COUNT(CASE WHEN service_type = '2' THEN 1 END) AS dischargeFollowCount,
+        COUNT(CASE WHEN service_type = '3' THEN 1 END) AS outpatientFollowCount,
+        0 AS pmiCount,
+        0 AS pmoCount
+        FROM service_subtask
+        WHERE
+        del_flag = '0'
+        <if test="startDate != null and endDate != null">
+            AND  visit_time  &gt;=  #{startDate}
+            AND  visit_time  &lt;=  #{endDate}
+        </if>
+
+        <if test="orgid != null">
+            AND orgid = #{orgid}
+        </if>
+
+        <if test="deptcodes != null and deptcodes.size() > 0">
+            AND deptcode IN
+            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
+                #{deptcode}
+            </foreach>
+        </if>
+
+        <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+            AND leavehospitaldistrictcode IN
+            <foreach collection="leavehospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
+                #{districtcode}
+            </foreach>
+        </if>
+
+        <if test="serviceTypes != null and serviceTypes.size() > 0">
+            AND service_type IN
+            <foreach collection="serviceTypes" item="serviceType" open="(" separator="," close=")">
+                #{serviceType}
+            </foreach>
+        </if>
+
+        GROUP BY
+        <choose>
+            <when test="timeType == 'day'">
+                to_char(visit_time, 'YYYY-MM-DD')
+            </when>
+            <when test="timeType == 'month'">
+                to_char(visit_time, 'YYYY-MM')
+            </when>
+            <when test="timeType == 'year'">
+                to_char(visit_time, 'YYYY')
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(visit_time), '-W', LPAD(WEEK(visit_time, 1), 2, '0'))
+            </when>
+            <otherwise>
+                to_char(visit_time, 'YYYY-MM-DD')
+            </otherwise>
+        </choose>
+
+        UNION ALL
+
+        -- 鍑洪櫌浜烘鏁版嵁
+        SELECT
+        <choose>
+            <when test="timeType == 'day'">
+                to_char(endtime, 'YYYY-MM-DD') AS timePeriod,
+            </when>
+            <when test="timeType == 'month'">
+                to_char(endtime, 'YYYY-MM') AS timePeriod,
+            </when>
+            <when test="timeType == 'year'">
+                to_char(endtime, 'YYYY') AS timePeriod,
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(endtime), '-W', LPAD(WEEK(endtime, 1), 2, '0')) AS timePeriod,
+            </when>
+            <otherwise>
+                to_char(endtime, 'YYYY-MM-DD') AS timePeriod,
+            </otherwise>
+        </choose>
+        0 AS dischargeFollowCount,
+        0 AS outpatientFollowCount,
+        COUNT( patid) AS pmiCount,
+        0 AS pmoCount
+        FROM pat_med_inhosp
+        WHERE del_flag = '0'
+        <if test="startDate != null and endDate != null">
+            AND endtime  &gt;=  #{startDate}
+            AND  endtime  &lt;=  #{endDate}
+        </if>
+
+        AND inhospstate=1
+        <if test="orgid != null">
+            AND orgid = #{orgid}
+        </if>
+
+        <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
+            AND leavehospitaldistrictcode IN
+            <foreach collection="leavehospitaldistrictcodes" item="districtcode" open="(" separator="," close=")">
+                #{districtcode}
+            </foreach>
+        </if>
+
+        <if test="deptcodes != null and deptcodes.size() > 0">
+            AND leaveldeptcode IN
+            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
+                #{deptcode}
+            </foreach>
+        </if>
+
+        GROUP BY
+        <choose>
+            <when test="timeType == 'day'">
+                to_char(endtime, 'YYYY-MM-DD')
+            </when>
+            <when test="timeType == 'month'">
+                to_char(endtime, 'YYYY-MM')
+            </when>
+            <when test="timeType == 'year'">
+                to_char(endtime, 'YYYY')
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(endtime), '-W', LPAD(WEEK(endtime, 1), 2, '0'))
+            </when>
+            <otherwise>
+                to_char(endtime, 'YYYY-MM-DD')
+            </otherwise>
+        </choose>
+
+        UNION ALL
+
+        -- 闂ㄨ瘖浜烘鏁版嵁
+        SELECT
+        <choose>
+            <when test="timeType == 'day'">
+                to_char(admitdate, 'YYYY-MM-DD') AS timePeriod,
+            </when>
+            <when test="timeType == 'month'">
+                to_char(admitdate, 'YYYY-MM') AS timePeriod,
+            </when>
+            <when test="timeType == 'year'">
+                to_char(admitdate, 'YYYY') AS timePeriod,
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0')) AS timePeriod,
+            </when>
+            <otherwise>
+                to_char(admitdate, 'YYYY-MM-DD') AS timePeriod,
+            </otherwise>
+        </choose>
+        0 AS dischargeFollowCount,
+        0 AS outpatientFollowCount,
+        0 AS pmiCount,
+        COUNT( patid) AS pmoCount
+        FROM pat_med_outhosp
+        WHERE del_flag = '0'
+        <if test="startDate != null and endDate != null">
+            AND admitdate &gt;= #{startDate}
+            AND admitdate &lt;= #{endDate}
+        </if>
+        <if test="orgid != null">
+            AND orgid = #{orgid}
+        </if>
+
+        <if test="deptcodes != null and deptcodes.size() > 0">
+            AND deptcode IN
+            <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
+                #{deptcode}
+            </foreach>
+        </if>
+
+        GROUP BY
+        <choose>
+            <when test="timeType == 'day'">
+                to_char(admitdate, 'YYYY-MM-DD')
+            </when>
+            <when test="timeType == 'month'">
+                to_char(admitdate, 'YYYY-MM')
+            </when>
+            <when test="timeType == 'year'">
+                to_char(admitdate, 'YYYY')
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0'))
+            </when>
+            <otherwise>
+                to_char(admitdate, 'YYYY-MM-DD')
+            </otherwise>
+        </choose>
+        ) AS combined_data
+        GROUP BY timePeriod
+        ORDER BY timePeriod DESC
+    </select>
+
+
 </mapper>

--
Gitblit v1.9.3