package com.njcn.harmonic.controller.pmsWifi;


import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.mapper.pmsWifi.PmsMonitorRealDataMapper;
import com.njcn.harmonic.pojo.po.pmsWifi.MonitorRealData;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 公共连接点母线电能质量统计 前端控制器
 * </p>
 *
 * @author cdf
 * @since 2024-08-15
 */
@RestController
@RequestMapping("/pmsWifi")
@RequiredArgsConstructor
public class PmsWifiController extends BaseController {

    private final PmsMonitorRealDataMapper pmsMonitorRealDataMapper;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/getPmsInfo")
    @ApiOperation("查询最新的一条电能质量数据")
    public HttpResult<MonitorRealData> getPmsInfo(@RequestParam String monitorId,@RequestParam String valueType) {
        String methodDescribe = getMethodDescribe("getPmsInfo");
        LambdaUpdateWrapper<MonitorRealData> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.eq(MonitorRealData::getValueType,valueType).eq(MonitorRealData::getLineId,monitorId);
        MonitorRealData monitorRealData = pmsMonitorRealDataMapper.selectOne(lambdaUpdateWrapper);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, monitorRealData, methodDescribe);
    }



}

