人脸告警数据写入完成
This commit is contained in:
parent
4316a25f6e
commit
6b1519a5b6
@ -36,7 +36,7 @@ public class SisAlarmEventAttachments extends TenantEntity {
|
|||||||
/**
|
/**
|
||||||
* 时间图片id
|
* 时间图片id
|
||||||
*/
|
*/
|
||||||
private String ossId;
|
private Long ossId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1:图片,2:文件;3视频
|
* 1:图片,2:文件;3视频
|
||||||
|
@ -77,4 +77,7 @@ public class SisDeviceManage extends BaseEntity {
|
|||||||
* 设备组id
|
* 设备组id
|
||||||
*/
|
*/
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class SisAlarmEventAttachmentsBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 时间图片id
|
* 时间图片id
|
||||||
*/
|
*/
|
||||||
private String ossId;
|
private Long ossId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1:图片,2:文件;3视频
|
* 1:图片,2:文件;3视频
|
||||||
|
@ -40,7 +40,7 @@ public class SisAlarmEventAttachmentsVo implements Serializable {
|
|||||||
* 时间图片id
|
* 时间图片id
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "时间图片id")
|
@ExcelProperty(value = "时间图片id")
|
||||||
private String ossId;
|
private Long ossId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1:图片,2:文件;3视频
|
* 1:图片,2:文件;3视频
|
||||||
|
@ -2,6 +2,7 @@ package org.dromara.sis.service;
|
|||||||
|
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.sis.domain.SisAlarmEventAttachments;
|
||||||
import org.dromara.sis.domain.bo.SisAlarmEventAttachmentsBo;
|
import org.dromara.sis.domain.bo.SisAlarmEventAttachmentsBo;
|
||||||
import org.dromara.sis.domain.vo.SisAlarmEventAttachmentsVo;
|
import org.dromara.sis.domain.vo.SisAlarmEventAttachmentsVo;
|
||||||
|
|
||||||
@ -65,4 +66,13 @@ public interface ISisAlarmEventAttachmentsService {
|
|||||||
* @return 是否删除成功
|
* @return 是否删除成功
|
||||||
*/
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量写入事件附件表
|
||||||
|
*
|
||||||
|
* @param ls 附件数据
|
||||||
|
* @return 返回写入数量
|
||||||
|
*/
|
||||||
|
Boolean batchInsert(List<SisAlarmEventAttachments> ls);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ public interface ISisDeviceManageService {
|
|||||||
*/
|
*/
|
||||||
SisDeviceManageVo queryVoByDeviceIp(String deviceIp);
|
SisDeviceManageVo queryVoByDeviceIp(String deviceIp);
|
||||||
|
|
||||||
|
SisDeviceManage queryByDeviceIp(String deviceId);
|
||||||
/**
|
/**
|
||||||
* 查询设备数
|
* 查询设备数
|
||||||
*
|
*
|
||||||
|
@ -131,4 +131,9 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
|
|||||||
}
|
}
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean batchInsert(List<SisAlarmEventAttachments> ls) {
|
||||||
|
return baseMapper.insertBatch(ls);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,19 +12,20 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
|||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.resource.api.RemoteFileService;
|
import org.dromara.resource.api.RemoteFileService;
|
||||||
import org.dromara.resource.api.domain.RemoteFile;
|
import org.dromara.resource.api.domain.RemoteFile;
|
||||||
|
import org.dromara.sis.domain.SisAlarmEventAttachments;
|
||||||
import org.dromara.sis.domain.SisAlarmEvents;
|
import org.dromara.sis.domain.SisAlarmEvents;
|
||||||
|
import org.dromara.sis.domain.SisDeviceManage;
|
||||||
import org.dromara.sis.domain.bo.SisAlarmEventsBo;
|
import org.dromara.sis.domain.bo.SisAlarmEventsBo;
|
||||||
import org.dromara.sis.domain.vo.SisAlarmEventsVo;
|
import org.dromara.sis.domain.vo.SisAlarmEventsVo;
|
||||||
import org.dromara.sis.domain.vo.SisDeviceManageVo;
|
|
||||||
import org.dromara.sis.mapper.SisAlarmEventsMapper;
|
import org.dromara.sis.mapper.SisAlarmEventsMapper;
|
||||||
|
import org.dromara.sis.service.ISisAlarmEventAttachmentsService;
|
||||||
import org.dromara.sis.service.ISisAlarmEventsService;
|
import org.dromara.sis.service.ISisAlarmEventsService;
|
||||||
import org.dromara.sis.service.ISisDeviceManageService;
|
import org.dromara.sis.service.ISisDeviceManageService;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 告警Service业务层处理
|
* 告警Service业务层处理
|
||||||
@ -39,6 +40,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
|||||||
|
|
||||||
private final SisAlarmEventsMapper baseMapper;
|
private final SisAlarmEventsMapper baseMapper;
|
||||||
private final ISisDeviceManageService deviceManageService;
|
private final ISisDeviceManageService deviceManageService;
|
||||||
|
private final ISisAlarmEventAttachmentsService alarmEventAttachmentsService;
|
||||||
|
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private RemoteFileService remoteFileService;
|
private RemoteFileService remoteFileService;
|
||||||
@ -148,17 +150,49 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
|||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void createAlarmRecord(String deviceIp, Integer level, Integer type, byte[] smallImg, byte[] bigImg) {
|
public void createAlarmRecord(String deviceIp, Integer level, Integer type, byte[] smallImg, byte[] bigImg) {
|
||||||
// 校验设备信息
|
// 校验设备信息
|
||||||
SisDeviceManageVo sisDeviceManageVo = deviceManageService.queryVoByDeviceIp(deviceIp);
|
SisDeviceManage sisDeviceManage = deviceManageService.queryByDeviceIp(deviceIp);
|
||||||
if (sisDeviceManageVo == null) {
|
if (sisDeviceManage == null) {
|
||||||
log.error("设备信息不存在,放弃此条告警记录。");
|
log.error("设备信息不存在,放弃此条告警记录。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 生成时间信息
|
||||||
|
SisAlarmEvents alarmEvents = new SisAlarmEvents();
|
||||||
|
alarmEvents.setType(1L);
|
||||||
|
alarmEvents.setLevel(Long.valueOf(level));
|
||||||
|
alarmEvents.setDeviceIp(deviceIp);
|
||||||
|
alarmEvents.setDeviceName(sisDeviceManage.getDeviceName());
|
||||||
|
alarmEvents.setDeviceGroupId(sisDeviceManage.getId());
|
||||||
|
alarmEvents.setReportTime(new Date());
|
||||||
|
alarmEvents.setState(1);
|
||||||
|
alarmEvents.setTenantId(sisDeviceManage.getTenantId());
|
||||||
|
alarmEvents.setCreateDept(sisDeviceManage.getCreateDept());
|
||||||
|
int insert = this.baseMapper.insert(alarmEvents);
|
||||||
|
log.info("写入报警事件表完成,num={}", insert);
|
||||||
|
// 写入附件表
|
||||||
// 上传图片
|
// 上传图片
|
||||||
RemoteFile small = remoteFileService.uploadImg(smallImg);
|
List<SisAlarmEventAttachments> ls = new ArrayList<>();
|
||||||
RemoteFile big = remoteFileService.uploadImg(bigImg);
|
if (smallImg != null && smallImg.length > 0) {
|
||||||
|
ls.add(createEventAttachments(smallImg, alarmEvents, sisDeviceManage));
|
||||||
|
}
|
||||||
|
if (bigImg != null && bigImg.length > 0) {
|
||||||
|
ls.add(createEventAttachments(bigImg, alarmEvents, sisDeviceManage));
|
||||||
|
}
|
||||||
|
Boolean flag = alarmEventAttachmentsService.batchInsert(ls);
|
||||||
|
log.info("写入告警事件附件表完成, reslut={}, size={}", flag, ls.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SisAlarmEventAttachments createEventAttachments(byte[] img, SisAlarmEvents alarmEvents, SisDeviceManage sisDeviceManage) {
|
||||||
|
RemoteFile result = remoteFileService.uploadImg(img);
|
||||||
|
SisAlarmEventAttachments attachments = new SisAlarmEventAttachments();
|
||||||
|
attachments.setEventId(alarmEvents.getId());
|
||||||
|
attachments.setOssId(result.getOssId());
|
||||||
|
attachments.setType(1L);
|
||||||
|
attachments.setTenantId(sisDeviceManage.getTenantId());
|
||||||
|
attachments.setCreateDept(sisDeviceManage.getCreateDept());
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,14 @@ public class SisDeviceManageServiceImpl implements ISisDeviceManageService {
|
|||||||
public SisDeviceManageVo queryVoByDeviceIp(String deviceIp) {
|
public SisDeviceManageVo queryVoByDeviceIp(String deviceIp) {
|
||||||
LambdaQueryWrapper<SisDeviceManage> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<SisDeviceManage> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(SisDeviceManage::getDeviceIp, deviceIp);
|
lqw.eq(SisDeviceManage::getDeviceIp, deviceIp);
|
||||||
return baseMapper.selectVoById(lqw);
|
return baseMapper.selectVoOne(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SisDeviceManage queryByDeviceIp(String deviceId) {
|
||||||
|
LambdaQueryWrapper<SisDeviceManage> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(SisDeviceManage::getDeviceIp, deviceId);
|
||||||
|
return baseMapper.selectOne(lqw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user