From baa11d154e41d24a790596899b329faaa19b24be Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Wed, 13 Nov 2019 09:31:40 +0800 Subject: [PATCH] update污染溯源 --- src/main/webapp/view/pollutionsource.jsp | 65 +++++++++++++++++++++++++++----- src/main/resources/mapper/AccountMapper.xml | 4 +- src/main/java/com/moral/controller/ScreenController.java | 3 + src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java | 2 4 files changed, 60 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java index 9a4183f..20c720a 100644 --- a/src/main/java/com/moral/controller/ScreenController.java +++ b/src/main/java/com/moral/controller/ScreenController.java @@ -1215,6 +1215,9 @@ if (MapUtils.isEmpty(getPollutionSourceData)) { getPollutionSourceData = historyHourlyService.getPollutionSourceDataAll(parameters); } + if (MapUtils.isEmpty(getPollutionSourceData)) { + getPollutionSourceData = new HashMap<>(); + } String mac = parameters.get("mac").toString(); Device device = deviceService.getDeviceByMac(mac, false); JSONObject params = new JSONObject(); diff --git a/src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java b/src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java index 01c42b7..314a26d 100644 --- a/src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java +++ b/src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java @@ -109,7 +109,7 @@ Device device = deviceService.getDeviceByMac(mac, false); Point pointEnd = new Point(); if (MapUtils.isNotEmpty(pollutionSourceData)) { - if (pollutionSourceData.get("e18") != null && pollutionSourceData.get("e23") != null && pollutionSourceData.get("e6") != null) { + if (pollutionSourceData.get("e18") != null && pollutionSourceData.get("e23") != null) { double windSpeed = Double.valueOf(pollutionSourceData.get("e18").toString()); double winDir = Double.valueOf(pollutionSourceData.get("e23").toString()); double distance = windSpeed * 3600; diff --git a/src/main/resources/mapper/AccountMapper.xml b/src/main/resources/mapper/AccountMapper.xml index a7e353d..2c97198 100644 --- a/src/main/resources/mapper/AccountMapper.xml +++ b/src/main/resources/mapper/AccountMapper.xml @@ -108,7 +108,7 @@ where a.account_name = #{accountName} and r.is_delete=0 and r.id is not null ) - where m.menu_parent_id=0 + where m.menu_parent_id=0 and m.is_delete=0 order by m.menu_order </select> @@ -132,7 +132,7 @@ where a.account_name = #{accountName} and r.is_delete=0 and r.id is not null ) - where m.menu_parent_id = #{id} + where m.menu_parent_id = #{id} and m.is_delete=0 order by m.menu_order </select> diff --git a/src/main/webapp/view/pollutionsource.jsp b/src/main/webapp/view/pollutionsource.jsp index b9a9f7b..927aa8c 100644 --- a/src/main/webapp/view/pollutionsource.jsp +++ b/src/main/webapp/view/pollutionsource.jsp @@ -123,7 +123,7 @@ <body> <div class="main_body"> <input type="button" id="show" value="������������"/> - <div id="cpm">������������������</div> + <div id="cpm"></div> <div id="mapCanvas"></div> <!-- ������������ --> <!-- ���sensorInfo,regionCode,regionName,monitorPoint,device--> <div id="pollutionSourceParams" style="display: none;"> @@ -162,10 +162,12 @@ var marker = new BMap.Marker(point, {icon: icon, offset: new BMap.Size(0, -20)}); map.addOverlay(marker); map.centerAndZoom(point, 16); - if (!$.isEmptyObject(dirPoint) && !$.isEmptyObject(getPollutionSourceData) && typeof (getPollutionSourceData["e6"]) != "undefined" && typeof (getPollutionSourceData["e7"]) != "undefined" && typeof (getPollutionSourceData["e18"]) != "undefined" && typeof (getPollutionSourceData["e23"]) != "undefined") { + var humidity = 0; + var temperature = 0; + if (!$.isEmptyObject(dirPoint) && !$.isEmptyObject(getPollutionSourceData) && typeof (getPollutionSourceData["e18"]) != "undefined" && typeof (getPollutionSourceData["e23"]) != "undefined" && getPollutionSourceData["e18"] != 0) { var windSpeed = parseFloat(getPollutionSourceData["e18"]); var windDir = parseFloat(getPollutionSourceData["e23"]); - var distance = windSpeed * 3600>108? windSpeed * 3600:108; + var distance = windSpeed * 3600; var winDirStart = 255 - windDir; var winDirEnd = 285 - windDir; var marker1 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.15, winDirStart), { @@ -192,11 +194,15 @@ $("#show").one('click', function () { setTimeout(function () { - if ($.isEmptyObject(dirPoint) || $.isEmptyObject(getPollutionSourceData) || typeof (getPollutionSourceData["e6"]) == "undefined" || typeof (getPollutionSourceData["e7"]) == "undefined" || typeof (getPollutionSourceData["e18"]) == "undefined" || typeof (getPollutionSourceData["e23"]) == "undefined") { + if ($.isEmptyObject(dirPoint) || $.isEmptyObject(getPollutionSourceData) || typeof (getPollutionSourceData["e18"]) == "undefined" || typeof (getPollutionSourceData["e23"]) == "undefined" || getPollutionSourceData["e18"] === 0) { showNoData(); } else { - var humidity = parseFloat(getPollutionSourceData["e6"]); - var temperature = parseFloat(getPollutionSourceData["e7"]); + if (typeof (getPollutionSourceData["e6"]) != "undefined") { + humidity = parseFloat(getPollutionSourceData["e6"]); + } + if (typeof (getPollutionSourceData["e7"]) != "undefined") { + temperature = parseFloat(getPollutionSourceData["e7"]); + } var windSpeed = parseFloat(getPollutionSourceData["e18"]); var windDir = parseFloat(getPollutionSourceData["e23"]); var selectSensorKey = getPollutionSourceData["selectSensorKey"]; @@ -213,7 +219,7 @@ }); map.addOverlay(lab); - var distance = windSpeed * 3600>108? windSpeed * 3600:108; + var distance = windSpeed * 3600; var winDirStartLeft = 240 - windDir; var winDirEndLeft = 250 - windDir; var winDirStartMiddle = 250 - windDir; @@ -475,10 +481,27 @@ } else if (windDir > 270 && windDir < 360) { windDirection = "���������"; } - lab = new BMap.Label("<P>������:" + temperature + "���</p><P>������:" + humidity + "%</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { - position: pointMiddle, - offset: new BMap.Size(-50, -40) - }); + if (temperature != 0 && humidity != 0) { + lab = new BMap.Label("<P>������:" + temperature + "���</p><P>������:" + humidity + "%</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } else if (temperature == 0 && humidity != 0) { + lab = new BMap.Label("<P>������:" + humidity + "%</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } else if (temperature != 0 && humidity == 0) { + lab = new BMap.Label("<P>������:" + temperature + "���</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } else { + lab = new BMap.Label("<P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } lab.setStyle({ color: "#EE3B3B", fontSize: "16px", @@ -493,6 +516,26 @@ function showNoData() { map.centerAndZoom(point, 17); setTimeout(function () { + if (JSON.stringify(getPollutionSourceData) == JSON.stringify({})) { + document.getElementById("cpm").innerText = "���������������������������"; + } else { + if (getPollutionSourceData["e18"] === 0) { + document.getElementById("cpm").style.width = '380px'; + document.getElementById("cpm").innerText = "���������0���������������������"; + } + if (typeof (getPollutionSourceData["e18"]) == "undefined") { + document.getElementById("cpm").style.width = '400px'; + document.getElementById("cpm").innerText = "������������������������������������"; + } + if (typeof (getPollutionSourceData["e23"]) == "undefined") { + document.getElementById("cpm").style.width = '400px'; + document.getElementById("cpm").innerText = "������������������������������������"; + } + if (typeof (getPollutionSourceData["e18"]) == "undefined" && typeof (getPollutionSourceData["e23"]) == "undefined") { + document.getElementById("cpm").style.width = '500px'; + document.getElementById("cpm").innerText = "������������������������������������������������"; + } + } document.getElementById("cpm").style.display = 'block'; }, 250); }; -- Gitblit v1.8.0