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.MeterYearDataVo;
import com.zksy.infrared.service.InfraredReadingMeterService;
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;

/**
 * @author Administrator
 * @version 1.0
 * @project dh-server-micro
 * @description 红外读电表
 * @date 2025/2/10 15:00:46
 */
@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);
    }
}
