package com.njcn.csdevice.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.pojo.vo.LineOverLimitVO;
import com.njcn.csdevice.service.IOverLimitService;
import com.njcn.device.biz.mapper.OverLimitWlMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * pqs
 *
 * @author cdf
 * @date 2023/6/7
 */
@DS("sjzx")
@Service
@RequiredArgsConstructor
public class OverLimitServiceImpl extends ServiceImpl<OverLimitWlMapper, Overlimit> implements IOverLimitService {


    @Override
    public Overlimit getOverLimitDataById(String id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public LineOverLimitVO getLineOverLimitDataById(String id) {
        //根据监测点id查询所在监测点的限值表数据
        Overlimit overlimit = this.baseMapper.selectById(id);
        LineOverLimitVO lineOverLimitVO = new LineOverLimitVO();
        BeanUtil.copyProperties(overlimit, lineOverLimitVO);
        lineOverLimitVO.setOddHarm(overlimit.getUharm3());
        lineOverLimitVO.setEvenHarm(overlimit.getUharm2());
        lineOverLimitVO.setInUharm(overlimit.getInuharm1());
        lineOverLimitVO.setInUharm16(overlimit.getInuharm16());
        return lineOverLimitVO;
    }

}

