已添加1个文件
已重命名1个文件
已修改34个文件
| | |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.net.UnknownHostException; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * appä½ç½®Controller |
| | | * |
| | | * |
| | | * @author ard |
| | | * @date 2023-07-18 |
| | | */ |
| | | @Api(tags = "appä½ç½®") |
| | | @RestController |
| | | @RequestMapping("/app/position") |
| | | public class ArdAppPositionController extends BaseController |
| | | { |
| | | public class ArdAppPositionController extends BaseController { |
| | | @Autowired |
| | | private IArdAppPositionService ardAppPositionService; |
| | | @Autowired |
| | |
| | | @ApiOperation("æ¥è¯¢appä½ç½®å表") |
| | | // @PreAuthorize("@ss.hasPermi('app:position:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(ArdAppPosition ardAppPosition) |
| | | { |
| | | public TableDataInfo list(ArdAppPosition ardAppPosition) { |
| | | startPage(); |
| | | List<ArdAppPosition> list = ardAppPositionService.selectArdAppPositionList(ardAppPosition); |
| | | return getDataTable(list); |
| | |
| | | @PreAuthorize("@ss.hasPermi('app:position:export')") |
| | | @Log(title = "appä½ç½®", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ArdAppPosition ardAppPosition) |
| | | { |
| | | public void export(HttpServletResponse response, ArdAppPosition ardAppPosition) { |
| | | List<ArdAppPosition> list = ardAppPositionService.selectArdAppPositionList(ardAppPosition); |
| | | ExcelUtil<ArdAppPosition> util = new ExcelUtil<ArdAppPosition>(ArdAppPosition.class); |
| | | util.exportExcel(response, list, "appä½ç½®æ°æ®"); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('app:position:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") String id) |
| | | { |
| | | public AjaxResult getInfo(@PathVariable("id") String id) { |
| | | return success(ardAppPositionService.selectArdAppPositionById(id)); |
| | | } |
| | | |
| | |
| | | // @PreAuthorize("@ss.hasPermi('app:position:add')") |
| | | @Log(title = "appä½ç½®", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ArdAppPosition ardAppPosition) |
| | | { |
| | | public AjaxResult add(@RequestBody ArdAppPosition ardAppPosition) { |
| | | return AjaxResult.success(ardAppPositionService.insertArdAppPosition(ardAppPosition)); |
| | | } |
| | | |
| | |
| | | @PreAuthorize("@ss.hasPermi('app:position:edit')") |
| | | @Log(title = "appä½ç½®", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ArdAppPosition ardAppPosition) |
| | | { |
| | | public AjaxResult edit(@RequestBody ArdAppPosition ardAppPosition) { |
| | | return toAjax(ardAppPositionService.updateArdAppPosition(ardAppPosition)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('app:position:remove')") |
| | | @Log(title = "appä½ç½®", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) |
| | | { |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) { |
| | | return toAjax(ardAppPositionService.deleteArdAppPositionByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * è·åææç¨æ· |
| | | */ |
| | | @ApiOperation("è·åææç¨æ·") |
| | | @GetMapping("/getUserlist") |
| | | public AjaxResult getUserlist(Long deptId) |
| | | { |
| | | SysUser user=new SysUser(); |
| | | public AjaxResult getUserlist(Long deptId) { |
| | | SysUser user = new SysUser(); |
| | | user.setDeptId(deptId); |
| | | List<SysUser> list = sysUserService.selectUserList(user); |
| | | return AjaxResult.success(list); |
| | |
| | | List<SysUser> list = sysUserService.selectAllAppUserList(user); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * è·åææappç¨æ· |
| | | */ |
| | | @ApiOperation("è·åææappç¨æ·pc") |
| | | @GetMapping("/getAppUserForPclist") |
| | | public AjaxResult getAppUserForPclist(Long deptId) |
| | | { |
| | | SysUser user=new SysUser(); |
| | | public AjaxResult getAppUserForPclist(Long deptId) { |
| | | SysUser user = new SysUser(); |
| | | user.setDeptId(deptId); |
| | | List<SysUser> list = sysUserService.selectAllAppUserList(user); |
| | | List<SysUser> onLineList=new ArrayList<>(); |
| | | List<SysUser> offLineList=new ArrayList<>(); |
| | | for(SysUser sysUser:list) |
| | | { |
| | | List<SysUser> onLineList = new ArrayList<>(); |
| | | List<SysUser> offLineList = new ArrayList<>(); |
| | | for (SysUser sysUser : list) { |
| | | ArdAppPosition ardAppPosition = ardAppPositionService.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | if(ardAppPosition!=null) { |
| | | Map<String, Object> params =new HashMap<>(); |
| | | if (ardAppPosition != null) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("longitude", ardAppPosition.getLongitude()); |
| | | params.put("latitude", ardAppPosition.getLatitude()); |
| | | params.put("altitude", ardAppPosition.getAltitude()); |
| | | params.put("bearing", ardAppPosition.getBearing()); |
| | | sysUser.setParams(params); |
| | | } |
| | | if(StringUtils.isNotNull(sysUser.getAppOnlineState())) |
| | | { |
| | | if(sysUser.getAppOnlineState().equals("1")) |
| | | { |
| | | if (StringUtils.isNotNull(sysUser.getAppOnlineState())) { |
| | | if (sysUser.getAppOnlineState().equals("1")) { |
| | | onLineList.add(sysUser); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | offLineList.add(sysUser); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | offLineList.add(sysUser); |
| | | } |
| | | |
| | | } |
| | | Map<String,Object> onlineMap=new HashMap<>(); |
| | | onlineMap.put("children",onLineList); |
| | | onlineMap.put("name","å¨çº¿ç¨æ·("+onLineList.size()+")"); |
| | | onlineMap.put("disabled",true); |
| | | onlineMap.put("id","onLine"); |
| | | Map<String,Object> offlineMap=new HashMap<>(); |
| | | offlineMap.put("children",offLineList); |
| | | offlineMap.put("name","ç¦»çº¿ç¨æ·("+offLineList.size()+")"); |
| | | offlineMap.put("disabled",true); |
| | | offlineMap.put("id","offLine"); |
| | | List< Map<String,Object> > lists = new ArrayList<>(); |
| | | Map<String, Object> onlineMap = new HashMap<>(); |
| | | onlineMap.put("children", onLineList); |
| | | onlineMap.put("name", "å¨çº¿ç¨æ·(" + onLineList.size() + ")"); |
| | | onlineMap.put("disabled", true); |
| | | onlineMap.put("id", "onLine"); |
| | | Map<String, Object> offlineMap = new HashMap<>(); |
| | | offlineMap.put("children", offLineList); |
| | | offlineMap.put("name", "ç¦»çº¿ç¨æ·(" + offLineList.size() + ")"); |
| | | offlineMap.put("disabled", true); |
| | | offlineMap.put("id", "offLine"); |
| | | List<Map<String, Object>> lists = new ArrayList<>(); |
| | | lists.add(onlineMap); |
| | | lists.add(offlineMap); |
| | | return AjaxResult.success(lists); |
| | |
| | | */ |
| | | @ApiOperation("è·åç¨æ·è¯¦æ
") |
| | | @GetMapping("/getUserInfo") |
| | | public AjaxResult getUserInfo(String userId) |
| | | { |
| | | public AjaxResult getUserInfo(String userId) { |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | return AjaxResult.success(sysUser); |
| | | } |
| | | |
| | | @PostMapping("/uploadFile") |
| | | @ApiOperation("ä¸ä¼ æä»¶") |
| | | public AjaxResult uploadFile(MultipartFile file,String type) |
| | | { |
| | | String url = MinioUtil.putObjectAndGetUrl("app",type, file); |
| | | return AjaxResult.success(url); |
| | | public AjaxResult uploadFile(MultipartFile file, String type) throws MalformedURLException, UnknownHostException { |
| | | String urlStr = MinioUtil.putObjectAndGetUrl("app", type, file); |
| | | URL url = new URL(urlStr); |
| | | // æ¿æ¢ https 为 httpï¼å¹¶å°ä¸»æºåå端å£å·æ¿æ¢ä¸ºæ¬å°å°å |
| | | String serverIpAddress = InetAddress.getLocalHost().getHostAddress(); |
| | | // æå»ºæ°ç URL 对象ï¼ä½¿ç¨ HTTPS åè®® |
| | | URL httpsUrl = new URL("https", serverIpAddress, url.getPort(), url.getFile()); |
| | | return AjaxResult.success(httpsUrl); |
| | | } |
| | | |
| | | @GetMapping("/getOnlinePCOrCommander") |
| | | @ApiOperation("æ¥è¯¢æ¬é¨é¨å¨çº¿PCç«¯åææ¥ç«¯") |
| | | public AjaxResult getOnlinePCOrCommander() { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | Map<String,List<SysUser>> result = ardAppPositionService.getOnlinePCOrCommander(usersId); |
| | | Map<String, List<SysUser>> result = ardAppPositionService.getOnlinePCOrCommander(usersId); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | |
| | | @ApiOperation("åå
µç«¯æ¥çå·²éè¿å®¡æ¹çå¨çº¿ææ¥ç«¯ä½ç½®") |
| | | public AjaxResult getOnlineCommanderPosition() { |
| | | String soilderId = SecurityUtils.getUserId(); |
| | | try{ |
| | | List<Map<String,Object>> result = ardAppPositionService.getOnlineCommanderPosition(soilderId); |
| | | try { |
| | | List<Map<String, Object>> result = ardAppPositionService.getOnlineCommanderPosition(soilderId); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | |
| | | |
| | | @PostMapping("/getAPPPositionByUserIdAndTime") |
| | | @ApiOperation("æ¥çAPPåå²ä½ç½®") |
| | | public AjaxResult getAPPPositionByUserIdAndTime(@RequestBody Map<String,String> para) { |
| | | try{ |
| | | public AjaxResult getAPPPositionByUserIdAndTime(@RequestBody Map<String, String> para) { |
| | | try { |
| | | List<ArdAppPosition> result = ardAppPositionService.getAPPPositionByUserIdAndTime(para); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | |
| | | Map<String, Object> map = JSONObject.parseObject(message, Map.class); |
| | | if (map.size() > 0) { |
| | | Boolean enabled = (Boolean) map.get("enabled"); |
| | | if(enabled==null) |
| | | { |
| | | return; |
| | | } |
| | | if (enabled) { |
| | | //å¯å¨å
¨å±æ¨é |
| | | List<ArdAppPosition> newList = new ArrayList<>(AppPositionPushService.getAppPositionList()); |
| | |
| | | AppPositionPushService.tempUserTimerMap.remove(userId); |
| | | AppPositionPushService.tempDataMap.remove(userId); |
| | | } |
| | | //region æ§æ¹æ³ |
| | | // Map<String, List<ArdAppPosition>> dataMap = new HashMap<>(); |
| | | // List<ArdAppPosition> positionList = AppPositionPush.initDataMap.get(userId);//è·åå½åç¨æ·çé»è®¤åéçæ°æ®map |
| | | // if(frequency>0) |
| | | // { |
| | | // //æ¥æ¶å°é¢ç大äº0ï¼å±äºç³è¯·å¼å¯¼ï¼è·åé¤å¼å¯¼å¤çå
¶ä»appç¨æ·çä½ç½®List |
| | | // List<ArdAppPosition> appPositionList = positionList.stream() |
| | | // .filter(obj -> !obj.getUserId().equals(uId)) |
| | | // .collect(Collectors.toList()); |
| | | // dataMap.put(userId,appPositionList); |
| | | // } |
| | | // else { |
| | | // //æ¥æ¶å°é¢ççäº0ï¼å±äºéæ¾å¼å¯¼ï¼è·åå°å
¨é¨appç¨æ·çä½ç½®List |
| | | // dataMap.put(userId,AppPositionPush.getAppPositionList()); |
| | | // } |
| | | // AppPositionPush.initDataMap.putAll(dataMap);//æ´æ°åå§ä¼è¯é»è®¤æ°æ®map |
| | | // AppPositionPush.startLocationPushTask(userId,session,uId, frequency);//å¼å¯æ°ä»»å¡ |
| | | //endregion |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åä¼è¯ç¨æ·ä¸é´è¡¨è¯¦ç»ä¿¡æ¯ |
| | | * è·åä¼è¯è¯¦æ
|
| | | */ |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") String id) { |
| | | return success(ardCallSessionUserService.selectArdCallSessionUserById(id)); |
| | | @ApiOperation("è·åä¼è¯è¯¦æ
") |
| | | @GetMapping(value = "/{userId}/{sessionId}") |
| | | public AjaxResult getInfo(@PathVariable("userId") String userId,@PathVariable("sessionId") String sessionId) { |
| | | return success(ardCallSessionUserService.selectArdCallSessionUserBySesionId(userId,sessionId)); |
| | | } |
| | | |
| | | /** |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.call.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @ClassName:CallMessage |
| | | * @Description: |
| | | * @Author:ard |
| | | * @Date:2024å¹´07æ08æ¥13:48 |
| | | * @Version:1.0 |
| | | **/ |
| | | @Data |
| | | public class CallMessage { |
| | | String step; |
| | | String roomId; |
| | | String userId; |
| | | String targetId; |
| | | Integer mediaType; |
| | | Integer type; |
| | | } |
| | |
| | | * @return ä¼è¯ç¨æ·ä¸é´è¡¨ |
| | | */ |
| | | public ArdCallSessionUser selectArdCallSessionUserById(String id); |
| | | |
| | | public ArdCallSessionUser selectArdCallSessionUserBySesionId(@Param("userId") String userId,@Param("sessionId") String sessionId); |
| | | /** |
| | | * æ¥è¯¢ä¼è¯ç¨æ·ä¸é´è¡¨å表 |
| | | * |
| | |
| | | * @return ä¼è¯ç¨æ·ä¸é´è¡¨ |
| | | */ |
| | | public ArdCallSessionUser selectArdCallSessionUserById(String id); |
| | | |
| | | public ArdCallSessionUser selectArdCallSessionUserBySesionId(String userId,String sessionId); |
| | | /** |
| | | * æ¥è¯¢ä¼è¯ç¨æ·ä¸é´è¡¨å表 |
| | | * |
| | |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.call.domain.ArdCallGroup; |
| | | import com.ruoyi.call.domain.ArdCallSessionUser; |
| | | import com.ruoyi.call.mapper.ArdCallSessionUserMapper; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | |
| | |
| | | private ArdCallGroupUserMapper ardCallGroupUserMapper; |
| | | @Resource |
| | | private SysUserMapper sysUserMapper; |
| | | @Resource |
| | | private ArdCallSessionUserMapper ardCallSessionUserMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¾¤ç»ç¨æ·ä¸é´ |
| | |
| | | ardCallGroupUser.setCreateTime(DateUtils.getNowDate()); |
| | | ardCallGroupUser.setUserId(userId); |
| | | ardCallGroupUserMapper.insertArdCallGroupUser(ardCallGroupUser); |
| | | //é请æåæååå建session |
| | | //éè¿ç¾¤idè·å群session |
| | | String sessionId = ardCallSessionUserMapper.getGroupSessionId("1", id); |
| | | if (StringUtils.isNotEmpty(sessionId)) { |
| | | ArdCallSessionUser ardCallSessionUser = new ArdCallSessionUser(); |
| | | ardCallSessionUser.setId(IdUtils.simpleUUID()); |
| | | ardCallSessionUser.setType("1"); |
| | | ardCallSessionUser.setSessionId(sessionId); |
| | | ardCallSessionUser.setUserId(userId); |
| | | ardCallSessionUser.setTargetId(id); |
| | | ardCallSessionUser.setCreateTime(DateUtils.getNowDate()); |
| | | ardCallSessionUserMapper.insertArdCallSessionUser(ardCallSessionUser); |
| | | } |
| | | }); |
| | | return userIds.length; |
| | | } |
| | |
| | | //è·å平尿æç¨æ· |
| | | List<SysUser> userList = sysUserMapper.selectUserList(new SysUser()); |
| | | //è·å群ç»å
ç¨æ· |
| | | ArdCallGroupUser ardCallGroupUser=new ArdCallGroupUser(); |
| | | ArdCallGroupUser ardCallGroupUser = new ArdCallGroupUser(); |
| | | ardCallGroupUser.setGroupId(groupId); |
| | | List<ArdCallGroupUser> ardCallGroupUsers = ardCallGroupUserMapper.selectArdCallGroupUserList(ardCallGroupUser); |
| | | // æågroupListä¸çuserIdå°ä¸ä¸ªSetä¸ |
| | |
| | | package com.ruoyi.call.service.impl; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.call.domain.*; |
| | | import com.ruoyi.call.mapper.*; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.call.service.IArdCallHistoryService; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.websocket.Session; |
| | | |
| | | import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public int insertArdCallHistory(ArdCallHistory ardCallHistory) { |
| | | |
| | | |
| | | ardCallHistory.setId(IdUtils.simpleUUID()); |
| | | ardCallHistory.setCreateTime(DateUtils.getNowDate()); |
| | | ArdCallSession ardCallSession = ardCallSessionMapper.selectArdCallSessionById(ardCallHistory.getSessionId()); |
| | |
| | | ardCallUnreadMessagesMapper.updateArdCallUnreadMessages(ardCallUnreadMessages); |
| | | } |
| | | //websocketåéç»targetId |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(ardCallHistory.getTargetId()),ardCallHistory.getContent()); |
| | | // æå»ºæ£åè¡¨è¾¾å¼æ¨¡å¼ |
| | | String regex = "^" + Pattern.quote(ardCallHistory.getTargetId()) + "_\\d+$"; |
| | | Pattern pattern = Pattern.compile(regex); |
| | | Map<String, Object> messageMap = new HashMap<>(); |
| | | messageMap.put("type", "message"); |
| | | messageMap.put("message", JSON.toJSONString(ardCallHistory)); |
| | | ONLINE_USER_SESSIONS.entrySet().stream() |
| | | .filter(entry -> { |
| | | Matcher matcher = pattern.matcher(entry.getKey()); |
| | | return matcher.matches(); |
| | | }) |
| | | .map(Map.Entry::getValue) |
| | | .forEach(session -> WebSocketUtils.sendMessage(session, messageMap)); |
| | | |
| | | } else { |
| | | //æ´æ°ç¾¤èç¨æ·æªè¯»æ¶æ¯è®¡æ° |
| | | ArdCallGroupUser ardCallGroupUser = new ArdCallGroupUser(); |
| | |
| | | ardCallUnreadMessages.setUnreadCount(ardCallUnreadMessages.getUnreadCount() + 1); |
| | | ardCallUnreadMessagesMapper.updateArdCallUnreadMessages(ardCallUnreadMessages); |
| | | } |
| | | //websocketåéç»targetId |
| | | // æå»ºæ£åè¡¨è¾¾å¼æ¨¡å¼ |
| | | String regex = "^" + Pattern.quote(groupUser.getUserId()) + "_\\d+$"; |
| | | Pattern pattern = Pattern.compile(regex); |
| | | Map<String, Object> messageMap = new HashMap<>(); |
| | | messageMap.put("type", "message"); |
| | | messageMap.put("message", JSON.toJSONString(ardCallHistory)); |
| | | ONLINE_USER_SESSIONS.entrySet().stream() |
| | | .filter(entry -> |
| | | { |
| | | Matcher matcher = pattern.matcher(entry.getKey()); |
| | | return matcher.matches(); |
| | | }) |
| | | .map(Map.Entry::getValue) |
| | | .forEach(session -> WebSocketUtils.sendMessage(session, messageMap)); |
| | | } |
| | | //websocketåéç»targetId |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(groupUser.getUserId()),ardCallHistory.getContent()); |
| | | |
| | | }); |
| | | |
| | | } |
| | |
| | | return ardCallSessionUserMapper.selectArdCallSessionUserById(id); |
| | | } |
| | | |
| | | @Override |
| | | public ArdCallSessionUser selectArdCallSessionUserBySesionId(String userId,String sessionId) { |
| | | ArdCallSessionUser ardCallSessionUser = ardCallSessionUserMapper.selectArdCallSessionUserBySesionId(userId,sessionId); |
| | | if(ardCallSessionUser!=null) |
| | | { |
| | | //è·åæªè¯»æ°é |
| | | ArdCallUnreadMessages ardCallUnreadMessages = ardCallUnreadMessagesMapper.getUnreadMessage(ardCallSessionUser.getSessionId(), ardCallSessionUser.getUserId()); |
| | | if (ardCallUnreadMessages != null) { |
| | | ardCallSessionUser.setUnReadCount(ardCallUnreadMessages.getUnreadCount()); |
| | | } else { |
| | | ardCallSessionUser.setUnReadCount(0); |
| | | } |
| | | //è·åæå䏿¡æ¶æ¯å®ä½ |
| | | ArdCallHistory ardCallHistory = ardCallHistoryMapper.selectLastArdCallHistory(ardCallSessionUser.getSessionId()); |
| | | ardCallSessionUser.setArdCallHistory(ardCallHistory); |
| | | } |
| | | return ardCallSessionUser; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¼è¯ç¨æ·ä¸é´è¡¨å表 |
| | | * |
| | |
| | | for (ArdCameras ardCamera : ardCameras) { |
| | | redisCache.setCacheObject(getCacheKey(ardCamera.getId()), ardCamera); |
| | | } |
| | | |
| | | //æ¸
空æµåªä½ |
| | | vtduService.clearVtdu(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @Param |
| | | * @return |
| | | */ |
| | | @Scheduled(cron = "0 0/10 * * * ?") |
| | | //@Scheduled(cron = "0 0/10 * * * ?") |
| | | public void clearRecordTemp() |
| | | { |
| | | log.debug("宿¶æ¸
çæ¬å°å½åç¼åæä»¶ï¼è¶
è¿1天ï¼"); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteArdChannelByDeviceId(String deviceId); |
| | | /** |
| | | * @Author åèä¹ |
| | | * @Description è·å2个ééå表ç交é |
| | | * @Date 2024/7/10 9:38 |
| | | * @Param |
| | | * @return |
| | | */ |
| | | public List<ArdChannel> sameList(List<ArdChannel> oldArrayList, List<ArdChannel> newArrayList); |
| | | /** |
| | | * @Author åèä¹ |
| | | * @Description å2个ééå表çå·®é |
| | | * @Date 2024/7/10 9:39 |
| | | * @Param |
| | | * @return |
| | | */ |
| | | public List<ArdChannel> diffList(List<ArdChannel> firstArrayList, List<ArdChannel> secondArrayList); |
| | | |
| | | /** |
| | | * @Author åèä¹ |
| | | * @Description 忥ééä¿¡æ¯ |
| | | * @Date 2024/7/10 13:20 |
| | | * @Param |
| | | * @return |
| | | */ |
| | | public void asyncChannel(List<ArdChannel> oldArrayList, List<ArdChannel> newArrayList); |
| | | } |
| | |
| | | package com.ruoyi.device.channel.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.ruoyi.device.channel.mapper.ArdChannelMapper; |
| | | import com.ruoyi.device.channel.domain.ArdChannel; |
| | | import com.ruoyi.device.channel.service.IArdChannelService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * éé管çServiceä¸å¡å±å¤ç |
| | |
| | | */ |
| | | @Service |
| | | public class ArdChannelServiceImpl implements IArdChannelService { |
| | | @Autowired |
| | | @Resource |
| | | private ArdChannelMapper ardChannelMapper; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int insertArdChannel(ArdChannel ardChannel) { |
| | | ardChannel.setId(IdUtils.simpleUUID()); |
| | | return ardChannelMapper.insertArdChannel(ardChannel); |
| | | ardChannel.setId(IdUtils.simpleUUID()); |
| | | return ardChannelMapper.insertArdChannel(ardChannel); |
| | | } |
| | | |
| | | /** |
| | |
| | | public int deleteArdChannelById(String id) { |
| | | return ardChannelMapper.deleteArdChannelById(id); |
| | | } |
| | | |
| | | /** |
| | | * å é¤éé管çä¿¡æ¯ |
| | | * |
| | |
| | | public int deleteArdChannelByDeviceId(String deviceId) { |
| | | return ardChannelMapper.deleteArdChannelByDeviceId(deviceId); |
| | | } |
| | | } |
| | | |
| | | //æ±ä¸¤ä¸ªå¯¹è±¡Listç交é |
| | | @Override |
| | | public List<ArdChannel> sameList(List<ArdChannel> oldArrayList, List<ArdChannel> newArrayList) { |
| | | List<ArdChannel> resultList = newArrayList.stream() |
| | | .filter(item -> oldArrayList.stream().map(e -> e.getChanNo()) |
| | | .collect(Collectors.toList()).contains(item.getChanNo())) |
| | | .collect(Collectors.toList()); |
| | | return resultList; |
| | | } |
| | | |
| | | //æ±ä¸¤ä¸ªå¯¹è±¡Listçå·®é |
| | | @Override |
| | | public List<ArdChannel> diffList(List<ArdChannel> firstArrayList, List<ArdChannel> secondArrayList) { |
| | | List<ArdChannel> resultList = firstArrayList.stream() |
| | | .filter(item -> !secondArrayList.stream().map(e -> e.getChanNo()).collect(Collectors.toList()).contains(item.getChanNo())) |
| | | .collect(Collectors.toList()); |
| | | return resultList; |
| | | } |
| | | |
| | | @Override |
| | | public void asyncChannel(List<ArdChannel> oldArrayList, List<ArdChannel> newArrayList) { |
| | | //éè¦æ´æ°çæ°æ®,åæ°é¡ºåºæ³¨æ |
| | | sameList(oldArrayList, newArrayList).stream().forEach(ardChannel -> { |
| | | updateArdChannel(ardChannel); |
| | | }); |
| | | //éè¦å é¤çæ°æ® |
| | | diffList(oldArrayList, newArrayList).stream().forEach(ardChannel -> { |
| | | deleteArdChannelById(ardChannel.getId()); |
| | | }); |
| | | //éè¦æ°å¢çæ°æ® |
| | | diffList(newArrayList, oldArrayList).stream().forEach(ardChannel -> { |
| | | insertArdChannel(ardChannel); |
| | | }); |
| | | } |
| | | } |
| | |
| | | return getDataTable(mediaService.getPullStreamList());
|
| | | }
|
| | |
|
| | | /**
|
| | | * é
ç½®æµåªä½åæ°
|
| | | */
|
| | | @PostMapping("/setConfig")
|
| | | @ApiOperation("é
ç½®æµåªä½åæ°")
|
| | | @ApiOperationSupport(order = 8)
|
| | | public AjaxResult setConfig(@RequestBody Config config) {
|
| | | return AjaxResult.success(mediaService.setConfig(config));
|
| | | }
|
| | | }
|
| | |
| | | */
|
| | | @GetMapping(value = "/{name}/noPerm")
|
| | | public AjaxResult getInfoNoPerm(@PathVariable("name") String name) {
|
| | | Vtdu vtdu = vtduService.selectVtduByName(name);
|
| | | if (vtdu != null) {
|
| | | String cameraId = name.split("_")[0];
|
| | | Integer chanNo = Integer.valueOf(name.split("_")[1]);
|
| | | CameraCmd cmd = new CameraCmd(cameraId, chanNo);
|
| | | Map<String, Object> videoCompressionCfg = cameraSdkService.getVideoCompressionCfg(cmd);
|
| | | String videoEncType = (String) videoCompressionCfg.get("videoEncType");
|
| | | if (videoEncType != null) {
|
| | | if (!videoEncType.equals("æ åh264")) {
|
| | | vtdu.setIsCode("1");
|
| | | } else {
|
| | | vtdu.setIsCode("0");
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | vtdu.setIsCode("0");
|
| | | }
|
| | | //æµåªä½ä¸å卿°å¢ï¼å卿´æ°
|
| | | if (!mediaService.checkNameExist(name)) {
|
| | | mediaService.addPath(name, vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode());
|
| | | } else {
|
| | | vtduService.updateVtdu(vtdu);
|
| | | }
|
| | | }
|
| | | return success(vtdu);
|
| | | return success(vtduService.selectVtduByName(name));
|
| | | }
|
| | | /**
|
| | | * æ°å¢æµåªä½ç®¡ç
|
| | |
| | | private List<Readers> readers; |
| | | private List<String> tracks; |
| | | private Long bytesReceived; |
| | | |
| | | private Date readyTime; |
| | | } |
ÎļþÃû´Ó ard-work/src/main/java/com/ruoyi/media/domain/JsonsRoot.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.media.domain; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | |
| | | * @Version: 1.0 |
| | | **/ |
| | | @Data |
| | | public class JsonsRoot { |
| | | public class Paths { |
| | | |
| | | private int itemCount; |
| | | |
| | |
| | | public class RtmpSession { |
| | | private String name; |
| | | private String id; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date created; |
| | | private String remoteAddr; |
| | | private String state; |
| | |
| | | public class RtspSession { |
| | | private String name; |
| | | private String id; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date created; |
| | | private String remoteAddr; |
| | | private String state; |
| | |
| | | * ç¸æºID |
| | | */ |
| | | String cameraId; |
| | | |
| | | } |
| | |
| | | public class WebrtcSession { |
| | | private String name; |
| | | private String id; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date created; |
| | | private String remoteAddr; |
| | | private String state; |
| | |
| | | package com.ruoyi.media.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.media.domain.Vtdu; |
| | | |
| | | /** |
| | | * æµåªä½ç®¡çMapperæ¥å£ |
| | | * |
| | | * |
| | | * @author ard |
| | | * @date 2023-08-29 |
| | | */ |
| | | public interface VtduMapper |
| | | { |
| | | public interface VtduMapper { |
| | | /** |
| | | * æ¥è¯¢æµåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param name æµåªä½ç®¡çä¸»é® |
| | | * @return æµåªä½ç®¡ç |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ¥è¯¢æµåªä½ç®¡çå表 |
| | | * |
| | | * |
| | | * @param vtdu æµåªä½ç®¡ç |
| | | * @return æµåªä½ç®¡çéå |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ°å¢æµåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param vtdu æµåªä½ç®¡ç |
| | | * @return ç»æ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * ä¿®æ¹æµåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param vtdu æµåªä½ç®¡ç |
| | | * @return ç»æ |
| | | */ |
| | |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteVtduByName(String name); |
| | | |
| | | /** |
| | | * æ¹éå 餿µåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param names éè¦å é¤çæ°æ®ä¸»é®éå |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteVtduByNames(String[] names); |
| | | |
| | | /** |
| | | * å 餿µåªä½ç®¡çä¿¡æ¯ |
| | | * |
| | |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteVtduByCameraId(String cameraId); |
| | | |
| | | public void clearVtdu(); |
| | | } |
| | |
| | | |
| | | Boolean kickWebrtcSession(String sessionId); |
| | | |
| | | /** |
| | | * é
ç½®æµåªä½åæ° |
| | | * åèä¹ |
| | | * 2023/10/13 15:17:57 |
| | | */ |
| | | public String setConfig(Config config); |
| | | } |
| | |
| | | package com.ruoyi.media.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.device.channel.domain.ArdChannel; |
| | | import com.ruoyi.media.domain.Vtdu; |
| | | |
| | | /** |
| | | * æµåªä½ç®¡çServiceæ¥å£ |
| | | * |
| | | * |
| | | * @author ard |
| | | * @date 2023-08-29 |
| | | */ |
| | | public interface IVtduService |
| | | { |
| | | public interface IVtduService { |
| | | /** |
| | | * æ¥è¯¢æµåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param name æµåªä½ç®¡çä¸»é® |
| | | * @return æµåªä½ç®¡ç |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ¥è¯¢æµåªä½ç®¡çå表 |
| | | * |
| | | * |
| | | * @param vtdu æµåªä½ç®¡ç |
| | | * @return æµåªä½ç®¡çéå |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ°å¢æµåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param vtdu æµåªä½ç®¡ç |
| | | * @return ç»æ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * ä¿®æ¹æµåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param vtdu æµåªä½ç®¡ç |
| | | * @return ç»æ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ¹éå 餿µåªä½ç®¡ç |
| | | * |
| | | * |
| | | * @param names éè¦å é¤çæµåªä½ç®¡ç主é®éå |
| | | * @return ç»æ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * å 餿µåªä½ç®¡çä¿¡æ¯ |
| | | * |
| | | * |
| | | * @param name æµåªä½ç®¡çä¸»é® |
| | | * @return ç»æ |
| | | */ |
| | |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteVtduByCameraId(String cameraId); |
| | | |
| | | /** |
| | | * @Author åèä¹ |
| | | * @Description æ¸
空æµåªä½æææ°æ® |
| | | * @Date 2024/7/10 13:21 |
| | | * @Param |
| | | * @return |
| | | */ |
| | | public void clearVtdu(); |
| | | |
| | | /** |
| | | * @return |
| | | * @Author åèä¹ |
| | | * @Description è·å2个ééå表ç交é |
| | | * @Date 2024/7/10 9:38 |
| | | * @Param |
| | | */ |
| | | public List<Vtdu> sameList(List<Vtdu> vtdus, List<String> names); |
| | | |
| | | /** |
| | | * @return |
| | | * @Author åèä¹ |
| | | * @Description å2个ééå表çå·®é |
| | | * @Date 2024/7/10 9:39 |
| | | * @Param |
| | | */ |
| | | public List<String> diffListToDel(List<Vtdu> vtdus, List<String> names); |
| | | public List<Vtdu> diffListToAdd(List<Vtdu> vtdus, List<String> names); |
| | | /** |
| | | * @return |
| | | * @Author åèä¹ |
| | | * @Description 忥æµåªä½ |
| | | * @Date 2024/7/10 13:18 |
| | | * @Param |
| | | */ |
| | | public void asyncVtdu(List<Vtdu> vtdus, List<String> names); |
| | | } |
| | |
| | | package com.ruoyi.media.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dtflys.forest.Forest; |
| | | import com.dtflys.forest.exceptions.ForestNetworkException; |
| | | import com.dtflys.forest.exceptions.ForestRuntimeException; |
| | | import com.dtflys.forest.http.ForestRequest; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.media.domain.*; |
| | | import com.ruoyi.media.service.IMediaService; |
| | |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import javax.xml.soap.SOAPEnvelope; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | @Service |
| | | @Slf4j(topic = "vtdu") |
| | | @Order(2) |
| | | public class MediaServiceImpl implements IMediaService, ApplicationRunner { |
| | | public static List<String> mediaNameList = new ArrayList<>(); |
| | | public class MediaServiceImpl implements IMediaService { |
| | | |
| | | @Resource |
| | | MediaClient mediaClient; |
| | | |
| | | @Value("${mediamtx.host}") |
| | | String mediamtxHost; |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | mediaNameList = getNameList(); |
| | | if (mediaNameList.size() > 0) { |
| | | removePath(mediaNameList.toArray(new String[0])); |
| | | mediaNameList.clear(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ·»å æµåªä½ |
| | |
| | | |
| | | if (!checkNameExist(name)) { |
| | | mediaClient.addPath(name, conf); |
| | | mediaNameList.add(name); |
| | | } else { |
| | | mediaClient.editPath(name, conf); |
| | | } |
| | | |
| | | map.put("rtspUrl", rtspUrl); |
| | |
| | | try { |
| | | if (checkNameExist(name)) { |
| | | mediaClient.removePath(name); |
| | | mediaNameList.remove(name); |
| | | } |
| | | } catch (ForestRuntimeException ex) { |
| | | log.error("ç§»é¤æµåªä½å¼å¸¸ï¼" + ex.getMessage()); |
| | |
| | | |
| | | @Override |
| | | public List<StreamInfo> paths() { |
| | | String list = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | List<StreamInfo> pathInfoList = new ArrayList<>(); |
| | | for (Items item : items) { |
| | | StreamInfo info = new StreamInfo(); |
| | |
| | | @Override |
| | | public List<StreamInfo> getPushStreamList() { |
| | | List<StreamInfo> PushStreamInfoList = new ArrayList<>(); |
| | | String list = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | for (Items item : items) { |
| | | StreamInfo info = new StreamInfo(); |
| | | //ID |
| | |
| | | long bytesReceived = item.getBytesReceived(); |
| | | String formatReceivedSize = ArdTool.formatFileSize(bytesReceived); |
| | | info.setUpTraffic(formatReceivedSize); |
| | | info.setBeginTime(item.getReadyTime()); |
| | | } else { |
| | | RtspSession rtspSession = getRtspSessionById(source.getId()); |
| | | //ä¼è¯ID |
| | |
| | | @Override |
| | | public List<StreamInfo> getPullStreamList() { |
| | | List<StreamInfo> PullStreamInfoList = new ArrayList<>(); |
| | | String list = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | for (Items item : items) { |
| | | List<Readers> readers = item.getReaders(); |
| | | for (Readers reader : readers) { |
| | |
| | | PullStreamInfoList.add(info); |
| | | break; |
| | | case "webRTCSession": |
| | | case "webrtcSession": |
| | | info.setSessionType("webrtc"); |
| | | //webrtcææ¾å°å |
| | | url = "http://" + mediamtxHost + ":8889/" + name; |
| | |
| | | */ |
| | | @Override |
| | | public List<String> getNameList() { |
| | | List<String> nameList = new ArrayList<>(); |
| | | try { |
| | | String paths = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(paths, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | for (Items item : items) { |
| | | mediaNameList.add(item.getName()); |
| | | nameList.add(item.getName()); |
| | | } |
| | | } catch (ForestNetworkException ex) { |
| | | log.error("è·åæµåªä½nameå表å¼å¸¸ï¼" + ex.getMessage()); |
| | | } catch (ForestRuntimeException ex) { |
| | | } catch (Exception ex) { |
| | | log.error("è·åæµåªä½nameå表å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return mediaNameList; |
| | | return nameList; |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥åç§°æ¯å¦åå¨ |
| | | * æ£æ¥nameæ¯å¦åå¨ |
| | | * åèä¹ |
| | | * 2023/10/19 15:18:45 |
| | | */ |
| | | @Override |
| | | public boolean checkNameExist(String name) { |
| | | boolean result = false; |
| | | if (mediaNameList.contains(name)) { |
| | | List<String> nameList = getNameList(); |
| | | if (nameList.contains(name)) { |
| | | result = true; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * é
ç½®æµåªä½åæ° |
| | | */ |
| | | @Override |
| | | public String setConfig(Config config) { |
| | | return mediaClient.setConfig(config); |
| | | } |
| | | |
| | | |
| | |
| | | import com.dtflys.forest.exceptions.ForestNetworkException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.media.domain.*; |
| | | import com.ruoyi.media.service.IMediaService; |
| | | import com.ruoyi.media.service.IMediaV2Service; |
| | | import com.ruoyi.utils.forest.MediaClient; |
| | | import com.ruoyi.utils.tools.ArdTool; |
| | |
| | | conf.setSourceProtocol("tcp"); |
| | | |
| | | List<String> nameList = new ArrayList<>(); |
| | | String paths = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(paths, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | for (Items item : items) { |
| | | nameList.add(item.getName()); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<StreamInfo> paths() { |
| | | String list = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | List<StreamInfo> pathInfoList = new ArrayList<>(); |
| | | for (Items item : items) { |
| | | StreamInfo info = new StreamInfo(); |
| | |
| | | @Override |
| | | public List<StreamInfo> getPushStreamList() { |
| | | List<StreamInfo> PushStreamInfoList = new ArrayList<>(); |
| | | String list = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | for (Items item : items) { |
| | | StreamInfo info = new StreamInfo(); |
| | | //ID |
| | |
| | | @Override |
| | | public List<StreamInfo> getPullStreamList() { |
| | | List<StreamInfo> PullStreamInfoList = new ArrayList<>(); |
| | | String list = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | for (Items item : items) { |
| | | List<Readers> readers = item.getReaders(); |
| | | for (Readers reader : readers) { |
| | |
| | | public List<String> getNameList() { |
| | | List<String> nameList = new ArrayList<>(); |
| | | try { |
| | | String paths = mediaClient.paths(); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(paths, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | Paths paths = mediaClient.paths(); |
| | | List<Items> items = paths.getItems(); |
| | | for (Items item : items) { |
| | | nameList.add(item.getName()); |
| | | } |
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | | import com.ruoyi.device.channel.domain.ArdChannel;
|
| | | import com.ruoyi.media.service.IMediaService;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | }
|
| | | return vtduMapper.deleteVtduByCameraId(cameraId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * @return
|
| | | * @Author åèä¹
|
| | | * @Description æ¸
é¤æææµåªä½æ°æ®
|
| | | * @Date 2024/7/10 13:31
|
| | | * @Param
|
| | | */
|
| | | public void clearVtdu() {
|
| | | vtduMapper.clearVtdu();
|
| | | }
|
| | |
|
| | |
|
| | | //éè¦æ´æ°çï¼æµåªä½åvtduç¸åï¼
|
| | | @Override
|
| | | public List<Vtdu> sameList(List<Vtdu> vtdus, List<String> names) {
|
| | | return vtdus.stream().filter(vtdu -> names.contains(vtdu.getName())).collect(Collectors.toList());
|
| | | }
|
| | |
|
| | | //éè¦å é¤çï¼æµåªä½ä¸å¤çï¼
|
| | | @Override
|
| | | public List<String> diffListToDel(List<Vtdu> vtdus, List<String> names) {
|
| | | if (vtdus.size() >= names.size()) {
|
| | | List<String> nameList = vtdus.stream().map(Vtdu::getName)
|
| | | .filter(item -> !names.contains(item))
|
| | | .collect(Collectors.toList());
|
| | | return nameList;
|
| | | } else {
|
| | |
|
| | | List<String> nameList = names.stream().filter(item -> !vtdus.stream().map(Vtdu::getName).collect(Collectors.toList()).contains(item))
|
| | | .collect(Collectors.toList());
|
| | | return nameList;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | //éè¦æ°å¢çï¼æµåªä½ä¸å°çï¼
|
| | | @Override
|
| | | public List<Vtdu> diffListToAdd(List<Vtdu> vtdus, List<String> names) {
|
| | | return vtdus.stream().filter(vtdu -> !names.contains(vtdu.getName())).collect(Collectors.toList());
|
| | | }
|
| | |
|
| | | /**
|
| | | * @Author åèä¹
|
| | | * @Description 忥æ¬å°vtduåºåæµåªä½ä¸çæ°æ®
|
| | | * @Date 2024/7/10 15:26
|
| | | * @Param vtdus vtduåºçéå
|
| | | * @Param names æµåªä½çnameéå
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public void asyncVtdu(List<Vtdu> vtdus, List<String> names) {
|
| | | //éè¦æ´æ°çæ°æ®,åæ°é¡ºåºæ³¨æ
|
| | | sameList(vtdus, names).stream().forEach(vtdu -> {
|
| | | mediaService.editPath(vtdu.getName(), vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode());
|
| | | });
|
| | | //éè¦å é¤çæ°æ®
|
| | | diffListToDel(vtdus, names).stream().forEach(name -> {
|
| | | mediaService.removePath(name);
|
| | | });
|
| | | //éè¦æ°å¢çæ°æ®
|
| | | diffListToAdd(vtdus, names).stream().forEach(vtdu -> {
|
| | | mediaService.addPath(vtdu.getName(), vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode());
|
| | | });
|
| | | }
|
| | | }
|
| | |
| | | import com.ruoyi.media.domain.Conf; |
| | | import com.ruoyi.media.domain.Config; |
| | | import com.ruoyi.media.domain.Items; |
| | | import com.ruoyi.media.domain.Paths; |
| | | |
| | | import java.nio.file.Path; |
| | | |
| | | /** |
| | | * @Description: mediamtxæµåªä½å®¢æ·ç«¯ |
| | |
| | | * æ¥è¯¢ææè·¯å¾ |
| | | */ |
| | | @Get("/paths/list") |
| | | public String paths(); |
| | | public Paths paths(); |
| | | |
| | | /** |
| | | * æ¥è¯¢æærtspä¼è¯ |
| | |
| | | int nBufferLen = 2*1024*1024; |
| | | byte[] strBuffer = new byte[nBufferLen]; |
| | | |
| | | if(netsdkapi.CLIENT_GetNewDevConfig( hLoginHandle, strCmd , nChn, strBuffer, nBufferLen,error,3000)) { |
| | | if(netsdkapi.CLIENT_GetNewDevConfig( hLoginHandle, strCmd , nChn, strBuffer, nBufferLen,error,6000)) { |
| | | cmdObject.write(); |
| | | if (configapi.CLIENT_ParseData(strCmd, strBuffer, cmdObject.getPointer(), |
| | | cmdObject.size(), null)) { |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public static String getChannelName(NetSDKLib.LLong hLoginHandle,Integer channel) { |
| | | String channelName = ""; |
| | | NetSDKLib.AV_CFG_ChannelName channelTitleName = new NetSDKLib.AV_CFG_ChannelName(); |
| | | if (ToolKits.GetDevConfig(hLoginHandle, channel, NetSDKLib.CFG_CMD_CHANNELTITLE, channelTitleName)) { |
| | | try { |
| | | channelName = new String(channelTitleName.szName, "GBK"); |
| | | } catch (Exception e) { |
| | | System.err.println("getChannelName Failed!"); |
| | | } |
| | | } else { |
| | | System.err.println("Get Channel Name Failed." + ToolKits.getErrorCodePrint()); |
| | | } |
| | | return channelName; |
| | | } |
| | | public static boolean GetDevConfig(NetSDKLib.LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) { |
| | | boolean result = true; |
| | | IntByReference error = new IntByReference(0); |
| | |
| | | stOut.read(); |
| | | ToolKits.GetPointerDataToStructArr(stOut.pCameraStateInfo, arrCameraStatus); // å°Pointeræ·è´å°æ°ç»å
å |
| | | final String[] connectionState = {"æªç¥", "æ£å¨è¿æ¥", "å·²è¿æ¥", "æªè¿æ¥", "ééæªé
ç½®,æ ä¿¡æ¯", "ééæé
ç½®,ä½è¢«ç¦ç¨"}; |
| | | log.debug(connectionState[arrCameraStatus[chanNo - 1].emConnectionState]); |
| | | if (connectionState[arrCameraStatus[chanNo - 1].emConnectionState].equals("å·²è¿æ¥")) { |
| | | log.debug("éé" + arrCameraStatus[chanNo - 1].nChannel + connectionState[arrCameraStatus[chanNo - 1].emConnectionState]); |
| | | bRet = true; |
| | |
| | | log.error("设å¤[" + camera.getIp() + ":" + camera.getPort() + "]ç»å½å¤±è´¥:" + getErrorCodePrint()); |
| | | return AjaxResult.warn(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | // if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | // GlobalVariable.loginMap.remove(camera.getId()); |
| | | // } |
| | | |
| | | camera.setState("1"); |
| | | camera.setChanNum(m_stDeviceInfo.byChanNum); |
| | | camera.setStartDChan(1); |
| | |
| | | //è·åææ°éé |
| | | List<ArdChannel> ardChannelList = getChannels(camera); |
| | | if (ardChannelList.size() > 0) { |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | ardChannelList.stream().forEach(channel -> { |
| | | ardChannelService.insertArdChannel(channel); |
| | | }); |
| | | camera.setChanNum(ardChannelList.size()); |
| | | camera.setChannelList(ardChannelList); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | //é
ç½®å°æµåªä½ |
| | | addVtdu(camera); |
| | |
| | | log.error("设å¤[" + camera.getIp() + ":" + camera.getPort() + "]ç»å½å¤±è´¥:" + getErrorCodePrint()); |
| | | return AjaxResult.warn(getErrorCodePrint()); |
| | | } |
| | | // if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | // GlobalVariable.loginMap.remove(camera.getId()); |
| | | // } |
| | | camera.setState("1"); |
| | | camera.setChanNum(m_stDeviceInfo.byChanNum); |
| | | camera.setStartDChan(1); |
| | |
| | | //è·åææ°éé |
| | | List<ArdChannel> ardChannelList = getChannels(camera); |
| | | if (ardChannelList.size() > 0) { |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | ardChannelList.stream().forEach(channel -> { |
| | | ardChannelService.insertArdChannel(channel); |
| | | }); |
| | | camera.setChanNum(ardChannelList.size()); |
| | | camera.setChannelList(ardChannelList); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | //é
ç½®å°æµåªä½ |
| | | addVtdu(camera); |
| | |
| | | |
| | | //æ·»å å°æµåªä½ |
| | | private void addVtdu(ArdCameras camera) { |
| | | for (int i = 1; i < camera.getChanNum() + 1; i++) { |
| | | String name = camera.getId() + "_" + i; |
| | | String rtspSource = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getIp() + ":" + camera.getRtspPort() + "/cam/realmonitor?channel=" + i + "&subtype=0"; |
| | | Vtdu vtdu = vtduService.selectVtduByName(name); |
| | | if (vtdu != null) { |
| | | camera.getChannelList().stream().forEach(channel -> { |
| | | String name = camera.getId() + "_" + channel.getChanNo(); |
| | | String rtspSource = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getIp() + ":" + camera.getRtspPort() + "/cam/realmonitor?channel=" + channel.getChanNo() + "&subtype=0"; |
| | | //å 餿µåªä½ |
| | | if (vtduService.selectVtduByName(name) != null) { |
| | | vtduService.deleteVtduByName(name); |
| | | } |
| | | //æ·»å å°æµåªä½ |
| | | CameraCmd cmd = new CameraCmd(camera.getId(), i); |
| | | CameraCmd cmd = new CameraCmd(camera.getId(), channel.getChanNo()); |
| | | Map<String, Object> videoCompressionCfg = getVideoCompressionCfg(cmd); |
| | | vtdu = new Vtdu(); |
| | | Vtdu vtdu = new Vtdu(); |
| | | if (videoCompressionCfg.get("videoEncType") != null) { |
| | | if (videoCompressionCfg.get("videoEncType").equals("æ åh264")) { |
| | | vtdu.setIsCode("0");//é»è®¤ä¸è½¬ç |
| | |
| | | vtdu.setIsCode("0");//é»è®¤ä¸è½¬ç |
| | | } |
| | | vtdu.setRtspSource(rtspSource); |
| | | vtdu.setName(camera.getId() + "_" + i); |
| | | vtdu.setName(name); |
| | | vtdu.setMode("1");//é»è®¤CPU软解ç |
| | | vtdu.setCameraId(camera.getId()); |
| | | vtduService.insertVtdu(vtdu); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //å建å¼å¯¼éå |
| | |
| | | |
| | | //è·åéé |
| | | public List<ArdChannel> getChannels(ArdCameras camera) { |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | LLong loginId = new LLong(camera.getLoginId()); |
| | | List<ArdChannel> ardChannelList = new ArrayList<>(); |
| | | for (int i = 1; i < camera.getChanNum() + 1; i++) { |
| | | ArdChannel channel = new ArdChannel(); |
| | | NetSDKLib.AV_CFG_ChannelName av_cfg_channelName = new NetSDKLib.AV_CFG_ChannelName(); |
| | | boolean b = ConfigModule.GetNewDevConfig(loginId, i - 1, CFG_CMD_CHANNELTITLE, av_cfg_channelName); |
| | | if (!b) { |
| | | log.error("è·åé
置失败,请ç¨åéè¯" + getErrorCodePrint()); |
| | | // return AjaxResult.warn(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | String chanName = ""; |
| | | try { |
| | | chanName = new String(av_cfg_channelName.szName, "GBK").trim(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String chanName = ConfigModule.getChannelName(loginId, i - 1).trim(); |
| | | log.debug("è·åééåç§°ï¼" + chanName); |
| | | channel.setName(chanName.equals("") ? "éé" + i : chanName); |
| | | channel.setDeviceId(camera.getId()); |
| | | channel.setChanNo(i); |
| | |
| | | } |
| | | } |
| | | ardChannelList.add(channel); |
| | | ardChannelService.insertArdChannel(channel); |
| | | } |
| | | return ardChannelList; |
| | | } |
| | |
| | | float t = (float) dh_ptz_location_info.nPTZTilt / 10 * -1; |
| | | String nPTZTilt = df.format(t < 0 ? t + 360 : t); |
| | | String nPTZZoom = df.format((float) dh_ptz_location_info.nPTZZoom); |
| | | ptzMap.put("p" , nPTZPan); |
| | | ptzMap.put("t" , nPTZTilt); |
| | | ptzMap.put("z" , nPTZZoom); |
| | | ptzMap.put("p", nPTZPan); |
| | | ptzMap.put("t", nPTZTilt); |
| | | ptzMap.put("z", nPTZZoom); |
| | | return AjaxResult.success(ptzMap); |
| | | } |
| | | |
| | |
| | | // return false; |
| | | //} |
| | | log.debug("æ¬å°å½åå¼å§"); |
| | | return AjaxResult.success("æ¬å°å½åå¼å§" , lRealHandle); |
| | | return AjaxResult.success("æ¬å°å½åå¼å§", lRealHandle); |
| | | } catch (Exception ex) { |
| | | log.error("æ¬å°å½åå¼å§å¼å¸¸" + ex.getMessage()); |
| | | return AjaxResult.error("æ¬å°å½åå¼å§å¼å¸¸" + ex.getMessage()); |
| | |
| | | log.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置ptz失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("å¼å¯¼ç®æ ä½ç½®æå",correctPitch); |
| | | return AjaxResult.success("å¼å¯¼ç®æ ä½ç½®æå", correctPitch); |
| | | } catch (Exception ex) { |
| | | log.error("å¼å¯¼ç®æ ä½ç½®å¼å¸¸:" + ex.getMessage()); |
| | | return AjaxResult.error("å¼å¯¼ç®æ ä½ç½®å¼å¸¸:" + ex.getMessage()); |
| | |
| | | int nHeight = cfg_encode_info.stuMainStream[0].stuVideoFormat.nHeight; |
| | | String resolution = nWidth + "*" + nHeight; |
| | | float nFrameRate = cfg_encode_info.stuMainStream[0].stuVideoFormat.nFrameRate; |
| | | map.put("resolution" , resolution);//å辨ç |
| | | map.put("videoBitrate" , String.valueOf(nBitRate));//æ¯ç¹ç |
| | | map.put("videoEncType" , videoEncType);//ç¼ç |
| | | map.put("nFrameRate" , String.valueOf(nFrameRate));//帧ç |
| | | map.put("resolution", resolution);//å辨ç |
| | | map.put("videoBitrate", String.valueOf(nBitRate));//æ¯ç¹ç |
| | | map.put("videoEncType", videoEncType);//ç¼ç |
| | | map.put("nFrameRate", String.valueOf(nFrameRate));//帧ç |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("åç æµåç¼©åæ°å¼å¸¸:" + ex.getMessage()); |
| | |
| | | float nAngelH = (float) dh_out_ptz_view_range_status.nAngelH / 10; |
| | | float nAngelV = (float) dh_out_ptz_view_range_status.nAngelV / 10; |
| | | Map<String, Object> map = getPtz(cmd);//è·åptz |
| | | map.put("fHorFieldAngle" , nAngelH);// æ°´å¹³è§åºè§ |
| | | map.put("fVerFieldAngle" , nAngelV);// åç´è§åºè§ |
| | | map.put("fHorFieldAngle", nAngelH);// æ°´å¹³è§åºè§ |
| | | map.put("fVerFieldAngle", nAngelV);// åç´è§åºè§ |
| | | return AjaxResult.success(map); |
| | | } catch (Exception ex) { |
| | | log.error("è·åäºå°å¯è§åå¼å¸¸" + ex.getMessage()); |
| | |
| | | log.debug("Set fExceptionCallBack function successfully!"); |
| | | } |
| | | } |
| | | |
| | | // if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | // GlobalVariable.loginMap.remove(camera.getId()); |
| | | // } |
| | | GlobalVariable.loginMap.put(camera.getId(), lUserID); |
| | | GlobalVariable.loginCameraMap.put(lUserID, camera); |
| | | camera.setLoginId(lUserID); |
| | |
| | | //è·åææ°éé |
| | | List<ArdChannel> cameraChannelList = getChannels(camera); |
| | | if (cameraChannelList.size() > 0) { |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | cameraChannelList.stream().forEach(channel -> { |
| | | ardChannelService.insertArdChannel(channel); |
| | | }); |
| | | camera.setChannelList(cameraChannelList); |
| | | camera.setChanNum(cameraChannelList.size()); |
| | | ardCamerasService.updateArdCameras(camera); |
| | |
| | | } |
| | | } |
| | | } |
| | | // if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | // GlobalVariable.loginMap.remove(camera.getId()); |
| | | // } |
| | | |
| | | GlobalVariable.loginMap.put(camera.getId(), lUserID); |
| | | GlobalVariable.loginCameraMap.put(lUserID, camera); |
| | | camera.setLoginId(lUserID); |
| | |
| | | //è·åææ°éé |
| | | List<ArdChannel> cameraChannelList = getChannels(camera); |
| | | if (cameraChannelList.size() > 0) { |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | cameraChannelList.stream().forEach(channel -> { |
| | | ardChannelService.insertArdChannel(channel); |
| | | }); |
| | | camera.setChannelList(cameraChannelList); |
| | | camera.setChanNum(cameraChannelList.size()); |
| | | ardCamerasService.updateArdCameras(camera); |
| | |
| | | //æ·»å å°æµåªä½ |
| | | private void addVtdu(ArdCameras camera) { |
| | | try { |
| | | for (ArdChannel channel : camera.getChannelList()) { |
| | | camera.getChannelList().stream().forEach(channel->{ |
| | | String name = camera.getId() + "_" + channel.getChanNo(); |
| | | String rtspSource = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getIp() + ":" + camera.getRtspPort() + "/h264/ch" + channel.getChanNo() + "/main/av_stream"; |
| | | Vtdu vtdu = vtduService.selectVtduByName(name); |
| | | if (vtdu != null) { |
| | | //å 餿µåªä½ |
| | | if (vtduService.selectVtduByName(name) != null) { |
| | | vtduService.deleteVtduByName(name); |
| | | } |
| | | //æ·»å å°æµåªä½ |
| | | vtdu = new Vtdu(); |
| | | Vtdu vtdu = new Vtdu(); |
| | | vtdu.setRtspSource(rtspSource); |
| | | vtdu.setName(camera.getId() + "_" + channel.getChanNo()); |
| | | vtdu.setName(name); |
| | | CameraCmd cmd = new CameraCmd(camera.getId(), channel.getChanNo()); |
| | | Map<String, Object> videoCompressionCfg = getVideoCompressionCfg(cmd); |
| | | if (videoCompressionCfg.get("videoEncType").equals("æ åh264")) { |
| | |
| | | vtdu.setMode("1");//é»è®¤CPU软解ç |
| | | vtdu.setCameraId(camera.getId()); |
| | | vtduService.insertVtdu(vtdu); |
| | | } |
| | | }); |
| | | } catch (Exception ex) { |
| | | log.error("ééæ·»å å°æµåªä½å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | |
| | | //è·åéé |
| | | List<ArdChannel> channelList = new ArrayList<>(); |
| | | try { |
| | | //å é¤ç®¡çéé |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | IntByReference ibrBytesReturned = new IntByReference(0);//è·åIPæ¥å
¥é
ç½®åæ° |
| | | HCNetSDK.NET_DVR_IPPARACFG_V40 m_strIpparaCfg = new HCNetSDK.NET_DVR_IPPARACFG_V40(); |
| | | m_strIpparaCfg.write(); |
| | |
| | | } |
| | | channelList.add(channel); |
| | | } |
| | | ardChannelService.insertArdChannel(channel); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åIPééå¼å¸¸:" + ex.getMessage()); |
| | |
| | | package com.ruoyi.utils.websocket.service; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.app.position.service.impl.AppPositionPushService; |
| | | import com.ruoyi.call.dto.CallMessage; |
| | | import com.ruoyi.utils.websocket.util.WebSocketUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | import javax.websocket.server.PathParam; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import java.io.IOException; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; |
| | | |
| | | /** |
| | | * @ClassName ChatServerEndpoint |
| | |
| | | @OnMessage |
| | | public void onMessage(@PathParam("userId") String userId, String message) { |
| | | log.info("æ¶å°æ¶æ¯ï¼" + message); |
| | | Session session = WebSocketUtils.ONLINE_USER_SESSIONS.get(userId); |
| | | WebSocketUtils.sendMessage(session, message); |
| | | //sendMessageAll("ç¨æ·[" + userid + "] : " + message); |
| | | // Session session = WebSocketUtils.ONLINE_USER_SESSIONS.get(userId); |
| | | // WebSocketUtils.sendMessage(session, message); |
| | | Map<String, Object> messageMap = JSONObject.parseObject(message, Map.class); |
| | | if (((String) messageMap.get("type")).equals("callMessage")) { |
| | | String msg = (String) messageMap.get("message"); |
| | | CallMessage callMessage = JSONObject.parseObject(msg, CallMessage.class); |
| | | if (callMessage != null && callMessage.getType().equals(0)) { |
| | | String regex = "^" + Pattern.quote(callMessage.getTargetId()) + "_\\d+$"; |
| | | Pattern pattern = Pattern.compile(regex); |
| | | ONLINE_USER_SESSIONS.entrySet().stream() |
| | | .filter(entry -> { |
| | | Matcher matcher = pattern.matcher(entry.getKey()); |
| | | return matcher.matches(); |
| | | }) |
| | | .map(Map.Entry::getValue) |
| | | .forEach(session -> WebSocketUtils.sendMessage(session, message)); |
| | | } |
| | | |
| | | } |
| | | // æ ¹æ®ç¨æ·æ°çé¢çéæ°è°æ´å®æ¶ä»»å¡ |
| | | AppPositionPushService.messageHandler(userId,message); |
| | | AppPositionPushService.messageHandler(userId, message); |
| | | } |
| | | |
| | | @OnClose |
| | |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectArdCallSessionUserBySesionId" parameterType="String" resultMap="ArdCallSessionUserResult"> |
| | | <include refid="selectArdCallSessionUserVo"/> |
| | | where session_id = #{sessionId} and user_id = #{userId} |
| | | </select> |
| | | <select id="selectArdCallSessionUserById" parameterType="String" resultMap="ArdCallSessionUserResult"> |
| | | <include refid="selectArdCallSessionUserVo"/> |
| | | where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertArdCallSessionUser" parameterType="ArdCallSessionUser"> |
| | | insert into ard_call_session_user |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | from vtdu |
| | | where camera_id = #{cameraId} |
| | | </delete> |
| | | <delete id="clearVtdu"> |
| | | delete from vtdu |
| | | </delete> |
| | | </mapper> |
| | |
| | |
|
| | | 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);
|
| | |
| | |
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.utils.uuid.IdUtils;
|
| | | import com.ruoyi.device.camera.domain.ArdCameras;
|
| | | import com.ruoyi.device.camera.domain.CameraCmd;
|
| | | import com.ruoyi.device.camera.factory.CameraSDK;
|
| | | import com.ruoyi.device.camera.factory.CameraSDKFactory;
|
| | | import com.ruoyi.device.camera.service.IArdCamerasService;
|
| | | import com.ruoyi.device.camera.service.ICameraSdkService;
|
| | | import com.ruoyi.device.channel.domain.ArdChannel;
|
| | | import com.ruoyi.device.channel.service.IArdChannelService;
|
| | | import com.ruoyi.device.channel.service.impl.ArdChannelServiceImpl;
|
| | | import com.ruoyi.media.domain.Vtdu;
|
| | | import com.ruoyi.media.service.IMediaService;
|
| | | import com.ruoyi.media.service.IVtduService;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | /**
|
| | | * @Description: 忥任å¡
|
| | |
| | | IMediaService mediaService;
|
| | | @Resource
|
| | | private ICameraSdkService cameraSdkService;
|
| | | @Resource
|
| | | private CameraSDKFactory cameraSDKFactory;
|
| | | @Resource
|
| | | private IArdChannelService ardChannelService;
|
| | | /**
|
| | | * åæ¥ç¸æºå¨çº¿ç¶æ
|
| | | * åèä¹
|
| | |
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("åæ¥ç¸æºå¨çº¿ç¶æå¼å¸¸:" + ex.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * @Author åèä¹
|
| | | * @Description 忥nvrééç¶æå®æ¶åæ¥æµåªä½
|
| | | * @Date 2024/7/9 16:01
|
| | | */
|
| | | public void nvrChannelState() {
|
| | | //è·åæænvr设å¤
|
| | | List<ArdCameras> ardCamerasList = iArdCamerasService.selectArdCamerasListNoDataScope(new ArdCameras());
|
| | | if (ardCamerasList.size() > 0) {
|
| | | ardCamerasList.stream()
|
| | | .filter(ardCameras -> ardCameras.getGdtype().equals("2"))
|
| | | .forEach(ardCameras -> {
|
| | | //éè¿SDKè·åNVRå½åéé
|
| | | CameraSDK cameraSDK = cameraSDKFactory.createCameraSDK(ardCameras.getFactory());
|
| | | List<ArdChannel> ardChannelList = cameraSDK.getChannels(ardCameras);
|
| | | //忥éé表
|
| | | ArdChannel ardChannel=new ArdChannel();
|
| | | ardChannel.setDeviceId(ardCameras.getId());
|
| | | List<ArdChannel> ardChannelListDb = ardChannelService.selectArdChannelList(ardChannel);
|
| | | ardChannelService.asyncChannel(ardChannelListDb,ardChannelList);
|
| | | //忥æµåªä½è¡¨
|
| | |
|
| | | //忥æµåªä½api
|
| | |
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | * 2023/10/13 14:13:53
|
| | | */
|
| | | public void vtdu() {
|
| | |
|
| | | List<Vtdu> vtdus = vtduService.selectVtduList(new Vtdu());
|
| | | for (Vtdu vtdu : vtdus) {
|
| | | boolean nameExist = mediaService.checkNameExist(vtdu.getName());
|
| | | if (!nameExist) {
|
| | | mediaService.addPath(vtdu.getName(), vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode());
|
| | | }
|
| | | }
|
| | | List<String> nameList = mediaService.getNameList();
|
| | | List<Vtdu> vtduList = vtduService.selectVtduList(new Vtdu());
|
| | | vtduService.asyncVtdu(vtduList,nameList);
|
| | | }
|
| | | }
|