dengzedong
昨天 66782b7ba787a92b54640cbab0ebd201f0ad9e51
提交 | 用户 | 时间
ead005 1 package com.iailab.module.model.api.controller.admin;
2
3 import com.iailab.framework.common.pojo.CommonResult;
0a7d0f 4 import com.iailab.framework.common.pojo.PageResult;
5 import com.iailab.framework.common.util.object.BeanUtils;
ead005 6 import com.iailab.module.model.api.mcs.McsApi;
a4891a 7 import com.iailab.module.model.api.mcs.dto.*;
ead005 8 import com.iailab.module.model.common.utils.ApiSecurityUtils;
179784 9 import com.iailab.module.model.common.utils.ExcelUtil;
ead005 10 import io.swagger.v3.oas.annotations.Operation;
11 import io.swagger.v3.oas.annotations.tags.Tag;
12 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.factory.annotation.Autowired;
a4891a 14 import org.springframework.web.bind.annotation.*;
ead005 15
16 import javax.annotation.Resource;
17 import javax.servlet.http.HttpServletRequest;
18 import javax.servlet.http.HttpServletResponse;
179784 19 import java.io.IOException;
D 20 import java.text.SimpleDateFormat;
21 import java.util.Date;
a4891a 22 import java.util.List;
6eeac9 23 import java.util.Map;
0a7d0f 24
25 import static com.iailab.framework.common.pojo.CommonResult.success;
ead005 26
27 /**
28  * @author PanZhibao
29  * @Description
30  * @createTime 2024年11月14日
31  */
32 @Slf4j
33 @RestController
34 @RequestMapping("/model/api/mcs")
35 @Tag(name = "数据")
36 public class McsApiController {
37
38     @Resource
39     private ApiSecurityUtils apiSecurityUtils;
40
41     @Autowired
42     private McsApi mcsApi;
43
a4891a 44     @GetMapping("/predict-item/tree")
45     @Operation(summary = "预测项树")
46     public CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(HttpServletResponse response, HttpServletRequest
47             request) throws Exception {
48         apiSecurityUtils.validate(request);
49         List<PredictItemTreeDTO> list = mcsApi.getPredictItemTree();
50         return CommonResult.success(list);
51     }
52
ead005 53     @PostMapping("/predict-data/charts")
54     @Operation(summary = "预测数据图表")
55     public CommonResult<PreDataBarLineRespVO> getPreDataCharts(HttpServletResponse response, HttpServletRequest
56             request, @RequestBody PreDataBarLineReqVO reqVO) throws Exception {
57         apiSecurityUtils.validate(request);
9e844c 58         PreDataBarLineRespVO respVO = new PreDataBarLineRespVO();
59         try {
60             respVO = mcsApi.getPreDataCharts(reqVO);
61         } catch (Exception e) {
62             e.printStackTrace();
63         }
ead005 64         return CommonResult.success(respVO);
65     }
66
67     @PostMapping("/predict-data/item-chart")
68     @Operation(summary = "预测数据图表")
69     public CommonResult<PreDataItemChartRespVO> getPreDataItemChart(HttpServletResponse response, HttpServletRequest
70             request, @RequestBody PreDataItemChartReqVO reqVO) throws Exception {
71         apiSecurityUtils.validate(request);
72         PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO);
73         return CommonResult.success(respVO);
74     }
328ef4 75
977edc 76     @PostMapping("/predict-data/single-chart")
328ef4 77     @Operation(summary = "预测数据图表")
91343d 78     public CommonResult<PreDataSingleChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest
328ef4 79             request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception {
80         apiSecurityUtils.validate(request);
91343d 81         PreDataSingleChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO);
328ef4 82         return CommonResult.success(respVO);
83     }
f0a527 84
8a74e9 85     @PostMapping("/plan-data/single-chart")
86     @Operation(summary = "预测数据图表")
87     public CommonResult<PlanDataSingleChartRespVO> getPlanDataSingleChart(HttpServletResponse response, HttpServletRequest
88             request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception {
89         apiSecurityUtils.validate(request);
90         PlanDataSingleChartRespVO respVO = mcsApi.getPlanDataSingleChart(reqVO);
91         return CommonResult.success(respVO);
92     }
93
6eeac9 94     @PostMapping("/predict-data/cur")
D 95     @Operation(summary = "获取当前预测数据")
96     public CommonResult<Map<String, List<Object[]>>> getPreDataCur(HttpServletResponse response, HttpServletRequest
97             request, @RequestBody PreDataJsonReqVO reqVO)throws Exception {
98         apiSecurityUtils.validate(request);
99         reqVO.setPredictTime(new Date());
100         Map<String, List<Object[]>> map = mcsApi.getPreDataCur(reqVO);
101         return CommonResult.success(map);
102     }
103
179784 104     @GetMapping("/predict-data/exportValue")
D 105     @Operation(summary = "导出预测数据")
106     public void exportPointValue(@RequestParam("itemId") String itemId,
107                                  @RequestParam("startTime") String startTime,
108                                  @RequestParam("endTime") String endTime,
109                                  HttpServletResponse response) throws IOException {
110         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
111         PreDataItemChartReqVO reqVO = new PreDataItemChartReqVO();
112         reqVO.setItemId(itemId);
113         try {
114             if (startTime == "") {
055765 115                 reqVO.setStartTime(new Date((new Date()).getTime() - 60 * 60 * 1000));
179784 116             } else {
D 117                 reqVO.setStartTime(formatter.parse(startTime));
118
119             }
120             if (endTime == "") {
055765 121                 reqVO.setEndTime(new Date((new Date()).getTime() + 60 * 60 * 1000));
179784 122             } else {
D 123                 reqVO.setEndTime(formatter.parse(endTime));
124             }
125         } catch (Exception e) {
126             e.printStackTrace();
127         }
128         PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO);
129         try {
055765 130             String sheetTitle = "sheet1";
179784 131             ExcelUtil.exportchart(sheetTitle, respVO, response);
D 132         } catch (Exception ex) {
133             ex.printStackTrace();
134         }
135     }
055765 136
137     @GetMapping("/alarm-message/last-one")
138     @Operation(summary = "根据监控对象获取最新预警信息")
139     public CommonResult<AlarmMessageRespDTO> getLastAlarmMessage(HttpServletResponse response, HttpServletRequest
140             request, @RequestParam("alarmObj") String alarmObj) {
141         AlarmMessageRespDTO data = mcsApi.getLastAlarmMessage(alarmObj);
142         return CommonResult.success(data);
143     }
144
145     @GetMapping("/schedule-suggest/last-limit")
146     @Operation(summary = "根据监控对象获取最新预警信息")
147     public CommonResult<List<ScheduleSuggestRespDTO>> getLastLimitScheduleSuggest(HttpServletResponse response, HttpServletRequest
148             request, @RequestParam("scheduleObj") String scheduleObj, @RequestParam("limit") Integer limit) {
149         List<ScheduleSuggestRespDTO> data = mcsApi.getLastLimitScheduleSuggest(scheduleObj, limit);
150         return CommonResult.success(data);
151     }
0a7d0f 152
10edab 153     @PostMapping("/alarm-suggest/page")
0a7d0f 154     @Operation(summary = "获取预警信息和调度建议分页列表")
155     public CommonResult<PageResult<StAlarmAndSuggestRespVO>> getAlarmAndSuggestPage(@RequestBody StAlarmAndSuggestPageReqVO reqVO) {
156         PageResult<StAlarmAndSuggestRespVO> page = mcsApi.getAlarmAndSuggestPage(reqVO);
157         return success(BeanUtils.toBean(page, StAlarmAndSuggestRespVO.class));
158     }
66782b 159
D 160     @GetMapping("/chart/param/list")
161     @Operation(summary = "图表配置列表")
162     public CommonResult<List<ChartParamDTO>> getChartParamList(@RequestParam("chartCode") String chartCode) {
163         List<ChartParamDTO> chartParamList = mcsApi.getChartParamList(chartCode);
164         return CommonResult.success(chartParamList);
165     }
ead005 166 }