package com.tofly.custom.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.custom.entity.dto.WisdomDisplayDto;
import com.tofly.custom.entity.vo.*;
import com.tofly.custom.service.CustomDisplayService;
import com.tofly.scada.entity.DeviceArchiveManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * @author JF
 * @date 2023-1-6
 * @description 自定义智慧综合展示相关
 */
@RestController
@RequestMapping("/customDisplay")
/*@AllArgsConstructor*/
@RefreshScope
@Api(tags = "自定义智慧综合展示")
public class CustomDisplayController {

    @Autowired
    private CustomDisplayService customDisplayService;

    /**
     * @param wisdomDisplayDto 自定义智慧综合展示筛选字段对象
     */
    @PostMapping("/viewDeviceIndex")
    @ApiOperation(value = "查询设备指标数据（设备分组）")
    public ResultRespone<List<DeviceArchiveManage>> viewDeviceIndex(WisdomDisplayDto wisdomDisplayDto) {
        try {
            return ResultRespone.success(customDisplayService.viewDeviceIndex(wisdomDisplayDto));
        } catch (Exception e) {
            e.printStackTrace();
            return ResultRespone.failed(e.getMessage());
        }
    }

    @PostMapping("/getScadaIndexData")
    @ApiOperation(value = "查询SCADA指标数据")
    public ResultRespone<List<ScadaIndexNewVo>> getScadaIndexData(WisdomDisplayDto dto){
        try {
            return ResultRespone.success(customDisplayService.getScadaIndexData(dto));
        }catch (Exception e){
            e.printStackTrace();
            return ResultRespone.failed(e.getMessage());
        }
    }


    @PostMapping("/getScadaHistoryData")
    @ApiOperation(value = "查询SCADA历史数据")

    public ResultRespone getHistoryPageData(Page page, WisdomDisplayDto dto){
        try {
            return ResultRespone.success(customDisplayService.getHistoryPageData(page,dto));
        }catch (Exception e){
            e.printStackTrace();
            return ResultRespone.failed(e.getMessage());
        }
    }
}
