| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.util.*;
|
| | |
|
| | | import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS;
|
| | |
|
| | | /**
|
| | |
| | | ICameraSdkService cameraSdkService;
|
| | | @Resource
|
| | | IGlobalAlarmService globalAlarmService;
|
| | |
|
| | | /**
|
| | | * @描述 定时推送所有报警的点位数量
|
| | | * @参数 []
|
| | |
| | | */
|
| | | public void ptzPush() {
|
| | | try {
|
| | | List<Map<String, Object>> list = new ArrayList<>();
|
| | | List<Object> Objects = redisCache.getListKey(CacheConstants.CAMERA_LIST_KEY);
|
| | | if (Objects.size() > 0) {
|
| | | for (Object obj : Objects) {
|
| | | ArdCameras camera = (ArdCameras) obj;
|
| | | if (!GlobalVariable.loginMap.containsKey(camera.getId()))//只推送首次登录成功的相机
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if(!"1".equals(camera.getGdtype()))
|
| | | {
|
| | | continue;
|
| | | }
|
| | | CameraCmd cmd = new CameraCmd();
|
| | | cmd.setCameraId(camera.getId());
|
| | | cmd.setChanNo(1);
|
| | | cmd.setOperator(camera.getOperatorId());
|
| | | //推送在线的相机
|
| | | boolean onLine = cameraSdkService.isOnLine(cmd);
|
| | | if(!onLine)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | AjaxResult ajaxResult = cameraSdkService.getGisInfo(cmd);
|
| | | Map<String, Object> ptz = (Map<String, Object>)ajaxResult.get("data");
|
| | | if (StringUtils.isNull(ptz)) {
|
| | | continue;
|
| | | }
|
| | | SysUser sysUser = redisCache.getCacheObject(CacheConstants.USER_LIST_KEY + camera.getOperatorId());
|
| | | if (StringUtils.isNotNull(sysUser)) {
|
| | | cmd.setOperatorZh(sysUser.getNickName());
|
| | | } else {
|
| | | cmd.setOperatorZh(cmd.getOperator());
|
| | | }
|
| | | if (ONLINE_USER_SESSIONS.size() > 0) {
|
| | | List<Map<String, Object>> list = new ArrayList<>();
|
| | | List<Object> Objects = redisCache.getListKey(CacheConstants.CAMERA_LIST_KEY);
|
| | | if (Objects.size() > 0) {
|
| | | for (Object obj : Objects) {
|
| | | ArdCameras camera = (ArdCameras) obj;
|
| | | if (!GlobalVariable.loginMap.containsKey(camera.getId()))//只推送首次登录成功的相机
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (!"1".equals(camera.getGdtype())) {
|
| | | continue;
|
| | | }
|
| | | CameraCmd cmd = new CameraCmd();
|
| | | cmd.setCameraId(camera.getId());
|
| | | cmd.setChanNo(1);
|
| | | cmd.setOperator(camera.getOperatorId());
|
| | | //推送在线的相机
|
| | | boolean onLine = cameraSdkService.isOnLine(cmd);
|
| | | if (!onLine) {
|
| | | continue;
|
| | | }
|
| | | AjaxResult ajaxResult = cameraSdkService.getGisInfo(cmd);
|
| | | Map<String, Object> ptz = (Map<String, Object>) ajaxResult.get("data");
|
| | | if (StringUtils.isNull(ptz)) {
|
| | | continue;
|
| | | }
|
| | | SysUser sysUser = redisCache.getCacheObject(CacheConstants.USER_LIST_KEY + camera.getOperatorId());
|
| | | if (StringUtils.isNotNull(sysUser)) {
|
| | | cmd.setOperatorZh(sysUser.getNickName());
|
| | | } else {
|
| | | cmd.setOperatorZh(cmd.getOperator());
|
| | | }
|
| | |
|
| | | //获取时间差
|
| | | long secDatePoor = 0;
|
| | | if (StringUtils.isNotNull(camera.getOperatorExpired())) {
|
| | | secDatePoor = DateUtils.getSecDatePoor(camera.getOperatorExpired(), new Date());
|
| | | if (secDatePoor < 0) {
|
| | | secDatePoor = 0;
|
| | | //获取时间差
|
| | | long secDatePoor = 0;
|
| | | if (StringUtils.isNotNull(camera.getOperatorExpired())) {
|
| | | secDatePoor = DateUtils.getSecDatePoor(camera.getOperatorExpired(), new Date());
|
| | | if (secDatePoor < 0) {
|
| | | secDatePoor = 0;
|
| | | }
|
| | | }
|
| | |
|
| | | if (ptz.size() > 0) {
|
| | | ptz.put("cameraId", cmd.getCameraId());
|
| | | ptz.put("usernameZh", cmd.getOperatorZh());
|
| | | ptz.put("operatorId", cmd.getOperator());//上锁用户id
|
| | | ptz.put("expirationRemainingSecond", secDatePoor);
|
| | | ptz.put("longitude", camera.getLongitude());
|
| | | ptz.put("latitude", camera.getLatitude());
|
| | | ptz.put("altitude", camera.getAltitude());
|
| | | list.add(ptz);
|
| | | }
|
| | | }
|
| | |
|
| | | if (ptz.size() > 0) {
|
| | | ptz.put("cameraId", cmd.getCameraId());
|
| | | ptz.put("usernameZh", cmd.getOperatorZh());
|
| | | ptz.put("operatorId", cmd.getOperator());//上锁用户id
|
| | | ptz.put("expirationRemainingSecond", secDatePoor);
|
| | | ptz.put("longitude",camera.getLongitude());
|
| | | ptz.put("latitude",camera.getLatitude());
|
| | | ptz.put("altitude",camera.getAltitude());
|
| | | list.add(ptz);
|
| | | }
|
| | | }
|
| | | if (ONLINE_USER_SESSIONS.size() > 0) {
|
| | | Map<String, Object> sendMap = new HashMap<>();
|
| | | sendMap.put("10000", list);
|
| | | WebSocketUtils.sendMessageAll(sendMap);
|
| | |
| | | log.error("推送ptz异常:" + ex.getMessage());
|
| | | }
|
| | | }
|
| | | }
|
| | | } |