Compare commits
2 Commits
4316a25f6e
...
59f8e0fc2f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
59f8e0fc2f | ||
![]() |
6b1519a5b6 |
@ -36,7 +36,7 @@ public class SisAlarmEventAttachments extends TenantEntity {
|
||||
/**
|
||||
* 时间图片id
|
||||
*/
|
||||
private String ossId;
|
||||
private Long ossId;
|
||||
|
||||
/**
|
||||
* 1:图片,2:文件;3视频
|
||||
|
@ -77,4 +77,7 @@ public class SisDeviceManage extends BaseEntity {
|
||||
* 设备组id
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class SisAlarmEventAttachmentsBo extends BaseEntity {
|
||||
/**
|
||||
* 时间图片id
|
||||
*/
|
||||
private String ossId;
|
||||
private Long ossId;
|
||||
|
||||
/**
|
||||
* 1:图片,2:文件;3视频
|
||||
|
@ -40,7 +40,7 @@ public class SisAlarmEventAttachmentsVo implements Serializable {
|
||||
* 时间图片id
|
||||
*/
|
||||
@ExcelProperty(value = "时间图片id")
|
||||
private String ossId;
|
||||
private Long ossId;
|
||||
|
||||
/**
|
||||
* 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.TableDataInfo;
|
||||
import org.dromara.sis.domain.SisAlarmEventAttachments;
|
||||
import org.dromara.sis.domain.bo.SisAlarmEventAttachmentsBo;
|
||||
import org.dromara.sis.domain.vo.SisAlarmEventAttachmentsVo;
|
||||
|
||||
@ -65,4 +66,13 @@ public interface ISisAlarmEventAttachmentsService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
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);
|
||||
|
||||
SisDeviceManage queryByDeviceIp(String deviceId);
|
||||
/**
|
||||
* 查询设备数
|
||||
*
|
||||
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.TableDataInfo;
|
||||
import org.dromara.sis.domain.SisAlarmEventAttachments;
|
||||
@ -40,7 +39,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public SisAlarmEventAttachmentsVo queryById(Long id){
|
||||
public SisAlarmEventAttachmentsVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
@ -75,7 +74,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
|
||||
LambdaQueryWrapper<SisAlarmEventAttachments> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(SisAlarmEventAttachments::getId);
|
||||
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());
|
||||
return lqw;
|
||||
}
|
||||
@ -113,7 +112,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(SisAlarmEventAttachments entity){
|
||||
private void validEntityBeforeSave(SisAlarmEventAttachments entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@ -126,9 +125,14 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
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.resource.api.RemoteFileService;
|
||||
import org.dromara.resource.api.domain.RemoteFile;
|
||||
import org.dromara.sis.domain.SisAlarmEventAttachments;
|
||||
import org.dromara.sis.domain.SisAlarmEvents;
|
||||
import org.dromara.sis.domain.SisDeviceManage;
|
||||
import org.dromara.sis.domain.bo.SisAlarmEventsBo;
|
||||
import org.dromara.sis.domain.vo.SisAlarmEventsVo;
|
||||
import org.dromara.sis.domain.vo.SisDeviceManageVo;
|
||||
import org.dromara.sis.mapper.SisAlarmEventsMapper;
|
||||
import org.dromara.sis.service.ISisAlarmEventAttachmentsService;
|
||||
import org.dromara.sis.service.ISisAlarmEventsService;
|
||||
import org.dromara.sis.service.ISisDeviceManageService;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 告警Service业务层处理
|
||||
@ -39,6 +40,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
|
||||
private final SisAlarmEventsMapper baseMapper;
|
||||
private final ISisDeviceManageService deviceManageService;
|
||||
private final ISisAlarmEventAttachmentsService alarmEventAttachmentsService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteFileService remoteFileService;
|
||||
@ -148,17 +150,49 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
|
||||
@Async
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createAlarmRecord(String deviceIp, Integer level, Integer type, byte[] smallImg, byte[] bigImg) {
|
||||
// 校验设备信息
|
||||
SisDeviceManageVo sisDeviceManageVo = deviceManageService.queryVoByDeviceIp(deviceIp);
|
||||
if (sisDeviceManageVo == null) {
|
||||
SisDeviceManage sisDeviceManage = deviceManageService.queryByDeviceIp(deviceIp);
|
||||
if (sisDeviceManage == null) {
|
||||
log.error("设备信息不存在,放弃此条告警记录。");
|
||||
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);
|
||||
RemoteFile big = remoteFileService.uploadImg(bigImg);
|
||||
|
||||
List<SisAlarmEventAttachments> ls = new ArrayList<>();
|
||||
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) {
|
||||
LambdaQueryWrapper<SisDeviceManage> lqw = Wrappers.lambdaQuery();
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user