From 2185035076aa14d98225b009c2035778c34e7ce7 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期四, 26 九月 2024 18:51:55 +0800
Subject: [PATCH] 指标管理

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 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 c342eaf..e0c6981 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,16 +1,28 @@
 package com.iailab.module.data.ind.item.service.impl;
 
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.iailab.framework.common.pojo.PageResult;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
 import com.iailab.framework.common.util.object.BeanUtils;
+import com.iailab.module.data.common.enums.ItemTypeEnum;
 import com.iailab.module.data.ind.item.dao.IndItemDao;
+import com.iailab.module.data.ind.item.entity.IndItemAtomEntity;
+import com.iailab.module.data.ind.item.entity.IndItemCalEntity;
+import com.iailab.module.data.ind.item.entity.IndItemDerEntity;
 import com.iailab.module.data.ind.item.entity.IndItemEntity;
+import com.iailab.module.data.ind.item.service.IndItemAtomService;
 import com.iailab.module.data.ind.item.service.IndItemService;
 import com.iailab.module.data.ind.item.vo.IndItemPageReqVO;
+import com.iailab.module.data.ind.item.vo.IndItemRespVO;
 import com.iailab.module.data.ind.item.vo.IndItemSaveReqVO;
+import com.iailab.module.data.point.common.IncreaseCodeEnum;
+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;
 import java.util.UUID;
 
 /**
@@ -21,20 +33,53 @@
 @Service
 public class IndItemServiceImpl extends BaseServiceImpl<IndItemDao, IndItemEntity> implements IndItemService {
 
+    @Autowired
+    private IndItemAtomService indItemAtomService;
+
+    @Autowired
+    private IndItemDerServiceImpl indItemDerServiceImpl;
+
+    @Autowired
+    private IndItemCalServiceImpl indItemCalServiceImpl;
+
+    @Autowired
+    private DaSequenceNumService daSequenceNumService;
     @Override
     public PageResult<IndItemEntity> page(IndItemPageReqVO reqVO) {
         return baseDao.selectPage(reqVO);
     }
 
     @Override
+    @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())){
+            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())){
+            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())){
+            IndItemCalEntity calEntity = BeanUtils.toBean(createReqVO.getCalItem(), IndItemCalEntity.class);
+            calEntity.setId(UUID.randomUUID().toString());
+            calEntity.setItemId(entity.getId());
+            indItemCalServiceImpl.insert(calEntity);
+            entity.setItemNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.IND_C.name()));
+        }
         entity.setCreateTime(new Date());
         baseDao.insert(entity);
     }
 
     @Override
+    @DSTransactional(rollbackFor= Exception.class)
     public void update(IndItemSaveReqVO updateReqVO) {
         IndItemEntity entity = BeanUtils.toBean(updateReqVO, IndItemEntity.class);
         entity.setUpdateTime(new Date());
@@ -47,7 +92,21 @@
     }
 
     @Override
+    @DSTransactional(rollbackFor= Exception.class)
     public void delete(String id) {
+        IndItemEntity entity = get(id);
+        if(ItemTypeEnum.ATOM.getCode().equals(entity.getItemType())){
+            indItemAtomService.deleteByItemId(id);
+        }else if (ItemTypeEnum.DER.getCode().equals(entity.getItemType())){
+            indItemDerServiceImpl.deleteByItemId(id);
+        }else if (ItemTypeEnum.CAL.getCode().equals(entity.getItemType())){
+            indItemCalServiceImpl.deleteByItemId(id);
+        }
         baseDao.deleteById(id);
     }
+
+    @Override
+    public List<IndItemRespVO> getList(IndItemPageReqVO reqVO) {
+        return baseDao.getItemList(reqVO);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3