陈昶聿
4 天以前 b65c4cdd68b72771634fcfd52709edfd77d7abc6
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -150,6 +150,9 @@
    IServiceSubtaskDetailTraceService serviceSubtaskDetailTraceService;
    @Autowired
    IPatMedOuthospService patMedOuthospService;
    @Autowired
    ISvyTaskTemplateService svyTaskTemplateService;
    @Autowired
@@ -181,6 +184,21 @@
    private String active;
    @Autowired
    private SysConfigMapper sysConfigMapper;
    @Autowired
    private IServiceTaskScheduleService serviceTaskScheduleService;
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
        System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
    }
    public void ryParams(String params) {
        System.out.println("执行有参方法:" + params);
    }
    public void ryNoParams() {
        System.out.println("执行无参方法");
    }
    public void importData() {
        String filePath = "C:\\Users\\86176\\Desktop\\新建文本文档 4.txt"; // 替换为你的文件路径
@@ -617,13 +635,31 @@
        ServiceSLTDInhospReqVO serviceSLTDInhospReqVO = new ServiceSLTDInhospReqVO();
        serviceSLTDInhospReqVO.setOrgId("20001001");
        Long outpPage = 1L;
        int totalCount = 0;  // 统计总共采集的药品数量
        while (true) {
            serviceSLTDInhospReqVO.setCurrent(outpPage);
            serviceSLTDInhospReqVO.setSize(OUTP_PAGE_SIZE);
            log.info("【dealHisData】省立同德“药品数据”采集第{}页数据", outpPage);
            Boolean b = serviceSLTDHealthcareRecordService.queryMedicationItemList(serviceSLTDInhospReqVO);
            log.info("【dealHisData】省立同德“药品数据”采集结果:{}", b);
            outpPage++;
            log.info("【dealHisData】省立同德\"药品数据\"采集第{}页数据", outpPage);
            try {
                Integer fetchedCount = serviceSLTDHealthcareRecordService.queryMedicationItemList(serviceSLTDInhospReqVO);
                log.info("【dealHisData】省立同德\"药品数据\"第{}页采集到{}条记录", outpPage, fetchedCount);
                totalCount += fetchedCount != null ? fetchedCount : 0;
                // 如果返回的数据量小于 pageSize,说明已经是最后一页了,退出循环
                if (fetchedCount == null || fetchedCount < OUTP_PAGE_SIZE) {
                    log.info("【dealHisData】省立同德\"药品数据\"采集完成,总页数:{}, 总计{}条记录", outpPage, totalCount);
                    break;
                }
                outpPage++;
            } catch (Exception e) {
                log.error("【dealHisData】省立同德\"药品数据\"第{}页采集失败", outpPage, e);
                // 出错时也可以选择退出或继续,这里选择退出避免无限重试
                break;
            }
        }
    }
@@ -668,7 +704,7 @@
    public void dealHisData2() {
        //将患者信息、出入院数据全部采集
        // 指定的开始日期
        LocalDate endDate = LocalDate.of(2025, 3, 3);
        LocalDate endDate = LocalDate.of(2026, 7, 6);
        // 当前日期
        LocalDate currentDate = LocalDate.now();
        // 定义日期格式
@@ -699,17 +735,17 @@
    }
    /**
     * 处理患者信息,进入子任务表
     * 处理患者信息,进入子任务表(任务组)
     */
    public void dealOutHospInfoByDimension() {
    public void dealOutHospInfoBySchedule() {
        String config = configService.selectConfigByKey("visit.early.day");
        if (port.equals("8095")) {
            //出院表
            iPatMedInhospService.dealOutHospInfoByDimension(config);
            iPatMedInhospService.dealOutHospInfoBySchedule(config);
            //门诊表(新华的暂时不做门诊随访)
            if (!active.equals("xh")) {
                //iPatMedOuthospService.dealOutpatientInfo();
            }
//            if (!active.equals("xh")) {
//                //iPatMedOuthospService.dealOutpatientInfo();
//            }
        }
    }
@@ -1334,7 +1370,7 @@
                    serviceSubtask.setSendstate(7L);
                    serviceSubtask.setFinishtime(null);
                    log.error("getSendPreachform方法 检查是否所有sendstate不等于9, 全失败了");
                    serviceSubtask.setRemark(StringUtils.isNotEmpty(serviceSubtask.getRemark()) ? serviceSubtask.getRemark() + "," + "所有发送方式均未获取结果,任务失败(超时)" : "所有发送方式均未获取结果,任务失败(超时)");
                    serviceSubtask.setRemark(StringUtils.isNotEmpty(serviceSubtask.getRemark()) ? serviceSubtask.getRemark() + "," + "所有执行方式均未获取结果,任务失败(超时)" : "所有执行方式均未获取结果,任务失败(超时)");
                    serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                    //修改发送状态
                    setFail(serviceSubtaskPreachforms, serviceSubtask);
@@ -1603,4 +1639,43 @@
        int result = QwenLLMUtil.matchRegex(questionText, voiceText, value, regexText);
        return result;
    }
    /**
     * 任务组(appltype=5)首轮纳入:扫描新出院患者,按 schedule 绑定的维度匹配任务组,
     * 为命中的患者按计划明细一次性生成第 0 轮 N 条 subtask,并置 schedulecheck_flag=1。
     * 后续轮次由 {@link #rollTaskGroupCycle()} 负责。
     * <p>
     * 与主扫描 dealOutHospInfo 分离,互不干扰。建议每 30 分钟执行一次。
     */
    public void dealTaskGroupOutHosp() {
        log.info("【dealTaskGroupOutHosp】开始扫描任务组新出院患者");
        if (!port.equals("8095")) {
            return;
        }
        try {
            String config = configService.selectConfigByKey("visit.early.day");
            iPatMedInhospService.dealOutHospInfoBySchedule(config);
            log.info("【dealTaskGroupOutHosp】任务组首轮纳入扫描完成");
        } catch (Exception e) {
            log.error("【dealTaskGroupOutHosp】任务组扫描异常", e);
        }
    }
    /**
     * 任务组(appltype=5)循环任务滚动调度。
     * <p>
     * 扫描所有 schedule_style=1 的计划,若本轮 subtask 全部 finalize(sendstate ∉ 1/2/3),
     * 则克隆本轮患者到下一轮,推进 current_loop_count 与 visit_time。
     * <p>
     * 建议每小时或每半小时执行一次,避免轮次积压。
     */
    public void rollTaskGroupCycle() {
        log.info("【rollTaskGroupCycle】开始扫描循环任务组");
        try {
            int rolled = serviceTaskScheduleService.rollCycleTasks();
            log.info("【rollTaskGroupCycle】本次推进 {} 个计划", rolled);
        } catch (Exception e) {
            log.error("【rollTaskGroupCycle】滚动调度异常", e);
        }
    }
}