package com.ruoyi.rocketmq.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.rocketmq.domain.InitialSwitchOtherCollectData;
import com.ruoyi.rocketmq.service.IInitialSwitchOtherCollectDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 交换机系统其他信息采集数据Controller
 * 
 * @author gyt
 * @date 2025-09-23
 */
@RestController
@RequestMapping("/switchOtherData")
public class InitialSwitchOtherCollectDataController extends BaseController
{
    @Autowired
    private IInitialSwitchOtherCollectDataService initialSwitchOtherCollectDataService;

    /**
     * 查询交换机系统其他信息采集数据列表
     */
    @RequiresPermissions("rocketmq:switchOtherData:list")
    @GetMapping("/list")
    public TableDataInfo list(InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        startPage();
        List<InitialSwitchOtherCollectData> list = initialSwitchOtherCollectDataService.selectInitialSwitchOtherCollectDataList(initialSwitchOtherCollectData);
        return getDataTable(list);
    }

    /**
     * 导出交换机系统其他信息采集数据列表
     */
    @RequiresPermissions("rocketmq:switchOtherData:export")
    @Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        List<InitialSwitchOtherCollectData> list = initialSwitchOtherCollectDataService.selectInitialSwitchOtherCollectDataList(initialSwitchOtherCollectData);
        ExcelUtil<InitialSwitchOtherCollectData> util = new ExcelUtil<InitialSwitchOtherCollectData>(InitialSwitchOtherCollectData.class);
        util.exportExcel(response, list, "交换机系统其他信息采集数据数据");
    }

    /**
     * 获取交换机系统其他信息采集数据详细信息
     */
    @RequiresPermissions("rocketmq:switchOtherData:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(initialSwitchOtherCollectDataService.selectInitialSwitchOtherCollectDataById(id));
    }

    /**
     * 新增交换机系统其他信息采集数据
     */
    @RequiresPermissions("rocketmq:switchOtherData:add")
    @Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        return toAjax(initialSwitchOtherCollectDataService.insertInitialSwitchOtherCollectData(initialSwitchOtherCollectData));
    }

    /**
     * 修改交换机系统其他信息采集数据
     */
    @RequiresPermissions("rocketmq:switchOtherData:edit")
    @Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        return toAjax(initialSwitchOtherCollectDataService.updateInitialSwitchOtherCollectData(initialSwitchOtherCollectData));
    }

    /**
     * 删除交换机系统其他信息采集数据
     */
    @RequiresPermissions("rocketmq:switchOtherData:remove")
    @Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(initialSwitchOtherCollectDataService.deleteInitialSwitchOtherCollectDataByIds(ids));
    }
    /**
     * 图形监控交换机监控项基础信息
     */
    @RequiresPermissions("rocketmq:switchOtherData:list")
    @PostMapping("/getSwitchMonitorMsg")
    public AjaxResult getSwitchMonitorMsg(@RequestBody InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        Map list = initialSwitchOtherCollectDataService.getSwitchMonitorMsg(initialSwitchOtherCollectData);
        return success(list);
    }
    /**
     * 图形监控交换机设备CPU使用率
     */
    @RequiresPermissions("rocketmq:switchOtherData:list")
    @PostMapping("/getSwitchCpuUseMsg")
    public AjaxResult getSwitchCpuUseMsg(@RequestBody InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        Map<String, Object> echartsData = initialSwitchOtherCollectDataService.getSwitchCpuUseMsg(initialSwitchOtherCollectData);
        return success(echartsData);
    }
    /**
     * 图形监控交换机设备内存利用率
     */
    @RequiresPermissions("rocketmq:switchOtherData:list")
    @PostMapping("/getSwitchMemUseMsg")
    public AjaxResult getSwitchMemUseMsg(@RequestBody InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        Map<String, Object> echartsData = initialSwitchOtherCollectDataService.getSwitchMemUseMsg(initialSwitchOtherCollectData);
        return success(echartsData);
    }
    /**
     * 图形监控交换机设备系统功率
     */
    @RequiresPermissions("rocketmq:switchOtherData:list")
    @PostMapping("/getSwitchPowerMsg")
    public AjaxResult getSwitchPowerMsg(@RequestBody InitialSwitchOtherCollectData initialSwitchOtherCollectData)
    {
        Map<String, Object> echartsData = initialSwitchOtherCollectDataService.getSwitchPowerMsg(initialSwitchOtherCollectData);
        return success(echartsData);
    }
}
