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

import com.docus.server.collect.service.IHttpDeptCollectService;
import com.docus.server.collect.service.ITaskConfigService;
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 DeptHttpCollectJob extends AbstractDeptCollectJob {

    @Resource
    private final IHttpDeptCollectService httpDeptCollectService;

    public DeptHttpCollectJob(IPowerDeptService deptService, ITaskConfigService taskConfigService, IHttpDeptCollectService httpDeptCollectService) {
        super(deptService, taskConfigService);
        this.httpDeptCollectService = httpDeptCollectService;
    }

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

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


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

        //需要根据不同医院去解析不同的内容。使用接口实现的方式。

        return httpDeptCollectService.getDepts(startDate, endDate, pazeNum, pageSize);
    }
}
