liusheng
2025-08-07 c5eaceb69bb9360f6bd802e4796b8023afa3c581
代码提交
已添加2个文件
已修改14个文件
536 ■■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-druid.yml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/logback.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/PatMedInhosp.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/PatMedInhospVO.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/ServiceStatisticsRequest.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/ServiceStatisticsResponse.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/ServiceSubtask.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml 241 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
    }
}
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
      #        # é«˜æ–¯æ•°æ®åº“配置
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"/>-->
    <!-- ä¸½æ°´æ—¥å¿—存放路径 -->
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;
}
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;
}
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;
}
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 = "统计维度:day-按天, 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;
}
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;
}
smartor/src/main/java/com/smartor/domain/ServiceSubtask.java
@@ -625,4 +625,17 @@
    @Excel(name = "ps")
    @ApiModelProperty(value = "ps")
    private Integer ps;
    /**
     * æ‚£è€…来源
     */
    @ApiModelProperty(value = "经管医生编码")
    private String managementDoctorCode;
    /**
     * æ‚£è€…来源
     */
    @ApiModelProperty(value = "经管医生")
    private String managementDoctor;
}
smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
@@ -641,6 +641,18 @@
    private String patfrom;
    /**
     * æ‚£è€…来源
     */
    @ApiModelProperty(value = "经管医生编码")
    private String managementDoctorCode;
    /**
     * æ‚£è€…来源
     */
    @ApiModelProperty(value = "经管医生")
    private String managementDoctor;
    /**
     * å¼€å§‹å‡ºé™¢æ—¥æœŸ
     */
    @ApiModelProperty(value = "开始出院日期")
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);
}
smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
@@ -45,6 +45,7 @@
     * æŸ¥è¯¢æ‚£è€…随访信息
     */
    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);
}
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那边告诉取哪个字段,现在还是不对的
        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("患者已经回来复诊");
                    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());
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);
                    // é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨â€œtts合成和播放”接口
                    // é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨"tts合成和播放"接口
                    String date = simpleDateFormat1.format(new Date());
                    log.info("去调用tts合成和播放接口: {},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();
                //静默话术  + é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨â€œtts合成和播放”接口
                //静默话术  + é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨"tts合成和播放"接口
                String date = simpleDateFormat1.format(new Date());
                log.info("静默话术  + é—®é¢˜,去调用tts合成和播放接口: {},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、tts合成和播放, tts_playback”将结果传回
                        //调用"15、tts合成和播放, tts_playback"将结果传回
                        String date = simpleDateFormat1.format(new Date());
                        log.info("调用“15、tts合成和播放------: {},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);
//                        // é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨â€œtts合成和播放”接口
//                        // é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨"tts合成和播放"接口
//                        phoneUtils.ttsPlayback(nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
//                    }
//                } else {
//                    redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES);
//                    //调用ivrLibaTemplateScriptVO中的slienceText(静默话术)
//                    String slienceText = nowQuestion.getSlienceText();
//                    //静默话术  + é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨â€œtts合成和播放”接口
//                    //静默话术  + é—®é¢˜ï¼Œ  åŽ»è°ƒç”¨"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、tts合成和播放, tts_playback”将结果传回
//                            //调用"15、tts合成和播放, 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
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>
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>