提交 | 用户 | 时间
|
ead005
|
1 |
package com.iailab.module.model.api.controller.admin; |
潘 |
2 |
|
179784
|
3 |
import com.iailab.framework.apilog.core.annotation.ApiAccessLog; |
ead005
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
潘 |
5 |
import com.iailab.module.model.api.mcs.McsApi; |
a4891a
|
6 |
import com.iailab.module.model.api.mcs.dto.*; |
ead005
|
7 |
import com.iailab.module.model.common.utils.ApiSecurityUtils; |
179784
|
8 |
import com.iailab.module.model.common.utils.ExcelUtil; |
ead005
|
9 |
import io.swagger.v3.oas.annotations.Operation; |
潘 |
10 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
11 |
import lombok.extern.slf4j.Slf4j; |
|
12 |
import org.springframework.beans.factory.annotation.Autowired; |
a4891a
|
13 |
import org.springframework.web.bind.annotation.*; |
ead005
|
14 |
|
潘 |
15 |
import javax.annotation.Resource; |
|
16 |
import javax.annotation.security.PermitAll; |
|
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; |
179784
|
23 |
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
ead005
|
24 |
|
潘 |
25 |
/** |
|
26 |
* @author PanZhibao |
|
27 |
* @Description |
|
28 |
* @createTime 2024年11月14日 |
|
29 |
*/ |
|
30 |
@Slf4j |
|
31 |
@RestController |
|
32 |
@RequestMapping("/model/api/mcs") |
|
33 |
@Tag(name = "数据") |
|
34 |
public class McsApiController { |
|
35 |
|
|
36 |
@Resource |
|
37 |
private ApiSecurityUtils apiSecurityUtils; |
|
38 |
|
|
39 |
@Autowired |
|
40 |
private McsApi mcsApi; |
|
41 |
|
a4891a
|
42 |
@GetMapping("/predict-item/tree") |
潘 |
43 |
@Operation(summary = "预测项树") |
|
44 |
public CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(HttpServletResponse response, HttpServletRequest |
|
45 |
request) throws Exception { |
|
46 |
apiSecurityUtils.validate(request); |
|
47 |
List<PredictItemTreeDTO> list = mcsApi.getPredictItemTree(); |
|
48 |
return CommonResult.success(list); |
|
49 |
} |
|
50 |
|
ead005
|
51 |
@PostMapping("/predict-data/charts") |
潘 |
52 |
@Operation(summary = "预测数据图表") |
|
53 |
public CommonResult<PreDataBarLineRespVO> getPreDataCharts(HttpServletResponse response, HttpServletRequest |
|
54 |
request, @RequestBody PreDataBarLineReqVO reqVO) throws Exception { |
|
55 |
apiSecurityUtils.validate(request); |
9e844c
|
56 |
PreDataBarLineRespVO respVO = new PreDataBarLineRespVO(); |
潘 |
57 |
try { |
|
58 |
respVO = mcsApi.getPreDataCharts(reqVO); |
|
59 |
} catch (Exception e) { |
|
60 |
e.printStackTrace(); |
|
61 |
} |
ead005
|
62 |
return CommonResult.success(respVO); |
潘 |
63 |
} |
|
64 |
|
|
65 |
@PostMapping("/predict-data/item-chart") |
|
66 |
@Operation(summary = "预测数据图表") |
|
67 |
public CommonResult<PreDataItemChartRespVO> getPreDataItemChart(HttpServletResponse response, HttpServletRequest |
|
68 |
request, @RequestBody PreDataItemChartReqVO reqVO) throws Exception { |
|
69 |
apiSecurityUtils.validate(request); |
|
70 |
PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO); |
|
71 |
return CommonResult.success(respVO); |
|
72 |
} |
328ef4
|
73 |
|
977edc
|
74 |
@PostMapping("/predict-data/single-chart") |
328ef4
|
75 |
@Operation(summary = "预测数据图表") |
91343d
|
76 |
public CommonResult<PreDataSingleChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest |
328ef4
|
77 |
request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception { |
潘 |
78 |
apiSecurityUtils.validate(request); |
91343d
|
79 |
PreDataSingleChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO); |
328ef4
|
80 |
return CommonResult.success(respVO); |
潘 |
81 |
} |
f0a527
|
82 |
|
179784
|
83 |
@GetMapping("/predict-data/exportValue") |
D |
84 |
@Operation(summary = "导出预测数据") |
|
85 |
@ApiAccessLog(operateType = EXPORT) |
|
86 |
public void exportPointValue(@RequestParam("itemId") String itemId, |
|
87 |
@RequestParam("startTime") String startTime, |
|
88 |
@RequestParam("endTime") String endTime, |
|
89 |
HttpServletResponse response) throws IOException { |
|
90 |
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
91 |
PreDataItemChartReqVO reqVO = new PreDataItemChartReqVO(); |
|
92 |
reqVO.setItemId(itemId); |
|
93 |
try { |
|
94 |
if (startTime == "") { |
|
95 |
reqVO.setStartTime(new Date((new Date()).getTime() - 60*60*1000)); |
|
96 |
} else { |
|
97 |
reqVO.setStartTime(formatter.parse(startTime)); |
|
98 |
|
|
99 |
} |
|
100 |
if (endTime == "") { |
|
101 |
reqVO.setEndTime(new Date((new Date()).getTime() + 60*60*1000)); |
|
102 |
} else { |
|
103 |
reqVO.setEndTime(formatter.parse(endTime)); |
|
104 |
} |
|
105 |
} catch (Exception e) { |
|
106 |
e.printStackTrace(); |
|
107 |
} |
|
108 |
PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO); |
|
109 |
try { |
|
110 |
String sheetTitle = "sheet1"; |
|
111 |
ExcelUtil.exportchart(sheetTitle, respVO, response); |
|
112 |
} catch (Exception ex) { |
|
113 |
ex.printStackTrace(); |
|
114 |
} |
|
115 |
} |
ead005
|
116 |
} |