diff --git a/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java index 3bc2aab..777adb2 100644 --- a/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java +++ b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java @@ -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 diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index ef01d27..57f535b 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -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() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index be79bc3..0890889 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -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.*; diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index f3bd168..892c35c 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -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); }