Commit b35c3bac authored by wujipeng's avatar wujipeng
Browse files

优化

parent 8e3facb1
......@@ -36,4 +36,10 @@ public class EquipmentController {
public Result getDeviceInfoList(@RequestBody EquipmentDTO equipmentDTO) {
return Result.success(equipmentService.getDeviceInfoList(equipmentDTO));
}
// @ApiOperation(value = "获取所有设备的最新一条数据")
// @PostMapping("/report/list")
// public Result getDeviceDataList() {
// return Result.success(equipmentService.getDeviceDataList());
// }
}
......@@ -5,6 +5,8 @@ import com.ruzhoukj.rx.pojo.vo.DeviceVO;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author 邬吉朋
*/
......@@ -12,4 +14,6 @@ import org.springframework.stereotype.Component;
public interface DeviceDao extends MongoRepository<DeviceEntity, String> {
DeviceVO findTopByDeviceIdOrderByTimestampDesc(String deviceId);
// List<DeviceVO> findtopOrderByTimestampDescgroupByDeviceId();
}
......@@ -28,25 +28,46 @@ public class DeviceEntity {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date timestamp;
@ApiModelProperty(value = "道路路面积水")
private double zu;
@ApiModelProperty(value = "窨井水位深度/管网液位")
private double zb;
@ApiModelProperty(value = "瞬时流速")
private double vj;
@ApiModelProperty(value = "瞬时流量")
private double q;
@ApiModelProperty(value = "总流量")
private double qa;
@ApiModelProperty(value = "正流量")
private double pqa;
@ApiModelProperty(value = "")
private double ph;
@ApiModelProperty(value = "")
private double cod;
@ApiModelProperty(value = "")
private double tn;
@ApiModelProperty(value = "")
private double cond;
@ApiModelProperty(value = "")
private double tp;
@ApiModelProperty(value = "负流量")
private double nqa;
@ApiModelProperty(value = "悬浮物(SS)")
private double tss;
@ApiModelProperty(value = "总雨量(mm)")
private double pt;
@ApiModelProperty(value = "5分钟内雨量(mm)")
private double pn05;
@ApiModelProperty(value = "电源电压")
private double vt;
@ApiModelProperty(value = "内置电池电压")
private double svt;
@ApiModelProperty(value = "遥测站状态及报警信息(见设备状态说明)")
private double zt;
@ApiModelProperty(value = "无线信号强度")
private double sin;
@ApiModelProperty(value = "主板温度")
private double tem;
@ApiModelProperty(value = "主板湿度")
private double hum;
}
......@@ -31,4 +31,10 @@ public interface EquipmentService extends IService<EquipmentEntity> {
* @return List<EquipmentVO>
*/
List<EquipmentVO> getDeviceInfoList(EquipmentDTO equipmentDTO);
// /**
// * 获取所有设备的最新一条数据
// * @return List<DeviceVO>
// */
// List<DeviceVO> getDeviceDataList();
}
......@@ -45,16 +45,33 @@ public class EquipmentServiceImpl
public List<EquipmentVO> getDeviceInfoList(EquipmentDTO equipmentDTO) {
List<EquipmentVO> deviceInfoList = baseMapper.getDeviceInfoList(equipmentDTO);
for (EquipmentVO equipmentVO : deviceInfoList) {
//判断设备类型,如果是水位传感器,则获取最新一条水位数据,并判断有没有超过阀值
if (equipmentVO.getType().equals(NumberConstant.ONE)) {
//判断有没有超过阀值
DeviceVO deviceVO = deviceDao.findTopByDeviceIdOrderByTimestampDesc(equipmentVO.getDeviceId());
if (equipmentVO.getType().equals(NumberConstant.ONE)) {
if (deviceVO != null && deviceVO.getZt() >= equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ONE);
} else if (deviceVO != null && deviceVO.getZt() < equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ZERO);
}
} else if (equipmentVO.getType().equals(NumberConstant.TWO)) {
if (deviceVO != null && deviceVO.getTss() >= equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ONE);
} else if (deviceVO != null && deviceVO.getTss() < equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ZERO);
}
} else if (equipmentVO.getType().equals(NumberConstant.THREE)) {
if (deviceVO != null && deviceVO.getVj() >= equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ONE);
} else if (deviceVO != null && deviceVO.getVj() < equipmentVO.getThresholdValue()) {
equipmentVO.setLiquidLevelStatus(NumberConstant.ZERO);
}
}
}
return deviceInfoList;
}
// @Override
// public List<DeviceVO> getDeviceDataList() {
// return deviceDao.findtopOrderByTimestampDescgroupByDeviceId();
// }
}
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