package com.dcs.equipment.controller;

import com.dcs.common.core.domain.AjaxResult;
import com.dcs.equipment.domain.vo.DataTwinAlarmVO;
import com.dcs.equipment.domain.vo.DataTwinEquipmentVO;
import com.dcs.equipment.domain.vo.DataTwinInfluxDBVO;
import com.dcs.equipment.service.DataTwinService;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: wangpx
 * @date: 2025-05-06 09:01
 */
@Api(tags = "数字孪生模块")
@RestController
@RequestMapping("/datatwin")
public class DataTwinController {
    @Autowired
    private DataTwinService service;

    @GetMapping("/getEquipmentList")
    @ApiOperation(value = "获取设备列表", response = DataTwinEquipmentVO.class)
    public AjaxResult getEquipmentList() {
        return AjaxResult.success(service.getEquipmentList());
    }

    @GetMapping("/getTemperatureList")
    @ApiOperation(value = "获取温度数据", response = DataTwinInfluxDBVO.class)
    public AjaxResult getTemperatureList() {
        return AjaxResult.success(service.getTemperatureList());
    }

    @GetMapping("/getTemperatureByDay")
    @ApiOperation(value = "获取1天内温度数据", response = DataTwinInfluxDBVO.class)
    public AjaxResult getTemperatureByDay() {
        return AjaxResult.success(service.queryTemperatureByDay());
    }
    @GetMapping("/getTemperatureByWeek")
    @ApiOperation(value = "获取1周内温度数据", response = DataTwinInfluxDBVO.class)
    public AjaxResult getTemperatureByWeek() {
        return AjaxResult.success(service.queryTemperatureByWeek());
    }
    @GetMapping("/getTemperatureByMonth")
    @ApiOperation(value = "获取1月内温度数据", response = DataTwinInfluxDBVO.class)
    public AjaxResult getTemperatureByMonth() {
        return AjaxResult.success(service.queryTemperatureByMonth());
    }

    @GetMapping("/getDataByCode/{equipmentCode}")
    @ApiOperation(value = "根据设备编码获取数据", response = DataTwinInfluxDBVO.class)
    public AjaxResult getDataByCode(@PathVariable("equipmentCode") String equipmentCode) {
        return AjaxResult.success(service.getDataByCode(equipmentCode));
    }

    // 获取报警信息
    @GetMapping("/getAlarmList")
    @ApiOperation(value = "获取报警信息", response = DataTwinAlarmVO.class)
    public AjaxResult getAlarmList() {
        return AjaxResult.success(service.getAlarmList());
    }
}
