1 files deleted
	
		
		8 files added
	
		
		8 files modified
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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(); | 
|---|
|  |  |  | 
|---|
|  |  |  | private Profession profession; | 
|---|
|  |  |  | @Transient | 
|---|
|  |  |  | private DeviceProperty deviceProperty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transient | 
|---|
|  |  |  | private Boolean hasWindInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 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>{ | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Device> getDeviceById2(@Param("id") int id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Device> getDeviceById3(@Param("id") int id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Integer> getHasWindDirAndWindSpeedDeviceVersion(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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) { | 
|---|
|  |  |  | 
|---|
|  |  |  | deviceList = deviceMapper.selectByMap(params); | 
|---|
|  |  |  | // loadDeviceState(deviceList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Device d:deviceList){ | 
|---|
|  |  |  | if(dv.contains(d.getDeviceVersionId())){ | 
|---|
|  |  |  | d.setHasWindInfo(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | d.setHasWindInfo(false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return deviceList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.util.concurrent.CopyOnWriteArraySet; | 
|---|
|  |  |  | import java.util.concurrent.TimeoutException; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.websocket.OnClose; | 
|---|
|  |  |  | import javax.websocket.OnError; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String regionCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Connection connection; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Channel channel; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 存放session的集合,很重要!! | 
|---|
|  |  |  | private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<WebSocketServer>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  | public void onClose() { | 
|---|
|  |  |  | /**从安全Set中 移除当前连接对象*/ | 
|---|
|  |  |  | webSocketSet.remove(this); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | channel.close(); | 
|---|
|  |  |  | connection.close(); | 
|---|
|  |  |  | }catch (IOException | TimeoutException e){ | 
|---|
|  |  |  | log.error(e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @OnMessage | 
|---|
|  |  |  | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return listView; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | moralMap.MoralMarker = function (option) { | 
|---|
|  |  |  | var _option = option; | 
|---|
|  |  |  | var _pointObj = new BMap.Point(_option['longitude'], _option['latitude']); | 
|---|
|  |  |  | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | //状态发生变化的时候设置图标风向 | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var moralMask = new moralMap.Equipment(obj); | 
|---|
|  |  |  | var moralDeviceWind = new moralMap.Device(obj); | 
|---|
|  |  |  | moralMap.addOverlay(moralMask); | 
|---|
|  |  |  | if (obj['hasWindInfo']) { | 
|---|
|  |  |  | var moralDeviceWind = new moralMap.Device(obj); | 
|---|
|  |  |  | moralMap.addOverlay(moralDeviceWind); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function addOverMpoints(data) { | 
|---|
|  |  |  | if (moralMap.layer() == "monitorpoints") { | 
|---|