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

import com.docus.server.collect.service.IHttpUserCollectService;
import com.docus.server.collect.service.ITaskConfigService;
import com.docus.server.sys.common.pojo.dto.UserDTO;
import com.docus.server.sys.service.IPowerUserService;
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 UserHttpCollectJob extends AbstractUserCollectJob {

    @Resource
    private final IHttpUserCollectService httpUserCollectService;

    public UserHttpCollectJob(IPowerUserService userService, ITaskConfigService taskConfigService, IHttpUserCollectService httpDeptCollectService) {
        super(userService, taskConfigService);
        this.httpUserCollectService = httpDeptCollectService;
    }

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

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


    @Override
    public List<UserDTO> getUsers(Date startDate, Date endDate, long pazeNum, long pageSize) {
        //需要根据不同医院去解析不同的内容。使用接口实现的方式。
        return httpUserCollectService.getUsers(startDate, endDate, pazeNum, pageSize);
    }
}
