package com.iailab.module.data.channel.opcua.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.opcua.dao.ChannelOPCUADeviceDao; import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; import javax.annotation.Resource; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; /** * @author DongYukun * @Description * @createTime 2023年05月08日 15:04:00 */ @Service public class ChannelOPCUADeviceServiceImpl extends ServiceImpl implements ChannelOPCUADeviceService { @Resource private ChannelOPCUADeviceDao channelOPCUADeviceDao; @Resource private ChannelOPCUATagService channelOPCUATagService; /** * 分页查询opc ua配置 * * @param params */ @Override public PageUtils queryPage(Map params) { String serverName = (String) params.get("serverName"); IPage page = this.page( new Query().getPage(params), new QueryWrapper() .like(StringUtils.isNotBlank(serverName), "server_name", serverName) .orderByDesc("create_time") ); return new PageUtils(page); } /** * 查询opc ua配置详情 * * @param id */ @Override public ChannelOPCUADeviceEntity info(String id) { return channelOPCUADeviceDao.selectById(id); } /** * 列表 * * @param params * @return */ @Override public List list(Map params) { return channelOPCUADeviceDao.selectList(new QueryWrapper().orderByAsc("server_name")); } /** * 添加opc ua配置 * * @param channelOPCUADeviceEntity */ @Override public void add(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { channelOPCUADeviceDao.insert(channelOPCUADeviceEntity); } /** * 修改opc ua配置 * * @param channelOPCUADeviceEntity */ @Override public void update(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { channelOPCUADeviceDao.updateById(channelOPCUADeviceEntity); } /** * 删除opc ua配置 * * @param id */ @Override public void delete(String id) { //先删除device下的tag channelOPCUATagService.deleteByDeviceName(info(id).getServerName()); channelOPCUADeviceDao.deleteById(id); } @Override public List selectAll() { List entityList = baseMapper.selectList( null ); return ConvertUtils.sourceToTarget(entityList, ChannelOPCUADeviceDTO.class); } }