feat: 新功能开发,设备告警信息、设备实时数据查看等。
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.intc.fishery.service;
|
||||
|
||||
import com.intc.fishery.domain.vo.CallNoticeVo;
|
||||
import com.intc.fishery.domain.bo.CallNoticeBo;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 告警电话通知记录Service接口
|
||||
*
|
||||
* @author intc
|
||||
* @date 2025-10-25
|
||||
*/
|
||||
public interface ICallNoticeService {
|
||||
|
||||
/**
|
||||
* 查询告警电话通知记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 告警电话通知记录
|
||||
*/
|
||||
CallNoticeVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询告警电话通知记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 告警电话通知记录分页列表
|
||||
*/
|
||||
TableDataInfo<CallNoticeVo> queryPageList(CallNoticeBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的告警电话通知记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 告警电话通知记录列表
|
||||
*/
|
||||
List<CallNoticeVo> queryList(CallNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 新增告警电话通知记录
|
||||
*
|
||||
* @param bo 告警电话通知记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(CallNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 修改告警电话通知记录
|
||||
*
|
||||
* @param bo 告警电话通知记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(CallNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除告警电话通知记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.intc.fishery.service;
|
||||
|
||||
import com.intc.fishery.domain.vo.MapMessageWarnCallNoticeVo;
|
||||
import com.intc.fishery.domain.bo.MapMessageWarnCallNoticeBo;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 告警消息和电话告警通知关系表Service接口
|
||||
*
|
||||
* @author intc
|
||||
* @date 2025-10-25
|
||||
*/
|
||||
public interface IMapMessageWarnCallNoticeService {
|
||||
|
||||
/**
|
||||
* 查询告警消息和电话告警通知关系表
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 告警消息和电话告警通知关系表
|
||||
*/
|
||||
MapMessageWarnCallNoticeVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询告警消息和电话告警通知关系表列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 告警消息和电话告警通知关系表分页列表
|
||||
*/
|
||||
TableDataInfo<MapMessageWarnCallNoticeVo> queryPageList(MapMessageWarnCallNoticeBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的告警消息和电话告警通知关系表列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 告警消息和电话告警通知关系表列表
|
||||
*/
|
||||
List<MapMessageWarnCallNoticeVo> queryList(MapMessageWarnCallNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 新增告警消息和电话告警通知关系表
|
||||
*
|
||||
* @param bo 告警消息和电话告警通知关系表
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(MapMessageWarnCallNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 修改告警消息和电话告警通知关系表
|
||||
*
|
||||
* @param bo 告警消息和电话告警通知关系表
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(MapMessageWarnCallNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除告警消息和电话告警通知关系表信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.intc.fishery.service;
|
||||
|
||||
import com.intc.fishery.domain.vo.MessageWarnVo;
|
||||
import com.intc.fishery.domain.bo.MessageWarnBo;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备告警记录Service接口
|
||||
*
|
||||
* @author intc
|
||||
* @date 2025-10-25
|
||||
*/
|
||||
public interface IMessageWarnService {
|
||||
|
||||
/**
|
||||
* 查询设备告警记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备告警记录
|
||||
*/
|
||||
MessageWarnVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询设备告警记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备告警记录分页列表
|
||||
*/
|
||||
TableDataInfo<MessageWarnVo> queryPageList(MessageWarnBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备告警记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备告警记录列表
|
||||
*/
|
||||
List<MessageWarnVo> queryList(MessageWarnBo bo);
|
||||
|
||||
/**
|
||||
* 新增设备告警记录
|
||||
*
|
||||
* @param bo 设备告警记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(MessageWarnBo bo);
|
||||
|
||||
/**
|
||||
* 修改设备告警记录
|
||||
*
|
||||
* @param bo 设备告警记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(MessageWarnBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备告警记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package com.intc.fishery.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.intc.common.core.utils.MapstructUtils;
|
||||
import com.intc.common.core.utils.StringUtils;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.intc.fishery.domain.bo.CallNoticeBo;
|
||||
import com.intc.fishery.domain.vo.CallNoticeVo;
|
||||
import com.intc.fishery.domain.CallNotice;
|
||||
import com.intc.fishery.domain.AquUser;
|
||||
import com.intc.fishery.domain.Device;
|
||||
import com.intc.fishery.domain.MapMessageWarnCallNotice;
|
||||
import com.intc.fishery.domain.MessageWarn;
|
||||
import com.intc.fishery.mapper.CallNoticeMapper;
|
||||
import com.intc.fishery.mapper.MapMessageWarnCallNoticeMapper;
|
||||
import com.intc.fishery.service.ICallNoticeService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 告警电话通知记录Service业务层处理
|
||||
*
|
||||
* @author intc
|
||||
* @date 2025-10-25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class CallNoticeServiceImpl implements ICallNoticeService {
|
||||
|
||||
private final CallNoticeMapper baseMapper;
|
||||
private final MapMessageWarnCallNoticeMapper mapMessageWarnCallNoticeMapper;
|
||||
|
||||
/**
|
||||
* 查询告警电话通知记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 告警电话通知记录
|
||||
*/
|
||||
@Override
|
||||
public CallNoticeVo queryById(Long id){
|
||||
MPJLambdaWrapper<CallNotice> wrapper = new MPJLambdaWrapper<CallNotice>()
|
||||
.selectAll(CallNotice.class)
|
||||
.selectAs(AquUser::getUserName, CallNoticeVo::getUserName)
|
||||
.selectAs(AquUser::getMobilePhone, CallNoticeVo::getUserMobilePhone)
|
||||
.selectAs(Device::getDeviceName, CallNoticeVo::getDeviceName)
|
||||
.selectAs(Device::getSerialNum, CallNoticeVo::getSerialNum)
|
||||
.selectAs(Device::getDeviceType, CallNoticeVo::getDeviceType)
|
||||
.select("mw.warn_type AS warnType")
|
||||
.select("mw.title AS warnTitle")
|
||||
.select("mw.message AS warnMessage")
|
||||
.leftJoin(AquUser.class, AquUser::getId, CallNotice::getUserId)
|
||||
.leftJoin(Device.class, Device::getId, CallNotice::getDeviceId)
|
||||
.leftJoin("aqu_map_message_warn_call_notice map ON map.call_notice_id = t.id")
|
||||
.leftJoin("aqu_message_warn mw ON mw.id = map.message_warn_id")
|
||||
.eq(CallNotice::getId, id);
|
||||
return baseMapper.selectJoinOne(CallNoticeVo.class, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询告警电话通知记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 告警电话通知记录分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<CallNoticeVo> queryPageList(CallNoticeBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<CallNotice> wrapper = buildJoinQueryWrapper(bo);
|
||||
Page<CallNoticeVo> result = baseMapper.selectJoinPage(pageQuery.build(), CallNoticeVo.class, wrapper);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的告警电话通知记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 告警电话通知记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<CallNoticeVo> queryList(CallNoticeBo bo) {
|
||||
MPJLambdaWrapper<CallNotice> wrapper = buildJoinQueryWrapper(bo);
|
||||
return baseMapper.selectJoinList(CallNoticeVo.class, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建关联查询条件
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 关联查询Wrapper
|
||||
*/
|
||||
private MPJLambdaWrapper<CallNotice> buildJoinQueryWrapper(CallNoticeBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<CallNotice> wrapper = new MPJLambdaWrapper<CallNotice>()
|
||||
.selectAll(CallNotice.class)
|
||||
.selectAs(AquUser::getUserName, CallNoticeVo::getUserName)
|
||||
.selectAs(AquUser::getMobilePhone, CallNoticeVo::getUserMobilePhone)
|
||||
.selectAs(Device::getDeviceName, CallNoticeVo::getDeviceName)
|
||||
.selectAs(Device::getSerialNum, CallNoticeVo::getSerialNum)
|
||||
.selectAs(Device::getDeviceType, CallNoticeVo::getDeviceType)
|
||||
.select("mw.warn_type AS warnType")
|
||||
.select("mw.title AS warnTitle")
|
||||
.select("mw.message AS warnMessage")
|
||||
.leftJoin(AquUser.class, AquUser::getId, CallNotice::getUserId)
|
||||
.leftJoin(Device.class, Device::getId, CallNotice::getDeviceId)
|
||||
.leftJoin("aqu_map_message_warn_call_notice map ON map.call_notice_id = t.id")
|
||||
.leftJoin("aqu_message_warn mw ON mw.id = map.message_warn_id")
|
||||
.eq(bo.getUserId() != null, CallNotice::getUserId, bo.getUserId())
|
||||
.eq(bo.getCallStatus() != null, CallNotice::getCallStatus, bo.getCallStatus())
|
||||
.eq(StringUtils.isNotBlank(bo.getMobilePhone()), CallNotice::getMobilePhone, bo.getMobilePhone())
|
||||
.eq(bo.getDeviceId() != null, CallNotice::getDeviceId, bo.getDeviceId())
|
||||
.eq(StringUtils.isNotBlank(bo.getDuration()), CallNotice::getDuration, bo.getDuration())
|
||||
.eq(StringUtils.isNotBlank(bo.getEndTime()), CallNotice::getEndTime, bo.getEndTime())
|
||||
.eq(StringUtils.isNotBlank(bo.getHangupDirection()), CallNotice::getHangupDirection, bo.getHangupDirection())
|
||||
.eq(StringUtils.isNotBlank(bo.getTollType()), CallNotice::getTollType, bo.getTollType())
|
||||
.orderByDesc(CallNotice::getCallTime);
|
||||
|
||||
// 处理额外的查询参数
|
||||
if (params != null && !params.isEmpty()) {
|
||||
handleExtraParams(wrapper, params);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理额外的查询参数
|
||||
*
|
||||
* @param wrapper 查询包装器
|
||||
* @param params 额外参数
|
||||
*/
|
||||
private void handleExtraParams(MPJLambdaWrapper<CallNotice> wrapper, Map<String, Object> params) {
|
||||
// 处理用户名或用户手机号模糊查询
|
||||
String userKeyword = (String) params.get("userKeyword");
|
||||
if (StringUtils.isNotBlank(userKeyword)) {
|
||||
wrapper.and(w -> w.like(AquUser::getUserName, userKeyword)
|
||||
.or()
|
||||
.like(AquUser::getMobilePhone, userKeyword));
|
||||
}
|
||||
|
||||
// 处理设备名称或设备编号模糊查询
|
||||
String deviceKeyword = (String) params.get("deviceKeyword");
|
||||
if (StringUtils.isNotBlank(deviceKeyword)) {
|
||||
wrapper.and(w -> w.like(Device::getDeviceName, deviceKeyword)
|
||||
.or()
|
||||
.like(Device::getSerialNum, deviceKeyword));
|
||||
}
|
||||
|
||||
// 处理设备类型精确查询
|
||||
Object deviceTypeObj = params.get("deviceType");
|
||||
if (deviceTypeObj != null) {
|
||||
Integer deviceType = deviceTypeObj instanceof String ?
|
||||
Integer.valueOf((String) deviceTypeObj) : (Integer) deviceTypeObj;
|
||||
wrapper.eq(Device::getDeviceType, deviceType);
|
||||
}
|
||||
|
||||
// 处理告警类型精确查询
|
||||
Object warnTypeObj = params.get("warnType");
|
||||
if (warnTypeObj != null) {
|
||||
Integer warnType = warnTypeObj instanceof String ?
|
||||
Integer.valueOf((String) warnTypeObj) : (Integer) warnTypeObj;
|
||||
wrapper.apply("mw.warn_type = {0}", warnType);
|
||||
}
|
||||
|
||||
// 处理告警ID精确查询
|
||||
Object messageWarnIdObj = params.get("messageWarnId");
|
||||
if (messageWarnIdObj != null) {
|
||||
Long messageWarnId = messageWarnIdObj instanceof String ?
|
||||
Long.valueOf((String) messageWarnIdObj) : (Long) messageWarnIdObj;
|
||||
wrapper.eq("mw.id", messageWarnId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增告警电话通知记录
|
||||
*
|
||||
* @param bo 告警电话通知记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(CallNoticeBo bo) {
|
||||
CallNotice add = MapstructUtils.convert(bo, CallNotice.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改告警电话通知记录
|
||||
*
|
||||
* @param bo 告警电话通知记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(CallNoticeBo bo) {
|
||||
CallNotice update = MapstructUtils.convert(bo, CallNotice.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(CallNotice entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除告警电话通知记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
|
||||
// 先删除中间表的关联记录
|
||||
for (Long callNoticeId : ids) {
|
||||
LambdaQueryWrapper<MapMessageWarnCallNotice> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MapMessageWarnCallNotice::getCallNoticeId, callNoticeId);
|
||||
mapMessageWarnCallNoticeMapper.delete(wrapper);
|
||||
}
|
||||
|
||||
// 再删除主表记录
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.intc.fishery.service.impl;
|
||||
|
||||
import com.intc.common.core.utils.MapstructUtils;
|
||||
import com.intc.common.core.utils.StringUtils;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.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 com.intc.fishery.domain.bo.MapMessageWarnCallNoticeBo;
|
||||
import com.intc.fishery.domain.vo.MapMessageWarnCallNoticeVo;
|
||||
import com.intc.fishery.domain.MapMessageWarnCallNotice;
|
||||
import com.intc.fishery.mapper.MapMessageWarnCallNoticeMapper;
|
||||
import com.intc.fishery.service.IMapMessageWarnCallNoticeService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 告警消息和电话告警通知关系表Service业务层处理
|
||||
*
|
||||
* @author intc
|
||||
* @date 2025-10-25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class MapMessageWarnCallNoticeServiceImpl implements IMapMessageWarnCallNoticeService {
|
||||
|
||||
private final MapMessageWarnCallNoticeMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询告警消息和电话告警通知关系表
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 告警消息和电话告警通知关系表
|
||||
*/
|
||||
@Override
|
||||
public MapMessageWarnCallNoticeVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询告警消息和电话告警通知关系表列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 告警消息和电话告警通知关系表分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<MapMessageWarnCallNoticeVo> queryPageList(MapMessageWarnCallNoticeBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<MapMessageWarnCallNotice> lqw = buildQueryWrapper(bo);
|
||||
Page<MapMessageWarnCallNoticeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的告警消息和电话告警通知关系表列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 告警消息和电话告警通知关系表列表
|
||||
*/
|
||||
@Override
|
||||
public List<MapMessageWarnCallNoticeVo> queryList(MapMessageWarnCallNoticeBo bo) {
|
||||
LambdaQueryWrapper<MapMessageWarnCallNotice> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<MapMessageWarnCallNotice> buildQueryWrapper(MapMessageWarnCallNoticeBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<MapMessageWarnCallNotice> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(MapMessageWarnCallNotice::getId);
|
||||
lqw.eq(bo.getMessageWarnId() != null, MapMessageWarnCallNotice::getMessageWarnId, bo.getMessageWarnId());
|
||||
lqw.eq(bo.getCallNoticeId() != null, MapMessageWarnCallNotice::getCallNoticeId, bo.getCallNoticeId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增告警消息和电话告警通知关系表
|
||||
*
|
||||
* @param bo 告警消息和电话告警通知关系表
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(MapMessageWarnCallNoticeBo bo) {
|
||||
MapMessageWarnCallNotice add = MapstructUtils.convert(bo, MapMessageWarnCallNotice.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改告警消息和电话告警通知关系表
|
||||
*
|
||||
* @param bo 告警消息和电话告警通知关系表
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(MapMessageWarnCallNoticeBo bo) {
|
||||
MapMessageWarnCallNotice update = MapstructUtils.convert(bo, MapMessageWarnCallNotice.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(MapMessageWarnCallNotice entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除告警消息和电话告警通知关系表信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.intc.fishery.service.impl;
|
||||
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.intc.common.core.utils.MapstructUtils;
|
||||
import com.intc.common.core.utils.StringUtils;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.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 com.intc.fishery.domain.bo.MessageWarnBo;
|
||||
import com.intc.fishery.domain.vo.MessageWarnVo;
|
||||
import com.intc.fishery.domain.MessageWarn;
|
||||
import com.intc.fishery.domain.AquUser;
|
||||
import com.intc.fishery.domain.Device;
|
||||
import com.intc.fishery.domain.Pond;
|
||||
import com.intc.fishery.mapper.MessageWarnMapper;
|
||||
import com.intc.fishery.service.IMessageWarnService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备告警记录Service业务层处理
|
||||
*
|
||||
* @author intc
|
||||
* @date 2025-10-25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class MessageWarnServiceImpl implements IMessageWarnService {
|
||||
|
||||
private final MessageWarnMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备告警记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备告警记录
|
||||
*/
|
||||
@Override
|
||||
public MessageWarnVo queryById(Long id){
|
||||
MPJLambdaWrapper<MessageWarn> wrapper = new MPJLambdaWrapper<MessageWarn>()
|
||||
.selectAll(MessageWarn.class)
|
||||
.selectAs(AquUser::getUserName, MessageWarnVo::getUserName)
|
||||
.selectAs(AquUser::getMobilePhone, MessageWarnVo::getMobilePhone)
|
||||
.selectAs(Device::getDeviceName, MessageWarnVo::getDeviceName)
|
||||
.selectAs(Device::getSerialNum, MessageWarnVo::getSerialNum)
|
||||
.selectAs(Pond::getPondName, MessageWarnVo::getPondName)
|
||||
.select("(SELECT COUNT(*) FROM aqu_map_message_warn_call_notice map WHERE map.message_warn_id = t.id AND map.tenant_id = t.tenant_id) AS callNoticeCount")
|
||||
.leftJoin(AquUser.class, AquUser::getId, MessageWarn::getUserId)
|
||||
.leftJoin(Device.class, Device::getId, MessageWarn::getDeviceId)
|
||||
.leftJoin(Pond.class, Pond::getId, Device::getPondId)
|
||||
.eq(MessageWarn::getId, id);
|
||||
return baseMapper.selectJoinOne(MessageWarnVo.class, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备告警记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备告警记录分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<MessageWarnVo> queryPageList(MessageWarnBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<MessageWarn> wrapper = buildJoinQueryWrapper(bo);
|
||||
Page<MessageWarnVo> result = baseMapper.selectJoinPage(pageQuery.build(), MessageWarnVo.class, wrapper);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备告警记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备告警记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<MessageWarnVo> queryList(MessageWarnBo bo) {
|
||||
MPJLambdaWrapper<MessageWarn> wrapper = buildJoinQueryWrapper(bo);
|
||||
return baseMapper.selectJoinList(MessageWarnVo.class, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建关联查询条件
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 关联查询Wrapper
|
||||
*/
|
||||
private MPJLambdaWrapper<MessageWarn> buildJoinQueryWrapper(MessageWarnBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<MessageWarn> wrapper = new MPJLambdaWrapper<MessageWarn>()
|
||||
.selectAll(MessageWarn.class)
|
||||
.selectAs(AquUser::getUserName, MessageWarnVo::getUserName)
|
||||
.selectAs(AquUser::getMobilePhone, MessageWarnVo::getMobilePhone)
|
||||
.selectAs(Device::getDeviceName, MessageWarnVo::getDeviceName)
|
||||
.selectAs(Device::getSerialNum, MessageWarnVo::getSerialNum)
|
||||
.selectAs(Pond::getPondName, MessageWarnVo::getPondName)
|
||||
.select("(SELECT COUNT(*) FROM aqu_map_message_warn_call_notice map WHERE map.message_warn_id = t.id AND map.tenant_id = t.tenant_id) AS callNoticeCount")
|
||||
.leftJoin(AquUser.class, AquUser::getId, MessageWarn::getUserId)
|
||||
.leftJoin(Device.class, Device::getId, MessageWarn::getDeviceId)
|
||||
.leftJoin(Pond.class, Pond::getId, Device::getPondId)
|
||||
.eq(bo.getUserId() != null, MessageWarn::getUserId, bo.getUserId())
|
||||
.eq(bo.getDeviceId() != null, MessageWarn::getDeviceId, bo.getDeviceId())
|
||||
.eq(StringUtils.isNotBlank(bo.getTitle()), MessageWarn::getTitle, bo.getTitle())
|
||||
.eq(StringUtils.isNotBlank(bo.getMessage()), MessageWarn::getMessage, bo.getMessage())
|
||||
.eq(bo.getIsRead() != null, MessageWarn::getIsRead, bo.getIsRead())
|
||||
.eq(bo.getWarnType() != null, MessageWarn::getWarnType, bo.getWarnType())
|
||||
.like(StringUtils.isNotBlank(bo.getPondName()), MessageWarn::getPondName, bo.getPondName())
|
||||
.orderByDesc(MessageWarn::getCreateTime);
|
||||
|
||||
// 处理额外的查询参数
|
||||
if (params != null && !params.isEmpty()) {
|
||||
handleExtraParams(wrapper, params);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理额外的查询参数
|
||||
*
|
||||
* @param wrapper 查询包装器
|
||||
* @param params 额外参数
|
||||
*/
|
||||
private void handleExtraParams(MPJLambdaWrapper<MessageWarn> wrapper, Map<String, Object> params) {
|
||||
// 处理用户名或用户手机号模糊查询
|
||||
String userKeyword = (String) params.get("userKeyword");
|
||||
if (StringUtils.isNotBlank(userKeyword)) {
|
||||
wrapper.and(w -> w.like(AquUser::getUserName, userKeyword)
|
||||
.or()
|
||||
.like(AquUser::getMobilePhone, userKeyword));
|
||||
}
|
||||
|
||||
// 处理设备名称或设备编号模糊查询
|
||||
String deviceKeyword = (String) params.get("deviceKeyword");
|
||||
if (StringUtils.isNotBlank(deviceKeyword)) {
|
||||
wrapper.and(w -> w.like(Device::getDeviceName, deviceKeyword)
|
||||
.or()
|
||||
.like(Device::getSerialNum, deviceKeyword));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备告警记录
|
||||
*
|
||||
* @param bo 设备告警记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(MessageWarnBo bo) {
|
||||
MessageWarn add = MapstructUtils.convert(bo, MessageWarn.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备告警记录
|
||||
*
|
||||
* @param bo 设备告警记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(MessageWarnBo bo) {
|
||||
MessageWarn update = MapstructUtils.convert(bo, MessageWarn.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(MessageWarn entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备告警记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user