Commit 12d14386 authored by 赵啸非's avatar 赵啸非

添加事件识别告警实现类

parent fa3d27ac
......@@ -46,6 +46,11 @@ CREATE TABLE mortals_xhx_appointment_records(
`monitorDevice` varchar(50) COMMENT '监测设备',
`checkInMethod` tinyint(1) DEFAULT '0' COMMENT '签到方式(0.自动签到,1.手动签到)',
`monitorCertificate` varchar(255) COMMENT '监测凭证',
`appointmentStatus` tinyint(1) DEFAULT '0' COMMENT '预约取号状态(0.未取号,1.取号中,2.取号完成)',
`flowNum` varchar(255) COMMENT '取号号码',
`flowTime` datetime COMMENT '取号时间',
`picUri` varchar(255) COMMENT '监控相对图片pic',
`serverIndexCode` varchar(255) COMMENT '图片资源唯一标识',
`createUserId` bigint(20) COMMENT '创建人id',
`createTime` datetime COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新人id',
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 预约取号状态(0.未取号,1.取号中,2.取号完成)枚举类
*
* @author zxfei
*/
public enum AppointmentStatusEnum {
未取号(0, "未取号"),
取号中(1, "取号中"),
取号完成(2, "取号完成");
private Integer value;
private String desc;
AppointmentStatusEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static AppointmentStatusEnum getByValue(Integer value) {
for (AppointmentStatusEnum appointmentStatusEnum : AppointmentStatusEnum.values()) {
if (appointmentStatusEnum.getValue() == value) {
return appointmentStatusEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (AppointmentStatusEnum item : AppointmentStatusEnum.values()) {
try {
boolean hasE = false;
for (Integer 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
......@@ -5,6 +5,7 @@ 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.framework.utils.ServletUtils;
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;
......@@ -66,7 +67,7 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
byte[] bytes = HttpUtil.downloadBytes(downUrl);
if(bytes.length>0){
InputStream inputStream = new ByteArrayInputStream(bytes);
MultipartFile file = getMultipartFile(inputStream, "photo.jpg");
MultipartFile file = ServletUtils.getMultipartFile(inputStream, "photo.jpg");
String filePath = uploadService.saveFileUpload(file, "file/fileupload",null);
personEntity.setPhoto(filePath);
personService.update(personEntity);
......@@ -80,66 +81,6 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
}
/**
* 获取封装得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) {
......
......@@ -8,7 +8,7 @@ import java.util.List;
* 预约签到记录 DAO接口
*
* @author zxfei
* @date 2023-04-09
* @date 2023-04-17
*/
public interface AppointmentRecordsDao extends ICRUDDao<AppointmentRecordsEntity,Long>{
......
......@@ -11,7 +11,7 @@ import java.util.List;
* 预约签到记录DaoImpl DAO接口
*
* @author zxfei
* @date 2023-04-09
* @date 2023-04-17
*/
@Repository("appointmentRecordsDao")
public class AppointmentRecordsDaoImpl extends BaseCRUDDaoMybatis<AppointmentRecordsEntity,Long> implements AppointmentRecordsDao {
......
......@@ -11,7 +11,7 @@ import com.mortals.xhx.module.appointment.model.vo.AppointmentRecordsVo;
* 预约签到记录实体对象
*
* @author zxfei
* @date 2023-04-09
* @date 2023-04-17
*/
public class AppointmentRecordsEntity extends AppointmentRecordsVo {
......@@ -80,6 +80,29 @@ public class AppointmentRecordsEntity extends AppointmentRecordsVo {
*/
@Excel(name = "监测凭证")
private String monitorCertificate;
/**
* 预约取号状态(0.未取号,1.取号中,2.取号完成)
*/
@Excel(name = "预约取号状态", readConverterExp = "0=未取号,1=取号中,2=取号完成")
private Integer appointmentStatus;
/**
* 取号号码
*/
@Excel(name = "取号号码")
private String flowNum;
/**
* 取号时间
*/
@Excel(name = "取号时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date flowTime;
/**
* 监控相对图片pic
*/
private String picUri;
/**
* 图片资源唯一标识
*/
private String serverIndexCode;
......@@ -266,6 +289,76 @@ public class AppointmentRecordsEntity extends AppointmentRecordsVo {
public void setMonitorCertificate(String monitorCertificate){
this.monitorCertificate = monitorCertificate;
}
/**
* 获取 预约取号状态(0.未取号,1.取号中,2.取号完成)
* @return Integer
*/
public Integer getAppointmentStatus(){
return appointmentStatus;
}
/**
* 设置 预约取号状态(0.未取号,1.取号中,2.取号完成)
* @param appointmentStatus
*/
public void setAppointmentStatus(Integer appointmentStatus){
this.appointmentStatus = appointmentStatus;
}
/**
* 获取 取号号码
* @return String
*/
public String getFlowNum(){
return flowNum;
}
/**
* 设置 取号号码
* @param flowNum
*/
public void setFlowNum(String flowNum){
this.flowNum = flowNum;
}
/**
* 获取 取号时间
* @return Date
*/
public Date getFlowTime(){
return flowTime;
}
/**
* 设置 取号时间
* @param flowTime
*/
public void setFlowTime(Date flowTime){
this.flowTime = flowTime;
}
/**
* 获取 监控相对图片pic
* @return String
*/
public String getPicUri(){
return picUri;
}
/**
* 设置 监控相对图片pic
* @param picUri
*/
public void setPicUri(String picUri){
this.picUri = picUri;
}
/**
* 获取 图片资源唯一标识
* @return String
*/
public String getServerIndexCode(){
return serverIndexCode;
}
/**
* 设置 图片资源唯一标识
* @param serverIndexCode
*/
public void setServerIndexCode(String serverIndexCode){
this.serverIndexCode = serverIndexCode;
}
......@@ -301,6 +394,11 @@ public class AppointmentRecordsEntity extends AppointmentRecordsVo {
sb.append(",monitorDevice:").append(getMonitorDevice());
sb.append(",checkInMethod:").append(getCheckInMethod());
sb.append(",monitorCertificate:").append(getMonitorCertificate());
sb.append(",appointmentStatus:").append(getAppointmentStatus());
sb.append(",flowNum:").append(getFlowNum());
sb.append(",flowTime:").append(getFlowTime());
sb.append(",picUri:").append(getPicUri());
sb.append(",serverIndexCode:").append(getServerIndexCode());
return sb.toString();
}
......@@ -331,5 +429,15 @@ public class AppointmentRecordsEntity extends AppointmentRecordsVo {
this.checkInMethod = 0;
this.monitorCertificate = "";
this.appointmentStatus = 0;
this.flowNum = "";
this.flowTime = null;
this.picUri = "";
this.serverIndexCode = "";
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import lombok.Data;
* 预约签到记录视图对象
*
* @author zxfei
* @date 2023-04-09
* @date 2023-04-17
*/
@Data
public class AppointmentRecordsVo extends BaseEntityLong {
......
package com.mortals.xhx.module.appointment.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.appointment.model.AppointmentRecordsEntity;
import org.springframework.web.bind.annotation.RequestBody;
/**
* AppointmentRecordsService
*
* 预约签到记录 service接口
*
* @author zxfei
* @date 2023-04-09
* @date 2023-04-17
*/
public interface AppointmentRecordsService extends ICRUDService<AppointmentRecordsEntity,Long>{
/**
* 停止群众预约推送服务
* @param appointmentRecordsEntity
* @param context
* @return
*/
Rest<String> stopService(AppointmentRecordsEntity appointmentRecordsEntity, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.appointment.service.impl;
import com.mortals.framework.common.Rest;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -12,14 +11,9 @@ import com.mortals.xhx.module.appointment.service.AppointmentRecordsService;
* 预约签到记录 service实现
*
* @author zxfei
* @date 2023-04-09
* @date 2023-04-17
*/
@Service("appointmentRecordsService")
public class AppointmentRecordsServiceImpl extends AbstractCRUDServiceImpl<AppointmentRecordsDao, AppointmentRecordsEntity, Long> implements AppointmentRecordsService {
@Override
public Rest<String> stopService(AppointmentRecordsEntity appointmentRecordsEntity, Context context) {
//todo 停止群众推送服务
return Rest.ok("服务停止成功");
}
}
\ No newline at end of file
package com.mortals.xhx.module.appointment.web;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.EnabledEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.device.model.DeviceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -32,7 +27,7 @@ import static com.mortals.framework.ap.SysConstains.*;
* 预约签到记录
*
* @author zxfei
* @date 2023-04-09
* @date 2023-04-17
*/
@RestController
@RequestMapping("appointment/records")
......@@ -48,35 +43,9 @@ public class AppointmentRecordsController extends BaseCRUDJsonBodyMappingControl
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "checkInMethod", paramService.getParamBySecondOrganize("AppointmentRecords","checkInMethod"));
this.addDict(model, "appointmentStatus", paramService.getParamBySecondOrganize("AppointmentRecords","appointmentStatus"));
super.init(model, context);
}
/**
* 群众停止服务
*/
@PostMapping(value = "stopService")
public String stopService(@RequestBody AppointmentRecordsEntity appointmentRecordsEntity) {
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>();
String busiDesc = this.getModuleDesc() + "停止服务";
try {
Rest<String> rest = this.service.stopService(appointmentRecordsEntity, getContext());
if(YesNoEnum.YES.getValue()==rest.getCode()){
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, rest.getMsg());
}else {
throw new AppException(rest.getMsg());
}
} catch (Exception e) {
log.error(busiDesc, e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
}
\ No newline at end of file
package com.mortals.xhx.module.hik.event.model;
import lombok.Data;
/**
* 公用参数
* @author:
* @date: 2023/4/17 9:39
*/
@Data
public class CommonCons {
}
package com.mortals.xhx.module.hik.event.service.impl;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.common.code.HikEventTypeEnum;
import com.mortals.xhx.module.hik.event.model.req.callback.EventData;
import com.mortals.xhx.module.hik.event.model.req.callback.EventsItem;
import java.util.Date;
/**
* @author:
* @date: 2023/4/17 9:22
*/
public abstract class EventTypeAbstract {
private int type;
abstract int getType();
public abstract void saveEventData(EventsItem event);
public static EventTypeAbstract newType(int type) {
if (type == HikEventTypeEnum.重点人员识别事件.getValue()) {
return new BlackPlanRecoginze(type);
} else if (type == HikEventTypeEnum.陌生人员识别事件.getValue()) {
return new StrangerRecoginze(type);
} else {
throw new AppException(String.format("未知的类型码:%s", type));
}
}
public EventTypeAbstract(int type) {
this.type = type;
}
}
......@@ -113,9 +113,15 @@ public class HikEventServiceImpl extends AbstractHikService implements IHikEvent
//String similarity = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_SIMILARITY, "0.8");
Params params = req.getParams();
if (HikAbilityEnum.人脸识别事件.getValue().equals(params.getAbility())) {
for (EventsItem event : params.getEvents()) {
EventData eventData = event.getData();
EventTypeAbstract eventTypeAbstract = EventTypeAbstract.newType(event.getEventType());
eventTypeAbstract.saveEventData(event);
// assessmentAbstract.initBidData(projectEntity, entity, supplierEntities);
/* EventData eventData = event.getData();
//识别结果
FaceRecognitionResult faceRecognitionResult = eventData.getFaceRecognitionResult();
//抓拍信息
......@@ -130,7 +136,6 @@ public class HikEventServiceImpl extends AbstractHikService implements IHikEvent
//保存当前识别结果到记录表中
}
}
} else if (HikEventTypeEnum.陌生人员识别事件.getValue() == event.getEventType()) {
//不论识别结果 保存流量数据
RealtimeDataflowEntity realtimeDataflowEntity = new RealtimeDataflowEntity();
......@@ -140,17 +145,13 @@ public class HikEventServiceImpl extends AbstractHikService implements IHikEvent
realtimeDataflowEntity.setPicUri(eventData.getFaceRecognitionResult().getSnap().getFaceUrl());
realtimeDataflowEntity.setEventId(event.getEventId());
realtimeDataflowEntity.setEventType(HikEventTypeEnum.陌生人员识别事件.getValue().longValue());
realtimeDataflowEntity.setCreateUserId(1L);
realtimeDataflowEntity.setCreateTime(new Date());
realtimeDataflowEntity.setCreateUserName("system");
realtimeDataflowEntity.initAttrValue();
//dataflowService.save()
}
dataflowService.save(realtimeDataflowEntity);
}*/
}
......
package com.mortals.xhx.module.hik.event.service.impl;
import com.mortals.xhx.common.code.HikEventTypeEnum;
import com.mortals.xhx.module.hik.event.model.req.callback.EventData;
import com.mortals.xhx.module.hik.event.model.req.callback.EventsItem;
import com.mortals.xhx.module.hik.event.model.req.callback.FaceRecognitionResult;
import com.mortals.xhx.module.hik.event.model.req.callback.Snap;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowEntity;
import com.mortals.xhx.module.realtime.service.RealtimeDataflowService;
import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.stream.Collectors;
/**
* 陌生人员识别
*
* @author:
* @date: 2023/4/17 9:27
*/
@Slf4j
public class StrangerRecoginze extends EventTypeAbstract {
private RealtimeDataflowService dataflowService;
public StrangerRecoginze(int type) {
super(type);
this.dataflowService = SpringUtils.getBean(RealtimeDataflowService.class);
}
@Override
int getType() {
return HikEventTypeEnum.重点人员识别事件.getValue();
}
@Override
public void saveEventData(EventsItem event) {
EventData eventData = event.getData();
//识别结果
FaceRecognitionResult faceRecognitionResult = eventData.getFaceRecognitionResult();
//抓拍信息
Snap snap = faceRecognitionResult.getSnap();
//不论识别结果 保存流量数据
RealtimeDataflowEntity realtimeDataflowEntity = new RealtimeDataflowEntity();
realtimeDataflowEntity.setDetectTime(event.getHappenTime());
String resIndexCodes = eventData.getResInfo().stream().map(i -> i.getIndexCode()).collect(Collectors.joining(","));
realtimeDataflowEntity.setDevice(resIndexCodes);
realtimeDataflowEntity.setPicUri(snap.getFaceUrl());
realtimeDataflowEntity.setEventId(event.getEventId());
realtimeDataflowEntity.setEventType(HikEventTypeEnum.陌生人员识别事件.getValue().longValue());
realtimeDataflowEntity.setCreateUserId(1L);
realtimeDataflowEntity.setCreateTime(new Date());
realtimeDataflowEntity.setCreateUserName("system");
realtimeDataflowEntity.initAttrValue();
dataflowService.save(realtimeDataflowEntity);
}
}
......@@ -274,7 +274,7 @@ public class MonitorAlarmEntity extends MonitorAlarmVo {
this.idNumber = "";
this.identifyNum = 0;
this.identifyNum = 1;
this.lastIdentifyTime = null;
......
package com.mortals.xhx.module.person.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.upload.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -13,6 +16,9 @@ import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.service.PersonService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -35,6 +41,8 @@ public class PersonController extends BaseCRUDJsonBodyMappingController<PersonSe
@Autowired
private ParamService paramService;
@Autowired
private UploadService uploadService;
public PersonController(){
super.setModuleDesc( "注册人员");
......@@ -48,5 +56,15 @@ public class PersonController extends BaseCRUDJsonBodyMappingController<PersonSe
super.init(model, context);
}
@Override
public void doExportFileAfter(byte[] data, Context context) throws AppException {
InputStream inputStream = new ByteArrayInputStream(data);
MultipartFile file = ServletUtils.getMultipartFile(inputStream, "photo.jpg");
String filePath = uploadService.saveFileUpload(file, "file/fileupload",null);
}
@Override
public void doImportExcelAfter(MultipartFile file, List<PersonEntity> list, Context context) throws AppException {
String filePath = uploadService.saveFileUpload(file, "file/fileupload",null);
}
}
\ No newline at end of file
package com.mortals.xhx.module.realtime.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* 人员发现记录视图对象
......
......@@ -30,19 +30,24 @@ Authorization: {{authToken}}
Content-Type: application/json
{
"siteId":771,
"siteName":"a4pdxm",
"personId":690,
"name":"0i4ese",
"contactInfo":"xh1x2r",
"idNumber":"ald5ri",
"reservationService":"pxfv7b",
"reservationNumber":"zt82er",
"monitorTime":"1680969600000",
"monitorDeviceId":674,
"monitorDevice":"loxzwu",
"siteId":526,
"siteName":"2pbm62",
"personId":727,
"name":"jkowci",
"contactInfo":"f0y3am",
"idNumber":"v9yk7u",
"reservationService":"m6ho0v",
"reservationNumber":"90im19",
"monitorTime":"1681660800000",
"monitorDeviceId":467,
"monitorDevice":"acwtwi",
"checkInMethod":0,
"monitorCertificate":"4s4yk4",
"monitorCertificate":"1p60xj",
"appointmentStatus":0,
"flowNum":"pldacl",
"flowTime":"1681660800000",
"picUri":"8pp1cq",
"serverIndexCode":"tpmae4",
}
> {%
......
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