From 03e8aca3ad6201c0d74e00d4c8d7367cdaaa54f9 Mon Sep 17 00:00:00 2001 From: Jay <csj123456> Date: 星期五, 01 十一月 2024 11:49:51 +0800 Subject: [PATCH] tag新增导入导出功能 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java | 39 ++++++++++++++++++++++++++++----------- 1 files changed, 28 insertions(+), 11 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java index 241c47c..39fb790 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java @@ -1,6 +1,7 @@ package com.iailab.module.data.ind.item.service.impl; import com.baomidou.dynamic.datasource.annotation.DSTransactional; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.BeanUtils; @@ -19,7 +20,6 @@ import com.iailab.module.data.point.service.DaSequenceNumService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; @@ -44,31 +44,31 @@ @Autowired private DaSequenceNumService daSequenceNumService; + @Override public PageResult<IndItemEntity> page(IndItemPageReqVO reqVO) { return baseDao.selectPage(reqVO); } @Override - @Transactional(rollbackFor = Exception.class) - @DSTransactional(rollbackFor= Exception.class) + @DSTransactional(rollbackFor = Exception.class) public void create(IndItemSaveReqVO createReqVO) { IndItemEntity entity = BeanUtils.toBean(createReqVO, IndItemEntity.class); entity.setId(UUID.randomUUID().toString()); - if(ItemTypeEnum.ATOM.getCode().equals(createReqVO.getItemType())){ + if (ItemTypeEnum.ATOM.getCode().equals(createReqVO.getItemType())) { IndItemAtomEntity atomEntity = BeanUtils.toBean(createReqVO.getAtomItem(), IndItemAtomEntity.class); atomEntity.setId(UUID.randomUUID().toString()); atomEntity.setItemId(entity.getId()); indItemAtomService.insert(atomEntity); entity.setItemNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.IND_A.name())); - }else if (ItemTypeEnum.DER.getCode().equals(createReqVO.getItemType())){ + } else if (ItemTypeEnum.DER.getCode().equals(createReqVO.getItemType())) { IndItemDerEntity derEntity = BeanUtils.toBean(createReqVO.getDerItem(), IndItemDerEntity.class); derEntity.setId(UUID.randomUUID().toString()); derEntity.setItemId(entity.getId()); indItemDerServiceImpl.insert(derEntity); entity.setItemNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.IND_D.name())); - }else if (ItemTypeEnum.CAL.getCode().equals(createReqVO.getItemType())){ + } else if (ItemTypeEnum.CAL.getCode().equals(createReqVO.getItemType())) { IndItemCalEntity calEntity = BeanUtils.toBean(createReqVO.getCalItem(), IndItemCalEntity.class); calEntity.setId(UUID.randomUUID().toString()); calEntity.setItemId(entity.getId()); @@ -80,10 +80,20 @@ } @Override - @DSTransactional(rollbackFor= Exception.class) + @DSTransactional(rollbackFor = Exception.class) public void update(IndItemSaveReqVO updateReqVO) { IndItemEntity entity = BeanUtils.toBean(updateReqVO, IndItemEntity.class); entity.setUpdateTime(new Date()); + if (ItemTypeEnum.ATOM.getCode().equals(updateReqVO.getItemType())) { + IndItemAtomEntity atomEntity = BeanUtils.toBean(updateReqVO.getAtomItem(), IndItemAtomEntity.class); + indItemAtomService.updateById(atomEntity); + } else if (ItemTypeEnum.DER.getCode().equals(updateReqVO.getItemType())) { + IndItemDerEntity derEntity = BeanUtils.toBean(updateReqVO.getDerItem(), IndItemDerEntity.class); + indItemDerServiceImpl.updateById(derEntity); + } else if (ItemTypeEnum.CAL.getCode().equals(updateReqVO.getItemType())) { + IndItemCalEntity calEntity = BeanUtils.toBean(updateReqVO.getCalItem(), IndItemCalEntity.class); + indItemCalServiceImpl.updateById(calEntity); + } baseDao.updateById(entity); } @@ -93,14 +103,21 @@ } @Override - @DSTransactional(rollbackFor= Exception.class) + public IndItemEntity getInfoByNo(String no) { + QueryWrapper<IndItemEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("item_no", no); + return baseDao.selectOne(queryWrapper); + } + + @Override + @DSTransactional(rollbackFor = Exception.class) public void delete(String id) { IndItemEntity entity = get(id); - if(ItemTypeEnum.ATOM.getCode().equals(entity.getItemType())){ + if (ItemTypeEnum.ATOM.getCode().equals(entity.getItemType())) { indItemAtomService.deleteByItemId(id); - }else if (ItemTypeEnum.DER.getCode().equals(entity.getItemType())){ + } else if (ItemTypeEnum.DER.getCode().equals(entity.getItemType())) { indItemDerServiceImpl.deleteByItemId(id); - }else if (ItemTypeEnum.CAL.getCode().equals(entity.getItemType())){ + } else if (ItemTypeEnum.CAL.getCode().equals(entity.getItemType())) { indItemCalServiceImpl.deleteByItemId(id); } baseDao.deleteById(id); -- Gitblit v1.9.3