ycl-platform/src/main/java/com/ycl/controller/platformApi/AlarmController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-platform/src/main/java/com/ycl/task/SynchronizeHKVideo.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-platform/src/main/java/com/ycl/timer/GetDingUserOrgTimer.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-platform/src/main/java/com/ycl/util/VideoUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-platform/src/main/resources/application-prod.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ycl-platform/src/main/java/com/ycl/controller/platformApi/AlarmController.java
@@ -2,12 +2,15 @@ import cn.hutool.json.JSONConverter; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.ycl.annotation.LogSave; import com.ycl.api.CommonResult; import com.ycl.dto.video.AlarmParam; import com.ycl.entity.video.VideoPoint; import com.ycl.enums.common.ResultCode; import com.ycl.service.video.IVideoAlarmReportService; import com.ycl.service.video.impl.IVideoPointService; import com.ycl.util.VideoUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -27,6 +30,7 @@ import java.util.Base64; import java.util.Dictionary; import java.util.Hashtable; import java.util.List; /** * @author admin @@ -35,6 +39,7 @@ @RestController @RequestMapping("/API") public class AlarmController { private IVideoPointService videoPointService; private IVideoAlarmReportService videoAlarmReportService; private static Dictionary<String, Integer> sessionDic = new Hashtable<>(); @@ -45,6 +50,11 @@ @Autowired public void setVideoAlarmReportService(IVideoAlarmReportService videoAlarmReportService) { this.videoAlarmReportService = videoAlarmReportService; } @Autowired public void setVideoPointService(IVideoPointService videoPointService) { this.videoPointService = videoPointService; } @ApiOperation("视频报警推送API") @@ -62,6 +72,15 @@ public CommonResult getMonitorAddress(@PathVariable String code, @PathVariable Integer subType, @RequestParam(required = false) String scheme) { LambdaQueryWrapper<VideoPoint> queryWrapper = new LambdaQueryWrapper<VideoPoint>() .eq(VideoPoint::getPlatResourceId, code) .or().eq(VideoPoint::getCode, code); List<VideoPoint> pointList = videoPointService.list(queryWrapper); if (pointList.size() > 0) { VideoPoint videoPoint = pointList.get(0); if (videoPoint.getType() == 1) { return CommonResult.successApi(videoUtil.getKHVideo(code)); } else { if (subType == null) { subType = 1; } @@ -70,6 +89,17 @@ } return CommonResult.successApi(videoUtil.getVideo(code, scheme, subType)); } } else { if (subType == null) { subType = 1; } if (!StringUtils.isNotBlank(scheme)) { scheme = "RTSP"; } return CommonResult.successApi(videoUtil.getVideo(code, scheme, subType)); } } @ApiOperation(value = "获取图片") ycl-platform/src/main/java/com/ycl/task/SynchronizeHKVideo.java
@@ -25,18 +25,18 @@ @Autowired private VideoUtil videoUtil; @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 // @Scheduled(cron = "0/9 * * * * ?") // 每秒执行 // @Scheduled(cron = "0 0/1 * ?") @Transactional(rollbackFor = Exception.class) public void scheduledTask() { try { System.out.println("海康:开始执行"); findVideoList(1, 20); } catch (Exception ex) { } } private void findVideoList(Integer pageNo, Integer pageSize) throws Exception { private void findVideoList(Integer pageNo, Integer pageSize) { try { PageResult<Camera> pageResult = videoUtil.callPostCameras(pageNo, pageSize, "0"); if (pageResult.getTotal() > 0) { if (pageResult.getList().size() > 0) { @@ -47,6 +47,9 @@ } } } } catch (Exception ex) { System.out.println("海康:" + ex.getMessage()); } } private void saveVideoFromCamera(List<Camera> list) { ycl-platform/src/main/java/com/ycl/timer/GetDingUserOrgTimer.java
@@ -105,7 +105,7 @@ umsDepartService.saveOrUpdate(dingOrg); }); log.info(TAG + "update organization size " + dingOrgList.size()); // log.info(TAG + "update organization size " + dingOrgList.size()); TimeInterval timer = DateUtil.timer(); /** // * 根据组织code 查询 通讯录人员信息 @@ -134,7 +134,7 @@ } } ArrayList<UmsAdminRoleRelation> relations = new ArrayList<>(); log.info(TAG + " elapsed time:" + timer.interval()); // log.info(TAG + " elapsed time:" + timer.interval()); for (DingUserInfo dingUserInfo : dingList) { //1.添加用户 UmsAdmin user = new UmsAdmin(); @@ -185,7 +185,7 @@ if (CollUtil.isNotEmpty(relations)) { umsAdminRoleRelationService.saveBatch(relations, IService.DEFAULT_BATCH_SIZE); } log.info(TAG + "update user size " + dingList.size()); // log.info(TAG + "update user size " + dingList.size()); // getEmployeeAvatar(); } ycl-platform/src/main/java/com/ycl/util/VideoUtil.java
@@ -123,7 +123,7 @@ return objectMapper.readTree(monitorReq.getBody()).get("url").textValue(); } catch (Exception ex) { System.out.println("获取视频异常:" + ex); System.out.println("获取视频异常:" + ex.getMessage()); return "获取地址失败,请检查code值"; } } @@ -135,11 +135,58 @@ private final String APP_SECRET = "LElVf9Ct3ykStZHCmFNZ"; public PageResult<Camera> callPostCameras(Integer pageNo, Integer pageSize, String treeCode) throws Exception { System.out.println("海康视频-callPostCameras"); ArtemisConfig config = new ArtemisConfig(); config.setHost(HOST); // 代理API网关nginx服务器ip端口 config.setAppKey(APP_KEY); // 秘钥appkey config.setAppSecret(APP_SECRET);// 秘钥appSecret System.out.println("海康视频-初始化config"); final String getSecurityApi = ARTEMIS_PATH + "/api/resource/v1/cameras"; // 接口路径 Map<String, String> path = new HashMap<String, String>(2) { { put("https://", getSecurityApi); } }; Map<String, String> head = new HashMap<String, String>(2) { //get请求的head参数 { put("headpost", "sky-test"); } }; JSONObject jsonBody = new JSONObject(); jsonBody.put("pageNo", pageNo); jsonBody.put("pageSize", pageSize); jsonBody.put("treeCode", treeCode); String body = jsonBody.toString(); System.out.println("海康视频开始请求:"); //参数根据接口实际情况设置 HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, null, null, "application/json", head); try { String strResult = EntityUtils.toString(result.getEntity()); HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class); System.out.println("海康视频结果:" + responseResult.toString()); if ("0".equals(responseResult.getCode())) { com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData(); String strList = jsonObject.getString("list"); Integer total = Integer.parseInt(jsonObject.getString("total")); Integer resultPageSize = Integer.parseInt(jsonObject.getString("pageSize")); Integer resultPageNo = Integer.parseInt(jsonObject.getString("pageNo")); List<Camera> ls = com.alibaba.fastjson.JSONObject.parseArray(strList, Camera.class); PageResult<Camera> pageResult = new PageResult<>(total, resultPageSize, resultPageNo, ls); return pageResult; } } catch (Exception e) { e.printStackTrace(); } return null; } public String getKHVideo(String code) throws Exception { ArtemisConfig config = new ArtemisConfig(); config.setHost(HOST); // 代理API网关nginx服务器ip端口 config.setAppKey(APP_KEY); // 秘钥appkey config.setAppSecret(APP_SECRET);// 秘钥appSecret final String getSecurityApi = ARTEMIS_PATH + "/api/resource/v1/cameras/previewURLs"; // 接口路径 Map<String, String> path = new HashMap<String, String>(2) { { put("https://", getSecurityApi); @@ -156,9 +203,10 @@ } }; JSONObject jsonBody = new JSONObject(); jsonBody.put("pageNo", pageNo); jsonBody.put("pageSize", pageSize); jsonBody.put("treeCode", treeCode); jsonBody.put("cameraIndexCode", code); jsonBody.put("streamType", 0); jsonBody.put("protocol", "hls"); jsonBody.put("transmode", 0); String body = jsonBody.toString(); //参数根据接口实际情况设置 HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, query, null, "application/json", head); @@ -167,17 +215,12 @@ HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class); if ("0".equals(responseResult.getCode())) { com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData(); String strList = jsonObject.getString("list"); Integer total = Integer.parseInt(jsonObject.getString("total")); Integer resultPageSize = Integer.parseInt(jsonObject.getString("pageSize")); Integer resultPageNo = Integer.parseInt(jsonObject.getString("pageNo")); List<Camera> ls = com.alibaba.fastjson.JSONObject.parseArray(strList, Camera.class); PageResult<Camera> pageResult = new PageResult<>(total, resultPageSize, resultPageNo, ls); return pageResult; String url = jsonObject.getString("url"); return url; } } catch (Exception e) { e.printStackTrace(); } return null; return ""; } } ycl-platform/src/main/resources/application-prod.yml
@@ -78,3 +78,11 @@ keyId: Tkf72Q1gdzETsZf6 keySecret: tRk39S6B1kSGARRdS4DF6jxr5nBYj5 bucketName: zhzfptoss #专有钉钉参数 zzding : app-key : SC_ZHZF-IC5g2YiRDW8tug1DfAfiui app-secret : 39RIHFOKd8fUeeW9T7CdBcwEqA6dMKx5d3686B6P domain-name : openplatform.dg-work.cn protocal : https tenant-id : 50645661