添加火点时,加入了websocket功能模块
This commit is contained in:
parent
31394ee9a2
commit
084bb672da
@ -76,7 +76,6 @@ public class TokenAuthenticationService {
|
||||
LocalDateTime overTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
||||
// 计算距离结束时间的天数作为token
|
||||
Duration duration = Duration.between(LocalDateTime.now(), overTime);
|
||||
System.out.println("-------"+duration.toDays());
|
||||
/**
|
||||
* 动态设置过期时间
|
||||
*/
|
||||
@ -95,7 +94,6 @@ public class TokenAuthenticationService {
|
||||
.signWith(key)
|
||||
.compact();
|
||||
map.put("token",jwt);
|
||||
map.put("role",authsList);
|
||||
map.put("user",sysUserEntity);
|
||||
}else {
|
||||
/**
|
||||
@ -116,7 +114,6 @@ public class TokenAuthenticationService {
|
||||
.signWith(key)
|
||||
.compact();
|
||||
map.put("token",jwt);
|
||||
map.put("role",authsList);
|
||||
map.put("user",sysUserEntity);
|
||||
}
|
||||
// 将 JWT 写入 body
|
||||
|
@ -47,6 +47,8 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers(HttpMethod.GET,"/selectAppTask").permitAll()
|
||||
.antMatchers(HttpMethod.GET,"/selectFirePointBetweenSeven").permitAll()
|
||||
.antMatchers(HttpMethod.GET,"/selectFirePointNum").permitAll()
|
||||
.antMatchers(HttpMethod.GET,"/api/user/booleanUserName").permitAll()
|
||||
.antMatchers(HttpMethod.GET,"/websocketTest").permitAll()
|
||||
// 所有其它请求需要身份认证
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
|
@ -8,6 +8,7 @@ import com.xkrs.model.entity.SysUserEntity;
|
||||
import com.xkrs.model.qo.FirePointQo;
|
||||
import com.xkrs.model.vo.AppTaskBodyVo;
|
||||
import com.xkrs.service.FirePointService;
|
||||
import com.xkrs.websocket.service.WebSocketServer;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.xkrs.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.common.tool.TokenUtil;
|
||||
import com.xkrs.dao.*;
|
||||
@ -9,6 +10,7 @@ import com.xkrs.model.vo.AppPhotoVo;
|
||||
import com.xkrs.model.vo.AppTaskBodyVo;
|
||||
import com.xkrs.service.FirePointService;
|
||||
import com.xkrs.utils.*;
|
||||
import com.xkrs.websocket.service.WebSocketServer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cglib.beans.BeanCopier;
|
||||
@ -81,6 +83,22 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now()));
|
||||
firePointEntity.setFireType("0");
|
||||
log.info("-------发现新火点");
|
||||
log.info("---------------开始进行实时通讯,将检测到的火点传给前端");
|
||||
Map map = new HashMap(3);
|
||||
map.put("countyCode",firePointQo.getCountyCode());
|
||||
map.put("countyName",firePointQo.getCountyName());
|
||||
map.put("fireCode",firePointQo.getFireCode());
|
||||
map.put("latitude",firePointQo.getLatitude());
|
||||
map.put("longitude",firePointQo.getLongitude());
|
||||
map.put("satelliteTime",DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
|
||||
map.put("satelliteType",firePointQo.getSatelliteType());
|
||||
map.put("addTime",DateTimeUtil.dateTimeToString(LocalDateTime.now()));
|
||||
map.put("detailedAddress",AddressUtils.getLatAndLng(firePointQo.getLatitude().toString(),firePointQo.getLongitude().toString()));
|
||||
Map map1 = new HashMap(3);
|
||||
map1.put("fire",map);
|
||||
String websocket = JSON.toJSONString(map1);
|
||||
// 将监测到的火点信息返给前端
|
||||
WebSocketServer.broadInfo(websocket);
|
||||
return firePointDao.save(firePointEntity);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user