package com.docus.server.collect.job.dept;

import com.docus.server.collect.service.ITaskConfigService;
import com.docus.server.his.service.IHisService;
import com.docus.server.sys.common.pojo.dto.DeptDTO;
import com.docus.server.sys.service.IPowerDeptService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Component
public class DeptViewCollectJob extends AbstractDeptCollectJob {
    @Resource
    private final IHisService hisService;

    protected DeptViewCollectJob(IPowerDeptService deptService, ITaskConfigService taskConfigService, IHisService hisService) {
        super(deptService, taskConfigService);
        this.hisService = hisService;
    }

    /**
     * xxl jobhandler 手工执行，全量执行
     */
    @XxlJob("startAllDeptViewCollect")
    public void startAllDeptViewCollect() {
        super.startCollectAll(getJobParam());
    }


    /**
     * xxl jobhandler 配置定时启动，如果未完成任务跳过。增量收集
     */
    @XxlJob("startIncDeptViewCollect")
    public void startIncDeptViewCollect() {
        super.startCollectIncrement(getJobParam());
    }


    @Override
    public List<DeptDTO> getDepts(Date startDate, Date endDate, long pageNum, long pageSize) {

        //每家医院按照固定的格式写sql，不同医院需要替换不同的sql即可。
        return hisService.getDeptListView(startDate, endDate, pageNum, pageSize);
    }

}
