From dcf1385a88fdf517e2cc60b50ea2e0a30e5652ca Mon Sep 17 00:00:00 2001 From: kaiyu <404897439@qq.com> Date: Wed, 02 Dec 2020 15:06:26 +0800 Subject: [PATCH] 更改获取五分钟数据结构BUG --- src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java | 65 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java index 155c822..54b5e3b 100644 --- a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java +++ b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java @@ -300,6 +300,13 @@ return this.monitorPointMapper.selectByPrimaryKey(mpointId); } + /** + * @Description: ������������������������������������������������ + * @Param: [parameters] + * @return: java.util.List<com.moral.entity.MonitorPoint> + * @Author: ������������ + * @Date: 2020/12/2 + */ @Override public List<MonitorPoint> getMonitorPointsAndDevicesByRegion(Map<String, Object> parameters) { //������������ @@ -377,8 +384,15 @@ return monitorPoints; } + /** + * @Description: ��������������������������������������������� + * @Param: [parameters] + * @return: java.util.List<com.moral.entity.MonitorPoint> + * @Author: ������������ + * @Date: 2020/12/2 + */ @Override - public List<MonitorPoint> getMonitorPointsByRegionAndOrgId(Map<String, Object> parameters) { + public List<MonitorPoint> getMonitorPointsAndDevicesByRegionNew(Map<String, Object> parameters) { //������������ Object organizationId = parameters.remove("organizationId"); //���������������������null������������null���������������������������msgKey��������������� @@ -400,6 +414,55 @@ } criteria.andEqualTo(parameters.get("regionType") + "Code", parameters.remove("regionCode")); List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example); + + //������������������������ + Example deviceExample = new Example(Device.class); + Criteria deviceCriteria = deviceExample.createCriteria(); + deviceCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE); + List<Device> devicesInfo = deviceMapper.selectByExample(deviceExample); + + //������������������������ + Example monitorExample = new Example(MonitorPoint.class); + Criteria monitorCriteria = monitorExample.createCriteria(); + monitorCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE); + List<MonitorPoint> monitorPointInfo = monitorPointMapper.selectByExample(monitorExample); + + //������������������������������ + List<DeviceProperty> devicePropertyList = devicePropertyMapper.selectAll(); + + //������������������������������������������ + for (Device d : devicesInfo) { + for (DeviceProperty dp : devicePropertyList) { + if (dp.getId().equals(d.getId())) { + d.setDeviceProperty(dp); + } + } + } + + //������������������������������������������ + Map<Integer, List<Device>> monitorDeviceMap = new HashMap(); + for (MonitorPoint m : monitorPointInfo) { + List<Device> monitorDevices = new ArrayList<>(); + for (Device d : devicesInfo) { + if (m.getId().equals(d.getMonitorPointId())) { + monitorDevices.add(d); + } + } + monitorDeviceMap.put(m.getId(), monitorDevices); + } + + //������������Code��������������������������������������������� + Iterator<MonitorPoint> iterator = monitorPoints.iterator(); + while (iterator.hasNext()) { + MonitorPoint monitorPoint = iterator.next(); + for (Map.Entry<Integer, List<Device>> entry : monitorDeviceMap.entrySet()) { + if (monitorPoint.getId().equals(entry.getKey())) { + if (!CollectionUtils.isEmpty(entry.getValue())) { + monitorPoint.setDevices(entry.getValue()); + } + } + } + } return monitorPoints; } -- Gitblit v1.8.0