From 692153c7d77721a6ec4e64c4d9ed0dface433c6e Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 24 九月 2024 08:50:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemDerService.java           |    5 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java     |   60 ++++++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/dao/IndItemDao.java                      |    7 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemService.java              |    5 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemSaveReqVO.java                 |   31 +-
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/ItemTypeEnum.java                    |   22 ++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemCalService.java           |    5 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemAtomService.java          |    7 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemRespVO.java                    |   13 +
 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml                                           |   28 ++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemDerVo.java                     |   56 +++++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemDerServiceImpl.java  |   12 +
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemCalVo.java                     |   32 +++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemEntity.java                |    5 
 /dev/null                                                                                                                        |   76 -------
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/package-info.java             |    1 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemDerEntity.java             |    5 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/admin/IndItemController.java  |  114 +++++++++++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemAtomServiceImpl.java |   17 +
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemAtomVo.java                    |   46 ++++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java                |    2 
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemCalServiceImpl.java  |   14 +
 22 files changed, 469 insertions(+), 94 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/ItemTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/ItemTypeEnum.java
new file mode 100644
index 0000000..5622549
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/ItemTypeEnum.java
@@ -0,0 +1,22 @@
+package com.iailab.module.data.common.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2023年05月03日 19:10:00
+ */
+@Getter
+@AllArgsConstructor
+public enum ItemTypeEnum {
+
+    ATOM("ATOM"),
+
+    DER("DER"),
+
+    CAL("CAL");
+
+    private String code;
+}
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/IndItemController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/IndItemController.java
deleted file mode 100644
index dbe122c..0000000
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/IndItemController.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.iailab.module.data.ind.item.controller;
-
-import com.iailab.framework.common.pojo.CommonResult;
-import com.iailab.framework.common.pojo.PageResult;
-import com.iailab.framework.common.util.object.BeanUtils;
-import com.iailab.module.data.ind.item.entity.IndItemEntity;
-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 io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-
-import static com.iailab.framework.common.pojo.CommonResult.success;
-
-/**
- * @author PanZhibao
- * @Description
- * @createTime 2024年09月11日
- */
-@Tag(name = "数据平台 - 指标项")
-@RestController
-@RequestMapping("/data/ind-item")
-@Validated
-public class IndItemController {
-    @Autowired
-    private IndItemService indItemService;
-
-    @GetMapping("/page")
-    @Operation(summary = "获取指标项列表", description = "用于【指标项】界面")
-    @PreAuthorize("@ss.hasPermission('data:ind-item:query')")
-    public CommonResult<PageResult<IndItemRespVO>> page(IndItemPageReqVO reqVO) {
-        PageResult<IndItemEntity> page = indItemService.page(reqVO);
-        return success(BeanUtils.toBean(page, IndItemRespVO.class));
-    }
-
-    @PostMapping("/create")
-    @Operation(summary = "创建指标项")
-    @PreAuthorize("@ss.hasPermission('data:ind-item:create')")
-    public CommonResult<Boolean> create(@Valid @RequestBody IndItemSaveReqVO createReqVO) {
-        indItemService.create(createReqVO);
-        return success(true);
-    }
-
-    @PutMapping("/update")
-    @Operation(summary = "修改指标项")
-    @PreAuthorize("@ss.hasPermission('data:ind-item:update')")
-    public CommonResult<Boolean> update(@Valid @RequestBody IndItemSaveReqVO updateReqVO) {
-        indItemService.update(updateReqVO);
-        return success(true);
-    }
-
-    @DeleteMapping("/delete")
-    @Operation(summary = "删除指标项")
-    @Parameter(name = "id", description = "指标项编号", required= true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('data:ind-item:delete')")
-    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
-        indItemService.delete(id);
-        return success(true);
-    }
-
-    @GetMapping("/get")
-    @Operation(summary = "获取指标项信息")
-    @PreAuthorize("@ss.hasPermission('system:ind-item:query')")
-    public CommonResult<IndItemRespVO> get(String id) {
-        IndItemEntity entity = indItemService.get(id);
-        return success(BeanUtils.toBean(entity, IndItemRespVO.class));
-    }
-}
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/admin/IndItemController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/admin/IndItemController.java
new file mode 100644
index 0000000..b2fd87d
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/admin/IndItemController.java
@@ -0,0 +1,114 @@
+package com.iailab.module.data.ind.item.controller.admin;
+
+import com.iailab.framework.common.pojo.CommonResult;
+import com.iailab.framework.common.pojo.PageResult;
+import com.iailab.framework.common.util.object.BeanUtils;
+import com.iailab.module.data.common.enums.ItemTypeEnum;
+import com.iailab.module.data.ind.category.service.IndItemCategoryService;
+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.IndItemCalService;
+import com.iailab.module.data.ind.item.service.IndItemDerService;
+import com.iailab.module.data.ind.item.service.IndItemService;
+import com.iailab.module.data.ind.item.vo.*;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+import static com.iailab.framework.common.pojo.CommonResult.success;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年09月11日
+ */
+@Tag(name = "数据平台 - 指标项")
+@RestController
+@RequestMapping("/data/ind-item")
+@Validated
+public class IndItemController {
+    @Autowired
+    private IndItemService indItemService;
+
+    @Autowired
+    private IndItemAtomService indItemAtomService;
+
+    @Autowired
+    private IndItemDerService indItemDerService;
+
+    @Autowired
+    private IndItemCalService indItemCalService;
+
+    @Autowired
+    private IndItemCategoryService indItemCategoryService;
+
+    @GetMapping("/page")
+    @Operation(summary = "获取指标项列表", description = "用于【指标项】界面")
+    @PreAuthorize("@ss.hasPermission('data:ind-item:query')")
+    public CommonResult<PageResult<IndItemRespVO>> page(IndItemPageReqVO reqVO) {
+        PageResult<IndItemEntity> page = indItemService.page(reqVO);
+        PageResult<IndItemRespVO> result = BeanUtils.toBean(page, IndItemRespVO.class);
+        for (IndItemRespVO item : result.getList()){
+            item.setItemCategoryName(indItemCategoryService.get(item.getItemCategory()) == null ? "" : indItemCategoryService.get(item.getItemCategory()).getLabel());
+        }
+        return success(result);
+    }
+
+    @PostMapping("/create")
+    @Operation(summary = "创建指标项")
+    @PreAuthorize("@ss.hasPermission('data:ind-item:create')")
+    public CommonResult<Boolean> create(@Valid @RequestBody IndItemSaveReqVO createReqVO) {
+        indItemService.create(createReqVO);
+        return success(true);
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "修改指标项")
+    @PreAuthorize("@ss.hasPermission('data:ind-item:update')")
+    public CommonResult<Boolean> update(@Valid @RequestBody IndItemSaveReqVO updateReqVO) {
+        indItemService.update(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除指标项")
+    @Parameter(name = "id", description = "指标项编号", required= true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('data:ind-item:delete')")
+    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
+        indItemService.delete(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获取指标项信息")
+    @PreAuthorize("@ss.hasPermission('data:ind-item:query')")
+    public CommonResult<IndItemRespVO> get(@RequestParam("id") String id) {
+        IndItemEntity entity = indItemService.get(id);
+        IndItemRespVO respVO = BeanUtils.toBean(entity, IndItemRespVO.class);
+        if (ItemTypeEnum.ATOM.getCode().equals(entity.getItemType())){
+            respVO.setAtomItem(indItemAtomService.getByItemId(entity.getId()));
+        }else if (ItemTypeEnum.DER.getCode().equals(entity.getItemType())){
+            IndItemDerVo derItem = indItemDerService.getByItemId(entity.getId());
+            respVO.setDerItem(derItem);
+            respVO.setAtomItem(indItemAtomService.get(derItem.getAtomItemId()));
+        }else if (ItemTypeEnum.CAL.getCode().equals(entity.getItemType())){
+            respVO.setCalItem(indItemCalService.getByItemId(entity.getId()) == null ? new IndItemCalVo() : indItemCalService.getByItemId(entity.getId()));
+        }
+        return success(respVO);
+    }
+
+    @GetMapping("/getList")
+    @Operation(summary = "获取指标项列表", description = "用于【指标项】界面")
+    @PreAuthorize("@ss.hasPermission('data:ind-item:query')")
+    public CommonResult<List<IndItemRespVO>> getList(IndItemPageReqVO reqVO) {
+        List<IndItemRespVO> list = indItemService.getList(reqVO);
+        return success(list);
+    }
+}
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/package-info.java
new file mode 100644
index 0000000..3f6cd5b
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/controller/package-info.java
@@ -0,0 +1 @@
+package com.iailab.module.data.ind.item.controller;
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/dao/IndItemDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/dao/IndItemDao.java
index 7500386..167d2df 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/dao/IndItemDao.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/dao/IndItemDao.java
@@ -6,7 +6,11 @@
 import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
 import com.iailab.module.data.ind.item.entity.IndItemEntity;
 import com.iailab.module.data.ind.item.vo.IndItemPageReqVO;
+import com.iailab.module.data.ind.item.vo.IndItemRespVO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @author PanZhibao
@@ -16,6 +20,7 @@
 @TenantDS
 @Mapper
 public interface IndItemDao extends BaseMapperX<IndItemEntity> {
+    List<IndItemRespVO> getItemList(@Param("params")IndItemPageReqVO reqVO);
 
     default PageResult<IndItemEntity> selectPage(IndItemPageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<IndItemEntity>()
@@ -25,4 +30,6 @@
                 .eqIfPresent(IndItemEntity::getItemCategory, reqVO.getItemCategory())
                 .orderByDesc(IndItemEntity::getCreateTime));
     }
+
+
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemDerEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemDerEntity.java
index 6c04a37..8f121ce 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemDerEntity.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemDerEntity.java
@@ -6,6 +6,7 @@
 import lombok.Data;
 
 import java.io.Serializable;
+import java.sql.Date;
 
 /**
  * 派生指标
@@ -46,12 +47,12 @@
     /**
      * 开始时间
      */
-    private String timeStart;
+    private Date timeStart;
 
     /**
      * 结束时间
      */
-    private String timeEnd;
+    private Date timeEnd;
 
     /**
      * 分析维度
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemEntity.java
index 37a506e..8b1580f 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemEntity.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/entity/IndItemEntity.java
@@ -1,9 +1,9 @@
 package com.iailab.module.data.ind.item.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -50,11 +50,12 @@
     /**
      * 转换系数
      */
-    private Boolean coefficient;
+    private String coefficient;
 
     /**
      * 指标精度
      */
+    @TableField("`precision`")
     private Integer precision;
 
     /**
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemAtomService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemAtomService.java
index a9517fd..4914761 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemAtomService.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemAtomService.java
@@ -2,6 +2,7 @@
 
 import com.iailab.framework.common.service.BaseService;
 import com.iailab.module.data.ind.item.entity.IndItemAtomEntity;
+import com.iailab.module.data.ind.item.vo.IndItemAtomVo;
 
 /**
  * @author PanZhibao
@@ -9,4 +10,10 @@
  * @createTime 2024年09月11日
  */
 public interface IndItemAtomService extends BaseService<IndItemAtomEntity> {
+
+    IndItemAtomVo getByItemId(String itemId);
+
+    IndItemAtomVo get(String id);
+
+    void deleteByItemId(String itemId);
 }
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemCalService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemCalService.java
index f709f61..229ebad 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemCalService.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemCalService.java
@@ -2,6 +2,7 @@
 
 import com.iailab.framework.common.service.BaseService;
 import com.iailab.module.data.ind.item.entity.IndItemCalEntity;
+import com.iailab.module.data.ind.item.vo.IndItemCalVo;
 
 /**
  * @author PanZhibao
@@ -9,4 +10,8 @@
  * @createTime 2024年09月11日
  */
 public interface IndItemCalService extends BaseService<IndItemCalEntity> {
+
+    IndItemCalVo getByItemId(String itemId);
+
+    void deleteByItemId(String itemId);
 }
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemDerService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemDerService.java
index e078fe9..2b8e5d3 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemDerService.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemDerService.java
@@ -2,6 +2,7 @@
 
 import com.iailab.framework.common.service.BaseService;
 import com.iailab.module.data.ind.item.entity.IndItemDerEntity;
+import com.iailab.module.data.ind.item.vo.IndItemDerVo;
 
 /**
  * @author PanZhibao
@@ -9,4 +10,8 @@
  * @createTime 2024年09月11日
  */
 public interface IndItemDerService extends BaseService<IndItemDerEntity> {
+
+    IndItemDerVo getByItemId(String itemId);
+
+    void deleteByItemId(String itemId);
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemService.java
index b092e3c..78e600d 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemService.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/IndItemService.java
@@ -4,7 +4,10 @@
 import com.iailab.framework.common.service.BaseService;
 import com.iailab.module.data.ind.item.entity.IndItemEntity;
 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 java.util.List;
 
 /**
  * @author PanZhibao
@@ -22,4 +25,6 @@
     IndItemEntity get(String id);
 
     void delete(String id);
+
+    List<IndItemRespVO> getList(IndItemPageReqVO reqVO);
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemAtomServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemAtomServiceImpl.java
index 34f2dd1..a444eb7 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemAtomServiceImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemAtomServiceImpl.java
@@ -1,9 +1,12 @@
 package com.iailab.module.data.ind.item.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
+import com.iailab.framework.common.util.object.BeanUtils;
 import com.iailab.module.data.ind.item.dao.IndItemAtomDao;
 import com.iailab.module.data.ind.item.entity.IndItemAtomEntity;
 import com.iailab.module.data.ind.item.service.IndItemAtomService;
+import com.iailab.module.data.ind.item.vo.IndItemAtomVo;
 import org.springframework.stereotype.Service;
 
 /**
@@ -13,4 +16,18 @@
  */
 @Service
 public class IndItemAtomServiceImpl extends BaseServiceImpl<IndItemAtomDao, IndItemAtomEntity> implements IndItemAtomService {
+    @Override
+    public IndItemAtomVo getByItemId(String itemId) {
+        return BeanUtils.toBean(baseDao.selectOne(new QueryWrapper<IndItemAtomEntity>().eq("item_id", itemId)), IndItemAtomVo.class);
+    }
+
+    @Override
+    public IndItemAtomVo get(String id) {
+        return BeanUtils.toBean(baseDao.selectById(id), IndItemAtomVo.class);
+    }
+
+    @Override
+    public void deleteByItemId(String itemId) {
+        baseDao.delete(new QueryWrapper<IndItemAtomEntity>().eq("item_id", itemId));
+    }
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemCalServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemCalServiceImpl.java
index 19447b5..e0149da 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemCalServiceImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemCalServiceImpl.java
@@ -1,14 +1,28 @@
 package com.iailab.module.data.ind.item.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
+import com.iailab.framework.common.util.object.BeanUtils;
 import com.iailab.module.data.ind.item.dao.IndItemCalDao;
 import com.iailab.module.data.ind.item.entity.IndItemCalEntity;
 import com.iailab.module.data.ind.item.service.IndItemCalService;
+import com.iailab.module.data.ind.item.vo.IndItemCalVo;
+import org.springframework.stereotype.Service;
 
 /**
  * @author PanZhibao
  * @Description
  * @createTime 2024年09月11日
  */
+@Service
 public class IndItemCalServiceImpl extends BaseServiceImpl<IndItemCalDao, IndItemCalEntity> implements IndItemCalService {
+    @Override
+    public IndItemCalVo getByItemId(String itemId) {
+        return BeanUtils.toBean(baseDao.selectOne(new QueryWrapper<IndItemCalEntity>().eq("item_id", itemId)), IndItemCalVo.class);
+    }
+
+    @Override
+    public void deleteByItemId(String itemId) {
+        baseDao.delete(new QueryWrapper<IndItemCalEntity>().eq("item_id", itemId));
+    }
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemDerServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemDerServiceImpl.java
index 11131bd..ea70a55 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemDerServiceImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemDerServiceImpl.java
@@ -1,9 +1,12 @@
 package com.iailab.module.data.ind.item.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
+import com.iailab.framework.common.util.object.BeanUtils;
 import com.iailab.module.data.ind.item.dao.IndItemDerDao;
 import com.iailab.module.data.ind.item.entity.IndItemDerEntity;
 import com.iailab.module.data.ind.item.service.IndItemDerService;
+import com.iailab.module.data.ind.item.vo.IndItemDerVo;
 import org.springframework.stereotype.Service;
 
 /**
@@ -13,4 +16,13 @@
  */
 @Service
 public class IndItemDerServiceImpl extends BaseServiceImpl<IndItemDerDao, IndItemDerEntity> implements IndItemDerService {
+    @Override
+    public IndItemDerVo getByItemId(String itemId) {
+        return BeanUtils.toBean(baseDao.selectOne(new QueryWrapper<IndItemDerEntity>().eq("item_id", itemId)), IndItemDerVo.class);
+    }
+
+    @Override
+    public void deleteByItemId(String itemId) {
+        baseDao.delete(new QueryWrapper<IndItemDerEntity>().eq("item_id", itemId));
+    }
 }
\ No newline at end of file
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..241c47c 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,54 @@
 @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
+    @Transactional(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())){
+            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 +93,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
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemAtomVo.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemAtomVo.java
new file mode 100644
index 0000000..e62a24e
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemAtomVo.java
@@ -0,0 +1,46 @@
+package com.iailab.module.data.ind.item.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 原子指标
+ *
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年09月11日
+ */
+@Data
+public class IndItemAtomVo implements Serializable {
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 指标ID
+     */
+    private String itemId;
+
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
+    /**
+     * 数据集
+     */
+    private String dataSet;
+
+    /**
+     * 使用字段
+     */
+    private String usingField;
+
+    /**
+     * 统计方式
+     */
+    private String statFunc;
+}
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemCalVo.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemCalVo.java
new file mode 100644
index 0000000..b6d62bd
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemCalVo.java
@@ -0,0 +1,32 @@
+package com.iailab.module.data.ind.item.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 复合指标
+ *
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年09月11日
+ */
+@Data
+public class IndItemCalVo implements Serializable {
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 指标ID
+     */
+    private String itemId;
+
+    /**
+     * 计算表达式
+     */
+    private String expression;
+}
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemDerVo.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemDerVo.java
new file mode 100644
index 0000000..3e96667
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemDerVo.java
@@ -0,0 +1,56 @@
+package com.iailab.module.data.ind.item.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Date;
+
+/**
+ * 派生指标
+ *
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年09月11日
+ */
+@Data
+public class IndItemDerVo implements Serializable {
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 指标ID
+     */
+    private String itemId;
+
+    /**
+     * 原子指标ID
+     */
+    private String atomItemId;
+
+    /**
+     * 时间标识
+     */
+    private String timeLabel;
+
+    /**
+     * 时间限定
+     */
+    private String timeLimit;
+
+    /**
+     * 开始时间
+     */
+    private Date timeStart;
+
+    /**
+     * 结束时间
+     */
+    private Date timeEnd;
+
+    /**
+     * 分析维度
+     */
+    private String dimension;
+}
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemRespVO.java
index 960d300..f93780e 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemRespVO.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemRespVO.java
@@ -33,8 +33,11 @@
     @Schema(description = "指标分类", example = "")
     private String itemCategory;
 
+    @Schema(description = "指标分类", example = "")
+    private String itemCategoryName;
+
     @Schema(description = "转换系数", example = "")
-    private Boolean coefficient;
+    private String coefficient;
 
     @Schema(description = "指标精度", example = "")
     private Integer precision;
@@ -62,4 +65,12 @@
 
     @Schema(description = "更新时间", example = "")
     private Date updateTime;
+
+    private String atomItemId;
+
+    private IndItemAtomVo atomItem;
+
+    private IndItemDerVo derItem;
+
+    private IndItemCalVo calItem;
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemSaveReqVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemSaveReqVO.java
index 7b345a5..f8842d2 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemSaveReqVO.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/vo/IndItemSaveReqVO.java
@@ -4,6 +4,7 @@
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
 
 /**
  * @author PanZhibao
@@ -20,7 +21,7 @@
     /**
      * 指标编码
      */
-    @Schema(description = "名称")
+    @Schema(description = "编码")
     private String itemNo;
 
     /**
@@ -33,50 +34,56 @@
     /**
      * 指标类型
      */
-    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotNull(message = "名称不能为空")
+    @Schema(description = "指标类型", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "指标类型不能为空")
     private String itemType;
 
     /**
      * 指标分类
      */
-    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotNull(message = "名称不能为空")
+    @Schema(description = "指标分类", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "指标分类不能为空")
     private String itemCategory;
 
     /**
      * 转换系数
      */
-    @Schema(description = "名称")
-    private Boolean coefficient;
+    @Schema(description = "系数")
+    private BigDecimal coefficient;
 
     /**
      * 指标精度
      */
-    @Schema(description = "名称")
+    @Schema(description = "指标精度")
     private Integer precision;
 
     /**
      * 时间粒度
      */
-    @Schema(description = "名称")
+    @Schema(description = "时间粒度")
     private String timeGranularity;
 
     /**
      * 数量单位
      */
-    @Schema(description = "名称")
+    @Schema(description = "数量单位")
     private String unit;
 
     /**
      * 备注
      */
-    @Schema(description = "名称")
+    @Schema(description = "备注")
     private String remark;
 
     /**
      * 状态
      */
-    @Schema(description = "名称")
+    @Schema(description = "状态(0正常 1停用)")
     private Integer status;
+
+    private IndItemAtomVo atomItem;
+
+    private IndItemDerVo derItem;
+
+    private IndItemCalVo calItem;
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java
index 1195a2f..4e6fb45 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java
@@ -7,5 +7,5 @@
  * @date 2021年05月24日 9:41
  */
 public enum IncreaseCodeEnum {
-    POINT_M, POINT_C, POINT_F
+    POINT_M, POINT_C, POINT_F, IND_A, IND_D, IND_C;
 }
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml
new file mode 100644
index 0000000..e9cd7e5
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.iailab.module.data.ind.item.dao.IndItemDao">
+
+    <select id="getItemList" resultType="com.iailab.module.data.ind.item.vo.IndItemRespVO">
+        select
+        t1.*,
+        t2.id as atomItemId
+        from t_ind_item t1
+        left join t_ind_item_atom t2 on t2.item_id = t1.id
+        <where>
+            <if test="params.itemNo != null and params.itemNo != ''">
+                and t1.item_no like concat('%', #{params.itemNo}, '%')
+            </if>
+            <if test="params.itemName != null and params.itemName != ''">
+                and t1.item_name like concat('%', #{params.itemName}, '%')
+            </if>
+            <if test="params.itemType != null and params.itemType != ''">
+                and t1.item_type = #{params.itemType}
+            </if>
+            <if test="params.itemCategory != null and params.itemCategory != ''">
+                and t1.item_category = #{params.itemCategory}
+            </if>
+        </where>
+    </select>
+
+</mapper>
\ No newline at end of file

--
Gitblit v1.9.3