From bbe7acfbe5a4c08d6edc91eaf81dcecf9d630e18 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期日, 15 十二月 2024 15:10:50 +0800
Subject: [PATCH] collectQuality

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java |  105 ++++++++++++++++++++++++++--------------------------
 1 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java
index de80b07..0b9271a 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java
@@ -1,84 +1,83 @@
 package com.iailab.module.data.ind.collection;
 
-import com.iailab.module.data.ind.collection.handler.AtomItemHandle;
-import com.iailab.module.data.ind.service.IndItemService;
-import com.iailab.module.data.ind.collection.handler.AtomItemHandle;
-import com.iailab.module.data.ind.service.IndItemService;
-import com.iailab.module.data.ind.collection.handler.AtomItemHandle;
-import com.iailab.module.data.ind.collection.handler.CalItemHandle;
-import com.iailab.module.data.ind.dto.IndItemDTO;
-import com.iailab.module.data.ind.dto.IndItemValueDTO;
-import com.iailab.module.data.ind.service.IndItemService;
-import com.iailab.module.data.ind.collection.handler.AtomItemHandle;
-import com.iailab.module.data.ind.service.IndItemService;
+import com.iailab.module.data.common.enums.ItemTypeEnum;
+import com.iailab.module.data.ind.collection.handler.AtomItemHandler;
+import com.iailab.module.data.ind.collection.handler.CalItemHandler;
+import com.iailab.module.data.ind.collection.handler.DerItemHandler;
+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.IndItemValueVO;
 import lombok.extern.slf4j.Slf4j;
-import javax.annotation.Resource;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
 
-import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @author PanZhibao
  * @Description
- * @createTime 2024年05月25日
+ * @createTime 2024年10月04日
  */
 @Slf4j
 @Component
 public class IndItemCollector {
 
-    @Resource
+    @Autowired
     private IndItemService indItemService;
 
-    @Resource
-    private AtomItemHandle atomItemHandle;
+    @Autowired
+    private AtomItemHandler atomItemHandler;
 
-    @Resource
-    private CalItemHandle calItemHandle;
+    @Autowired
+    private DerItemHandler derItemHandler;
 
+    @Autowired
+    private CalItemHandler calItemHandler;
 
-    public Map<String, List<IndItemValueDTO>> getValueList(List<String> itemNos) {
-        Map<String, List<IndItemValueDTO>> result = new HashMap<>();
-        if (CollectionUtils.isEmpty(itemNos)) {
+    public List<IndItemValueVO> queryValue(String itemNo) {
+        List<IndItemValueVO> result = new ArrayList<IndItemValueVO>();
+        IndItemEntity indItem = indItemService.getInfoByNo(itemNo);
+        if (indItem == null) {
             return result;
         }
-        try {
-            List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos);
-            atomList.forEach(item -> {
-                result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo()));
-            });
-
-            List<IndItemDTO> calList = indItemService.getItemCal(itemNos);
-            calList.forEach(item -> {
-                result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo()));
-            });
-
-        } catch (Exception ex) {
-            ex.printStackTrace();
+        ItemTypeEnum itemType = ItemTypeEnum.getEumByCode(indItem.getItemType());
+        switch (itemType) {
+            case ATOM:
+                result = atomItemHandler.queryValue(indItem.getId());
+                break;
+            case DER:
+                result = derItemHandler.queryValue(indItem.getId());
+                break;
+            case CAL:
+                result = calItemHandler.queryValue(itemNo);
+                break;
+            default:
+                break;
         }
         return result;
     }
 
-    public Map<String, List<IndItemValueDTO>> getValueListRange(List<String> itemNos, String start, String end) {
-        Map<String, List<IndItemValueDTO>> result = new HashMap<>();
-        if (CollectionUtils.isEmpty(itemNos)) {
+    public List<IndItemValueVO> queryValue(String itemNo, Date startTime, Date endTime) {
+        List<IndItemValueVO> result = new ArrayList<IndItemValueVO>();
+        IndItemEntity indItem = indItemService.getInfoByNo(itemNo);
+        if (indItem == null) {
             return result;
         }
-        try {
-            List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos);
-            atomList.forEach(item -> {
-                result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo(), start, end));
-            });
-
-            List<IndItemDTO> calList = indItemService.getItemCal(itemNos);
-            calList.forEach(item -> {
-                result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo(), start, end));
-            });
-
-        } catch (Exception ex) {
-            ex.printStackTrace();
+        ItemTypeEnum itemType = ItemTypeEnum.getEumByCode(indItem.getItemType());
+        switch (itemType) {
+            case ATOM:
+                result = atomItemHandler.queryValue(indItem.getId());
+                break;
+            case DER:
+                result = derItemHandler.queryValue(itemNo, startTime, endTime);
+                break;
+            case CAL:
+                result = calItemHandler.queryValue(itemNo, startTime, endTime);
+                break;
+            default:
+                break;
         }
         return result;
     }

--
Gitblit v1.9.3