于紫祥_1901
2020-10-10 00e38ff225eb948f5234934afc01aa54c94e0de6
update
7 files added
5 files modified
250 ■■■■■ changed files
src/main/java/com/moral/controller/ScreenController.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/HistorySpecialMapper.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/MonitorPointMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/DeviceRoadService.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/HistorySpecialService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceRoadServiceImpl.java 130 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/HistorySpecialServiceImpl.java 16 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceRoadMapper.xml 9 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/HistorySpecialMapper.xml 5 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/MonitorPointMapper.xml 16 ●●●●● patch | view | raw | blame | history
src/main/webapp/js/newmoralmap.js 39 ●●●●● patch | view | raw | blame | history
src/main/webapp/view/newmap.jsp 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java
@@ -2248,7 +2248,7 @@
        return alarmData;
}
    @GetMapping("/lianxian")
  /*  @GetMapping("/lianxian")
    @ApiOperation(value = "连线", notes = "连线" )
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "lonAndLat", value = "经纬度", required = true, paramType = "query", dataType = "String")})
@@ -2272,5 +2272,5 @@
        model.addObject("params", params);
        model.setViewName("lianxian");
        return model;
    }
    }*/
}
src/main/java/com/moral/mapper/HistorySpecialMapper.java
New file
@@ -0,0 +1,10 @@
package com.moral.mapper;
import com.moral.service.HistoryService;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface HistorySpecialMapper {
}
src/main/java/com/moral/mapper/MonitorPointMapper.java
@@ -44,4 +44,6 @@
    MonitorPoint getFirstMonitorPointByProvinceCode(@Param("provinceCode") int provinceCode);
    List<Integer> getMonitorPointIds(Map<String, Object> params);
    List<MonitorPoint> byCodeGetMonitor(Map<String, Object> params);
}
src/main/java/com/moral/service/DeviceRoadService.java
New file
@@ -0,0 +1,9 @@
package com.moral.service;
import com.moral.entity.DeviceRoad;
import java.util.List;
public interface DeviceRoadService {
    List<DeviceRoad> getAlarmData(String windData, String code, String mac, String speedLevel);
}
src/main/java/com/moral/service/HistorySpecialService.java
New file
@@ -0,0 +1,8 @@
package com.moral.service;
import java.util.List;
import java.util.Map;
public interface HistorySpecialService {
}
src/main/java/com/moral/service/impl/DeviceRoadServiceImpl.java
New file
@@ -0,0 +1,130 @@
package com.moral.service.impl;
import com.moral.entity.Device;
import com.moral.entity.DeviceRoad;
import com.moral.entity.MonitorPoint;
import com.moral.mapper.DeviceRoadMapper;
import com.moral.mapper.MonitorPointMapper;
import com.moral.service.DeviceRoadService;
import com.moral.util.MyLatLng;
import com.moral.util.mapUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.sockjs.transport.handler.JsonpPollingTransportHandler;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class DeviceRoadServiceImpl implements DeviceRoadService {
    @Resource
    private MonitorPointMapper monitorPointMapper;
    @Resource
    private DeviceRoadMapper deviceRoadMapper;
    @Override
    public List<DeviceRoad> getAlarmData(String windData, String code, String mac, String speedLevel) {
        int len = code.length();
        Map params = new HashMap();
        String townCode = null;
        String areaCode = null;
        String cityCode = null;
        if (len == 12) {
            townCode = code;
        } else if (code.substring(4, 6).equals("00")) {
            cityCode = code;
        } else {
            areaCode = code;
        }
        params.put("townCode", townCode);
        params.put("areaCode", areaCode);
        params.put("cityCode", cityCode);
        List<MonitorPoint> monitorPointList = monitorPointMapper.byCodeGetMonitor(params);
        List<MonitorPoint> monitorPoints = new ArrayList();
        List<Device> allDeviceList = new ArrayList();
        //找出所有国控站站点放到一个集合中;将几台国控站的所有设备放到一个集合中
        for (MonitorPoint monitorPoint : monitorPointList) {
            String description = monitorPoint.getDescription();
            if (description != null) {
                if (monitorPoint.getDescription().equals("国控站")) {
                    int monitorId = monitorPoint.getId();
                    MonitorPoint monitorPointG = monitorPointMapper.getMonitorPointById(monitorId);
                    monitorPoints.add(monitorPointG);
                    List<Device> deviceList = monitorPointMapper.getDeviceList(monitorId);
                    for (Device device : deviceList) {
                        String state = device.getState();
                        if (state.equals("1") || state.equals("2") || state.equals("0")) {
                            allDeviceList.add(device);
                        }
                    }
                }
            }
        }
        List drlist = null;
        if (allDeviceList.size() > 0) {
            for (int i = 0; i < allDeviceList.size(); i++) {
                if (/*allDeviceList.get(i).getMac()*/("p5dnd7a0392210").equals(mac)) {
                    Double lng = allDeviceList.get(i).getLongitude();
                    Double lat = allDeviceList.get(i).getLatitude();
                    List<Integer> iList = new ArrayList<Integer>();
                    //求出每台设备和每台国控站的距离,距离大于5000米的舍弃
                    for (int j = 0; j < monitorPoints.size(); j++) {
                        Double distance = 0.0;
                        Double mLat = monitorPoints.get(j).getLatitude();
                        Double mLng = monitorPoints.get(j).getLongitude();
                        distance = mapUtils.getDistance(lng, lat, mLng, mLat);
                        if (distance < 5000) {
                            iList.add(j);
                        } else {
                            continue;
                        }
                    }
                    List<Integer> indexList = new ArrayList<Integer>();
                    if (iList.size() > 0) {
                        for (int q = 0; q < iList.size(); q++) {
                            int index = iList.get(q);
                            Double latitude = monitorPoints.get(index).getLatitude();
                            Double longitude = monitorPoints.get(index).getLongitude();
                            Double angle = mapUtils.getAngle(new MyLatLng(lng, lat), new MyLatLng(longitude, latitude));
                            Double angleDiff = angle - Double.parseDouble(windData);
                            if (Math.abs(angleDiff) < 30.0) {
                                indexList.add(index);
                            } else {
                                continue;
                            }
                        }
                    }
                    List<MonitorPoint> monitorPoints1 = new ArrayList<MonitorPoint>();
                    if (indexList.size() > 0) {
                        for (int k = 0; k < indexList.size(); k++) {
                            MonitorPoint monitorPoint1 = monitorPoints.get(indexList.get(k));
                            monitorPoints1.add(monitorPoint1);
                        }
                    }
                    //System.out.println(monitorPoints1.size());
                    if (monitorPoints1.size() > 0) {
                        drlist = new ArrayList();
                        for (MonitorPoint point : monitorPoints1) {
                            List<DeviceRoad> list = deviceRoadMapper.getData(mac, point.getId());
                            drlist.add(list);
                        }
                    }
                    //System.out.println("==========" + drlist);
                }
            }
        }
        return drlist;
    }
}
src/main/java/com/moral/service/impl/HistorySpecialServiceImpl.java
New file
@@ -0,0 +1,16 @@
package com.moral.service.impl;
import com.moral.mapper.HistorySpecialMapper;
import com.moral.service.HistoryService;
import com.moral.service.HistorySpecialService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
public class HistorySpecialServiceImpl implements HistorySpecialService {
    @Resource
    HistorySpecialMapper historySpecialMapper;
}
src/main/resources/mapper/DeviceRoadMapper.xml
New file
@@ -0,0 +1,9 @@
<?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.DeviceRoadMapper">
    <select id="getData" resultType="com.moral.entity.DeviceRoad">
        select * from device_road where mac=#{mac} and national_monitorPoint_id=#{monitorPointId}
    </select>
</mapper>
src/main/resources/mapper/HistorySpecialMapper.xml
New file
@@ -0,0 +1,5 @@
<?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.HistorySpecialMapper">
</mapper>
src/main/resources/mapper/MonitorPointMapper.xml
@@ -203,4 +203,20 @@
            province_code = #{provinceCode}
        </if>
    </select>
    <select id="byCodeGetMonitor" resultType="com.moral.entity.MonitorPoint">
        select * from monitor_point
        where
        <if test="townCode != null">
            town_code = #{townCode}
        </if>
        <if test="areaCode != null">
            area_code = #{areaCode}
        </if>
        <if test="cityCode != null">
            city_code = #{cityCode}
        </if>
        <if test="provinceCode != null">
            province_code = #{provinceCode}
        </if>
    </select>
</mapper>
src/main/webapp/js/newmoralmap.js
@@ -1233,6 +1233,45 @@
        }
    }
    moralMap.getRoad=function(data,regionCode){
        var wind =data["e23"];
        var mac=data["mac"];
        var windSpeed=data["e18"] ;
        var speedLevel;
        if (windSpeed >= 0 && windSpeed <= 0.2) {
            speedLevel = 0;
        } else if (windSpeed > 0.2 && windSpeed <= 1.5) {
            speedLevel = 1;
        } else if (windSpeed > 1.5 && windSpeed <= 3.3) {
            speedLevel = 2;
        } else if (windSpeed > 3.3 && windSpeed <= 5.4) {
            speedLevel = 3;
        } else if (windSpeed > 5.4 && windSpeed <= 7.9) {
            speedLevel = 4;
        } else if (windSpeed > 7.9 && windSpeed <= 10.7) {
            speedLevel = 5;
        } else if (windSpeed > 10.7 && windSpeed <= 13.8) {
            speedLevel = 6;
        } else if (windSpeed > 13.8 && windSpeed <= 17.1) {
            speedLevel = 7;
        } else if (windSpeed > 17.1) {
            speedLevel = 8;
        }
        $.ajax({
            url: "/screen/getAlarm",
            type: "get",
            dataType: "json",
            data:{"windData":wind,"code":regionCode,"mac":mac,"speedLevel":speedLevel},
            success: function (info) {
                console.log("---------------"+info);
            },
        })
    }
    moralMap.refreshWindDir = function (devicesInfo) {
        var deviceInfo = devicesInfo;
        var mac = deviceInfo["mac"];
src/main/webapp/view/newmap.jsp
@@ -370,7 +370,6 @@
<textarea id="close" hidden></textarea>
<div class="main_body">
    <%--<input  id="button" type="button" value="点击" onclick="getJs();">--%>
    <div class="tools_box">
        <div class="charts_btn">
        </div>
@@ -705,6 +704,7 @@
            //获得消息事件
            ws.onmessage = function (msg) {
                // $("#searchParam").val(JSON.parse(msg.data));
                moralMap.getRoad(JSON.parse(JSON.parse(msg.data)),regionCode);
                moralMap.refreshWindDir(JSON.parse(JSON.parse(msg.data)));
                /*  if (moralMap.showSensors && typeof (moralMap.showSensors) == "function") {
                      moralMap.showSensors(JSON.parse(JSON.parse(msg.data)));