package com.ruoyi.quartz.task;

import com.ruoyi.excel.wecom.helper.HandleAllData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component("wecomTask")
public class WeComTask {
    @Autowired
    private HandleAllData handleAllData;
    public void initData() throws IOException {
        System.out.println("初始化项目数据 包括 部门 人员");
        handleAllData.initData();
    }

    public void getCustomerData() throws IOException {
        System.out.println("抓取企业微信客户数据");
        handleAllData.handleAllData();
    }

    public void createAllCustomerReport() throws IOException {
        System.out.println("计算所有流量看板数据");
        handleAllData.createAllReportData();
    }

    public void createAllDepartmentReportData() throws IOException {
        System.out.println("计算所有流量看板数据");
        handleAllData.createAllDepartmentReportData();
    }

    public void createCurDateCustomerReport() throws IOException {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = simpleDateFormat.format(date);
        System.out.println("计算" + dateStr + "流量看板数据");
        handleAllData.createReportData(new Date(dateStr));
    }

    public void createCurDateDepartmentReportData() throws IOException {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = simpleDateFormat.format(date);
        System.out.println("计算" + dateStr + "销售看板数据");
        handleAllData.createDepartmentReportData(new Date(simpleDateFormat.format(date)));
    }
}
