8a73ac17d717c32aa8fd97f4c682094d7b1c0654..a2101aa52a00ae103a26a950b54f985f46769239
3 天以前 陈昶聿
【丽水】妇幼随访发送
a2101a 对比 | 目录
3 天以前 陈昶聿
feat: 增加妇幼随访任务列表接口与随访结果字段
c885a9 对比 | 目录
3 天以前 陈昶聿
【丽水】妇幼随访发送
3acf94 对比 | 目录
已删除19个文件
已修改15个文件
已添加1个文件
2455 ■■■■■ 文件已修改
.gitignore 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtask.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/common/MchFollowupConstants.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/MchFollowupNode.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java 33 ●●●●● 补丁 | 查看 | 原始文档 | 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 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | 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 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java 321 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java 210 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | 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/MchFollowupLogicCheck.java 200 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java 283 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java 198 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/mch_followup_plan_20261117.sql 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/pat_mch_archive_followup_status_20261123.sql 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -37,7 +37,9 @@
!/sql/quartz.sql
!/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/service_subtask_add_mch_fields_20261123.sql
!/sql/drop_mch_followup_plan_tables_20261123.sql
sql/_probe/
*.log
_dbcheck.txt
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -32,14 +32,14 @@
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.message.sms.provider.sltd.ws.MessageSend;
import com.smartor.common.MchFollowupConstants;
import com.smartor.common.QwenLLMUtil;
import com.smartor.common.SpecificArchiveConstants;
import com.smartor.domain.*;
import com.ruoyi.task.domain.VO.ServiceSubtaskDetailTraceVO;
import com.smartor.mapper.*;
import com.smartor.service.*;
import com.smartor.service.mch.IMchFollowupPlanService;
import com.smartor.service.mch.IMchFollowupSendService;
import com.smartor.service.mch.IMchFollowupSubtaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -154,10 +154,7 @@
    private IPatSpecificArchiveGenerateService patSpecificArchiveGenerateService;
    @Autowired
    private IMchFollowupPlanService mchFollowupPlanService;
    @Autowired
    private IMchFollowupSendService mchFollowupSendService;
    private IMchFollowupSubtaskService mchFollowupSubtaskService;
    @Autowired
    private com.ruoyi.task.event.FollowupCompletedEventPublisher followupCompletedEventPublisher;
@@ -1339,6 +1336,15 @@
            log.error("【sfHandlle】子任务为空,跳过处理");
            return;
        }
        // å¦‡å¹¼éšè®¿ï¼šservice_type=21,走妇幼专用发送逻辑,不依赖 service_task.preachform_desc
        if (MchFollowupConstants.SERVICE_TYPE_MCH.equals(serviceSubtask.getServiceType())) {
            try {
                mchFollowupSubtaskService.sendSubtask(serviceSubtask);
            } catch (Exception e) {
                log.error("【妇幼随访】sfHandlle å‘送异常,subid={}", serviceSubtask.getId(), e);
            }
            return;
        }
        //这里需要根据身份证去重(给微信小程序的固定任务用的)
        List<ServiceSubtask> serviceSubtaskListFilter = new ArrayList<>();
        ServiceTask ivrTask1 = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
@@ -2382,30 +2388,17 @@
    }
    /**
     * å¦‡å¹¼éšè®¿ï¼šä¸ºå·²æœ‰å¦‡å¹¼æ¡£æ¡ˆè¡¥å»ºè®¡åˆ’。
     * å¦‡å¹¼éšè®¿ï¼šæ‰«æå·²ç¡®è®¤æ¡£æ¡ˆï¼ŒæŒ‰ plannedFollowTime + followupPeriod ç”Ÿæˆ service_subtask。
     *
     * <p>档案新增/修改时会自动重建计划;本任务用于历史数据补建和异常补偿。</p>
     * <p>实际发送由 longTaskSend / compensateTask è°ƒç”¨ sfHandlle çš„
     * service_type=21 åˆ†æ”¯å®Œæˆã€‚</p>
     */
    public void generateMchFollowupPlan() {
    public void generateMchFollowupSubtask() {
        try {
            int generated = mchFollowupPlanService.rebuildAll(200);
            log.info("【generateMchFollowupPlan】妇幼随访计划补建完成,生成节点数={}", generated);
            int generated = mchFollowupSubtaskService.rebuildAll(200);
            log.info("【generateMchFollowupSubtask】妇幼随访任务生成完成,生成节点数={}", generated);
        } catch (Exception e) {
            log.error("【generateMchFollowupPlan】妇幼随访计划补建失败", e);
        }
    }
    /**
     * å¦‡å¹¼éšè®¿ï¼šæ‰«æåˆ°æœŸèŠ‚ç‚¹å¹¶å‘é€ã€‚
     *
     * <p>只补发 1 å¤©å†…到期的节点;超过 1 å¤©æ ‡è®°è¿‡æœŸã€‚短信走云MAS,微信走 sendChatLs。</p>
     */
    public void sendMchFollowup() {
        try {
            int sent = mchFollowupSendService.sendDue(200);
            log.info("【sendMchFollowup】妇幼随访发送完成,成功数量={}", sent);
        } catch (Exception e) {
            log.error("【sendMchFollowup】妇幼随访发送失败", e);
            log.error("【generateMchFollowupSubtask】妇幼随访任务生成失败", e);
        }
    }
ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtask.java
@@ -164,6 +164,18 @@
    @ApiModelProperty(value = "服务类型集合,按逗号分割")
    private String serviceTypes;
    @ApiModelProperty(value = "妇幼档案详情ID")
    private Long mchArchiveDetailId;
    @ApiModelProperty(value = "妇幼随访节点序号")
    private Integer mchNodeSeq;
    @ApiModelProperty(value = "妇幼随访计划哈希")
    private String mchPlanHash;
    @ApiModelProperty(value = "妇幼随访节点JSON")
    private String mchNodeJson;
    /**
     * æ¨¡æ¿ID
     */
smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
@@ -1,10 +1,10 @@
package com.smartor.common;
/**
 * å¦‡å¹¼éšè®¿è®¡åˆ’相关常量。
 * å¦‡å¹¼éšè®¿ç›¸å…³å¸¸é‡ã€‚
 *
 * <p>妇幼随访只适用于丽水市妇幼保健院,且使用独立的计划表和发送任务,
 * ä¸è¿›å…¥æ™®é€šéšè®¿çš„ {@code service_subtask_preachform} / {@code compensateTask} è¡¥å¿é“¾è·¯ã€‚</p>
 * <p>妇幼随访只适用于丽水市妇幼保健院。随访节点落 service_subtask,
 * service_type=21,由 sfHandlle çš„妇幼分支发送,不进入普通随访补偿链路。</p>
 */
public final class MchFollowupConstants {
@@ -14,38 +14,23 @@
    /** æ¡£æ¡ˆç±»åž‹ï¼šå„¿ä¿ */
    public static final String ARCHIVE_TYPE_CHILD = "2";
    /** è®¡åˆ’状态:有效 */
    public static final String PLAN_STATUS_ACTIVE = "0";
    /**
     * æ¡£æ¡ˆéšè®¿çŠ¶æ€ï¼šå¾…ç¡®è®¤ã€‚
     *
     * <p>门诊接诊完成/住院随访完成自动建档时写入,表示档案尚未经过人工确认,
     * ä¸ç”Ÿæˆéšè®¿ä»»åŠ¡ã€‚</p>
     */
    public static final String FOLLOWUP_STATUS_PENDING = "0";
    /** è®¡åˆ’状态:已取消 */
    public static final String PLAN_STATUS_CANCELED = "1";
    /**
     * æ¡£æ¡ˆéšè®¿çŠ¶æ€ï¼šéšè®¿ä¸­ã€‚
     *
     * <p>人工保存/确认档案后写入,允许生成 service_subtask。</p>
     */
    public static final String FOLLOWUP_STATUS_ACTIVE = "1";
    /** è®¡åˆ’状态:已完成 */
    public static final String PLAN_STATUS_COMPLETED = "2";
    /** è®¡åˆ’状态:待补充基准日/配置异常 */
    public static final String PLAN_STATUS_WAITING = "3";
    /** èŠ‚ç‚¹çŠ¶æ€ï¼šå¾…å‘é€ */
    public static final String ITEM_STATUS_PENDING = "0";
    /** èŠ‚ç‚¹çŠ¶æ€ï¼šå‘é€ä¸­ */
    public static final String ITEM_STATUS_SENDING = "1";
    /** èŠ‚ç‚¹çŠ¶æ€ï¼šæˆåŠŸ */
    public static final String ITEM_STATUS_SUCCESS = "2";
    /** èŠ‚ç‚¹çŠ¶æ€ï¼šå¤±è´¥ï¼ˆé‡è¯•è€—å°½ï¼‰ */
    public static final String ITEM_STATUS_FAILED = "3";
    /** èŠ‚ç‚¹çŠ¶æ€ï¼šè¿‡æœŸï¼ˆè¶…è¿‡è¡¥å‘çª—å£ï¼Œæœªå‘é€ï¼‰ */
    public static final String ITEM_STATUS_EXPIRED = "4";
    /** èŠ‚ç‚¹çŠ¶æ€ï¼šå–æ¶ˆ */
    public static final String ITEM_STATUS_CANCELED = "5";
    /** èŠ‚ç‚¹çŠ¶æ€ï¼šè·³è¿‡ï¼ˆæ‰‹æœºå·ä¸ºç©ºç­‰ï¼‰ */
    public static final String ITEM_STATUS_SKIPPED = "6";
    /** service_subtask.service_type:妇幼随访 */
    public static final String SERVICE_TYPE_MCH = "21";
    /** å‘送方式:短信 */
    public static final String SEND_TYPE_SMS = "sms";
@@ -53,18 +38,12 @@
    /** å‘送方式:微信公众号 */
    public static final String SEND_TYPE_WECHAT = "wechat";
    /** è¡¥å‘窗口:只补发 1 å¤©å†…到期的节点。 */
    public static final long CATCHUP_MILLIS = 24L * 60L * 60L * 1000L;
    /** é»˜è®¤æœ€å¤§é‡è¯•次数。 */
    public static final int DEFAULT_MAX_RETRY = 3;
    /** é»˜è®¤é‡è¯•间隔(分钟)。 */
    public static final int DEFAULT_RETRY_DELAY_MINUTES = 10;
    /** å•次扫描默认上限。 */
    public static final int DEFAULT_BATCH_SIZE = 200;
    /** è¡¥å‘窗口:只补发 1 å¤©å†…到期的节点。 */
    public static final long CATCHUP_MILLIS = 24L * 60L * 60L * 1000L;
    /** å¯ç”¨å¼€å…³ï¼ˆsys_config,按机构读取;缺省视为启用)。 */
    public static final String CONFIG_ENABLED = "mch.followup.enabled";
smartor/src/main/java/com/smartor/domain/MchFollowupNode.java
@@ -3,6 +3,7 @@
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * followupPeriod JSON è§£æžåŽçš„发送节点定义(尚未计算绝对发送时间)。
@@ -29,4 +30,13 @@
    private Long templateId;
    private String url;
    /** æ¡£æ¡ˆå¤§ç±»ï¼š1妇保 2儿保(生成 subtask æ—¶å›žå¡«ï¼Œä¾¿äºŽå ä½ç¬¦æ¸²æŸ“) */
    private String archiveType;
    /** æ¡£æ¡ˆå­ç±»åž‹ï¼šæ—©å­•关爱/围绝经期MHI/营养性疾病/学习困难/高危儿专案 */
    private String archiveSubType;
    /** å‘¨æœŸåŸºå‡†æ—¥ */
    private Date plannedFollowTime;
}
smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java
ÎļþÒÑɾ³ý
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
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java
ÎļþÒÑɾ³ý
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
@@ -10,7 +10,7 @@
import com.smartor.mapper.PatChildArchiveMapper;
import com.smartor.service.IPatChildArchiveDetailService;
import com.smartor.service.IPatChildArchiveService;
import com.smartor.service.mch.IMchFollowupPlanService;
import com.smartor.service.mch.IMchFollowupSubtaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +36,7 @@
    private IPatChildArchiveDetailService patChildArchiveDetailService;
    @Autowired
    private IMchFollowupPlanService mchFollowupPlanService;
    private IMchFollowupSubtaskService mchFollowupSubtaskService;
    @Override
    public PatChildArchive selectPatChildArchiveById(Long id)
@@ -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,19 +208,72 @@
            patChildArchiveDetailService.insertPatChildArchiveDetail(patChildArchiveDetail);
        }
        // å¦‡å¹¼éšè®¿è®¡åˆ’:档案新增/修改后按 plannedFollowTime + followupPeriod é‡å»º
        // å¦‡å¹¼éšè®¿ä»»åŠ¡ï¼šåªæœ‰äººå·¥ç¡®è®¤ï¼ˆfollowup_status=1)的档案才生成/重建 service_subtask;
        // è‡ªåŠ¨å»ºæ¡£ä¸ºå¾…ç¡®è®¤ï¼ŒrebuildForArchive å†…部会直接跳过。
        try {
            if (mchFollowupPlanService != null) {
                mchFollowupPlanService.rebuildForArchive(
            if (mchFollowupSubtaskService != null) {
                mchFollowupSubtaskService.rebuildForArchive(
                        MchFollowupConstants.ARCHIVE_TYPE_CHILD,
                        patChildArchive.getId(), patChildArchiveDetail.getId());
            }
        } catch (Exception e) {
            log.error("妇幼随访计划重建失败,archiveId={},detailId={}",
            log.error("妇幼随访任务生成失败,archiveId={},detailId={}",
                    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
@@ -13,7 +13,7 @@
import com.smartor.mapper.PatMaternityArchiveMapper;
import com.smartor.service.IPatMaternityArchiveDetailService;
import com.smartor.service.IPatMaternityArchiveService;
import com.smartor.service.mch.IMchFollowupPlanService;
import com.smartor.service.mch.IMchFollowupSubtaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,7 +41,7 @@
    private PatMaternityArchiveDetailMapper patMaternityArchiveDetailMapper;
    @Autowired
    private IMchFollowupPlanService mchFollowupPlanService;
    private IMchFollowupSubtaskService mchFollowupSubtaskService;
    @Override
    public PatMaternityArchive selectPatMaternityArchiveById(Long id)
@@ -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,19 +232,73 @@
            patMaternityArchiveDetailService.insertPatMaternityArchiveDetail(patMaternityArchiveDetail);
        }
        // å¦‡å¹¼éšè®¿è®¡åˆ’:档案新增/修改后按 plannedFollowTime + followupPeriod é‡å»º
        // å¦‡å¹¼éšè®¿ä»»åŠ¡ï¼šåªæœ‰äººå·¥ç¡®è®¤ï¼ˆfollowup_status=1)的档案才生成/重建 service_subtask;
        // è‡ªåŠ¨å»ºæ¡£ä¸ºå¾…ç¡®è®¤ï¼ŒrebuildForArchive å†…部会直接跳过。
        try {
            if (mchFollowupPlanService != null) {
                mchFollowupPlanService.rebuildForArchive(
            if (mchFollowupSubtaskService != null) {
                mchFollowupSubtaskService.rebuildForArchive(
                        MchFollowupConstants.ARCHIVE_TYPE_MATERNITY,
                        patMaternityArchive.getId(), patMaternityArchiveDetail.getId());
            }
        } catch (Exception e) {
            log.error("妇幼随访计划重建失败,archiveId={},detailId={}",
            log.error("妇幼随访任务生成失败,archiveId={},detailId={}",
                    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
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java
@@ -6,8 +6,6 @@
import com.ruoyi.common.utils.sms.SmsUtils;
import com.ruoyi.system.service.ISysConfigService;
import com.smartor.common.MchFollowupConstants;
import com.smartor.domain.MchFollowupPlan;
import com.smartor.domain.MchFollowupPlanItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -19,7 +17,7 @@
 *
 * <p>短信复用 {@link SmsUtils#sendYunMasSms},微信复用
 * {@link SmsUtils#sendChatLs}(即 {@code /sms/sendChatFuyou} çš„内部实现)。
 * ä¸ç»è¿‡æ™®é€šéšè®¿çš„发送方工厂与补偿链路。</p>
 * å‘送上下文由 service_subtask + mch_node_json ç»„装。</p>
 */
@Slf4j
@Component
@@ -28,9 +26,9 @@
    @Autowired
    private ISysConfigService configService;
    public MchFollowupSendOutcome sendSms(MchFollowupPlan plan, MchFollowupPlanItem item) {
        String phone = plan == null ? null : plan.getPhone();
        String content = item == null ? null : renderContent(item.getContent(), plan, item);
    public MchFollowupSendOutcome sendSms(MchFollowupSendContext context) {
        String phone = context == null ? null : context.getPhone();
        String content = context == null ? null : renderContent(context.getContent(), context);
        if (StringUtils.isBlank(phone)) {
            return MchFollowupSendOutcome.skip("手机号为空");
        }
@@ -39,7 +37,7 @@
        }
        try {
            String configJson = configService.selectConfigByKey(
                    MchFollowupConstants.CONFIG_YUNMAS, plan.getOrgid());
                    MchFollowupConstants.CONFIG_YUNMAS, context.getOrgid());
            SmsUtils.YunMasConfig config = SmsUtils.YunMasConfig.of(configJson);
            SmsUtils.SmsResult result = SmsUtils.sendYunMasSms(config, phone, content);
            String requestBody = requestSummary("sms", phone, null);
@@ -50,34 +48,34 @@
            String message = result == null ? "云MAS返回为空" : result.getMessage();
            return MchFollowupSendOutcome.fail(message, requestBody, responseBody);
        } catch (Exception e) {
            log.error("【妇幼随访】短信发送异常,planId={},itemId={}", plan.getId(), item.getId(), e);
            log.error("【妇幼随访】短信发送异常,subtaskId={}", context == null ? null : context.getSeq(), e);
            return MchFollowupSendOutcome.fail("短信发送异常:" + e.getMessage(),
                    requestSummary("sms", phone, null), null);
        }
    }
    public MchFollowupSendOutcome sendWechat(MchFollowupPlan plan, MchFollowupPlanItem item) {
        String phone = plan == null ? null : plan.getPhone();
        if (StringUtils.isBlank(phone) && StringUtils.isBlank(plan == null ? null : plan.getIdcardno())) {
    public MchFollowupSendOutcome sendWechat(MchFollowupSendContext context) {
        String phone = context == null ? null : context.getPhone();
        if (context == null || (StringUtils.isBlank(phone) && StringUtils.isBlank(context.getIdcardno()))) {
            return MchFollowupSendOutcome.skip("手机号和证件号都为空");
        }
        try {
            String configJson = configService.selectConfigByKey(
                    MchFollowupConstants.CONFIG_LS_WX, plan.getOrgid());
                    MchFollowupConstants.CONFIG_LS_WX, context.getOrgid());
            SmsUtils.LsWxConfig config = SmsUtils.LsWxConfig.of(configJson);
            SmsUtils.LsWxMessage message = new SmsUtils.LsWxMessage();
            message.setId(item.getTemplateId());
            message.setPatientId(plan.getPatid() == null ? null : String.valueOf(plan.getPatid()));
            message.setPatientName(plan.getPatname());
            message.setIdCard(plan.getIdcardno());
            message.setId(context.getTemplateId());
            message.setPatientId(context.getPatid() == null ? null : String.valueOf(context.getPatid()));
            message.setPatientName(context.getPatname());
            message.setIdCard(context.getIdcardno());
            message.setMobile(phone);
            message.setMedCardNo(plan.getSourceBizNo());
            message.setTitleName(renderContent(item.getTitleName(), plan, item));
            message.setContent(renderContent(item.getContent(), plan, item));
            message.setUrl(item.getUrl());
            message.setMedCardNo(context.getSourceBizNo());
            message.setTitleName(renderContent(context.getTitleName(), context));
            message.setContent(renderContent(context.getContent(), context));
            message.setUrl(context.getUrl());
            String requestBody = requestSummary("wechat", phone, item.getTemplateId());
            String requestBody = requestSummary("wechat", phone, context.getTemplateId());
            String resp = SmsUtils.sendChatLs(config, message);
            String messageText = parseWechatMessage(resp);
            boolean ok = parseWechatOk(resp);
@@ -86,9 +84,9 @@
            }
            return MchFollowupSendOutcome.fail(messageText, requestBody, resp);
        } catch (Exception e) {
            log.error("【妇幼随访】微信发送异常,planId={},itemId={}", plan.getId(), item.getId(), e);
            log.error("【妇幼随访】微信发送异常,subtaskSeq={}", context == null ? null : context.getSeq(), e);
            return MchFollowupSendOutcome.fail("微信发送异常:" + e.getMessage(),
                    requestSummary("wechat", phone, item == null ? null : item.getTemplateId()), null);
                    requestSummary("wechat", phone, context == null ? null : context.getTemplateId()), null);
        }
    }
@@ -125,22 +123,22 @@
     * ${patname}、${patid}、${phone}、${idcardno}、${plannedFollowTime}、
     * ${sourceBizNo}、${archiveType}、${orgid}、${seq}。
     */
    String renderContent(String text, MchFollowupPlan plan, MchFollowupPlanItem item) {
        if (StringUtils.isBlank(text) || plan == null) {
    String renderContent(String text, MchFollowupSendContext context) {
        if (StringUtils.isBlank(text) || context == null) {
            return text;
        }
        String result = text;
        result = result.replace("${patname}", nvl(plan.getPatname()));
        result = result.replace("${patid}", plan.getPatid() == null ? "" : String.valueOf(plan.getPatid()));
        result = result.replace("${phone}", nvl(plan.getPhone()));
        result = result.replace("${idcardno}", nvl(plan.getIdcardno()));
        result = result.replace("${sourceBizNo}", nvl(plan.getSourceBizNo()));
        result = result.replace("${archiveType}", nvl(plan.getArchiveType()));
        result = result.replace("${orgid}", nvl(plan.getOrgid()));
        result = result.replace("${seq}", item == null || item.getSeq() == null ? "" : String.valueOf(item.getSeq()));
        if (plan.getPlannedFollowTime() != null) {
        result = result.replace("${patname}", nvl(context.getPatname()));
        result = result.replace("${patid}", context.getPatid() == null ? "" : String.valueOf(context.getPatid()));
        result = result.replace("${phone}", nvl(context.getPhone()));
        result = result.replace("${idcardno}", nvl(context.getIdcardno()));
        result = result.replace("${sourceBizNo}", nvl(context.getSourceBizNo()));
        result = result.replace("${archiveType}", nvl(context.getArchiveType()));
        result = result.replace("${orgid}", nvl(context.getOrgid()));
        result = result.replace("${seq}", context.getSeq() == null ? "" : String.valueOf(context.getSeq()));
        if (context.getPlannedFollowTime() != null) {
            result = result.replace("${plannedFollowTime}",
                    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(plan.getPlannedFollowTime()));
                    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(context.getPlannedFollowTime()));
        } else {
            result = result.replace("${plannedFollowTime}", "");
        }
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java
ÎļþÒÑɾ³ý
smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
ÎļþÒÑɾ³ý
smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
ÎļþÒÑɾ³ý
smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml
ÎļþÒÑɾ³ý
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/MchFollowupLogicCheck.java
ÎļþÒÑɾ³ý
smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
ÎļþÒÑɾ³ý
smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java
ÎļþÒÑɾ³ý
sql/mch_followup_plan_20261117.sql
ÎļþÒÑɾ³ý
sql/pat_mch_archive_followup_status_20261123.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,48 @@
-- =============================================================================
-- å¦‡å¹¼æ¡£æ¡ˆéšè®¿çŠ¶æ€ï¼šæŽ¥è¯Šå®Œæˆè‡ªåŠ¨å»ºæ¡£åªå†™å¾…ç¡®è®¤ï¼Œäººå·¥ä¿å­˜åŽå†ç”Ÿæˆéšè®¿ä»»åŠ¡
-- æ—¥æœŸï¼š2026-11-23
-- é€‚用:丽水市妇幼保健院妇幼专科档案(妇保/儿保)
-- è¯´æ˜Žï¼š
--   1. followup_status=0 å¾…确认:门诊接诊/住院随访自动建档,不生成 service_subtask;
--   2. followup_status=1 éšè®¿ä¸­ï¼šäººå·¥ä¿å­˜æ¡£æ¡ˆåŽå†™å…¥ï¼Œå…è®¸ç”Ÿæˆ/重建 service_subtask;
--   3. å­˜é‡æ•°æ®ä¸­å·²æœ‰æ‹Ÿéšè®¿æ—¶é—´å’Œéšè®¿å‘¨æœŸçš„æ¡£æ¡ˆå›žå¡«ä¸º 1,保持原有发送行为。
-- =============================================================================
ALTER TABLE pat_maternity_archive_detail
    ADD COLUMN followup_status CHAR(1) NOT NULL DEFAULT '0'
        COMMENT '随访状态:0待确认 1随访中' AFTER close_status,
    ADD COLUMN followup_confirm_time DATETIME NULL
        COMMENT '随访确认时间' AFTER followup_status,
    ADD COLUMN followup_confirm_by VARCHAR(64) NULL
        COMMENT '随访确认人' AFTER followup_confirm_time;
ALTER TABLE pat_child_archive_detail
    ADD COLUMN followup_status CHAR(1) NOT NULL DEFAULT '0'
        COMMENT '随访状态:0待确认 1随访中' AFTER close_status,
    ADD COLUMN followup_confirm_time DATETIME NULL
        COMMENT '随访确认时间' AFTER followup_status,
    ADD COLUMN followup_confirm_by VARCHAR(64) NULL
        COMMENT '随访确认人' AFTER followup_confirm_time;
-- å­˜é‡å›žå¡«ï¼šå·²æœ‰æ‹Ÿéšè®¿æ—¥æœŸå’Œéšè®¿å‘¨æœŸçš„æ¡£æ¡ˆç»§ç»­æŒ‰åŽŸé€»è¾‘ç”Ÿæˆ/发送。
-- ç¡®è®¤æ—¶é—´/确认人不回填,避免把迁移时间误当成人工确认时间。
UPDATE pat_maternity_archive_detail
SET followup_status = '1'
WHERE followup_status = '0'
  AND planned_follow_time IS NOT NULL
  AND followup_period IS NOT NULL
  AND followup_period <> '';
UPDATE pat_child_archive_detail
SET followup_status = '1'
WHERE followup_status = '0'
  AND planned_follow_time IS NOT NULL
  AND followup_period IS NOT NULL
  AND followup_period <> '';
-- è¡¥å»ºæ‰«æä¸Žåˆ—表过滤
ALTER TABLE pat_maternity_archive_detail
    ADD INDEX idx_maternity_followup_status (orgid, followup_status);
ALTER TABLE pat_child_archive_detail
    ADD INDEX idx_child_followup_status (orgid, followup_status);