From f7e880deb0612ba5efe96e6ce229abd8c19bc6e7 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 03 九月 2024 09:08:23 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java | 78 ++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 46 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java index 8a7cd0e..51c5de3 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java @@ -1,83 +1,69 @@ package com.iailab.module.data.channel.kio.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.impl.BaseServiceImpl; -import com.iailab.framework.common.util.object.ConvertUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.module.data.channel.kio.service.ChannelKioTagService; import com.iailab.module.data.channel.kio.dao.ChannelKioDeviceDao; -import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; -import com.iailab.module.data.channel.kio.service.ChannelKioTagService; -import org.apache.commons.lang3.StringUtils; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import com.iailab.module.data.channel.kio.vo.KioDevicePageReqVO; -import java.util.Arrays; +import javax.annotation.Resource; + +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; +import org.springframework.stereotype.Service; + +import java.util.Date; import java.util.List; import java.util.Map; /** - * @author PanZhibao + * @author lirm * @Description - * @createTime 2024年06月04日 + * @createTime 2024年08月26日 */ @Service -public class ChannelKioDeviceServiceImpl extends BaseServiceImpl<ChannelKioDeviceDao, ChannelKioDeviceEntity> implements ChannelKioDeviceService { +public class ChannelKioDeviceServiceImpl extends ServiceImpl<ChannelKioDeviceDao, ChannelKioDeviceEntity> implements ChannelKioDeviceService { + + @Resource + private ChannelKioDeviceDao channelKioDeviceDao; @Resource ChannelKioTagService channelKioTagService; + @Override - public PageData<ChannelKioDeviceDTO> page(Map<String, Object> params) { - IPage<ChannelKioDeviceEntity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_TIME, false), - getWrapper(params) - ); - return getPageData(page, ChannelKioDeviceDTO.class); + public PageResult<ChannelKioDeviceEntity> queryPage(KioDevicePageReqVO reqVO) { + return channelKioDeviceDao.selectPage(reqVO); } @Override - public List<ChannelKioDeviceDTO> list(Map<String, Object> params) { - List<ChannelKioDeviceEntity> list = baseDao.selectList(getWrapper(params)); - return ConvertUtils.sourceToTarget(list, ChannelKioDeviceDTO.class); - } - - private QueryWrapper<ChannelKioDeviceEntity> getWrapper(Map<String, Object> params){ - String instanceName = (String)params.get("instanceName"); - QueryWrapper<ChannelKioDeviceEntity> wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(instanceName), "instance_name", instanceName); - return wrapper; + public ChannelKioDeviceEntity info(String id) { + return channelKioDeviceDao.selectById(id); } @Override - public ChannelKioDeviceDTO get(String id) { - ChannelKioDeviceEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, ChannelKioDeviceDTO.class); + public void add(ChannelKioDeviceEntity channelKioDeviceEntity) { + channelKioDeviceDao.insert(channelKioDeviceEntity); } @Override - public void save(ChannelKioDeviceDTO dto) { - ChannelKioDeviceEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioDeviceEntity.class); - insert(entity); + public void update(ChannelKioDeviceEntity channelKioDeviceEntity) { + channelKioDeviceDao.updateById(channelKioDeviceEntity); } @Override - public void update(ChannelKioDeviceDTO dto) { - ChannelKioDeviceEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioDeviceEntity.class); - updateById(entity); + public void delete(String id) { + //先删除device下的tag + channelKioTagService.deleteByDeviceName(info(id).getInstanceName()); + + channelKioDeviceDao.deleteById(id); + } @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - Arrays.asList(ids).forEach(id -> { - channelKioTagService.deleteByDeviceName(get(id).getInstanceName()); - }); - baseDao.deleteBatchIds(Arrays.asList(ids)); + public List<ChannelKioDeviceEntity> list(Map<String, Object> params) { + return channelKioDeviceDao.selectList(new QueryWrapper<ChannelKioDeviceEntity>().orderByAsc("instance_name")); } } \ No newline at end of file -- Gitblit v1.9.3