ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
@@ -885,6 +885,39 @@
    }
    /**
     * 兼容「科室/病区」字段重命名前的旧入参。
     *
     * <p>2026-11 起:{@code deptcode/deptname} = 在院科室,{@code leaveldeptcode/leaveldeptname} = 离院科室。
     * 但前端/旧调用方({@code /serviceSubtask/addSubTask})仍可能把科室放在 {@code deptcode/deptname} 里。
     * 若不归位,子任务会落到「在院维度」,列表按离院科室筛选时查不到(本次线上 2654501/2663019 即此问题)。
     *
     * <p>规则:
     * <ul>
     *   <li>只对非延续护理({@code service_type != '99'})生效;99 允许使用在院维度;</li>
     *   <li>离院科室为空且 {@code deptcode} 有值时,把 {@code deptcode/deptname} 迁到离院维度;</li>
     *   <li>清空在院维度,避免同一份科室同时命中两组筛选(与 {@code toSubtaskFromTaskVO} 的口径一致)。</li>
     * </ul>
     */
    private void alignLeaveDeptFromLegacyDept(ServiceSubtask serviceSubtask) {
        if (serviceSubtask == null || "99".equals(serviceSubtask.getServiceType())) {
            return;
        }
        if (StringUtils.isEmpty(serviceSubtask.getLeaveldeptcode())
                && StringUtils.isNotEmpty(serviceSubtask.getDeptcode())) {
            serviceSubtask.setLeaveldeptcode(serviceSubtask.getDeptcode());
        }
        if (StringUtils.isEmpty(serviceSubtask.getLeaveldeptname())
                && StringUtils.isNotEmpty(serviceSubtask.getDeptname())) {
            serviceSubtask.setLeaveldeptname(serviceSubtask.getDeptname());
        }
        // 手工新增入口没有「在院维度」的可靠来源;任务配置里的科室不是患者本人的在院科室。
        serviceSubtask.setDeptcode(null);
        serviceSubtask.setDeptname(null);
        serviceSubtask.setHospitaldistrictcode(null);
        serviceSubtask.setHospitaldistrictname(null);
    }
    /**
     * 新增单一任务(随访)
     *
     * @param serviceSubtask 单一任务(随访)
@@ -892,6 +925,8 @@
     */
    @Override
    public Map<String, Object> insertServiceSubtask(ServiceSubtask serviceSubtask) {
        // 兼容 2026-11 字段重命名前的旧入参:/addSubTask 仍可能把科室放在 deptcode/deptname 里
        alignLeaveDeptFromLegacyDept(serviceSubtask);
        List<ServiceSubtask> serviceSubtasks = null;
        //先查询一下该患者是否已经创建根据serviceType,sendstate,inhospid,patid,orgid
        //这样判断主要是为了想让新华医院的外部导入患者创建任务,也能用这个接口
@@ -913,7 +948,7 @@
            serviceOutPath.setSubId(serviceSubtask1.getId());
            List<ServiceOutPath> serviceOutPaths = serviceOutPathMapper.selectServiceOutPathList(serviceOutPath);
            if (CollectionUtils.isNotEmpty(serviceOutPaths))
                format = String.format("%03X", serviceOutPaths.get(0).getId());
                format = ShortCode.encode(serviceOutPaths.get(0).getId());
            else format = getOutPath(serviceSubtask1, rsaPublicKeyExample);
            serviceSubtask = serviceSubtask1;
        } else {
@@ -965,7 +1000,7 @@
        serviceOutPath.setSubId(serviceSubtask.getId());
        iServiceOutPathService.insertServiceOutPath(serviceOutPath);
        //转成16进制
        format = String.format("%03X", serviceOutPath.getId());
        format = ShortCode.encode(serviceOutPath.getId());
        serviceOutPath.setRadix(format);
        serviceOutPath.setUpdateTime(new Date());
        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
@@ -1599,6 +1634,61 @@
    }
    /**
     * 取逗号串里的第一个值(任务上科室/病区是多选,而 {@code service_subtask} 上都是单值列)。
     */
    private String firstValue(String value) {
        if (StringUtils.isEmpty(value)) {
            return null;
        }
        for (String item : value.split(",")) {
            if (StringUtils.isNotEmpty(item.trim())) {
                return item.trim();
            }
        }
        return null;
    }
    /**
     * 任务配置({@link ServiceTaskVO})→ 子任务({@link ServiceSubtask})的字段搬运。
     * <p>
     * <b>为什么不能直接 {@code DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class)}:</b>
     * 它是纯同名拷贝,而两边同名的 {@code deptcode / deptname} <b>语义不同</b>:
     * <ul>
     *   <li>{@code ServiceTaskVO.deptcode / deptname} = 任务的「适用科室」,
     *       出院随访(serviceType=2)/ 出院宣教(4)/ 门诊随访(3)等场景下就是<b>离院科室</b>;</li>
     *   <li>{@code ServiceSubtask.deptcode / deptname} = <b>在院科室</b>
     *       (2026-11 由原 sendlimitpbegin/pend 复用而来,见 {@code ServiceSubtask} 字段注释)。</li>
     * </ul>
     * 于是纯同名拷贝会把「离院科室」写进「在院科室」列,后果有两个:
     * <ol>
     *   <li>按在院维度筛({@code deptcodes} → {@code service_subtask.deptcode})会误命中这些子任务;</li>
     *   <li>按离院维度筛({@code leaveldeptcodes} → {@code service_subtask.leaveldeptcode})时,
     *       患者自己没带科室的那些(前端手动勾选患者很常见)会因为 {@code leaveldeptcode} 为空而查不到。</li>
     * </ol>
     * 因此这里按项目既定口径({@code doc/service_subtask_字段改名_改动清单.md} §8:这几条
     * 「长期任务 / 任务组 / 手动建任务」路径<b>不填在院维度</b>)统一处理:
     * <b>在院维度 4 列清空</b>(在院科室/在院病区只有 HIS 链路能从 {@code pat_med_inhosp} 拿到),
     * <b>科室 / 病区一律落离院维度</b>({@code leaveldeptcode/name}、{@code leavehospitaldistrictcode/name})。
     *
     * @param serviceTaskVO 建任务入参
     * @return 已按离院维度归位的子任务对象(在院维度为空)
     */
    private ServiceSubtask toSubtaskFromTaskVO(ServiceTaskVO serviceTaskVO) {
        ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class);
        // ① 在院维度必须清空:任务配置的科室不是患者本人的在院科室
        serviceSubtask.setDeptcode(null);
        serviceSubtask.setDeptname(null);
        serviceSubtask.setHospitaldistrictcode(null);
        serviceSubtask.setHospitaldistrictname(null);
        // ② 科室 / 病区 → 离院维度(多选串取第一个,子任务是单值列)
        serviceSubtask.setLeaveldeptcode(firstValue(serviceTaskVO.getDeptcode()));
        serviceSubtask.setLeaveldeptname(firstValue(serviceTaskVO.getDeptname()));
        serviceSubtask.setLeavehospitaldistrictcode(firstValue(serviceTaskVO.getLeavehospitaldistrictcode()));
        serviceSubtask.setLeavehospitaldistrictname(firstValue(serviceTaskVO.getLeavehospitaldistrictname()));
        return serviceSubtask;
    }
    /**
     * 单一任务
     *
     * @return 结果
@@ -1815,6 +1905,25 @@
                            serviceTaskdeptService.insertServiceTaskdept(serviceTaskdept);
                        }
                    }
                    // 点位行(2026-11,appltype=7):科室 / 病区 / 点位在 service_taskdept 里是
                    // **各自独立的行**,可以共存也可以不共存 —— 所以点位行是"额外追加",
                    // 不替换上面的科室/病区行。点位行的 dept_code/dept_name 留空,编码只落 point_location。
                    if ("7".equals(serviceTaskVO.getAppltype())) {
                        String pointLocation = firstNonBlank(serviceTaskVO.getPointLocation(),
                                serviceTask.getPointLocation());
                        if (StringUtils.isNotEmpty(pointLocation)) {
                            ServiceTaskdept pointDept = new ServiceTaskdept();
                            pointDept.setTaskId(serviceTask.getTaskid());
                            pointDept.setTaskName(serviceTask.getTaskName());
                            pointDept.setOrgid(serviceTask.getOrgid());
                            pointDept.setLongtask(serviceTask.getLongTask() == null ? null
                                    : Long.valueOf(serviceTask.getLongTask()));
                            pointDept.setServiceType(serviceTaskVO.getServiceType());
                            pointDept.setDeptType("3");
                            pointDept.setPointLocation(pointLocation);
                            serviceTaskdeptService.insertServiceTaskdept(pointDept);
                        }
                    }
                }
            }
//长期任务,也允许加人了
@@ -1825,7 +1934,8 @@
//            }
            //将任务信息放到服务表中
            ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class);
            // 科室/病区按「离院维度」归位(出院随访的科室病区就是离院科室/病区),见 toSubtaskFromTaskVO
            ServiceSubtask serviceSubtask = toSubtaskFromTaskVO(serviceTaskVO);
            serviceSubtask.setTaskid(serviceTask.getTaskid().longValue());
            serviceSubtask.setTemplatename(ObjectUtils.isNotEmpty(tempid) ? tempName : serviceTask.getTemplatename());
            serviceSubtask.setTemplateid(ObjectUtils.isNotEmpty(tempid) ? tempid : serviceTask.getTemplateid());
@@ -1846,15 +1956,18 @@
                    serviceSubtask.setInhospid(patTaskRelevance.getHospid());
                    //新建完成就是待发送状态
                    serviceSubtask.setSendstate(2L);
                    String subtaskDeptCode = patTaskRelevance.getDeptcode();
                    if (StringUtils.isEmpty(subtaskDeptCode) && StringUtils.isNotEmpty(serviceTaskVO.getDeptcode())) {
                        // service_subtask.leaveldeptcode 为单值字段,不能写入任务的多科室拼接串,取第一个科室兜底
                        subtaskDeptCode = serviceTaskVO.getDeptcode().split(",")[0].trim();
                    }
                    serviceSubtask.setLeaveldeptcode(subtaskDeptCode);
                    serviceSubtask.setLeaveldeptname(StringUtils.isNotEmpty(patTaskRelevance.getDeptName()) ? patTaskRelevance.getDeptName() : serviceTaskVO.getDeptname());
                    serviceSubtask.setLeavehospitaldistrictcode(patTaskRelevance.getLeavehospitaldistrictcode());
                    serviceSubtask.setLeavehospitaldistrictname(patTaskRelevance.getLeavehospitaldistrictname());
                    // 离院维度(出院随访 = 出院科室 / 出院病区):
                    // 患者自带的出院科室/病区优先,患者侧没带(前端手动勾选很常见)时回退到任务配置,
                    // 不能无条件覆盖 —— 否则会把 toSubtaskFromTaskVO 按任务配置兜好的离院维度抹成 null,
                    // 结果「任务配了科室病区、生成出来的子任务离院科室/病区却是空」。
                    serviceSubtask.setLeaveldeptcode(firstNonBlank(patTaskRelevance.getDeptcode(),
                            firstValue(serviceTaskVO.getDeptcode())));
                    serviceSubtask.setLeaveldeptname(firstNonBlank(patTaskRelevance.getDeptName(),
                            firstValue(serviceTaskVO.getDeptname())));
                    serviceSubtask.setLeavehospitaldistrictcode(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictcode(),
                            firstValue(serviceTaskVO.getLeavehospitaldistrictcode())));
                    serviceSubtask.setLeavehospitaldistrictname(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictname(),
                            firstValue(serviceTaskVO.getLeavehospitaldistrictname())));
                    serviceSubtask.setType(serviceTaskVO.getType());
                    serviceSubtask.setHospType(patTaskRelevance.getHospType());
                    serviceSubtask.setOpenid(patTaskRelevance.getOpenid());
@@ -2190,6 +2303,27 @@
                    scheduleVO.setOplevelCodes(serviceTaskVO.getOplevelcode());
                    scheduleVO.setCreateBy(serviceTask.getUpdateBy());
                    serviceTaskScheduleService.saveScheduleWithDetail(scheduleVO);
                } else if (serviceTaskVO.getAppltype().equals("7")) {
                    // 按点位(同德需求):先软删该任务旧的 dept_type='3' 行,再按入参重建
                    //   (与科室/病区「先删后插」同口径;点位行 dept_code/dept_name 留空)
                    ServiceTaskdept oldPoint = new ServiceTaskdept();
                    oldPoint.setTaskId(serviceTask.getTaskid());
                    oldPoint.setDeptType("3");
                    serviceTaskdeptService.deleteServiceTaskdeptByTaskId(oldPoint);
                    String pointLocation = StringUtils.isNotEmpty(serviceTaskVO.getPointLocation())
                            ? serviceTaskVO.getPointLocation() : serviceTask.getPointLocation();
                    if (StringUtils.isNotEmpty(pointLocation)) {
                        ServiceTaskdept pointDept = new ServiceTaskdept();
                        pointDept.setTaskId(serviceTask.getTaskid());
                        pointDept.setTaskName(serviceTask.getTaskName());
                        pointDept.setOrgid(serviceTaskVO.getOrgid());
                        pointDept.setLongtask(serviceTask.getLongTask() == null ? null
                                : Long.valueOf(serviceTask.getLongTask()));
                        pointDept.setServiceType(serviceTaskVO.getServiceType());
                        pointDept.setDeptType("3");
                        pointDept.setPointLocation(pointLocation);
                        serviceTaskdeptService.insertServiceTaskdept(pointDept);
                    }
                }
            }
            if (ObjectUtils.isNotEmpty(serviceTaskVO.getIvrTaskTemplateVO())) {
@@ -2212,7 +2346,8 @@
            }
            if (CollectionUtils.isNotEmpty(serviceTaskVO.getPatTaskRelevances())) {
                for (PatTaskRelevance patTaskRelevance : serviceTaskVO.getPatTaskRelevances()) {
                    ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class);
                    // 科室/病区按「离院维度」归位(出院随访的科室病区就是离院科室/病区),见 toSubtaskFromTaskVO
                    ServiceSubtask serviceSubtask = toSubtaskFromTaskVO(serviceTaskVO);
                    serviceSubtask.setLibtemplateid(ObjectUtils.isEmpty(serviceTaskVO.getLibtemplateid()) ? null : Long.valueOf(serviceTaskVO.getLibtemplateid()));
                    serviceSubtask.setLibtemplatename(serviceTaskVO.getLibtemplatename());
                    serviceSubtask.setTemplateid(serviceTask.getTemplateid());
@@ -2224,10 +2359,16 @@
                    serviceSubtask.setAddr(patTaskRelevance.getAddr());
                    serviceSubtask.setPatid(patTaskRelevance.getPatid());
                    serviceSubtask.setOpenid(patTaskRelevance.getOpenid());
                    serviceSubtask.setLeaveldeptcode(patTaskRelevance.getDeptcode());
                    serviceSubtask.setLeavehospitaldistrictname(patTaskRelevance.getLeavehospitaldistrictname());
                    serviceSubtask.setLeavehospitaldistrictcode(patTaskRelevance.getLeavehospitaldistrictcode());
                    serviceSubtask.setLeaveldeptname(patTaskRelevance.getDeptName());
                    // 离院维度:患者自带的出院科室/病区优先,没带时回退到任务配置(否则会把
                    // toSubtaskFromTaskVO 按任务配置兜好的值抹成 null,出院随访就成「离院科室/病区为空」)
                    serviceSubtask.setLeaveldeptcode(firstNonBlank(patTaskRelevance.getDeptcode(),
                            firstValue(serviceTaskVO.getDeptcode())));
                    serviceSubtask.setLeaveldeptname(firstNonBlank(patTaskRelevance.getDeptName(),
                            firstValue(serviceTaskVO.getDeptname())));
                    serviceSubtask.setLeavehospitaldistrictcode(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictcode(),
                            firstValue(serviceTaskVO.getLeavehospitaldistrictcode())));
                    serviceSubtask.setLeavehospitaldistrictname(firstNonBlank(patTaskRelevance.getLeavehospitaldistrictname(),
                            firstValue(serviceTaskVO.getLeavehospitaldistrictname())));
                    serviceSubtask.setType(serviceTaskVO.getType());
                    serviceSubtask.setCreateTime(DateUtils.getNowDate());
                    serviceSubtask.setDrname(patTaskRelevance.getDrname());
@@ -2459,7 +2600,10 @@
            if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
                groupKey = drcode;
            } else {
                groupKey = "deptcode";
                // 2026-11 字段重命名后:deptcode 是在院科室(历史数据为空),
                // 出院科室已改名为 leaveldeptcode,分组必须用后者,
                // 否则 getSfStatisticsGroupKey 会返回 NULL,拼成 IN (NULL) 导致整表查空。
                groupKey = "leaveldeptcode";
            }
        } else if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 3) {
            // 病种统计:按任务ID分组,每个任务即一个病种随访任务
@@ -2470,6 +2614,17 @@
        Map<String, List<ServiceSubtask>> collect = new HashMap<>();
        serviceSubtaskCountReq.setGroupKey(groupKey);
        List<String> groupKeyList = serviceSubtaskMapper.getSfStatisticsGroupKey(serviceSubtaskCountReq);
        /*
         * 分组键可能为 NULL(历史数据、或重命名后尚未回填的在院维度列),
         * 直接拼进 SQL 会变成 `AND IFNULL(列,'Unknown') IN (NULL)`,恒不成立,整张统计表为空。
         * 这里统一成 'Unknown',与聚合 SQL 的 IFNULL(列,'Unknown') 口径对齐。
         */
        if (groupKeyList != null) {
            groupKeyList = groupKeyList.stream()
                    .map(key -> key == null ? "Unknown" : key)
                    .distinct()
                    .collect(Collectors.toList());
        }
        serviceSubtaskCountReq.setGroupKeyList(groupKeyList);
        List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq);
        switch (groupKey) {
@@ -2484,6 +2639,7 @@
                collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getManagementDoctorCode()).orElse("Unknown")));
                break;
            case "deptcode":
            case "leaveldeptcode":
                collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeaveldeptcode()).orElse("Unknown")));
                break;
            case "leavehospitaldistrictcode":
@@ -2504,6 +2660,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);
            }
@@ -2802,6 +2960,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);
@@ -2924,6 +3083,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);
@@ -3100,7 +3260,7 @@
    }
    /**
     * 再次随访附加统计:待随访、已发送、人工电话超时及回院复诊复查(suggest=6)。
     * 再次随访附加统计:待随访、已发送、人工电话超时及回院复诊复查(suggest=7)。
     */
    private void applyAgainFollowUpExtraStatistics(ServiceSubtaskStatistic statistic, ServiceSubtask serviceSubtask) {
        if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() <= 1) {
@@ -3110,9 +3270,9 @@
            return;
        }
        Long sendstate = serviceSubtask.getSendstate();
        // 回院复诊复查:再次随访中按处理意见 suggest=6 统计
        if (StringUtils.equals("6", StringUtils.trim(serviceSubtask.getSuggest()))) {
            statistic.setSuggest6CountAgain(statistic.getSuggest6CountAgain() + 1L);
        // 回院复诊复查:再次随访中按处理意见 suggest=7 统计
        if (StringUtils.equals("7", StringUtils.trim(serviceSubtask.getSuggest()))) {
            statistic.setSuggest7CountAgain(statistic.getSuggest7CountAgain() + 1L);
        }
        if (sendstate.equals(3L)) {
            statistic.setSentAgain(statistic.getSentAgain() + 1L);
@@ -3133,6 +3293,220 @@
    private boolean isManuallyNotCalled(ServiceSubtask serviceSubtask) {
        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);
        }
    }
    /**
@@ -3175,6 +3549,7 @@
            //首次出院随访
            if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
                applyFirstCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                //首次应随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                    serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
@@ -3349,6 +3724,7 @@
            //再次出院随访
            if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) {
                applyAgainCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
                //再次应随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                    serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
@@ -3727,6 +4103,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
@@ -3758,7 +4138,7 @@
     * pendingFollowUpSentAgainInfo - visitCount > 1 && sendstate in (3,7)
     * sentInfo - visitCount = 1 && sendstate = 3
     * sentAgainInfo - visitCount > 1 && sendstate = 3
     * suggest6CountAgainInfo - visitCount > 1 && suggest = 6
     * suggest7CountAgainInfo - visitCount > 1 && suggest = 7
     * filterCountList - taskSituation = 6 && sendstate = 4
     *
     */
@@ -3796,6 +4176,7 @@
        serviceSubtaskCountReq.setVisitCount(null);
        serviceSubtaskCountReq.setSendstates(null);
        serviceSubtaskCountReq.setCurrentPreachform(null);
        serviceSubtaskCountReq.setCumulativePreachform(null);
        serviceSubtaskCountReq.setExcep(null);
        serviceSubtaskCountReq.setTaskSituation(null);
        serviceSubtaskCountReq.setFinishState(null);
@@ -3848,20 +4229,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);
@@ -3904,20 +4298,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);
@@ -3943,10 +4333,10 @@
                serviceSubtaskCountReq.setVisitCount(2);
                serviceSubtaskCountReq.setExcep("1");
                break;
            case "suggest6CountAgainInfo":
                // 再次随访回院复诊复查:visitCount > 1 且 suggest = 6
            case "suggest7CountAgainInfo":
                // 再次随访回院复诊复查:visitCount > 1 且 suggest = 7
                serviceSubtaskCountReq.setVisitCount(2);
                serviceSubtaskCountReq.setSuggest("6");
                serviceSubtaskCountReq.setSuggest("7");
                break;
            case "taskSituation1Info":
                serviceSubtaskCountReq.setTaskSituation(1);
@@ -4490,6 +4880,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);
@@ -4505,7 +4899,7 @@
        total.setSentAgain(0L);
        total.setFollowUpSuccessAgain(0L);
        total.setFollowUpFailAgain(0L);
        total.setSuggest6CountAgain(0L);
        total.setSuggest7CountAgain(0L);
        total.setManualAgain(0L);
        total.setSmsAgain(0L);
        total.setWeChatAgain(0L);
@@ -4535,6 +4929,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));
@@ -4550,7 +4948,7 @@
            total.setSentAgain(total.getSentAgain() + (stat.getSentAgain() != null ? stat.getSentAgain() : 0L));
            total.setFollowUpSuccessAgain(total.getFollowUpSuccessAgain() + (stat.getFollowUpSuccessAgain() != null ? stat.getFollowUpSuccessAgain() : 0L));
            total.setFollowUpFailAgain(total.getFollowUpFailAgain() + (stat.getFollowUpFailAgain() != null ? stat.getFollowUpFailAgain() : 0L));
            total.setSuggest6CountAgain(total.getSuggest6CountAgain() + (stat.getSuggest6CountAgain() != null ? stat.getSuggest6CountAgain() : 0L));
            total.setSuggest7CountAgain(total.getSuggest7CountAgain() + (stat.getSuggest7CountAgain() != null ? stat.getSuggest7CountAgain() : 0L));
            total.setManualAgain(total.getManualAgain() + (stat.getManualAgain() != null ? stat.getManualAgain() : 0L));
            total.setSmsAgain(total.getSmsAgain() + (stat.getSmsAgain() != null ? stat.getSmsAgain() : 0L));
            total.setWeChatAgain(total.getWeChatAgain() + (stat.getWeChatAgain() != null ? stat.getWeChatAgain() : 0L));
@@ -5128,7 +5526,7 @@
        serviceOutPath.setCreateTime(new Date());
        serviceOutPath.setOrgid(serviceSubtask.getOrgid());
        iServiceOutPathService.insertServiceOutPath(serviceOutPath);
        String format = String.format("%03X", serviceOutPath.getId());
        String format = ShortCode.encode(serviceOutPath.getId());
        String url = "";
        SendMagParam sendMagParam = new SendMagParam();
        sendMagParam.setType("4");
@@ -5212,7 +5610,7 @@
            serviceOutPath.setCreateTime(new Date());
            serviceOutPath.setOrgid(serviceSubtask.getOrgid());
            iServiceOutPathService.insertServiceOutPath(serviceOutPath);
            String format = String.format("%03X", serviceOutPath.getId());
            String format = ShortCode.encode(serviceOutPath.getId());
            serviceOutPath.setRadix(format);
            serviceOutPath.setUpdateTime(new Date());
            serviceOutPath.setUrl(url);
@@ -5390,16 +5788,46 @@
        String ip = localIP;
        ServiceTask serviceTask = new ServiceTask();
        serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceTaskVo.getTaskid());
        if (ObjectUtils.isEmpty(serviceTask)) {
            // 任务不存在 → 不可能有 data,直接抛业务异常(接口层会转成 code=500)
            throw new BaseException("扫码生成任务失败:任务不存在或已删除(taskid=" + serviceTaskVo.getTaskid() + ")");
        }
        if (ObjectUtils.isNotEmpty(serviceTask)) {
            try {
                ServiceTaskdept serviceTaskdept = new ServiceTaskdept();
                if (ObjectUtils.isNotEmpty(serviceTaskVo.getDeptcode())) {
                    serviceTaskdept.setDeptType("1");
                    serviceTaskdept.setDeptCode(serviceTaskVo.getDeptcode());
                }
                if (ObjectUtils.isNotEmpty(serviceTaskVo.getLeavehospitaldistrictcode())) {
                // 维度(科室/病区/点位)由任务的 appltype 决定:1=科室、2=病区、7=点位。
                //   三种维度在 service_taskdept 里是**各自独立的行**(各自的列),可以共存、也可以不共存;
                //   但查行时必须只带一个维度 —— 否则会用 A 维度的编码去撞 B 维度的行,
                //   而点位行的 dept_code 本来就是空的。
                String appltype = serviceTask.getAppltype();
                if ("7".equals(appltype)) {
                    serviceTaskdept.setDeptType("3");
                    serviceTaskdept.setPointLocation(firstNonBlank(serviceTaskVo.getPointLocation(),
                            serviceTask.getPointLocation()));
                } else if ("2".equals(appltype)) {
                    serviceTaskdept.setDeptType("2");
                    serviceTaskdept.setDeptCode(serviceTaskVo.getLeavehospitaldistrictcode());
                    // 任务上的科室/病区可能是逗号多选,查 service_taskdept 要用单值(取第一个)
                    serviceTaskdept.setDeptCode(firstNonBlank(serviceTaskVo.getLeavehospitaldistrictcode(),
                            firstValue(serviceTask.getLeavehospitaldistrictcode())));
                } else if ("1".equals(appltype)) {
                    serviceTaskdept.setDeptType("1");
                    serviceTaskdept.setDeptCode(firstNonBlank(serviceTaskVo.getDeptcode(),
                            firstValue(serviceTask.getDeptcode())));
                } else {
                    // appltype 为空的历史任务:沿用改造前的口径(科室 → 病区,后写的覆盖先写的),
                    // 点位作为第三维,只在传了点位时补上。
                    if (ObjectUtils.isNotEmpty(serviceTaskVo.getDeptcode())) {
                        serviceTaskdept.setDeptType("1");
                        serviceTaskdept.setDeptCode(serviceTaskVo.getDeptcode());
                    }
                    if (ObjectUtils.isNotEmpty(serviceTaskVo.getLeavehospitaldistrictcode())) {
                        serviceTaskdept.setDeptType("2");
                        serviceTaskdept.setDeptCode(serviceTaskVo.getLeavehospitaldistrictcode());
                    }
                    if (ObjectUtils.isNotEmpty(serviceTaskVo.getPointLocation())) {
                        serviceTaskdept.setDeptType("3");
                        serviceTaskdept.setPointLocation(serviceTaskVo.getPointLocation());
                    }
                }
                serviceTaskdept.setServiceType(serviceTask.getServiceType());
                serviceTaskdept.setOrgid(serviceTask.getOrgid());
@@ -5427,7 +5855,7 @@
                        serviceOutPath.setCreateTime(new Date());
                        serviceOutPath.setOrgid(serviceTask.getOrgid());
                        iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                        String format = String.format("%03X", serviceOutPath.getId());
                        String format = ShortCode.encode(serviceOutPath.getId());
                        serviceOutPath.setRadix(format);
                        serviceOutPath.setUpdateTime(new Date());
                        String url = StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format;
@@ -5436,10 +5864,21 @@
                        iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                    }
                } else {
                    // 配置缺失属「业务可预期」情况:带上排查信息抛出去(不吞),
                    // 接口层据此返回 code=500 + 明确 msg,避免「200 + 空 data」。
                    throw new BaseException("扫码生成任务失败:未匹配到任务维度配置(taskid=" + serviceTaskVo.getTaskid()
                            + ",appltype=" + appltype
                            + ",deptType=" + serviceTaskdept.getDeptType()
                            + ",deptCode=" + serviceTaskdept.getDeptCode()
                            + ",pointLocation=" + serviceTaskdept.getPointLocation() + ")");
                }
            } catch (BaseException be) {
                // ⚠️ 必须排在 catch (Exception) 之前:BaseException 是 RuntimeException,
                //    否则刚抛出的业务异常会被下面整段吞掉,接口又变成 200 + 空 data。
                throw be;
            } catch (Exception e) {
                e.printStackTrace();
                log.error("【扫码生成任务】处理异常:{}", e.getMessage());
                log.error("【扫码生成任务】处理异常:taskid={},{}", serviceTaskVo.getTaskid(), e.getMessage(), e);
            }
        }
        return content;
@@ -5457,6 +5896,9 @@
        if (StringUtils.isNotEmpty(serviceTaskdept.getDeptType()) && serviceTaskdept.getDeptType().equals("1")) {
            serviceSubtask.setLeaveldeptcode(serviceTaskdept.getDeptCode());
            serviceSubtask.setLeaveldeptname(serviceTaskdept.getDeptName());
        } else if (StringUtils.isNotEmpty(serviceTaskdept.getDeptType()) && serviceTaskdept.getDeptType().equals("3")) {
            // 点位行(dept_type='3'):dept_code/dept_name 为空,点位只落 point_location
            serviceSubtask.setPointLocation(serviceTaskdept.getPointLocation());
        } else {
            serviceSubtask.setLeavehospitaldistrictcode(serviceTaskdept.getDeptCode());
            serviceSubtask.setLeavehospitaldistrictname(serviceTaskdept.getDeptName());