ZhuDongming
2019-09-03 2759eea24b4d6cd5e0e8f8c88eae69a59b48d299
update 污染传播接口
2 files modified
106 ■■■■ changed files
src/main/java/com/moral/controller/ScreenController.java 3 ●●●●● patch | view | raw | blame | history
src/main/webapp/view/pollutionsource.jsp 103 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java
@@ -1232,12 +1232,9 @@
        String time = YearAndDay + " " + Hour + ":00:00";
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime timeLocalDateTime = LocalDateTime.parse(time, dateTimeFormatter);
        System.out.println(timeLocalDateTime);
        int month = timeLocalDateTime.getMonth().getValue();
        Point dirPoint = historyHourlyService.getDirPoint(parameters);
        Map<String, Object> getPollutionSourceData = historyHourlyService.getPollutionSourceData(parameters);
        System.out.println(dirPoint.toString());
        System.out.println("getPollutionSourceData:" + getPollutionSourceData);
        String mac = parameters.get("mac").toString();
        Device device = deviceService.getDeviceByMac(mac, false);
        JSONObject params = new JSONObject();
src/main/webapp/view/pollutionsource.jsp
@@ -97,11 +97,33 @@
        line-height: 100px;
        text-align: center;
    }
    #show {
        position: absolute;
        z-index: 1;
        top: 30px;
        right: 50px;
        display: inline-block;
        width: 80px;
        height: 40px;
        border-width: 0px;
        border-radius: 3px;
        background: #6495ED;
        cursor: pointer;
        outline: none;
        color: white;
        font-size: 20px;
    }
    #show:hover {
        background: #5CACEE;
    }
</style>
<body>
<div class="main_body">
    <div id="cpm">查无数据</div>
    <input type="button" id="show" value="计算"/>
    <div id="cpm">无法推测来源</div>
    <div id="mapCanvas"></div> <!-- 百度地图 -->
    <!-- 传sensorInfo,regionCode,regionName,monitorPoint,device-->
    <div id="pollutionSourceParams" style="display: none;">
@@ -122,7 +144,6 @@
    var device = params["device"];
    var dirPoint = new BMap.Point(params["dirPoint"].lng, params["dirPoint"].lat);
    var getPollutionSourceData = params["getPollutionSourceData"];
    var windSpeed = parseFloat(getPollutionSourceData["e18"]);
    var map = new BMap.Map("mapCanvas", {enableMapClick: false});
    map.setMapStyle(mapStyle);
    map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
@@ -132,11 +153,6 @@
    });
    map.addControl(navigation);
    map.addControl(new BMap.ScaleControl());
    if ($.isEmptyObject(dirPoint) || $.isEmptyObject(getPollutionSourceData) || getPollutionSourceData["e6"] == 0 || getPollutionSourceData["e18"] == 0 || getPollutionSourceData["e23"] == 0 || windSpeed <= 0.03) {
        showNoData();
    } else {
        var humidity = parseFloat(getPollutionSourceData["e6"]);
        var windDir = parseFloat(getPollutionSourceData["e23"]);
        var longitude = params["device"]["longitude"];
        var latitude = params["device"]["latitude"];
        var point = new BMap.Point(longitude, latitude);
@@ -144,6 +160,20 @@
        var marker = new BMap.Marker(point, {icon: icon, offset: new BMap.Size(0, -20)});
        map.addOverlay(marker);
        map.centerAndZoom(point, 16);
    $("#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" || getPollutionSourceData["e18"] <= 0.03) {
                showNoData();
            } else {
                var humidity = parseFloat(getPollutionSourceData["e6"]);
                var temperature = parseFloat(getPollutionSourceData["e7"]);
                var windSpeed = parseFloat(getPollutionSourceData["e18"]);
                var windDir = parseFloat(getPollutionSourceData["e23"]);
                var iconDir = new BMap.Icon("/img/ico07.gif", new BMap.Size(50, 50));
                var markerDir = new BMap.Marker(dirPoint, {icon: iconDir, offset: new BMap.Size(0, -20)});
        //centre:椭圆中心点,X:横向经度,Y:纵向纬度
        function add_oval(centre, x, y) {
@@ -162,7 +192,7 @@
        //以画多边形区域的方法画扇形区域 画出以point点为圆心,半径为radius,夹角从sDegree到eDegree的扇形
        function Sector(point, radius, sDegree, eDegree) {
            var points = []; //创建构成多边形的点数组
            var step = ((eDegree - sDegree) / 10) || 10; //根据扇形的总夹角确定每步夹角度数,最大为10
                    var step = ((eDegree - sDegree) / 100) || 1; //根据扇形的总夹角确定每步夹角度数,最大为10
            points.push(point);
            for (var i = sDegree; i < eDegree + 0.001; i += step) { //循环获取每步的圆弧上点的坐标,存入点数组
                points.push(EOffsetBearing(point, radius, i));
@@ -183,6 +213,7 @@
        var distance = windSpeed * 3600;
        var winDirStart = 240 - windDir;
        var winDirEnd = 300 - windDir;
                setTimeout(function () {
        var oval = new BMap.Polygon(Sector(dirPoint, distance, winDirStart, winDirEnd), {
            strokeColor: "grey",
            strokeWeight: 1,
@@ -190,6 +221,8 @@
            fillColor: "grey"
        });
        map.addOverlay(oval);
                }, 1500);
                setTimeout(function () {
        var oval = new BMap.Polygon(Sector(dirPoint, distance * 0.66, winDirStart, winDirEnd), {
            strokeColor: "grey",
            strokeWeight: 1,
@@ -197,21 +230,26 @@
            fillColor: "grey"
        });
        map.addOverlay(oval);
        var oval = new BMap.Polygon(Sector(dirPoint, distance * 0.33, winDirStart, winDirEnd), {
            strokeColor: "grey",
            strokeWeight: 1,
            strokeOpacity: 0.4,
            fillColor: "grey"
        });
        map.addOverlay(oval);
        var polyline = new BMap.Polyline([
                dirPoint,
                point
            ],
            {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1}
        );
        addArrow(polyline, 0, Math.PI / 7, windSpeed, humidity);
                    addArrow(polyline, 0, Math.PI / 7, temperature, humidity, windSpeed, windDir);
                }, 1000);
                setTimeout(function () {
                    var oval = new BMap.Polygon(Sector(dirPoint, distance * 0.33, winDirStart, winDirEnd), {
                        strokeColor: "grey",
                        strokeWeight: 1,
                        strokeOpacity: 0.4,
                        fillColor: "grey"
                    });
                    map.addOverlay(markerDir);
                    map.addOverlay(oval);
                }, 500);
        var winfowTextCause = "<p style='height: 44px;line-height: 22px'>汽车尾气,工厂废气,以及周边地区农田秸秆焚烧,污染传播途径是根据风向来做出调整</p>";
        var winfowTextSource;
        var supplement;
@@ -274,7 +312,7 @@
        });
    }
    function addArrow(polyline, length, angleValue, windSpeed, humidity) {
            function addArrow(polyline, length, angleValue, temperature, humidity, windSpeed, windDir) {
        var linePoint = polyline.getPath();// 线的坐标串
        var arrowCount = linePoint.length;
        for (var i = 1; i < arrowCount; i++) { // 在拐点处绘制箭头
@@ -313,12 +351,30 @@
                pixelY = pixelTemY - Math.tan(angle) * r / param;
            }
            var pointMiddle = map.pixelToPoint(new BMap.Pixel(poMiddleX, poMiddleY));
            lab = new BMap.Label("<P>风速:" + windSpeed + "m/s</p><P>湿度:" + humidity + "°</p>", {
                    var windDirection;
                    if (windDir == 0) {
                        windDirection = "北风";
                    } else if (windDir == 90) {
                        windDirection = "东风";
                    } else if (windDir == 180) {
                        windDirection = "南风";
                    } else if (windDir == 270) {
                        windDirection = "西风";
                    } else if (windDir > 0 && windDir < 90) {
                        windDirection = "东北风";
                    } else if (windDir > 90 && windDir < 180) {
                        windDirection = "东南风";
                    } else if (windDir > 180 && windDir < 270) {
                        windDirection = "西南风";
                    } 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, -20)
                        offset: new BMap.Size(-50, -40)
            });
            lab.setStyle({
                color: "#FFFFFF",
                        color: "#EE3B3B",
                fontSize: "16px",
                backgroundColor: "1",
                border: "0",
@@ -329,13 +385,12 @@
    };
    function showNoData() {
        var longitude = 120.987287;
        var latitude = 31.391562;
        var point = new BMap.Point(longitude, latitude);
        map.centerAndZoom(point, 17);
        setTimeout(function () {
            document.getElementById("cpm").style.display = 'block';
        }, 250);
    };
        }, 1500);
    });
</script>