package com.fuyuanshen.web.controller.device;

import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.equipment.domain.vo.AlarmInformationVo;
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
import com.fuyuanshen.equipment.domain.vo.EquipmentClassificationVo;
import com.fuyuanshen.equipment.service.DeviceService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * 首页数据
 *
 * @author: 默苍璃
 * @date: 2025-09-0113:46
 */
@Tag(name = "首页数据", description = "首页数据")
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/device/homepage")
public class HomePageController {

    private final DeviceService deviceService;


    /**
     * 获取 数据总览
     * DataOverview
     */
    @GetMapping("/getDataOverview")
    public R<DataOverviewVo> getDataOverview() {
        return R.ok(deviceService.getDataOverview());
    }


    /**
     * 获取 设备分类
     * DataOverview
     */
    @GetMapping("/getEquipmentClassification")
    public R<EquipmentClassificationVo> getEquipmentClassification() {
        return R.ok(deviceService.getEquipmentClassification());
    }


    /**
     * 获取 报警信息
     * DataOverview
     */
    @GetMapping("/getAlarmInformation")
    public R<AlarmInformationVo> getAlarmInformation() {
        return R.ok(deviceService.getAlarmInformation());
    }


    /**
     * 获取设备使用数据
     *
     * @param deviceTypeId 设备ID (可选)
     * @param range    时间范围 1:半年 2:一年
     * @return 每月使用数据列表
     */
    @GetMapping("/getEquipmentUsageData/{range}")
    public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Integer range,
                                                              @RequestParam(required = false) Long deviceTypeId) {
        return R.ok(deviceService.getEquipmentUsageData(deviceTypeId, range));
    }


}
