From 80818916e742aa568f719d54c2ca170bc5b55d6c Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 18 十一月 2024 17:51:37 +0800
Subject: [PATCH] 预测项,计划项信息查询

---
 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/dto/ApiIndItemDTO.java    |   33 ++++++++++++++++
 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/PlanItemApi.java         |    4 ++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/ind/IndItemApiImpl.java       |   11 +++++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java     |    6 +++
 iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yaml                                |    5 +-
 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/IndItemApi.java           |   10 +++--
 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/TimeGranularitySecEnum.java |   34 +++++++++++++++++
 7 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/IndItemApi.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/IndItemApi.java
index f4120fe..e0cc621 100644
--- a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/IndItemApi.java
+++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/IndItemApi.java
@@ -1,15 +1,13 @@
 package com.iailab.module.data.api.ind;
 
+import com.iailab.module.data.api.ind.dto.ApiIndItemDTO;
 import com.iailab.module.data.api.ind.dto.ApiIndItemQueryDTO;
 import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO;
 import com.iailab.module.data.enums.ApiConstants;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -31,4 +29,8 @@
     @PostMapping(PREFIX + "/query-ind/history-value")
     @Operation(summary = "查询指标历史值")
     List<ApiIndItemValueDTO> queryIndItemHistoryValue(@RequestBody ApiIndItemQueryDTO dto);
+
+    @GetMapping(PREFIX + "/info/id/{id}")
+    @Operation(summary = "根据测点编号查询测点信息")
+    ApiIndItemDTO getInfoById(@PathVariable("id") String id);
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/dto/ApiIndItemDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/dto/ApiIndItemDTO.java
new file mode 100644
index 0000000..17618ce
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/ind/dto/ApiIndItemDTO.java
@@ -0,0 +1,33 @@
+package com.iailab.module.data.api.ind.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年11月18日
+ */
+@Data
+@Tag(name = "指标项")
+public class ApiIndItemDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "ID")
+    private String id;
+
+    @Schema(description = "指标编码")
+    private String itemNo;
+
+    @Schema(description = "指标名称")
+    private String itemName;
+
+    @Schema(description = "指标分类")
+    private String itemCategory;
+
+    @Schema(description = "时间粒度")
+    private String timeGranularity;
+}
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/PlanItemApi.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/PlanItemApi.java
index 46c4473..b54bd3b 100644
--- a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/PlanItemApi.java
+++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/PlanItemApi.java
@@ -38,4 +38,8 @@
     @GetMapping(PREFIX + "/info/no/{itemNo}")
     @Operation(summary = "根据测点编号查询测点信息")
     ApiPlanItemDTO getInfoByNo(@PathVariable("itemNo") String itemNo);
+
+    @GetMapping(PREFIX + "/info/id/{id}")
+    @Operation(summary = "根据测点编号查询测点信息")
+    ApiPlanItemDTO getInfoById(@PathVariable("id") String id);
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/TimeGranularitySecEnum.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/TimeGranularitySecEnum.java
new file mode 100644
index 0000000..3f33015
--- /dev/null
+++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/TimeGranularitySecEnum.java
@@ -0,0 +1,34 @@
+package com.iailab.module.data.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年11月18日
+ */
+@Getter
+@AllArgsConstructor
+public enum TimeGranularitySecEnum {
+    TG_MIN("min", 60),
+    TG_HOUR("hour", 60 * 60),
+    TG_DAY("day", 60 * 60 * 24);
+
+    private String code;
+
+    private Integer value;
+
+    public static TimeGranularitySecEnum getEumByCode(String code) {
+        if (code == null) {
+            return null;
+        }
+
+        for (TimeGranularitySecEnum statusEnum : TimeGranularitySecEnum.values()) {
+            if (statusEnum.getCode().equals(code)) {
+                return statusEnum;
+            }
+        }
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/ind/IndItemApiImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/ind/IndItemApiImpl.java
index 7bf2fb6..93f346f 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/ind/IndItemApiImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/ind/IndItemApiImpl.java
@@ -1,9 +1,11 @@
 package com.iailab.module.data.api.ind;
 
 import com.iailab.framework.common.util.object.ConvertUtils;
+import com.iailab.module.data.api.ind.dto.ApiIndItemDTO;
 import com.iailab.module.data.api.ind.dto.ApiIndItemQueryDTO;
 import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO;
 import com.iailab.module.data.ind.collection.IndItemCollector;
+import com.iailab.module.data.ind.item.service.IndItemService;
 import com.iailab.module.data.ind.item.vo.IndItemValueVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -23,6 +25,10 @@
     @Autowired
     private IndItemCollector indItemCollector;
 
+    @Autowired
+    private IndItemService indItemService;
+
+    @Override
     public List<ApiIndItemValueDTO> queryIndItemDefaultValue(String itemNo){
         List<IndItemValueVO> list = indItemCollector.queryValue(itemNo);
         return ConvertUtils.sourceToTarget(list, ApiIndItemValueDTO.class);
@@ -33,4 +39,9 @@
         List<IndItemValueVO> list = indItemCollector.queryValue(dto.getItemNo(), dto.getStart(), dto.getEnd());
         return ConvertUtils.sourceToTarget(list, ApiIndItemValueDTO.class);
     }
+
+    @Override
+    public ApiIndItemDTO getInfoById(String id) {
+        return ConvertUtils.sourceToTarget(indItemService.get(id), ApiIndItemDTO.class);
+    }
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java
index 4fcf398..b37fc51 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java
@@ -59,4 +59,10 @@
         return ConvertUtils.sourceToTarget(entity, ApiPlanItemDTO.class);
     }
 
+    @Override
+    public ApiPlanItemDTO getInfoById(String itemNo){
+        PlanItemEntity entity = planItemService.get(itemNo);
+        return ConvertUtils.sourceToTarget(entity, ApiPlanItemDTO.class);
+    }
+
 }
\ No newline at end of file
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yaml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yaml
index c315b9f..4864dfc 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yaml
+++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yaml
@@ -47,7 +47,7 @@
     host: 172.16.8.100 # 地址
     port: 6379 # 端口
     database: 0 # 数据库索引
-    password: 123456 # 密码,建议生产环境开启
+    # password: 123456 # 密码,建议生产环境开启
 
 --- #################### MQ 消息队列相关配置 ####################
 
@@ -71,8 +71,7 @@
 
 influx-db:
   org: iailab
-  bucket: buk_shasteel
-  token: Q2qsriQG3FEfZ35lik1KSkFToma3bsgfQLwJrNQfSK06MC569sZ9mrQ0vLtsVYn70HMfQcC9gf_yUG16JQtm8w==
+  token: p-WkLXdPmHD4Cdij2PD-r92dLEQqjQ8V5KhyZYHYroBNVE0ZrW5VgzqWBNmXmiEdxEWaURC7rrKVzuM0XTEraQ==
   url: http://172.16.8.200:8086
   username: root
   password: iailab12345678

--
Gitblit v1.9.3