From 67a7a24b47d71dd843dd0b17c5cdf9f519e29d5d Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Tue, 30 Jun 2020 13:20:25 +0800
Subject: [PATCH] update大屏左侧站点设备查询优化及设备因子名称显示null问题

---
 src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java |  471 ++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 262 insertions(+), 209 deletions(-)

diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
index 3f1f427..0d68e94 100644
--- a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
@@ -17,15 +17,6 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.moral.mapper.DictionaryDataMapper;
-import com.moral.mapper.OrganizationMapper;
-import com.moral.service.HistoryHourlyService;
-import com.moral.util.MyLatLng;
-import com.moral.util.mapUtils;
-import org.apache.commons.collections.CollectionUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-
 import com.github.pagehelper.PageHelper;
 import com.moral.common.bean.Constants;
 import com.moral.common.bean.PageBean;
@@ -35,13 +26,22 @@
 import com.moral.common.util.StringUtils;
 import com.moral.common.util.ValidateUtil;
 import com.moral.entity.Device;
+import com.moral.entity.DeviceProperty;
 import com.moral.entity.MonitorPoint;
 import com.moral.mapper.DeviceMapper;
+import com.moral.mapper.DevicePropertyMapper;
+import com.moral.mapper.DictionaryDataMapper;
 import com.moral.mapper.MonitorPointMapper;
+import com.moral.mapper.OrganizationMapper;
 import com.moral.service.DeviceService;
+import com.moral.service.HistoryHourlyService;
 import com.moral.service.MonitorPointService;
 import com.moral.service.OrganizationService;
+import com.moral.util.MyLatLng;
+import com.moral.util.mapUtils;
 
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.stereotype.Service;
 import tk.mybatis.mapper.entity.Example;
 import tk.mybatis.mapper.entity.Example.Criteria;
 
@@ -60,28 +60,33 @@
 
     @Resource
     private DeviceService deviceService;
-    
+
     @Resource
     private OrganizationService organizationService;
 
     @Resource
     private HistoryHourlyService historyHourlyService;
-    
+
+    @Resource
+    DevicePropertyMapper devicePropertyMapper;
+
     private static Class ENTITY_CLASS = MonitorPoint.class;
+
     @Override
     public List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters) {
         ValidateUtil.notNull(parameters.get("areaName"), "param.is.null");
         return monitorPointMapper.getMonitorPointsByAreaName(parameters);
     }
+
     @Override
-    public List<MonitorPoint> queryWithStateByMap(Map<String, Object> params){
-        params.put("isDelete",Constants.IS_DELETE_FALSE);
+    public List<MonitorPoint> queryWithStateByMap(Map<String, Object> params) {
+        params.put("isDelete", Constants.IS_DELETE_FALSE);
         Object orgIdObj = params.get("orgId");
         List<MonitorPoint> monitorPointList = null;
-        if(orgIdObj != null) {
+        if (orgIdObj != null) {
             Integer orgId = Integer.parseInt(orgIdObj.toString());
             List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
-            params.put("orgIds",orgIds);
+            params.put("orgIds", orgIds);
             monitorPointList = monitorPointMapper.selectByMap(params);
 //            for(MonitorPoint monitorPoint:monitorPointList){
 //                Integer state = getStateFromRedis(monitorPoint.getId());
@@ -90,72 +95,76 @@
         }
         return monitorPointList == null ? new ArrayList<>() : monitorPointList;
     }
-    private Integer getStateFromRedis(Integer monitorPointId){
+
+    private Integer getStateFromRedis(Integer monitorPointId) {
         StringBuilder key = new StringBuilder();
         key.append("state_").append(monitorPointId).append("_*");
-        List<Map> stateList = redisUtils.getList(key.toString(),Map.class);
+        List<Map> stateList = redisUtils.getList(key.toString(), Map.class);
         int state = -1;
-        if(stateList!=null){
-            for (Map deviceState:stateList){
-                int s =  Integer.parseInt(deviceState.get("state").toString());
-                state = s>state&&s<4?s:state;
+        if (stateList != null) {
+            for (Map deviceState : stateList) {
+                int s = Integer.parseInt(deviceState.get("state").toString());
+                state = s > state && s < 4 ? s : state;
             }
         }
-        state = state==-1?4:state;
+        state = state == -1 ? 4 : state;
         return state;
     }
+
     @Override
     public PageBean queryByPageBean(PageBean pageBean) {
-        Example example = ExampleUtil.generateExample(ENTITY_CLASS,pageBean);
+        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
         List<Example.Criteria> criteriaList = example.getOredCriteria();
-        PageHelper.startPage(pageBean.getPageIndex(),pageBean.getPageSize());
+        PageHelper.startPage(pageBean.getPageIndex(), pageBean.getPageSize());
         List<MonitorPoint> monitorPointList = monitorPointMapper.selectWithAreaNameByExample(example);
         return new PageBean(monitorPointList);
     }
+
     @Override
-   public MonitorPoint queryWithRelationById(Integer id){
-         Example example = new Example(ENTITY_CLASS);
-         example.or().andEqualTo("id",id);
-         List<MonitorPoint> monitorPointList = monitorPointMapper.selectWithAreaNameByExample(example);
-         return monitorPointList!=null&&monitorPointList.size()>0?monitorPointList.get(0):null;
+    public MonitorPoint queryWithRelationById(Integer id) {
+        Example example = new Example(ENTITY_CLASS);
+        example.or().andEqualTo("id", id);
+        List<MonitorPoint> monitorPointList = monitorPointMapper.selectWithAreaNameByExample(example);
+        return monitorPointList != null && monitorPointList.size() > 0 ? monitorPointList.get(0) : null;
     }
+
     @Override
     public void addOrModify(MonitorPoint monitorPoint) {
-        try{
-            if(monitorPoint.getId()==null){
+        try {
+            if (monitorPoint.getId() == null) {
                 monitorPoint.setIsDelete(Constants.IS_DELETE_FALSE);
                 monitorPointMapper.insertSelective(monitorPoint);
-            }else{
+            } else {
                 MonitorPoint queryMonitorPoint = new MonitorPoint();
                 queryMonitorPoint.setId(monitorPoint.getId());
                 queryMonitorPoint.setOrganizationId(monitorPoint.getOrganizationId());
                 // num = 1,���������������,������������������������
-                Integer num =  monitorPointMapper.selectCount(queryMonitorPoint);
-                boolean needRefreshCach = (num!=1);
+                Integer num = monitorPointMapper.selectCount(queryMonitorPoint);
+                boolean needRefreshCach = (num != 1);
                 monitorPointMapper.updateByPrimaryKeySelective(monitorPoint);
-                if(needRefreshCach){
+                if (needRefreshCach) {
                     // ������������������������������ ���redis���������������
                     refreshDevicesInRedis(monitorPoint.getId());
                 }
             }
-        }
-        catch (Exception ex){
-            throw  ex;
+        } catch (Exception ex) {
+            throw ex;
         }
     }
+
     /*
       ������������������������������ ���redis���������������
      */
-    private void  refreshDevicesInRedis(int monitorPointId){
+    private void refreshDevicesInRedis(int monitorPointId) {
         Device queryDevice = new Device();
         queryDevice.setMonitorPointId(monitorPointId);
         List<Device> deviceList = deviceMapper.select(queryDevice);
-        if (!CollectionUtils.isEmpty(deviceList)){
+        if (!CollectionUtils.isEmpty(deviceList)) {
             List<Integer> orgIds = monitorPointMapper.selectOrganizationIds(monitorPointId);
-            if (!CollectionUtils.isEmpty(orgIds)){
-                deviceList.stream().forEach(dev ->{
-                    if(!StringUtils.isNullOrEmpty(dev.getMac())){
-                        String key = "device_"+dev.getMac();
+            if (!CollectionUtils.isEmpty(orgIds)) {
+                deviceList.stream().forEach(dev -> {
+                    if (!StringUtils.isNullOrEmpty(dev.getMac())) {
+                        String key = "device_" + dev.getMac();
 //                        // ��������������������� ������������redis
 //                        Device simpleDevice = new Device();
 //                        simpleDevice.setId(dev.getId());
@@ -164,147 +173,152 @@
 //                        simpleDevice.setMonitorPointId(dev.getMonitorPointId());
                         // ������������������������������������������������������������������
                         dev.setOrganizationIds(orgIds);
-                        redisUtils.set(key,dev);
+                        redisUtils.set(key, dev);
                     }
                 });
             }
         }
 
     }
+
     @Override
     public void deleteByIds(Integer... ids) {
         MonitorPoint monitorPoint = new MonitorPoint();
         monitorPoint.setIsDelete(Constants.IS_DELETE_TRUE);
-        if(ids!=null&&ids.length>0){
-            if(ids.length==1){
+        if (ids != null && ids.length > 0) {
+            if (ids.length == 1) {
                 monitorPoint.setId(ids[0]);
                 monitorPointMapper.updateByPrimaryKeySelective(monitorPoint);
-            }else{
+            } else {
                 Example example = new Example(ENTITY_CLASS);
                 example.or().andIn("id", Arrays.asList(ids));
-                monitorPointMapper.updateByExampleSelective(monitorPoint,example);
+                monitorPointMapper.updateByExampleSelective(monitorPoint, example);
             }
 
         }
     }
 
-	@Override
-	public List<MonitorPoint> getMonitorPointsByName(String name) {
-		Example example = new Example(MonitorPoint.class);
-		Criteria criteria = example.createCriteria();
+    @Override
+    public List<MonitorPoint> getMonitorPointsByName(String name) {
+        Example example = new Example(MonitorPoint.class);
+        Criteria criteria = example.createCriteria();
 
-		criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE).andLike("name", "%" + name + "%");
-		example.or().andEqualTo("isDelete", Constants.IS_DELETE_FALSE)
-				.andCondition("getPY(" + getReplaceStr("name") + ") like ", "%" + name + "%");
+        criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE).andLike("name", "%" + name + "%");
+        example.or().andEqualTo("isDelete", Constants.IS_DELETE_FALSE)
+                .andCondition("getPY(" + getReplaceStr("name") + ") like ", "%" + name + "%");
 
-		List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example);
-		return monitorPoints;
-	}
+        List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example);
+        return monitorPoints;
+    }
 
-	private String getReplaceStr(String name){
+    private String getReplaceStr(String name) {
         List<String[]> list = new ArrayList<String[]>();
-        list.add(new String[]{"���",""});
-        list.add(new String[]{"���",""});
+        list.add(new String[]{"���", ""});
+        list.add(new String[]{"���", ""});
         for (String[] string : list) {
-        	name = replace(name,string[0],string[1]);
-		}
-		return name;
-	}
-	
-	private  String replace(String name,String fromStr,String toStr){
-		return "REPLACE (" + name + ",'" + fromStr + "','" + toStr + "')";
-	}
+            name = replace(name, string[0], string[1]);
+        }
+        return name;
+    }
+
+    private String replace(String name, String fromStr, String toStr) {
+        return "REPLACE (" + name + ",'" + fromStr + "','" + toStr + "')";
+    }
 
     /**
-     *
      * @param idList
-     * @return  {id:,state:}
+     * @return {id:,state:}
      */
     @Override
     public List<Map<String, String>> queryMonitroPointsState(List<Integer> idList) {
-        List<Map<String, String>> list = idList.stream().map( id -> {
-           Integer state = getStateFromRedis(id);
-           Map<String,String> stateMap = new HashMap<>();
-           stateMap.put("id",id.toString());
-           stateMap.put("state",state.toString());
-           return stateMap;
+        List<Map<String, String>> list = idList.stream().map(id -> {
+            Integer state = getStateFromRedis(id);
+            Map<String, String> stateMap = new HashMap<>();
+            stateMap.put("id", id.toString());
+            stateMap.put("state", state.toString());
+            return stateMap;
         }).collect(Collectors.toList());
         return list;
     }
 
     /**
      * ������������������������������������
+     *
      * @param orgId
      * @return
      */
     @Override
-    public Integer countOfSubOrgs(@NotNull  Integer orgId){
+    public Integer countOfSubOrgs(@NotNull Integer orgId) {
         Example example = new Example(ENTITY_CLASS);
         //���������������������������
-        if(!dictionaryDataMapper.isSupperOrgId(orgId)){
+        if (!dictionaryDataMapper.isSupperOrgId(orgId)) {
             List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
-            example.or().andIn("organizationId",orgIds);
+            example.or().andIn("organizationId", orgIds);
         }
         return monitorPointMapper.selectCountByExample(example);
     }
-    @Override
-	public List<MonitorPoint> getMonitorPointsByOrganizationId(Integer orgId) {
-		Example example = new Example(MonitorPoint.class);
-		Criteria criteria = example.createCriteria();
-		
-		criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
-		if (Constants.isNotSpecialOrgId(orgId)) {
-			//criteria.andEqualTo("organizationId", orgId);
-			Set<Integer> organizationIds = organizationService.getChildOrganizationIds(orgId);
-			criteria.andIn("organizationId", organizationIds);
 
-		}
-		example.orderBy("name").asc();
-		return monitorPointMapper.selectByExample(example);
-	}
-	@Override
-	public List<MonitorPoint> getMonitorPointsByRegion(Map<String, Object> parameters) {
-		Example example = new Example(MonitorPoint.class);
-		Criteria criteria = example.createCriteria();
-		
-		criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
-		criteria.andEqualTo(parameters.get("name").toString(), parameters.get("value"));
-		return monitorPointMapper.selectByExample(example);
-	}
-	@Override
-    public List<Integer> queryVersionsById(Integer id){
-        return  monitorPointMapper.selectVersionsById(id);
+    @Override
+    public List<MonitorPoint> getMonitorPointsByOrganizationId(Integer orgId) {
+        Example example = new Example(MonitorPoint.class);
+        Criteria criteria = example.createCriteria();
+
+        criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
+        if (Constants.isNotSpecialOrgId(orgId)) {
+            //criteria.andEqualTo("organizationId", orgId);
+            Set<Integer> organizationIds = organizationService.getChildOrganizationIds(orgId);
+            criteria.andIn("organizationId", organizationIds);
+
+        }
+        example.orderBy("name").asc();
+        return monitorPointMapper.selectByExample(example);
     }
+
+    @Override
+    public List<MonitorPoint> getMonitorPointsByRegion(Map<String, Object> parameters) {
+        Example example = new Example(MonitorPoint.class);
+        Criteria criteria = example.createCriteria();
+
+        criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
+        criteria.andEqualTo(parameters.get("name").toString(), parameters.get("value"));
+        return monitorPointMapper.selectByExample(example);
+    }
+
+    @Override
+    public List<Integer> queryVersionsById(Integer id) {
+        return monitorPointMapper.selectVersionsById(id);
+    }
+
     @Override
     public MonitorPoint queryMonitorPointById(Integer mpointId) {
-        return  this.monitorPointMapper.selectByPrimaryKey(mpointId);
+        return this.monitorPointMapper.selectByPrimaryKey(mpointId);
     }
 
     @Override
-	public List<MonitorPoint> getMonitorPointsAndDevicesByRegion(Map<String, Object> parameters) {
-    	//������������
-		Object organizationId = parameters.remove("organizationId");
-		ValidateUtil.notNull(organizationId, "param.is.null");
-		ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
+    public List<MonitorPoint> getMonitorPointsAndDevicesByRegion(Map<String, Object> parameters) {
+        //������������
+        Object organizationId = parameters.remove("organizationId");
+        ValidateUtil.notNull(organizationId, "param.is.null");
+        ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
 
-		//������������������
-		ParameterUtils.getRegionType4RegionCode(parameters);
-		
-		Example example = new Example(MonitorPoint.class);
-		Criteria criteria = example.createCriteria();
-		criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
-		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()) {
+        //������������������
+        ParameterUtils.getRegionType4RegionCode(parameters);
+
+        Example example = new Example(MonitorPoint.class);
+        Criteria criteria = example.createCriteria();
+        criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
+        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)) {
@@ -313,67 +327,106 @@
 				monitorPoint.setDevices(devices);
 			}
 			
-		}
-		return monitorPoints;
-	}
+		}*/
+        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);
+        }
+        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());
+                    } else {
+                        iterator.remove();
+                    }
+                }
+            }
+        }
+        return monitorPoints;
+    }
 
     @SuppressWarnings("unchecked")
-	@Override
-	public Collection<Object> getDevicesStateByRegion(Map<String, Object> parameters) {
-    	//������������
-		Object organizationId = parameters.remove("organizationId");
-		ValidateUtil.notNull(organizationId, "param.is.null");
-		ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
+    @Override
+    public Collection<Object> getDevicesStateByRegion(Map<String, Object> parameters) {
+        //������������
+        Object organizationId = parameters.remove("organizationId");
+        ValidateUtil.notNull(organizationId, "param.is.null");
+        ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
 
-		//������������������
-		ParameterUtils.getRegionType4RegionCode(parameters);
-		
-		if (Constants.isNotSpecialOrgId(Integer.valueOf(organizationId.toString()))) {
-			Set<Integer> organizationIds = organizationService.getChildOrganizationIds(Integer.valueOf(organizationId.toString()));
-			parameters.put("orgIds", organizationIds);
-		}
-		List<Map<String, Object>> monitorPoints  = deviceMapper.getDevicesStateByRegion(parameters);
-		Map<String, Object> result = new HashMap<String, Object>();
-		Map<String,Object> device;
-		List<Map<String, Object>> devices;
-		for (Map<String, Object> map : monitorPoints) {
-			String id = map.get("id").toString();
+        //������������������
+        ParameterUtils.getRegionType4RegionCode(parameters);
 
-			device = new HashMap<String,Object>();
-			device.put("id", map.remove("deviceId"));
-			device.put("name", map.remove("deviceName"));
-			device.put("state", map.remove("state"));
-			device.put("mac", map.remove("mac"));
+        if (Constants.isNotSpecialOrgId(Integer.valueOf(organizationId.toString()))) {
+            Set<Integer> organizationIds = organizationService.getChildOrganizationIds(Integer.valueOf(organizationId.toString()));
+            parameters.put("orgIds", organizationIds);
+        }
+        List<Map<String, Object>> monitorPoints = deviceMapper.getDevicesStateByRegion(parameters);
+        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> device;
+        List<Map<String, Object>> devices;
+        for (Map<String, Object> map : monitorPoints) {
+            String id = map.get("id").toString();
 
-			if (result.containsKey(id)) {
-				Map<String, Object> monitorPoint = (Map<String, Object>) result.get(id);
-				devices = (List<Map<String, Object>>) monitorPoint.get("devices");
-			} else {
-				devices = new ArrayList<Map<String, Object>>();
-				result.put(id, map);
-			}
-			devices.add(device);
-			map.put("devices", devices);
-			result.put(id, map);
-		}
-		
-		return result.values();
-	}
-    
+            device = new HashMap<String, Object>();
+            device.put("id", map.remove("deviceId"));
+            device.put("name", map.remove("deviceName"));
+            device.put("state", map.remove("state"));
+            device.put("mac", map.remove("mac"));
+
+            if (result.containsKey(id)) {
+                Map<String, Object> monitorPoint = (Map<String, Object>) result.get(id);
+                devices = (List<Map<String, Object>>) monitorPoint.get("devices");
+            } else {
+                devices = new ArrayList<Map<String, Object>>();
+                result.put(id, map);
+            }
+            devices.add(device);
+            map.put("devices", devices);
+            result.put(id, map);
+        }
+
+        return result.values();
+    }
+
     @Override
     public void isCompensateCalculation(Map<String, Object> parameters) {
-		MonitorPoint monitorPoint = monitorPointMapper.selectByPrimaryKey(Integer.valueOf(parameters.get("monitorPointId").toString()));
-		if (Integer.valueOf(320581).equals(monitorPoint.getAreaCode())) {
-			parameters.put("compensate", true);
-		}
-    	
-	}
-	@Override
-	public Map<String, Object> selectAllById(String id) {
-		int id2 = Integer.parseInt(id);
-		Map<String, Object> map = monitorPointMapper.selectAllById(id2);
-		return map;
-	}
+        MonitorPoint monitorPoint = monitorPointMapper.selectByPrimaryKey(Integer.valueOf(parameters.get("monitorPointId").toString()));
+        if (Integer.valueOf(320581).equals(monitorPoint.getAreaCode())) {
+            parameters.put("compensate", true);
+        }
+
+    }
+
+    @Override
+    public Map<String, Object> selectAllById(String id) {
+        int id2 = Integer.parseInt(id);
+        Map<String, Object> map = monitorPointMapper.selectAllById(id2);
+        return map;
+    }
 
     @Override
     public List<Device> getDeviceList(int id) {
@@ -413,7 +466,7 @@
                 params.put("device3", device3);
                 for (Device device33 : device3) {
                     String mac3 = device33.getMac();
-                    String tvoc = historyHourlyService.getTVOCByMac(mac3, Time,sensor);
+                    String tvoc = historyHourlyService.getTVOCByMac(mac3, Time, sensor);
                     if (tvoc != null) {
                         workshop = Double.parseDouble(tvoc);
                     } else {
@@ -425,7 +478,7 @@
                 } else {
                     for (Device device11 : device1) {
                         String mac1 = device11.getMac();
-                        flue = Double.parseDouble(historyHourlyService.getTVOCByMac(mac1, Time,sensor));
+                        flue = Double.parseDouble(historyHourlyService.getTVOCByMac(mac1, Time, sensor));
                         if (workshop == 0.0) {
                             purificationRate = "���������������������������������������������������";
                         } else {
@@ -475,7 +528,7 @@
                         if (pressure2 != null) {
                             pressure = Double.parseDouble(pressure2);
                             list1.add(pressure);
-                        }else {
+                        } else {
                             collectionRate = "������������������������������������������������������������";
                         }
 
@@ -518,7 +571,7 @@
             List<Map> windList = new ArrayList<Map>();//���������������������������������������
             Map<String, Object> jsonMap = new HashMap<String, Object>();//���������������������
             Map<String, Object> deviceMap = null;
-            if (deviceList.size()>1){
+            if (deviceList.size() > 1) {
                 for (Device device : deviceList) {
                     deviceMap = new HashMap<String, Object>();
                     smac = device.getMac();
@@ -548,25 +601,25 @@
                         windDir = (JSONArray) JSONArray.toJSON(map.get("e23"));
                         JSONArray concentration = (JSONArray) JSONArray.toJSON(map.get(sensor));
 
-                        BigDecimal bigDecimal1=new BigDecimal(0);
-                        BigDecimal bigDecimal=new BigDecimal(0);
-                        if (concentration!=null){
-                            if (concentration.get(0) instanceof Integer){
-                                bigDecimal1 =new BigDecimal(concentration.get(0).toString());
-                            }else {
-                                bigDecimal1= (BigDecimal) concentration.get(0);
+                        BigDecimal bigDecimal1 = new BigDecimal(0);
+                        BigDecimal bigDecimal = new BigDecimal(0);
+                        if (concentration != null) {
+                            if (concentration.get(0) instanceof Integer) {
+                                bigDecimal1 = new BigDecimal(concentration.get(0).toString());
+                            } else {
+                                bigDecimal1 = (BigDecimal) concentration.get(0);
                             }
-                            if (windDir!=null){
-                                if (windDir.get(0) instanceof Integer){
-                                    bigDecimal =new BigDecimal(windDir.get(0).toString());
-                                }else {
-                                    bigDecimal=(BigDecimal) windDir.get(0);
+                            if (windDir != null) {
+                                if (windDir.get(0) instanceof Integer) {
+                                    bigDecimal = new BigDecimal(windDir.get(0).toString());
+                                } else {
+                                    bigDecimal = (BigDecimal) windDir.get(0);
                                 }
                                 mapDevice.put("e23", bigDecimal.doubleValue());
                                 mapDevice.put("sensor", bigDecimal1.doubleValue());
                                 mapDevice.put("longitude", objectMap.get("longitude"));
                                 mapDevice.put("latitude", objectMap.get("latitude"));
-                            }else {
+                            } else {
                                 mapDevice.put("noSensor", "���������������");
                                 mapDevice.put("longitude", objectMap.get("longitude"));
                                 mapDevice.put("latitude", objectMap.get("latitude"));
@@ -617,7 +670,7 @@
                 }
                 Double min = 0.0;
                 int indexMin = 0;
-                if (mapList.size()>0){
+                if (mapList.size() > 0) {
                     if (mapList.get(0).containsKey("diff")) {
                         min = (Double) mapList.get(0).get("diff");
                         for (int q = 1; q < mapList.size(); q++) {
@@ -691,8 +744,8 @@
 
                     Double length = mapUtils.getDistance((Double) preAngleDeviceList.get(0).get("longitude"), (Double) preAngleDeviceList.get(0).get("latitude"),
                             (Double) preAngleDeviceList.get(1).get("longitude"), (Double) preAngleDeviceList.get(1).get("latitude"));
-                    Double subLength = length/5;
-                    Double subLength1 = length/6.1;
+                    Double subLength = length / 5;
+                    Double subLength1 = length / 6.1;
                     Double angle = mapUtils.getAngle(
                             new MyLatLng((Double) preAngleDeviceList.get(0).get("longitude"),
                                     (Double) preAngleDeviceList.get(0).get("latitude")),
@@ -727,11 +780,11 @@
                 params.put("wind", wind);
                 //String preAngleDeviceString=preAngleDeviceList.
                 params.put("deviceList", deviceList);
-            }else {
-                if (deviceList.size()!=0){
+            } else {
+                if (deviceList.size() != 0) {
                     params.put("deviceList", deviceList.get(0));
-                }else {
-                    params.put("deviceList","");
+                } else {
+                    params.put("deviceList", "");
                 }
                 params.put("preAngleDeviceString", 1);
                 params.put("locationList", "");

--
Gitblit v1.8.0