陈昶聿
3 天以前 3acf9415fce2dd21c0fd5d67805b72a8bde24a81
【丽水】妇幼随访发送
已修改19个文件
641 ■■■■■ 文件已修改
.gitignore 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/common/MchFollowupConstants.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/IPatChildArchiveService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/IPatMaternityArchiveService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -38,6 +38,8 @@
!/sql/ry_20220822.sql
!/sql/pat_specific_archive_generate_config_lishui_mch_20261104.sql
!/sql/mch_followup_plan_20261117.sql
!/sql/pat_mch_archive_followup_status_20261123.sql
!/sql/mch_followup_plan_item_add_followup_fields_20261123.sql
sql/_probe/
*.log
_dbcheck.txt
smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
@@ -14,6 +14,21 @@
    /** 档案类型:儿保 */
    public static final String ARCHIVE_TYPE_CHILD = "2";
    /**
     * 档案随访状态:待确认。
     *
     * <p>门诊接诊完成/住院随访完成自动建档时写入,表示档案尚未经过人工确认,
     * 不生成随访计划,也不会发送消息。</p>
     */
    public static final String FOLLOWUP_STATUS_PENDING = "0";
    /**
     * 档案随访状态:随访中。
     *
     * <p>人工保存/确认档案后写入,允许按 plannedFollowTime + followupPeriod 生成计划。</p>
     */
    public static final String FOLLOWUP_STATUS_ACTIVE = "1";
    /** 计划状态:有效 */
    public static final String PLAN_STATUS_ACTIVE = "0";
@@ -47,6 +62,21 @@
    /** 节点状态:跳过(手机号为空等) */
    public static final String ITEM_STATUS_SKIPPED = "6";
    /** 节点随访状态:未随访 */
    public static final String ITEM_FOLLOWUP_STATUS_PENDING = "0";
    /** 节点随访状态:已随访 */
    public static final String ITEM_FOLLOWUP_STATUS_DONE = "1";
    /** 节点随访状态:失访 */
    public static final String ITEM_FOLLOWUP_STATUS_LOST = "2";
    /** 节点随访状态:拒访 */
    public static final String ITEM_FOLLOWUP_STATUS_REFUSED = "3";
    /** 节点随访状态:号码错误 */
    public static final String ITEM_FOLLOWUP_STATUS_BAD_NUMBER = "4";
    /** 发送方式:短信 */
    public static final String SEND_TYPE_SMS = "sms";
smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
@@ -1,5 +1,6 @@
package com.smartor.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -54,6 +55,22 @@
    @ApiModelProperty(value = "实际发送时间")
    private Date sendTimeActual;
    @ApiModelProperty(value = "随访日期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date followupDate;
    @ApiModelProperty(value = "随访人员ID")
    private String followupUserId;
    @ApiModelProperty(value = "随访人员姓名")
    private String followupUserName;
    @ApiModelProperty(value = "随访情况")
    private String followupSituation;
    @ApiModelProperty(value = "随访状态:0未随访 1已随访 2失访 3拒访 4号码错误")
    private String followupStatus;
    @ApiModelProperty(value = "结果说明")
    private String resultMsg;
smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java
@@ -260,6 +260,22 @@
    @ApiModelProperty(value = "结案状态")
    private String closeStatus;
    /** 随访状态:0待确认 1随访中 */
    @Excel(name = "随访状态")
    @ApiModelProperty(value = "随访状态:0待确认 1随访中")
    private String followupStatus;
    /** 随访确认时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "随访确认时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "随访确认时间")
    private Date followupConfirmTime;
    /** 随访确认人 */
    @Excel(name = "随访确认人")
    @ApiModelProperty(value = "随访确认人")
    private String followupConfirmBy;
    /** 出生孕周 */
    @Excel(name = "出生孕周")
    @ApiModelProperty(value = "出生孕周")
smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java
@@ -182,6 +182,22 @@
    @ApiModelProperty(value = "结案状态")
    private String closeStatus;
    /** 随访状态:0待确认 1随访中 */
    @Excel(name = "随访状态")
    @ApiModelProperty(value = "随访状态:0待确认 1随访中")
    private String followupStatus;
    /** 随访确认时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "随访确认时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "随访确认时间")
    private Date followupConfirmTime;
    /** 随访确认人 */
    @Excel(name = "随访确认人")
    @ApiModelProperty(value = "随访确认人")
    private String followupConfirmBy;
    /** 是否建册 0-否 1-是 */
    @Excel(name = "是否建册")
    @ApiModelProperty(value = "是否建册 0-否 1-是")
smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
@@ -1,6 +1,8 @@
package com.smartor.mapper;
import com.smartor.domain.MchFollowupPlanItem;
import com.smartor.domain.MchFollowupTaskQuery;
import com.smartor.domain.MchFollowupTaskVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -19,6 +21,11 @@
    int updateSendResult(MchFollowupPlanItem item);
    /**
     * 回填人工随访结果:随访日期、随访人员、随访情况、随访状态。
     */
    int updateFollowupResult(MchFollowupPlanItem item);
    MchFollowupPlanItem selectMchFollowupPlanItemById(@Param("id") Long id);
    List<MchFollowupPlanItem> selectByPlanId(@Param("planId") Long planId);
@@ -35,4 +42,9 @@
    int cancelPendingByPlanId(@Param("planId") Long planId, @Param("now") Date now);
    int countPendingByPlanId(@Param("planId") Long planId);
    /**
     * 妇幼随访任务列表:join 计划、档案详情、门诊记录。
     */
    List<MchFollowupTaskVO> selectTaskList(MchFollowupTaskQuery query);
}
smartor/src/main/java/com/smartor/service/IPatChildArchiveService.java
@@ -27,5 +27,18 @@
    public int deletePatChildArchiveById(Long id);
    /**
     * 人工保存/确认档案。保存成功后档案进入“随访中”,并按随访周期和拟随访时间生成计划。
     */
    public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail);
    /**
     * 保存档案,并指定是否由人工确认随访。
     *
     * @param patChildArchiveDetail 档案详情
     * @param confirmFollowup       true=人工保存/确认,允许生成随访计划;
     *                              false=门诊接诊/住院随访自动建档,只建草稿,不生成计划
     */
    public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail,
                                          boolean confirmFollowup);
}
smartor/src/main/java/com/smartor/service/IPatMaternityArchiveService.java
@@ -27,5 +27,18 @@
    public int deletePatMaternityArchiveById(Long id);
    /**
     * 人工保存/确认档案。保存成功后档案进入“随访中”,并按随访周期和拟随访时间生成计划。
     */
    public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail);
    /**
     * 保存档案,并指定是否由人工确认随访。
     *
     * @param patMaternityArchiveDetail 档案详情
     * @param confirmFollowup           true=人工保存/确认,允许生成随访计划;
     *                                  false=门诊接诊/住院随访自动建档,只建草稿,不生成计划
     */
    public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail,
                                              boolean confirmFollowup);
}
smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
@@ -89,6 +89,13 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail) {
        return insertOrUpdateChildArchive(patChildArchiveDetail, true);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail,
                                          boolean confirmFollowup) {
        if (patChildArchiveDetail == null) {
            log.error("insertOrUpdateChildArchive入参为空,请检查入参");
            throw new BaseException("儿科档案入参为空,请检查入参");
@@ -113,10 +120,15 @@
        Long existArchiveId = null;
        Long existDetailId = null;
        PatChildArchiveDetail existingDetail = null;
        if (CollectionUtils.isNotEmpty(olds)) {
            existArchiveId = olds.get(0).getArchiveid();
            existDetailId = olds.get(0).getId();
            existingDetail = olds.get(0);
            existArchiveId = existingDetail.getArchiveid();
            existDetailId = existingDetail.getId();
        }
        // 人工保存/确认时进入随访中;HIS 自动建档只写待确认,不生成随访计划
        applyFollowupState(patChildArchiveDetail, existingDetail, confirmFollowup);
        // 详情没查到,再兜底按同样键查主表,避免主表重复
        if (existArchiveId == null) {
@@ -196,7 +208,8 @@
            patChildArchiveDetailService.insertPatChildArchiveDetail(patChildArchiveDetail);
        }
        // 妇幼随访计划:档案新增/修改后按 plannedFollowTime + followupPeriod 重建
        // 妇幼随访计划:只有人工确认(followup_status=1)的档案才生成/重建;
        // 自动建档为待确认,rebuildForArchive 内部会直接跳过。
        try {
            if (mchFollowupPlanService != null) {
                mchFollowupPlanService.rebuildForArchive(
@@ -208,7 +221,59 @@
                    patChildArchive.getId(), patChildArchiveDetail.getId(), e);
        }
        log.info("insertOrUpdateChildArchive处理完成,主表id:{},详情id:{}", patChildArchive.getId(), patChildArchiveDetail.getId());
        log.info("insertOrUpdateChildArchive处理完成,主表id:{},详情id:{},随访状态:{}",
                patChildArchive.getId(), patChildArchiveDetail.getId(),
                patChildArchiveDetail.getFollowupStatus());
        return patChildArchive.getId().intValue();
    }
    /**
     * 处理档案随访状态。
     *
     * <p>人工保存/确认:档案进入随访中,并记录首次确认时间/确认人;
     * HIS 自动建档:新档案进入待确认,更新时不改动已有状态,也不覆盖人工维护的
     * plannedFollowTime / followupPeriod。</p>
     */
    private void applyFollowupState(PatChildArchiveDetail detail,
                                    PatChildArchiveDetail existing,
                                    boolean confirmFollowup) {
        if (confirmFollowup) {
            boolean alreadyActive = existing != null
                    && MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())
                    && existing.getFollowupConfirmTime() != null;
            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
            if (alreadyActive) {
                // 已确认过的档案重复保存时,保留首次确认时间/确认人
                detail.setFollowupConfirmTime(null);
                detail.setFollowupConfirmBy(null);
            } else {
                detail.setFollowupConfirmTime(DateUtils.getNowDate());
                String confirmBy = detail.getUpdateBy();
                if (StringUtils.isEmpty(confirmBy)) {
                    confirmBy = detail.getCreateBy();
                }
                detail.setFollowupConfirmBy(confirmBy);
            }
            return;
        }
        // HIS 自动建档:新增只进入待确认,不生成计划
        if (existing == null) {
            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_PENDING);
            detail.setFollowupConfirmTime(null);
            detail.setFollowupConfirmBy(null);
            return;
        }
        // 更新时保持原状态,避免 HIS 重复推送把已确认档案退回待确认
        detail.setFollowupStatus(null);
        detail.setFollowupConfirmTime(null);
        detail.setFollowupConfirmBy(null);
        // 已确认/历史已生效档案的随访日期与周期由人工维护,HIS 同步不覆盖
        if (StringUtils.isEmpty(existing.getFollowupStatus())
                || MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())) {
            detail.setPlannedFollowTime(null);
            detail.setFollowupPeriod(null);
        }
    }
}
smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
@@ -94,6 +94,13 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail) {
        return insertOrUpdateMaternityArchive(patMaternityArchiveDetail, true);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail,
                                              boolean confirmFollowup) {
        if (patMaternityArchiveDetail == null) {
            log.error("insertOrUpdateMaternityArchive入参为空,请检查入参");
            throw new BaseException("妇科档案入参为空,请检查入参");
@@ -130,10 +137,15 @@
        Long existArchiveId = null;
        Long existDetailId = null;
        PatMaternityArchiveDetail existingDetail = null;
        if (CollectionUtils.isNotEmpty(olds)) {
            existArchiveId = olds.get(0).getArchiveid();
            existDetailId = olds.get(0).getId();
            existingDetail = olds.get(0);
            existArchiveId = existingDetail.getArchiveid();
            existDetailId = existingDetail.getId();
        }
        // 人工保存/确认时进入随访中;HIS 自动建档只写待确认,不生成随访计划
        applyFollowupState(patMaternityArchiveDetail, existingDetail, confirmFollowup);
        // 详情没查到,再兜底按同样键查主表,避免主表重复
        if (existArchiveId == null) {
@@ -220,7 +232,8 @@
            patMaternityArchiveDetailService.insertPatMaternityArchiveDetail(patMaternityArchiveDetail);
        }
        // 妇幼随访计划:档案新增/修改后按 plannedFollowTime + followupPeriod 重建
        // 妇幼随访计划:只有人工确认(followup_status=1)的档案才生成/重建;
        // 自动建档为待确认,rebuildForArchive 内部会直接跳过。
        try {
            if (mchFollowupPlanService != null) {
                mchFollowupPlanService.rebuildForArchive(
@@ -232,7 +245,60 @@
                    patMaternityArchive.getId(), patMaternityArchiveDetail.getId(), e);
        }
        log.info("insertOrUpdateMaternityArchive处理完成,主表id:{},详情id:{}", patMaternityArchive.getId(), patMaternityArchiveDetail.getId());
        log.info("insertOrUpdateMaternityArchive处理完成,主表id:{},详情id:{},随访状态:{}",
                patMaternityArchive.getId(), patMaternityArchiveDetail.getId(),
                patMaternityArchiveDetail.getFollowupStatus());
        return patMaternityArchive.getId().intValue();
    }
    /**
     * 处理档案随访状态。
     *
     * <p>人工保存/确认:档案进入随访中,并记录首次确认时间/确认人;
     * HIS 自动建档:新档案进入待确认,更新时不改动已有状态,也不覆盖人工维护的
     * plannedFollowTime / followupPeriod / followupCycleTimes。</p>
     */
    private void applyFollowupState(PatMaternityArchiveDetail detail,
                                    PatMaternityArchiveDetail existing,
                                    boolean confirmFollowup) {
        if (confirmFollowup) {
            boolean alreadyActive = existing != null
                    && MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())
                    && existing.getFollowupConfirmTime() != null;
            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
            if (alreadyActive) {
                // 已确认过的档案重复保存时,保留首次确认时间/确认人
                detail.setFollowupConfirmTime(null);
                detail.setFollowupConfirmBy(null);
            } else {
                detail.setFollowupConfirmTime(DateUtils.getNowDate());
                String confirmBy = detail.getUpdateBy();
                if (StringUtils.isEmpty(confirmBy)) {
                    confirmBy = detail.getCreateBy();
                }
                detail.setFollowupConfirmBy(confirmBy);
            }
            return;
        }
        // HIS 自动建档:新增只进入待确认,不生成计划
        if (existing == null) {
            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_PENDING);
            detail.setFollowupConfirmTime(null);
            detail.setFollowupConfirmBy(null);
            return;
        }
        // 更新时保持原状态,避免 HIS 重复推送把已确认档案退回待确认
        detail.setFollowupStatus(null);
        detail.setFollowupConfirmTime(null);
        detail.setFollowupConfirmBy(null);
        // 已确认/历史已生效档案的随访日期与周期由人工维护,HIS 同步不覆盖
        if (StringUtils.isEmpty(existing.getFollowupStatus())
                || MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())) {
            detail.setPlannedFollowTime(null);
            detail.setFollowupPeriod(null);
            detail.setFollowupCycleTimes(null);
        }
    }
}
smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
@@ -166,12 +166,14 @@
                if (SpecificArchiveConstants.DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
                    PatMaternityArchiveDetail detail =
                            buildMaternityDetail(patMedOuthosp, targetArchive, config, campusid);
                    patMaternityArchiveService.insertOrUpdateMaternityArchive(detail);
                    // 接诊完成自动建档:只建草稿,等人工保存档案后再生成随访计划
                    patMaternityArchiveService.insertOrUpdateMaternityArchive(detail, false);
                    generatedCount++;
                } else if (SpecificArchiveConstants.DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
                    PatChildArchiveDetail detail =
                            buildChildDetail(patMedOuthosp, targetArchive, config, campusid);
                    patChildArchiveService.insertOrUpdateChildArchive(detail);
                    // 接诊完成自动建档:只建草稿,等人工保存档案后再生成随访计划
                    patChildArchiveService.insertOrUpdateChildArchive(detail, false);
                    generatedCount++;
                } else {
                    log.warn("生成专科档案跳过:未知部门分类,configId={},deptCategory={}",
@@ -329,10 +331,12 @@
                Long archiveId;
                if (SpecificArchiveConstants.DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
                    PatMaternityArchiveDetail detail = buildInhospMaternityDetail(context, config);
                    archiveId = (long) patMaternityArchiveService.insertOrUpdateMaternityArchive(detail);
                    // 住院随访完成自动建档:只建草稿,等人工保存档案后再生成随访计划
                    archiveId = (long) patMaternityArchiveService.insertOrUpdateMaternityArchive(detail, false);
                } else if (SpecificArchiveConstants.DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
                    PatChildArchiveDetail detail = buildInhospChildDetail(context, config);
                    archiveId = (long) patChildArchiveService.insertOrUpdateChildArchive(detail);
                    // 住院随访完成自动建档:只建草稿,等人工保存档案后再生成随访计划
                    archiveId = (long) patChildArchiveService.insertOrUpdateChildArchive(detail, false);
                } else {
                    log.warn("住院随访生成专科档案跳过:未知部门分类,configId={},deptCategory={}",
                            config.getId(), deptCategory);
smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
@@ -1,5 +1,11 @@
package com.smartor.service.mch;
import com.smartor.domain.MchFollowupPlanItem;
import com.smartor.domain.MchFollowupTaskQuery;
import com.smartor.domain.MchFollowupTaskVO;
import java.util.List;
/**
 * 妇幼随访计划服务。
 */
@@ -22,4 +28,30 @@
     * @return 新生成的发送节点数量
     */
    int rebuildAll(int limit);
    /**
     * 回填随访节点的实际随访日期、随访人员、随访情况和随访状态。
     *
     * <p>只更新人工随访结果,不影响 send_status 发送状态。</p>
     *
     * @param item 至少包含 id 和 followupStatus
     * @return 更新行数
     */
    int updateItemFollowupResult(MchFollowupPlanItem item);
    /**
     * 查询某个计划下的所有随访节点。
     *
     * @param planId 计划ID
     * @return 节点列表(含发送状态和人工随访结果)
     */
    List<MchFollowupPlanItem> listItems(Long planId);
    /**
     * 查询妇幼随访任务列表。
     *
     * <p>返回门诊日期、计划/实际随访日期、随访人、sendname、patid 等字段;
     * taskid 固定为空,taskname 为档案类型+随访。</p>
     */
    List<MchFollowupTaskVO> listTasks(MchFollowupTaskQuery query);
}
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
@@ -36,6 +36,7 @@
            item.setTemplateId(node.getTemplateId());
            item.setUrl(node.getUrl());
            item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
            item.setFollowupStatus(MchFollowupConstants.ITEM_FOLLOWUP_STATUS_PENDING);
            item.setRetryCount(0);
            item.setCreateTime(now);
            item.setUpdateTime(now);
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
@@ -1,5 +1,6 @@
package com.smartor.service.mch;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysConfigService;
@@ -9,6 +10,8 @@
import com.smartor.domain.MchFollowupNode;
import com.smartor.domain.MchFollowupPlan;
import com.smartor.domain.MchFollowupPlanItem;
import com.smartor.domain.MchFollowupTaskQuery;
import com.smartor.domain.MchFollowupTaskVO;
import com.smartor.domain.PatChildArchiveDetail;
import com.smartor.domain.PatMaternityArchiveDetail;
import com.smartor.mapper.MchFollowupPlanItemMapper;
@@ -84,6 +87,12 @@
        if (!SpecificArchiveConstants.LISHUI_MCH_ORG_ID.equals(snapshot.orgid)) {
            return 0;
        }
        // 档案必须经过人工保存/确认后才允许生成计划;接诊完成自动建档只是草稿。
        if (!isFollowupActive(snapshot.followupStatus)) {
            log.debug("【妇幼随访】档案未确认随访,跳过计划重建,archiveType={},archiveId={},detailId={},followupStatus={}",
                    snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId, snapshot.followupStatus);
            return 0;
        }
        List<MchFollowupPlan> actives = planMapper.selectActiveByArchive(
                snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId);
@@ -91,7 +100,10 @@
            actives = Collections.emptyList();
        }
        for (MchFollowupPlan active : actives) {
            if (sameTime(active.getPlannedFollowTime(), snapshot.plannedFollowTime)
            // 只有“有效”计划才做幂等判断;待补充计划即使日期/周期字符串相同,
            // 也可能是因为之前配置非法而挂起,人工确认后必须重新解析并生成节点。
            if (MchFollowupConstants.PLAN_STATUS_ACTIVE.equals(active.getPlanStatus())
                    && sameTime(active.getPlannedFollowTime(), snapshot.plannedFollowTime)
                    && StringUtils.equals(active.getFollowupPeriod(), snapshot.followupPeriod)) {
                MchFollowupPlan contactUpdate = new MchFollowupPlan();
                contactUpdate.setId(active.getId());
@@ -194,6 +206,50 @@
        return generated;
    }
    @Override
    public int updateItemFollowupResult(MchFollowupPlanItem item) {
        if (item == null || item.getId() == null) {
            throw new BaseException("随访节点ID不能为空");
        }
        String followupStatus = item.getFollowupStatus();
        if (StringUtils.isEmpty(followupStatus)) {
            throw new BaseException("随访状态不能为空");
        }
        if (!isValidItemFollowupStatus(followupStatus)) {
            throw new BaseException("不支持的随访状态:" + followupStatus);
        }
        MchFollowupPlanItem existing = itemMapper.selectMchFollowupPlanItemById(item.getId());
        if (existing == null) {
            throw new BaseException("随访节点不存在:" + item.getId());
        }
        item.setUpdateTime(DateUtils.getNowDate());
        return itemMapper.updateFollowupResult(item);
    }
    @Override
    public List<MchFollowupPlanItem> listItems(Long planId) {
        if (planId == null) {
            throw new BaseException("计划ID不能为空");
        }
        return itemMapper.selectByPlanId(planId);
    }
    @Override
    public List<MchFollowupTaskVO> listTasks(MchFollowupTaskQuery query) {
        if (query == null || StringUtils.isEmpty(query.getOrgid())) {
            throw new BaseException("机构ID不能为空");
        }
        return itemMapper.selectTaskList(query);
    }
    private boolean isValidItemFollowupStatus(String status) {
        return MchFollowupConstants.ITEM_FOLLOWUP_STATUS_PENDING.equals(status)
                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_DONE.equals(status)
                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_LOST.equals(status)
                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_REFUSED.equals(status)
                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_BAD_NUMBER.equals(status);
    }
    private ArchiveSnapshot loadSnapshot(String archiveType, Long archiveId, Long archiveDetailId) {
        if (MchFollowupConstants.ARCHIVE_TYPE_MATERNITY.equals(archiveType)) {
            return loadMaternitySnapshot(archiveId, archiveDetailId);
@@ -237,6 +293,7 @@
        snapshot.plannedFollowTime = detail.getPlannedFollowTime();
        snapshot.followupPeriod = detail.getFollowupPeriod();
        snapshot.followupCycleTimes = detail.getFollowupCycleTimes();
        snapshot.followupStatus = detail.getFollowupStatus();
        return snapshot;
    }
@@ -271,7 +328,16 @@
        snapshot.idcardno = detail.getIdcardno();
        snapshot.plannedFollowTime = detail.getPlannedFollowTime();
        snapshot.followupPeriod = detail.getFollowupPeriod();
        snapshot.followupStatus = detail.getFollowupStatus();
        return snapshot;
    }
    /**
     * 历史数据没有状态时按已确认处理,保证已有档案的计划不受影响。
     */
    private boolean isFollowupActive(String followupStatus) {
        return StringUtils.isEmpty(followupStatus)
                || MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(followupStatus);
    }
    private boolean isEnabled() {
@@ -317,5 +383,6 @@
        private Date plannedFollowTime;
        private String followupPeriod;
        private String followupCycleTimes;
        private String followupStatus;
    }
}
smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
@@ -18,15 +18,53 @@
        <result property="retryCount" column="retry_count"/>
        <result property="nextRetryTime" column="next_retry_time"/>
        <result property="sendTimeActual" column="send_time_actual"/>
        <result property="followupDate" column="followup_date"/>
        <result property="followupUserId" column="followup_user_id"/>
        <result property="followupUserName" column="followup_user_name"/>
        <result property="followupSituation" column="followup_situation"/>
        <result property="followupStatus" column="followup_status"/>
        <result property="resultMsg" column="result_msg"/>
        <result property="providerMsgId" column="provider_msg_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
    <resultMap id="MchFollowupTaskResult" type="com.smartor.domain.MchFollowupTaskVO">
        <result property="itemId" column="item_id"/>
        <result property="planId" column="plan_id"/>
        <result property="taskid" column="taskid"/>
        <result property="taskType" column="task_type"/>
        <result property="taskname" column="task_name"/>
        <result property="archiveType" column="archive_type"/>
        <result property="archiveTypeName" column="archive_type_name"/>
        <result property="archiveId" column="archive_id"/>
        <result property="archiveDetailId" column="archive_detail_id"/>
        <result property="sourceType" column="source_type"/>
        <result property="sourceBizNo" column="source_biz_no"/>
        <result property="patid" column="patid"/>
        <result property="patname" column="patname"/>
        <result property="sendname" column="sendname"/>
        <result property="phone" column="phone"/>
        <result property="idcardno" column="idcardno"/>
        <result property="seq" column="seq"/>
        <result property="outpatientDate" column="outpatient_date"/>
        <result property="plannedFollowTime" column="planned_follow_time"/>
        <result property="plannedFollowDate" column="planned_follow_date"/>
        <result property="followupDate" column="followup_date"/>
        <result property="followupUserId" column="followup_user_id"/>
        <result property="followupUserName" column="followup_user_name"/>
        <result property="followupSituation" column="followup_situation"/>
        <result property="followupStatus" column="followup_status"/>
        <result property="sendStatus" column="send_status"/>
        <result property="sendTimeActual" column="send_time_actual"/>
        <result property="orgid" column="orgid"/>
        <result property="campusid" column="campusid"/>
    </resultMap>
    <sql id="selectItemVo">
        select id, plan_id, seq, send_type, send_time, title_name, content, template_id, url,
               send_status, retry_count, next_retry_time, send_time_actual,
               followup_date, followup_user_id, followup_user_name, followup_situation, followup_status,
               result_msg, provider_msg_id, create_time, update_time
        from mch_followup_plan_item
    </sql>
@@ -36,10 +74,13 @@
        insert into mch_followup_plan_item
        (plan_id, seq, send_type, send_time, title_name, content, template_id, url,
         send_status, retry_count, next_retry_time, send_time_actual,
         followup_date, followup_user_id, followup_user_name, followup_situation, followup_status,
         result_msg, provider_msg_id, create_time, update_time)
        values
        (#{planId}, #{seq}, #{sendType}, #{sendTime}, #{titleName}, #{content}, #{templateId}, #{url},
         #{sendStatus}, #{retryCount}, #{nextRetryTime}, #{sendTimeActual},
         #{followupDate}, #{followupUserId}, #{followupUserName}, #{followupSituation},
         COALESCE(#{followupStatus,jdbcType=CHAR}, '0'),
         #{resultMsg}, #{providerMsgId}, #{createTime}, #{updateTime})
    </insert>
@@ -56,6 +97,11 @@
            <if test="retryCount != null">retry_count = #{retryCount},</if>
            <if test="nextRetryTime != null">next_retry_time = #{nextRetryTime},</if>
            <if test="sendTimeActual != null">send_time_actual = #{sendTimeActual},</if>
            <if test="followupDate != null">followup_date = #{followupDate},</if>
            <if test="followupUserId != null">followup_user_id = #{followupUserId},</if>
            <if test="followupUserName != null">followup_user_name = #{followupUserName},</if>
            <if test="followupSituation != null">followup_situation = #{followupSituation},</if>
            <if test="followupStatus != null">followup_status = #{followupStatus},</if>
            <if test="resultMsg != null">result_msg = #{resultMsg},</if>
            <if test="providerMsgId != null">provider_msg_id = #{providerMsgId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
@@ -75,6 +121,17 @@
        where id = #{id}
    </update>
    <update id="updateFollowupResult" parameterType="com.smartor.domain.MchFollowupPlanItem">
        update mch_followup_plan_item
        set followup_date = #{followupDate,jdbcType=TIMESTAMP},
            followup_user_id = #{followupUserId,jdbcType=VARCHAR},
            followup_user_name = #{followupUserName,jdbcType=VARCHAR},
            followup_situation = #{followupSituation,jdbcType=VARCHAR},
            followup_status = #{followupStatus,jdbcType=CHAR},
            update_time = #{updateTime,jdbcType=TIMESTAMP}
        where id = #{id}
    </update>
    <select id="selectMchFollowupPlanItemById" resultMap="MchFollowupPlanItemResult">
        <include refid="selectItemVo"/>
        where id = #{id}
@@ -89,7 +146,9 @@
    <select id="selectDueItems" resultMap="MchFollowupPlanItemResult">
        select i.id, i.plan_id, i.seq, i.send_type, i.send_time, i.title_name, i.content,
               i.template_id, i.url, i.send_status, i.retry_count, i.next_retry_time,
               i.send_time_actual, i.result_msg, i.provider_msg_id, i.create_time, i.update_time
               i.send_time_actual, i.followup_date, i.followup_user_id, i.followup_user_name,
               i.followup_situation, i.followup_status,
               i.result_msg, i.provider_msg_id, i.create_time, i.update_time
        from mch_followup_plan_item i
        inner join mch_followup_plan p on p.id = i.plan_id
        where p.orgid = #{orgid}
@@ -125,4 +184,86 @@
          and send_status in ('0', '1')
    </select>
    <select id="selectTaskList" parameterType="com.smartor.domain.MchFollowupTaskQuery"
            resultMap="MchFollowupTaskResult">
        select
            i.id as item_id,
            i.plan_id as plan_id,
            cast(null as signed) as taskid,
            'MCH' as task_type,
            case
                when p.archive_type = '1' and m.archive_type = '1' then '早孕关爱随访'
                when p.archive_type = '1' and m.archive_type = '2' then '围绝经期MHI随访'
                when p.archive_type = '2' and c.archive_type = '1' then '营养性疾病随访'
                when p.archive_type = '2' and c.archive_type = '2' then '学习困难随访'
                when p.archive_type = '2' and c.archive_type = '3' then '高危儿专案随访'
                when p.archive_type = '1' then '妇保随访'
                when p.archive_type = '2' then '儿保随访'
                else '妇幼随访'
            end as task_name,
            p.archive_type as archive_type,
            case
                when p.archive_type = '1' and m.archive_type = '1' then '早孕关爱'
                when p.archive_type = '1' and m.archive_type = '2' then '围绝经期MHI'
                when p.archive_type = '2' and c.archive_type = '1' then '营养性疾病'
                when p.archive_type = '2' and c.archive_type = '2' then '学习困难'
                when p.archive_type = '2' and c.archive_type = '3' then '高危儿专案'
                when p.archive_type = '1' then '妇保'
                when p.archive_type = '2' then '儿保'
                else '妇幼'
            end as archive_type_name,
            p.archive_id as archive_id,
            p.archive_detail_id as archive_detail_id,
            p.source_type as source_type,
            p.source_biz_no as source_biz_no,
            p.patid as patid,
            p.patname as patname,
            p.patname as sendname,
            p.phone as phone,
            p.idcardno as idcardno,
            i.seq as seq,
            o.admitdate as outpatient_date,
            p.planned_follow_time as planned_follow_time,
            i.send_time as planned_follow_date,
            i.followup_date as followup_date,
            i.followup_user_id as followup_user_id,
            i.followup_user_name as followup_user_name,
            i.followup_situation as followup_situation,
            i.followup_status as followup_status,
            i.send_status as send_status,
            i.send_time_actual as send_time_actual,
            p.orgid as orgid,
            p.campusid as campusid
        from mch_followup_plan_item i
        inner join mch_followup_plan p on p.id = i.plan_id
        left join pat_maternity_archive_detail m
            on p.archive_type = '1' and m.id = p.archive_detail_id
        left join pat_child_archive_detail c
            on p.archive_type = '2' and c.id = p.archive_detail_id
        left join pat_med_outhosp o
            on p.source_type = '1'
           and o.orgid = p.orgid
           and o.outhospno = p.source_biz_no
        where p.orgid = #{orgid}
          and p.plan_status &lt;&gt; '1'
          and i.send_status &lt;&gt; '5'
          <if test="campusid != null and campusid != ''">and p.campusid = #{campusid}</if>
          <if test="planId != null">and p.id = #{planId}</if>
          <if test="itemId != null">and i.id = #{itemId}</if>
          <if test="archiveType != null and archiveType != ''">and p.archive_type = #{archiveType}</if>
          <if test="sourceType != null and sourceType != ''">and p.source_type = #{sourceType}</if>
          <if test="sendStatus != null and sendStatus != ''">and i.send_status = #{sendStatus}</if>
          <if test="followupStatus != null and followupStatus != ''">and i.followup_status = #{followupStatus}</if>
          <if test="patid != null">and p.patid = #{patid}</if>
          <if test="keyword != null and keyword != ''">
              and (p.patname like concat('%', #{keyword}, '%')
                   or p.phone like concat('%', #{keyword}, '%')
                   or p.idcardno like concat('%', #{keyword}, '%')
                   or p.source_biz_no like concat('%', #{keyword}, '%'))
          </if>
          <if test="beginDate != null">and i.send_time &gt;= #{beginDate}</if>
          <if test="endDate != null">and i.send_time &lt;= #{endDate}</if>
        order by i.send_time asc, i.seq asc, i.id asc
    </select>
</mapper>
smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
@@ -107,19 +107,33 @@
        from pat_maternity_archive_detail d
        where d.orgid = #{orgid}
          and (d.del_flag is null or d.del_flag = '0')
          and d.followup_status = '1'
          and d.planned_follow_time is not null
          and d.followup_period is not null
          and d.followup_period &lt;&gt; ''
          and d.archiveid is not null
          and not exists (
              select 1 from mch_followup_plan p
              where p.archive_type = '1'
                and p.archive_detail_id = d.id
                and p.plan_status in ('0', '3')
          )
        union all
        select '2' as archiveType, d.archiveid as archiveId, d.id as archiveDetailId
        from pat_child_archive_detail d
        where d.orgid = #{orgid}
          and (d.del_flag is null or d.del_flag = '0')
          and d.followup_status = '1'
          and d.planned_follow_time is not null
          and d.followup_period is not null
          and d.followup_period &lt;&gt; ''
          and d.archiveid is not null
          and not exists (
              select 1 from mch_followup_plan p
              where p.archive_type = '2'
                and p.archive_detail_id = d.id
                and p.plan_status in ('0', '3')
          )
        limit #{limit}
    </select>
smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml
@@ -55,6 +55,9 @@
        <result property="hrcNeurologicalEvaluation" column="hrc_neurological_evaluation"/>
        <result property="hrcInterventionRecords" column="hrc_intervention_records"/>
        <result property="closeStatus" column="close_status"/>
        <result property="followupStatus" column="followup_status"/>
        <result property="followupConfirmTime" column="followup_confirm_time"/>
        <result property="followupConfirmBy" column="followup_confirm_by"/>
        <result property="gestationalWeek" column="gestational_week"/>
        <result property="birthWeight" column="birth_weight"/>
        <result property="registerUser" column="register_user"/>
@@ -119,6 +122,9 @@
               hrc_neurological_evaluation,
               hrc_intervention_records,
               close_status,
               followup_status,
               followup_confirm_time,
               followup_confirm_by,
               gestational_week,
               birth_weight,
               register_user,
@@ -170,6 +176,7 @@
            <if test="highRiskChildType != null and highRiskChildType != ''">and high_risk_child_type = #{highRiskChildType}</if>
            <if test="highRiskChildName != null and highRiskChildName != ''">and high_risk_child_name like concat('%', #{highRiskChildName}, '%')</if>
            <if test="closeStatus != null and closeStatus != ''">and close_status = #{closeStatus}</if>
            <if test="followupStatus != null and followupStatus != ''">and followup_status = #{followupStatus}</if>
            <if test="gestationalWeek != null">and gestational_week = #{gestationalWeek}</if>
            <if test="birthWeight != null">and birth_weight = #{birthWeight}</if>
            <if test="registerUser != null and registerUser != ''">and register_user = #{registerUser}</if>
@@ -242,6 +249,9 @@
            <if test="hrcNeurologicalEvaluation != null">hrc_neurological_evaluation,</if>
            <if test="hrcInterventionRecords != null">hrc_intervention_records,</if>
            <if test="closeStatus != null">close_status,</if>
            <if test="followupStatus != null">followup_status,</if>
            <if test="followupConfirmTime != null">followup_confirm_time,</if>
            <if test="followupConfirmBy != null">followup_confirm_by,</if>
            <if test="gestationalWeek != null">gestational_week,</if>
            <if test="birthWeight != null">birth_weight,</if>
            <if test="registerUser != null">register_user,</if>
@@ -304,6 +314,9 @@
            <if test="hrcNeurologicalEvaluation != null">#{hrcNeurologicalEvaluation},</if>
            <if test="hrcInterventionRecords != null">#{hrcInterventionRecords},</if>
            <if test="closeStatus != null">#{closeStatus},</if>
            <if test="followupStatus != null">#{followupStatus},</if>
            <if test="followupConfirmTime != null">#{followupConfirmTime},</if>
            <if test="followupConfirmBy != null">#{followupConfirmBy},</if>
            <if test="gestationalWeek != null">#{gestationalWeek},</if>
            <if test="birthWeight != null">#{birthWeight},</if>
            <if test="registerUser != null">#{registerUser},</if>
@@ -370,6 +383,9 @@
            <if test="hrcNeurologicalEvaluation != null">hrc_neurological_evaluation = #{hrcNeurologicalEvaluation},</if>
            <if test="hrcInterventionRecords != null">hrc_intervention_records = #{hrcInterventionRecords},</if>
            <if test="closeStatus != null">close_status = #{closeStatus},</if>
            <if test="followupStatus != null">followup_status = #{followupStatus},</if>
            <if test="followupConfirmTime != null">followup_confirm_time = #{followupConfirmTime},</if>
            <if test="followupConfirmBy != null">followup_confirm_by = #{followupConfirmBy},</if>
            <if test="gestationalWeek != null">gestational_week = #{gestationalWeek},</if>
            <if test="birthWeight != null">birth_weight = #{birthWeight},</if>
            <if test="registerUser != null">register_user = #{registerUser},</if>
smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml
@@ -38,6 +38,9 @@
        <result property="specificSituation" column="specific_situation"/>
        <result property="handleSuggestion" column="handle_suggestion"/>
        <result property="closeStatus" column="close_status"/>
        <result property="followupStatus" column="followup_status"/>
        <result property="followupConfirmTime" column="followup_confirm_time"/>
        <result property="followupConfirmBy" column="followup_confirm_by"/>
        <result property="isRecordEstablished" column="is_record_established"/>
        <result property="dueDate" column="due_date"/>
        <result property="registerUser" column="register_user"/>
@@ -99,6 +102,9 @@
               specific_situation,
               handle_suggestion,
               close_status,
               followup_status,
               followup_confirm_time,
               followup_confirm_by,
               is_record_established,
               due_date,
               register_user,
@@ -158,6 +164,7 @@
            <if test="icd10code != null and icd10code != ''">and icd10code = #{icd10code}</if>
            <if test="diagname != null and diagname != ''">and diagname like concat('%', #{diagname}, '%')</if>
            <if test="closeStatus != null and closeStatus != ''">and close_status = #{closeStatus}</if>
            <if test="followupStatus != null and followupStatus != ''">and followup_status = #{followupStatus}</if>
            <if test="isRecordEstablished != null and isRecordEstablished != ''">and is_record_established = #{isRecordEstablished}</if>
            <if test="registerUser != null and registerUser != ''">and register_user = #{registerUser}</if>
            <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
@@ -212,6 +219,9 @@
            <if test="specificSituation != null">specific_situation,</if>
            <if test="handleSuggestion != null">handle_suggestion,</if>
            <if test="closeStatus != null">close_status,</if>
            <if test="followupStatus != null">followup_status,</if>
            <if test="followupConfirmTime != null">followup_confirm_time,</if>
            <if test="followupConfirmBy != null">followup_confirm_by,</if>
            <if test="isRecordEstablished != null">is_record_established,</if>
            <if test="dueDate != null">due_date,</if>
            <if test="registerUser != null">register_user,</if>
@@ -271,6 +281,9 @@
            <if test="specificSituation != null">#{specificSituation},</if>
            <if test="handleSuggestion != null">#{handleSuggestion},</if>
            <if test="closeStatus != null">#{closeStatus},</if>
            <if test="followupStatus != null">#{followupStatus},</if>
            <if test="followupConfirmTime != null">#{followupConfirmTime},</if>
            <if test="followupConfirmBy != null">#{followupConfirmBy},</if>
            <if test="isRecordEstablished != null">#{isRecordEstablished},</if>
            <if test="dueDate != null">#{dueDate},</if>
            <if test="registerUser != null">#{registerUser},</if>
@@ -334,6 +347,9 @@
            <if test="specificSituation != null">specific_situation = #{specificSituation},</if>
            <if test="handleSuggestion != null">handle_suggestion = #{handleSuggestion},</if>
            <if test="closeStatus != null">close_status = #{closeStatus},</if>
            <if test="followupStatus != null">followup_status = #{followupStatus},</if>
            <if test="followupConfirmTime != null">followup_confirm_time = #{followupConfirmTime},</if>
            <if test="followupConfirmBy != null">followup_confirm_by = #{followupConfirmBy},</if>
            <if test="isRecordEstablished != null">is_record_established = #{isRecordEstablished},</if>
            <if test="dueDate != null">due_date = #{dueDate},</if>
            <if test="registerUser != null">register_user = #{registerUser},</if>
smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
@@ -5,6 +5,8 @@
import com.smartor.common.SpecificArchiveConstants;
import com.smartor.domain.MchFollowupPlan;
import com.smartor.domain.MchFollowupPlanItem;
import com.smartor.domain.MchFollowupTaskQuery;
import com.smartor.domain.MchFollowupTaskVO;
import com.smartor.domain.PatChildArchiveDetail;
import com.smartor.domain.PatMaternityArchiveDetail;
import com.smartor.mapper.MchFollowupPlanItemMapper;
@@ -111,6 +113,7 @@
        detail.setPhone("13800000000");
        detail.setIdcardno("330102199001010000");
        detail.setPlannedFollowTime(plannedTime);
        detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
        detail.setFollowupPeriod("{\"items\":["
                + "{\"dayOffset\":0,\"sendTime\":\"09:00\",\"sendType\":\"sms\",\"content\":\"短信1\"},"
                + "{\"dayOffset\":3,\"sendType\":\"wechat\",\"templateId\":16,\"content\":\"微信2\"},"
@@ -132,6 +135,7 @@
        detail.setParentPhone("13700000000");
        detail.setIdcardno("330102199202020000");
        detail.setPlannedFollowTime(plannedTime);
        detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
        detail.setFollowupPeriod("{\"items\":[{\"dayOffset\":1,\"sendType\":\"sms\",\"content\":\"儿保短信\"}]}");
        return detail;
    }
@@ -170,6 +174,7 @@
            return defaultValue(method.getReturnType());
        });
        MchFollowupPlanItem[] updatedFollowupItem = new MchFollowupPlanItem[1];
        MchFollowupPlanItemMapper itemMapper = proxy(MchFollowupPlanItemMapper.class, (p, method, a) -> {
            String name = method.getName();
            if ("insertMchFollowupPlanItem".equals(name)) {
@@ -184,12 +189,46 @@
            if ("countPendingByPlanId".equals(name)) {
                return 1;
            }
            if ("selectMchFollowupPlanItemById".equals(name)) {
                MchFollowupPlanItem item = new MchFollowupPlanItem();
                item.setId((Long) a[0]);
                return item;
            }
            if ("updateFollowupResult".equals(name)) {
                updatedFollowupItem[0] = (MchFollowupPlanItem) a[0];
                return 1;
            }
            if ("selectByPlanId".equals(name)) {
                Long queryPlanId = (Long) a[0];
                List<MchFollowupPlanItem> list = new ArrayList<>();
                for (MchFollowupPlanItem item : insertedItems) {
                    if (queryPlanId.equals(item.getPlanId())) {
                        list.add(item);
                    }
                }
                return list;
            }
            if ("selectTaskList".equals(name)) {
                MchFollowupTaskVO vo = new MchFollowupTaskVO();
                vo.setItemId(1L);
                vo.setPlanId(1L);
                vo.setTaskname("早孕关爱随访");
                vo.setPatid(100L);
                vo.setPatname("张三");
                vo.setSendname("张三");
                List<MchFollowupTaskVO> list = new ArrayList<>();
                list.add(vo);
                return list;
            }
            return defaultValue(method.getReturnType());
        });
        Map<Long, PatMaternityArchiveDetail> maternityMap = new HashMap<>();
        maternityMap.put(20L, maternityDetail(20L, 10L, date("2026-11-20 14:30:00")));
        maternityMap.put(21L, maternityDetail(21L, 11L, null));
        PatMaternityArchiveDetail pendingDetail = maternityDetail(22L, 13L, date("2026-11-25 10:00:00"));
        pendingDetail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_PENDING);
        maternityMap.put(22L, pendingDetail);
        PatMaternityArchiveDetailMapper maternityMapper = proxy(PatMaternityArchiveDetailMapper.class, (p, method, a) -> {
            String name = method.getName();
            if ("selectPatMaternityArchiveDetailById".equals(name)) {
@@ -254,6 +293,13 @@
        check("计划数不变", 1, activePlans.size());
        check("节点数不变", 3, insertedItems.size());
        System.out.println("-- 2.1) 待确认档案不生成 --");
        int pendingGenerated = service.rebuildForArchive(
                MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 13L, 22L);
        check("待确认不生成", 0, pendingGenerated);
        check("待确认计划数不变", 1, activePlans.size());
        check("待确认节点数不变", 3, insertedItems.size());
        System.out.println("-- 3) 拟随访时间为空 --");
        int waiting = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 11L, 21L);
        check("等待计划不生成节点", 0, waiting);
@@ -275,6 +321,32 @@
        int otherGenerated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 20L, 40L);
        check("其他机构不生成", 0, otherGenerated);
        System.out.println("-- 6) 回填人工随访结果 --");
        MchFollowupPlanItem feedback = new MchFollowupPlanItem();
        feedback.setId(1L);
        feedback.setFollowupDate(date("2026-11-24 10:00:00"));
        feedback.setFollowupUserId("U001");
        feedback.setFollowupUserName("王护士");
        feedback.setFollowupSituation("电话随访,情况稳定");
        feedback.setFollowupStatus(MchFollowupConstants.ITEM_FOLLOWUP_STATUS_DONE);
        int feedbackUpdated = service.updateItemFollowupResult(feedback);
        check("回填更新行数", 1, feedbackUpdated);
        check("回填状态", MchFollowupConstants.ITEM_FOLLOWUP_STATUS_DONE,
                updatedFollowupItem[0].getFollowupStatus());
        check("回填人员", "王护士", updatedFollowupItem[0].getFollowupUserName());
        check("回填时间非空", true, updatedFollowupItem[0].getUpdateTime() != null);
        check("节点列表数", 3, service.listItems(1L).size());
        System.out.println("-- 7) 妇幼任务列表字段 --");
        MchFollowupTaskQuery taskQuery = new MchFollowupTaskQuery();
        taskQuery.setOrgid(SpecificArchiveConstants.LISHUI_MCH_ORG_ID);
        List<MchFollowupTaskVO> taskList = service.listTasks(taskQuery);
        check("任务列表数", 1, taskList.size());
        check("taskid为空", null, taskList.get(0).getTaskid());
        check("taskname", "早孕关爱随访", taskList.get(0).getTaskname());
        check("sendname", "张三", taskList.get(0).getSendname());
        check("patid", 100L, taskList.get(0).getPatid());
        System.out.println("========== 结果:PASS=" + passed + ",FAIL=" + failed + " ==========");
        if (failed > 0) {
            System.exit(1);