skjcmanager/skjcmanager-auth/src/main/java/cn/gistack/auth/endpoint/BladeTokenEndPoint.java
@@ -103,7 +103,11 @@ @SneakyThrows @GetMapping("/oauth/tokenLoginUI") public void tokenLoginUI(HttpServletResponse response, String code) { response.sendRedirect(oauthProperties.getRedirectWebUri() + "?code=" + code); if (StringUtil.isBlank(code)) { response.sendRedirect(oauthProperties.getRedirectExitUri()); } else { response.sendRedirect(oauthProperties.getRedirectWebUri() + "?code=" + code); } } @GetMapping("/oauth/tokenLogin") skjcmanager/skjcmanager-auth/src/main/java/cn/gistack/auth/props/OAuthProperties.java
@@ -33,4 +33,6 @@ private String redirectWebUri; private String redirectExitUri; } skjcmanager/skjcmanager-auth/src/main/resources/application-dev.yml
@@ -26,3 +26,4 @@ profile-url: ${oauth.config.server-url-prefix}/api-auth/inspur/cas/oauth2.0/profile redirect-uri: http://10.10.3.99:32182/api/blade-auth/oauth/tokenLoginUI redirect-web-uri: http://192.168.1.198:1888/business/#/tokenlogin redirect-exit-uri: http://10.10.3.99:32182/#/index skjcmanager/skjcmanager-auth/src/main/resources/application-prod.yml
@@ -26,3 +26,4 @@ profile-url: ${oauth.config.server-url-prefix}/api-auth/inspur/cas/oauth2.0/profile redirect-uri: http://10.10.3.99:32182/api/blade-auth/oauth/tokenLoginUI redirect-web-uri: http://10.10.3.99:32182/#/tokenlogin redirect-exit-uri: http://10.10.3.99:32182/#/index skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/constant/HkConstant.java
@@ -120,6 +120,21 @@ */ public static final String presetsDeletionURLs = "/api/video/v1/presets/deletion"; /** * 按事件类型订阅事件 */ public static final String eventSubscriptionByEventTypesURLs = "/api/eventService/v1/eventSubscriptionByEventTypes"; /** * 按事件类型取消订阅 */ public static final String eventUnSubscriptionByEventTypesURLs = "/api/eventService/v1/eventUnSubscriptionByEventTypes"; /** * 查询事件订阅信息 */ public static final String eventSubscriptionViewURLs = "/api/eventService/v1/eventSubscriptionView"; skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/controller/HkEventController.java
New file @@ -0,0 +1,101 @@ package cn.gistack.sm.hk.controller; import cn.gistack.sm.hk.constant.HkConstant; import cn.gistack.sm.hk.constant.ProtocolConstant; import cn.gistack.sm.hk.service.HkService; import cn.gistack.sm.hk.vo.EventVO; import cn.gistack.sm.hk.vo.HkVO; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; import static cn.gistack.sm.hk.util.GetCameraUtils.*; /** * @author zhongrj * @Description: 海康视频事件管理 * @date 2023-08-10 */ @Slf4j @Api(tags = "海康视频事件") @RestController @RequestMapping("/hk/hkEvent") @AllArgsConstructor public class HkEventController { private final HkService hkService; /** * 海康视频事件订阅 * @param eventVO 订阅参数 * @return */ @GetMapping(value = "/eventSubscriptionByEventTypes") public R eventSubscriptionByEventTypes(EventVO eventVO) { String result = addEventSubscriptionByEventTypes(eventVO, HkConstant.eventSubscriptionByEventTypesURLs); JSONObject jsonObject1 = JSONObject.parseObject(result); // 查询海康设备列表并返回 return R.data(jsonObject1); } /** * 海康视频事件取消订阅 * @param eventVO 订阅参数 * @return */ @GetMapping(value = "/eventUnSubscriptionByEventTypes") public R eventUnSubscriptionByEventTypes(EventVO eventVO) { String result = removeEventSubscriptionByEventTypes(eventVO, HkConstant.eventUnSubscriptionByEventTypesURLs); JSONObject jsonObject1 = JSONObject.parseObject(result); // 查询海康设备列表并返回 return R.data(jsonObject1); } /** * 查询事件订阅信息 * @param eventVO 订阅参数 * @return */ @GetMapping(value = "/eventSubscriptionView") public R eventSubscriptionView(EventVO eventVO) { String result = getEventSubscriptionView(eventVO, HkConstant.eventSubscriptionViewURLs); JSONObject jsonObject1 = JSONObject.parseObject(result); // 查询海康设备列表并返回 return R.data(jsonObject1); } /** * 事件回调事件 * @param data 回调数据 * @return */ @PostMapping(value = "/eventRcv") public String eventRcv(@RequestBody String data) { Date date = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //格式化输出json JSONObject jsonObject = JSON.parseObject(data); String prettyData = JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue); System.out.println(simpleDateFormat.format(date) + "收到数据:" + System.lineSeparator() + prettyData); JSONObject jsonBody = new JSONObject(); jsonBody.put("code", "200"); jsonBody.put("msg", "ok"); jsonBody.put("data", null); return jsonBody.toJSONString(); } } skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/util/GetCameraUtils.java
@@ -2,6 +2,7 @@ import cn.gistack.sm.hk.constant.HkConstant; import cn.gistack.sm.hk.constant.ProtocolConstant; import cn.gistack.sm.hk.vo.EventVO; import cn.gistack.sm.hk.vo.HkVO; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -10,10 +11,7 @@ import com.hikvision.artemis.sdk.config.ArtemisConfig; import org.springblade.core.tool.api.R; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; import static cn.gistack.sm.hk.constant.HkConstant.ARTEMIS_PATH; import static cn.gistack.sm.hk.util.GetCameraUtils.GetCameraPreviewURL; @@ -247,10 +245,29 @@ return common(type,url,body); } /** * 抓图 * * @param url 监控资源url * @return */ public static String manualCaptureUrls(Integer type,String url,String cameraIndexCode) { /** * 组装请求参数 */ JSONObject jsonBody = new JSONObject(); jsonBody.put("cameraIndexCode", cameraIndexCode); String body = jsonBody.toJSONString(); /** * 调用接口并返回数据 * post请求application/json类型参数; */ return common(type,url, body); } /** * 获取监控点资源分页数据 * * @param url 监控资源url * @return */ @@ -271,24 +288,73 @@ } /** * 抓图 * * @param url 监控资源url * 海康视频事件订阅 * @param eventVO * @param url * @return */ public static String manualCaptureUrls(Integer type,String url,String cameraIndexCode) { public static String addEventSubscriptionByEventTypes(EventVO eventVO, String url) { /** * 组装请求参数 */ JSONObject jsonBody = new JSONObject(); jsonBody.put("cameraIndexCode", cameraIndexCode); jsonBody.put("eventTypes", Arrays.stream(eventVO.getEventTypes().split(",")).mapToInt(Integer::parseInt).toArray()); jsonBody.put("eventDest", eventVO.getEventDest()); if (null!=eventVO.getSubType()){ jsonBody.put("subType", eventVO.getSubType()); } if (null!=eventVO.getEventLvl()){ jsonBody.put("eventLvl", Arrays.stream(eventVO.getEventLvl().split(",")).mapToInt(Integer::parseInt).toArray()); } String body = jsonBody.toJSONString(); /** * 调用接口并返回数据 * post请求application/json类型参数; */ return common(type,url, body); return common(null==eventVO.getType()?1:eventVO.getType(),url, body); } /** * 海康视频事件取消订阅 * @param eventVO * @param url * @return */ public static String removeEventSubscriptionByEventTypes(EventVO eventVO, String url) { int[] eventTypes = Arrays.stream(eventVO.getEventTypes().split(",")).mapToInt(Integer::parseInt).toArray(); /** * 组装请求参数 */ JSONObject jsonBody = new JSONObject(); jsonBody.put("eventTypes", eventTypes); String body = jsonBody.toJSONString(); /** * 调用接口并返回数据 * post请求application/json类型参数; */ return common(null==eventVO.getType()?1:eventVO.getType(),url, body); } /** * 查询事件订阅信息 * @param eventVO * @param url * @return */ public static String getEventSubscriptionView(EventVO eventVO, String url) { /** * 组装请求参数 */ JSONObject jsonBody = new JSONObject(); String body = jsonBody.toJSONString(); /** * 调用接口并返回数据 * post请求application/json类型参数; */ return common(null==eventVO.getType()?1:eventVO.getType(),url, body); } // public static void main(String[] args) { skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/vo/EventVO.java
New file @@ -0,0 +1,37 @@ package cn.gistack.sm.hk.vo; import lombok.Data; import java.io.Serializable; @Data public class EventVO implements Serializable { /** * 类型(新站,老站) */ private Integer type; /** * 事件类型 区域入侵:131588,徘徊侦测:131590 视频丢失:131329 */ private String eventTypes; /** * 指定事件接收的地址,采用restful回调模式,支持http和https,样式如下:http://ip:port/eventRcv或者 * https://ip:port/eventRcv */ private String eventDest; /** * 订阅类型,0-订阅原始事件,1-联动事件,2-原始事件和联动事件,不填使用默认值0 */ private Integer subType; /** * 事件等级,0-未配置,1-低,2-中,3-高 */ private String eventLvl; }