From 84b79096372143c9f9ed5d91156a966f7d119c2b Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Wed, 02 Dec 2020 14:39:02 +0800
Subject: [PATCH] 修改获取五分钟数据无站点相关BUG

---
 src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java |   84 +++++++++++++++++++++++++++++++-----------
 1 files changed, 62 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
index 94f379e..155c822 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();
@@ -298,45 +304,42 @@
     public List<MonitorPoint> getMonitorPointsAndDevicesByRegion(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()))) {
-            //criteria.andEqualTo("organizationId", organizationId);
             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);
-        //���������������������������������
-        Iterator<MonitorPoint> iterator = monitorPoints.iterator();
-		/*while (iterator.hasNext()) {
-			MonitorPoint monitorPoint = iterator.next();
-			List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPoint.getId());
-			if (ObjectUtils.isEmpty(devices)) {
-				iterator.remove();
-			} else {
-				monitorPoint.setDevices(devices);
-			}
-			
-		}*/
-        Example deviceExample = new Example(Device.class);//���������
+
+        //������������������������
+        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);//���������
+
+        //������������������������
+        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())) {
@@ -344,6 +347,8 @@
                 }
             }
         }
+
+        //������������������������������������������
         Map<Integer, List<Device>> monitorDeviceMap = new HashMap();
         for (MonitorPoint m : monitorPointInfo) {
             List<Device> monitorDevices = new ArrayList<>();
@@ -354,6 +359,9 @@
             }
             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()) {
@@ -368,6 +376,33 @@
         }
         return monitorPoints;
     }
+
+    @Override
+    public List<MonitorPoint> getMonitorPointsByRegionAndOrgId(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);
+        return monitorPoints;
+    }
+
 
     @SuppressWarnings("unchecked")
     @Override
@@ -804,11 +839,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;
     }
 
@@ -822,5 +857,10 @@
         return monitorPointMapper.byIdGetMonitorPoint(id);
     }
 
+    @Override
+    public String getOrgIdByMac(String mac) {
+        return monitorPointMapper.getOrgIdByMac(mac);
+    }
+
 
 }

--
Gitblit v1.8.0