diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisDevicePointServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisDevicePointServiceImpl.java new file mode 100644 index 0000000..90109c0 --- /dev/null +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisDevicePointServiceImpl.java @@ -0,0 +1,143 @@ +package org.dromara.sis.service.impl; + +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.SisDevicePointBo; +import org.dromara.sis.domain.vo.SisDevicePointVo; +import org.dromara.sis.domain.SisDevicePoint; +import org.dromara.sis.mapper.SisDevicePointMapper; +import org.dromara.sis.service.ISisDevicePointService; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 宇视设备点位(通道)Service业务层处理 + * + * @author mocheng + * @date 2025-06-25 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class SisDevicePointServiceImpl implements ISisDevicePointService { + + private final SisDevicePointMapper baseMapper; + + /** + * 查询宇视设备点位(通道) + * + * @param id 主键 + * @return 宇视设备点位(通道) + */ + @Override + public SisDevicePointVo queryById(Long id){ + return baseMapper.selectVoById(id); + } + + /** + * 分页查询宇视设备点位(通道)列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 宇视设备点位(通道)分页列表 + */ + @Override + public TableDataInfo queryPageList(SisDevicePointBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的宇视设备点位(通道)列表 + * + * @param bo 查询条件 + * @return 宇视设备点位(通道)列表 + */ + @Override + public List queryList(SisDevicePointBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(SisDevicePointBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByAsc(SisDevicePoint::getId); + lqw.eq(StringUtils.isNotBlank(bo.getEqpCode()), SisDevicePoint::getEqpCode, bo.getEqpCode()); + lqw.eq(bo.getVideo() != null, SisDevicePoint::getVideo, bo.getVideo()); + lqw.eq(bo.getTransportType() != null, SisDevicePoint::getTransportType, bo.getTransportType()); + lqw.like(StringUtils.isNotBlank(bo.getChannelName()), SisDevicePoint::getChannelName, bo.getChannelName()); + lqw.eq(StringUtils.isNotBlank(bo.getRtspAddr()), SisDevicePoint::getRtspAddr, bo.getRtspAddr()); + lqw.eq(StringUtils.isNotBlank(bo.getIp()), SisDevicePoint::getIp, bo.getIp()); + lqw.eq(bo.getPort() != null, SisDevicePoint::getPort, bo.getPort()); + lqw.like(StringUtils.isNotBlank(bo.getUsername()), SisDevicePoint::getUsername, bo.getUsername()); + lqw.eq(StringUtils.isNotBlank(bo.getPwd()), SisDevicePoint::getPwd, bo.getPwd()); + lqw.eq(bo.getVideoType() != null, SisDevicePoint::getVideoType, bo.getVideoType()); + lqw.eq(bo.getVideoId() != null, SisDevicePoint::getVideoId, bo.getVideoId()); + lqw.eq(StringUtils.isNotBlank(bo.getSearchValue()), SisDevicePoint::getSearchValue, bo.getSearchValue()); + return lqw; + } + + /** + * 新增宇视设备点位(通道) + * + * @param bo 宇视设备点位(通道) + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(SisDevicePointBo bo) { + SisDevicePoint add = MapstructUtils.convert(bo, SisDevicePoint.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改宇视设备点位(通道) + * + * @param bo 宇视设备点位(通道) + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(SisDevicePointBo bo) { + SisDevicePoint update = MapstructUtils.convert(bo, SisDevicePoint.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(SisDevicePoint entity){ + //TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除宇视设备点位(通道)信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } +}