package com.xhpc.order.tasks;

import com.xhpc.order.service.IXhpcPlaceholderOrderService;
import com.xhpc.order.service.IXhpcRealTimeOrderService;
import io.swagger.annotations.Api;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yuyang
 * @date 2022/10/20 14:30
 */
@EnableScheduling
@RestController
@RequestMapping("/scheduledTasks")
@Api(value = "定时任务接口", tags = "定时任务接口")
public class ScheduledTasks {

    @Resource
    IXhpcRealTimeOrderService xhpcRealTimeOrderService;
    @Resource
    IXhpcPlaceholderOrderService xhpcPlaceholderOrderService;


    //实时电流定时任务，每天下午2点,清除一个月半之前的数据
    @GetMapping("/orderCurrent")
    @Scheduled(cron = "0 0 14 * * ?")
    public void orderCurrent(){
        xhpcRealTimeOrderService.orderCurrent();
    }


    //实时电压定时任务，每天下午2点30,清除一个月半之前的数据
    @GetMapping("/orderVoltage")
    @Scheduled(cron = "0 30 14 * * ?")
    public void orderVoltage(){
        xhpcRealTimeOrderService.orderVoltage();
    }

    //实时soc定时任务，每天下午3点,清除一个月半之前的数据
    @GetMapping("/orderSoc")
    @Scheduled(cron = "0 0 15 * * ?")
    public void orderSoc(){
        xhpcRealTimeOrderService.orderSoc();
    }

    //实时充电数据定时任务，每天下午3.30点,清除一个月半之前的数据
    @GetMapping("/realTimeOrder")
    @Scheduled(cron = "0 30 15 * * ?")
    public void realTimeOrder(){
        xhpcRealTimeOrderService.realTimeOrder();
    }
    //充电结算订单报文定时任务，每天下午4点,清除一个月半之前的数据
    @GetMapping("/orderRedisRecord")
    @Scheduled(cron = "0 0 16 * * ?")
    public void orderRedisRecord(){
        xhpcRealTimeOrderService.orderRedisRecord();
    }
    //充电结算订单报文定时任务，每天下午4点30,清除一个月半之前的数据
    @GetMapping("/realTimeOrderBms")
    @Scheduled(cron = "0 30 16 * * ?")
    public void realTimeOrderBms(){
        xhpcRealTimeOrderService.realTimeOrderBms();
    }

    /**
     * 定时任务相同桩号，前一个订单已结束，本次订单响应结束
     */
   // @Scheduled(cron = "0 0/10 * * * ? ")
    public void getxhpcPlaceholderOrderTasks() {
        xhpcPlaceholderOrderService.getxhpcPlaceholderOrderTasks();
    }



    //定时清理推送订单数据保留
    //@Scheduled(cron = "0 0 11 * * ? ")
    public void deleteOrderCacheDate(){
        xhpcRealTimeOrderService.deleteOrderCacheDate();
    }





}
