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

import com.docus.server.collect.service.IHttpTBasicCollectService;
import com.docus.server.collect.service.ITaskConfigService;
import com.docus.server.record.pojo.dto.TBasicDTO;
import com.docus.server.record.service.ITBasicService;
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 TBasicHttpCollectJob extends AbstractTBasicCollectJob {

    @Resource
    private final IHttpTBasicCollectService iHttpTBasicCollectService;

    public TBasicHttpCollectJob(ITBasicService deptService, ITaskConfigService taskConfigService, IHttpTBasicCollectService iHttpTBasicCollectService) {
        super(deptService, taskConfigService);
        this.iHttpTBasicCollectService = iHttpTBasicCollectService;
    }

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

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


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

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

        return iHttpTBasicCollectService.getTBasics(startDate, endDate, pazeNum, pageSize);
    }
}
