diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java index b1589c39..d9016490 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java @@ -1,6 +1,7 @@ package com.zc.business.service.impl; import com.ruoyi.common.utils.DateUtils; +import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcMeteorologicalDetectorData; import com.zc.business.enums.UniversalEnum; import com.zc.business.mapper.DcMeteorologicalDetectorDataMapper; @@ -8,8 +9,10 @@ import com.zc.business.service.IDcMeteorologicalDetectorDataService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Map; +import javax.annotation.Resource; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 气象检测器数据Service业务层处理 @@ -22,7 +25,8 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica { @Autowired private DcMeteorologicalDetectorDataMapper dcMeteorologicalDetectorDataMapper; - + @Resource + private DcDeviceServiceImpl dcDeviceServiceImpl; /** * 查询气象检测器数据 @@ -113,7 +117,36 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica @Override public List selectlistAll(DcMeteorologicalDetectorData dcMeteorologicalDetectorData) { - return dcMeteorologicalDetectorDataMapper.selectlistAll(dcMeteorologicalDetectorData); + Map parameter =new HashMap<>(); + + parameter.put("deviceType","3"); + List dcDevices = dcDeviceServiceImpl.devicePileNumberQueryDevice(parameter); + Map deviceStateMap = dcDevices.stream() + .filter(Objects::nonNull) // DcDevice 对象不为空 + .collect(Collectors.toMap( + DcDevice::getIotDeviceId, + Function.identity(), + (existing, replacement) -> existing) // 重复键,默认保留第一个值 + ); + List dcMeteorologicalDetectorDataList = dcMeteorologicalDetectorDataMapper.selectlistAll(dcMeteorologicalDetectorData); + // 遍历气象检测数据并设置对应的设备状态和桩号 + for (DcMeteorologicalDetectorData data : dcMeteorologicalDetectorDataList) { + String iotDeviceId = data.getIotDeviceId(); + if (deviceStateMap.containsKey(iotDeviceId)) { + DcDevice device = deviceStateMap.get(iotDeviceId); + // 设置设备状态 + data.setDeviceState(device.getDeviceState()); + // 设置桩号 + data.setStakeMark(device.getStakeMark()); + } + } + + // 按照桩号排序 + List sortedList = dcMeteorologicalDetectorDataList.stream() + .sorted(Comparator.comparing(DcMeteorologicalDetectorData::getStakeMark)) + .collect(Collectors.toList()); + + return sortedList; } @Override diff --git a/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml index c04132fe..4adc7534 100644 --- a/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml @@ -200,27 +200,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"