| | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.common.websocket.util.WebSocketUtils; |
| | | import com.ruoyi.utils.websocket.util.WebSocketUtils; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.service.IArdCamerasService; |
| | | import com.ruoyi.device.hiksdk.common.GlobalVariable; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | import static com.ruoyi.common.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; |
| | | import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; |
| | | |
| | | /** |
| | | * @Description: |
| | |
| | | public void ptzPush() { |
| | | try { |
| | | RedisCache redisCache = SpringUtils.getBean(RedisCache.class); |
| | | ISysUserService sysUserService = SpringUtils.getBean(ISysUserService.class); |
| | | IHikClientService hikClientService = SpringUtils.getBean(IHikClientService.class); |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | ArdCameras ardCameras = new ArdCameras(); |
| | | ardCameras.setGdtype("1"); |
| | | List<Object> Objects = redisCache.getListKey(getCacheKey()); |
| | | List<Object> Objects = redisCache.getListKey(CacheConstants.CAMERA_LIST_KEY); |
| | | if (Objects.size() > 0) { |
| | | for (Object obj : Objects) { |
| | | ArdCameras camera = (ArdCameras) obj; |
| | | if(!"1".equals(camera.getGdtype())) |
| | | { |
| | | continue; |
| | | } |
| | | CameraCmd cmd = new CameraCmd(); |
| | | cmd.setCameraId(camera.getId()); |
| | | cmd.setChannelNum(1); |
| | | cmd.setChanNo(1); |
| | | cmd.setOperator(camera.getOperatorId()); |
| | | if (!GlobalVariable.loginMap.containsKey(camera.getId()))//只推送登录成功的相机 |
| | | { |
| | | continue; |
| | | } |
| | | Map<String, Object> ptz = hikClientService.getPtz(cmd); |
| | | Map<String, Object> ptz = hikClientService.getGisInfo(cmd); |
| | | if (StringUtils.isNull(ptz)) { |
| | | continue; |
| | | } |
| | | SysUser sysUser = sysUserService.selectUserById(camera.getOperatorId()); |
| | | SysUser sysUser = redisCache.getCacheObject(CacheConstants.USER_LIST_KEY + camera.getOperatorId()); |
| | | if (StringUtils.isNotNull(sysUser)) { |
| | | cmd.setOperatorZh(sysUser.getNickName()); |
| | | } else { |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | log.error("推送ptz异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | /** |
| | | * 获取cache key |
| | | * |
| | | * @return 缓存键key |
| | | */ |
| | | private String getCacheKey() { |
| | | return CacheConstants.CAMERA_LIST_KEY; |
| | | } |
| | | |
| | | } |