Commit 02e0023c authored by 赵啸非's avatar 赵啸非

添加服务追踪

parent bacf56e3
package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.busiz.handler.BaseReqHandler;
import com.mortals.xhx.busiz.rsp.ApiResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.util.ObjectUtils;
import javax.annotation.PostConstruct;
import java.util.Map;
@Slf4j
public class BaseAbstractApiController {
private Map<String, BaseReqHandler> handlers;
@Autowired
private ApplicationContext context;
@SuppressWarnings("unchecked")
protected <T, K> ApiResp<K> handle(T apiReq, String handleName) {
BaseReqHandler reqHandler = handlers.get(handleName);
if (!ObjectUtils.isEmpty(reqHandler)) {
return reqHandler.process(apiReq);
} else {
log.warn(String.format("没有找到业务处理类 handleName:%s", handleName));
return null;
}
}
protected String getTransmissionAction(String transmissionReq) {
return JSON.parseObject(transmissionReq).getJSONObject("transmission").getString("action");
}
@PostConstruct
private void init() {
handlers = context.getBeansOfType(BaseReqHandler.class);
}
}
package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.event.model.req.callback.EventReq;
import com.mortals.xhx.module.hik.event.service.IHikEventService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -18,18 +20,15 @@ public class HikCallbackController {
@Autowired
private IHikEventService hikEventService;
@PostMapping("eventRcv")
@PostMapping("eventPlanRcv")
@UnAuth
public Rest<String> refreshMessage(@RequestBody String req) {
log.info("【接收事件数据】【请求体】--> {}", req);
public Rest<String> receivePlanMessage(@RequestBody EventReq req) {
log.info("【接收人脸计划事件数据】【请求体】--> {}", JSON.toJSONString(req));
// EventReq eventReq = JSON.parseObject(req, EventReq.class);
try {
/* if ("OnEventNotify".equals(req.getMethod())) {
Rest<String> rest = hikEventService.handleEvent(req);
return rest;
}*/
return Rest.ok(rest.getMsg());
return Rest.ok("接收成功");
//todo
} catch (Exception e) {
log.error("接收数据失败", e);
return Rest.fail();
......
......@@ -3,17 +3,18 @@ package com.mortals.xhx.module.hik.event.model.req.callback;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.event.model.req.callback.recognition.EventData;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import java.util.Date;
@Data
public class EventsItem<T> {
public class EventsItem {
//事件唯一标识
private String eventId;
//事件数据
private T data;
private EventData data;
//事件类型
private Integer eventType;
//事件源编号,物理设备是资源编号
......
......@@ -2,6 +2,7 @@ package com.mortals.xhx.module.hik.event.model.req.callback.recognition;
import java.util.List;
import com.mortals.xhx.module.hik.event.model.req.callback.snap.CaptureLibResultItem;
import lombok.Data;
@Data
......@@ -18,4 +19,22 @@ public class EventData {
* 触发重点人员识别事件的报警的抓拍点的信息
*/
private List<ResInfoItem> resInfo;
private int portNo;
/**
* 事件类别
*/
private String dataType;
/**
* 事件来源的地址,人脸抓拍的事件来源为抓拍机的地址。
*/
private String ipAddress;
/**
* 抓拍结果
*/
private List<CaptureLibResultItem> captureLibResult;
/**
* 抓拍这张图片的监控点的通道号
*/
private int channelID;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class Age{
private String ageGroup;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import java.util.List;
import lombok.Data;
@Data
public class CaptureLibResultItem{
private TargetAttrs targetAttrs;
private List<FacesItem> faces;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class FaceRect{
private double width;
private double X;
private double Y;
private double height;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class FaceScore{
private String enable;
private int type;
private int totalScore;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class FacesItem{
private Glass glass;
private Gender gender;
private FaceRect faceRect;
private FaceScore faceScore;
private String uRL;
private Age age;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class Gender{
private String value;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class Glass{
private String value;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class Rect{
private double width;
private double X;
private double Y;
private double height;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import java.util.List;
import lombok.Data;
@Data
public class SnapData{
private int portNo;
private String dataType;
private String ipAddress;
private List<CaptureLibResultItem> captureLibResult;
private int channelID;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback.snap;
import lombok.Data;
@Data
public class TargetAttrs{
private String faceTime;
private Rect rect;
private String deviceIndexCode;
private String picServerIndexCode;
private String cameraIndexCode;
private String bkgUrl;
}
\ No newline at end of file
......@@ -74,6 +74,7 @@ public class BlackPlanRecoginze extends EventTypeAbstract {
return HikEventTypeEnum.重点人员识别事件.getValue();
}
@Override
public void saveEventData(EventsItem event) {
log.info("预约人员识别事件,eventId:{}", event.getEventId());
......
......@@ -3,12 +3,13 @@ package com.mortals.xhx.module.hik.event.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.xhx.common.code.HikEventTypeEnum;
import com.mortals.xhx.module.hik.event.model.req.callback.EventsItem;
import org.apache.poi.ss.formula.functions.T;
/**
* @author:
* @date: 2023/4/17 9:22
*/
public abstract class EventTypeAbstract {
public abstract class EventTypeAbstract{
private int type;
abstract int getType();
......
......@@ -113,6 +113,7 @@ public class HikEventServiceImpl extends AbstractHikService implements IHikEvent
if (HikAbilityEnum.人脸识别事件.getValue().equals(params.getAbility())) {
for (EventsItem event : params.getEvents()) {
EventTypeAbstract eventTypeAbstract = EventTypeAbstract.newType(event.getEventType());
eventTypeAbstract.saveEventData(event);
// assessmentAbstract.initBidData(projectEntity, entity, supplierEntities);
......
......@@ -37,7 +37,7 @@ public class StrangerRecoginze extends EventTypeAbstract {
@Override
public void saveEventData(EventsItem event) {
log.info("处理陌生人事件,eventId:{}",event.getEventId());
log.info("处理陌生人事件,eventId:{}", event.getEventId());
EventData eventData = event.getData();
//识别结果
FaceRecognitionResult faceRecognitionResult = eventData.getFaceRecognitionResult();
......
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