陈昶聿
7 小时以前 38955eba4ef0e86bac6b1993b6b03abbbec2a929
Merge branch '20261118市一随访' into smartor_ls_merge
已修改13个文件
429 ■■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceOutPathController.java 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-druid.yml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-message/src/main/java/com/ruoyi/message/sms/provider/hzszlyy/ShiyiSmsApi.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-message/src/main/java/com/ruoyi/message/sms/provider/hzszlyy/ShiyiSmsSender.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtaskCountReq.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtaskStatistic.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java 272 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/SvyTaskSingleServiceImpl.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -675,6 +675,10 @@
     * 入参沿用原分支里已经组装好的 {@code SendMagParam},保证内容与线上完全一致。
     * 各站点差异见 {@code ruoyi-message} 模块各实现类。
     * <p>
     * 市一({@code hzszlyy})与 {@code RyTask}/{@code /sms/sendTest} 共用
     * {@code ShiyiSmsSender}:HTTP 200 即判成功;老模板里的「新华医院」签名
     * 由 {@code ShiyiSmsApi} 统一清理,本方法无需再重复处理。
     * <p>
     * ⚠️ 新华({@code xh})在本入口原本走「URL 编码表单」,
     * 与 {@code RyTask}(发空报文)/ {@code smsSubTask}(JSON)并不一致;
     * 这里按原样走 {@code XinHuaSmsSender#sendForm}(表单模式)。
@@ -682,7 +686,10 @@
    private SendResult sendSmsByActive(ServiceSubtask serviceSubtask, SendMagParam sendMagParam) {
        SmsSendRequest request = SmsSendRequest.of(
                sendMagParam.getPhone(), sendMagParam.getContent(), serviceSubtask.getOrgid());
        return smsSenderFactory.send(active, request);
        SendResult result = smsSenderFactory.send(active, request);
        log.info("【RedisMqReceiver】短信发送结果,subid:{},active:{},手机号:{},ok:{},raw:{}",
                serviceSubtask.getId(), active, sendMagParam.getPhone(), result.isOk(), result.getRawResponse());
        return result;
    }
    /**
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceOutPathController.java
@@ -106,6 +106,7 @@
                String orgId = serviceOutPath1.getOrgid();
                BaseOrganization baseOrganization = new BaseOrganization();
                baseOrganization.setOrgid(orgId);
                baseOrganization.setCampusid(orgId);
                List<BaseOrganization> orgs = baseOrganizationService.selectBaseOrganizationList(baseOrganization);
                if(CollectionUtils.isNotEmpty(orgs)){
                    String orgname = orgs.get(0).getOrganizationName();
ruoyi-admin/src/main/resources/application-druid.yml
@@ -34,7 +34,7 @@
        #        password: Hxerp2000
        #        driverClassName: com.mysql.cj.jdbc.Driver
        #  公司本地
        url: jdbc:mysql://haiershi.a1.luyouxia.net:23844/smartor_lishui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&connectTimeout=120000&socketTimeout=240000
        url: jdbc:mysql://haiershi.a1.luyouxia.net:23844/smartor_shiyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&connectTimeout=120000&socketTimeout=240000
        username: smartor
        password: Smartor.2023
        driverClassName: com.mysql.cj.jdbc.Driver
@@ -46,12 +46,12 @@
      #        driverClassName: org.postgresql.Driver
      # 从库数据源
      slave:
        enabled: true
        url: jdbc:oracle:thin:@//192.200.85.40:1521/hzsyhis
        username: wssf
        password: Hzsywssf
        driver-class-name: oracle.jdbc.OracleDriver
#      slave:
#        enabled: true
#        url: jdbc:oracle:thin:@//192.200.85.40:1521/hzsyhis
#        username: wssf
#        password: Hzsywssf
#        driver-class-name: oracle.jdbc.OracleDriver
      #        enabled: true
      #        url: jdbc:mysql://192.168.100.10:3306/emr?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
      #        username: smartor
ruoyi-admin/src/main/resources/application.yml
@@ -85,7 +85,7 @@
    # 国际化资源文件路径
    basename: i18n/messages
  profiles:
    active: druid
    active: hzszlyy
  # 文件上传
  servlet:
ruoyi-message/src/main/java/com/ruoyi/message/sms/provider/hzszlyy/ShiyiSmsApi.java
@@ -48,7 +48,7 @@
    /**
     * 吴山院区发送(等价 {@code smsUtils.sendSms})
     *
     * @return 网关返回的字符串,含「处理成功」表示成功
     * @return HTTP 200 时返回 {@code "true"},非 200 直接抛异常;业务是否成功由调用方判定
     */
    public String sendWushan(String phone, String content) {
        return send(phone, content, PREFIX_WUSHAN);
@@ -67,7 +67,10 @@
        XhsmsConfig cfg = properties.getSms().getXhsms();
        long timestamp = new Date().getTime();
        String sign = Md5Utils.hash(cfg.getAccount() + timestamp + Md5Utils.hash(cfg.getPwd()));
        String fullContent = prefix + content;
        // 老模板可能自带「新华医院」签名;市一网关只接受一个签名前缀,
        // 这里统一去掉,避免与【杭州市肿瘤医院】/【杭州市第一人民医院】形成双签名。
        String plainContent = content == null ? "" : content.replace("【新华医院】", "");
        String fullContent = prefix + plainContent;
        String jsonMsg = "{"
                + "\"userName\": \"" + cfg.getAccount() + "\","
                + "\"content\": \"" + fullContent + "\","
ruoyi-message/src/main/java/com/ruoyi/message/sms/provider/hzszlyy/ShiyiSmsSender.java
@@ -19,7 +19,7 @@
 * 判定依据来自 {@code RyTask} 中通过 {@code SysDept.campusid} 查到的院区编码,
 * 调用方负责把 {@code campus} 传进来;不传则保持与线上「非湖滨即吴山」一致的默认行为。
 * <p>
 * 成功判定:网关返回字符串包含「处理成功」。
 * 成功判定:HTTP 200({@link ShiyiSmsApi} 返回 {@code "true"}),或响应字符串包含「处理成功」。
 * 代码来源:{@code RyTask.hzszlyy 分支}(行为保持不变)。
 */
@Slf4j
@@ -60,7 +60,13 @@
                : shiyiSmsApi.sendWushan(request.getPhone(), request.getContent());
        log.info("【{}】市一短信发送结果({}):{}", KEY, hibin ? "湖滨" : "吴山", result);
        if (StringUtils.isNotEmpty(result) && result.contains("处理成功")) {
        // ⚠️ 这里必须与 /sms/sendTest 的成功判定保持一致:
        // ShiyiSmsApi 底层用的是 HttpUtil.postJsonRequest,HTTP 200 时固定返回 "true"
        // (非 200 会直接抛异常),并不会返回网关报文里的「处理成功」。
        // 原判断只认「处理成功」,导致 sendTest 能发、定时任务却一律判失败。
        boolean accepted = StringUtils.isNotEmpty(result)
                && ("true".equalsIgnoreCase(result) || result.contains("处理成功"));
        if (accepted) {
            return SendResult.success(KEY, MessageChannel.SMS, result).withCode(result);
        }
        return SendResult.fail(KEY, MessageChannel.SMS, "短信发送失败", result).withCode(result);
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -1711,7 +1711,7 @@
     */
    private SendResult sendSmsByActive(ServiceSubtask serviceSubtask, SendMagParam sendMagParam) {
        SmsSendRequest request = SmsSendRequest.of(sendMagParam.getPhone(), sendMagParam.getContent(), serviceSubtask.getOrgid());
        //市一区分湖滨/吴山两套短信签名
        //市一区分湖滨/吴山两套短信签名;老模板里的「新华医院」前缀由 ShiyiSmsApi 统一清理
        if ("hzszlyy".equals(active)) {
            request.setCampus(resolveShiyiCampus(serviceSubtask));
        }
ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java
@@ -852,6 +852,10 @@
     * smsSuccessInfo - visitCount = 1 && currentPreachForm = "4" && sendstate = 6
     * wechatSuccessInfo - visitCount = 1 && currentPreachForm = "5" && sendstate = 6
     * wechatInfo - visitCount = 1 && currentPreachForm = "5"
     * voiceCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的语音及之后
     * weChatCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的微信及之后
     * smsCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的短信及之后
     * manualCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的人工及之后
     * abnormalInfo - visitCount = 1 && excep = "1"
     * needFollowUpAgainInfo - visitCount > 1 && sendstate != 4
     * pendingFollowUpAgainInfo -  visitCount > 1 && sendstate = 2
ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtaskCountReq.java
@@ -286,6 +286,16 @@
    private String currentPreachform;
    /**
     * 累计发送方式编码 - 超链接统计。
     * <p>
     * 1=人工、3=语音、4=短信、5=微信。与 currentPreachform 的等值过滤不同,
     * 该条件按 service_subtask.preachform 保存的执行顺序判断:
     * 只要 current_preachform 位于该方式及其之后,就认为该方式已进入过。
     */
    @ApiModelProperty(value = "累计发送方式编码:1人工 3语音 4短信 5微信")
    private String cumulativePreachform;
    /**
     * 随访情况 - 超链接统计
     */
    @ApiModelProperty(value = "随访情况:1正常语音,2患者拒接或拒访,3面访或者接诊,4微信随访,5随访电话不正确,6被过滤,7其它")
ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtaskStatistic.java
@@ -256,6 +256,26 @@
    @Excel(name = " 首次微信 ")
    private Long weChat = 0L;
    /**
     * 累计口径:按 {@code service_subtask.preachform} 保存的执行顺序推算,
     * current_preachform 位于语音及之后即计入。与 {@link #voice} 的“当前方式=语音”口径不同。
     */
    @ApiModelProperty(value = "首次累计语音发送数")
    @Excel(name = " 首次累计语音 ")
    private Long voiceCumulative = 0L;
    @ApiModelProperty(value = "首次累计微信发送数")
    @Excel(name = " 首次累计微信 ")
    private Long weChatCumulative = 0L;
    @ApiModelProperty(value = "首次累计短信发送数")
    @Excel(name = " 首次累计短信 ")
    private Long smsCumulative = 0L;
    @ApiModelProperty(value = "首次累计人工发送数")
    @Excel(name = " 首次累计人工 ")
    private Long manualCumulative = 0L;
    @ApiModelProperty(value = "首次人工成功")
    @Excel(name = " 首次人工成功 ")
    private Long manualSuccess = 0L;
@@ -359,6 +379,24 @@
    @Excel(name = " 二次微信 ")
    private Long weChatAgain = 0L;
    /**
     * 二次随访累计口径,仅服务端内部使用。
     * <p>
     * hzszlyy 站点会把累计值回填到上面的 manualAgain/voiceAgain/smsAgain/weChatAgain,
     * 其它站点保持原“当前方式精确匹配”的口径,因此这四个字段不返回给前端。
     */
    @JsonIgnore
    private Long manualAgainCumulative = 0L;
    @JsonIgnore
    private Long voiceAgainCumulative = 0L;
    @JsonIgnore
    private Long smsAgainCumulative = 0L;
    @JsonIgnore
    private Long weChatAgainCumulative = 0L;
    @ApiModelProperty(value = "二次人工成功")
    @Excel(name = " 二次人工成功 ")
    private Long manualAgainSuccess = 0L;
ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
@@ -2672,6 +2672,8 @@
                continue;
            }
            ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList, serviceSubtaskCountReq.getFollowUpCountStyle(), serviceSubtaskCountReq.getVisitCount());
            // hzszlyy:前端不改字段,直接把累计值回填到原 manual/voice/sms/weChat 及 Again 字段
            applySiteCumulativeOverride(statistic);
            if ("taskid".equals(groupKey)) {
                applyTaskGroupInfo(statistic, serviceSubtaskList);
            }
@@ -2989,6 +2991,7 @@
                //首次出院随访
                if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
                    applyFirstFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask);
                    applyFirstCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                    //首次应随访
                    if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L)) {
                        serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
@@ -3111,6 +3114,7 @@
                }//二次出院随访
                else if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) {
                    applyAgainFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask);
                    applyAgainCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                    //再次应随访
                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                        serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
@@ -3322,6 +3326,220 @@
        return serviceSubtask.getIsManuallyCalled() != null && serviceSubtask.getIsManuallyCalled().equals(0L);
    }
    /** 发送方式编码:人工 */
    private static final String PREACHFORM_MANUAL = "1";
    /** 发送方式编码:语音 */
    private static final String PREACHFORM_VOICE = "3";
    /** 发送方式编码:短信 */
    private static final String PREACHFORM_SMS = "4";
    /** 发送方式编码:微信 */
    private static final String PREACHFORM_WECHAT = "5";
    /** 累计位图:语音 */
    private static final int CUMULATIVE_MASK_VOICE = 1;
    /** 累计位图:微信 */
    private static final int CUMULATIVE_MASK_WECHAT = 1 << 1;
    /** 累计位图:短信 */
    private static final int CUMULATIVE_MASK_SMS = 1 << 2;
    /** 累计位图:人工 */
    private static final int CUMULATIVE_MASK_MANUAL = 1 << 3;
    /** 需要把累计值回填到原字段的站点 */
    private static final String SITE_HZSZLYY = "hzszlyy";
    /**
     * 首次随访「累计发送方式」统计。
     * <p>
     * 原口径只看 current_preachform 等于某个方式:例如 current_preachform=5(微信)时,
     * 前面已经执行过的语音不再计入语音数。本方法按 service_subtask.preachform 保存的
     * 顺序推算:current_preachform 在顺序中的位置之前的发送方式,都算“累计已进入过”。
     * <p>
     * 例:preachform = 3,5,4,1(语音→微信→短信→人工):
     * <ul>
     *   <li>current=3:累计语音=1;微信/短信/人工=0</li>
     *   <li>current=5:累计语音=1、微信=1;短信/人工=0</li>
     *   <li>current=4:累计语音=1、微信=1、短信=1;人工=0</li>
     *   <li>current=1:四项都=1</li>
     * </ul>
     * 约定:current_preachform 为空时取 preachform 第一个方式;current_preachform=-1 时按
     * 最后一个位置处理;current_preachform 不在顺序中时只做精确匹配兜底,避免历史脏数据误算。
     * <p>
     * sendstate 过滤与原有 manual/voice/sms/weChat 保持一致:
     * followUpCountStyle=1 排除 sendstate=4;=3 只统计 sendstate=6;其它统计所有非空 sendstate。
     */
    private void applyFirstCumulativePreachformStatistics(ServiceSubtaskStatistic statistic,
                                                          ServiceSubtask serviceSubtask,
                                                          String followUpCountStyle) {
        if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() != 1) {
            return;
        }
        if (!isCumulativePreachformCountable(serviceSubtask, followUpCountStyle)) {
            return;
        }
        int mask = resolveCumulativePreachformMask(serviceSubtask);
        if ((mask & CUMULATIVE_MASK_VOICE) != 0) {
            statistic.setVoiceCumulative(statistic.getVoiceCumulative() + 1L);
        }
        if ((mask & CUMULATIVE_MASK_WECHAT) != 0) {
            statistic.setWeChatCumulative(statistic.getWeChatCumulative() + 1L);
        }
        if ((mask & CUMULATIVE_MASK_SMS) != 0) {
            statistic.setSmsCumulative(statistic.getSmsCumulative() + 1L);
        }
        if ((mask & CUMULATIVE_MASK_MANUAL) != 0) {
            statistic.setManualCumulative(statistic.getManualCumulative() + 1L);
        }
    }
    /**
     * 再次随访「累计发送方式」统计,口径与 {@link #applyFirstCumulativePreachformStatistics} 一致。
     */
    private void applyAgainCumulativePreachformStatistics(ServiceSubtaskStatistic statistic,
                                                          ServiceSubtask serviceSubtask,
                                                          String followUpCountStyle) {
        if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() <= 1) {
            return;
        }
        if (!isCumulativePreachformCountable(serviceSubtask, followUpCountStyle)) {
            return;
        }
        int mask = resolveCumulativePreachformMask(serviceSubtask);
        if ((mask & CUMULATIVE_MASK_VOICE) != 0) {
            statistic.setVoiceAgainCumulative(statistic.getVoiceAgainCumulative() + 1L);
        }
        if ((mask & CUMULATIVE_MASK_WECHAT) != 0) {
            statistic.setWeChatAgainCumulative(statistic.getWeChatAgainCumulative() + 1L);
        }
        if ((mask & CUMULATIVE_MASK_SMS) != 0) {
            statistic.setSmsAgainCumulative(statistic.getSmsAgainCumulative() + 1L);
        }
        if ((mask & CUMULATIVE_MASK_MANUAL) != 0) {
            statistic.setManualAgainCumulative(statistic.getManualAgainCumulative() + 1L);
        }
    }
    /**
     * 计算某条子任务“已进入过”的发送方式位图。
     * <p>
     * current_preachform 为空取第一个;= -1 视为全部遍历完;不在顺序里时退化为精确匹配。
     */
    private int resolveCumulativePreachformMask(ServiceSubtask serviceSubtask) {
        List<String> order = splitPreachformOrder(serviceSubtask.getPreachform());
        String current = StringUtils.isNotBlank(serviceSubtask.getCurrentPreachform())
                ? serviceSubtask.getCurrentPreachform().trim()
                : (order.isEmpty() ? null : order.get(0));
        if (order.isEmpty()) {
            return exactCumulativeMask(current);
        }
        int currentPosition;
        if ("-1".equals(current)) {
            currentPosition = order.size();
        } else {
            int currentIndex = order.indexOf(current);
            if (currentIndex < 0) {
                return exactCumulativeMask(current);
            }
            currentPosition = currentIndex + 1;
        }
        int mask = 0;
        if (reachedPreachform(order, PREACHFORM_VOICE, currentPosition)) {
            mask |= CUMULATIVE_MASK_VOICE;
        }
        if (reachedPreachform(order, PREACHFORM_WECHAT, currentPosition)) {
            mask |= CUMULATIVE_MASK_WECHAT;
        }
        if (reachedPreachform(order, PREACHFORM_SMS, currentPosition)) {
            mask |= CUMULATIVE_MASK_SMS;
        }
        if (reachedPreachform(order, PREACHFORM_MANUAL, currentPosition)) {
            mask |= CUMULATIVE_MASK_MANUAL;
        }
        return mask;
    }
    private int exactCumulativeMask(String current) {
        if (PREACHFORM_MANUAL.equals(current)) {
            return CUMULATIVE_MASK_MANUAL;
        }
        if (PREACHFORM_VOICE.equals(current)) {
            return CUMULATIVE_MASK_VOICE;
        }
        if (PREACHFORM_SMS.equals(current)) {
            return CUMULATIVE_MASK_SMS;
        }
        if (PREACHFORM_WECHAT.equals(current)) {
            return CUMULATIVE_MASK_WECHAT;
        }
        return 0;
    }
    private boolean isCumulativePreachformCountable(ServiceSubtask serviceSubtask, String followUpCountStyle) {
        if (serviceSubtask.getSendstate() == null) {
            return false;
        }
        if ("1".equals(followUpCountStyle)) {
            return !Long.valueOf(4L).equals(serviceSubtask.getSendstate());
        }
        if ("3".equals(followUpCountStyle)) {
            return Long.valueOf(6L).equals(serviceSubtask.getSendstate());
        }
        return true;
    }
    /**
     * 拆分 preachform 执行顺序。兼容英文逗号、中文逗号和空格,去重并保持原顺序。
     */
    private List<String> splitPreachformOrder(String preachform) {
        if (StringUtils.isEmpty(preachform)) {
            return Collections.emptyList();
        }
        return Arrays.stream(preachform.split("[,,]"))
                .map(String::trim)
                .filter(StringUtils::isNotEmpty)
                .distinct()
                .collect(Collectors.toList());
    }
    private boolean reachedPreachform(List<String> order, String preachform, int currentPosition) {
        int position = order.indexOf(preachform);
        return position >= 0 && currentPosition >= position + 1;
    }
    /**
     * hzszlyy 站点保持前端字段不变:把累计值回填到原 manual/voice/sms/weChat 及 Again 字段。
     * <p>
     * 其它站点不覆盖,继续使用原来的“当前方式精确匹配”口径。
     */
    private void applySiteCumulativeOverride(ServiceSubtaskStatistic statistic) {
        if (!SITE_HZSZLYY.equals(active)) {
            return;
        }
        statistic.setManual(nvlLong(statistic.getManualCumulative()));
        statistic.setVoice(nvlLong(statistic.getVoiceCumulative()));
        statistic.setSms(nvlLong(statistic.getSmsCumulative()));
        statistic.setWeChat(nvlLong(statistic.getWeChatCumulative()));
        statistic.setManualAgain(nvlLong(statistic.getManualAgainCumulative()));
        statistic.setVoiceAgain(nvlLong(statistic.getVoiceAgainCumulative()));
        statistic.setSmsAgain(nvlLong(statistic.getSmsAgainCumulative()));
        statistic.setWeChatAgain(nvlLong(statistic.getWeChatAgainCumulative()));
    }
    /**
     * 超链接下钻的发送方式条件。
     * <p>
     * hzszlyy 站点的前端不改字段,仍点原来的 manualInfo/voiceInfo/...,
     * 后端改用累计口径;其它站点保持 current_preachform 精确匹配。
     */
    private void applyPreachformInfoCondition(ServiceSubtaskCountReq serviceSubtaskCountReq,
                                              int visitCount,
                                              String preachform) {
        serviceSubtaskCountReq.setVisitCount(visitCount);
        if (SITE_HZSZLYY.equals(active)) {
            serviceSubtaskCountReq.setCumulativePreachform(preachform);
        } else {
            serviceSubtaskCountReq.setCurrentPreachform(preachform);
        }
    }
    /**
     * 首次随访统计
     *
@@ -3362,6 +3580,7 @@
            //首次出院随访
            if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
                applyFirstCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                //首次应随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                    serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
@@ -3536,6 +3755,7 @@
            //再次出院随访
            if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) {
                applyAgainCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                //再次应随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                    serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
@@ -3914,6 +4134,10 @@
     * voiceSuccessInfo - visitCount = 1 && currentPreachForm = "3" && sendstate = 6
     * smsSuccessInfo - visitCount = 1 && currentPreachForm = "4" && sendstate = 6
     * wechatSuccessInfo - visitCount = 1 && currentPreachForm = "5" && sendstate = 6
     * voiceCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的语音及之后
     * weChatCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的微信及之后
     * smsCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的短信及之后
     * manualCumulativeInfo - visitCount = 1 && currentPreachForm 位于 preachform 顺序中的人工及之后
     * abnormalInfo - visitCount = 1 && excep = "1"
     * needFollowUpAgainInfo - visitCount > 1 && sendstate != 4
     * pendingFollowUpAgainInfo -  visitCount > 1 && sendstate = 2
@@ -3983,6 +4207,7 @@
        serviceSubtaskCountReq.setVisitCount(null);
        serviceSubtaskCountReq.setSendstates(null);
        serviceSubtaskCountReq.setCurrentPreachform(null);
        serviceSubtaskCountReq.setCumulativePreachform(null);
        serviceSubtaskCountReq.setExcep(null);
        serviceSubtaskCountReq.setTaskSituation(null);
        serviceSubtaskCountReq.setFinishState(null);
@@ -4035,20 +4260,33 @@
                serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(5L, 7L)));
                break;
            case "manualInfo":
                serviceSubtaskCountReq.setVisitCount(1);
                serviceSubtaskCountReq.setCurrentPreachform("1");
                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_MANUAL);
                break;
            case "voiceInfo":
                serviceSubtaskCountReq.setVisitCount(1);
                serviceSubtaskCountReq.setCurrentPreachform("3");
                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_VOICE);
                break;
            case "smsInfo":
                serviceSubtaskCountReq.setVisitCount(1);
                serviceSubtaskCountReq.setCurrentPreachform("4");
                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_SMS);
                break;
            case "weChatInfo":
                applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_WECHAT);
                break;
            // 累计口径:按 preachform 的执行顺序,current_preachform 位于该方式及之后即计入
            case "voiceCumulativeInfo":
                serviceSubtaskCountReq.setVisitCount(1);
                serviceSubtaskCountReq.setCurrentPreachform("5");
                serviceSubtaskCountReq.setCumulativePreachform("3");
                break;
            case "weChatCumulativeInfo":
                serviceSubtaskCountReq.setVisitCount(1);
                serviceSubtaskCountReq.setCumulativePreachform("5");
                break;
            case "smsCumulativeInfo":
                serviceSubtaskCountReq.setVisitCount(1);
                serviceSubtaskCountReq.setCumulativePreachform("4");
                break;
            case "manualCumulativeInfo":
                serviceSubtaskCountReq.setVisitCount(1);
                serviceSubtaskCountReq.setCumulativePreachform("1");
                break;
            case "manualSuccessInfo":
                serviceSubtaskCountReq.setVisitCount(1);
@@ -4091,20 +4329,16 @@
                serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(5L, 7L)));
                break;
            case "manualAgainInfo":
                serviceSubtaskCountReq.setVisitCount(2);
                serviceSubtaskCountReq.setCurrentPreachform("1");
                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_MANUAL);
                break;
            case "voiceAgainInfo":
                serviceSubtaskCountReq.setVisitCount(2);
                serviceSubtaskCountReq.setCurrentPreachform("3");
                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_VOICE);
                break;
            case "smsAgainInfo":
                serviceSubtaskCountReq.setVisitCount(2);
                serviceSubtaskCountReq.setCurrentPreachform("4");
                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_SMS);
                break;
            case "weChatAgainInfo":
                serviceSubtaskCountReq.setVisitCount(2);
                serviceSubtaskCountReq.setCurrentPreachform("5");
                applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_WECHAT);
                break;
            case "manualAgainSuccessInfo":
                serviceSubtaskCountReq.setVisitCount(1);
@@ -4677,6 +4911,10 @@
        total.setManual(0L);
        total.setSms(0L);
        total.setWeChat(0L);
        total.setVoiceCumulative(0L);
        total.setWeChatCumulative(0L);
        total.setSmsCumulative(0L);
        total.setManualCumulative(0L);
        total.setAbnormal(0L);
        total.setNeedFollowUpAgain(0L);
        total.setPendingFollowUpAgain(0L);
@@ -4722,6 +4960,10 @@
            total.setManual(total.getManual() + (stat.getManual() != null ? stat.getManual() : 0L));
            total.setSms(total.getSms() + (stat.getSms() != null ? stat.getSms() : 0L));
            total.setWeChat(total.getWeChat() + (stat.getWeChat() != null ? stat.getWeChat() : 0L));
            total.setVoiceCumulative(total.getVoiceCumulative() + (stat.getVoiceCumulative() != null ? stat.getVoiceCumulative() : 0L));
            total.setWeChatCumulative(total.getWeChatCumulative() + (stat.getWeChatCumulative() != null ? stat.getWeChatCumulative() : 0L));
            total.setSmsCumulative(total.getSmsCumulative() + (stat.getSmsCumulative() != null ? stat.getSmsCumulative() : 0L));
            total.setManualCumulative(total.getManualCumulative() + (stat.getManualCumulative() != null ? stat.getManualCumulative() : 0L));
            total.setAbnormal(total.getAbnormal() + (stat.getAbnormal() != null ? stat.getAbnormal() : 0L));
            total.setNeedFollowUpAgain(total.getNeedFollowUpAgain() + (stat.getNeedFollowUpAgain() != null ? stat.getNeedFollowUpAgain() : 0L));
            total.setPendingFollowUpAgain(total.getPendingFollowUpAgain() + (stat.getPendingFollowUpAgain() != null ? stat.getPendingFollowUpAgain() : 0L));
ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -358,6 +358,17 @@
        COALESCE(NULLIF(TRIM(current_preachform), ''), TRIM(SUBSTRING_INDEX(preachform, ',', 1)))
    </sql>
    <!-- 累计发送方式统计用:归一化 preachform 顺序(去空格、统一中文逗号) -->
    <sql id="normalizedPreachformExpr">
        REPLACE(REPLACE(IFNULL(preachform, ''), ' ', ''), ',', ',')
    </sql>
    <!-- 累计发送方式统计用:归一化后的有效 current_preachform(为空时取 preachform 第一个) -->
    <sql id="normalizedEffectiveCurrentPreachformExpr">
        COALESCE(NULLIF(TRIM(current_preachform), ''),
                 TRIM(SUBSTRING_INDEX(<include refid="normalizedPreachformExpr"/>, ',', 1)))
    </sql>
    <select id="selectServiceSubtaskBySendstate" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity"
            resultMap="ServiceSubtaskResult">
        <include refid="selectServiceSubtaskVo"/>
@@ -2895,9 +2906,52 @@
        </if>
        <if test="currentPreachform != null and currentPreachform != '' ">
            AND <include refid="effectiveCurrentPreachformExpr"/> = #{currentPreachform}
            <if test="followUpCountStyle != null and followUpCountStyle = '1'">
            <!-- 注意:OGNL 里单引号 '1' 是 Character,String 与之用 = 比较会得到非 0 数字(恒真),必须用 =="1" -->
            <if test='followUpCountStyle != null and followUpCountStyle == "1"'>
                AND sendstate != 4
            </if>
            <if test='followUpCountStyle != null and followUpCountStyle == "3"'>
                AND sendstate = 6
            </if>
        </if>
        <!--
          累计发送方式下钻:
          preachform 是执行顺序(如 3,5,4,1),current_preachform 是当前执行到的位置。
          若要在“语音”下钻,则 current 位于语音及之后的所有行都要返回。
          以下条件与 ServiceSubtaskServiceImpl#applyFirstCumulativePreachformStatistics 口径一致:
            current 为空   -> 按 preachform 第一个方式
            current = -1   -> 按最后一个位置(全部方式都进入过)
            current 不在顺序中 -> 只做精确匹配兜底
        -->
        <if test="cumulativePreachform != null and cumulativePreachform != ''">
            AND (
                CASE
                    WHEN <include refid="normalizedPreachformExpr"/> = '' THEN
                        <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform}
                    WHEN <include refid="normalizedEffectiveCurrentPreachformExpr"/> = '-1' THEN
                        FIND_IN_SET(#{cumulativePreachform},
                            <include refid="normalizedPreachformExpr"/>) &gt; 0
                    WHEN FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>,
                            <include refid="normalizedPreachformExpr"/>) = 0 THEN
                        <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform}
                    ELSE
                        FIND_IN_SET(#{cumulativePreachform},
                            <include refid="normalizedPreachformExpr"/>) &gt; 0
                        AND FIND_IN_SET(#{cumulativePreachform},
                            <include refid="normalizedPreachformExpr"/>)
                            &lt;= FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>,
                            <include refid="normalizedPreachformExpr"/>)
                END
            )
            <if test='followUpCountStyle != null and followUpCountStyle == "1"'>
                AND sendstate != 4
            </if>
            <if test='followUpCountStyle != null and followUpCountStyle == "3"'>
                AND sendstate = 6
            </if>
        </if>
        <if test="excep != null and excep != ''">
            AND excep = #{excep}
smartor/src/main/java/com/smartor/service/impl/SvyTaskSingleServiceImpl.java
@@ -357,8 +357,8 @@
                    if(ObjectUtils.isNotEmpty(patArchive.getIdcardno())){
                        List<PatArchive> patArchives = patArchiveMapper.selectPatArchiveList(patArchive);
                        if(CollectionUtils.isNotEmpty(patArchives)){
                            String patidHis = patArchives.get(0).getPatidHis();
                            result = OkHttpExample.getUnsafe("http://192.200.81.189:9100/blj/view?BINGRENID="+ patidHis +"&YONGHUID=DBA", token);
                            String idcardno = patArchives.get(0).getIdcardno();
                            result = OkHttpExample.getUnsafe("http://192.200.81.189:9100/blj/view?SHENFENZH="+ idcardno +"&YONGHUID=DBA", token);
                        }
                    }
                }