From c5eaceb69bb9360f6bd802e4796b8023afa3c581 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 07 八月 2025 09:41:00 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/domain/ServiceSubtask.java                             |   13 +
 smartor/src/main/java/com/smartor/domain/ServiceStatisticsResponse.java                  |   41 ++++
 smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java           |    8 
 smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java                    |    3 
 smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml                       |  241 ++++++++++++++++++++++++++
 smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java                  |    6 
 smartor/src/main/java/com/smartor/domain/PatMedInhospVO.java                             |   15 +
 smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml                         |   61 ++++--
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java |   10 +
 smartor/src/main/java/com/smartor/domain/PatMedInhosp.java                               |   14 +
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java            |   49 ++++-
 ruoyi-admin/src/main/resources/application-druid.yml                                     |   13 +
 ruoyi-admin/src/main/resources/logback.xml                                               |    2 
 smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java                       |    2 
 smartor/src/main/java/com/smartor/domain/ServiceStatisticsRequest.java                   |   46 +++++
 smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java                           |   12 +
 16 files changed, 495 insertions(+), 41 deletions(-)

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 850c856..a8c2986 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
@@ -336,4 +336,14 @@
         util.exportExcel(response, sfStatistics, "闅忚缁熻瀵煎嚭");
     }
 
+    /**
+     * 闅忚缁熻瀵煎嚭
+     */
+    @ApiOperation("鏈嶅姟缁熻鏌ヨ-鎸夋椂闂寸淮搴︾粺璁″嚭闄�/闂ㄨ瘖闅忚鏁版嵁")
+    @PostMapping("/getServiceStatistics")
+    public AjaxResult getServiceStatistics(@RequestBody ServiceStatisticsRequest serviceStatisticsRequest) {
+        List<ServiceStatisticsResponse> serviceStatistics = serviceSubtaskService.getServiceStatistics(serviceStatisticsRequest);
+        return success(serviceStatistics);
+    }
+
 }
diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml
index da4ddd3..1759df4 100644
--- a/ruoyi-admin/src/main/resources/application-druid.yml
+++ b/ruoyi-admin/src/main/resources/application-druid.yml
@@ -28,10 +28,15 @@
         #        password: Smartor.2023
         #        driverClassName: com.mysql.cj.jdbc.Driver
 
-        #  鍏徃浜�
-        url: jdbc:mysql://116.62.18.175:6002/smartor_lisui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-        username: hxsoft
-        password: Hxerp2000
+        #        #  鍏徃浜�
+        #        url: jdbc:mysql://116.62.18.175:6002/smartor_lisui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        #        username: hxsoft
+        #        password: Hxerp2000
+        #        driverClassName: com.mysql.cj.jdbc.Driver
+        #  鍏徃鏈湴
+        url: jdbc:mysql://192.168.100.10:3306/smartor_lishui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        username: smartor
+        password: Smartor.2023
         driverClassName: com.mysql.cj.jdbc.Driver
 
       #        # 楂樻柉鏁版嵁搴撻厤缃�
diff --git a/ruoyi-admin/src/main/resources/logback.xml b/ruoyi-admin/src/main/resources/logback.xml
index 96dd132..ab17872 100644
--- a/ruoyi-admin/src/main/resources/logback.xml
+++ b/ruoyi-admin/src/main/resources/logback.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <!-- 鏃ュ織瀛樻斁璺緞 8095-->
-    <property name="log.path" value="E:/health/logs"/>
+    <property name="log.path" value="D:/health/logs"/>
     <!-- 鏃ュ織瀛樻斁璺緞 8096-->
     <!--    <property name="log.path" value="D:/lihu/logs"/>-->
     <!-- 涓芥按鏃ュ織瀛樻斁璺緞 -->
diff --git a/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java b/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java
index bc2160c..805a65b 100644
--- a/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java
+++ b/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java
@@ -182,4 +182,10 @@
     @ApiModelProperty(value = "鑱旂郴浜轰俊鎭�")
     List<ExternalInHospPatientLiaisonInfo> externalInHospPatientLiaisonInfos;
 
+    @ApiModelProperty(value = "缁忕鍖荤敓ID")
+    private String JingGuanYSID;
+
+    @ApiModelProperty(value = "缁忕鍖荤敓濮撳悕")
+    private String JingGuanYSXM;
+
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java b/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
index 94f4791..e2d662a 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMedInhosp.java
@@ -449,4 +449,18 @@
     @ApiModelProperty("璇佷欢鍙风爜")
     @Excel(name = " 璇佷欢鍙风爜 ")
     private String idcardno;
+
+    /**
+     * 缁忕鍖荤敓
+     */
+    @ApiModelProperty("缁忕鍖荤敓")
+    @Excel(name = " 缁忕鍖荤敓 ")
+    private String managementDoctor;
+
+    /**
+     * 缁忕鍖荤敓
+     */
+    @ApiModelProperty("缁忕鍖荤敓")
+    @Excel(name = " 缁忕鍖荤敓 ")
+    private String managementDoctorCode;
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatMedInhospVO.java b/smartor/src/main/java/com/smartor/domain/PatMedInhospVO.java
index 93b10ba..c29bf85 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMedInhospVO.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMedInhospVO.java
@@ -340,4 +340,19 @@
      */
     @ApiModelProperty(value = "缁撴潫鍏ラ櫌鏃ユ湡")
     private Date endInHospTime;
+
+    /**
+     * 缁忕鍖荤敓
+     */
+    @ApiModelProperty("缁忕鍖荤敓")
+    @Excel(name = " 缁忕鍖荤敓 ")
+    private String managementDoctor;
+
+    /**
+     * 缁忕鍖荤敓
+     */
+    @ApiModelProperty("缁忕鍖荤敓")
+    @Excel(name = " 缁忕鍖荤敓 ")
+    private String managementDoctorCode;
 }
+
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..6d9f8de
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/ServiceStatisticsRequest.java
@@ -0,0 +1,46 @@
+package com.smartor.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+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 Long 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..850455a
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/ServiceStatisticsResponse.java
@@ -0,0 +1,41 @@
+package com.smartor.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 鏈嶅姟缁熻鍝嶅簲缁撴灉
+ *
+ * @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 9cda916..69c18ee 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
@@ -625,4 +625,17 @@
     @Excel(name = "ps")
     @ApiModelProperty(value = "ps")
     private Integer ps;
+
+
+    /**
+     * 鎮h�呮潵婧�
+     */
+    @ApiModelProperty(value = "缁忕鍖荤敓缂栫爜")
+    private String managementDoctorCode;
+
+    /**
+     * 鎮h�呮潵婧�
+     */
+    @ApiModelProperty(value = "缁忕鍖荤敓")
+    private String managementDoctor;
 }
diff --git a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
index d4486fd..7a5806f 100644
--- a/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
+++ b/smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
@@ -641,6 +641,18 @@
     private String patfrom;
 
     /**
+     * 鎮h�呮潵婧�
+     */
+    @ApiModelProperty(value = "缁忕鍖荤敓缂栫爜")
+    private String managementDoctorCode;
+
+    /**
+     * 鎮h�呮潵婧�
+     */
+    @ApiModelProperty(value = "缁忕鍖荤敓")
+    private String managementDoctor;
+
+    /**
      * 寮�濮嬪嚭闄㈡棩鏈�
      */
     @ApiModelProperty(value = "寮�濮嬪嚭闄㈡棩鏈�")
diff --git a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
index a1c2dbf..bffdbe3 100644
--- a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
@@ -96,4 +96,6 @@
 
     public List<PatMedRes> getDeptRanking(PatMedReq patMedReq);
 
+    public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest serviceStatisticsRequest);
+
 }
diff --git a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
index 6c648e8..22e2881 100644
--- a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
+++ b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
@@ -45,6 +45,7 @@
      * 鏌ヨ鎮h�呴殢璁夸俊鎭�
      */
     public List<ServiceSubtask> patItem(ServiceSubtaskVO serviceSubtaskVO);
+
     public List<ServiceSubtask> patItem2(ServiceSubtaskVO serviceSubtaskVO);
 
     public Map<String, Object> patItemCount(ServiceSubtaskVO serviceSubtaskVO);
@@ -127,4 +128,6 @@
     public List<ServiceSubtaskCount> getSfFzInfoEveryMonth(ServiceSubtaskCountReq serviceSubtaskCountReq);
 
     public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq);
+
+    public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest request);
 }
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
index 8602729..16b192f 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -283,6 +283,8 @@
         externalInHospPatientInfo.setZhuZhiYSID(externalInDeptPatientInfo.getZhuZhiYSID());
         externalInHospPatientInfo.setZhuZhiYSXM(externalInDeptPatientInfo.getZhuZhiYSXM());
         externalInHospPatientInfo.setRuYuanSJ(externalInDeptPatientInfo.getRuYuanSJ());
+        externalInHospPatientInfo.setJingGuanYSID(externalInDeptPatientInfo.getJingGuanYSID());
+        externalInHospPatientInfo.setJingGuanYSXM(externalInDeptPatientInfo.getJingGuanYSXM());
         externalInHospPatientInfo.setLianXiDH(ObjectUtils.isNotEmpty(BingRenXX.get("LianXiDH")) ? BingRenXX.get("LianXiDH").toString() : null);
         externalInHospPatientInfo.setDangQianCWID(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianCWID")) ? BingRenXX.get("DangQianCWID").toString() : null);
         externalInHospPatientInfo.setDangQianCWMC(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianCWMC")) ? BingRenXX.get("DangQianCWMC").toString() : null);
@@ -900,6 +902,7 @@
         patMedOuthosp.setAdmitdate(externalJZInfo.getJiuZhenRQ());
         patMedOuthosp.setOrgid(FaSongJGID);
         patMedOuthosp.setHospitalname(FaSongJGMC);
+        patMedOuthosp.setIdcardno(patArchive.getIdcardno());
 
         //杩欎釜闇�瑕佺瓑HIS閭h竟鍛婅瘔鍙栧摢涓瓧娈碉紝鐜板湪杩樻槸涓嶅鐨�
         patMedOuthosp.setFudate(externalJZInfo.getSfrq());
@@ -941,7 +944,7 @@
         }
 
         //鍏堥�氳繃韬唤璇佸拰绉戝鏌ヨ璇ユ偅鑰呮槸鍚︽湁闇�瑕侀殢璁跨殑(鏅畞鎻愬嚭鏉ョ殑)
-        if (patMedOuthosp.getOrgid().equals("47255004333112711A1001")) {
+        if (patMedOuthosp.getOrgid().equals("47255004333112711A1001") && StringUtils.isNotEmpty(patMedOuthosp.getIdcardno()) && StringUtils.isNotEmpty(patMedOuthosp.getDeptcode())) {
             ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO();
             serviceSubtaskVO.setSfzh(patMedOuthosp.getIdcardno());
             serviceSubtaskVO.setDeptcode(patMedOuthosp.getDeptcode());
@@ -951,6 +954,7 @@
                 for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
                     serviceSubtask.setSendstate(6L);
                     serviceSubtask.setRemark("鎮h�呭凡缁忓洖鏉ュ璇�");
+                    serviceSubtask.setUpdateTime(new Date());
                     serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                 }
             }
@@ -1361,6 +1365,8 @@
             patMedInhosp.setDrcode(externalInHospPatientInfo.getZhuZhiYSID());
             patMedInhosp.setNurseId(externalInHospPatientInfo.getZeRenHSID());
             patMedInhosp.setNurseName(externalInHospPatientInfo.getZeRenHSXM());
+            patMedInhosp.setManagementDoctor(externalInHospPatientInfo.getJingGuanYSXM());
+            patMedInhosp.setManagementDoctorCode(externalInHospPatientInfo.getJingGuanYSID());
         }
         if (ObjectUtils.isNotEmpty(externalInHospPatientDiagnoseInfo)) {
 //            patMedInhosp.setIcd10code(StringUtils.isNotEmpty(patMedInhosp.getIcd10code()) ? patMedInhosp.getIcd10code() + "," + externalInHospPatientDiagnoseInfo.getZhenDuanID() : externalInHospPatientDiagnoseInfo.getZhenDuanID());
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 de6eb96..bc69fb7 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -15,7 +15,6 @@
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.ListOperations;
@@ -24,6 +23,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.time.Duration;
@@ -854,7 +854,7 @@
                     //鏈変笅涓�棰�
                     redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
                     IvrTaskTemplateScriptVO nextQuestion = getNextQuestion(IvrTaskTemplateScriptVOs, nowQuestion);
-                    // 闂锛�  鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+                    // 闂锛�  鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
                     String date = simpleDateFormat1.format(new Date());
                     log.info("鍘昏皟鐢╰ts鍚堟垚鍜屾挱鏀炬帴鍙�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                     phoneUtils.ttsPlayback(nowQuestion.getIvrtext(), phoneCallBackVO.getUuid());
@@ -863,7 +863,7 @@
                 redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES);
                 //璋冪敤ivrLibaTemplateScriptVO涓殑slienceText(闈欓粯璇濇湳)
                 String slienceText = nowQuestion.getSlienceText();
-                //闈欓粯璇濇湳  + 闂锛�  鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+                //闈欓粯璇濇湳  + 闂锛�  鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
                 String date = simpleDateFormat1.format(new Date());
                 log.info("闈欓粯璇濇湳  + 闂,鍘昏皟鐢╰ts鍚堟垚鍜屾挱鏀炬帴鍙�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                 phoneUtils.ttsPlayback(slienceText + nowQuestion.getIvrtext(), phoneCallBackVO.getUuid());
@@ -1028,9 +1028,9 @@
                             redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
                             redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES);
                         }
-                        //璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback鈥濆皢缁撴灉浼犲洖
+                        //璋冪敤"15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback"灏嗙粨鏋滀紶鍥�
                         String date = simpleDateFormat1.format(new Date());
-                        log.info("璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀�------: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
+                        log.info("璋冪敤tts鍚堟垚鍜屾挱鏀�------: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                         phoneUtils.ttsPlayback(nowQuestion.getIvrtext() + ivrTaskTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid());
                     }
                     break;
@@ -1061,7 +1061,7 @@
         if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) {
             //澶勭悊鎸傛柇
             if (phoneCallReqYQVO.getAsrtext().contains("鎷ㄥ彨鐨勭敤鎴锋蹇�")) {
-                //鍒ゆ柇 recordAccept-hungup 鏄惁鏈夊�硷紝濡傛灉鏈夛紝鍒欒鏄庝笉鐢ㄥ鐞嗕簡锛屼箣鍓嶅凡缁忓鐞嗚繃浜嗭紙recordAccept-hungup杩欎釜涓昏鏄粰鈥滈�氳瘽璁板綍鐢ㄧ殑锛屸�濓級
+                //鍒ゆ柇 recordAccept-hungup 鏄惁鏈夊�硷紝濡傛灉鏈夛紝鍒欒鏄庝笉鐢ㄥ鐞嗕簡锛屼箣鍓嶅凡缁忓鐞嗚繃浜嗭紙recordAccept-hungup杩欎釜涓昏鏄粰"閫氳瘽璁板綍鐢ㄧ殑锛�"锛�
                 Object cacheObject = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup");
                 if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) {
                     return new PhoneCallBackYQVO();
@@ -1918,14 +1918,14 @@
 //                        //鏈変笅涓�棰�
 //                        redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
 //                        IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion);
-//                        // 闂锛�  鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+//                        // 闂锛�  鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
 //                        phoneUtils.ttsPlayback(nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
 //                    }
 //                } else {
 //                    redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES);
 //                    //璋冪敤ivrLibaTemplateScriptVO涓殑slienceText(闈欓粯璇濇湳)
 //                    String slienceText = nowQuestion.getSlienceText();
-//                    //闈欓粯璇濇湳  + 闂锛�  鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+//                    //闈欓粯璇濇湳  + 闂锛�  鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
 //                    phoneUtils.ttsPlayback(slienceText + nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
 //                    return new PhoneCallBackVO();
 //                }
@@ -2035,7 +2035,7 @@
 //                                redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES);
 //                            }
 //
-//                            //璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback鈥濆皢缁撴灉浼犲洖
+//                            //璋冪敤"15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback"灏嗙粨鏋滀紶鍥�
 //
 //
 //                        }
@@ -2187,6 +2187,37 @@
     }
 
     /**
+     * 鏈嶅姟缁熻鏌ヨ - 鎸夋椂闂寸淮搴︾粺璁″嚭闄�/闂ㄨ瘖闅忚鏁版嵁
+     *
+     * @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 (StringUtils.isEmpty(request.getTimeType())) {
+            request.setTimeType("day");
+        }
+
+        List<ServiceStatisticsResponse> result = serviceSubtaskMapper.getServiceStatistics(request);
+
+
+        log.info("getServiceStatistics杩斿洖缁撴灉鏁伴噺锛歿}", result.size());
+        return result;
+    }
+
+    /**
      * 鑾峰彇闅忚缁熻姣斾緥
      *
      * @param serviceSubtaskCountReq
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 7d2406d..044efbd 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -70,12 +70,16 @@
         <result property="futypedesc" column="futypedesc"/>
         <result property="fuadvice" column="fuadvice"/>
         <result property="fuspecialadvice" column="fuspecialadvice"/>
+        <result property="managementDoctor" column="management_doctor"/>
+        <result property="managementDoctorCode" column="management_doctor_code"/>
     </resultMap>
 
     <sql id="selectPatMedInhospVo">
         select inhospid,
                patname,
                fuflag,
+               management_doctor,
+               management_doctor_code,
                fudate,
                fuperiod,
                futypecode,
@@ -145,6 +149,8 @@
         b.nurse_id,
         b.nurse_name,
         b.patname,
+        b.management_doctor,
+        b.management_doctor_code,
         b.out_way_id,
         b.out_way_name,
         b.deptcheck_flag,
@@ -209,20 +215,6 @@
             a.del_flag = 0
             AND b.del_flag = 0
             AND a.idcardno IS NOT NULL
-            <!--<if test="startOutHospTime != null">
-                AND STR_TO_DATE(b.endtime,'%Y-%m-%d') &gt;= STR_TO_DATE(#{startOutHospTime},'%Y-%m-%d')
-            </if>
-            <if test="endOutHospTime != null">
-                AND STR_TO_DATE(b.endtime,'%Y-%m-%d') &lt;= STR_TO_DATE(#{endOutHospTime},'%Y-%m-%d')
-            </if>
-            <if test="tagname != null  and tagname != ''">and c.tagname like concat('%', #{tagname}, '%')</if>
-
-            <if test="startInHospTime != null">
-                AND STR_TO_DATE(b.starttime, '%Y-%m-%d') >= STR_TO_DATE(#{startInHospTime}, '%Y-%m-%d')
-            </if>
-            <if test="endInHospTime != null">
-                AND STR_TO_DATE(b.starttime, '%Y-%m-%d') &lt;= STR_TO_DATE(#{startInHospTime}, '%Y-%m-%d')
-            </if>-->
             <if test="startOutHospTime != null ">and date_format(b.endtime,'%y%m%d') &gt;=
                 date_format(#{startOutHospTime},'%y%m%d')
             </if>
@@ -243,6 +235,8 @@
                 concat('%', #{hospitaldistrictname}, '%')
             </if>
             <if test="endtime != null ">and b.endtime = #{endtime}</if>
+            <if test="managementDoctor != null ">and b.management_doctor = #{managementDoctor}</if>
+            <if test="managementDoctorCode != null ">and b.management_doctor_code = #{managementDoctorCode}</if>
             <if test="inhospno != null ">and b.inhospno = #{inhospno}</if>
             <if test="fuflag != null ">and b.fuflag = #{fuflag}</if>
             <if test="serialnum != null ">and b.serialnum = #{serialnum}</if>
@@ -310,6 +304,8 @@
         select CONCAT( a.age, a.age_unit ) AS age,
         a.telcode as telcode,
         b.inhospid,
+        b.management_doctor,
+        b.management_doctor_code,
         b.patname,
         b.operator_id,
         b.operator,
@@ -380,6 +376,8 @@
             <if test="hospitalname != null  and hospitalname != ''">and hospitalname like concat('%', #{hospitalname},
                 '%')
             </if>
+            <if test="managementDoctor != null ">and b.management_doctor = #{managementDoctor}</if>
+            <if test="managementDoctorCode != null ">and b.management_doctor_code = #{managementDoctorCode}</if>
             <if test="patname != null  and patname != ''">and patname like concat('%', #{patname}, '%')</if>
             <if test="hospitaldistrictname != null  and hospitaldistrictname != ''">and hospitaldistrictname like
                 concat('%', #{hospitaldistrictname}, '%')
@@ -428,8 +426,6 @@
         <include refid="selectPatMedInhospVo"/>
         where inhospid = #{inhospid}
     </select>
-
-
 
 
     <insert id="insertPatMedInhosp" parameterType="com.smartor.domain.PatMedInhosp" useGeneratedKeys="true"
@@ -496,6 +492,8 @@
             <if test="futypedesc != null ">futypedesc,</if>
             <if test="fuadvice != null ">fuadvice,</if>
             <if test="fuspecialadvice != null ">fuspecialadvice,</if>
+            <if test="managementDoctor != null ">management_doctor,</if>
+            <if test="managementDoctorCode != null ">management_doctor_code,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="serialnum != null">#{serialnum},</if>
@@ -558,11 +556,14 @@
             <if test="futypedesc != null ">#{futypedesc},</if>
             <if test="fuadvice != null ">#{fuadvice},</if>
             <if test="fuspecialadvice != null ">#{fuspecialadvice},</if>
+            <if test="managementDoctor != null ">#{managementDoctor},</if>
+            <if test="managementDoctorCode != null ">#{managementDoctorCode},</if>
         </trim>
     </insert>
 
 
-    <insert id="insertPatMedInhospBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="item.inhospid">
+    <insert id="insertPatMedInhospBatch" parameterType="java.util.List" useGeneratedKeys="true"
+            keyProperty="item.inhospid">
         insert into pat_med_inhosp (
         serialnum, hospitalname, hospitalcode, hospitaldistrictcode, hospitaldistrictname,
         icd10code, diagname, starttime, endtime, deptcode, deptname, roomno, bed_no,
@@ -574,22 +575,29 @@
         deptcheck_flag, wardcheck_flag, diagcheck_flag, long_task_reason,
         nurse_id, nurse_name, out_way_id, out_way_name, guid,
         operator, operator_id, inhospno, remark,
-        fuflag, fudate, fuperiod, futypecode, futypedesc, fuadvice, fuspecialadvice
+        fuflag, fudate, fuperiod, futypecode, futypedesc, fuadvice, fuspecialadvice, management_doctor, management_doctor_doctor
         )
         values
         <foreach collection="list" item="item" separator=",">
             (
-            #{item.serialnum}, #{item.hospitalname}, #{item.hospitalcode}, #{item.hospitaldistrictcode}, #{item.hospitaldistrictname},
-            #{item.icd10code}, #{item.diagname}, #{item.starttime}, #{item.endtime}, #{item.deptcode}, #{item.deptname}, #{item.roomno}, #{item.bedNo},
-            #{item.orgid}, #{item.delFlag}, #{item.updateBy}, #{item.updateTime}, #{item.createBy}, #{item.createTime}, #{item.isupload},
-            #{item.uploadTime}, #{item.patid}, #{item.leavediagname}, #{item.leaveicd10code}, #{item.drcode}, #{item.drname},
-            #{item.schemestatus}, #{item.generalschemestatus}, #{item.leaveldeptcode}, #{item.leaveldeptname}, #{item.hospitaldistrictid},
+            #{item.serialnum}, #{item.hospitalname}, #{item.hospitalcode}, #{item.hospitaldistrictcode},
+            #{item.hospitaldistrictname},
+            #{item.icd10code}, #{item.diagname}, #{item.starttime}, #{item.endtime}, #{item.deptcode}, #{item.deptname},
+            #{item.roomno}, #{item.bedNo},
+            #{item.orgid}, #{item.delFlag}, #{item.updateBy}, #{item.updateTime}, #{item.createBy}, #{item.createTime},
+            #{item.isupload},
+            #{item.uploadTime}, #{item.patid}, #{item.leavediagname}, #{item.leaveicd10code}, #{item.drcode},
+            #{item.drname},
+            #{item.schemestatus}, #{item.generalschemestatus}, #{item.leaveldeptcode}, #{item.leaveldeptname},
+            #{item.hospitaldistrictid},
             #{item.leavehospitaldistrictcode}, #{item.leavehospitaldistrictname}, #{item.leavehospitaldistrictid},
-            #{item.deptid}, #{item.leaveldeptid}, #{item.schemetime}, #{item.patname}, #{item.patno}, #{item.inhospstate},
+            #{item.deptid}, #{item.leaveldeptid}, #{item.schemetime}, #{item.patname}, #{item.patno},
+            #{item.inhospstate},
             #{item.deptcheckFlag}, #{item.wardcheckFlag}, #{item.diagcheckFlag}, #{item.longTaskReason},
             #{item.nurseId}, #{item.nurseName}, #{item.outWayId}, #{item.outWayName}, #{item.guid},
             #{item.operator}, #{item.operatorId}, #{item.inhospno}, #{item.remark},
-            #{item.fuflag}, #{item.fudate}, #{item.fuperiod}, #{item.futypecode}, #{item.futypedesc}, #{item.fuadvice}, #{item.fuspecialadvice}
+            #{item.fuflag}, #{item.fudate}, #{item.fuperiod}, #{item.futypecode}, #{item.futypedesc}, #{item.fuadvice},
+            #{item.fuspecialadvice}, #{item.managementDoctor}, #{item.managementDoctorCode}
             )
         </foreach>
     </insert>
@@ -657,6 +665,9 @@
             <if test="futypedesc != null ">futypedesc = #{futypedesc},</if>
             <if test="fuadvice != null ">fuadvice = #{fuadvice},</if>
             <if test="fuspecialadvice != null ">fuspecialadvice = #{fuspecialadvice},</if>
+            <if test="managementDoctor != null ">management_doctor = #{managementDoctor},</if>
+            <if test="managementDoctorCode != null ">management_doctor_code = #{managementDoctorCode}</if>
+
         </trim>
         where inhospid = #{inhospid}
     </update>
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index b043a6b..c02bd2d 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -82,6 +82,8 @@
         <result property="visitTime" column="visit_time"/>
         <result property="visitDeptName" column="visit_dept_name"/>
         <result property="visitDeptCode" column="visit_dept_code"/>
+        <result property="managementDoctor" column="management_doctor"/>
+        <result property="managementDoctorCode" column="management_doctor_code"/>
     </resultMap>
 
     <resultMap type="com.smartor.domain.ServiceSubtaskCount" id="ServiceSubtaskResult2">
@@ -96,6 +98,8 @@
                hosp_type,
                task_guid,
                patfrom,
+               management_doctor,
+               management_doctor_code,
                upid,
                visit_dept_name,
                visit_dept_code,
@@ -191,11 +195,15 @@
             <if test="leavediagname != null  and leavediagname != ''">and leavediagname like concat('%',
                 #{leavediagname}, '%')
             </if>
+            <if test="managementDoctor != null  and managementDoctor != ''">and management_doctor like concat('%',
+                #{managementDoctor}, '%')
+            </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="managementDoctorCode != null ">and management_doctor_code = #{managementDoctorCode}</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>
@@ -349,6 +357,8 @@
             <if test="isVisitAgain != null ">and is_visit_again = #{isVisitAgain}</if>
             <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
             <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if>
+            <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
+            <if test="managementDoctor != null">and management_doctor = #{managementDoctor}</if>
         </where>
 
     </select>
@@ -403,6 +413,8 @@
             <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="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
+            <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
         </where>
 
     </select>
@@ -438,6 +450,8 @@
         <if test="leavehospitaldistrictname != null  and leavehospitaldistrictname != ''">and
             leavehospitaldistrictname = #{leavehospitaldistrictname}
         </if>
+        <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
+        <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
         ) a
     </select>
 
@@ -467,7 +481,8 @@
             <if test="leavehospitaldistrictname != null  and leavehospitaldistrictname != ''">and
                 leavehospitaldistrictname = #{leavehospitaldistrictname}
             </if>
-
+            <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if>
+            <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if>
             ) a where a.finished =1)
         </where>
     </select>
@@ -560,6 +575,8 @@
             <if test="visitTime != null ">visit_Time,</if>
             <if test="visitDeptCode != null">visit_dept_code,</if>
             <if test="visitDeptName != null">visit_dept_name,</if>
+            <if test="managementDoctorCode != null">management_doctor_code,</if>
+            <if test="managementDoctor != null">management_doctor,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="sendname != null">#{sendname},</if>
@@ -641,6 +658,8 @@
             <if test="visitTime != null ">#{visitTime},</if>
             <if test="visitDeptCode != null">#{visitDeptCode},</if>
             <if test="visitDeptName != null">#{visitDeptName},</if>
+            <if test="managementDoctorCode != null">#{managementDoctorCode},</if>
+            <if test="managementDoctor != null">#{managementDoctor},</if>
         </trim>
     </insert>
 
@@ -727,6 +746,8 @@
             <if test="visitTime != null ">visit_time=#{visitTime},</if>
             <if test="visitDeptCode != null">visit_dept_code = #{visitDeptCode},</if>
             <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
+            <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
+            <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
         </trim>
         where id = #{id}
     </update>
@@ -814,6 +835,8 @@
             <if test="visitTime != null ">visit_time=#{visitTime},</if>
             <if test="visitDeptCode != null">visit_dept_code = #{visitDeptCode},</if>
             <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
+            <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
+            <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
         </trim>
         <where>
             <if test="patid != null ">and patid = #{patid}</if>
@@ -903,6 +926,8 @@
             <if test="visitTime != null ">visit_time=#{visitTime},</if>
             <if test="visitDeptCode != null">visit_dept_code = #{visitDeptCode},</if>
             <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
+            <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
+            <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
         </trim>
         where patid = #{patid} and taskid = #{taskid}
     </update>
@@ -989,6 +1014,8 @@
             <if test="visitTime != null ">visit_time=#{visitTime},</if>
             <if test="visitDeptCode != null">visit_dept_code = #{visitDeptCode},</if>
             <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if>
+            <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if>
+            <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if>
         </trim>
         where task_guid = #{taskGuid} and task_name = #{taskName}
     </update>
@@ -1119,6 +1146,8 @@
                patguid,
                visitDeptCode,
                visitDeptName,
+               management_doctor_code,
+               management_doctor,
                leaveicd10code
         FROM service_subtask,
              JSON_TABLE(send_time_slot, '$[*]' COLUMNS (
@@ -1164,4 +1193,214 @@
         GROUP BY deptname
     </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'">
+                DATE_FORMAT(visit_time, '%Y-%m-%d') AS timePeriod,
+            </when>
+            <when test="timeType == 'month'">
+                DATE_FORMAT(visit_time, '%Y-%m') AS timePeriod,
+            </when>
+            <when test="timeType == 'year'">
+                DATE_FORMAT(visit_time, '%Y') AS timePeriod,
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(visit_time), '-W', LPAD(WEEK(visit_time, 1), 2, '0')) AS timePeriod,
+            </when>
+            <otherwise>
+                DATE_FORMAT(visit_time, '%Y-%m-%d') 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 visit_time BETWEEN #{startDate} AND #{endDate}
+        AND del_flag = '0'
+
+        <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'">
+                DATE_FORMAT(visit_time, '%Y-%m-%d')
+            </when>
+            <when test="timeType == 'month'">
+                DATE_FORMAT(visit_time, '%Y-%m')
+            </when>
+            <when test="timeType == 'year'">
+                DATE_FORMAT(visit_time, '%Y')
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(visit_time), '-W', LPAD(WEEK(visit_time, 1), 2, '0'))
+            </when>
+            <otherwise>
+                DATE_FORMAT(visit_time, '%Y-%m-%d')
+            </otherwise>
+        </choose>
+
+        UNION ALL
+
+        -- 鍑洪櫌浜烘鏁版嵁
+        SELECT
+        <choose>
+            <when test="timeType == 'day'">
+                DATE_FORMAT(endtime, '%Y-%m-%d') AS timePeriod,
+            </when>
+            <when test="timeType == 'month'">
+                DATE_FORMAT(endtime, '%Y-%m') AS timePeriod,
+            </when>
+            <when test="timeType == 'year'">
+                DATE_FORMAT(endtime, '%Y') AS timePeriod,
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(endtime), '-W', LPAD(WEEK(endtime, 1), 2, '0')) AS timePeriod,
+            </when>
+            <otherwise>
+                DATE_FORMAT(endtime, '%Y-%m-%d') AS timePeriod,
+            </otherwise>
+        </choose>
+        0 AS dischargeFollowCount,
+        0 AS outpatientFollowCount,
+        COUNT(DISTINCT patid) AS pmiCount,
+        0 AS pmoCount
+        FROM pat_med_inhosp
+        WHERE endtime BETWEEN #{startDate} AND #{endDate}
+        AND del_flag = '0'
+
+        <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'">
+                DATE_FORMAT(endtime, '%Y-%m-%d')
+            </when>
+            <when test="timeType == 'month'">
+                DATE_FORMAT(endtime, '%Y-%m')
+            </when>
+            <when test="timeType == 'year'">
+                DATE_FORMAT(endtime, '%Y')
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(endtime), '-W', LPAD(WEEK(endtime, 1), 2, '0'))
+            </when>
+            <otherwise>
+                DATE_FORMAT(endtime, '%Y-%m-%d')
+            </otherwise>
+        </choose>
+
+        UNION ALL
+
+        -- 闂ㄨ瘖浜烘鏁版嵁
+        SELECT
+        <choose>
+            <when test="timeType == 'day'">
+                DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,
+            </when>
+            <when test="timeType == 'month'">
+                DATE_FORMAT(admitdate, '%Y-%m') AS timePeriod,
+            </when>
+            <when test="timeType == 'year'">
+                DATE_FORMAT(admitdate, '%Y') AS timePeriod,
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0')) AS timePeriod,
+            </when>
+            <otherwise>
+                DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,
+            </otherwise>
+        </choose>
+        0 AS dischargeFollowCount,
+        0 AS outpatientFollowCount,
+        0 AS pmiCount,
+        COUNT(DISTINCT patid) AS pmoCount
+        FROM pat_med_outhosp
+        WHERE admitdate BETWEEN #{startDate} AND #{endDate}
+        AND del_flag = '0'
+
+        <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'">
+                DATE_FORMAT(admitdate, '%Y-%m-%d')
+            </when>
+            <when test="timeType == 'month'">
+                DATE_FORMAT(admitdate, '%Y-%m')
+            </when>
+            <when test="timeType == 'year'">
+                DATE_FORMAT(admitdate, '%Y')
+            </when>
+            <when test="timeType == 'week'">
+                CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0'))
+            </when>
+            <otherwise>
+                DATE_FORMAT(admitdate, '%Y-%m-%d')
+            </otherwise>
+        </choose>
+        ) AS combined_data
+        GROUP BY timePeriod
+        ORDER BY timePeriod DESC
+    </select>
+
 </mapper>

--
Gitblit v1.9.3