package com.ruoyi.project.aspen.controller;

import java.util.List;

import com.ruoyi.project.aspen.domain.TDashboarddayelec;
import com.ruoyi.project.aspen.service.ITDashboarddayelecService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 电厂大屏每日0：00抓取数据Controller
 *
 * @author ruoyi
 * @date 2022-03-12
 */
@RestController
@RequestMapping("/aspen/dashboarddayelec")
public class TDashboarddayelecController extends BaseController
{
    @Autowired
    private ITDashboarddayelecService tDashboarddayelecService;

    /**
     * 查询电厂大屏每日0：00抓取数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TDashboarddayelec tDashboarddayelec)
    {
        startPage();
        List<TDashboarddayelec> list = tDashboarddayelecService.selectTDashboarddayelecList(tDashboarddayelec);
        return getDataTable(list);
    }

    /**
     * 导出电厂大屏每日0：00抓取数据列表
     */
    @Log(title = "电厂大屏每日0：00抓取数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDashboarddayelec tDashboarddayelec)
    {
        List<TDashboarddayelec> list = tDashboarddayelecService.selectTDashboarddayelecList(tDashboarddayelec);
        ExcelUtil<TDashboarddayelec> util = new ExcelUtil<TDashboarddayelec>(TDashboarddayelec.class);
        return util.exportExcel(list, "dashboarddayelec");
    }

    /**
     * 获取电厂大屏每日0：00抓取数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDashboarddayelecService.selectTDashboarddayelecById(id));
    }

    /**
     * 新增电厂大屏每日0：00抓取数据
     */
    @Log(title = "电厂大屏每日0：00抓取数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDashboarddayelec tDashboarddayelec)
    {
        return toAjax(tDashboarddayelecService.insertTDashboarddayelec(tDashboarddayelec));
    }

    /**
     * 修改电厂大屏每日0：00抓取数据
     */
    @Log(title = "电厂大屏每日0：00抓取数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDashboarddayelec tDashboarddayelec)
    {
        return toAjax(tDashboarddayelecService.updateTDashboarddayelec(tDashboarddayelec));
    }

    /**
     * 删除电厂大屏每日0：00抓取数据
     */
    @Log(title = "电厂大屏每日0：00抓取数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDashboarddayelecService.deleteTDashboarddayelecByIds(ids));
    }

    /**
     * 查询最后一条dashboard抓取数据
     */
    @GetMapping("/selectLast")
    public AjaxResult selectLast(TDashboarddayelec tDashboarddayelec)
    {
        TDashboarddayelec tDashboarddayelec1 = tDashboarddayelecService.selectLast(tDashboarddayelec);
        return AjaxResult.success(tDashboarddayelec1);
    }

    /**
     * 查询最近31条DASHBOARD每日抓取数据列表
     */
    @GetMapping("/month")
    public AjaxResult selectMonth(TDashboarddayelec tDashboarddayelec)
    {
        List<TDashboarddayelec> tDashboarddayelecs = tDashboarddayelecService.selectMonth(tDashboarddayelec);
        return AjaxResult.success(tDashboarddayelecs);
    }

    /**
     * 查询最近一周DASHBOARD每日抓取数据列表
     */
    @GetMapping("/week")
    public AjaxResult selectWeek(TDashboarddayelec tDashboarddayelec)
    {
        List<TDashboarddayelec> tDashboarddayelecs = tDashboarddayelecService.selectWeek(tDashboarddayelec);
        return AjaxResult.success(tDashboarddayelecs);
    }

    /**
     * 查询最近49天DASHBOARD每日抓取数据列表
     */
    @GetMapping("/fiftyday")
    public AjaxResult selecctfiftyday(TDashboarddayelec tDashboarddayelec)
    {
        List<TDashboarddayelec> selecctfiftyday = tDashboarddayelecService.selecctfiftyday(tDashboarddayelec);
        return AjaxResult.success(selecctfiftyday);
    }
}
