Compare commits

...

2 Commits

Author SHA1 Message Date
15683799673
59f8e0fc2f 人脸告警数据写入完成
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2025-08-05 00:44:43 +08:00
15683799673
6b1519a5b6 人脸告警数据写入完成 2025-08-05 00:44:13 +08:00
9 changed files with 77 additions and 18 deletions

View File

@@ -36,7 +36,7 @@ public class SisAlarmEventAttachments extends TenantEntity {
/** /**
* 时间图片id * 时间图片id
*/ */
private String ossId; private Long ossId;
/** /**
* 1图片2文件3视频 * 1图片2文件3视频

View File

@@ -77,4 +77,7 @@ public class SisDeviceManage extends BaseEntity {
* 设备组id * 设备组id
*/ */
private Long groupId; private Long groupId;
private String tenantId;
} }

View File

@@ -35,7 +35,7 @@ public class SisAlarmEventAttachmentsBo extends BaseEntity {
/** /**
* 时间图片id * 时间图片id
*/ */
private String ossId; private Long ossId;
/** /**
* 1图片2文件3视频 * 1图片2文件3视频

View File

@@ -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视频

View File

@@ -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);
} }

View File

@@ -76,6 +76,7 @@ public interface ISisDeviceManageService {
*/ */
SisDeviceManageVo queryVoByDeviceIp(String deviceIp); SisDeviceManageVo queryVoByDeviceIp(String deviceIp);
SisDeviceManage queryByDeviceIp(String deviceId);
/** /**
* 查询设备数 * 查询设备数
* *

View File

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
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.SisAlarmEventAttachments;
@@ -40,7 +39,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
* @return 【请填写功能名称】 * @return 【请填写功能名称】
*/ */
@Override @Override
public SisAlarmEventAttachmentsVo queryById(Long id){ public SisAlarmEventAttachmentsVo queryById(Long id) {
return baseMapper.selectVoById(id); return baseMapper.selectVoById(id);
} }
@@ -75,7 +74,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
LambdaQueryWrapper<SisAlarmEventAttachments> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<SisAlarmEventAttachments> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(SisAlarmEventAttachments::getId); lqw.orderByAsc(SisAlarmEventAttachments::getId);
lqw.eq(bo.getEventId() != null, SisAlarmEventAttachments::getEventId, bo.getEventId()); lqw.eq(bo.getEventId() != null, SisAlarmEventAttachments::getEventId, bo.getEventId());
lqw.eq(StringUtils.isNotBlank(bo.getOssId()), SisAlarmEventAttachments::getOssId, bo.getOssId()); lqw.eq(bo.getOssId() != null, SisAlarmEventAttachments::getOssId, bo.getOssId());
lqw.eq(bo.getType() != null, SisAlarmEventAttachments::getType, bo.getType()); lqw.eq(bo.getType() != null, SisAlarmEventAttachments::getType, bo.getType());
return lqw; return lqw;
} }
@@ -113,7 +112,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
/** /**
* 保存前的数据校验 * 保存前的数据校验
*/ */
private void validEntityBeforeSave(SisAlarmEventAttachments entity){ private void validEntityBeforeSave(SisAlarmEventAttachments entity) {
//TODO 做一些数据校验,如唯一约束 //TODO 做一些数据校验,如唯一约束
} }
@@ -126,9 +125,14 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
*/ */
@Override @Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){ if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验 //TODO 做一些业务上的校验,判断是否需要校验
} }
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }
@Override
public Boolean batchInsert(List<SisAlarmEventAttachments> ls) {
return baseMapper.insertBatch(ls);
}
} }

View File

@@ -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;
}
} }

View File

@@ -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