Merge remote-tracking branch 'origin/master'
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
package org.dromara.sis.domain;
|
||||
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 电梯⇄楼层⇄通道关联对象 sis_elevator_floor_channel_ref
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-08-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sis_elevator_floor_channel_ref")
|
||||
public class SisElevatorFloorChannelRef extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 楼层id
|
||||
*/
|
||||
private Long floorId;
|
||||
|
||||
/**
|
||||
* 电梯id
|
||||
*/
|
||||
private Long elevatorId;
|
||||
|
||||
/**
|
||||
* 内部通道号
|
||||
*/
|
||||
private Long inChannel;
|
||||
|
||||
/**
|
||||
* 外部通道号
|
||||
*/
|
||||
private Long outChannel;
|
||||
|
||||
|
||||
}
|
@@ -35,7 +35,7 @@ public class SisAlarmEventAttachmentsBo extends BaseEntity {
|
||||
/**
|
||||
* 时间图片id
|
||||
*/
|
||||
private String ossId;
|
||||
private Long ossId;
|
||||
|
||||
/**
|
||||
* 1:图片,2:文件;3视频
|
||||
|
@@ -0,0 +1,52 @@
|
||||
package org.dromara.sis.domain.bo;
|
||||
|
||||
import org.dromara.sis.domain.SisElevatorFloorChannelRef;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 电梯⇄楼层⇄通道关联业务对象 sis_elevator_floor_channel_ref
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-08-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = SisElevatorFloorChannelRef.class, reverseConvertGenerate = false)
|
||||
public class SisElevatorFloorChannelRefBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 楼层id
|
||||
*/
|
||||
@NotNull(message = "楼层id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long floorId;
|
||||
|
||||
/**
|
||||
* 电梯id
|
||||
*/
|
||||
@NotNull(message = "电梯id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long elevatorId;
|
||||
|
||||
/**
|
||||
* 内部通道号
|
||||
*/
|
||||
private Long inChannel;
|
||||
|
||||
/**
|
||||
* 外部通道号
|
||||
*/
|
||||
private Long outChannel;
|
||||
|
||||
|
||||
}
|
@@ -135,12 +135,12 @@ public class SisElevatorInfoBo extends BaseEntity {
|
||||
/**
|
||||
* 建筑id
|
||||
*/
|
||||
@NotNull(message = "建筑不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long buildingId;
|
||||
|
||||
/**
|
||||
* 单元编码
|
||||
*/
|
||||
@NotNull(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long unitId;
|
||||
|
||||
/**
|
||||
@@ -153,6 +153,19 @@ public class SisElevatorInfoBo extends BaseEntity {
|
||||
*/
|
||||
private DeviceInfo elevatorControlDeviceId;
|
||||
|
||||
/**
|
||||
* 通道信息
|
||||
*/
|
||||
private List<ChannelInfo> channels;
|
||||
|
||||
|
||||
@Data
|
||||
public static class ChannelInfo {
|
||||
private Long floorId;
|
||||
private Long inChannel;
|
||||
private Long outChannel;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class DeviceInfo {
|
||||
|
@@ -40,7 +40,7 @@ public class SisAlarmEventAttachmentsVo implements Serializable {
|
||||
* 时间图片id
|
||||
*/
|
||||
@ExcelProperty(value = "时间图片id")
|
||||
private String ossId;
|
||||
private Long ossId;
|
||||
|
||||
/**
|
||||
* 1:图片,2:文件;3视频
|
||||
|
@@ -0,0 +1,62 @@
|
||||
package org.dromara.sis.domain.vo;
|
||||
|
||||
import org.dromara.sis.domain.SisElevatorFloorChannelRef;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 电梯⇄楼层⇄通道关联视图对象 sis_elevator_floor_channel_ref
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-08-04
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = SisElevatorFloorChannelRef.class)
|
||||
public class SisElevatorFloorChannelRefVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ExcelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 楼层id
|
||||
*/
|
||||
@ExcelProperty(value = "楼层id")
|
||||
private Long floorId;
|
||||
|
||||
/**
|
||||
* 电梯id
|
||||
*/
|
||||
@ExcelProperty(value = "电梯id")
|
||||
private Long elevatorId;
|
||||
|
||||
/**
|
||||
* 内部通道号
|
||||
*/
|
||||
@ExcelProperty(value = "内部通道号")
|
||||
private Long inChannel;
|
||||
|
||||
/**
|
||||
* 外部通道号
|
||||
*/
|
||||
@ExcelProperty(value = "外部通道号")
|
||||
private Long outChannel;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package org.dromara.sis.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.sis.domain.SisElevatorFloorChannelRef;
|
||||
import org.dromara.sis.domain.vo.SisElevatorFloorChannelRefVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 电梯⇄楼层⇄通道关联Mapper接口
|
||||
*
|
||||
* @author lsm
|
||||
* @since 2025-08-04
|
||||
*/
|
||||
@Mapper
|
||||
public interface SisElevatorFloorChannelRefMapper extends BaseMapperPlus<SisElevatorFloorChannelRef, SisElevatorFloorChannelRefVo> {
|
||||
|
||||
}
|
@@ -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);
|
||||
/**
|
||||
* 查询设备数
|
||||
*
|
||||
|
@@ -0,0 +1,78 @@
|
||||
package org.dromara.sis.service;
|
||||
|
||||
import org.dromara.sis.domain.SisElevatorFloorChannelRef;
|
||||
import org.dromara.sis.domain.vo.SisElevatorFloorChannelRefVo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorFloorChannelRefBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 电梯⇄楼层⇄通道关联Service接口
|
||||
*
|
||||
* @author lsm
|
||||
* @since 2025-08-04
|
||||
*/
|
||||
public interface ISisElevatorFloorChannelRefService {
|
||||
|
||||
/**
|
||||
* 查询电梯⇄楼层⇄通道关联
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 电梯⇄楼层⇄通道关联
|
||||
*/
|
||||
SisElevatorFloorChannelRefVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询电梯⇄楼层⇄通道关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 电梯⇄楼层⇄通道关联分页列表
|
||||
*/
|
||||
TableDataInfo<SisElevatorFloorChannelRefVo> queryPageList(SisElevatorFloorChannelRefBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的电梯⇄楼层⇄通道关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 电梯⇄楼层⇄通道关联列表
|
||||
*/
|
||||
List<SisElevatorFloorChannelRefVo> queryList(SisElevatorFloorChannelRefBo bo);
|
||||
|
||||
/**
|
||||
* 新增电梯⇄楼层⇄通道关联
|
||||
*
|
||||
* @param bo 电梯⇄楼层⇄通道关联
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(SisElevatorFloorChannelRefBo bo);
|
||||
|
||||
/**
|
||||
* 修改电梯⇄楼层⇄通道关联
|
||||
*
|
||||
* @param bo 电梯⇄楼层⇄通道关联
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(SisElevatorFloorChannelRefBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除电梯⇄楼层⇄通道关联信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 批量增加电梯⇄楼层⇄通道关联信息
|
||||
*
|
||||
* @param elevatorId 电梯id
|
||||
* @param bo 电梯⇄楼层⇄通道关联
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
Boolean batchInsert(Long elevatorId, Collection<SisElevatorFloorChannelRef> bo);
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -11,19 +11,21 @@ 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.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业务层处理
|
||||
@@ -38,9 +40,11 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
|
||||
private final SisAlarmEventsMapper baseMapper;
|
||||
private final ISisDeviceManageService deviceManageService;
|
||||
private final ISisAlarmEventAttachmentsService alarmEventAttachmentsService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 查询告警
|
||||
*
|
||||
@@ -48,7 +52,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
* @return 告警
|
||||
*/
|
||||
@Override
|
||||
public SisAlarmEventsVo queryById(Long id){
|
||||
public SisAlarmEventsVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
@@ -125,7 +129,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(SisAlarmEvents entity){
|
||||
private void validEntityBeforeSave(SisAlarmEvents entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@@ -138,7 +142,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
@@ -146,19 +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);
|
||||
// 写入附件表
|
||||
// 上传图片
|
||||
remoteFileService.upload(smallImg);
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
@@ -0,0 +1,157 @@
|
||||
package org.dromara.sis.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.sis.domain.bo.SisElevatorFloorChannelRefBo;
|
||||
import org.dromara.sis.domain.vo.SisElevatorFloorChannelRefVo;
|
||||
import org.dromara.sis.domain.SisElevatorFloorChannelRef;
|
||||
import org.dromara.sis.mapper.SisElevatorFloorChannelRefMapper;
|
||||
import org.dromara.sis.service.ISisElevatorFloorChannelRefService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 电梯⇄楼层⇄通道关联Service业务层处理
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-08-04
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SisElevatorFloorChannelRefServiceImpl implements ISisElevatorFloorChannelRefService {
|
||||
|
||||
private final SisElevatorFloorChannelRefMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询电梯⇄楼层⇄通道关联
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 电梯⇄楼层⇄通道关联
|
||||
*/
|
||||
@Override
|
||||
public SisElevatorFloorChannelRefVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询电梯⇄楼层⇄通道关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 电梯⇄楼层⇄通道关联分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SisElevatorFloorChannelRefVo> queryPageList(SisElevatorFloorChannelRefBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SisElevatorFloorChannelRef> lqw = buildQueryWrapper(bo);
|
||||
Page<SisElevatorFloorChannelRefVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的电梯⇄楼层⇄通道关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 电梯⇄楼层⇄通道关联列表
|
||||
*/
|
||||
@Override
|
||||
public List<SisElevatorFloorChannelRefVo> queryList(SisElevatorFloorChannelRefBo bo) {
|
||||
LambdaQueryWrapper<SisElevatorFloorChannelRef> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SisElevatorFloorChannelRef> buildQueryWrapper(SisElevatorFloorChannelRefBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SisElevatorFloorChannelRef> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(SisElevatorFloorChannelRef::getId);
|
||||
lqw.eq(bo.getFloorId() != null, SisElevatorFloorChannelRef::getFloorId, bo.getFloorId());
|
||||
lqw.eq(bo.getElevatorId() != null, SisElevatorFloorChannelRef::getElevatorId, bo.getElevatorId());
|
||||
lqw.eq(bo.getInChannel() != null, SisElevatorFloorChannelRef::getInChannel, bo.getInChannel());
|
||||
lqw.eq(bo.getOutChannel() != null, SisElevatorFloorChannelRef::getOutChannel, bo.getOutChannel());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增电梯⇄楼层⇄通道关联
|
||||
*
|
||||
* @param bo 电梯⇄楼层⇄通道关联
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(SisElevatorFloorChannelRefBo bo) {
|
||||
SisElevatorFloorChannelRef add = MapstructUtils.convert(bo, SisElevatorFloorChannelRef.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改电梯⇄楼层⇄通道关联
|
||||
*
|
||||
* @param bo 电梯⇄楼层⇄通道关联
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(SisElevatorFloorChannelRefBo bo) {
|
||||
SisElevatorFloorChannelRef update = MapstructUtils.convert(bo, SisElevatorFloorChannelRef.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(SisElevatorFloorChannelRef entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除电梯⇄楼层⇄通道关联信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量增加电梯⇄楼层⇄通道关联信息
|
||||
*
|
||||
* @param elevatorId 电梯id
|
||||
* @param bo 电梯⇄楼层⇄通道关联
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean batchInsert(Long elevatorId, Collection<SisElevatorFloorChannelRef> bo) {
|
||||
// 先删除通道关系
|
||||
LambdaQueryWrapper<SisElevatorFloorChannelRef> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SisElevatorFloorChannelRef::getElevatorId, elevatorId);
|
||||
baseMapper.delete(lqw);
|
||||
|
||||
boolean flag = baseMapper.insertBatch(bo);
|
||||
Assert.isTrue(flag, "批量增加电梯⇄楼层⇄通道关联信息失败");
|
||||
return flag;
|
||||
}
|
||||
}
|
@@ -13,15 +13,17 @@ 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.property.api.RemoteUnitService;
|
||||
import org.dromara.property.api.domain.vo.RemoteUnitVo;
|
||||
import org.dromara.property.api.RemoteBuildingService;
|
||||
import org.dromara.property.api.domain.vo.RemoteBuildingVo;
|
||||
import org.dromara.sis.domain.SisDeviceBindRef;
|
||||
import org.dromara.sis.domain.SisElevatorFloorChannelRef;
|
||||
import org.dromara.sis.domain.SisElevatorInfo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorInfoBo;
|
||||
import org.dromara.sis.domain.enums.ControlTypeEnum;
|
||||
import org.dromara.sis.domain.vo.SisElevatorInfoVo;
|
||||
import org.dromara.sis.mapper.SisElevatorInfoMapper;
|
||||
import org.dromara.sis.service.ISisDeviceBindRefService;
|
||||
import org.dromara.sis.service.ISisElevatorFloorChannelRefService;
|
||||
import org.dromara.sis.service.ISisElevatorInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -43,9 +45,10 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService {
|
||||
|
||||
private final SisElevatorInfoMapper baseMapper;
|
||||
private final ISisDeviceBindRefService deviceBindRefService;
|
||||
private final ISisElevatorFloorChannelRefService elevatorFloorChannelRefService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteUnitService remoteUnitService;
|
||||
private RemoteBuildingService remoteBuildingService;
|
||||
|
||||
/**
|
||||
* 查询电梯基本信息
|
||||
@@ -137,17 +140,23 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(SisElevatorInfoBo bo) {
|
||||
// 验证单元是否存在
|
||||
RemoteUnitVo remoteUnitVo = remoteUnitService.queryUnitById(bo.getUnitId());
|
||||
Assert.notNull(remoteUnitVo, "社区单元信息不存在。");
|
||||
// 验证建筑是否存在
|
||||
RemoteBuildingVo remoteBuildingVo = remoteBuildingService.queryBuildingById(bo.getBuildingId());
|
||||
Assert.notNull(remoteBuildingVo, "建筑信息不存在。");
|
||||
|
||||
// 数据转换
|
||||
SisElevatorInfo add = MapstructUtils.convert(bo, SisElevatorInfo.class);
|
||||
Assert.notNull(add, "电梯信息处理失败。");
|
||||
add.setCommunityId(remoteUnitVo.getCommunityId());
|
||||
add.setBuildingId(remoteUnitVo.getBuildingId());
|
||||
|
||||
assert add != null;
|
||||
add.setCommunityId(remoteBuildingVo.getCommunityId());
|
||||
add.setBuildingId(remoteBuildingVo.getId());
|
||||
// 生成电梯编码
|
||||
String code = ELEVATOR_CONTROL_CODE_PREFIX + IdUtil.getSnowflakeNextIdStr();
|
||||
add.setElevatorCode(code);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "新增电梯信息失败。");
|
||||
|
||||
if (flag) {
|
||||
bo.setElevatorId(add.getElevatorId());
|
||||
List<SisDeviceBindRef> ls = new ArrayList<>();
|
||||
@@ -176,6 +185,22 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService {
|
||||
Boolean b = deviceBindRefService.batchInsert(ls);
|
||||
Assert.isTrue(b, "设备绑定关联关系写入失败!");
|
||||
}
|
||||
|
||||
// 写入电梯⇄楼层⇄通道关联表
|
||||
if(!bo.getChannels().isEmpty()){
|
||||
Collection<SisElevatorFloorChannelRef> channelRefs = new ArrayList<>();
|
||||
for (SisElevatorInfoBo.ChannelInfo channelInfo : bo.getChannels()) {
|
||||
SisElevatorFloorChannelRef ref = new SisElevatorFloorChannelRef();
|
||||
ref.setElevatorId(add.getElevatorId());
|
||||
ref.setFloorId(channelInfo.getFloorId());
|
||||
ref.setInChannel(channelInfo.getInChannel());
|
||||
ref.setOutChannel(channelInfo.getOutChannel());
|
||||
channelRefs.add(ref);
|
||||
}
|
||||
Boolean b = elevatorFloorChannelRefService.batchInsert(add.getElevatorId(), channelRefs);
|
||||
Assert.isTrue(b, "电梯楼层通道关联关系写入失败!");
|
||||
}
|
||||
|
||||
// hik sdk 登录
|
||||
// short port = bo.getControlPort().shortValue();
|
||||
// Boolean isLogin = HikApiService.getInstance().login(bo.getControlIp(), port, bo.getControlAccount(), bo.getControlPwd());
|
||||
@@ -224,6 +249,21 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService {
|
||||
Boolean b = deviceBindRefService.batchInsert(ls);
|
||||
Assert.isTrue(b, "设备绑定关联关系写入失败!");
|
||||
}
|
||||
|
||||
// 写入电梯⇄楼层⇄通道关联表
|
||||
if(!bo.getChannels().isEmpty()){
|
||||
Collection<SisElevatorFloorChannelRef> channelRefs = new ArrayList<>();
|
||||
for (SisElevatorInfoBo.ChannelInfo channelInfo : bo.getChannels()) {
|
||||
SisElevatorFloorChannelRef ref = new SisElevatorFloorChannelRef();
|
||||
ref.setElevatorId(update.getElevatorId());
|
||||
ref.setFloorId(channelInfo.getFloorId());
|
||||
ref.setInChannel(channelInfo.getInChannel());
|
||||
ref.setOutChannel(channelInfo.getOutChannel());
|
||||
channelRefs.add(ref);
|
||||
}
|
||||
Boolean b = elevatorFloorChannelRefService.batchInsert(update.getElevatorId(), channelRefs);
|
||||
Assert.isTrue(b, "电梯楼层通道关联关系写入失败!");
|
||||
}
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user