Commit 59f8655d authored by 赵啸非's avatar 赵啸非

添加服务追踪

parent 62b44130
INSERT INTO `mortals_xhx_param` VALUES (null, '注册人员来源', 'Person', 'source', '3', '海康考勤系统', 1, 4, 0, 'source', NULL, NULL, NULL);
......@@ -251,23 +251,25 @@ CREATE TABLE mortals_xhx_person(
`siteId` bigint(20) COMMENT '站点Id',
`siteName` varchar(256) COMMENT '站点名称',
`name` varchar(128) COMMENT '用户名称',
`idCard` varchar(18) COMMENT '身份证号码',
`gender` tinyint(2) NOT NULL DEFAULT '0' COMMENT '性别(0.男,1.女)',
`idCard` varchar(32) COMMENT '身份证号码',
`gender` tinyint(2) DEFAULT '0' COMMENT '性别(0.男,1.女)',
`phone` varchar(20) COMMENT '手机号码',
`birthday` datetime NOT NULL COMMENT '出生日期',
`address` varchar(256) NOT NULL COMMENT '家庭住址',
`photo` varchar(128) NOT NULL COMMENT '本地照片路径',
`birthday` datetime COMMENT '出生日期',
`address` varchar(256) COMMENT '家庭住址',
`photo` varchar(128) COMMENT '本地照片路径',
`sourcePhotoUri` varchar(128) COMMENT '原始照片路径',
`sourceId` bigint(20) COMMENT 'Php原始注册用户id',
`remark` varchar(256) COMMENT '备注',
`source` tinyint(2) COMMENT '注册人员来源(0.预约系统,1.排队叫号系统,2.自助服务系统,99.其它)',
`inFaceHk` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否添加到海康人脸库(0.否,1.是)',
`source` tinyint(2) DEFAULT '0' COMMENT '注册人员来源(0.预约系统,1.排队叫号系统,2.自助服务系统,3.海康,99.其它)',
`inFaceHk` tinyint(2) DEFAULT '0' COMMENT '是否添加到海康人脸库(0.否,1.是)',
`indexCode` varchar(256) COMMENT '人脸的唯一标识',
`ifaceGroupIndexCode` varchar(256) COMMENT '人脸所属的人脸分组的唯一标识',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间',
`picUrl` varchar(256) COMMENT '海康人脸图片url',
`serverIndexCode` varchar(256) COMMENT '海康人脸服务标识',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='注册人员';
......
......@@ -38,9 +38,10 @@
<profiles.hik.protocol>http://</profiles.hik.protocol>
<profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.hik.callback>http://8.136.255.30:11080/refined/hik/eventRcv</profiles.hik.callback>
<profiles.hik.callback>http://10.12.185.213:11080/refined/hik/eventRcv</profiles.hik.callback>
<package.environment>serve</package.environment>
<skipUi>false</skipUi>
<showSql>true</showSql>
</properties>
</profile>
<profile>
......
......@@ -5,11 +5,13 @@ 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.face.service.FacePlanService;
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;
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.PlanRecognInfo;
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;
......@@ -40,6 +42,9 @@ public class TestController {
private IHikDoorService hikDoorService;
@Autowired
private IHikEventService hikEventService;
@Autowired
private FacePlanService facePlanService;
@GetMapping("webservice")
......@@ -72,6 +77,13 @@ public class TestController {
}
@PostMapping("addStrangePlan")
public String addStrangePlan() {
Rest<List<PlanRecognInfo>> strangerPlanByDay = facePlanService.createStrangerPlanByDay();
return JSON.toJSONString(strangerPlanByDay);
}
public static void main(String[] args) {
......
......@@ -9,7 +9,7 @@ import java.util.Map;
* @author zxfei
*/
public enum RecognitionResourceEnum {
SUPER_BRAIN("BLACK_LIST", "超脑"),
SUPER_BRAIN("SUPER_BRAIN", "超脑"),
FACE_RECOGNITION_SERVER("FACE_RECOGNITION_SERVER", "脸谱"),
COMPARISON("COMPARISON", "深眸");
private String value;
......
......@@ -12,6 +12,7 @@ public enum SourceEnum {
预约系统(0, "预约系统"),
排队叫号系统(1, "排队叫号系统"),
自助服务系统(2, "自助服务系统"),
海康系统(3, "海康"),
其它(99, "其它");
private Integer value;
private String desc;
......
package com.mortals.xhx.common.utils;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
......@@ -127,13 +128,13 @@ public class ArtemisPostTest {
*/
public static String callPostImgs() throws Exception {
ArtemisConfig config = new ArtemisConfig();
config.setHost("127.0.0.1"); // 代理API网关nginx服务器ip端口
config.setAppKey("20469790"); // 秘钥appkey
config.setAppSecret("lofnD6DbnBllHmk5YOyx");// 秘钥appSecret
config.setHost("8.136.255.30:8001"); // 代理API网关nginx服务器ip端口
config.setAppKey("25128371"); // 秘钥appkey
config.setAppSecret("2m9RcPJOKq5j2QPQM4v5");// 秘钥appSecret
final String getSecurityApi = "/artemis" + "/api/visitor/v1/record/pictures"; // 接口路径
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", getSecurityApi);
put("http://", getSecurityApi);
}
};
Map<String, String> head = new HashMap<String, String>(2) { //get请求的head参数
......@@ -147,11 +148,11 @@ public class ArtemisPostTest {
}
};
JSONObject jsonBody = new JSONObject();
jsonBody.put("svrIndexCode", "9ff58bc2-65a5-464b-b28c-daea67ba9569");
jsonBody.put("picUri", "/pic?9dda12i40-e*5b84626c4105m5ep=t=i3p*i=d1s*i=d3b*i1d3b*855925cea-96008b--2718943z855s=5i76=");
jsonBody.put("svrIndexCode", "5027ba75-d30b-499c-b42c-ee91e2b9e8f7");
jsonBody.put("picUri", "/pic?8d00=4a01l4b-do4b1a*71dc*6o1=7=6453*2l4532999176*7t1=9*3ps===121**bbed34e5b-812d30b-130oe0-pi0dd8=007d0");
String body = jsonBody.toJSONString();
//参数根据接口实际情况设置
HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, query, null,"application/json",head);
HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, query, null,"application/json",null);
try {
HttpResponse resp = result;
if (302==resp.getStatusLine().getStatusCode()) {
......@@ -162,12 +163,14 @@ public class ArtemisPostTest {
*/
Header header= resp.getFirstHeader("location");
String newUrl = header.getValue();
HttpGet httpget = new HttpGet(newUrl);
String replace = StrUtil.replace(newUrl, "https://10.12.177.245:6114", "http://8.136.255.30:8002");
HttpGet httpget = new HttpGet(replace);
HttpClient httpClient = wrapClient(httpget.getURI().getScheme()+"://"+httpget.getURI().getHost());
HttpResponse execute = httpClient.execute(httpget);
HttpEntity entity = execute.getEntity();
InputStream in = entity.getContent();
Tools.savePicToDisk(in, "d:/", "test311.jpg");
Tools.savePicToDisk(in, "E:/", "test311.jpg");
}else{
System.out.println("下载出错");
}
......@@ -186,10 +189,14 @@ public class ArtemisPostTest {
// System.out.println(VechicleDataResult);
String result = callPostApiGetPersonList();
System.out.println(result);
/* String result = callPostApiGetPersonList();
System.out.println(result);*/
//callPostApiGetPersonList
String result =callPostImgs();
System.out.println(result);
}
}
......@@ -5,26 +5,23 @@ import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.common.code.RecognitionResourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.face.model.FaceGroupEntity;
import com.mortals.xhx.module.face.model.FaceGroupQuery;
import com.mortals.xhx.module.face.model.FacePlanEntity;
import com.mortals.xhx.module.face.model.FacePlanQuery;
import com.mortals.xhx.module.face.service.FaceGroupService;
import com.mortals.xhx.module.face.service.FacePlanService;
import com.mortals.xhx.module.hik.event.model.req.sub.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.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognListReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.hik.face.service.IHikPlanService;
import lombok.extern.slf4j.Slf4j;
......@@ -33,7 +30,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -105,6 +101,26 @@ public class SubEventStartedService implements IApplicationStartedService {
}
}
//创建陌生人计划
facePlanService.createStrangerPlanByDay();
//删除重点人员计划
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognInfo> delPlanList = planRecognBlackRest.getData();
if (!ObjectUtils.isEmpty(delPlanList)) {
//删除计划
PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setRecognitionResourceIndexCodes(delPlanList.stream().map(i -> i.getIndexCode()).collect(Collectors.toList()));
Rest<Boolean> delRest = hikPlanService.planRecognBlackDel(planRecognBlackReq);
if (delRest.getCode() == YesNoEnum.YES.getValue() && delRest.getData()) {
log.info("预约计划删除成功!");
}
}
}*/
//删除创建陌生人员识别计划,todo
// String planBlackName = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_PLAN_BLACK, "取号监控");
......
package com.mortals.xhx.daemon.applicationservice;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.face.service.FaceGroupService;
import com.mortals.xhx.module.face.service.FacePlanService;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.hik.face.service.IHikPlanService;
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo;
import com.mortals.xhx.module.hik.person.service.IHikPersonService;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.service.PersonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 同步工作人员到本地注册人员中
*
* @author:
* @date: 2023/4/24 10:50
*/
//@Component
@Slf4j
public class SyncWorkmanStartedService implements IApplicationStartedService {
@Autowired
private PersonService personService;
@Autowired
private IHikPersonService hikPersonService;
@Override
public void start() {
log.info("开始服务..[工作人员同步]");
PersonReq personReq = new PersonReq();
personReq.setPageNo(1);
personReq.setPageSize(3);
Rest<PersonDataInfo> personListRest = hikPersonService.getPersonList(personReq);
if (personListRest.getCode() == YesNoEnum.YES.getValue()) {
List<PersonEntity> collect = personListRest.getData().getList().parallelStream().map(work -> {
//判断是否存在,存在更新,
if (work.getCertificateType() == 990) {
work.setCertificateNo(StrUtil.subSufByLength(work.getPersonId(), 20));
}
PersonEntity personEntity = personService.getExtCache(work.getCertificateNo());
if (ObjectUtils.isEmpty(personEntity)) {
personEntity = new PersonEntity();
personEntity.initAttrValue();
personEntity.setName(work.getPersonName());
personEntity.setGender(work.getGender() == 1 ? 0 : 1);
personEntity.setIdCard(work.getCertificateNo());
personEntity.setPhone(work.getPhoneNo());
try {
personEntity.setBirthday(DateUtil.parse(IdcardUtil.getBirth(work.getCertificateNo()), "yyyyMMdd"));
} catch (Exception e) {
}
personEntity.setServerIndexCode(work.getPersonPhoto().getServerIndexCode());
personEntity.setPicUrl(work.getPersonPhoto().getPicUri());
personEntity.setSource(SourceEnum.海康系统.getValue());
personEntity.setCreateTime(new Date());
personEntity.setCreateUserId(1L);
personEntity.setCreateUserName("system");
return personEntity;
}
return personEntity;
}).collect(Collectors.toList());
Map<Boolean, List<PersonEntity>> booleanListMap = collect.parallelStream().collect(Collectors.partitioningBy(x -> x.getId() == null));
List<PersonEntity> savePersonList = booleanListMap.get(true);
List<PersonEntity> updatePersonList = booleanListMap.get(false);
if (!ObjectUtils.isEmpty(savePersonList)) {
log.info("新增人员数量:{}", savePersonList.size());
personService.save(savePersonList);
}
if (!ObjectUtils.isEmpty(updatePersonList)) {
log.info("更新人员数量:{}", updatePersonList.size());
// personService.update(updatePersonList);
}
}
}
@Override
public void stop() {
log.info("停止服务..");
}
@Override
public int getOrder() {
return 11;
}
}
......@@ -92,15 +92,22 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
public void excuteTask(ITask task) throws AppException {
log.info("{}=>创建陌生人计划任务", DateUtils.getCurrStrDate());
createStrangerPlanByDay();
//createStrangerPlanByDay();
facePlanService.createStrangerPlanByDay();
log.info("{}=>创建陌生人计划任务完成", DateUtils.getCurrStrDate());
log.info("{}=>创建预约计划任务", DateUtils.getCurrStrDate());
createAppointmentPlanByDay();
facePlanService.createAppointmentPlanByDay();
//createAppointmentPlanByDay();
log.info("{}=>创建预约计划任务完成", DateUtils.getCurrStrDate());
}
private void createStrangerPlanByDay() {
facePlanService.createStrangerPlanByDay();
/*
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
//创建或者更新
PlanRecognListReq planRecognListReq = new PlanRecognListReq();
......@@ -129,10 +136,26 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
faceGroupIndexCodes.add(faceGroupEntity.getIndexCode());
planRecognBlackReq.setFaceGroupIndexCodes(faceGroupIndexCodes);
//设置监控点
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().map(DeviceEntity::getDeviceCode).collect(Collectors.toList());
planRecognBlackReq.setCameraIndexCodes(cameraIndexCodes);
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().distinct().map(DeviceEntity::getDeviceCode).collect(Collectors.toList());
ArrayList<String> temp = new ArrayList<>();
temp.add(cameraIndexCodes.get(0));
planRecognBlackReq.setCameraIndexCodes(temp);
//设置识别方式
planRecognBlackReq.setRecognitionResourceType(RecognitionResourceEnum.COMPARISON.getValue());
// List<String> faceGroupIndexCodes = new ArrayList<>();
List<String> recognitionResourceIndexCodes = faceGroupPersonService.find(new FaceGroupPersonQuery().faceGroupId(faceGroupEntity.getId())).stream().map(i -> i.getIndexCode()).filter(f->!ObjectUtils.isEmpty(f)).collect(Collectors.toList());
ArrayList<String> temp1 = new ArrayList<>();
// temp1.add(recognitionResourceIndexCodes.get(0));
// temp1.add(recognitionResourceIndexCodes.get(1));
temp1.add(recognitionResourceIndexCodes.get(3));
//temp1.add(recognitionResourceIndexCodes.get(4));
// planRecognBlackReq.setRecognitionResourceIndexCodes(temp1);
//设置时间段 默认全天候
if (ObjectUtils.isEmpty(planRecognWhiteInfo)) {
Rest<String> planRecognWhiteAddRest = hikPlanService.planRecognWhiteAdd(planRecognBlackReq);
......@@ -154,23 +177,30 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
if (planRecognWhiteUpdateRest.getCode() == YesNoEnum.YES.getValue() && planRecognWhiteUpdateRest.getData()) {
FacePlanEntity whitePlan = facePlanService.selectOne(new FacePlanQuery().indexCode(planRecognWhiteInfo.getIndexCode()));
if(!ObjectUtils.isEmpty(whitePlan)){
whitePlan.setUpdateTime(new Date());
whitePlan.setUpdateUserId(1L);
whitePlan.setUpdateUserName("system");
facePlanService.update(whitePlan);
}
}
}
}
}*/
}
private void createAppointmentPlanByDay() {
PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
facePlanService.createAppointmentPlanByDay();
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognInfo> delPlanList = planRecognBlackRest.getData().stream().map(i -> {
......@@ -315,7 +345,7 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
}
} else {
log.info("当天无预约人员,不创建监控计划=>{}", DateUtils.getCurrStrDate());
}
}*/
}
......
......@@ -7,6 +7,10 @@ import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.InFaceHkEnum;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.module.hik.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.model.PersonQuery;
import com.mortals.xhx.module.person.service.PersonService;
......@@ -14,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
......@@ -40,6 +45,8 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
private PersonService personService;
@Autowired
private UploadService uploadService;
@Autowired
private IHikFaceService hikFaceService;
@Value("${php.host:''}")
private String host;
......@@ -56,6 +63,7 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
private void syncRegisterUsersPhotos() {
String url = host.endsWith("/") ? host : host + "/";
List<PersonEntity> collect = personService.find(new PersonQuery()).stream()
.filter(item -> ObjectUtils.isEmpty(item.getPhoto()))
.filter(item -> !ObjectUtils.isEmpty(item.getSourcePhotoUri())).collect(Collectors.toList());
......@@ -63,16 +71,38 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
//下载图片到本地保存并更新
String downUrl = url + personEntity.getSourcePhotoUri();
//String downUrl = "http://192.168.0.98:11078/file/fileupload/1679215657433.jpg";
log.info("downUrl:{}",downUrl);
log.info("downUrl:{}", downUrl);
byte[] bytes = HttpUtil.downloadBytes(downUrl);
if(bytes.length>0){
if (bytes.length > 0) {
InputStream inputStream = new ByteArrayInputStream(bytes);
MultipartFile file = ServletUtils.getMultipartFile(inputStream, "photo.jpg");
String filePath = uploadService.saveFileUpload(file, "file/fileupload",null);
String filePath = uploadService.saveFileUpload(file, "file/fileupload", null);
personEntity.setPhoto(filePath);
personService.update(personEntity);
}
}
List<PersonEntity> hikPerson = personService.find(new PersonQuery().source(SourceEnum.海康系统.getValue())).stream().filter(f -> ObjectUtils.isEmpty(f.getPhoto())).collect(Collectors.toList());
for (PersonEntity person : hikPerson) {
ImgReq imgReq = new ImgReq();
imgReq.setSvrIndexCode(person.getServerIndexCode());
imgReq.setPicUri(person.getPicUrl());
try {
InputStream inputStream = hikFaceService.callPostImgs(imgReq);
if (!ObjectUtils.isEmpty(inputStream)) {
MultipartFile file = ServletUtils.getMultipartFile(inputStream, "photo.jpg");
String filePath = uploadService.saveFileUpload(file, "file/fileupload", null);
person.setPhoto(filePath);
personService.update(person);
} else {
log.error("获取图片异常!");
}
} catch (Exception e) {
log.error("下载图片异常", e.getMessage());
}
}
}
......
......@@ -92,7 +92,7 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
int count=0;
List<PersonEntity> max = personService.getDao().getMax();
if(!ObjectUtils.isEmpty(max)){
count=max.get(0).getSiteId().intValue();
count=max.get(0).getSourceId().intValue();
}
String registerPath = "/inter/Actuary/peopleList";
String url = host + registerPath;
......@@ -194,7 +194,6 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
}
}
}
......
......@@ -26,7 +26,7 @@ import java.util.List;
*/
@Slf4j
@Service("SyncUserTask")
@ConditionalOnExpression("'${platform.type:null}'=='cloud'")
@ConditionalOnExpression("'${spring.profiles.active}'!='develop'")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
......
......@@ -2,6 +2,7 @@ package com.mortals.xhx.daemon.task;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
......
......@@ -440,14 +440,14 @@ public class DeviceEntity extends DeviceVo {
@Override
public int hashCode() {
return this.getId().hashCode();
return this.getEncodeDevIndexCode().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof DeviceEntity) {
DeviceEntity tmp = (DeviceEntity) obj;
if (this.getId() == tmp.getId()) {
if (this.getEncodeDevIndexCode() .equals( tmp.getEncodeDevIndexCode())) {
return true;
}
}
......
package com.mortals.xhx.module.face.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.face.model.FacePlanEntity;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognInfo;
import java.util.List;
/**
* FacePlanService
*
* 人员识别计划信息 service接口
*
* @author zxfei
* @date 2023-04-15
*/
public interface FacePlanService extends ICRUDService<FacePlanEntity,Long>{
* FacePlanService
* <p>
* 人员识别计划信息 service接口
*
* @author zxfei
* @date 2023-04-15
*/
public interface FacePlanService extends ICRUDService<FacePlanEntity, Long> {
/**
* 创建陌生人监控计划
*/
Rest<List<PlanRecognInfo>> createStrangerPlanByDay();
/**
* 创建预约人员监控计划
*/
void createAppointmentPlanByDay();
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.req.img;
import lombok.Data;
@Data
public class ImgReq {
private String svrIndexCode;
private String picUri;
}
package com.mortals.xhx.module.hik.face.model.req.resource;
import java.util.List;
import lombok.Data;
@Data
public class ResourceReq{
private String name;
private String recognitionResourceType;
private List<String> indexCodes;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.face.model.rsp.resource;
import lombok.Data;
@Data
public class ResourceDataInfo{
private String name;
private String indexCode;
private String recognitionResourceType;
}
\ No newline at end of file
......@@ -6,10 +6,14 @@ 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;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.model.req.resource.ResourceReq;
import com.mortals.xhx.module.hik.face.model.rsp.face.FaceDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.face.ResRecognDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.resource.ResourceDataInfo;
import java.io.InputStream;
import java.util.List;
/**
......@@ -79,4 +83,15 @@ public interface IHikFaceService {
Rest<List<ResRecognDataInfo>> findResRecognList(ResRecognReq recognReq);
/**
* 获取识别资源
* @param recognReq
* @return
*/
Rest<List<ResourceDataInfo>> getResourceRecognition(ResourceReq recognReq);
InputStream callPostImgs(ImgReq imgReq) throws Exception;
}
package com.mortals.xhx.module.hik.face.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
......@@ -11,14 +12,27 @@ 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;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.model.req.resource.ResourceReq;
import com.mortals.xhx.module.hik.face.model.rsp.face.FaceDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.face.ResRecognDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.group.FaceGroupDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.resource.ResourceDataInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.hikvision.artemis.sdk.util.HttpUtil.wrapClient;
/**
* 海康人员接口类
......@@ -206,4 +220,62 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<List<ResourceDataInfo>> getResourceRecognition(ResourceReq recognReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/resource/recognition";
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json");
Rest<List<ResourceDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<ResourceDataInfo>>>() {
});
if (rest.getCode() == 0) {
return Rest.ok(rest.getData());
} else {
log.info("resource recognition list error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("resource recognition", e);
return Rest.fail(e.getMessage());
}
}
//下载图片
@Override
public InputStream callPostImgs(ImgReq imgReq) throws Exception {
ArtemisConfig config = getArtemisConfig();
String getSecurityApi = ARTEMIS_PATH + "/api/visitor/v1/record/pictures";
path.put(protocol, getSecurityApi);
//ArtemisHttpUtil.doPostStringImgArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json");
Map<String, String> query = new HashMap<String, String>(2) { //get请求的head参数
{
put("domainId", "0");
}
};
//参数根据接口实际情况设置
HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, JSON.toJSONString(imgReq), query, null, "application/json", null);
HttpResponse resp = result;
if (302 == resp.getStatusLine().getStatusCode()) {
Header header = resp.getFirstHeader("location");
String newUrl = header.getValue();
//本地测试
String replace = StrUtil.replace(newUrl, "https://10.12.177.245:6114", "http://8.136.255.30:8002");
HttpGet httpget = new HttpGet(replace);
//HttpGet httpget = new HttpGet(newUrl);
HttpClient httpClient = wrapClient(httpget.getURI().getScheme() + "://" + httpget.getURI().getHost());
HttpResponse execute = httpClient.execute(httpget);
HttpEntity entity = execute.getEntity();
InputStream in = entity.getContent();
return in;
} else {
System.out.println("下载出错");
return null;
}
}
}
package com.mortals.xhx.module.person.model;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.person.model.vo.PersonVo;
import lombok.Data;
import java.util.Date;
/**
* 注册人员实体对象
*
* @author zxfei
* @date 2023-04-16
* @date 2023-04-24
*/
@Data
public class PersonEntity extends PersonVo {
......@@ -43,12 +44,10 @@ public class PersonEntity extends PersonVo {
/**
* 出生日期
*/
@Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
/**
* 家庭住址
*/
@Excel(name = "家庭住址")
private String address;
/**
* 本地照片路径
......@@ -67,7 +66,7 @@ public class PersonEntity extends PersonVo {
*/
private String remark;
/**
* 注册人员来源(0.预约系统,1.排队叫号系统,2.自助服务系统,99.其它)
* 注册人员来源(0.预约系统,1.排队叫号系统,2.自助服务系统,3.海康,99.其它)
*/
private Integer source;
/**
......@@ -82,12 +81,18 @@ public class PersonEntity extends PersonVo {
* 人脸所属的人脸分组的唯一标识
*/
private String ifaceGroupIndexCode;
/**
* 海康人脸图片url
*/
private String picUrl;
/**
* 海康人脸服务标识
*/
private String serverIndexCode;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
......@@ -100,8 +105,7 @@ public class PersonEntity extends PersonVo {
return false;
}
public void initAttrValue() {
public void initAttrValue(){
this.siteId = null;
......@@ -134,5 +138,9 @@ public class PersonEntity extends PersonVo {
this.indexCode = "";
this.ifaceGroupIndexCode = "";
this.picUrl = "";
this.serverIndexCode = "";
}
}
\ No newline at end of file
......@@ -16,5 +16,9 @@
<property name="dialect" value="MySql" />
<property name="showSql" value="MySql" />
</plugin>
<plugin interceptor="com.mortals.framework.thirty.mybatis.LogInterceptor">
<property name="enableExecutorTime" value="true" />
<property name="showSql" value="false" />
</plugin>
</plugins>
</configuration>
\ No newline at end of file
......@@ -26,6 +26,8 @@
<result property="createTime" column="createTime" />
<result property="updateUserId" column="updateUserId" />
<result property="updateTime" column="updateTime" />
<result property="picUrl" column="picUrl" />
<result property="serverIndexCode" column="serverIndexCode" />
</resultMap>
......@@ -96,23 +98,29 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
a.updateTime,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('picUrl') or colPickMode == 1 and data.containsKey('picUrl')))">
a.picUrl,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('serverIndexCode') or colPickMode == 1 and data.containsKey('serverIndexCode')))">
a.serverIndexCode,
</if>
</trim>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="PersonEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_person
(siteId,siteName,name,idCard,gender,phone,birthday,address,photo,sourcePhotoUri,sourceId,remark,source,inFaceHk,indexCode,ifaceGroupIndexCode,createUserId,createTime,updateUserId,updateTime)
(siteId,siteName,name,idCard,gender,phone,birthday,address,photo,sourcePhotoUri,sourceId,remark,source,inFaceHk,indexCode,ifaceGroupIndexCode,createUserId,createTime,updateUserId,updateTime,picUrl,serverIndexCode)
VALUES
(#{siteId},#{siteName},#{name},#{idCard},#{gender},#{phone},#{birthday},#{address},#{photo},#{sourcePhotoUri},#{sourceId},#{remark},#{source},#{inFaceHk},#{indexCode},#{ifaceGroupIndexCode},#{createUserId},#{createTime},#{updateUserId},#{updateTime})
(#{siteId},#{siteName},#{name},#{idCard},#{gender},#{phone},#{birthday},#{address},#{photo},#{sourcePhotoUri},#{sourceId},#{remark},#{source},#{inFaceHk},#{indexCode},#{ifaceGroupIndexCode},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{picUrl},#{serverIndexCode})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_person
(siteId,siteName,name,idCard,gender,phone,birthday,address,photo,sourcePhotoUri,sourceId,remark,source,inFaceHk,indexCode,ifaceGroupIndexCode,createUserId,createTime,updateUserId,updateTime)
(siteId,siteName,name,idCard,gender,phone,birthday,address,photo,sourcePhotoUri,sourceId,remark,source,inFaceHk,indexCode,ifaceGroupIndexCode,createUserId,createTime,updateUserId,updateTime,picUrl,serverIndexCode)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.siteId},#{item.siteName},#{item.name},#{item.idCard},#{item.gender},#{item.phone},#{item.birthday},#{item.address},#{item.photo},#{item.sourcePhotoUri},#{item.sourceId},#{item.remark},#{item.source},#{item.inFaceHk},#{item.indexCode},#{item.ifaceGroupIndexCode},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime})
(#{item.siteId},#{item.siteName},#{item.name},#{item.idCard},#{item.gender},#{item.phone},#{item.birthday},#{item.address},#{item.photo},#{item.sourcePhotoUri},#{item.sourceId},#{item.remark},#{item.source},#{item.inFaceHk},#{item.indexCode},#{item.ifaceGroupIndexCode},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.picUrl},#{item.serverIndexCode})
</foreach>
</insert>
......@@ -203,6 +211,12 @@
<if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))">
a.updateTime=#{data.updateTime},
</if>
<if test="(colPickMode==0 and data.containsKey('picUrl')) or (colPickMode==1 and !data.containsKey('picUrl'))">
a.picUrl=#{data.picUrl},
</if>
<if test="(colPickMode==0 and data.containsKey('serverIndexCode')) or (colPickMode==1 and !data.containsKey('serverIndexCode'))">
a.serverIndexCode=#{data.serverIndexCode},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
......@@ -390,6 +404,20 @@
</if>
</foreach>
</trim>
<trim prefix="picUrl=(case" suffix="ELSE picUrl end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('picUrl')) or (colPickMode==1 and !item.containsKey('picUrl'))">
when a.id=#{item.id} then #{item.picUrl}
</if>
</foreach>
</trim>
<trim prefix="serverIndexCode=(case" suffix="ELSE serverIndexCode end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('serverIndexCode')) or (colPickMode==1 and !item.containsKey('serverIndexCode'))">
when a.id=#{item.id} then #{item.serverIndexCode}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
......@@ -977,6 +1005,48 @@
<if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''">
${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('picUrl')">
<if test="conditionParamRef.picUrl != null and conditionParamRef.picUrl != ''">
${_conditionType_} a.picUrl like #{${_conditionParam_}.picUrl}
</if>
<if test="conditionParamRef.picUrl == null">
${_conditionType_} a.picUrl is null
</if>
</if>
<if test="conditionParamRef.containsKey('picUrlList') and conditionParamRef.picUrlList.size() > 0">
${_conditionType_} a.picUrl in
<foreach collection="conditionParamRef.picUrlList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('picUrlNotList') and conditionParamRef.picUrlNotList.size() > 0">
${_conditionType_} a.picUrl not in
<foreach collection="conditionParamRef.picUrlNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('serverIndexCode')">
<if test="conditionParamRef.serverIndexCode != null and conditionParamRef.serverIndexCode != ''">
${_conditionType_} a.serverIndexCode like #{${_conditionParam_}.serverIndexCode}
</if>
<if test="conditionParamRef.serverIndexCode == null">
${_conditionType_} a.serverIndexCode is null
</if>
</if>
<if test="conditionParamRef.containsKey('serverIndexCodeList') and conditionParamRef.serverIndexCodeList.size() > 0">
${_conditionType_} a.serverIndexCode in
<foreach collection="conditionParamRef.serverIndexCodeList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('serverIndexCodeNotList') and conditionParamRef.serverIndexCodeNotList.size() > 0">
${_conditionType_} a.serverIndexCode not in
<foreach collection="conditionParamRef.serverIndexCodeNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</sql>
<sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
......@@ -1095,6 +1165,16 @@
<if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('picUrl')">
a.picUrl
<if test='orderCol.picUrl != null and "DESC".equalsIgnoreCase(orderCol.picUrl)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('serverIndexCode')">
a.serverIndexCode
<if test='orderCol.serverIndexCode != null and "DESC".equalsIgnoreCase(orderCol.serverIndexCode)'>DESC</if>
,
</if>
</trim>
</if>
</sql>
......
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