package com.docus.server.gdszy.job;

import com.docus.core.util.Func;
import com.docus.server.archive.mapper.TBasicMapper;
import com.docus.server.gdszy.service.GdSzyFileService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author YongBin Wen
 * @date 2024/7/12 15:22
 */

@Component
@Slf4j
public class YzyMergeJob {
    @Autowired
    private TBasicMapper tBasicMapper;

    @Autowired
    private GdSzyFileService gdSzyFileService;

    /**
     * 广东省中医院预住院文件合并根据文件表的更新时间 job
     *
     * @date 2024/9/26 9:49
     * @author YongBin Wen
     */
    @XxlJob("GdSzyYzyMergeJob")
    public void gdSzyYzyMergeJob() {
        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>广东省中医院，预住院患者文件合并，开始任务！");
        try {
            List<String> yzyPatientIds = tBasicMapper.getYzyPatientIdFromScanAssort();
            log.info("文件表 查询到：{} 个预住院患者！", yzyPatientIds.size());
            if (Func.isNotEmpty(yzyPatientIds)) {
                gdSzyFileService.yzyReportMerge(yzyPatientIds);
            }
            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>广东省中医院，预住院患者文件合并，结束任务！");
        } catch (Exception ex) {
            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>广东省中医院，预住院患者文件合并，任务异常！" + ex.getMessage(), ex);
        }
    }

}
