Commit dd52a534 authored by 赵啸非's avatar 赵啸非

修改消费海康回调函数

parent c25fb97f
...@@ -3,6 +3,8 @@ package com.mortals.xhx.busiz.web; ...@@ -3,6 +3,8 @@ package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.common.utils.ComsumerSnapTask;
import com.mortals.xhx.module.hik.event.model.req.callback.EventReq; import com.mortals.xhx.module.hik.event.model.req.callback.EventReq;
import com.mortals.xhx.module.hik.event.service.IHikEventService; import com.mortals.xhx.module.hik.event.service.IHikEventService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -23,12 +25,14 @@ public class HikCallbackController { ...@@ -23,12 +25,14 @@ public class HikCallbackController {
@PostMapping("eventRcv") @PostMapping("eventRcv")
@UnAuth @UnAuth
public Rest<String> receivePlanMessage(@RequestBody EventReq req) { public Rest<String> receivePlanMessage(@RequestBody EventReq req) {
log.info("【接收人脸计划事件数据】【请求体】--> {}", JSON.toJSONString(req)); //log.info("【接收人脸计划事件数据】【请求体】--> {}", JSON.toJSONString(req));
// EventReq eventReq = JSON.parseObject(req, EventReq.class); // EventReq eventReq = JSON.parseObject(req, EventReq.class);
try { try {
Rest<String> rest = hikEventService.handleEvent(req); //单独线程处理
return Rest.ok(rest.getMsg()); // Rest<String> rest = hikEventService.handleEvent(req);
ComsumerSnapTask comsumerSnapTask = new ComsumerSnapTask(hikEventService,req);
ThreadPool.getInstance().execute(comsumerSnapTask);
return Rest.ok();
} catch (Exception e) { } catch (Exception e) {
log.error("接收数据失败", e); log.error("接收数据失败", e);
return Rest.fail(); return Rest.fail();
......
...@@ -9,7 +9,8 @@ import java.util.Map; ...@@ -9,7 +9,8 @@ import java.util.Map;
* @author zxfei * @author zxfei
*/ */
public enum HikAbilityEnum { public enum HikAbilityEnum {
人脸识别事件("event_face_recognition", "人脸识别事件"); 人脸识别事件("event_face_recognition", "人脸识别事件"),
人脸比对事件("event_face_match", "人脸比对事件");
private String value; private String value;
private String desc; private String desc;
......
package com.mortals.xhx.common.utils;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.HttpUtil;
import com.mortals.xhx.module.hik.event.model.req.callback.EventReq;
import com.mortals.xhx.module.hik.event.service.IHikEventService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.Map;
import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
/**
* 发通知第三方
*
* @author: zxfei
* @date: 2022/4/28 10:56
* @description:
**/
@Slf4j
@AllArgsConstructor
public class ComsumerSnapTask implements Runnable {
private IHikEventService hikEventService;
private EventReq req;
@Override
public void run() {
try {
Rest<String> rest = hikEventService.handleEvent(req);
} catch (Exception e) {
log.error("异常:", e);
}
}
}
...@@ -55,7 +55,7 @@ public class SubEventStartedService implements IApplicationStartedService { ...@@ -55,7 +55,7 @@ public class SubEventStartedService implements IApplicationStartedService {
@Override @Override
public void start() { public void start() {
ThreadPool.getInstance().init(20); ThreadPool.getInstance().init(10);
Constants.DEFAULT_TIMEOUT=12000; Constants.DEFAULT_TIMEOUT=12000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment