ZhuDongming
2020-06-28 f55f6e05bae945d275101592782fb3b8980d77cf
update风速风向显示设置
1 files deleted
8 files added
8 files modified
158 ■■■■ changed files
src/main/java/com/moral/controller/ScreenController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Device.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DeviceMapper.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/webSocketServer/WebSocketServer.java 15 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceMapper.xml 19 ●●●●● patch | view | raw | blame | history
src/main/webapp/img/icoWind01.png patch | view | raw | blame | history
src/main/webapp/img/icoWind02.png patch | view | raw | blame | history
src/main/webapp/img/icoWind03.png patch | view | raw | blame | history
src/main/webapp/img/icoWind04.png patch | view | raw | blame | history
src/main/webapp/img/icoWind05.png patch | view | raw | blame | history
src/main/webapp/img/icoWind06.png patch | view | raw | blame | history
src/main/webapp/img/icoWind07.png patch | view | raw | blame | history
src/main/webapp/img/icoWind08.png patch | view | raw | blame | history
src/main/webapp/img/wind_dir.png patch | view | raw | blame | history
src/main/webapp/js/newmoralmap.js 93 ●●●● patch | view | raw | blame | history
src/main/webapp/view/newmap.jsp 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java
@@ -620,6 +620,15 @@
    @RequestMapping(value = "/get-devices", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "设备信息", notes = "设备信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "orgId",defaultValue = "5", value = "组织Id", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "regionCode",defaultValue = "320583", value = "地区编码", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "Fe", defaultValue = "31.485018",value = "东北角纬度", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "Ge", defaultValue = "121.378395",value = "东北角经度", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "Ke", defaultValue = "31.296614",value = "西南角纬度", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "Le", defaultValue = "120.59651",value = "西南角经度", required = true, paramType = "query", dataType = "String")
    })
    public ResultBean getDevices(@RequestParam("orgId") Integer orgId, MapBounds mapBounds,
                                 @RequestParam("regionCode") String regionCode) {
        ResultBean<List<Device>> resultBean = new ResultBean();
src/main/java/com/moral/entity/Device.java
@@ -119,4 +119,7 @@
    private Profession profession;
    @Transient
    private DeviceProperty deviceProperty;
    @Transient
    private Boolean hasWindInfo;
}
src/main/java/com/moral/mapper/DeviceMapper.java
@@ -4,11 +4,10 @@
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Device;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.entity.Example;
public interface DeviceMapper extends BaseMapper<Device>{
@@ -51,4 +50,6 @@
    List<Device> getDeviceById2(@Param("id") int id);
    List<Device> getDeviceById3(@Param("id") int id);
    List<Integer> getHasWindDirAndWindSpeedDeviceVersion();
}
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -206,6 +206,7 @@
     */
    @Override
    public List<Device> query(Map<String, Object> params) {
        List<Integer> dv = deviceMapper.getHasWindDirAndWindSpeedDeviceVersion();
        Object orgIdObj = params.get("orgId");
        List<Device> deviceList = null;
        if (orgIdObj != null) {
@@ -215,6 +216,13 @@
            deviceList = deviceMapper.selectByMap(params);
            // loadDeviceState(deviceList);
        }
      for(Device d:deviceList){
            if(dv.contains(d.getDeviceVersionId())){
                d.setHasWindInfo(true);
            }else{
                d.setHasWindInfo(false);
            }
      }
        return deviceList;
    }
src/main/java/com/moral/webSocketServer/WebSocketServer.java
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.TimeoutException;
import javax.websocket.OnClose;
import javax.websocket.OnError;
@@ -38,6 +39,10 @@
    private String regionCode;
    private Connection connection;
    private Channel channel;
    // 存放session的集合,很重要!!
    private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<WebSocketServer>();
@@ -64,8 +69,8 @@
            factory.setUsername("guest");
            factory.setPassword("guest_pass");
            String routingKey = orgId+".*";
            Connection connection = factory.newConnection();
            Channel channel = connection.createChannel();
            connection = factory.newConnection();
            channel = connection.createChannel();
            //声明队列,主要为了防止消息接收者先运行此程序,队列还不存在时创建队列。
            channel.queueDeclare(QUEUE_NAME, false, false, true, null);
            channel.queueBind(QUEUE_NAME,"screens_data",routingKey);
@@ -93,6 +98,12 @@
    public void onClose() {
        /**从安全Set中 移除当前连接对象*/
        webSocketSet.remove(this);
        try {
            channel.close();
            connection.close();
        }catch (IOException | TimeoutException e){
            log.error(e.getMessage());
        }
    }
    @OnMessage
src/main/resources/mapper/DeviceMapper.xml
@@ -440,5 +440,24 @@
        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 from
        device_version
        where id in
        (SELECT s.device_version_id
        from
        (SELECT device_version_id
        from
        device_version_sensor
        WHERE sensor_Id in
        (SELECT id from
        sensor
        where
        sensor_key='e18' or sensor_key='e23')) s
        GROUP BY s.device_version_id
        HAVING count(1)=2)
        and is_delete=0;
    </select>
</mapper>
src/main/webapp/img/icoWind01.png
src/main/webapp/img/icoWind02.png
src/main/webapp/img/icoWind03.png
src/main/webapp/img/icoWind04.png
src/main/webapp/img/icoWind05.png
src/main/webapp/img/icoWind06.png
src/main/webapp/img/icoWind07.png
src/main/webapp/img/icoWind08.png
src/main/webapp/img/wind_dir.png
Binary files differ
src/main/webapp/js/newmoralmap.js
@@ -644,6 +644,7 @@
        return listView;
    }
    moralMap.MoralMarker = function (option) {
        var _option = option;
        var _pointObj = new BMap.Point(_option['longitude'], _option['latitude']);
@@ -696,21 +697,60 @@
        })
    }
    moralMap.WindMarker = function (option, target) {
    moralMap.WindMarker = function (option, moralMap) {
        var _option = option;
        var _pointObj = new BMap.Point(_option['longitude'], _option['latitude']);
        var _iconObj = new BMap.Icon("/img/wind_dir.png", new BMap.Size(25, 25));
        var _iconObj = _getWindIcon(1);
        this._point = _pointObj;
        function _getWindIcon(speedLevel) {
            speedLevel = speedLevel == null ? 0 : speedLevel;
            var icon = _option["icon"];
            var url = icon["url"] + speedLevel + ".png";
            return new BMap.Icon(url, new BMap.Size(icon["width"], icon["height"]), {
                imageSize: new BMap.Size(icon["width"], icon["height"])
            });
        }
        this.constructor.call(this, _pointObj, {
            icon: _iconObj,
            offset: new BMap.Size(0, -35),
            offset: new BMap.Size(0, -11),
            enableMassClear: true
        })
        return $.extend(this, {
            refreshWindDir: function (windDir) {
            refreshWindDir: function (windDir, windSpeed) {
                //状态发生变化的时候设置图标风向
                this.setRotation(windDir);
                if (windDir == undefined || windSpeed == undefined) {
                    moralMap.removeOverlay(this);
                } else {
                    var speedLevel;
                    if (windSpeed >= 0.0 && windSpeed <= 0.2) {
                        speedLevel = 0;
                    } else if (windSpeed >= 0.3 && windSpeed <= 1.5) {
                        speedLevel = 1;
                    } else if (windSpeed >= 1.6 && windSpeed <= 3.3) {
                        speedLevel = 2;
                    } else if (windSpeed >= 3.4 && windSpeed <= 5.4) {
                        speedLevel = 3;
                    } else if (windSpeed >= 5.5 && windSpeed <= 7.9) {
                        speedLevel = 4;
                    } else if (windSpeed >= 8.0 && windSpeed <= 10.7) {
                        speedLevel = 5;
                    } else if (windSpeed >= 10.8 && windSpeed <= 13.8) {
                        speedLevel = 6;
                    } else if (windSpeed >= 13.9 && windSpeed <= 17.1) {
                        speedLevel = 7;
                    } else if (windSpeed >= 17.2) {
                        speedLevel = 8;
                    }
                }
                if (speedLevel == 0) {
                    moralMap.removeOverlay(this);
                } else {
                    var iconObj = _getWindIcon(speedLevel);
                    this.setIcon(iconObj);
                    this.setRotation(windDir);
                }
            },
            getOption: function () {
                return _option;
@@ -823,14 +863,19 @@
                }
            }
        }
        var windMarker = new moralMap.WindMarker(option);
        var icon = {};
        icon["url"] = "/img/icoWind0";
        icon["width"] = 25;
        icon["height"] = 25;
        option["icon"] = icon;
        var windMarker = new moralMap.WindMarker(option, moralMap);
        moralMap.putDevice(option['mac'], windMarker);
        var refreshWindMarker = windMarker.refreshWindDir;
        return $.extend(windMarker, {
            refreshWindDir: function (data) {
                if (data != null && data != "") {
                    this.setData(data); //更新数据
                    refreshWindMarker.call(this, data["e23"]);
                    refreshWindMarker.call(this, data["e23"], data["e18"]);
                }
            },
            setData: function (data) {
@@ -898,15 +943,15 @@
        }
        var mouseOverHandle = option['mouseover'];
        moralMarker.addEventListener("mouseover", function () {
         /*   var obj = {};
            obj['methodName'] = 'deliverMac';
            obj['mac'] = option['mac'];
            var objStr = JSON.stringify(obj);
            if (!!window['external'] && !!window['external']['callWin']) {
                window['external'].callWin(objStr);
            } else {
                alert(objStr);
            }*/
            /*   var obj = {};
               obj['methodName'] = 'deliverMac';
               obj['mac'] = option['mac'];
               var objStr = JSON.stringify(obj);
               if (!!window['external'] && !!window['external']['callWin']) {
                   window['external'].callWin(objStr);
               } else {
                   alert(objStr);
               }*/
            moralMap.showSensors = function (jsonData) {
                var deviceSensors = jsonData;
@@ -958,14 +1003,14 @@
        });
        moralMarker.addEventListener("mouseout", function () {
          /*  var obj = {};
            obj['methodName'] = 'stopDeliverMac';
            var objStr = JSON.stringify(obj);
            if (!!window['external'] && !!window['external']['callWin']) {
                window['external'].callWin(objStr);
            } else {
                alert(objStr);
            }*/
            /*  var obj = {};
              obj['methodName'] = 'stopDeliverMac';
              var objStr = JSON.stringify(obj);
              if (!!window['external'] && !!window['external']['callWin']) {
                  window['external'].callWin(objStr);
              } else {
                  alert(objStr);
              }*/
            moralMap.closeInfoWindow();
        });
src/main/webapp/view/newmap.jsp
@@ -487,9 +487,11 @@
                            }
                        }
                        var moralMask = new moralMap.Equipment(obj);
                        var moralDeviceWind = new moralMap.Device(obj);
                        moralMap.addOverlay(moralMask);
                        moralMap.addOverlay(moralDeviceWind);
                        if (obj['hasWindInfo']) {
                            var moralDeviceWind = new moralMap.Device(obj);
                            moralMap.addOverlay(moralDeviceWind);
                        }
                    }
                }
            }