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

添加同步预约和注册用户类

parent 04c193d0
......@@ -235,7 +235,9 @@ CREATE TABLE mortals_xhx_person(
`phone` varchar(20) COMMENT '手机号码',
`birthday` datetime NOT NULL COMMENT '出生日期',
`address` varchar(256) NOT NULL COMMENT '家庭住址',
`photo` varchar(256) NOT NULL COMMENT '照片路径',
`photo` varchar(128) NOT NULL 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.是)',
......@@ -247,6 +249,7 @@ CREATE TABLE mortals_xhx_person(
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='注册人员';
-- ----------------------------
-- 设备业务表
-- ----------------------------
......@@ -405,3 +408,28 @@ CREATE TABLE mortals_xhx_face_plan(
`updateUserId` bigint(20) COMMENT '更新人ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='人员识别计划信息';
-- ----------------------------
-- 预约人员表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_appointment_person`;
CREATE TABLE mortals_xhx_appointment_person(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`siteId` bigint(20) COMMENT '站点Id',
`siteName` varchar(256) COMMENT '站点名称',
`personId` bigint(20) NOT NULL COMMENT '人员id',
`name` varchar(50) COMMENT '姓名',
`contactInfo` varchar(50) COMMENT '联系方式',
`idCard` varchar(50) COMMENT '身份证号码',
`bussinessId` bigint(20) COMMENT '业务Id',
`bussinessName` varchar(255) COMMENT '预约业务',
`appontmentNumber` varchar(50) COMMENT '预约编号',
`appointmentStartTime` datetime COMMENT '预约开始时间',
`appointmentEndTime` datetime COMMENT '预约结束时间',
`createUserId` bigint(20) COMMENT '创建人id',
`createTime` datetime COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新人id',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='预约人员';
......@@ -31,6 +31,7 @@
<profiles.log.path>/mortals/app/logs</profiles.log.path>
<profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.php.host>http://192.168.0.98:8090</profiles.php.host>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
......@@ -55,10 +56,10 @@
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.log.level>INFO</profiles.log.level>
<profiles.php.host>http://192.168.0.98:8090</profiles.php.host>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
......
package com.mortals.xhx.busiz.req.register;
import lombok.Data;
@Data
public class registerReq {
private Integer page;
private Integer size;
}
package com.mortals.xhx.busiz.rsp.register;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.List;
@Data
public class AppointmentDataInfo {
@JSONField(name = "per_page")
Integer perPage;
@JSONField(name = "total")
Integer total;
@JSONField(name = "data")
List<AppointmentDataItem> data;
@JSONField(name = "last_page")
Integer lastPage;
@JSONField(name = "current_page")
Integer currentPage;
}
\ No newline at end of file
package com.mortals.xhx.busiz.rsp.register;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Date;
@Data
public class AppointmentDataItem {
@JSONField(name = "birthday")
private String birthday;
@JSONField(name = "business_name")
private String businessName;
@JSONField(name = "idcard_IDCardNo")
private String idcardIDCardNo;
@JSONField(name = "businessid")
private Long businessId;
@JSONField(name = "endtime",format = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
@JSONField(name = "starttime",format = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@JSONField(name = "idcard_Name")
private String idcardName;
@JSONField(name = "number")
private String number;
@JSONField(name = "idcard_Sex")
private String idcardSex;
@JSONField(name = "idcard_Address")
private String idcardAddress;
@JSONField(name = "peopleid")
private Long peopleId;
@JSONField(name = "phone")
private String phone;
@JSONField(name = "siteid")
private Long siteId;
@JSONField(name = "idcardData_PhotoFileName")
private String idcardDataPhotoFileName;
}
\ No newline at end of file
package com.mortals.xhx.busiz.rsp.register;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class DataItem {
@JSONField(name = "birthday")
String birthday;
@JSONField(name = "idcard_Address")
String idcardAddress;
@JSONField(name = "idcard_Sex")
String idcardSex;
@JSONField(name = "phone")
String phone;
@JSONField(name = "idcard_IDCardNo")
String idcardIDCardNo;
@JSONField(name = "id")
Long id;
@JSONField(name = "idcard_Name")
String idcardName;
@JSONField(name = "idcardData_PhotoFileName")
String idcardDataPhotoFileName;
}
\ No newline at end of file
package com.mortals.xhx.busiz.rsp.register;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class RegisterDataInfo {
@JSONField(name = "per_page")
Integer perPage;
@JSONField(name = "total")
Integer total;
@JSONField(name = "data")
List<DataItem> data;
@JSONField(name = "last_page")
Integer lastPage;
@JSONField(name = "current_page")
Integer currentPage;
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 海康事件类型
*
* @author zxfei
*/
public enum HikEventTypeEnum {
重点人员识别事件("event_face_recognition", "重点人员识别事件");
private String value;
private String desc;
HikEventTypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static HikEventTypeEnum getByValue(String value) {
for (HikEventTypeEnum recognitionPlanTypeEnum : HikEventTypeEnum.values()) {
if (recognitionPlanTypeEnum.getValue() == value) {
return recognitionPlanTypeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (HikEventTypeEnum item : HikEventTypeEnum.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
......@@ -15,6 +15,9 @@ public class ParamKey {
/** 人脸识别阈值 */
public static final String PARAM_FACE_THRESHOLD = "face_threshold";
/** 人脸相似度 */
public static final String PARAM_FACE_SIMILARITY = "face_similarity";
/**
* 系统参数:设备心跳间隔时间(单位:秒,默认值:60秒)
*/
......
......@@ -30,7 +30,6 @@ 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;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
......@@ -39,7 +38,7 @@ import java.util.List;
import java.util.stream.Collectors;
@Component
//@Component
@Slf4j
public class SubEventStartedService implements IApplicationStartedService {
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.busiz.rsp.register.AppointmentDataInfo;
import com.mortals.xhx.busiz.rsp.register.AppointmentDataItem;
import com.mortals.xhx.busiz.rsp.register.DataItem;
import com.mortals.xhx.busiz.rsp.register.RegisterDataInfo;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import com.mortals.xhx.module.appointment.model.AppointmentPersonQuery;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.model.PersonQuery;
import com.mortals.xhx.module.person.service.PersonService;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 同步预约人数。
*/
@Slf4j
@Service("SyncRegisterUserPicTask")
public class SyncAppointmentPersonTaskImpl implements ITaskExcuteService {
@Autowired
private PersonService personService;
@Autowired
private AppointmentPersonService appointmentPersonService;
@Value("${php.host:''}")
private String host;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步今天预约用户任务");
syncAppointmentPerson();
log.info("同步今天预约用户任务完成");
}
private void syncAppointmentPerson() {
//根据数量查询
String registerPath = "/inter/Actuary/orderPeople";
String url = host + registerPath;
Map<String, Object> params = new HashMap<>();
params.put("page", 1);
params.put("size", 1);
String respJson = HttpUtil.get(url, params);
Rest<AppointmentDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<AppointmentDataInfo>>() {
});
if (rest.getCode() == YesNoEnum.YES.getValue()) {
Integer total = rest.getData().getTotal();
if (total > 1) {
params = new HashMap<>();
params.put("page", 1);
params.put("size", total);
respJson = HttpUtil.get(url, params);
Rest<AppointmentDataInfo> restTotal = JSON.parseObject(respJson, new TypeReference<Rest<AppointmentDataInfo>>() {
});
if (restTotal.getCode() == YesNoEnum.YES.getValue()) {
//同步今天预约用户
List<AppointmentDataItem> appointUserList = restTotal.getData().getData();
log.info("预约用户总数量:{}", appointUserList.size());
if (!ObjectUtils.isEmpty(appointUserList)) {
//查询今天添加的预约 并删除
AppointmentPersonQuery appointmentPersonQuery = new AppointmentPersonQuery();
appointmentPersonQuery.setCreateTimeStart(DateUtil.format(new Date(),"yyyy-MM-dd"));
appointmentPersonQuery.setCreateTimeEnd(DateUtil.format(new Date(),"yyyy-MM-dd"));
Long[] ids = appointmentPersonService.find(appointmentPersonQuery).stream().map(i -> i.getId()).toArray(Long[]::new);
if(!ObjectUtils.isEmpty(ids)){
appointmentPersonService.remove(ids,null);
}
List<AppointmentPersonEntity> newUserList = appointUserList.stream().map(user -> {
AppointmentPersonEntity appointmentPersonEntity = new AppointmentPersonEntity();
appointmentPersonEntity.initAttrValue();
PersonEntity personCache = personService.getExtCache(user.getIdcardIDCardNo());
appointmentPersonEntity.setPersonId(personCache == null ? -1 : personCache.getId());
appointmentPersonEntity.setName(personCache == null ? "" : personCache.getName());
appointmentPersonEntity.setSiteId(user.getSiteId());
appointmentPersonEntity.setIdCard(user.getIdcardIDCardNo());
appointmentPersonEntity.setAppointmentStartTime(user.getStartTime());
appointmentPersonEntity.setAppointmentEndTime(user.getEndTime());
appointmentPersonEntity.setBussinessId(user.getBusinessId());
appointmentPersonEntity.setBussinessName(user.getBusinessName());
appointmentPersonEntity.setContactInfo(user.getPhone());
appointmentPersonEntity.setAppontmentNumber(user.getNumber());
appointmentPersonEntity.setCreateUserId(1L);
appointmentPersonEntity.setCreateUserName("系统管理员");
appointmentPersonEntity.setCreateTime(new Date());
return appointmentPersonEntity;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(newUserList)) {
log.info("注册用户新增,size:{}", newUserList.size());
appointmentPersonService.save(newUserList);
}
}
}
}
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
/**
* 获取封装得MultipartFile
*
* @param inputStream inputStream
* @param fileName fileName
* @return MultipartFile
*/
public MultipartFile getMultipartFile(InputStream inputStream, String fileName) {
FileItem fileItem = createFileItem(inputStream, fileName);
//CommonsMultipartFile是feign对multipartFile的封装,但是要FileItem类对象
return new CommonsMultipartFile(fileItem);
}
/**
* FileItem类对象创建
*
* @param inputStream inputStream
* @param fileName fileName
* @return FileItem
*/
public FileItem createFileItem(InputStream inputStream, String fileName) {
FileItemFactory factory = new DiskFileItemFactory(16, null);
String textFieldName = "file";
FileItem item = factory.createItem(textFieldName, MediaType.MULTIPART_FORM_DATA_VALUE, true, fileName);
int bytesRead = 0;
byte[] buffer = new byte[10 * 1024 * 1024];
OutputStream os = null;
//使用输出流输出输入流的字节
try {
os = item.getOutputStream();
while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
inputStream.close();
} catch (IOException e) {
log.error("Stream copy exception", e);
throw new IllegalArgumentException("文件上传失败");
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
log.error("Stream close exception", e);
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.error("Stream close exception", e);
}
}
}
return item;
}
public static void main(String[] args) {
System.out.println(DateUtil.parse("19951071", "yyyyMMdd"));
}
}
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.model.PersonQuery;
import com.mortals.xhx.module.person.service.PersonService;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.stream.Collectors;
/**
* 同步注册用户与预约人数。
*/
@Slf4j
@Service("SyncRegisterUserPicTask")
public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
@Autowired
private PersonService personService;
@Autowired
private UploadService uploadService;
@Value("${php.host:''}")
private String host;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步注册用户照片任务");
syncRegisterUsersPhotos();
log.info("同步注册用户任务照片完成");
}
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());
for (PersonEntity personEntity : collect) {
//下载图片到本地保存并更新
String downUrl = url + personEntity.getSourcePhotoUri();
//String downUrl = "http://192.168.0.98:11078/file/fileupload/1679215657433.jpg";
log.info("downUrl:{}",downUrl);
byte[] bytes = HttpUtil.downloadBytes(downUrl);
if(bytes.length>0){
InputStream inputStream = new ByteArrayInputStream(bytes);
MultipartFile file = getMultipartFile(inputStream, "photo.jpg");
String filePath = uploadService.saveFileUpload(file, "file/fileupload",null);
personEntity.setPhoto(filePath);
personService.update(personEntity);
}
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
/**
* 获取封装得MultipartFile
*
* @param inputStream inputStream
* @param fileName fileName
* @return MultipartFile
*/
public MultipartFile getMultipartFile(InputStream inputStream, String fileName) {
FileItem fileItem = createFileItem(inputStream, fileName);
//CommonsMultipartFile是feign对multipartFile的封装,但是要FileItem类对象
return new CommonsMultipartFile(fileItem);
}
/**
* FileItem类对象创建
*
* @param inputStream inputStream
* @param fileName fileName
* @return FileItem
*/
public FileItem createFileItem(InputStream inputStream, String fileName) {
FileItemFactory factory = new DiskFileItemFactory(16, null);
String textFieldName = "file";
FileItem item = factory.createItem(textFieldName, MediaType.MULTIPART_FORM_DATA_VALUE, true, fileName);
int bytesRead = 0;
byte[] buffer = new byte[10 * 1024 * 1024];
OutputStream os = null;
//使用输出流输出输入流的字节
try {
os = item.getOutputStream();
while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
inputStream.close();
} catch (IOException e) {
log.error("Stream copy exception", e);
throw new IllegalArgumentException("文件上传失败");
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
log.error("Stream close exception", e);
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.error("Stream close exception", e);
}
}
}
return item;
}
public static void main(String[] args) {
System.out.println(DateUtil.parse("19951071", "yyyyMMdd"));
}
}
package com.mortals.xhx.module.appointment.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import java.util.List;
/**
* 预约人员记录Dao
* 预约人员记录 DAO接口
*
* @author zxfei
* @date 2023-04-16
*/
public interface AppointmentPersonDao extends ICRUDDao<AppointmentPersonEntity,Long>{
}
package com.mortals.xhx.module.appointment.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.appointment.dao.AppointmentPersonDao;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 预约人员记录DaoImpl DAO接口
*
* @author zxfei
* @date 2023-04-16
*/
@Repository("appointmentPersonDao")
public class AppointmentPersonDaoImpl extends BaseCRUDDaoMybatis<AppointmentPersonEntity,Long> implements AppointmentPersonDao {
}
package com.mortals.xhx.module.appointment.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.appointment.model.vo.AppointmentPersonVo;
/**
* 预约人员记录实体对象
*
* @author zxfei
* @date 2023-04-16
*/
public class AppointmentPersonEntity extends AppointmentPersonVo {
private static final long serialVersionUID = 1L;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点名称
*/
private String siteName;
/**
* 人员id
*/
@Excel(name = "人员id")
private Long personId;
/**
* 姓名
*/
@Excel(name = "姓名")
private String name;
/**
* 联系方式
*/
@Excel(name = "联系方式")
private String contactInfo;
/**
* 身份证号码
*/
@Excel(name = "身份证号码")
private String idCard;
/**
* 业务Id
*/
private Long bussinessId;
/**
* 预约业务
*/
@Excel(name = "预约业务")
private String bussinessName;
/**
* 预约编号
*/
@Excel(name = "预约编号")
private String appontmentNumber;
/**
* 预约开始时间
*/
@Excel(name = "预约开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date appointmentStartTime;
/**
* 预约结束时间
*/
@Excel(name = "预约结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date appointmentEndTime;
public AppointmentPersonEntity(){}
/**
* 获取 站点Id
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 站点名称
* @return String
*/
public String getSiteName(){
return siteName;
}
/**
* 设置 站点名称
* @param siteName
*/
public void setSiteName(String siteName){
this.siteName = siteName;
}
/**
* 获取 人员id
* @return Long
*/
public Long getPersonId(){
return personId;
}
/**
* 设置 人员id
* @param personId
*/
public void setPersonId(Long personId){
this.personId = personId;
}
/**
* 获取 姓名
* @return String
*/
public String getName(){
return name;
}
/**
* 设置 姓名
* @param name
*/
public void setName(String name){
this.name = name;
}
/**
* 获取 联系方式
* @return String
*/
public String getContactInfo(){
return contactInfo;
}
/**
* 设置 联系方式
* @param contactInfo
*/
public void setContactInfo(String contactInfo){
this.contactInfo = contactInfo;
}
/**
* 获取 身份证号码
* @return String
*/
public String getIdCard(){
return idCard;
}
/**
* 设置 身份证号码
* @param idCard
*/
public void setIdCard(String idCard){
this.idCard = idCard;
}
/**
* 获取 业务Id
* @return Long
*/
public Long getBussinessId(){
return bussinessId;
}
/**
* 设置 业务Id
* @param bussinessId
*/
public void setBussinessId(Long bussinessId){
this.bussinessId = bussinessId;
}
/**
* 获取 预约业务
* @return String
*/
public String getBussinessName(){
return bussinessName;
}
/**
* 设置 预约业务
* @param bussinessName
*/
public void setBussinessName(String bussinessName){
this.bussinessName = bussinessName;
}
/**
* 获取 预约编号
* @return String
*/
public String getAppontmentNumber(){
return appontmentNumber;
}
/**
* 设置 预约编号
* @param appontmentNumber
*/
public void setAppontmentNumber(String appontmentNumber){
this.appontmentNumber = appontmentNumber;
}
/**
* 获取 预约开始时间
* @return Date
*/
public Date getAppointmentStartTime(){
return appointmentStartTime;
}
/**
* 设置 预约开始时间
* @param appointmentStartTime
*/
public void setAppointmentStartTime(Date appointmentStartTime){
this.appointmentStartTime = appointmentStartTime;
}
/**
* 获取 预约结束时间
* @return Date
*/
public Date getAppointmentEndTime(){
return appointmentEndTime;
}
/**
* 设置 预约结束时间
* @param appointmentEndTime
*/
public void setAppointmentEndTime(Date appointmentEndTime){
this.appointmentEndTime = appointmentEndTime;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof AppointmentPersonEntity) {
AppointmentPersonEntity tmp = (AppointmentPersonEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",siteId:").append(getSiteId());
sb.append(",siteName:").append(getSiteName());
sb.append(",personId:").append(getPersonId());
sb.append(",name:").append(getName());
sb.append(",contactInfo:").append(getContactInfo());
sb.append(",idCard:").append(getIdCard());
sb.append(",bussinessId:").append(getBussinessId());
sb.append(",bussinessName:").append(getBussinessName());
sb.append(",appontmentNumber:").append(getAppontmentNumber());
sb.append(",appointmentStartTime:").append(getAppointmentStartTime());
sb.append(",appointmentEndTime:").append(getAppointmentEndTime());
return sb.toString();
}
public void initAttrValue(){
this.siteId = null;
this.siteName = "";
this.personId = null;
this.name = "";
this.contactInfo = "";
this.idCard = "";
this.bussinessId = null;
this.bussinessName = "";
this.appontmentNumber = "";
this.appointmentStartTime = null;
this.appointmentEndTime = null;
}
}
\ No newline at end of file
package com.mortals.xhx.module.appointment.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* 预约人员记录视图对象
*
* @author zxfei
* @date 2023-04-16
*/
@Data
public class AppointmentPersonVo extends BaseEntityLong {
}
\ No newline at end of file
package com.mortals.xhx.module.appointment.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
/**
* AppointmentPersonService
*
* 预约人员记录 service接口
*
* @author zxfei
* @date 2023-04-16
*/
public interface AppointmentPersonService extends ICRUDService<AppointmentPersonEntity,Long>{
}
\ No newline at end of file
package com.mortals.xhx.module.appointment.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.appointment.dao.AppointmentPersonDao;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService;
/**
* AppointmentPersonService
* 预约人员记录 service实现
*
* @author zxfei
* @date 2023-04-16
*/
@Service("appointmentPersonService")
public class AppointmentPersonServiceImpl extends AbstractCRUDServiceImpl<AppointmentPersonDao, AppointmentPersonEntity, Long> implements AppointmentPersonService {
}
\ No newline at end of file
package com.mortals.xhx.module.appointment.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 预约人员记录
*
* @author zxfei
* @date 2023-04-16
*/
@RestController
@RequestMapping("appointment/person")
public class AppointmentPersonController extends BaseCRUDJsonBodyMappingController<AppointmentPersonService,AppointmentPersonEntity,Long> {
@Autowired
private ParamService paramService;
public AppointmentPersonController(){
super.setModuleDesc( "预约人员记录");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model.req.callback;
import java.util.List;
import lombok.Data;
@Data
public class EventData{
private FaceRecognitionResult faceRecognitionResult;
private String srcEventId;
private List<ResInfoItem> resInfo;
public class EventData {
/**
* 识别结果
*/
private FaceRecognitionResult faceRecognitionResult;
/**
* 源事件的唯一标识,即转自的人脸比对事件的唯一标识
*/
private String srcEventId;
/**
* 触发重点人员识别事件的报警的抓拍点的信息
*/
private List<ResInfoItem> resInfo;
}
\ No newline at end of file
......@@ -8,15 +8,33 @@ import java.util.Date;
@Data
public class EventsItem {
//事件唯一标识
private String eventId;
//
private EventData data;
private int eventType;
//事件类型
private Integer eventType;
//事件源编号,物理设备是资源编号
private String srcIndex;
//事件类别
private String ability;
//事件源类型
private String srcType;
private int timeout;
//脉冲超时时间
private Integer timeout;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
/**
* 事件发生时间(设备时间)
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
private Date happenTime;
/**
* 事件状态
* 0-瞬时
* 1-开始
* 2-停止
* 3-事件脉冲
* 4-事件联动结果更新
*/
private int status;
}
\ No newline at end of file
......@@ -4,13 +4,40 @@ 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 faceGroupName;
/**
* 目标对应的人脸的唯一标识
*/
private String faceInfoCode;
/**
* 目标对应的人脸的名称
*/
private String faceInfoName;
/**
* 目标对应的人脸的性别
*/
private String faceInfoSex;
/**
* 目标对应的人脸的证件类型
*/
private String certificateType;
/**
* 目标对应的人脸的证件号码
*/
private String certificate;
/**
* 目标人脸和抓拍人脸的相似度
*/
private Double similarity;
/**
* 目标人脸的图片
*/
private String facePicUrl;
}
\ No newline at end of file
......@@ -5,6 +5,12 @@ import lombok.Data;
@Data
public class FaceRecognitionResult{
private List<FaceMatchItem> faceMatch;
/**
* 抓拍信息
*/
private Snap snap;
/**
* 识别到的目标信息 可能有1-5个目标
*/
private List<FaceMatchItem> faceMatch;
}
\ No newline at end of file
......@@ -6,10 +6,28 @@ import java.util.Date;
@Data
public class Snap{
/**
* 人脸图片URI
*/
private String faceUrl;
/**
* 抓拍图片的时间
*/
private Date faceTime;
/**
* 是否戴眼镜
*/
private String glass;
/**
* 性别
*/
private String gender;
/**
* 年龄段
*/
private String ageGroup;
/**
* 背景图片URL
*/
private String bkgUrl;
}
\ No newline at end of file
......@@ -4,16 +4,25 @@ 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.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.common.code.HikEventTypeEnum;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.module.hik.AbstractHikService;
import com.mortals.xhx.module.hik.HikApiRest;
import com.mortals.xhx.module.hik.event.model.req.callback.EventRecognBlackReq;
import com.mortals.xhx.module.hik.event.model.req.callback.*;
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.person.service.PersonService;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowEntity;
import com.mortals.xhx.module.realtime.service.RealtimeDataflowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
......@@ -26,6 +35,10 @@ import java.util.List;
@Slf4j
public class HikEventServiceImpl extends AbstractHikService implements IHikEventService {
@Autowired
private RealtimeDataflowService dataflowService;
@Autowired
private PersonService personService;
@Override
public Rest<String> subEvent(EventSubReq eventSubReq) {
......@@ -92,8 +105,63 @@ public class HikEventServiceImpl extends AbstractHikService implements IHikEvent
}
@Override
public Rest<String> handleEvent(EventRecognBlackReq eventRecognBlackReq) {
public Rest<String> handleEvent(EventRecognBlackReq req) {
//处理识别业务 todo
Double similarity = DataUtil.converStr2Double(GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_SIMILARITY, "0.8"), 0);
//String similarity = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_SIMILARITY, "0.8");
Params params = req.getParams();
if (HikEventTypeEnum.重点人员识别事件.getValue().equals(params.getAbility())) {
params.getEvents();
for (EventsItem event : params.getEvents()) {
//事件详细
String eventId = event.getEventId();
int eventType = event.getEventType();
EventData eventData = event.getData();
//识别结果
FaceRecognitionResult faceRecognitionResult = eventData.getFaceRecognitionResult();
//抓拍信息
Snap snap = faceRecognitionResult.getSnap();
//匹配的结果
List<FaceMatchItem> faceMatchs = faceRecognitionResult.getFaceMatch();
for (FaceMatchItem faceMatch : faceMatchs) {
//不论识别结果 保存流量数据
RealtimeDataflowEntity realtimeDataflowEntity = new RealtimeDataflowEntity();
// realtimeDataflowEntity.setPersonId();
// realtimeDataflowEntity.setName();
// realtimeDataflowEntity.setDevice();
// realtimeDataflowEntity.setDetectTime();
// realtimeDataflowEntity.setContact();
// realtimeDataflowEntity.setIdNumber();
// realtimeDataflowEntity.setIsBooking();
// realtimeDataflowEntity.setQueueNum();
// realtimeDataflowEntity.setLocation();
// realtimeDataflowEntity.setPicture();
// realtimeDataflowEntity.setOrderCols();
// realtimeDataflowEntity.setOrderColList();
realtimeDataflowEntity.setCreateUserId(1L);
realtimeDataflowEntity.setCreateTime(new Date());
realtimeDataflowEntity.setCreateUserName("system");
realtimeDataflowEntity.initAttrValue();
//dataflowService.save()
//根据匹配结果 保存业务数据 todo
if(faceMatch.getSimilarity()>similarity){
//保存当前识别结果到记录表中
}else {
//识别为陌生人 保存
}
}
}
}
return Rest.ok("处理成功!");
}
......
......@@ -61,6 +61,8 @@ sms:
smsSendUrl: @profiles.sms.smsSendUrl@
apiId: @profiles.sms.apiId@
type: @profiles.sms.type@
php:
host: @profiles.php.host@
hik:
host: @profiles.hik.host@
appKey: @profiles.hik.appKey@
......
###登录
POST {{baseUrl}}/login/login
Content-Type: application/json
{
"loginName":"admin",
"password":"admin",
"securityCode":"8888"
}
> {%
client.global.set("SmsSet_id", JSON.parse(response.body).data.id);
client.global.set("authToken", JSON.parse(response.body).data.token);
%}
###预约人员记录列表
POST {{baseUrl}}/appointment/person/list
Authorization: {{authToken}}
Content-Type: application/json
{
"page":1,
"size":10
}
###预约人员记录更新与保存
POST {{baseUrl}}/appointment/person/save
Authorization: {{authToken}}
Content-Type: application/json
{
"siteId":841,
"siteName":"exbn83",
"personId":452,
"name":"rgqtai",
"contactInfo":"rx8lt9",
"idNumber":"z8djwa",
"reservationService":"x1vgyl",
"reservationNumber":"7im1er",
"appointmentTime":"1681574400000",
}
> {%
client.global.set("AppointmentPerson_id", JSON.parse(response.body).data.id);
%}
###预约人员记录查看
GET {{baseUrl}}/appointment/person/info?id={{AppointmentPerson_id}}
Authorization: {{authToken}}
Accept: application/json
###预约人员记录编辑
GET {{baseUrl}}/appointment/person/edit?id={{AppointmentPerson_id}}
Authorization: {{authToken}}
Accept: application/json
###预约人员记录删除
GET {{baseUrl}}/appointment/person/delete?id={{AppointmentPerson_id}}
Authorization: {{authToken}}
Accept: application/json
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