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

添加海康部分接口实现类

parent d27bddfe
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<profiles.sms.type>3</profiles.sms.type> <profiles.sms.type>3</profiles.sms.type>
<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>k6BVS1PEbyzcJAE4</profiles.hik.appKey> <profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<package.environment>serve</package.environment> <package.environment>serve</package.environment>
<skipUi>false</skipUi> <skipUi>false</skipUi>
......
package com.mortals.xhx.busiz.web; package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.module.hik.door.model.req.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.DoorEventDataInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/** /**
* 设备 * 设备
* *
...@@ -26,6 +34,68 @@ public class TestController { ...@@ -26,6 +34,68 @@ public class TestController {
public static void main(String[] args) { public static void main(String[] args) {
DoorEventReq doorEventReq = new DoorEventReq();
doorEventReq.setStartTime(new Date());
System.out.println(JSON.toJSONString(doorEventReq));
String json="{\"startTime\":\"2023-04-13T10:48:22+08:00\"}";
DoorEventReq doorEventReq1 = JSON.parseObject(json, DoorEventReq.class);
System.out.println(DateUtils.convertTime2Str(doorEventReq1.getStartTime().getTime(),DateUtils.P_yyyy_MM_dd_HH_mm_ss));
String respJson="{\n" +
" \"code\": \"0\",\n" +
" \"msg\": \"success\",\n" +
" \"data\": {\n" +
" \"pageSize\": 1,\n" +
" \"list\": [\n" +
" {\n" +
" \"eventId\": \"0f3ba98192f02d7f186b9eb33314ef44\",\n" +
" \"eventName\": \"acs.acs.eventType.successFace\",\n" +
" \"eventTime\": \"2023-04-12T11:59:37+08:00\",\n" +
" \"personId\": \"31757ce46e09418ca926094f58935897\",\n" +
" \"cardNo\": \"9990000008\",\n" +
" \"personName\": \"何肃桃\",\n" +
" \"orgIndexCode\": \"36553719-e462-498a-9664-cc7fdaf9c421\",\n" +
" \"orgName\": \"默认组织/宜宾市民中心/1A公安大厅/市交警支队\",\n" +
" \"doorName\": \"公安大厅1A_门_1\",\n" +
" \"doorIndexCode\": \"38419b11af544d45a664dd27db15d8f2\",\n" +
" \"doorRegionIndexCode\": \"bd1e680d-662f-45b3-a798-8bae7cd194e6\",\n" +
" \"picUri\": null,\n" +
" \"svrIndexCode\": null,\n" +
" \"eventType\": 196893,\n" +
" \"inAndOutType\": 1,\n" +
" \"readerDevIndexCode\": \"fc6bc97929bb449e9c2fa91dbd6b1d01\",\n" +
" \"readerDevName\": \"读卡器_1\",\n" +
" \"devIndexCode\": \"73f5f57cb4cd486fba06e817c7555dd8\",\n" +
" \"devName\": \"公安大厅1A\",\n" +
" \"identityCardUri\": null,\n" +
" \"receiveTime\": \"2023-04-12T11:59:39.727+08:00\",\n" +
" \"jobNo\": \"8\",\n" +
" \"studentId\": null,\n" +
" \"certNo\": \"8\"\n" +
" }\n" +
" ],\n" +
" \"total\": 3903,\n" +
" \"totalPage\": 3903,\n" +
" \"pageNo\": 1\n" +
" }\n" +
"}";
Rest<DoorEventDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<DoorEventDataInfo>>() {
});
System.out.println(rest.getData().getTotal());
System.out.println(rest.getData().getList().get(0).getPersonName());
} }
......
package com.mortals.xhx.module.hik; package com.mortals.xhx.module.hik;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractHikService { public abstract class AbstractHikService {
@Value("${hik.host:''") @Value("${hik.host:''")
...@@ -19,4 +23,15 @@ public abstract class AbstractHikService { ...@@ -19,4 +23,15 @@ public abstract class AbstractHikService {
public String ARTEMIS_PATH = "/artemis"; public String ARTEMIS_PATH = "/artemis";
protected Map<String, String> path = new HashMap<>(2);
protected ArtemisConfig getArtemisConfig() {
ArtemisConfig config = new ArtemisConfig();
config.setHost(host);
config.setAppKey(appKey); // 秘钥appkey
config.setAppSecret(appSecret);// 秘钥appSecret
return config;
}
} }
package com.mortals.xhx.module.hik.model; package com.mortals.xhx.module.hik;
import lombok.Data; import lombok.Data;
...@@ -10,19 +10,4 @@ import lombok.Data; ...@@ -10,19 +10,4 @@ import lombok.Data;
@Data @Data
public class BaseReq { public class BaseReq {
/**
* 当前页
*/
private String pageNo;
/**
* 每页大小
*/
private String pageSize;
// /**
// * http协议
// */
// private String httpProtocol="http://";
} }
package com.mortals.xhx.module.hik.door.model.req;
import com.alibaba.fastjson.annotation.JSONField;
import com.mortals.xhx.module.hik.BaseReq;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class DoorEventReq extends BaseReq implements Serializable {
/**
* 当前页
*/
private Integer pageNo;
/**
* 每页大小
*/
private Integer pageSize;
private String doorName;
private String receiveStartTime;
private String sort;
/**
* 事件类型,参考[附录D2.1 门禁事件]
* @[软件产品-综合安防管理平台-附录-附录D 事件列表-附录D2 一卡通事件-附录D2.1 门禁事件]
*/
private List<Integer> eventTypes;
private List<String> readerDevIndexCodes;
private String personName;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date doorRegionIndexCode;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date receiveEndTime;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date startTime;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date endTime;
private List<String> doorIndexCodes;
private String order;
}
package com.mortals.xhx.module.hik.door.model.rsp;
import lombok.Data;
import java.util.List;
@Data
public class DoorEventDataInfo {
private List<DoorEventInfo> list;
private Integer total;
private Integer totalPage;
private Integer pageNo;
}
package com.mortals.xhx.module.hik.door.model.rsp;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Date;
@Data
public class DoorEventInfo{
private String eventId;
private String orgName;
private String svrIndexCode;
private String doorName;
private String orgIndexCode;
private String doorIndexCode;
private int eventType;
private String devIndexCode;
private String identityCardUri;
private String readerDevName;
private String devName;
private String cardNo;
private String personName;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date receiveTime;
private String studentId;
private String readerDevIndexCode;
private String certNo;
private String doorRegionIndexCode;
private int inAndOutType;
private String picUri;
private String jobNo;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date eventTime;
private String eventName;
private String personId;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.door.service;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.door.model.req.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.DoorEventDataInfo;
/**
* 海康门禁接口对接类
*
* @author:
* @date: 2023/4/12 17:47
*/
public interface IHikDoorService {
/**
* 获取门禁事件
*
* @author:
* @date: 2023/4/13 10:24
*/
Rest<DoorEventDataInfo> getDoorEvents(DoorEventReq doorEventReq);
}
package com.mortals.xhx.module.hik.door.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.door.model.req.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.DoorEventDataInfo;
import com.mortals.xhx.module.hik.door.service.IHikDoorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 海康人员接口类
*
* @author: zxfei
* @date: 2023/4/12 17:51
*/
@Service("hikDoorService")
@Slf4j
public class HikDoorServiceImpl extends AbstractHikService implements IHikDoorService {
@Override
public Rest<DoorEventDataInfo> getDoorEvents(DoorEventReq doorEventReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/acs/v2/door/events";
Map<String, String> path = new HashMap<>(2);
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(doorEventReq), null, null, "application/json");
Rest<DoorEventDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<DoorEventDataInfo>>() {
});
if(rest.getCode()==0){
return Rest.ok(rest.getData());
}else{
log.info("door events error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("获取门禁事件异常", e);
return Rest.fail(e.getMessage());
}
}
}
package com.mortals.xhx.module.hik.face.model.req.face;
import lombok.Data;
@Data
public class FaceInfo{
private String sex;
private String name;
private String certificateNum;
private String certificateType;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.face;
import java.util.List;
import lombok.Data;
@Data
public class FaceListReq{
private String faceGroupIndexCode;
private int pageNo;
private String sex;
private String name;
private int pageSize;
private String certificateNum;
private String certificateType;
private List<String> indexCodes;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.face;
import lombok.Data;
@Data
public class FacePic{
//地址
private String faceUrl;
//base64
private String faceBinaryData;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.face;
import lombok.Data;
import java.util.List;
@Data
public class FaceReq {
private String faceGroupIndexCode;
private FaceInfo faceInfo;
private FacePic facePic;
//人脸集合id
private List<String> indexCodes;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.group;
import lombok.Data;
import java.util.List;
@Data
public class FaceGroupReq {
private String name;
private String description;
//分组标识
private List<String> indexCodes;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.plan;
import java.util.List;
import lombok.Data;
@Data
public class PlanRecognBlackListReq{
private List<String> faceGroupIndexCodes;
private String name;
private String description;
private String status;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.plan;
import java.util.List;
import lombok.Data;
@Data
public class PlanRecognBlackReq{
private List<String> cameraIndexCodes;
private List<String> faceGroupIndexCodes;
private String name;
private String description;
private List<String> recognitionResourceIndexCodes;
private String recognitionResourceType;
private int threshold;
private List<TimeBlockListItem> timeBlockList;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.plan;
import java.util.List;
import lombok.Data;
@Data
public class TimeBlockListItem{
private String dayOfWeek;
private List<TimeRangeItem> timeRange;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.plan;
import lombok.Data;
@Data
public class TimeRangeItem{
private String startTime;
private String endTime;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.rsp.face;
import com.mortals.xhx.module.hik.face.model.req.face.FaceInfo;
import com.mortals.xhx.module.hik.face.model.req.face.FacePic;
import lombok.Data;
@Data
public class FaceDataInfo {
private String faceGroupIndexCode;
private String indexCode;
private FaceInfo faceInfo;
private FacePic facePic;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.rsp.group;
import lombok.Data;
@Data
public class FaceGroupDataInfo {
private String name;
private String indexCode;
private String description;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.rsp.plan;
import java.util.List;
import lombok.Data;
@Data
public class PlanRecognBlackInfo{
private List<String> cameraIndexCodes;
private boolean available;
private String indexCode;
private String description;
private int threshold;
private String recognitionPlanType;
private int usingTime;
private List<String> faceGroupIndexCodes;
private String name;
private List<String> recognitionResourceIndexCodes;
private String recognitionResourceType;
private String startTime;
private String status;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.service;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.face.model.req.face.FaceListReq;
import com.mortals.xhx.module.hik.face.model.req.face.FaceReq;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.rsp.face.FaceDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import java.util.List;
/**
* 海康门禁接口对接类
* @author:
* @date: 2023/4/12 17:47
*/
public interface IHikFaceService {
/**
* 查询人脸
* @param faceListReq
* @return
*/
Rest<List<FaceDataInfo>> findFaceList(FaceListReq faceListReq);
/**
* 添加单个人脸
* @param faceReq
* @return
*/
Rest<FaceDataInfo> faceSingleAdd(FaceReq faceReq);
/**
* 修改单个人脸
* @param faceReq
* @return
*/
Rest<Boolean> faceSingleUpdate(FaceReq faceReq);
/**
* 删除单个人脸
* @param faceReq
* @return
*/
Rest<Boolean> faceSingleDel(FaceReq faceReq);
/**
* 查询人脸分组
* @param faceGroupReq
* @return
*/
Rest<List<FaceGroupDataInfo>> findFaceGroupList(FaceGroupReq faceGroupReq);
/**
* 添加人脸分组
* @param faceGroupReq
* @return
*/
Rest<FaceGroupDataInfo> faceGroupSingleAdd(FaceGroupReq faceGroupReq);
/**
* 删除人脸分组
* @param faceGroupReq
* @return
*/
Rest<Boolean> faceGroupSingleDel(FaceGroupReq faceGroupReq);
}
package com.mortals.xhx.module.hik.face.service;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackListReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackReq;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo;
import java.util.List;
/**
* 海康门禁接口对接类
* @author:
* @date: 2023/4/12 17:47
*/
public interface IHikPlanService {
/**
* 查询重点识别计划
* @param planRecognBlackListReq
* @return
*/
Rest<List<PlanRecognBlackInfo>> findPlanRecognBlackList(PlanRecognBlackListReq planRecognBlackListReq);
/**
* 人员监视计划
* @param planRecognBlackReq
* @return
*/
Rest<String> planRecognBlackAdd(PlanRecognBlackReq planRecognBlackReq);
/**
* 人员监视计划删除
* @param planRecognBlackReq
* @return
*/
Rest<Boolean> planRecognBlackDel(PlanRecognBlackReq planRecognBlackReq);
}
package com.mortals.xhx.module.hik.face.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.face.model.req.face.FaceListReq;
import com.mortals.xhx.module.hik.face.model.req.face.FaceReq;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.rsp.face.FaceDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 海康人员接口类
*
* @author: zxfei
* @date: 2023/4/12 17:51
*/
@Service("hikFaceService")
@Slf4j
public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceService {
@Override
public Rest<List<FaceDataInfo>> findFaceList(FaceListReq faceListReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceListReq), null, null, "application/json");
Rest<List<FaceDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<FaceDataInfo>>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("face add error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<FaceDataInfo> faceSingleAdd(FaceReq faceReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/single/addition";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceReq), null, null, "application/json");
Rest<FaceDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<FaceDataInfo>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("face add error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<Boolean> faceSingleUpdate(FaceReq faceReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/single/update";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceReq), null, null, "application/json");
Rest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<Rest<Boolean>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("face add error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<Boolean> faceSingleDel(FaceReq faceReq) {
return null;
}
@Override
public Rest<List<FaceGroupDataInfo>> findFaceGroupList(FaceGroupReq faceGroupReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/group";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
Rest<List<FaceGroupDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<FaceGroupDataInfo>>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("face group list error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("face group list error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<FaceGroupDataInfo> faceGroupSingleAdd(FaceGroupReq faceGroupReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/single/addition";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
Rest<FaceGroupDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<FaceGroupDataInfo>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("face add error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<Boolean> faceGroupSingleDel(FaceGroupReq faceGroupReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/single/update";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
Rest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<Rest<Boolean>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("face add error异常", e);
return Rest.fail(e.getMessage());
}
}
}
package com.mortals.xhx.module.hik.face.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.face.model.req.plan.PlanRecognBlackListReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackReq;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognBlackInfo;
import com.mortals.xhx.module.hik.face.service.IHikPlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 海康人员接口类
*
* @author: zxfei
* @date: 2023/4/12 17:51
*/
@Service("hikPlanService")
@Slf4j
public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanService {
@Override
public Rest<List<PlanRecognBlackInfo>> findPlanRecognBlackList(PlanRecognBlackListReq planRecognBlackListReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognBlackListReq), null, null, "application/json");
Rest<List<PlanRecognBlackInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<PlanRecognBlackInfo>>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize balck list error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("plan recognize balck list error异常", e);
return Rest.fail(e.getMessage());
}
}
/**
* a)该接口可以新增一条重点人员识别计划,以实现将若干抓拍点抓拍到的人脸,
* 通过若干识别资源同若干分组内的人脸比较,并将命中结果以事件形式上报。
* b)配置一条识别计划需要人脸分组集合(通过”按条件查询人脸分组”接口获取)
* ,抓拍点集合(通过LDAP服务获取监控点,并通过型号确定抓拍点),
* 识别资源集合(通过”按条件查询识别资源”接口获取)。
* c)一条重点人员识别计划只能配置一种识别资源类别:深眸或脸谱或超脑。
* d)一条重点人员识别计划,可以配置多个超脑作为识别资源或一个脸谱作为识别资源。
* e)一条重点人员识别计划如果配置深眸作为识别资源,则recognitionResourceIndexCodes可以传空
* 。因为深眸的抓拍点就是识别资源本身,人脸监控应用服务会根据抓拍点自动匹配正确的识别资源。
* f)人脸监控应用服务会校验抓拍点的有效性。校验规则如下:超脑作为识别资源时,
* 抓拍点必须是超脑的通道;脸谱作为识别资源时,脸谱作为识别资源时,抓拍点一般为深眸或其他人脸抓拍机通道;
* 深眸作为识别资源时,抓拍点必须是深眸的通道;一个通道是否是深眸/超脑/抓拍机的通道,取决于通道所属设备的型号,
* 详见详见附录I 人脸监控应用服务支持设备型号列表。
* g)重点人员识别计划配置有以下限制,这些限制会在添加时作为特殊错误返回:超脑的一个通道只能配置一次重点人员识别计划;
* 同一个抓拍点不能同时配置在多个脸谱上;抓拍点或识别资源没有同步到IAC前,无法配置识别计划。
* h)识别计划的配置为异步过程,调用接口成功后,人脸监控应用服务会在后台自动下发人脸分组并执行布控操作,
* 可以通过接口”单个查询重点人员识别计划详情”查询该识别计划的下发结果。 i) 识别计划支持配置时间计划模板,
* 当时间计划参数不传时,默认全天候。当传入此参数时,时间计划规则如下:按周计划进行配置,每一天的时间段上限为8,每一个时间段的开始时间必须小于结束时间。
* j)同一个深眸支持配置多个识别计划。
* k)若设备上人脸分组达到上限,则有可能导致下发失败。
* @param planRecognBlackReq
* @return
*/
@Override
public Rest<String> planRecognBlackAdd(PlanRecognBlackReq planRecognBlackReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/single/addition";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognBlackReq), null, null, "application/json");
Rest<String> rest = JSON.parseObject(respJson, new TypeReference<Rest<String>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize balck error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("plan recognize balck add error异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<Boolean> planRecognBlackDel(PlanRecognBlackReq planRecognBlackReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black/deletion";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognBlackReq), null, null, "application/json");
Rest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<Rest<Boolean>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize balck error del resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("plan recognize balck del error异常", e);
return Rest.fail(e.getMessage());
}
}
}
package com.mortals.xhx.module.hik.model.person.req; package com.mortals.xhx.module.hik.person.model.req;
import com.mortals.xhx.module.hik.model.BaseReq; import com.mortals.xhx.module.hik.BaseReq;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
......
package com.mortals.xhx.module.hik.person.model.rsp;
import lombok.Data;
import java.util.List;
@Data
public class PersonDataInfo {
private List<PersonInfo> list;
private Integer total;
private Integer totalPage;
private Integer pageNo;
}
package com.mortals.xhx.module.hik.person.model.rsp;
import lombok.Data;
@Data
public class PersonInfo{
private int gender;
private String orgPath;
private String orgPathName;
private String orgIndexCode;
private String updateTime;
private String certificateNo;
private String phoneNo;
private String personName;
private PersonPhoto personPhoto;
private String createTime;
private String jobNo;
private String personId;
private int certificateType;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.person.model.rsp;
import lombok.Data;
@Data
public class PersonPhoto{
private String personPhotoIndexCode;
private String picUri;
private String personId;
private String serverIndexCode;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.service; package com.mortals.xhx.module.hik.person.model.service;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.model.person.req.PersonReq; import com.mortals.xhx.module.hik.person.model.req.PersonReq;
import com.mortals.xhx.module.hik.person.model.rsp.PersonDataInfo;
/** /**
* 海康人员接口对接类 * 海康人员接口对接类
...@@ -12,9 +13,9 @@ import com.mortals.xhx.module.hik.model.person.req.PersonReq; ...@@ -12,9 +13,9 @@ import com.mortals.xhx.module.hik.model.person.req.PersonReq;
public interface IHikPersonService { public interface IHikPersonService {
/** /**
* 请求人员接口 * 获取人员接口
* @param personReq * @param personReq
* @return * @return
*/ */
Rest<String> callPostApiGetPersonList(PersonReq personReq); Rest<PersonDataInfo> getPersonList(PersonReq personReq);
} }
package com.mortals.xhx.module.hik.service.impl; package com.mortals.xhx.module.hik.person.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.hikvision.artemis.sdk.ArtemisHttpUtil; import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig; import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.AbstractHikService; import com.mortals.xhx.module.hik.AbstractHikService;
import com.mortals.xhx.module.hik.model.person.req.PersonReq; import com.mortals.xhx.module.hik.person.model.req.PersonReq;
import com.mortals.xhx.module.hik.service.IHikPersonService; import com.mortals.xhx.module.hik.person.model.rsp.PersonDataInfo;
import com.mortals.xhx.module.hik.person.model.service.IHikPersonService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
...@@ -25,22 +26,22 @@ import java.util.Map; ...@@ -25,22 +26,22 @@ import java.util.Map;
public class HikPersonServiceImpl extends AbstractHikService implements IHikPersonService { public class HikPersonServiceImpl extends AbstractHikService implements IHikPersonService {
@Override @Override
public Rest<String> callPostApiGetPersonList(PersonReq personReq) { public Rest<PersonDataInfo> getPersonList(PersonReq personReq) {
ArtemisConfig config = getArtemisConfig();
ArtemisConfig config = new ArtemisConfig();
config.setHost(super.host);
config.setAppKey(appKey); // 秘钥appkey
config.setAppSecret(appSecret);// 秘钥appSecret
String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList"; String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList";
Map<String, String> path = new HashMap<String, String>(2) { Map<String, String> path = new HashMap<>(2);
{ path.put(protocol, getCamsApi);
put(protocol, getCamsApi);
}
};
try { try {
String resp = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(personReq), null, null, "application/json"); String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(personReq), null, null, "application/json");
log.info("person resp=>", resp);
return Rest.ok(resp); Rest<PersonDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<PersonDataInfo>>() {
});
if(rest.getCode()==0){
return Rest.ok(rest.getData());
}else{
log.info("person error resp=>", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) { } catch (Exception e) {
log.error("获取人员异常", e); log.error("获取人员异常", e);
return Rest.fail(e.getMessage()); return Rest.fail(e.getMessage());
......
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