提交 | 用户 | 时间
|
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.*; |
153763
|
8 |
import com.iailab.module.model.api.mdk.dto.StScheduleRecordVO; |
ead005
|
9 |
import com.iailab.module.model.common.utils.ApiSecurityUtils; |
179784
|
10 |
import com.iailab.module.model.common.utils.ExcelUtil; |
ead005
|
11 |
import io.swagger.v3.oas.annotations.Operation; |
潘 |
12 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
13 |
import lombok.extern.slf4j.Slf4j; |
|
14 |
import org.springframework.beans.factory.annotation.Autowired; |
61c1fd
|
15 |
import org.springframework.util.CollectionUtils; |
a4891a
|
16 |
import org.springframework.web.bind.annotation.*; |
ead005
|
17 |
|
潘 |
18 |
import javax.annotation.Resource; |
|
19 |
import javax.servlet.http.HttpServletRequest; |
|
20 |
import javax.servlet.http.HttpServletResponse; |
179784
|
21 |
import java.io.IOException; |
bffae5
|
22 |
import java.math.BigDecimal; |
179784
|
23 |
import java.text.SimpleDateFormat; |
61c1fd
|
24 |
import java.util.*; |
0a7d0f
|
25 |
|
潘 |
26 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
ead005
|
27 |
|
潘 |
28 |
/** |
|
29 |
* @author PanZhibao |
|
30 |
* @Description |
|
31 |
* @createTime 2024年11月14日 |
|
32 |
*/ |
|
33 |
@Slf4j |
|
34 |
@RestController |
|
35 |
@RequestMapping("/model/api/mcs") |
|
36 |
@Tag(name = "数据") |
|
37 |
public class McsApiController { |
|
38 |
|
|
39 |
@Resource |
|
40 |
private ApiSecurityUtils apiSecurityUtils; |
|
41 |
|
|
42 |
@Autowired |
|
43 |
private McsApi mcsApi; |
|
44 |
|
a4891a
|
45 |
@GetMapping("/predict-item/tree") |
潘 |
46 |
@Operation(summary = "预测项树") |
|
47 |
public CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(HttpServletResponse response, HttpServletRequest |
|
48 |
request) throws Exception { |
|
49 |
apiSecurityUtils.validate(request); |
|
50 |
List<PredictItemTreeDTO> list = mcsApi.getPredictItemTree(); |
|
51 |
return CommonResult.success(list); |
|
52 |
} |
|
53 |
|
ead005
|
54 |
@PostMapping("/predict-data/charts") |
潘 |
55 |
@Operation(summary = "预测数据图表") |
|
56 |
public CommonResult<PreDataBarLineRespVO> getPreDataCharts(HttpServletResponse response, HttpServletRequest |
|
57 |
request, @RequestBody PreDataBarLineReqVO reqVO) throws Exception { |
|
58 |
apiSecurityUtils.validate(request); |
9e844c
|
59 |
PreDataBarLineRespVO respVO = new PreDataBarLineRespVO(); |
潘 |
60 |
try { |
|
61 |
respVO = mcsApi.getPreDataCharts(reqVO); |
|
62 |
} catch (Exception e) { |
|
63 |
e.printStackTrace(); |
|
64 |
} |
ead005
|
65 |
return CommonResult.success(respVO); |
潘 |
66 |
} |
|
67 |
|
|
68 |
@PostMapping("/predict-data/item-chart") |
|
69 |
@Operation(summary = "预测数据图表") |
|
70 |
public CommonResult<PreDataItemChartRespVO> getPreDataItemChart(HttpServletResponse response, HttpServletRequest |
|
71 |
request, @RequestBody PreDataItemChartReqVO reqVO) throws Exception { |
|
72 |
apiSecurityUtils.validate(request); |
|
73 |
PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO); |
|
74 |
return CommonResult.success(respVO); |
|
75 |
} |
328ef4
|
76 |
|
977edc
|
77 |
@PostMapping("/predict-data/single-chart") |
328ef4
|
78 |
@Operation(summary = "预测数据图表") |
91343d
|
79 |
public CommonResult<PreDataSingleChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest |
328ef4
|
80 |
request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception { |
潘 |
81 |
apiSecurityUtils.validate(request); |
91343d
|
82 |
PreDataSingleChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO); |
328ef4
|
83 |
return CommonResult.success(respVO); |
潘 |
84 |
} |
f0a527
|
85 |
|
8a74e9
|
86 |
@PostMapping("/plan-data/single-chart") |
潘 |
87 |
@Operation(summary = "预测数据图表") |
|
88 |
public CommonResult<PlanDataSingleChartRespVO> getPlanDataSingleChart(HttpServletResponse response, HttpServletRequest |
|
89 |
request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception { |
|
90 |
apiSecurityUtils.validate(request); |
|
91 |
PlanDataSingleChartRespVO respVO = mcsApi.getPlanDataSingleChart(reqVO); |
|
92 |
return CommonResult.success(respVO); |
|
93 |
} |
|
94 |
|
6eeac9
|
95 |
@PostMapping("/predict-data/cur") |
D |
96 |
@Operation(summary = "获取当前预测数据") |
|
97 |
public CommonResult<Map<String, List<Object[]>>> getPreDataCur(HttpServletResponse response, HttpServletRequest |
|
98 |
request, @RequestBody PreDataJsonReqVO reqVO)throws Exception { |
|
99 |
apiSecurityUtils.validate(request); |
|
100 |
reqVO.setPredictTime(new Date()); |
|
101 |
Map<String, List<Object[]>> map = mcsApi.getPreDataCur(reqVO); |
|
102 |
return CommonResult.success(map); |
|
103 |
} |
|
104 |
|
179784
|
105 |
@GetMapping("/predict-data/exportValue") |
D |
106 |
@Operation(summary = "导出预测数据") |
|
107 |
public void exportPointValue(@RequestParam("itemId") String itemId, |
|
108 |
@RequestParam("startTime") String startTime, |
|
109 |
@RequestParam("endTime") String endTime, |
|
110 |
HttpServletResponse response) throws IOException { |
|
111 |
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
112 |
PreDataItemChartReqVO reqVO = new PreDataItemChartReqVO(); |
|
113 |
reqVO.setItemId(itemId); |
|
114 |
try { |
|
115 |
if (startTime == "") { |
055765
|
116 |
reqVO.setStartTime(new Date((new Date()).getTime() - 60 * 60 * 1000)); |
179784
|
117 |
} else { |
D |
118 |
reqVO.setStartTime(formatter.parse(startTime)); |
|
119 |
|
|
120 |
} |
|
121 |
if (endTime == "") { |
055765
|
122 |
reqVO.setEndTime(new Date((new Date()).getTime() + 60 * 60 * 1000)); |
179784
|
123 |
} else { |
D |
124 |
reqVO.setEndTime(formatter.parse(endTime)); |
|
125 |
} |
|
126 |
} catch (Exception e) { |
|
127 |
e.printStackTrace(); |
|
128 |
} |
|
129 |
PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO); |
|
130 |
try { |
055765
|
131 |
String sheetTitle = "sheet1"; |
179784
|
132 |
ExcelUtil.exportchart(sheetTitle, respVO, response); |
D |
133 |
} catch (Exception ex) { |
|
134 |
ex.printStackTrace(); |
|
135 |
} |
|
136 |
} |
055765
|
137 |
|
潘 |
138 |
@GetMapping("/alarm-message/last-one") |
|
139 |
@Operation(summary = "根据监控对象获取最新预警信息") |
|
140 |
public CommonResult<AlarmMessageRespDTO> getLastAlarmMessage(HttpServletResponse response, HttpServletRequest |
|
141 |
request, @RequestParam("alarmObj") String alarmObj) { |
|
142 |
AlarmMessageRespDTO data = mcsApi.getLastAlarmMessage(alarmObj); |
|
143 |
return CommonResult.success(data); |
|
144 |
} |
|
145 |
|
|
146 |
@GetMapping("/schedule-suggest/last-limit") |
|
147 |
@Operation(summary = "根据监控对象获取最新预警信息") |
|
148 |
public CommonResult<List<ScheduleSuggestRespDTO>> getLastLimitScheduleSuggest(HttpServletResponse response, HttpServletRequest |
|
149 |
request, @RequestParam("scheduleObj") String scheduleObj, @RequestParam("limit") Integer limit) { |
|
150 |
List<ScheduleSuggestRespDTO> data = mcsApi.getLastLimitScheduleSuggest(scheduleObj, limit); |
|
151 |
return CommonResult.success(data); |
|
152 |
} |
0a7d0f
|
153 |
|
10edab
|
154 |
@PostMapping("/alarm-suggest/page") |
0a7d0f
|
155 |
@Operation(summary = "获取预警信息和调度建议分页列表") |
潘 |
156 |
public CommonResult<PageResult<StAlarmAndSuggestRespVO>> getAlarmAndSuggestPage(@RequestBody StAlarmAndSuggestPageReqVO reqVO) { |
|
157 |
PageResult<StAlarmAndSuggestRespVO> page = mcsApi.getAlarmAndSuggestPage(reqVO); |
|
158 |
return success(BeanUtils.toBean(page, StAlarmAndSuggestRespVO.class)); |
|
159 |
} |
66782b
|
160 |
|
D |
161 |
@GetMapping("/chart/param/list") |
|
162 |
@Operation(summary = "图表配置列表") |
|
163 |
public CommonResult<List<ChartParamDTO>> getChartParamList(@RequestParam("chartCode") String chartCode) { |
|
164 |
List<ChartParamDTO> chartParamList = mcsApi.getChartParamList(chartCode); |
|
165 |
return CommonResult.success(chartParamList); |
|
166 |
} |
22e321
|
167 |
|
D |
168 |
@PostMapping("/predict-data/doubleValue") |
|
169 |
@Operation(summary = "获取多个预测项Double类型数据") |
|
170 |
public CommonResult<Map<String, Map<String,Double>>> getPreDoubleData(@RequestBody PreDoubleDataReqVO reqVO) { |
|
171 |
Map<String, Map<String,Double>> map = mcsApi.getPreDoubleData(reqVO); |
|
172 |
return CommonResult.success(map); |
|
173 |
} |
bffae5
|
174 |
|
潘 |
175 |
@PostMapping("/predict-data/last-value") |
|
176 |
@Operation(summary = "获取最后预测值") |
|
177 |
public CommonResult<Map<String, BigDecimal>> getPredictLastValue(@RequestBody PredictLastValueReqVO reqVO) { |
|
178 |
Map<String, BigDecimal> data = mcsApi.getPredictLastValue(reqVO); |
|
179 |
return CommonResult.success(data); |
|
180 |
} |
dec0c2
|
181 |
|
D |
182 |
@GetMapping("/schedule-data/last") |
|
183 |
@Operation(summary = "调度模型最新结果查询") |
153763
|
184 |
public CommonResult<List<StScheduleRecordVO>> getLastScheduleData(@RequestParam String scheduleCode, @RequestParam Integer limit) { |
D |
185 |
if (null == limit) { |
|
186 |
limit = 1; |
|
187 |
} |
|
188 |
return CommonResult.success(mcsApi.getLastScheduleData(scheduleCode,limit)); |
dec0c2
|
189 |
} |
D |
190 |
|
61c1fd
|
191 |
@PostMapping("/schedule-data/last/more") |
D |
192 |
@Operation(summary = "多个调度模型最新结果查询") |
|
193 |
public CommonResult<Map<String,List<StScheduleRecordVO>>> getMoreLastScheduleData(@RequestBody Map<String,Object> params) { |
|
194 |
if (!params.containsKey("scheduleCodes")) { |
|
195 |
return success(new HashMap<>()); |
|
196 |
} |
|
197 |
Set<String> scheduleCodes = new HashSet<>(((List<String>) params.get("scheduleCodes"))); |
|
198 |
if (CollectionUtils.isEmpty(scheduleCodes)) { |
|
199 |
return success(new HashMap<>()); |
|
200 |
} |
|
201 |
Integer limit = 1; |
|
202 |
if (params.containsKey("limit")) { |
|
203 |
limit = Integer.parseInt(params.get("limit").toString()); |
|
204 |
} |
|
205 |
|
|
206 |
Map<String,List<StScheduleRecordVO>> result = new HashMap<>(scheduleCodes.size()); |
|
207 |
for (String scheduleCode : scheduleCodes) { |
|
208 |
result.put(scheduleCode,mcsApi.getLastScheduleData(scheduleCode, limit)); |
|
209 |
} |
|
210 |
return CommonResult.success(result); |
dec0c2
|
211 |
} |
153763
|
212 |
|
D |
213 |
@PostMapping("/predict-data/itemNo") |
|
214 |
@Operation(summary = "查询时间范围内预测结果") |
|
215 |
CommonResult<Map<String,List<Object[]>>> getPredictDataItemNo(@RequestBody PreDataItemNoReqVO reqVO) { |
|
216 |
return CommonResult.success(mcsApi.getPredictDataItemNo(reqVO)); |
|
217 |
} |
af72d8
|
218 |
|
J |
219 |
@GetMapping("/electricityPrice/list") |
|
220 |
@Operation(summary = "电价表") |
|
221 |
public CommonResult<List<ElectricityPriceSegmentedDTO>> getElectricityPriceList() { |
|
222 |
List<ElectricityPriceSegmentedDTO> electricityPriceSegmentedList = mcsApi.getElectricityPriceList(); |
|
223 |
return CommonResult.success(electricityPriceSegmentedList); |
|
224 |
} |
ead005
|
225 |
} |