From a7b1117ea24c4ffd783c52a0685961eff95f049f Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Thu, 17 Dec 2020 15:49:48 +0800 Subject: [PATCH] UV风向工具类修改,根据时间段获取五分钟数据 --- src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 106 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java index 2df2138..54b5e3b 100644 --- a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java +++ b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java @@ -42,6 +42,7 @@ import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example.Criteria; @@ -275,6 +276,11 @@ } @Override + public List<MonitorPoint> getMonitorPointsByOrganizationIds(Set<Integer> orgIds) { + return monitorPointMapper.getMonitorPointsByOrganizationIds(orgIds); + } + + @Override public List<MonitorPoint> getMonitorPointsByRegion(Map<String, Object> parameters) { Example example = new Example(MonitorPoint.class); Criteria criteria = example.createCriteria(); @@ -294,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) { //������������ @@ -370,6 +383,89 @@ } return monitorPoints; } + + /** + * @Description: ��������������������������������������������� + * @Param: [parameters] + * @return: java.util.List<com.moral.entity.MonitorPoint> + * @Author: ������������ + * @Date: 2020/12/2 + */ + @Override + public List<MonitorPoint> getMonitorPointsAndDevicesByRegionNew(Map<String, Object> parameters) { + //������������ + Object organizationId = parameters.remove("organizationId"); + //���������������������null������������null���������������������������msgKey��������������� + ValidateUtil.notNull(organizationId, "param.is.null"); + ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null"); + + //������������������ + ParameterUtils.getRegionType4RegionCode(parameters); + + //������������code��������������� + Example example = new Example(MonitorPoint.class); + Criteria criteria = example.createCriteria(); + criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE); + + //������������������������������������������������������������orgid������������������������ + if (Constants.isNotSpecialOrgId(Integer.valueOf(organizationId.toString()))) { + Set<Integer> organizationIds = organizationService.getChildOrganizationIds(Integer.valueOf(organizationId.toString())); + criteria.andIn("organizationId", organizationIds); + } + 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; + } + @SuppressWarnings("unchecked") @Override @@ -806,11 +902,11 @@ //������������������������ List<Device> deviceList = deviceService.getDeviceById2(monitPointId); - params.put("longitudeCompany",monitorPoint.getLongitude()); - params.put("latitudeCompany",monitorPoint.getLatitude()); - params.put("latitudeCompany",monitorPoint.getLatitude()); - params.put("monitPointId",monitPointId); - params.put("deviceList",deviceList); + params.put("longitudeCompany", monitorPoint.getLongitude()); + params.put("latitudeCompany", monitorPoint.getLatitude()); + params.put("latitudeCompany", monitorPoint.getLatitude()); + params.put("monitPointId", monitPointId); + params.put("deviceList", deviceList); return params; } @@ -824,5 +920,10 @@ return monitorPointMapper.byIdGetMonitorPoint(id); } + @Override + public String getOrgIdByMac(String mac) { + return monitorPointMapper.getOrgIdByMac(mac); + } + } -- Gitblit v1.8.0