package com.iailab.module.data.channel.modbus.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.iailab.framework.common.util.object.ConvertUtils;
|
import com.iailab.module.data.common.utils.PageUtils;
|
import com.iailab.module.data.common.utils.Query;
|
import com.iailab.module.data.channel.modbus.dao.ChannelModBusDeviceDao;
|
import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO;
|
import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity;
|
import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService;
|
import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2023年04月23日 17:45:00
|
*/
|
@Service
|
public class ChannelModbusDeviceServiceImpl extends ServiceImpl<ChannelModBusDeviceDao, ChannelModBusDeviceEntity> implements ChannelModbusDeviceService {
|
@Resource
|
private ChannelModBusDeviceDao channelModBusDeviceDao;
|
@Resource
|
private ChannelModbusTagService channelModbusTagService;
|
|
/**
|
* 分页查询设备
|
*
|
* @param params
|
*/
|
@Override
|
public PageUtils queryPage(Map<String, Object> params) {
|
|
String name = (String) params.get("name");
|
|
IPage<ChannelModBusDeviceEntity> page = this.page(
|
new Query<ChannelModBusDeviceEntity>().getPage(params),
|
new QueryWrapper<ChannelModBusDeviceEntity>()
|
.like(StringUtils.isNotBlank(name), "name", name)
|
.orderByDesc("create_time")
|
);
|
return new PageUtils(page);
|
}
|
|
/**
|
* 列表
|
*
|
* @param params
|
* @return
|
*/
|
@Override
|
public List<ChannelModBusDeviceEntity> list(Map<String, Object> params) {
|
return channelModBusDeviceDao.selectList(new QueryWrapper<ChannelModBusDeviceEntity>().orderByAsc("name"));
|
}
|
|
/**
|
* 添加设备
|
*
|
* @param channelModBusDeviceEntity
|
*/
|
@Override
|
public void add(ChannelModBusDeviceEntity channelModBusDeviceEntity) {
|
|
channelModBusDeviceDao.insert(channelModBusDeviceEntity);
|
|
}
|
|
/**
|
* 修改设备
|
*
|
* @param channelModBusDeviceEntity
|
*/
|
@Override
|
public void update(ChannelModBusDeviceEntity channelModBusDeviceEntity) {
|
|
channelModBusDeviceDao.updateById(channelModBusDeviceEntity);
|
}
|
|
/**
|
* 删除设备
|
*
|
* @param id
|
*/
|
@Override
|
public void delete(String id) {
|
//先删除device下的tag
|
channelModbusTagService.deleteByDeviceName(info(id).getName());
|
|
channelModBusDeviceDao.deleteById(id);
|
|
|
}
|
|
/**
|
* 查询设备详情
|
*
|
* @param id
|
*/
|
@Override
|
public ChannelModBusDeviceEntity info(String id) {
|
|
return channelModBusDeviceDao.selectById(id);
|
}
|
|
@Override
|
public List<ChannelModBusDeviceDTO> selectAll() {
|
|
List<ChannelModBusDeviceEntity> entityList = baseMapper.selectList(
|
null);
|
|
return ConvertUtils.sourceToTarget(entityList, ChannelModBusDeviceDTO.class);
|
|
}
|
}
|