Commit 08d09e6a authored by 赵啸非's avatar 赵啸非

添加海康回调实现类

parent 6fc8965b
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host> <profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.appKey>25128371</profiles.hik.appKey> <profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.hik.callback>http://8.136.255.30:11080/refined/hik/eventRcv</profiles.hik.callback>
<package.environment>serve</package.environment> <package.environment>serve</package.environment>
<skipUi>false</skipUi> <skipUi>false</skipUi>
</properties> </properties>
......
package com.mortals.xhx.busiz.req.event;
import java.util.List;
import lombok.Data;
@Data
public class EventData{
private FaceRecognitionResult faceRecognitionResult;
private String srcEventId;
private List<ResInfoItem> resInfo;
}
\ No newline at end of file
package com.mortals.xhx.busiz.req.event;
import lombok.Data;
@Data
public class EventRecognBlackInfo{
private String method;
private Params params;
}
\ No newline at end of file
package com.mortals.xhx.busiz.req.event;
import lombok.Data;
@Data
public class EventsItem {
private String eventId;
private EventData data;
private int eventType;
private String srcIndex;
private String ability;
private String srcType;
private int timeout;
private String happenTime;
private int status;
}
\ No newline at end of file
package com.mortals.xhx.busiz.req.event;
import lombok.Data;
@Data
public class FaceMatchItem{
private String faceGroupName;
private String faceInfoSex;
private double similarity;
private String facePicUrl;
private String certificate;
private String faceGroupCode;
private String faceInfoCode;
private String faceInfoName;
private String certificateType;
}
\ No newline at end of file
package com.mortals.xhx.busiz.req.event;
import java.util.List;
import lombok.Data;
@Data
public class FaceRecognitionResult{
private List<FaceMatchItem> faceMatch;
private Snap snap;
}
\ No newline at end of file
package com.mortals.xhx.busiz.req.event;
import java.util.List;
import lombok.Data;
@Data
public class Params{
private String ability;
private List<EventsItem> events;
private String sendTime;
}
\ No newline at end of file
package com.mortals.xhx.busiz.req.event;
import lombok.Data;
@Data
public class ResInfoItem{
private String indexCode;
private String cn;
private String resourceType;
}
\ No newline at end of file
package com.mortals.xhx.busiz.req.event;
import lombok.Data;
@Data
public class Snap{
private String faceUrl;
private String faceTime;
private String glass;
private String gender;
private String ageGroup;
private String bkgUrl;
}
\ No newline at end of file
package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.busiz.req.event.EventRecognBlackInfo;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
@RequestMapping("hik")
public class HikCallbackController {
@PostMapping("eventRcv")
@UnAuth
public Rest<String> refreshMessage(@RequestBody EventRecognBlackInfo req) {
log.info("【接收事件数据】【请求体】--> " + JSONObject.toJSONString(req));
try {
//todo
} catch (Exception e) {
log.error("接收数据失败", e);
return Rest.fail();
}
return Rest.ok();
}
}
package com.mortals.xhx.module.hik.event.model.req;
import java.util.List;
import lombok.Data;
@Data
public class EventSubReq{
private String eventDest;
private int subType;
private List<Integer> eventLvl;
private List<Integer> eventTypes;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.rsp;
import java.util.List;
import lombok.Data;
@Data
public class EventInfo{
private String eventDest;
private List<Integer> eventTypes;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.service;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.event.model.req.EventSubReq;
import com.mortals.xhx.module.hik.event.model.rsp.EventInfo;
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo;
import java.util.List;
/**
* 海康事件接口对接类
*
* @author:
* @date: 2023/4/12 17:47
*/
public interface IHikEventService {
/**
* 订阅事件
*
* @param eventSubReq
* @return
*/
Rest<String> subEvent(EventSubReq eventSubReq);
/**
* 获取当前合作方订阅的事件
* @return
*/
Rest<List<EventInfo>> getEvents();
/**
* 取消订阅事件
*
* @param eventSubReq
* @return
*/
Rest<String> cancelEvent(EventSubReq eventSubReq);
}
package com.mortals.xhx.module.hik.event.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.AbstractHikService;
import com.mortals.xhx.module.hik.event.model.req.EventSubReq;
import com.mortals.xhx.module.hik.event.model.rsp.EventInfo;
import com.mortals.xhx.module.hik.event.service.IHikEventService;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 海康人员接口类
*
* @author: zxfei
* @date: 2023/4/12 17:51
*/
@Service("hikEventService")
@Slf4j
public class HikEventServiceImpl extends AbstractHikService implements IHikEventService {
@Override
public Rest<String> subEvent(EventSubReq eventSubReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventSubscriptionByEventTypes";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(eventSubReq), null, null, "application/json");
Rest<String> rest = JSON.parseObject(respJson, new TypeReference<Rest<String>>() {
});
if (rest.getCode() == 0) {
return Rest.ok();
} else {
log.info("event sub error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("event sub error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<List<EventInfo>> getEvents() {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventSubscriptionView";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, "", null, null, "application/json");
Rest<List<EventInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<EventInfo>>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("sub event list error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("event list error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<String> cancelEvent(EventSubReq eventSubReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventUnSubscriptionByEventTypes";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(eventSubReq), null, null, "application/json");
Rest<String> rest = JSON.parseObject(respJson, new TypeReference<Rest<String>>() {
});
if (rest.getCode() == 0) {
return Rest.ok();
} else {
log.info("event cancel error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("event cancel error异常", e);
return Rest.fail(e.getMessage());
}
}
}
...@@ -56,6 +56,7 @@ hystrix: ...@@ -56,6 +56,7 @@ hystrix:
isolation: isolation:
thread: thread:
timeoutInMilliseconds: 60000 timeoutInMilliseconds: 60000
sms: sms:
smsSendUrl: @profiles.sms.smsSendUrl@ smsSendUrl: @profiles.sms.smsSendUrl@
apiId: @profiles.sms.apiId@ apiId: @profiles.sms.apiId@
...@@ -64,3 +65,4 @@ hik: ...@@ -64,3 +65,4 @@ hik:
host: @profiles.hik.host@ host: @profiles.hik.host@
appKey: @profiles.hik.appKey@ appKey: @profiles.hik.appKey@
appSecret: @profiles.hik.appSecret@ appSecret: @profiles.hik.appSecret@
callback: @profiles.hik.callback@
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