package com.fjhx.task.controller;

import com.fjhx.stock.service.StockBackPlanService;
import com.fjhx.task.service.ScheduleTaskService;
import org.springblade.core.launch.BladeApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.PostConstruct;

@Configuration
@EnableScheduling
public class ScheduleTaskController {

    @Autowired
    private ScheduleTaskService scheduleTaskService;

    @Autowired
    private StockBackPlanService stockBackPlanService;

    /**
     * 定时推送id与工号不一致的信息
     */
    @Scheduled(cron = "0 0/10 * * * ?")
    private void stockAcceptActionTask() {
        if (BladeApplication.isLocalDev()) {
            return;
        }
        scheduleTaskService.stockAcceptActionTask();
    }

    /**
     * 同步领料信息
     */
    @Scheduled(cron = "30 0/19 * * * ?")
    private void schedulingTask() {
        if (BladeApplication.isLocalDev()) {
            return;
        }
        scheduleTaskService.schedulingTask();
    }

    /**
     * 获取排班面积
     */
    @Scheduled(cron = "0 0/5 * * * ?")
//    @PostConstruct
    private void getScheduleTask() {
        if (BladeApplication.isLocalDev()) {
            return;
        }
        stockBackPlanService.getScheduleTask(4);
    }

    /**
     * 统计排班数据
     */
    @Scheduled(cron = "30 0/5 * * * ?")
//    @PostConstruct
    private void statisticsScheduleDateTask() {
        if (BladeApplication.isLocalDev()) {
            return;
        }
        stockBackPlanService.statisticsScheduleDateTask(4);
    }

}
