Commit 30d25155 authored by 赵啸非's avatar 赵啸非

添加识别计划类

parent f87f1377
......@@ -27,6 +27,7 @@ import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognBlackReq;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.hik.face.service.IHikPlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -51,6 +52,8 @@ public class SubEventStartedService implements IApplicationStartedService {
@Autowired
private IHikFaceService hikFaceService;
@Autowired
private IHikPlanService hikPlanService;
@Autowired
private FaceGroupService faceGroupService;
@Autowired
private FacePlanService facePlanService;
......@@ -58,7 +61,6 @@ public class SubEventStartedService implements IApplicationStartedService {
private DeviceService deviceService;
@Override
public void start() {
ThreadPool.getInstance().init(20);
......@@ -105,7 +107,7 @@ public class SubEventStartedService implements IApplicationStartedService {
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
FacePlanEntity facePlanEntity = facePlanService.selectOne(new FacePlanQuery().name(planBlackName));
if(ObjectUtils.isEmpty(facePlanEntity)){
if (ObjectUtils.isEmpty(facePlanEntity)) {
//初始化新增取号监控识别计划
PlanRecognBlackReq planRecognBlackReq = new PlanRecognBlackReq();
planRecognBlackReq.setName(planBlackName);
......@@ -122,6 +124,20 @@ public class SubEventStartedService implements IApplicationStartedService {
//设置识别方式
planRecognBlackReq.setRecognitionResourceType(RecognitionResourceEnum.COMPARISON.getValue());
//设置时间段 默认全天候
Rest<String> planRecognBlackAddRest = hikPlanService.planRecognBlackAdd(planRecognBlackReq);
if (planRecognBlackAddRest.getCode() == YesNoEnum.YES.getValue()) {
FacePlanEntity planEntity = new FacePlanEntity();
planEntity.initAttrValue();
planEntity.setIndexCode(planRecognBlackAddRest.getData());
planEntity.setName(planBlackName);
planEntity.setDescription(planBlackName);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
facePlanService.save(planEntity);
}
}
//创建陌生人员识别计划
......
package com.mortals.xhx.module.hik;
public class HikApiRest<T> {
private T data;
private String code;
private String msg;
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
......@@ -6,6 +6,7 @@ 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.HikApiRest;
import com.mortals.xhx.module.hik.camera.model.req.CameraListReq;
import com.mortals.xhx.module.hik.camera.model.rsp.CameraDataInfo;
import com.mortals.xhx.module.hik.camera.model.rsp.CameraInfo;
......@@ -35,9 +36,9 @@ public class HikCameraServiceImpl extends AbstractHikService implements IHikCame
log.info("camera list req=>{}", JSON.toJSONString(cameraListReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(cameraListReq), null, null, "application/json");
log.info("camera list resp=>{}", respJson);
Rest<CameraDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<CameraDataInfo>>() {
HikApiRest<CameraDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<CameraDataInfo>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
return Rest.fail(rest.getMsg());
......
......@@ -6,6 +6,7 @@ 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.HikApiRest;
import com.mortals.xhx.module.hik.door.model.req.door.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo;
import com.mortals.xhx.module.hik.door.service.IHikDoorService;
......@@ -36,9 +37,9 @@ public class HikDoorServiceImpl extends AbstractHikService implements IHikDoorSe
log.info("door events req=>{}", JSON.toJSONString(doorEventReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(doorEventReq), null, null, "application/json");
log.info("door events error resp=>{}", respJson);
Rest<DoorEventDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<DoorEventDataInfo>>() {
HikApiRest<DoorEventDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<DoorEventDataInfo>>() {
});
if(rest.getCode()==0){
if(rest.getCode()=="0"){
return Rest.ok(rest.getData());
}else{
return Rest.fail(rest.getMsg());
......
......@@ -6,6 +6,7 @@ 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.HikApiRest;
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;
......@@ -35,9 +36,9 @@ public class HikEventServiceImpl extends AbstractHikService implements IHikEvent
log.info("event sub req=>{}", JSON.toJSONString(eventSubReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(eventSubReq), null, null, "application/json");
log.info("event sub resp=>{}", respJson);
Rest<String> rest = JSON.parseObject(respJson, new TypeReference<Rest<String>>() {
HikApiRest<String> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<String>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok();
} else {
return Rest.fail(rest.getMsg());
......
......@@ -6,6 +6,7 @@ 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.HikApiRest;
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.face.ResRecognReq;
......@@ -36,9 +37,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
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>>>() {
HikApiRest<List<FaceDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<FaceDataInfo>>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>", respJson);
......@@ -59,9 +60,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
//log.info("face single add req=>{}", JSON.toJSONString(faceReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceReq), null, null, "application/json");
log.info("face single add resp=>{}", respJson);
Rest<FaceDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<FaceDataInfo>>() {
HikApiRest<FaceDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<FaceDataInfo>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
return Rest.fail(rest.getMsg());
......@@ -79,9 +80,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
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>>() {
HikApiRest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<Boolean>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>{}", respJson);
......
......@@ -6,6 +6,7 @@ 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.HikApiRest;
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;
......@@ -32,12 +33,12 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
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>>>() {
HikApiRest<List<PlanRecognBlackInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<PlanRecognBlackInfo>>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize balck list error resp=>", respJson);
log.info("plan recognize balck list error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
......@@ -73,16 +74,18 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
@Override
public Rest<String> planRecognBlackAdd(PlanRecognBlackReq planRecognBlackReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/single/addition";
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/plan/recognition/black/addition";
path.put(protocol, getCamsApi);
try {
log.info("plan recognize balck req=>{}", JSON.toJSONString(planRecognBlackReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(planRecognBlackReq), null, null, "application/json");
Rest<String> rest = JSON.parseObject(respJson, new TypeReference<Rest<String>>() {
log.info("plan recognize balck resp=>{}", respJson);
HikApiRest<String> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<String>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize balck error resp=>", respJson);
log.info("plan recognize balck error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
......@@ -98,12 +101,12 @@ public class HikPlanServiceImpl extends AbstractHikService implements IHikPlanSe
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>>() {
HikApiRest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<Boolean>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("plan recognize balck error del resp=>", respJson);
log.info("plan recognize balck error del resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
......
......@@ -6,6 +6,7 @@ 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.HikApiRest;
import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo;
......@@ -35,9 +36,9 @@ public class HikPersonServiceImpl extends AbstractHikService implements IHikPers
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(personReq), null, null, "application/json");
Rest<PersonDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<PersonDataInfo>>() {
HikApiRest<PersonDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<PersonDataInfo>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("person error resp=>{}", respJson);
......@@ -71,9 +72,9 @@ public class HikPersonServiceImpl extends AbstractHikService implements IHikPers
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(orgListReq), null, null, "application/json");
Rest<OrgDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<OrgDataInfo>>() {
HikApiRest<OrgDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<OrgDataInfo>>() {
});
if (rest.getCode() == 0) {
if (rest.getCode() == "0") {
return Rest.ok(rest.getData());
} else {
log.info("org list error resp=>{}", respJson);
......
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