From 97d38f7b7f7d95fe38cdbb79960106c15454b6ba Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 19 十一月 2024 15:23:51 +0800
Subject: [PATCH] 预警信息

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
index 247f271..79e2d5b 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
@@ -1,9 +1,11 @@
 package com.iailab.module.model.api.controller.admin;
 
+import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
 import com.iailab.framework.common.pojo.CommonResult;
 import com.iailab.module.model.api.mcs.McsApi;
 import com.iailab.module.model.api.mcs.dto.*;
 import com.iailab.module.model.common.utils.ApiSecurityUtils;
+import com.iailab.module.model.common.utils.ExcelUtil;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
@@ -14,7 +16,11 @@
 import javax.annotation.security.PermitAll;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
+import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 
 /**
  * @author PanZhibao
@@ -33,7 +39,6 @@
     @Autowired
     private McsApi mcsApi;
 
-    @PermitAll
     @GetMapping("/predict-item/tree")
     @Operation(summary = "预测项树")
     public CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(HttpServletResponse response, HttpServletRequest
@@ -43,17 +48,20 @@
         return CommonResult.success(list);
     }
 
-    @PermitAll
     @PostMapping("/predict-data/charts")
     @Operation(summary = "预测数据图表")
     public CommonResult<PreDataBarLineRespVO> getPreDataCharts(HttpServletResponse response, HttpServletRequest
             request, @RequestBody PreDataBarLineReqVO reqVO) throws Exception {
         apiSecurityUtils.validate(request);
-        PreDataBarLineRespVO respVO = mcsApi.getPreDataCharts(reqVO);
+        PreDataBarLineRespVO respVO = new PreDataBarLineRespVO();
+        try {
+            respVO = mcsApi.getPreDataCharts(reqVO);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         return CommonResult.success(respVO);
     }
 
-    @PermitAll
     @PostMapping("/predict-data/item-chart")
     @Operation(summary = "预测数据图表")
     public CommonResult<PreDataItemChartRespVO> getPreDataItemChart(HttpServletResponse response, HttpServletRequest
@@ -62,4 +70,47 @@
         PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO);
         return CommonResult.success(respVO);
     }
+
+    @PostMapping("/predict-data/single-chart")
+    @Operation(summary = "预测数据图表")
+    public CommonResult<PreDataSingleChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest
+            request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception {
+        apiSecurityUtils.validate(request);
+        PreDataSingleChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO);
+        return CommonResult.success(respVO);
+    }
+
+    @GetMapping("/predict-data/exportValue")
+    @Operation(summary = "导出预测数据")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportPointValue(@RequestParam("itemId") String itemId,
+                                 @RequestParam("startTime") String startTime,
+                                 @RequestParam("endTime") String endTime,
+                                 HttpServletResponse response) throws IOException {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        PreDataItemChartReqVO reqVO = new PreDataItemChartReqVO();
+        reqVO.setItemId(itemId);
+        try {
+            if (startTime == "") {
+                reqVO.setStartTime(new Date((new Date()).getTime() - 60*60*1000));
+            } else {
+                reqVO.setStartTime(formatter.parse(startTime));
+
+            }
+            if (endTime == "") {
+                reqVO.setEndTime(new Date((new Date()).getTime() + 60*60*1000));
+            } else {
+                reqVO.setEndTime(formatter.parse(endTime));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO);
+        try {
+            String sheetTitle =  "sheet1";
+            ExcelUtil.exportchart(sheetTitle, respVO, response);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3