|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
|
+import com.ozs.common.core.domain.entity.SysUser;
|
|
|
import com.ozs.common.core.redis.RedisCache;
|
|
|
import com.ozs.common.exception.base.BaseException;
|
|
|
import com.ozs.common.utils.ApiTokenUtils;
|
|
@@ -34,6 +35,7 @@ import com.ozs.entity.vo.CameraPlayVo;
|
|
|
import com.ozs.entity.vo.CameraVo;
|
|
|
import com.ozs.entity.vo.Files;
|
|
|
import com.ozs.entity.vo.HeartbeatVo;
|
|
|
+import com.ozs.entity.vo.MsgAlarmResp;
|
|
|
import com.ozs.entity.vo.ParameterVo;
|
|
|
import com.ozs.entity.vo.QueryAlarmVo;
|
|
|
import com.ozs.entity.vo.ReleaseAlarmVo;
|
|
@@ -57,6 +59,10 @@ import com.ozs.service.MsgAlarmService;
|
|
|
import com.ozs.service.SvcAddressService;
|
|
|
import com.ozs.service.TerminalIgnoreAlarmService;
|
|
|
import com.ozs.service.VehiclePositionService;
|
|
|
+import com.ozs.system.domain.SysUserOnline;
|
|
|
+import com.ozs.system.mapper.SysUserMapper;
|
|
|
+import com.ozs.web.controller.monitor.SysUserOnlineController;
|
|
|
+import com.ozs.web.controller.websocket.WebSocketServer;
|
|
|
import com.ozs.web.core.util.CameraUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -79,6 +85,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 1. 获取身份认证控制层
|
|
@@ -92,8 +99,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
public static final String PATTERNS = "^[0-9]*$";
|
|
|
@Resource
|
|
|
private ApiTokenUtils apiTokenUtils;
|
|
|
- @Resource
|
|
|
- BaseDeviceDynamicManagementService baseDeviceDynamicManagementService;
|
|
|
+ @Autowired
|
|
|
+ WebSocketServer webSocketServer;
|
|
|
@Autowired
|
|
|
MsgAlarmService msgAlarmService;
|
|
|
@Autowired
|
|
@@ -102,6 +109,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
SvcAddressService svcAddressService;
|
|
|
@Autowired
|
|
|
BaseCameraManagementService baseCameraManagementService;
|
|
|
+ @Autowired
|
|
|
+ SysUserOnlineController sysUserOnlineController;
|
|
|
// @Value("${sdk.publish}")
|
|
|
// private String sdkUrl;
|
|
|
@Autowired
|
|
@@ -126,6 +135,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
private ServerConfig serverConfig;
|
|
|
@Autowired
|
|
|
private BaseVehicleTerminalService baseVehicleTerminalService;
|
|
|
+ @Resource
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
|
|
|
/**
|
|
|
* 获取web访问令牌
|
|
@@ -571,6 +582,28 @@ public class GeoHazardMonitorTokenController {
|
|
|
LambdaQueryWrapper<BaseVehicleTerminal> terminal = new LambdaQueryWrapper<>();
|
|
|
terminal.eq(BaseVehicleTerminal::getTerminalCode, vehiclePosition.getTerminalCode());
|
|
|
boolean update = baseVehicleTerminalService.update(baseVehicleTerminal, terminal);
|
|
|
+ //*******获取终端经度纬度,将车载终端code改为机车的code,便是机车的位置
|
|
|
+ HeartbeatVo heartbeatVoCH = new HeartbeatVo();
|
|
|
+ BeanUtils.copyProperties(heartbeatVo, heartbeatVoCH);
|
|
|
+ //*******将终端关联的机车编码赋值给推送信息对象
|
|
|
+ heartbeatVoCH.setVehicleCode(baseTerminal.getVehicleCode());
|
|
|
+ String content = objStr(heartbeatVoCH);
|
|
|
+ //获取在线用户
|
|
|
+ List<SysUserOnline> rows = (List<SysUserOnline>) sysUserOnlineController.list(null, null).getRows();
|
|
|
+ if (!ObjectUtils.isEmpty(rows)) {
|
|
|
+ //拿到用户userNameList
|
|
|
+ List<String> userNameList = rows.stream().map(SysUserOnline::getUserName).collect(Collectors.toList());
|
|
|
+ LambdaQueryWrapper<SysUser> userWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userWrapper.in(SysUser::getUserName, userNameList);
|
|
|
+ List<SysUser> sysUsers = sysUserMapper.selectList(userWrapper);
|
|
|
+ //拿到用户userIdList
|
|
|
+ List<Long> userIdList = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
|
|
|
+ for (Long userid : userIdList) {
|
|
|
+ //推送给在线用户
|
|
|
+ webSocketServer.sendOneMessage(String.valueOf(userid), content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//目视距离和里程位置
|
|
|
if (save && update) {
|
|
|
LambdaQueryWrapper<MsgAlarm> queryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -912,7 +945,7 @@ public class GeoHazardMonitorTokenController {
|
|
|
jsonObject.put("data", "没有该相机编码的相机");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
|
|
|
}
|
|
|
- String flv = CameraUtil.getPlayFlvRtsp(one.getCameraCode(), one.getChannel(),false);
|
|
|
+ String flv = CameraUtil.getPlayFlvRtsp(one.getCameraCode(), one.getChannel(), false);
|
|
|
map.put("url", flv);
|
|
|
jsonObject.put("resultCode", 1);
|
|
|
jsonObject.put("message", "ok");
|
|
@@ -1091,6 +1124,15 @@ public class GeoHazardMonitorTokenController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private String objStr(HeartbeatVo heartbeatVoCH) {
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ //data
|
|
|
+ obj.put("data", heartbeatVoCH);
|
|
|
+ //code
|
|
|
+ obj.put("code", 151);
|
|
|
+ log.info("【websocket消息】 机车地址信息:" + obj.toJSONString());
|
|
|
+ return obj.toJSONString();
|
|
|
+ }
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
JSONObject res = new JSONObject();
|