| | |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | |
| | | InformationService informationService ; |
| | | @Override |
| | | public void onMessage(String message) { |
| | | //System.out.println("recv msg: "+message); |
| | | System.out.println("recv msg: "+message); |
| | | sendAllMessage(message); |
| | | } |
| | | |
| | |
| | | */ |
| | | |
| | | public void sendAllMessage(String message) { |
| | | //System.out.println("【websocket消息】广播消息:"+message); |
| | | System.out.println("【websocket消息】广播消息:"+message); |
| | | |
| | | JSONObject jsonObject = JSONObject.parseObject(message); |
| | | String personNo = jsonObject.getString("personNo"); |
| | | |
| | | SysUser sysUser = infoSynchService.selectUserInfoById(personNo) ; |
| | | //System.out.println("【user]:"+JSONObject.toJSONString(sysUser)); |
| | | System.out.println("【user]:"+JSONObject.toJSONString(sysUser)); |
| | | List<RetInfo> list = new ArrayList<>(); |
| | | //查询用户所处围栏 |
| | | List<FencePosition> fencePositionList = null ; |
| | | try{ |
| | | fencePositionList = (List<FencePosition>)this.detectService.checkInFence(jsonObject.get("w84lat").toString(),jsonObject.get("w84lon").toString()); |
| | | }catch (Exception e){ |
| | | System.out.println(e.getMessage()); |
| | | } |
| | | //System.out.println("【FencePosition]:"+JSONObject.toJSONString(fencePositionList)); |
| | | List<FencePosition> fencePositionList = (List<FencePosition>)this.detectService.checkInFence(jsonObject.get("w84lat").toString(),jsonObject.get("w84lon").toString()); |
| | | System.out.println("【FencePosition]:"+JSONObject.toJSONString(fencePositionList)); |
| | | RetInfo alertinfo = new RetInfo(); |
| | | initAlertInfos(jsonObject, personNo, sysUser, alertinfo); |
| | | if( fencePositionList != null && fencePositionList.size() > 0){ |
| | |
| | | Fence_User fence_user = detectService.checkInAlert(f.getWorkId(),sysUser.getId()); |
| | | alertinfo.setFence_name(f.getFname()); |
| | | alertinfo.setWtId(f.getWorkId()); |
| | | if( fence_user == null && checkHight(alertinfo.getBaseFloor(),f.getStartaltitude())){ |
| | | if( fence_user == null && checkHight(alertinfo.getBaseFloor(),f)){ |
| | | alertinfo.setStatus("alert"); |
| | | |
| | | }else{ |
| | |
| | | list.add(alertinfo) ; |
| | | } |
| | | insertInformation(list); |
| | | // System.out.println( "list:"+jsonObject.toJSONString(list)); |
| | | System.out.println( "list:"+jsonObject.toJSONString(list)); |
| | | // if( list != null && list.size() > 0) |
| | | // System.out.println( "websocket status ..["+webSocketController.sendAllMessage(JSONObject.toJSONString(list))+"["+JSONObject.toJSONString(list)+"]" ); |
| | | } |
| | |
| | | alertinfo.setMobile(sysUser.getMobile()); |
| | | |
| | | alertinfo.setBaseFloor(jsonObject.get("baseFloor").toString()); |
| | | String time = Long.toString(new Date().getTime()); |
| | | |
| | | alertinfo.setStartTime(time.substring(0,time.length()-3)); |
| | | alertinfo.setHb(jsonObject.getIntValue("hb")); |
| | | alertinfo.setStartTime(jsonObject.get("timestamp").toString()); |
| | | alertinfo.setHb(jsonObject.getInteger("hb").intValue()); |
| | | } |
| | | |
| | | private boolean checkHight(String basefloor,double start){ |
| | | return (Integer.parseInt(basefloor)-2)*6.3 >=start ; |
| | | private boolean checkHight(String basefloor,FencePosition f){ |
| | | int fl = (int)(f.getEndaltitude()/7)+1 ; |
| | | System.out.println("接收:"+basefloor+" 围栏楼层:"+f.getFname()+":"+fl); |
| | | return (Integer.parseInt(basefloor)-1) ==fl ; |
| | | } |
| | | |
| | | |
| | |
| | | Information information = new Information(); |
| | | information.setFence_type(r.getType()); |
| | | information.setName(r.getFence_name()); |
| | | information.setStartTime(r.getStartTime()); |
| | | //information.setStartTime(r.getStartTime()); |
| | | //避免时间同步问题 |
| | | information.setStartTime((new Date()).getTime()/1000+""); |
| | | information.setStatus(r.getStatus()); |
| | | information.setUserId(r.getUserId()); |
| | | information.setWtId(r.getWtId()); |