forked from dyf/fys-Multi-tenant
设备分组
This commit is contained in:
@ -0,0 +1,58 @@
|
||||
package com.fuyuanshen.equipment.service;
|
||||
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备分组Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-08
|
||||
*/
|
||||
public interface IDeviceGroupService {
|
||||
|
||||
/**
|
||||
* 查询设备分组
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备分组
|
||||
*/
|
||||
DeviceGroupVo queryById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备分组列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备分组列表
|
||||
*/
|
||||
List<DeviceGroupVo> queryList(DeviceGroupBo bo);
|
||||
|
||||
/**
|
||||
* 新增设备分组
|
||||
*
|
||||
* @param bo 设备分组
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(DeviceGroupBo bo);
|
||||
|
||||
/**
|
||||
* 修改设备分组
|
||||
*
|
||||
* @param bo 设备分组
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(DeviceGroupBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备分组信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.fuyuanshen.equipment.service;
|
||||
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceRepairRecordsVo;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceRepairRecordsBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备维修记录Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-08
|
||||
*/
|
||||
public interface IDeviceRepairRecordsService {
|
||||
|
||||
/**
|
||||
* 查询设备维修记录
|
||||
*
|
||||
* @param recordId 主键
|
||||
* @return 设备维修记录
|
||||
*/
|
||||
DeviceRepairRecordsVo queryById(Long recordId);
|
||||
|
||||
/**
|
||||
* 分页查询设备维修记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备维修记录分页列表
|
||||
*/
|
||||
TableDataInfo<DeviceRepairRecordsVo> queryPageList(DeviceRepairRecordsBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备维修记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备维修记录列表
|
||||
*/
|
||||
List<DeviceRepairRecordsVo> queryList(DeviceRepairRecordsBo bo);
|
||||
|
||||
/**
|
||||
* 新增设备维修记录
|
||||
*
|
||||
* @param bo 设备维修记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(DeviceRepairRecordsBo bo);
|
||||
|
||||
/**
|
||||
* 修改设备维修记录
|
||||
*
|
||||
* @param bo 设备维修记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(DeviceRepairRecordsBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备维修记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
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.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
|
||||
import com.fuyuanshen.equipment.domain.DeviceGroup;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceGroupMapper;
|
||||
import com.fuyuanshen.equipment.service.IDeviceGroupService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备分组Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-08
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
|
||||
private final DeviceGroupMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备分组
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备分组
|
||||
*/
|
||||
@Override
|
||||
public DeviceGroupVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备分组列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备分组列表
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceGroupVo> queryList(DeviceGroupBo bo) {
|
||||
LambdaQueryWrapper<DeviceGroup> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<DeviceGroup> buildQueryWrapper(DeviceGroupBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<DeviceGroup> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(DeviceGroup::getId);
|
||||
lqw.like(StringUtils.isNotBlank(bo.getGroupName()), DeviceGroup::getGroupName, bo.getGroupName());
|
||||
lqw.eq(bo.getStatus() != null, DeviceGroup::getStatus, bo.getStatus());
|
||||
lqw.eq(bo.getParentId() != null, DeviceGroup::getParentId, bo.getParentId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFullPath()), DeviceGroup::getFullPath, bo.getFullPath());
|
||||
lqw.eq(bo.getIsDeleted() != null, DeviceGroup::getIsDeleted, bo.getIsDeleted());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备分组
|
||||
*
|
||||
* @param bo 设备分组
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DeviceGroupBo bo) {
|
||||
DeviceGroup add = MapstructUtils.convert(bo, DeviceGroup.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备分组
|
||||
*
|
||||
* @param bo 设备分组
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(DeviceGroupBo bo) {
|
||||
DeviceGroup update = MapstructUtils.convert(bo, DeviceGroup.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DeviceGroup 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,135 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.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.fuyuanshen.equipment.domain.bo.DeviceRepairRecordsBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceRepairRecordsVo;
|
||||
import com.fuyuanshen.equipment.domain.DeviceRepairRecords;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceRepairRecordsMapper;
|
||||
import com.fuyuanshen.equipment.service.IDeviceRepairRecordsService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备维修记录Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-08
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DeviceRepairRecordsServiceImpl implements IDeviceRepairRecordsService {
|
||||
|
||||
private final DeviceRepairRecordsMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备维修记录
|
||||
*
|
||||
* @param recordId 主键
|
||||
* @return 设备维修记录
|
||||
*/
|
||||
@Override
|
||||
public DeviceRepairRecordsVo queryById(Long recordId){
|
||||
return baseMapper.selectVoById(recordId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备维修记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备维修记录分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<DeviceRepairRecordsVo> queryPageList(DeviceRepairRecordsBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<DeviceRepairRecords> lqw = buildQueryWrapper(bo);
|
||||
Page<DeviceRepairRecordsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备维修记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备维修记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceRepairRecordsVo> queryList(DeviceRepairRecordsBo bo) {
|
||||
LambdaQueryWrapper<DeviceRepairRecords> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<DeviceRepairRecords> buildQueryWrapper(DeviceRepairRecordsBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<DeviceRepairRecords> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(DeviceRepairRecords::getRecordId);
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDeviceId()), DeviceRepairRecords::getDeviceId, bo.getDeviceId());
|
||||
lqw.eq(bo.getRepairTime() != null, DeviceRepairRecords::getRepairTime, bo.getRepairTime());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRepairPart()), DeviceRepairRecords::getRepairPart, bo.getRepairPart());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRepairReason()), DeviceRepairRecords::getRepairReason, bo.getRepairReason());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRepairPerson()), DeviceRepairRecords::getRepairPerson, bo.getRepairPerson());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备维修记录
|
||||
*
|
||||
* @param bo 设备维修记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DeviceRepairRecordsBo bo) {
|
||||
DeviceRepairRecords add = MapstructUtils.convert(bo, DeviceRepairRecords.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setRecordId(add.getRecordId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备维修记录
|
||||
*
|
||||
* @param bo 设备维修记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(DeviceRepairRecordsBo bo) {
|
||||
DeviceRepairRecords update = MapstructUtils.convert(bo, DeviceRepairRecords.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DeviceRepairRecords 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