From f718fb9c06fa75b65870a3f5ef2fea10054009aa Mon Sep 17 00:00:00 2001
From: 于紫祥_1901 <email@yuzixiang_1910>
Date: Wed, 12 Aug 2020 09:31:26 +0800
Subject: [PATCH] 风场图

---
 src/main/resources/mapper/DeviceMapper.xml                        |  746 +++++++++++++++++++-----------------
 src/main/java/com/moral/entity/DeviceAndWind.java                 |   64 +++
 src/main/webapp/view/newUnorganizedMap.jsp                        |   13 
 pom.xml                                                           |   18 
 src/main/java/com/moral/service/impl/DeviceServiceImpl.java       |  188 +++++++++
 src/main/java/com/moral/mapper/MonitorPointMapper.java            |    1 
 src/main/java/com/moral/service/DeviceService.java                |   11 
 src/main/webapp/view/unorganizedMap.jsp                           |    2 
 src/main/resources/mapper/MonitorPointMapper.xml                  |    3 
 src/main/java/com/moral/mapper/DeviceMapper.java                  |   13 
 src/main/java/com/moral/service/MonitorPointService.java          |    3 
 src/main/java/com/moral/webSocketServer/WebSocketServerNew.java   |    7 
 src/main/java/com/moral/service/impl/OrganizationServiceImpl.java |    5 
 src/main/java/com/moral/controller/ScreenController.java          |   95 +++
 src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java |    5 
 15 files changed, 781 insertions(+), 393 deletions(-)

diff --git a/pom.xml b/pom.xml
index 6642f1f..6ec9b1f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,12 +41,28 @@
 	</repositories>
 
 	<dependencies>
+		<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
+		<dependency>
+			<groupId>com.google.code.gson</groupId>
+			<artifactId>gson</artifactId>
+			<version>2.8.5</version>
+		</dependency>
+
+
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter</artifactId>
 		</dependency>
 
-        <dependency>
+		<!-- https://mvnrepository.com/artifact/org.json/json -->
+		<dependency>
+			<groupId>org.json</groupId>
+			<artifactId>json</artifactId>
+			<version>20160810</version>
+		</dependency>
+
+
+		<dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java
index 566eb6d..a4d4a42 100644
--- a/src/main/java/com/moral/controller/ScreenController.java
+++ b/src/main/java/com/moral/controller/ScreenController.java
@@ -1,9 +1,7 @@
 package com.moral.controller;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
+import java.lang.reflect.Array;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
@@ -17,7 +15,9 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+
 import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
 import com.googlecode.aviator.AviatorEvaluator;
 import com.googlecode.aviator.Expression;
 import com.moral.common.bean.Constants;
@@ -29,15 +29,7 @@
 import com.moral.common.util.ValidateUtil;
 import com.moral.common.util.WebUtils;
 import com.moral.common.xml.Version;
-import com.moral.entity.Account;
-import com.moral.entity.AreaNames;
-import com.moral.entity.Device;
-import com.moral.entity.DeviceVersion;
-import com.moral.entity.MapBounds;
-import com.moral.entity.MonitorPoint;
-import com.moral.entity.Organization;
-import com.moral.entity.Point;
-import com.moral.entity.Region;
+import com.moral.entity.*;
 import com.moral.entity.alarm.AlarmConfig;
 import com.moral.entity.alarm.AlarmConfigValue;
 import com.moral.entity.alarm.AlarmSensorLevel;
@@ -65,12 +57,14 @@
 import com.moral.service.WeatherService;
 import com.moral.util.*;
 
+import com.rabbitmq.client.*;
+import com.rabbitmq.client.Channel;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import jdk.nashorn.internal.runtime.regexp.joni.Regex;
 import net.sf.json.JSONString;
-
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.net.ftp.FTPClient;
@@ -712,8 +706,8 @@
             String time = map.get("time").toString();
             time = time.substring(time.length() - 2);
             map.put("time", Integer.valueOf(time));
-            if (parameters.get("type").equals("day")) {
-                map.put("time", Integer.valueOf(time) + 1);
+            if(parameters.get("type").equals("day")){
+                map.put("time", Integer.valueOf(time)+1);
             }
             map.put("value", map.remove(sensorKey));
         }
@@ -1916,8 +1910,8 @@
             if (minAngle > (Double) longAndLatiList.get(j).get("angle")) {
                 minAngle = (Double) longAndLatiList.get(j).get("angle");
                 indexAngle = j;
-            } else {
-                indexAngle = indexAngle;
+            }else {
+                indexAngle=indexAngle;
             }
         }
         preAngleDeviceList.add(deviceList.get((Integer) longAndLatiList.get(indexAngle).get("h")));
@@ -1953,6 +1947,71 @@
         return params;
     }
 
+    @GetMapping("/allDevice")
+    @ResponseBody
+    public Map<String,List> getAllDevice() {
+        List<String> macList=deviceService.getAllMac();
+        Map<String,List> latlngMap=new HashMap<String,List>();
+        Map devMap=null;
+        List list=new ArrayList();
+        for (String mac : macList) {
+            devMap=new HashMap();
+            if (mac!=null){
+                Device device=deviceService.byMacGetDevice(mac);
+                List list1= LatLngTransformation.Convert_BD09_To_GCJ02(device.getLatitude(),device.getLongitude());
+                devMap.put("lat",list1.get(1));
+                devMap.put("lng",list1.get(0));
+                devMap.put("monitorPointId",device.getMonitorPointId());
+                //System.out.println(device);
+                list.add(devMap);
+            }else {
+                continue;
+            }
+        }
+        latlngMap.put("latlng",list);
+        return latlngMap;
+    }
+
+
+
+    @GetMapping("/windAndDeviceData")
+    @ResponseBody
+    public List windAndDeviceData(HttpServletRequest request, String monitorPointId) {
+        Calendar c = Calendar.getInstance();//������������������������������������   ������������������������������
+        int year = c.get(Calendar.YEAR);
+        int month = c.get(Calendar.MONTH);
+        String mon="";
+        if (month+1<10){
+            mon="0"+(month+1);
+        }else {
+            mon=(month+1)+"";
+        }
+        int date = c.get(Calendar.DATE);
+        String dt="";
+        if(date<10){
+            dt="0"+date;
+        }else {
+            dt=""+date;
+        }
+        int hour = c.get(Calendar.HOUR_OF_DAY);
+        String hu="";
+        if (hour<10){
+            hu="0"+hour;
+        }else {
+            hu=""+hour;
+        }
+        int minute = c.get(Calendar.MINUTE);
+        String mu="";
+        if (minute<10){
+            mu="0"+minute;
+        }else {
+            mu=""+minute;
+        }
+        String time=year + "-" + mon + "-" + dt + " " +hu + ":" +mu + ":" + "00";
+        String table="history_minutely_"+year+mon;
+        List list=deviceService.byMonitorIdGetDeviceAndWind(monitorPointId,time,table);
+        return list;
+    }
     @GetMapping("forecastO3")
     @ApiOperation(value = "���������������������������", notes = "���������������������������")
     @ApiImplicitParams(value = {
diff --git a/src/main/java/com/moral/entity/DeviceAndWind.java b/src/main/java/com/moral/entity/DeviceAndWind.java
new file mode 100644
index 0000000..6abbfa3
--- /dev/null
+++ b/src/main/java/com/moral/entity/DeviceAndWind.java
@@ -0,0 +1,64 @@
+package com.moral.entity;
+
+public class DeviceAndWind {
+    private Double longitude;
+
+    private Double latitude;
+
+    private Double windDir;
+
+    private Double windSpeed;
+
+    private Double tVoc;
+
+    public Double gettVoc() {
+        return tVoc;
+    }
+
+    public void settVoc(Double tVoc) {
+        this.tVoc = tVoc;
+    }
+
+    public Double getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(Double longitude) {
+        this.longitude = longitude;
+    }
+
+    public Double getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
+    }
+
+    public Double getWindDir() {
+        return windDir;
+    }
+
+    public void setWindDir(Double windDir) {
+        this.windDir = windDir;
+    }
+
+    public Double getWindSpeed() {
+        return windSpeed;
+    }
+
+    public void setWindSpeed(Double windSpeed) {
+        this.windSpeed = windSpeed;
+    }
+
+    @Override
+    public String toString() {
+        return "DeviceAndWind{" +
+                "longitude=" + longitude +
+                ", latitude=" + latitude +
+                ", windDir=" + windDir +
+                ", windSpeed=" + windSpeed +
+                ", tVoc=" + tVoc +
+                '}';
+    }
+}
diff --git a/src/main/java/com/moral/mapper/DeviceMapper.java b/src/main/java/com/moral/mapper/DeviceMapper.java
index 99b1786..81a33bf 100644
--- a/src/main/java/com/moral/mapper/DeviceMapper.java
+++ b/src/main/java/com/moral/mapper/DeviceMapper.java
@@ -7,6 +7,7 @@
 import com.moral.common.mapper.BaseMapper;
 import com.moral.entity.Device;
 
+import com.moral.entity.DeviceAndWind;
 import org.apache.ibatis.annotations.Param;
 import tk.mybatis.mapper.entity.Example;
 
@@ -55,6 +56,18 @@
 
 	List<Device> selectDevicesAll(Map<String, Object> params);
 
+	List<DeviceAndWind> getAllDevice();
+
+	List<String> getAllMac();
+
+	Device byMacGetDevice(@Param("mac") String mac);
+
+	DeviceAndWind getDeviceAndWindByMac(@Param("mac") String mac,@Param("time") String time,
+										@Param("table") String table);
+
+	List<DeviceAndWind> byMonitorIdGetDeviceAndWind(@Param("id") String id,@Param("time") String time,
+													@Param("table") String table);
+
 	List<Device> getDeviceListByMonitorPointIds(List<Integer> list);
 
 	Map<String, Object> selectAllFieldByMac(Map<String, Object> params);
diff --git a/src/main/java/com/moral/mapper/MonitorPointMapper.java b/src/main/java/com/moral/mapper/MonitorPointMapper.java
index 7689907..e61a63d 100644
--- a/src/main/java/com/moral/mapper/MonitorPointMapper.java
+++ b/src/main/java/com/moral/mapper/MonitorPointMapper.java
@@ -24,6 +24,7 @@
     MonitorPoint getMonitorPointById(@Param("id") int id);
 
     List<MonitorPoint> getMonitorPointListByAccountId(@Param("id") int id);
+    MonitorPoint byIdGetMonitorPoint(@Param("id")int id);
 
     MonitorPoint getFirstMonitorPointByAreaCode(@Param("areaCode") int areaCode);
 
diff --git a/src/main/java/com/moral/service/DeviceService.java b/src/main/java/com/moral/service/DeviceService.java
index 5ffb2ac..8b7cb04 100644
--- a/src/main/java/com/moral/service/DeviceService.java
+++ b/src/main/java/com/moral/service/DeviceService.java
@@ -7,6 +7,7 @@
 import com.moral.common.bean.PageBean;
 import com.moral.common.bean.PageResult;
 import com.moral.entity.Device;
+import com.moral.entity.DeviceAndWind;
 import com.moral.entity.DeviceProperty;
 
 public interface DeviceService {
@@ -72,4 +73,14 @@
 	List<Device> queryDevice(Map<String,Object> map);
 
 	Map<String, Object> getAllFieldByMac(Map<String, Object> parameters);
+
+	List<DeviceAndWind> getAllDevice();
+
+	List<String> getAllMac();
+
+	Device byMacGetDevice(String mac);
+
+	List<DeviceAndWind> byMonitorIdGetDeviceAndWind(String id,String time,String tab);
+
+	DeviceAndWind getDeviceAndWindByMac(String mac,String time,String table);
 }
diff --git a/src/main/java/com/moral/service/MonitorPointService.java b/src/main/java/com/moral/service/MonitorPointService.java
index 9f2247b..3ff350d 100644
--- a/src/main/java/com/moral/service/MonitorPointService.java
+++ b/src/main/java/com/moral/service/MonitorPointService.java
@@ -8,6 +8,7 @@
 import com.moral.common.bean.PageBean;
 import com.moral.entity.Device;
 import com.moral.entity.MonitorPoint;
+import org.apache.xmlbeans.impl.jam.mutable.MPackage;
 
 public interface MonitorPointService {
 
@@ -53,4 +54,6 @@
     JSONObject getMacList(int id);
 
     List<MonitorPoint> getMonitorPointListByAccountId(int id);
+
+    MonitorPoint byIdGetMonitorPoint(int id);
 }
diff --git a/src/main/java/com/moral/service/impl/DeviceServiceImpl.java b/src/main/java/com/moral/service/impl/DeviceServiceImpl.java
index 5eb9c1c..f68a409 100644
--- a/src/main/java/com/moral/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -1,16 +1,12 @@
 package com.moral.service.impl;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 import javax.validation.constraints.NotNull;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.TypeReference;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
@@ -22,6 +18,7 @@
 import com.moral.common.util.RedisUtils;
 import com.moral.common.util.ValidateUtil;
 import com.moral.entity.Device;
+import com.moral.entity.DeviceAndWind;
 import com.moral.entity.DeviceProperty;
 import com.moral.entity.MonitorPoint;
 import com.moral.mapper.DeviceMapper;
@@ -32,6 +29,7 @@
 import com.moral.mapper.OrganizationMapper;
 import com.moral.service.AccountService;
 import com.moral.service.DeviceService;
+import com.moral.util.LatLngTransformation;
 import com.moral.util.TkMybatisUtils;
 
 import org.apache.commons.collections.MapUtils;
@@ -703,4 +701,182 @@
         Map<String, Object> deviceMap = deviceMapper.selectAllFieldByMac(parameters);
         return deviceMap;
     }
+
+    @Override
+    public List<DeviceAndWind> getAllDevice() {
+        return deviceMapper.getAllDevice();
+    }
+
+    @Override
+    public List<String> getAllMac() {
+        return deviceMapper.getAllMac();
+    }
+
+    @Override
+    public Device byMacGetDevice(String mac) {
+        return deviceMapper.byMacGetDevice(mac);
+    }
+
+    @Override
+    public List byMonitorIdGetDeviceAndWind(String id,String time,String tab) {
+        List<DeviceAndWind> deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(id,time,tab);
+        List list1=new ArrayList();
+        List loList=new ArrayList();
+        List laList=new ArrayList();
+        Double U=0.0;
+        Double V=0.0;
+        for (DeviceAndWind andWind : deviceAndWinds) {
+            List list2=new ArrayList();
+            Double lo=andWind.getLongitude();
+            Double la=andWind.getLatitude();
+            List list= LatLngTransformation.Convert_BD09_To_GCJ02(la,lo);
+            Double transLo=(Double) list.get(0);
+            Double transLa=(Double) list.get(1);
+            loList.add(transLo);
+            laList.add(transLa);
+        }
+        Double loma= (Double) Collections.max(loList);
+        Double lomi= (Double) Collections.min(loList);
+        Double lama= (Double) Collections.max(laList);
+        Double lami= (Double) Collections.min(laList);
+
+        Map laLaMap=new HashMap();
+        laLaMap.put("maxLo",loma);
+        laLaMap.put("minLo",lomi);
+        laLaMap.put("maxLa",lama);
+        laLaMap.put("lami",lami);
+
+
+        Double lo1=lomi-250*0.00001141;
+        Double lo2=loma+250*0.00001141;
+        Double la2=lami-250*0.00000899;
+        Double la1=lama+250*0.00000899;
+
+        Double dx=0.00001141*20;
+        Double dy=0.00000899*20;
+        int nx=(int) Math.floor((lo2-lo1)/dx);
+        int ny=(int) Math.floor((la1-la2)/dy);
+        String header1 = "\"" + "header" + "\"" + ": " + "{" + "\"" + "parameterUnit" + "\"" + ": " + "\"" + "m/s" + "\"" + ", " + "\"" + "parameterNumber" + "\"" + ": " + 2 +
+                ", " + "\"" + "dx" + "\"" + ": " + dx + ", " + "\"" + "dy" + "\"" + ": " + dy +
+                ", " + "\"" + "parameterNumberName" + "\"" + ": " + "\"" + "eastward_wind" + "\"" + ", " + "\"" + "la1" + "\"" + ": " + la1 + ", " + "\"" + "la2" + "\"" + ": " + la2 +
+                ", " + "\"" + "parameterCategory" + "\"" + ": " + 2 + ", " + "\"" + "lo1" + "\"" + ": " + lo1 + ", " + "\"" + "lo2" + "\"" + ": " + lo2 +
+                ", " + "\"" + "nx" + "\"" + ": " + nx + ", " + "\"" + "ny" + "\"" + ": " + ny + ", " + "\"" + "refTime" + "\"" + ": " + "\"" + "2020-07-22 23:00:00" + "\"" + "}";
+
+        String header2 = "\"" + "header" + "\"" + ": " + "{" + "\"" + "parameterUnit" + "\"" + ": " + "\"" + "m/s" + "\"" + ", " + "\"" + "parameterNumber" + "\"" + ": " + 3 +
+                ", " + "\"" + "dx" + "\"" + ": " + dx + ", " + "\"" + "dy" + "\"" + ": " + dy +
+                ", " + "\"" + "parameterNumberName" + "\"" + ": " + "\"" + "eastward_wind" + "\"" + ", " + "\"" + "la1" + "\"" + ": " + la1 + ", " + "\"" + "la2" + "\"" + ": " + la2 +
+                ", " + "\"" + "parameterCategory" + "\"" + ": " + 2 + ", " + "\"" + "lo1" + "\"" + ": " + lo1 + ", " + "\"" + "lo2" + "\"" + ": " + lo2 +
+                ", " + "\"" + "nx" + "\"" + ": " + nx + ", " + "\"" + "ny" + "\"" + ": " + ny + ", " + "\"" + "refTime" + "\"" + ": " + "\"" + "2020-07-22 23:00:00" + "\"" + "}";
+
+        List<Double> uList=new ArrayList<Double> ();
+        List<Double>  vList=new ArrayList<Double> ();
+        int x=0;
+        int y=0;
+        List<Map> mapList=new ArrayList<Map>();
+
+        for (int j = 0; j <deviceAndWinds.size() ; j++) {
+            Map<String,Double> map=new HashMap<String,Double> ();
+            Double windDir= deviceAndWinds.get(j).getWindDir();
+
+            Double windSpeed=deviceAndWinds.get(j).getWindSpeed();
+            if (windDir==null){
+                windDir=0.0;
+                windSpeed=0.0;
+            }
+            Double tvoc=deviceAndWinds.get(j).gettVoc();
+
+            List list= LatLngTransformation.Convert_BD09_To_GCJ02(deviceAndWinds.get(j).getLatitude(),deviceAndWinds.get(j).getLongitude());
+            Double transLo=(Double) list.get(0);
+            Double transLa=(Double) list.get(1);
+            if (tvoc==null){
+                tvoc=0.0;
+            }
+            Double dir = (270.0 - windDir * Math.PI / 180.0);
+
+            U = windSpeed * Math.cos(dir);
+            V = windSpeed * Math.sin(dir);
+            map.put("lo",transLo);
+            map.put("la",transLa);
+            map.put("U",U);
+            map.put("V",V);
+            mapList.add(map);
+        }
+        System.out.println(mapList);
+        for (int i = 0; i <mapList.size() ; i++) {
+            Double lo= (Double) mapList.get(i).get("lo");
+            Double la= (Double) mapList.get(i).get("la");
+            x= (int) Math.floor((lo-lo1)/dx);
+            y=Math.abs((int)Math.floor((la-la1)/dy));
+            //y=Math.floor(Math.abs(la-la1)/dy);
+            U=(Double) mapList.get(i).get("U");
+            V=(Double) mapList.get(i).get("V");
+            if (i==0){
+                for (int j = 0; j <nx*ny ; j++) {
+                    uList.add(0.0);
+                    vList.add(0.0);
+                }
+            }
+            for (int j = 0; j <nx*ny ; j++) {
+                if (i==0){
+                    if ((y>=2 && j==(y)*nx+x)){
+                        int k;
+                        System.out.println(nx*ny);
+                        for (k = j-2*nx; k <=j+2*nx ;k=k+nx) {
+                            System.out.println(k);
+                            System.out.println("----------------");
+                            System.out.println(uList.size());
+                            uList.set(k,U);
+                            uList.set(k-1,U);
+                            uList.set(k-2,U);
+                            uList.set(k+1,U);
+                            uList.set(k+2,U);
+                            vList.set(k,V);
+                            vList.set(k-1,V);
+                            vList.set(k-2,V);
+                            vList.set(k+1,V);
+                            vList.set(k+2,V);
+                        }
+                    }
+                }else {
+                    if (y>=1 && j==y*nx+x && uList.get(j)==0.0 && vList.get(j)==0.0){
+                        int k;
+                        for (k = j-2*nx; k <=j+2*nx ;) {
+                            uList.set(k-1,U);
+                            uList.set(k-2,U);
+                            uList.set(k+1,U);
+                            uList.set(k+2,U);
+                            vList.set(k-1,V);
+                            vList.set(k-2,V);
+                            vList.set(k+1,V);
+                            vList.set(k+2,V);
+                            k=k+nx;
+                        }
+                        uList.set(j,U);
+                        vList.set(j,V);
+                    }
+                }
+            }
+        }
+        String uData = "\"" + "data" + "\"" + ": " + uList;
+        String vData = "\"" + "data" + "\"" + ": " + vList;
+        String s1 = "[" + "{" + header1 + ", " + uData + "}" + ", " + "{" + header2 + ", " + vData + "}" + "]";
+        JSONArray jsonArray = JSONArray.parseArray(s1);
+        MonitorPoint monitorPoint=monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
+        Double monitorLo=monitorPoint.getLongitude();
+        Double monitorLa=monitorPoint.getLatitude();
+        List transList= LatLngTransformation.Convert_BD09_To_GCJ02(monitorLa,monitorLo);
+        Double transLo=(Double) transList.get(0);
+        Double transLa=(Double) transList.get(1);
+        List list=new ArrayList();
+        list.add(jsonArray);
+        list.add(transLo);
+        list.add(transLa);
+list.add(laLaMap);
+        return list;
+    }
+
+    @Override
+    public DeviceAndWind getDeviceAndWindByMac(String mac,String time,String table) {
+        return deviceMapper.getDeviceAndWindByMac(mac,time,table);
+    }
 }
diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
index ea969fb..94f379e 100644
--- a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
@@ -817,5 +817,10 @@
         return monitorPointMapper.getMonitorPointListByAccountId(id);
     }
 
+    @Override
+    public MonitorPoint byIdGetMonitorPoint(int id) {
+        return monitorPointMapper.byIdGetMonitorPoint(id);
+    }
+
 
 }
diff --git a/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java b/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java
index cb68b39..deb0c0c 100644
--- a/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java
@@ -60,7 +60,10 @@
         return orgIds;
     }
 
-
+    @Override
+    public Organization getOrganizationByMac(Map<String, Object> parameters) {
+        return organizationMapper.getOrganizationByMac(parameters);
+    }
     @Override
     public List<Organization> getOrganizationsByAreaName(Map<String, Object> parameters) {
         ValidateUtil.notNull(parameters.get("areaName"), "param.is.null");
diff --git a/src/main/java/com/moral/webSocketServer/WebSocketServerNew.java b/src/main/java/com/moral/webSocketServer/WebSocketServerNew.java
index 22e2ef6..deac7a4 100644
--- a/src/main/java/com/moral/webSocketServer/WebSocketServerNew.java
+++ b/src/main/java/com/moral/webSocketServer/WebSocketServerNew.java
@@ -35,11 +35,6 @@
     // ������������������������������������������������������������������������������
     private Session session;
 
-    private String orgId;
-
-    private String accountId;
-
-
     private Connection connection;
 
     private Channel channel;
@@ -116,9 +111,7 @@
 
     @OnClose
     public void onClose() {
-
 //**���������Set��� ������������������������*//**//**//**//**//**//**//**//*
-
         webSocketSet.remove(this);
         try {
             connection.close();
diff --git a/src/main/resources/mapper/DeviceMapper.xml b/src/main/resources/mapper/DeviceMapper.xml
index a7d881e..196e7ee 100644
--- a/src/main/resources/mapper/DeviceMapper.xml
+++ b/src/main/resources/mapper/DeviceMapper.xml
@@ -1,92 +1,94 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.moral.mapper.DeviceMapper">
-	<resultMap id="ResultMap" type="com.moral.entity.Device">
-		<id column="id" jdbcType="INTEGER" property="id" />
-		<result column="name" jdbcType="VARCHAR" property="name" />
-		<result column="address" jdbcType="VARCHAR" property="address" />
-		<result column="longitude" jdbcType="DOUBLE" property="longitude" />
-		<result column="latitude" jdbcType="DOUBLE" property="latitude" />
-		<result column="mac" jdbcType="VARCHAR" property="mac" />
-		<result column="operate_user_id" jdbcType="INTEGER" property="operateUserId" />
-		<result column="state" jdbcType="CHAR" property="state" />
-		<result column="is_delete" jdbcType="CHAR" property="isDelete" />
-		<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-		<result column="install_time" jdbcType="TIMESTAMP" property="installTime" />
-		<result column="monitor_point_id" jdbcType="INTEGER" property="monitorPointId" />
-		<result column="device_version_id" jdbcType="INTEGER" property="deviceVersionId" />
-		<result column="profession_id" jdbcType="INTEGER" property="professionId" />
-	</resultMap>
+    <resultMap id="ResultMap" type="com.moral.entity.Device">
+        <id column="id" jdbcType="INTEGER" property="id"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="address" jdbcType="VARCHAR" property="address"/>
+        <result column="longitude" jdbcType="DOUBLE" property="longitude"/>
+        <result column="latitude" jdbcType="DOUBLE" property="latitude"/>
+        <result column="mac" jdbcType="VARCHAR" property="mac"/>
+        <result column="operate_user_id" jdbcType="INTEGER" property="operateUserId"/>
+        <result column="state" jdbcType="CHAR" property="state"/>
+        <result column="is_delete" jdbcType="CHAR" property="isDelete"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="install_time" jdbcType="TIMESTAMP" property="installTime"/>
+        <result column="monitor_point_id" jdbcType="INTEGER" property="monitorPointId"/>
+        <result column="device_version_id" jdbcType="INTEGER" property="deviceVersionId"/>
+        <result column="profession_id" jdbcType="INTEGER" property="professionId"/>
+    </resultMap>
 
-	<resultMap id="BaseResultMap" type="com.moral.entity.Device" extends="ResultMap">
-		<association property="operateUser" javaType="com.moral.entity.OperateUser">
-			<result column="operate_user_id" property="id" jdbcType="INTEGER" />
-			<result column="operate_user_name" property="name" jdbcType="VARCHAR" />
-		</association>
-		<association property="deviceVersion" javaType="com.moral.entity.DeviceVersion">
-			<result column="device_version_id" property="id" jdbcType="INTEGER" />
-			<result column="device_version_value" property="version" jdbcType="INTEGER" />
-			<result column="device_version_name" property="name" jdbcType="VARCHAR" />
-		</association>
-		<association property="monitorPoint" javaType="com.moral.entity.MonitorPoint">
-			<result column="monitor_point_id" property="id" jdbcType="INTEGER" />
-			<result column="monitor_point_name" property="name" jdbcType="VARCHAR" />
-			<result column="province_code" property="provinceCode" jdbcType="VARCHAR" />
-		</association>
-		<association property="profession" javaType="com.moral.entity.Profession">
-			<result column="profession_id" property="id" jdbcType="INTEGER" />
-			<result column="profession_name" property="name" jdbcType="VARCHAR" />
-		</association>
-	</resultMap>
+    <resultMap id="BaseResultMap" type="com.moral.entity.Device" extends="ResultMap">
+        <association property="operateUser" javaType="com.moral.entity.OperateUser">
+            <result column="operate_user_id" property="id" jdbcType="INTEGER"/>
+            <result column="operate_user_name" property="name" jdbcType="VARCHAR"/>
+        </association>
+        <association property="deviceVersion" javaType="com.moral.entity.DeviceVersion">
+            <result column="device_version_id" property="id" jdbcType="INTEGER"/>
+            <result column="device_version_value" property="version" jdbcType="INTEGER"/>
+            <result column="device_version_name" property="name" jdbcType="VARCHAR"/>
+        </association>
+        <association property="monitorPoint" javaType="com.moral.entity.MonitorPoint">
+            <result column="monitor_point_id" property="id" jdbcType="INTEGER"/>
+            <result column="monitor_point_name" property="name" jdbcType="VARCHAR"/>
+            <result column="province_code" property="provinceCode" jdbcType="VARCHAR"/>
+        </association>
+        <association property="profession" javaType="com.moral.entity.Profession">
+            <result column="profession_id" property="id" jdbcType="INTEGER"/>
+            <result column="profession_name" property="name" jdbcType="VARCHAR"/>
+        </association>
+    </resultMap>
 
-	<resultMap id="PropertyResultMap" type="com.moral.entity.Device" extends="BaseResultMap">
-		<association property="deviceProperty" javaType="com.moral.entity.DeviceProperty">
-			<result column="id" property="id" jdbcType="INTEGER" />
-			<result column="device_tech" property="deviceTech" jdbcType="TINYINT" />
-			<result column="device_cat" property="deviceCat" jdbcType="TINYINT" />
-			<result column="device_source" property="deviceSource" jdbcType="VARCHAR" />
-			<result column="ext_c" property="extC" jdbcType="VARCHAR" />
-			<result column="ext_d" property="extD" jdbcType="VARCHAR" />
-		</association>
-	</resultMap>
+    <resultMap id="PropertyResultMap" type="com.moral.entity.Device" extends="BaseResultMap">
+        <association property="deviceProperty" javaType="com.moral.entity.DeviceProperty">
+            <result column="id" property="id" jdbcType="INTEGER"/>
+            <result column="device_tech" property="deviceTech" jdbcType="TINYINT"/>
+            <result column="device_cat" property="deviceCat" jdbcType="TINYINT"/>
+            <result column="device_source" property="deviceSource" jdbcType="VARCHAR"/>
+            <result column="ext_c" property="extC" jdbcType="VARCHAR"/>
+            <result column="ext_d" property="extD" jdbcType="VARCHAR"/>
+        </association>
+    </resultMap>
 
-	<resultMap id="BaseResultWithOrgIdsMap" type="com.moral.entity.Device" extends="BaseResultMap">
-		<collection property="organizationIds" column="id" select="selectOrganizationIds"></collection>
-	</resultMap>
-	<sql id="Example_Where_Clause">
-		<where>
-			<foreach collection="oredCriteria" item="criteria" separator="or">
-				<if test="criteria.valid">
-					<trim prefix="(" prefixOverrides="and" suffix=")">
-						<foreach collection="criteria.criteria" item="criterion">
-							<choose>
-								<when test="criterion.noValue">
-									and ${criterion.condition}
-								</when>
-								<when test="criterion.singleValue">
-									and ${criterion.condition} #{criterion.value}
-								</when>
-								<when test="criterion.betweenValue">
-									and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-								</when>
-								<when test="criterion.listValue">
-									and ${criterion.condition}
-									<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
-										#{listItem}
-									</foreach>
-								</when>
-							</choose>
-						</foreach>
-					</trim>
-				</if>
-			</foreach>
-		</where>
-	</sql>
-  <sql id="Base_Column_List">
+    <resultMap id="BaseResultWithOrgIdsMap" type="com.moral.entity.Device" extends="BaseResultMap">
+        <collection property="organizationIds" column="id" select="selectOrganizationIds"></collection>
+    </resultMap>
+    <sql id="Example_Where_Clause">
+        <where>
+            <foreach collection="oredCriteria" item="criteria" separator="or">
+                <if test="criteria.valid">
+                    <trim prefix="(" prefixOverrides="and" suffix=")">
+                        <foreach collection="criteria.criteria" item="criterion">
+                            <choose>
+                                <when test="criterion.noValue">
+                                    and ${criterion.condition}
+                                </when>
+                                <when test="criterion.singleValue">
+                                    and ${criterion.condition} #{criterion.value}
+                                </when>
+                                <when test="criterion.betweenValue">
+                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                                </when>
+                                <when test="criterion.listValue">
+                                    and ${criterion.condition}
+                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
+                                             separator=",">
+                                        #{listItem}
+                                    </foreach>
+                                </when>
+                            </choose>
+                        </foreach>
+                    </trim>
+                </if>
+            </foreach>
+        </where>
+    </sql>
+    <sql id="Base_Column_List">z
     id, name, address, longitude, latitude, mac, operate_user_id, state, is_delete, create_time, 
     install_time, monitor_point_id, device_version_id
   </sql>
-	<select id="countByTimes"   resultType="java.util.Map">
+
+    <select id="countByTimes" resultType="java.util.Map">
 		select DATE_FORMAT(create_time,#{format}) as time, COUNT(*) as count from device
 		where create_time >= #{start}
 		and create_time
@@ -98,44 +100,44 @@
 		]]> 1
 		GROUP BY DATE_FORMAT(create_time,#{format}) ;
 	</select>
-  <select id="selectWithRelationData" parameterType="tk.mybatis.mapper.entity.Example" resultMap="BaseResultMap">
-    select
-	dev.*,
-	ouser.name as operate_user_name,
-	dvn.name as device_version_name,
-	mpt.name as monitor_point_name
-    from device dev
-	left join operate_user ouser on dev.operate_user_id = ouser.id
-	left join device_version dvn on dev.device_version_id = dvn.id
-	left join monitor_point mpt on dev.monitor_point_id = mpt.id
-	where dev.id in (
-	  select id from device
-	  <if test="_parameter != null">
-		  <include refid="Example_Where_Clause" />
-	  </if>
-	  <if test="orderByClause != null">
-		  order by ${orderByClause}
-	  </if>
-	  )
-  </select>
-	<select id="getDeviceStatesByAccount" resultType="java.util.Map">
-		SELECT
-			COUNT( d.state ) count,
-			d.state 
-		FROM
-			device d
-		<if test="orgIds != null and orgIds.size &gt; 0">
-			,monitor_point mp
-		WHERE
-			d.monitor_point_id = mp.id 
-			AND mp.organization_id IN
-			<foreach close=")" collection="orgIds" item="listItem" open="(" separator=",">
-				#{listItem}
-			</foreach>
-		</if>
-		GROUP BY d.state
-	</select>
-	<select id="getSensorsByDevice" resultType="java.util.Map">
+    <select id="selectWithRelationData" parameterType="tk.mybatis.mapper.entity.Example" resultMap="BaseResultMap">
+        select
+        dev.*,
+        ouser.name as operate_user_name,
+        dvn.name as device_version_name,
+        mpt.name as monitor_point_name
+        from device dev
+        left join operate_user ouser on dev.operate_user_id = ouser.id
+        left join device_version dvn on dev.device_version_id = dvn.id
+        left join monitor_point mpt on dev.monitor_point_id = mpt.id
+        where dev.id in (
+        select id from device
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+        <if test="orderByClause != null">
+            order by ${orderByClause}
+        </if>
+        )
+    </select>
+    <select id="getDeviceStatesByAccount" resultType="java.util.Map">
+        SELECT
+        COUNT( d.state ) count,
+        d.state
+        FROM
+        device d
+        <if test="orgIds != null and orgIds.size &gt; 0">
+            ,monitor_point mp
+            WHERE
+            d.monitor_point_id = mp.id
+            AND mp.organization_id IN
+            <foreach close=")" collection="orgIds" item="listItem" open="(" separator=",">
+                #{listItem}
+            </foreach>
+        </if>
+        GROUP BY d.state
+    </select>
+    <select id="getSensorsByDevice" resultType="java.util.Map">
 		SELECT
 			s.`key`,
 			s.`name` 
@@ -150,7 +152,7 @@
 		ORDER BY
 			s.id
 	</select>
-	<select id="getDeviceVersionIdByMonitorPoint" resultType="java.util.Map">
+    <select id="getDeviceVersionIdByMonitorPoint" resultType="java.util.Map">
 		SELECT
 			device_version_id deviceVersionId
 		FROM
@@ -160,23 +162,23 @@
 		GROUP BY
 			device_version_id
 	</select>
-	<select id="getDeviceVersionIdByAreaCode" resultType="java.lang.Integer">
-		SELECT DISTINCT
-			d.device_version_id 
-		FROM
-			monitor_point mp,
-			device d 
-		WHERE
-			mp.area_code = #{areaCode} 
-			AND d.monitor_point_id = mp.id
-		<if test="orgIds != null and orgIds.size() > 0">
-			AND mp.organization_id IN
-			<foreach  collection="orgIds" open="(" separator="," close=")" item="listItem">
-				#{listItem}
-			</foreach>
-		</if>
-	</select>
-	<select id="getDeviceMacByMonitorPointAndDeviceVersion" resultType="java.lang.String">
+    <select id="getDeviceVersionIdByAreaCode" resultType="java.lang.Integer">
+        SELECT DISTINCT
+        d.device_version_id
+        FROM
+        monitor_point mp,
+        device d
+        WHERE
+        mp.area_code = #{areaCode}
+        AND d.monitor_point_id = mp.id
+        <if test="orgIds != null and orgIds.size() > 0">
+            AND mp.organization_id IN
+            <foreach collection="orgIds" open="(" separator="," close=")" item="listItem">
+                #{listItem}
+            </foreach>
+        </if>
+    </select>
+    <select id="getDeviceMacByMonitorPointAndDeviceVersion" resultType="java.lang.String">
 		SELECT
 			mac
 		FROM
@@ -185,89 +187,89 @@
 			monitor_point_id = #{monitorPointId}
 			AND device_version_id = #{deviceVersionId}
 	</select>
-	<select id="selectByOrgIdAndDevName" resultMap="BaseResultMap">
-		SELECT dev.*,dve.version as device_version_value from device dev
-		left join monitor_point mpt on dev.monitor_point_id = mpt.id
-		left join device_version dve on dev.device_version_id = dve.id
-		<where>
-		<if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
-			(
-			1 > 1
-			<if test="orgIds!=null and orgIds.size() > 0">
-				or mpt.organization_id in
-				<foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
-					#{tempOrgId,jdbcType=INTEGER}
-				</foreach>
-			</if>
-			)
-		</if>
-			and dev.is_delete = 0
-			<if test="devState!=null">
-				and dev.state = #{devState}
-			</if>
-			<if test="name!=null and ''!=name">
-				and
-				(
-				dev.name like CONCAT('%',#{name},'%')
-				or dev.mac like CONCAT('%',#{name},'%')
-				or mpt.name like CONCAT('%',#{name},'%')
-				)
-			</if>
-		</where>
-	</select>
-	<select id="selectByOrgIdAndMpId" resultMap="BaseResultMap">
-		SELECT dev.*,dve.version as device_version_value,mpt.* from device dev
-		left join monitor_point mpt on dev.monitor_point_id = mpt.id
-		left join device_version dve on dev.device_version_id = dve.id
-		<where>
-			<if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
-				(
-				1 > 1
-				<if test="orgIds!=null and orgIds.size() > 0">
-					or mpt.organization_id in
-					<foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
-						#{tempOrgId,jdbcType=INTEGER}
-					</foreach>
-				</if>
-				)
-			</if>
-			and dev.monitor_point_id = #{mpId}
-			and dev.is_delete = 0
-		</where>
-	</select>
-	<select id="selectByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
-		SELECT dev.*,dve.version as device_version_value from device dev
-		left join monitor_point  mpt on dev.monitor_point_id = mpt.id
+    <select id="selectByOrgIdAndDevName" resultMap="BaseResultMap">
+        SELECT dev.*,dve.version as device_version_value from device dev
+        left join monitor_point mpt on dev.monitor_point_id = mpt.id
         left join device_version dve on dev.device_version_id = dve.id
-		<where>
-			<if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
-				(
-				1 > 1
-				<if test="orgIds!=null and orgIds.size() > 0">
-					or mpt.organization_id in
-					<foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
-						#{tempOrgId,jdbcType=INTEGER}
-					</foreach>
-				</if>
-				)
-			</if>
-			<![CDATA[
+        <where>
+            <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
+                (
+                1 > 1
+                <if test="orgIds!=null and orgIds.size() > 0">
+                    or mpt.organization_id in
+                    <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
+                        #{tempOrgId,jdbcType=INTEGER}
+                    </foreach>
+                </if>
+                )
+            </if>
+            and dev.is_delete = 0
+            <if test="devState!=null">
+                and dev.state = #{devState}
+            </if>
+            <if test="name!=null and ''!=name">
+                and
+                (
+                dev.name like CONCAT('%',#{name},'%')
+                or dev.mac like CONCAT('%',#{name},'%')
+                or mpt.name like CONCAT('%',#{name},'%')
+                )
+            </if>
+        </where>
+    </select>
+    <select id="selectByOrgIdAndMpId" resultMap="BaseResultMap">
+        SELECT dev.*,dve.version as device_version_value,mpt.* from device dev
+        left join monitor_point mpt on dev.monitor_point_id = mpt.id
+        left join device_version dve on dev.device_version_id = dve.id
+        <where>
+            <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
+                (
+                1 > 1
+                <if test="orgIds!=null and orgIds.size() > 0">
+                    or mpt.organization_id in
+                    <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
+                        #{tempOrgId,jdbcType=INTEGER}
+                    </foreach>
+                </if>
+                )
+            </if>
+            and dev.monitor_point_id = #{mpId}
+            and dev.is_delete = 0
+        </where>
+    </select>
+    <select id="selectByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
+        SELECT dev.*,dve.version as device_version_value from device dev
+        left join monitor_point mpt on dev.monitor_point_id = mpt.id
+        left join device_version dve on dev.device_version_id = dve.id
+        <where>
+            <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
+                (
+                1 > 1
+                <if test="orgIds!=null and orgIds.size() > 0">
+                    or mpt.organization_id in
+                    <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
+                        #{tempOrgId,jdbcType=INTEGER}
+                    </foreach>
+                </if>
+                )
+            </if>
+            <![CDATA[
 			AND dev.longitude < #{mapBounds.Ge,jdbcType=NUMERIC}
             AND dev.longitude > #{mapBounds.Le,jdbcType=NUMERIC}
             AND dev.latitude  < #{mapBounds.Fe,jdbcType=NUMERIC}
             AND dev.latitude  > #{mapBounds.Ke,jdbcType=NUMERIC}
      		 ]]>
-     		<if test="regionCode != null">
-     		AND mpt.${regionType}_code = #{regionCode}
-     		</if>
-			AND dev.is_delete =0
-		</where>
-	</select>
-	<!-- resultMap������ -->
-	<select id="selectOrganizationIds" resultType="java.lang.Integer">
+            <if test="regionCode != null">
+                AND mpt.${regionType}_code = #{regionCode}
+            </if>
+            AND dev.is_delete =0
+        </where>
+    </select>
+    <!-- resultMap������ -->
+    <select id="selectOrganizationIds" resultType="java.lang.Integer">
 		call proc_organizationIds_GetByDeviceId(#{id,jdbcType=INTEGER});
 	</select>
-	<select id="selectWithOrgIdsByMac" parameterType="java.lang.String" resultMap="BaseResultWithOrgIdsMap">
+    <select id="selectWithOrgIdsByMac" parameterType="java.lang.String" resultMap="BaseResultWithOrgIdsMap">
 		select
 		dev.*,
 		mpt.name as monitor_point_name,
@@ -280,79 +282,79 @@
 		where dev.mac = #{mac,jdbcType=VARCHAR}
 		limit 0,1
 	</select>
-	<select id="getDeviceCountByRegion" resultType="java.lang.Integer">
-		SELECT
-			COUNT( * ) 
-		FROM
-			device d 
-		WHERE
-			d.is_delete = 0 
-			AND d.monitor_point_id IN (
-				SELECT
-					mp.id 
-				FROM
-					monitor_point mp 
-				WHERE
-					mp.is_delete = 0 
-					<if test="provinceCode != null">
-					AND mp.province_code = #{provinceCode}
-					</if>
-					<if test="cityCode != null">
-					AND mp.city_code = #{cityCode}
-					</if>
-					<if test="areaCode != null">
-					AND mp.area_code = #{areaCode}
-					</if>
-					<if test="townCode != null">
-					AND mp.town_code = #{townCode}
-					</if>
-					<if test="villageCode != null">
-					AND mp.village_code = #{villageCode}
-					</if>
-			)
-			<if test="professionId != null">
-			AND d.profession_id = #{professionId}
-			</if>
-	</select>
-	<select id="getDevicesByProfession" resultType="com.moral.entity.Device">
-		SELECT
-			* 
-		FROM
-			device d 
-		WHERE
-			d.is_delete = 0 
-			AND d.monitor_point_id IN (
-				SELECT
-					mp.id 
-				FROM
-					monitor_point mp 
-				WHERE
-					mp.is_delete = 0 
-					<if test="provinceCode != null">
-					AND mp.province_code = #{provinceCode}
-					</if>
-					<if test="cityCode != null">
-					AND mp.city_code = #{cityCode}
-					</if>
-					<if test="areaCode != null">
-					AND mp.area_code = #{areaCode}
-					</if>
-					<if test="monitorPointId != null">
-					AND mp.id = #{monitorPointId}
-					</if>
-					<if test="townCode != null">
-					AND mp.town_code = #{townCode}
-					</if>
-					<if test="villageCode != null">
-					AND mp.village_code = #{villageCode}
-					</if>
-			)
-			<if test="professionId != null">
-			AND d.profession_id = #{professionId}
-			</if>
-	</select>
+    <select id="getDeviceCountByRegion" resultType="java.lang.Integer">
+        SELECT
+        COUNT( * )
+        FROM
+        device d
+        WHERE
+        d.is_delete = 0
+        AND d.monitor_point_id IN (
+        SELECT
+        mp.id
+        FROM
+        monitor_point mp
+        WHERE
+        mp.is_delete = 0
+        <if test="provinceCode != null">
+            AND mp.province_code = #{provinceCode}
+        </if>
+        <if test="cityCode != null">
+            AND mp.city_code = #{cityCode}
+        </if>
+        <if test="areaCode != null">
+            AND mp.area_code = #{areaCode}
+        </if>
+        <if test="townCode != null">
+            AND mp.town_code = #{townCode}
+        </if>
+        <if test="villageCode != null">
+            AND mp.village_code = #{villageCode}
+        </if>
+        )
+        <if test="professionId != null">
+            AND d.profession_id = #{professionId}
+        </if>
+    </select>
+    <select id="getDevicesByProfession" resultType="com.moral.entity.Device">
+        SELECT
+        *
+        FROM
+        device d
+        WHERE
+        d.is_delete = 0
+        AND d.monitor_point_id IN (
+        SELECT
+        mp.id
+        FROM
+        monitor_point mp
+        WHERE
+        mp.is_delete = 0
+        <if test="provinceCode != null">
+            AND mp.province_code = #{provinceCode}
+        </if>
+        <if test="cityCode != null">
+            AND mp.city_code = #{cityCode}
+        </if>
+        <if test="areaCode != null">
+            AND mp.area_code = #{areaCode}
+        </if>
+        <if test="monitorPointId != null">
+            AND mp.id = #{monitorPointId}
+        </if>
+        <if test="townCode != null">
+            AND mp.town_code = #{townCode}
+        </if>
+        <if test="villageCode != null">
+            AND mp.village_code = #{villageCode}
+        </if>
+        )
+        <if test="professionId != null">
+            AND d.profession_id = #{professionId}
+        </if>
+    </select>
 
-	<select id="getDevicesByOrganizationId" resultMap="ResultMap">
+    <select id="getDevicesByOrganizationId" resultMap="ResultMap">
 		SELECT
 			d.* 
 		FROM
@@ -364,58 +366,81 @@
 			AND mp.is_delete = 0 
 			AND mp.organization_id = #{organizationId}
 	</select>
+    <select id="getAllMac" resultType="java.lang.String">
+        SELECT mac FROM `device` where  state!=4;
+    </select>
+    <select id="byMacGetDevice" resultType="com.moral.entity.Device" resultMap="ResultMap">
+        SELECT * from device where mac=#{mac}
+    </select>
+    <select id="getDeviceAndWindByMac" resultType="com.moral.entity.DeviceAndWind">
+            select d.longitude as longitude,d.latitude as latitude,
+            case when h.json->"$.e18[0]"=0 then 0.1 else h.json->"$.e18[0]" end
+            as windSpeed, h.json->"$.e23[0]" as windDir,
+            h.json->"$.e17[0]" as tVoc
+            from ${table} h ,`device` as d
+            where d.mac=h.mac and d.mac=#{mac} and h.time=#{time}
+ </select>
+    <select id="byMonitorIdGetDeviceAndWind" resultType="com.moral.entity.DeviceAndWind">
+          select d.longitude as longitude,d.latitude as latitude,
+            case when h.json->"$.e18[0]"=0 then 0.1 else h.json->"$.e18[0]" end
+            as windSpeed, h.json->"$.e23[0]" as windDir,
+            h.json->"$.e17[0]" as tVoc
+            from ${table} h ,`device` as d
+            where d.mac=h.mac and h.time=#{time}
+						and d.mac in (select d.mac from device , monitor_point as m where d.monitor_point_id=m.id and m.id=#{id})
+    </select>
 
 
-	<select id="getDevicesStateByRegion" resultType="map">
-		SELECT
-			d.id deviceId,d.mac,d.state,d.name deviceName,
-			mp.id,mp.name
-		FROM
-			device d ,
-			monitor_point mp
-		<where>
-			d.monitor_point_id = mp.id 
-			AND d.is_delete = 0 
-			AND mp.is_delete = 0 
-			AND mp.${regionType}_code = #{regionCode}
-		<if test="orgIds != null and orgIds.size &gt; 0">
-			AND mp.organization_id IN
-			<foreach  collection="orgIds" open="(" separator="," close=")" item="listItem">
-				#{listItem}
-			</foreach>
-		</if>
-		</where>
-	</select>
+    <select id="getDevicesStateByRegion" resultType="map">
+        SELECT
+        d.id deviceId,d.mac,d.state,d.name deviceName,
+        mp.id,mp.name
+        FROM
+        device d ,
+        monitor_point mp
+        <where>
+            d.monitor_point_id = mp.id
+            AND d.is_delete = 0
+            AND mp.is_delete = 0
+            AND mp.${regionType}_code = #{regionCode}
+            <if test="orgIds != null and orgIds.size &gt; 0">
+                AND mp.organization_id IN
+                <foreach collection="orgIds" open="(" separator="," close=")" item="listItem">
+                    #{listItem}
+                </foreach>
+            </if>
+        </where>
+    </select>
 
-	<select id="getDeviceList" resultMap="PropertyResultMap">
-		select
-			dev.*,
-			ouser.name as operate_user_name,
-			dvn.name as device_version_name,
-			mpt.name as monitor_point_name,
-			mpt.province_code,
-			dp.device_tech,
-			dp.device_cat,
-			dp.device_source,
-			dp.ext_c,
-			dp.ext_d
-		from device dev
-		left join operate_user ouser on dev.operate_user_id = ouser.id
-		left join device_version dvn on dev.device_version_id = dvn.id
-		left join monitor_point mpt on dev.monitor_point_id = mpt.id
-		left join device_property dp on dev.id = dp.id
-		where dev.id in (
-			select id from device
-			<if test="_parameter != null">
-				<include refid="Example_Where_Clause" />
-			</if>
-			<if test="orderByClause != null">
-				order by ${orderByClause}
-			</if>
-		)
-	</select>
-	
-	<select id="getLimitDataByDevice" resultType="String">
+    <select id="getDeviceList" resultMap="PropertyResultMap">
+        select
+        dev.*,
+        ouser.name as operate_user_name,
+        dvn.name as device_version_name,
+        mpt.name as monitor_point_name,
+        mpt.province_code,
+        dp.device_tech,
+        dp.device_cat,
+        dp.device_source,
+        dp.ext_c,
+        dp.ext_d
+        from device dev
+        left join operate_user ouser on dev.operate_user_id = ouser.id
+        left join device_version dvn on dev.device_version_id = dvn.id
+        left join monitor_point mpt on dev.monitor_point_id = mpt.id
+        left join device_property dp on dev.id = dp.id
+        where dev.id in (
+        select id from device
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+        <if test="orderByClause != null">
+            order by ${orderByClause}
+        </if>
+        )
+    </select>
+
+    <select id="getLimitDataByDevice" resultType="String">
 		SELECT limit_val FROM view_device_density WHERE mac = #{mac}
 	</select>
 
@@ -430,17 +455,17 @@
         AND d.is_delete = '0'
     </select>
 
-	<select id="getDeviceById1" resultType="com.moral.entity.Device">
+    <select id="getDeviceById1" resultType="com.moral.entity.Device">
 		SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp  where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=1 and d.monitor_point_id=#{id}
 	</select>
-	<select id="getDeviceById2" resultType="com.moral.entity.Device">
+    <select id="getDeviceById2" resultType="com.moral.entity.Device">
 		SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp  where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=2 and d.monitor_point_id=#{id}
 	</select>
-	<select id="getDeviceById3" resultType="com.moral.entity.Device">
+    <select id="getDeviceById3" resultType="com.moral.entity.Device">
 		SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp  where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=3 and d.monitor_point_id=#{id}
 	</select>
 
-	<select id="getHasWindDirAndWindSpeedDeviceVersion" resultType="integer">
+    <select id="getHasWindDirAndWindSpeedDeviceVersion" resultType="integer">
 		SELECT id from
 		device_version
 		where id in
@@ -459,26 +484,35 @@
 		and is_delete=0;
 	</select>
 
-	<select id="selectDevicesAll" parameterType="java.util.Map" resultType="com.moral.entity.Device">
-		SELECT dev.id,dev.mac,dev.device_version_id deviceVersionId from device dev
-		left join monitor_point  mpt on dev.monitor_point_id = mpt.id
-		<where>
-			<if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
-				(
-				1 > 1
-				<if test="orgIds!=null and orgIds.size() > 0">
-					or mpt.organization_id in
-					<foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
-						#{tempOrgId,jdbcType=INTEGER}
-					</foreach>
-				</if>
-				)
-			</if>
-			<if test="regionCode != null">
-				AND mpt.${regionType}_code = #{regionCode}
-			</if>
-			AND dev.is_delete =0
-		</where>
+    <select id="selectDevicesAll" parameterType="java.util.Map" resultType="com.moral.entity.Device">
+        SELECT dev.id,dev.mac,dev.device_version_id deviceVersionId from device dev
+        left join monitor_point mpt on dev.monitor_point_id = mpt.id
+        <where>
+            <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
+                (
+                1 > 1
+                <if test="orgIds!=null and orgIds.size() > 0">
+                    or mpt.organization_id in
+                    <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=",">
+                        #{tempOrgId,jdbcType=INTEGER}
+                    </foreach>
+                </if>
+                )
+            </if>
+            <if test="regionCode != null">
+                AND mpt.${regionType}_code = #{regionCode}
+            </if>
+            AND dev.is_delete =0
+        </where>
+    </select>
+    <select id="getAllDevice" resultType="com.moral.entity.DeviceAndWind">
+		select d.longitude as longitude,d.latitude as latitude,
+		case when h.json->"$.e18[0]"=0 then 0.1 else h.json->"$.e18[0]" end
+		 as windSpeed, h.json->"$.e23[0]" as windDir
+			from history_minutely_202007 h ,`device` as d
+			where h.time="2020-07-20 15:30:00" and h.json->"$.e23[0]" is not null and  h.mac in(SELECT d.mac   FROM monitor_point m
+			where d.monitor_point_id=m.id
+)
 	</select>
 
 	<select id="getDeviceListByMonitorPointIds" resultType="com.moral.entity.Device">
diff --git a/src/main/resources/mapper/MonitorPointMapper.xml b/src/main/resources/mapper/MonitorPointMapper.xml
index c1d3c7d..90ddde8 100644
--- a/src/main/resources/mapper/MonitorPointMapper.xml
+++ b/src/main/resources/mapper/MonitorPointMapper.xml
@@ -172,6 +172,9 @@
 		and o.id=mp.organization_id
 		and a.id=#{id};
 	</select>
+	<select id="byIdGetMonitorPoint" resultType="com.moral.entity.MonitorPoint">
+		SELECT * FROM `monitor_point` where id=#{id}
+	</select>
 
     <select id="getFirstMonitorPointByAreaCode" resultType="com.moral.entity.MonitorPoint" resultMap="BaseResultMap">
 		select * from monitor_point where area_code=#{areaCode} limit 0,1
diff --git a/src/main/webapp/view/newUnorganizedMap.jsp b/src/main/webapp/view/newUnorganizedMap.jsp
index f923a81..9c23b9f 100644
--- a/src/main/webapp/view/newUnorganizedMap.jsp
+++ b/src/main/webapp/view/newUnorganizedMap.jsp
@@ -19,7 +19,7 @@
         #box {
             width: 300px;
             height: 400px;
-            top: 220px;
+            top: 30px;
             right: 30px;
             position: absolute;
             z-index: 1;
@@ -157,10 +157,17 @@
                   moralMap.showSensors(JSON.parse(JSON.parse(msg.data)));
               }*/
         };
+        window.onbeforeunload=function(e){
+            e = window.event||e;
 
+            e.returnValue=("������������������������������");
+            ws.onclose = function () {
+            };
+            alert(1)
+        }
         //������������
-        ws.onclose = function () {
-        };
+        /*ws.onclose = function () {
+        };*/
         //���������������������
         ws.onerror = function () {
         };
diff --git a/src/main/webapp/view/unorganizedMap.jsp b/src/main/webapp/view/unorganizedMap.jsp
index b67884d..3c76c42 100644
--- a/src/main/webapp/view/unorganizedMap.jsp
+++ b/src/main/webapp/view/unorganizedMap.jsp
@@ -18,7 +18,7 @@
         #box {
             width:300px;
             height:400px;
-            top:220px;
+            top:30px;
             right:30px;
             position:absolute;
             z-index:1;

--
Gitblit v1.8.0