Commit bd2f99b8 authored by wujipeng's avatar wujipeng
Browse files

根据路段或设备名查询设备

parent 6b078298
package com.ruzhoukj.rx.common;
/**
* @author wujipeng
* @version 1.0
* @create 2024-06-06 9:16
*/
public class NumberConstant {
public static final Integer ONE = 1;
public static final Integer ZERO = 0;
public static final Integer SIX = 6;
public static final Integer TWO = 2;
public static final Integer FIVE = 5;
public static final Integer FOUR = 4;
public static final Integer THREE = 3;
}
package com.ruzhoukj.rx.pojo.vo;
import com.ruzhoukj.rx.pojo.entity.EquipmentEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -12,4 +13,7 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class EquipmentVO extends EquipmentEntity {
@ApiModelProperty(value = "液位状态 0:没超过阀值 1:超过阀值")
private Integer liquidLevelStatus;
}
package com.ruzhoukj.rx.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruzhoukj.rx.common.NumberConstant;
import com.ruzhoukj.rx.dao.DeviceDao;
import com.ruzhoukj.rx.dao.EquipmentDao;
import com.ruzhoukj.rx.pojo.dto.EquipmentDTO;
......@@ -36,6 +37,18 @@ public class EquipmentServiceImpl
@Override
public List<EquipmentVO> getDeviceInfoList(EquipmentDTO equipmentDTO) {
return baseMapper.getDeviceInfoList(equipmentDTO);
List<EquipmentVO> deviceInfoList = baseMapper.getDeviceInfoList(equipmentDTO);
for (EquipmentVO equipmentVO : deviceInfoList) {
//判断设备类型,如果是水位传感器,则获取最新一条水位数据,并判断有没有超过阀值
if (equipmentVO.getType().equals(NumberConstant.ONE)) {
DeviceVO deviceVO = deviceDao.findTopByDeviceIdOrderByTimestampDesc(equipmentVO.getDeviceId());
if (deviceVO != null && deviceVO.getZt() >= equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ONE);
} else if (deviceVO != null && deviceVO.getZt() < equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ZERO);
}
}
}
return deviceInfoList;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment