package com.zksy.infrared.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zksy.common.core.domain.Result;
import com.zksy.common.utils.SearchUtil;
import com.zksy.infrared.domain.InfraredReadingMeter;
import com.zksy.infrared.domain.vo.MeterDayDataVo;
import com.zksy.infrared.domain.vo.MeterMonthDataVo;
import com.zksy.infrared.domain.vo.MeterQuarterDataVo;
import com.zksy.infrared.domain.vo.MeterYearDataVo;
import com.zksy.infrared.service.InfraredReadingMeterService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @version 1.0
 * @project dh-server-micro
 * @description 红外读电表
 * @date 2025/2/10 15:00:46
 */
@Api(tags = "红外电表信息",description = "红外电表信息desc")
@RequestMapping("/infraredReadingMeter")
@RestController
public class InfraredReadingMeterController {
    @Autowired
    private InfraredReadingMeterService service;

    @GetMapping("/findByPage")
    @ApiOperation(value = "分页查询")
    public Result getMinuteDataPage(long pageNum, long pageSize, String conditionJson) throws Exception {
        Page<InfraredReadingMeter> page = service.page(new Page<>(pageNum, pageSize), SearchUtil.parseWhereSql(conditionJson));
        return Result.ok(page);
    }
    @GetMapping("/getAll")
    @ApiOperation(value = "查询所有")
    public Result getAllByConditionJson(String conditionJson) throws Exception {
        List<InfraredReadingMeter> list = service.list(SearchUtil.parseWhereSql(conditionJson));
        return Result.ok(list);
    }

    @GetMapping("/selectByYearAndMonthData")
    @ApiOperation(value = "根据年查询")
    public Result selectByYearAndMonthData(Integer year,String meterNumber){
        MeterYearDataVo vo = service.selectByYear(year,meterNumber);
        return Result.ok(vo);
    }

    @GetMapping("/selectByYearAndMonthWithDayData")
    @ApiOperation(value = "根据年和月查询")
    public Result selectByYearAndMonthWithDayData(Integer year,Integer month,String meterNumber){
        MeterMonthDataVo vo = service.selectByYearselectByYearAndMonthWithDayData(year,month,meterNumber);
        return Result.ok(vo);
    }

    @GetMapping("/selectTodayNewestData")
    @ApiOperation(value = "查询今天最新数据")
    public Result selectTodayNewestData(String meterNumber){
        MeterDayDataVo vo = service.selectByNewestData(meterNumber);
        return Result.ok(vo);
    }

    @GetMapping("/selectByCurrentYearData")
    @ApiOperation(value = "根据当前年份查询数据")
    public Result selectByYearData(){
        MeterYearDataVo vo=service.selectByCurrentYearData();
        return Result.ok(vo);
    }

    @GetMapping("/selectByCurrentSeasonData")
    @ApiOperation(value = "根据当前季度查询数据")
    public Result selectBySeasonData(){
        MeterQuarterDataVo vo=service.selectByCurrentQuarterData();
        return Result.ok(vo);
    }

    @GetMapping("/selectByCurrentMouthData")
    @ApiOperation(value = "根据当前所在月份查询数据")
    public Result selectByMouthData(){
        MeterMonthDataVo vo=service.selectByCurrentYearselectByCurrentYearAndCurrentMonthWithDayData();
        return Result.ok(vo);
    }

    @GetMapping("/dailyAndTotalMap")
    @ApiOperation(value = "电表分组查询")
    public List<Map<String, Object>> getDailyAndTotalElectricityAsMap() {
        return service.getDailyAndTotalElectricityAsMap();
    }
}
