package cn.cecep.talroad.task;

import cn.cecep.talroad.common.core.utils.DateUtils;
import cn.cecep.talroad.common.core.web.controller.BasesController;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.data.analyse.task.service.StationBuildingStatTaskService;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


@Api(tags = "站房统计")
@RestController
@RequestMapping("/station/building/task")
public class PcStationBuildingStatTaskController extends BasesController {

    @Autowired
    private StationBuildingStatTaskService stationBuildingStatTaskService;

    @ApiOperation(value = "日统计")
    @GetMapping("/day")
    public AjaxResults<Boolean> day() {
        Date lastDay = DateUtils.addDateDays(new Date(),-1);
        final DateTime endTime = DateUtil.endOfDay(lastDay);
        final DateTime startTime = DateUtil.beginOfDay(lastDay);
        return AjaxResults.success(stationBuildingStatTaskService.dayTask(startTime,endTime));
    }

}
