kaiyu
2020-09-22 30d07fbe902f3013a65a7c00fa141b119610a8f7
Merge branch 'master' of http://blit.7drlb.com:8888/r/screen_api_v2
7 files modified
140 ■■■■■ changed files
src/main/java/com/moral/config/WebSocketConfig.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java 68 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/webSocketServer/WebSocketServer.java 1 ●●●● patch | view | raw | blame | history
src/main/webapp/js/moralmap.js 4 ●●●● patch | view | raw | blame | history
src/main/webapp/js/newmoralmap.js 4 ●●●● patch | view | raw | blame | history
src/main/webapp/view/cartrajectory.jsp 37 ●●●● patch | view | raw | blame | history
src/main/webapp/view/newmap.jsp 23 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/config/WebSocketConfig.java
@@ -14,7 +14,8 @@
@Configuration
public class WebSocketConfig {
/*    @Bean
    //本地测试需要将注释解开
    /*@Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }*/
src/main/java/com/moral/controller/ScreenController.java
@@ -34,26 +34,7 @@
import com.moral.entity.alarm.AlarmSensorLevel;
import com.moral.entity.charts.DataSortCondition;
import com.moral.entity.layout.RealTimeDeviceLayout;
import com.moral.service.AccountService;
import com.moral.service.AlarmConfigService;
import com.moral.service.AlarmDailyService;
import com.moral.service.AreaService;
import com.moral.service.DeviceService;
import com.moral.service.DeviceVersionService;
import com.moral.service.DictionaryDataService;
import com.moral.service.HangzhouAqiService;
import com.moral.service.HistoryDailyService;
import com.moral.service.HistoryHourlyService;
import com.moral.service.HistoryMinutelyService;
import com.moral.service.HistoryService;
import com.moral.service.MachineActivateService;
import com.moral.service.MonitorPointService;
import com.moral.service.OrganizationLayoutService;
import com.moral.service.OrganizationService;
import com.moral.service.QualityDailyService;
import com.moral.service.SensorService;
import com.moral.service.SensorUnitService;
import com.moral.service.WeatherService;
import com.moral.service.*;
import com.moral.util.*;
import com.rabbitmq.client.*;
@@ -115,6 +96,9 @@
    MonitorPointService monitorPointService;
    @Resource
    DeviceVersionService deviceVersionService;
  /*  @Resource
    HistorySpecialService historySpecialService;*/
    /**
     * The screen service.
@@ -691,26 +675,37 @@
        return new ResultBean<List<MonitorPoint>>(monitorPoints);
    }
    /*
    * 参数:monitorPoint=368&mac=p5dnd7a0392018&sensorKey=e92&time=2020-08-11
    * 获取传感器均值接口
    * */
    @GetMapping("report_avg_datas")
    public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgData(HttpServletRequest request)
            throws Exception {
        Map<String, Object> parameters = getParametersStartingWith(request, null);
        //该方法用于判断时间是具体到年月日
        ParameterUtils.getTimeType4Time(parameters);
        parameters.put("monitorPointId", parameters.remove("monitorPoint"));
        Object sensorKey = parameters.remove("sensorKey");
        parameters.put("sensors", Arrays.asList(sensorKey));
        // monitorPointService.isCompensateCalculation(parameters);
        List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
        for (Map<String, Object> map : list) {
            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);
        String time1= (String) parameters.get("time");
        String mac1= (String) parameters.get("mac");
        List<Map<String, Object>> list=null;
        if (mac1.equals("p5dnd7a0392018") && time1.substring(0,4).equals("2019") ){
                list=null;
        }else {
            parameters.put("monitorPointId", parameters.remove("monitorPoint"));
            Object sensorKey = parameters.remove("sensorKey");
            parameters.put("sensors", Arrays.asList(sensorKey));
            // monitorPointService.isCompensateCalculation(parameters);
            list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
            for (Map<String, Object> map : list) {
                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);
                }
                map.put("value", map.remove(sensorKey));
            }
            map.put("value", map.remove(sensorKey));
        }
        return new ResultBean<List<Map<String, Object>>>(list);
    }
@@ -1504,13 +1499,15 @@
        String startHour = st.substring(st.lastIndexOf("-") + 1);
        String startTime = startYearAndDay + " " + startHour + ":00:00";
        String et = parameters.get("endTime").toString();
        String endYearAndDay = et.substring(0, st.lastIndexOf("-"));
        String endHour = et.substring(et.lastIndexOf("-") + 1);
        int endHourValue = Integer.valueOf(endHour);
        String endTime=endYearAndDay + " " + endHour + ":00:00";
       /* int endHourValue = Integer.valueOf(endHour);
        int startHourValue = Integer.valueOf(startHour);
        if (endHourValue <= startHourValue) {
            endHourValue = startHourValue + 1;
        }
        String endTime = startYearAndDay + " " + endHourValue + ":00:00";
        String endTime = startYearAndDay + " " + endHourValue + ":00:00";*/
        parameters.put("startTime", startTime);
        parameters.put("endTime", endTime);
        String mac = parameters.get("mac").toString();
@@ -1525,6 +1522,7 @@
            params.put("sensorInfo", sensorList);
            params.put("sensorsMap", sensorsMap);
            String paramsJson = params.toJSONString();
            //System.out.println(paramsJson);
            model.addObject("carTrajectoryParams", paramsJson);
            model.setViewName("cartrajectory");
            return model;
src/main/java/com/moral/webSocketServer/WebSocketServer.java
@@ -114,6 +114,7 @@
        /**从安全Set中 移除当前连接对象*/
        webSocketSet.remove(this);
        try {
            channel.queueDelete("deviceInfo_" + accountId);
            connection.close();
        } catch (IOException e) {
            log.error(e.getMessage());
src/main/webapp/js/moralmap.js
@@ -234,6 +234,10 @@
                    var longitude = 106.638135;
                    var latitude = 29.709625;
                    point = new BMap.Point(longitude, latitude);
                }else if("射阳县" == regoinNames[2]){
                    var longitude = 120.332826;
                    var latitude = 33.772274;
                    point = new BMap.Point(longitude, latitude);
                }
                map.centerAndZoom(point, showZoom);
            } else {
src/main/webapp/js/newmoralmap.js
@@ -218,6 +218,10 @@
                    var longitude = 106.638135;
                    var latitude = 29.709625;
                    point = new BMap.Point(longitude, latitude);
                }else if("射阳县" == regoinNames[2]){
                    var longitude = 120.332826;
                    var latitude = 33.772274;
                    point = new BMap.Point(longitude, latitude);
                }
                map.centerAndZoom(point, showZoom);
            } else {
src/main/webapp/view/cartrajectory.jsp
@@ -263,6 +263,26 @@
    }
    var trackPoints = []; //用来存放从后台获取到的所有历史轨迹点的数据
    if (sensorInfo.length > 0) {
        for (var i = 0; i <sensorInfo.length ; i++) {
            if (typeof (sensorInfo[i]["e76"]) == "undefined") {
                sensorInfo.splice(i,1);
                i--;
            }else {
                var lon = parseFloat(sensorInfo[i].e76.substr(0, sensorInfo[i].e76.length - 1));
                var lat = parseFloat(sensorInfo[i].e77.substr(0, sensorInfo[i].e77.length - 1));
                if (lon>150 || lon<70 || lat<=20 || lat>60){
                    sensorInfo.splice(i,1);
                    i--;
                }
                if (i>1){
                    if (sensorInfo[i]["e76"]==sensorInfo[i-1]["e76"] && sensorInfo[i]["e77"]==sensorInfo[i-1]["e77"]){
                        sensorInfo.splice(i,1);
                        i--;
                    }
                }
            }
        }
        $.each(sensorInfo, function (item, value) {
            if (typeof (value.e76) == "undefined") {
                showNoFlightTrajectory();
@@ -340,11 +360,18 @@
            }else {
                var data="<p style='height: 30px;font-size: 15px;font-weight: bold;padding: 10px 0 0 13px;color: #2aabd2'>"+"走航信息"+"</p>";
                data=data+"<p style='padding:10px 0 0 18px '>"+"时间:"+info["time"]+"</p>";
                data=data+"<p style='padding:10px 0 0 18px '>"+"PM2.5:"+info["e1"]+"</p>";
                data=data+"<p style='padding:10px 0 0 18px '>"+"PM10:"+info["e2"]+"</p>";
                data=data+"<p style='padding:10px 0 0 18px '>"+"TSP:"+info["e40"]+"</p>";
                if (typeof(info["e17"])==="undefined"){
                }else {
                if (typeof(info["e1"])!="undefined"){
                    data=data+"<p style='padding:10px 0 0 18px '>"+"PM2.5:"+info["e1"]+"</p>";
                }
                if (typeof(info["e2"])!="undefined"){
                    data=data+"<p style='padding:10px 0 0 18px '>"+"PM10:"+info["e2"]+"</p>";
                }
                if (typeof(info["e40"])!="undefined"){
                    data=data+"<p style='padding:10px 0 0 18px '>"+"TSP:"+info["e40"]+"</p>";
                }
                if (typeof (info["e17"])!="undefined"){
                    data=data+"<p style='padding:10px 0 0 18px '>"+"VOCs总量:"+info["e17"]+"</p>";
                }
                textArea=textArea+data+"</div>";
src/main/webapp/view/newmap.jsp
@@ -365,7 +365,12 @@
    }
</style>
<body>
<div>
</div>
<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>
@@ -522,15 +527,15 @@
                                alert(equStr);
                            }
                        }
                        if("国控站"===obj["monitorPoint"]["description"]){
                        if ("国控站" === obj["monitorPoint"]["description"]) {
                            var icon05 = new BMap.Icon("/img/ico05.png", new BMap.Size(50, 50));
                            var mark05 = new BMap.Marker(new BMap.Point(obj["monitorPoint"]["longitude"], obj["monitorPoint"]["latitude"]), {icon: icon05});
                            moralMap.addOverlay(mark05);
                        }else if("省控站"===obj["monitorPoint"]["description"]){
                        } else if ("省控站" === obj["monitorPoint"]["description"]) {
                            var icon06 = new BMap.Icon("/img/ico06.png", new BMap.Size(50, 50));
                            var mark06 = new BMap.Marker(new BMap.Point(obj["monitorPoint"]["longitude"], obj["monitorPoint"]["latitude"]), {icon: icon06});
                            moralMap.addOverlay(mark06);
                        }else if("县控站"===obj["monitorPoint"]["description"]){
                        } else if ("县控站" === obj["monitorPoint"]["description"]) {
                            var icon08 = new BMap.Icon("/img/ico08.png", new BMap.Size(50, 50));
                            var mark08 = new BMap.Marker(new BMap.Point(obj["monitorPoint"]["longitude"], obj["monitorPoint"]["latitude"]), {icon: icon08});
                            moralMap.addOverlay(mark08);
@@ -697,7 +702,6 @@
            ws = new WebSocket('ws://' + hostAndPort + '/screen/webSocket/' + orgId + '&' + accountId + '_' + regionCode);
            ws.onopen = function () {
            };
            //获得消息事件
            ws.onmessage = function (msg) {
                // $("#searchParam").val(JSON.parse(msg.data));
@@ -705,14 +709,20 @@
                /*  if (moralMap.showSensors && typeof (moralMap.showSensors) == "function") {
                      moralMap.showSensors(JSON.parse(JSON.parse(msg.data)));
                  }*/
                if ($("#close").html() == "CloseMq") {
                    ws.close();
                }
            };
            //关闭事件
            ws.onclose = function () {
                $("#close").html("websocket已经关闭");
            };
            //发生了错误事件
            ws.onerror = function () {
                $("#close").html("websocket关闭错误");
            };
        }
    })(jQuery);
@@ -820,6 +830,7 @@
    }
    function callJS(jsonData) {
        $("#close").html(jsonData);
        var jsonData = JSON.parse(jsonData);
        var methodName = jsonData.methodName;
        // $("#searchParam").val(JSON.stringify(jsonData));
@@ -829,7 +840,11 @@
            var states = jsonData.states;
            moralMap.refreshState(states);
        } else if ("DeliverSensors" == methodName) {
            $("#close").html(methodName);
            moralMap.showSensors(jsonData);
        } else if ("CloseMq" == methodName) {
            $("#close").html(methodName);
        }
    }
</script>