|
|
|
@ -1,13 +1,20 @@
|
|
|
|
|
package com.ruoyi.ems.base.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
import com.ruoyi.ems.base.domain.TreeSelects;
|
|
|
|
|
import com.ruoyi.ems.record.domain.TWTempertureData;
|
|
|
|
|
import com.ruoyi.ems.record.mapper.TWTempertureDataMapper;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.ruoyi.ems.base.mapper.EmsBaseMonitorInfoMapper;
|
|
|
|
@ -26,6 +33,8 @@ public class EmsBaseMonitorInfoServiceImpl implements IEmsBaseMonitorInfoService
|
|
|
|
|
@Autowired
|
|
|
|
|
private EmsBaseMonitorInfoMapper emsBaseMonitorInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TWTempertureDataMapper tWTempertureDataMapper;
|
|
|
|
|
/**
|
|
|
|
|
* 查询计量设备信息
|
|
|
|
|
*
|
|
|
|
@ -139,9 +148,50 @@ public class EmsBaseMonitorInfoServiceImpl implements IEmsBaseMonitorInfoService
|
|
|
|
|
* @return 树结构列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<EmsBaseMonitorInfo> buildMonitorInfoTree(List<EmsBaseMonitorInfo> baseMonitorInfos)
|
|
|
|
|
{
|
|
|
|
|
List<EmsBaseMonitorInfo> returnList = new ArrayList<EmsBaseMonitorInfo>();
|
|
|
|
|
public List<EmsBaseMonitorInfo> buildMonitorInfoTree(List<EmsBaseMonitorInfo> baseMonitorInfos) {
|
|
|
|
|
|
|
|
|
|
// 创建一个Map来存储温度数据,键为监控ID,值为TWTempertureData对象
|
|
|
|
|
Map<String, TWTempertureData> tempDataMap = new HashMap<>();
|
|
|
|
|
// 创建一个List来存储设备编号
|
|
|
|
|
List<String> monitorCodes = new ArrayList<>();
|
|
|
|
|
// 遍历设备列表
|
|
|
|
|
for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos) {
|
|
|
|
|
// 如果设备不为空且监控类型为1L
|
|
|
|
|
if (!ObjectUtils.isEmpty(baseMonitorInfo) && baseMonitorInfo.getMonitorType() == 1L) {
|
|
|
|
|
// 获取设备编号并添加到设备编号列表中
|
|
|
|
|
String monitorCode = baseMonitorInfo.getMonitorCode();
|
|
|
|
|
monitorCodes.add(monitorCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 如果设备编号列表不为空
|
|
|
|
|
if (CollectionUtils.isNotEmpty(monitorCodes)) {
|
|
|
|
|
// 根据设备编号列表查询最新的温度数据
|
|
|
|
|
List<TWTempertureData> tempDatas = tWTempertureDataMapper.selectLastTWTempertureDataByMonitorCodes(monitorCodes);
|
|
|
|
|
// 遍历查询到的温度数据
|
|
|
|
|
for (TWTempertureData tempData : tempDatas) {
|
|
|
|
|
// 如果温度数据和温度值不为空
|
|
|
|
|
if (!ObjectUtils.isEmpty(tempData) && tempData.getTempreture() != null) {
|
|
|
|
|
// 将温度数据存入Map中,键为监控ID,值为温度数据对象
|
|
|
|
|
tempDataMap.put(tempData.getMonitorId(), tempData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 再次遍历设备列表
|
|
|
|
|
for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos) {
|
|
|
|
|
// 如果设备不为空且监控类型为1L
|
|
|
|
|
if (!ObjectUtils.isEmpty(baseMonitorInfo) && baseMonitorInfo.getMonitorType() == 1L) {
|
|
|
|
|
// 根据设备ID从Map中获取对应的温度数据
|
|
|
|
|
TWTempertureData tempData = tempDataMap.get(baseMonitorInfo.getMonitorCode());
|
|
|
|
|
// 如果温度数据不为空
|
|
|
|
|
if (!ObjectUtils.isEmpty(tempData)) {
|
|
|
|
|
// 设置设备的温度值
|
|
|
|
|
baseMonitorInfo.setTemperature(tempData.getTempreture());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<EmsBaseMonitorInfo> returnList = new ArrayList<>();
|
|
|
|
|
List<Long> tempList = baseMonitorInfos.stream().map(EmsBaseMonitorInfo::getObjId).collect(Collectors.toList());
|
|
|
|
|
for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos)
|
|
|
|
|
{
|
|
|
|
|