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