提交 | 用户 | 时间
|
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 |
|
8a74e9
|
83 |
@PostMapping("/plan-data/single-chart") |
潘 |
84 |
@Operation(summary = "预测数据图表") |
|
85 |
public CommonResult<PlanDataSingleChartRespVO> getPlanDataSingleChart(HttpServletResponse response, HttpServletRequest |
|
86 |
request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception { |
|
87 |
apiSecurityUtils.validate(request); |
|
88 |
PlanDataSingleChartRespVO respVO = mcsApi.getPlanDataSingleChart(reqVO); |
|
89 |
return CommonResult.success(respVO); |
|
90 |
} |
|
91 |
|
179784
|
92 |
@GetMapping("/predict-data/exportValue") |
D |
93 |
@Operation(summary = "导出预测数据") |
|
94 |
@ApiAccessLog(operateType = EXPORT) |
|
95 |
public void exportPointValue(@RequestParam("itemId") String itemId, |
|
96 |
@RequestParam("startTime") String startTime, |
|
97 |
@RequestParam("endTime") String endTime, |
|
98 |
HttpServletResponse response) throws IOException { |
|
99 |
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
100 |
PreDataItemChartReqVO reqVO = new PreDataItemChartReqVO(); |
|
101 |
reqVO.setItemId(itemId); |
|
102 |
try { |
|
103 |
if (startTime == "") { |
|
104 |
reqVO.setStartTime(new Date((new Date()).getTime() - 60*60*1000)); |
|
105 |
} else { |
|
106 |
reqVO.setStartTime(formatter.parse(startTime)); |
|
107 |
|
|
108 |
} |
|
109 |
if (endTime == "") { |
|
110 |
reqVO.setEndTime(new Date((new Date()).getTime() + 60*60*1000)); |
|
111 |
} else { |
|
112 |
reqVO.setEndTime(formatter.parse(endTime)); |
|
113 |
} |
|
114 |
} catch (Exception e) { |
|
115 |
e.printStackTrace(); |
|
116 |
} |
|
117 |
PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO); |
|
118 |
try { |
|
119 |
String sheetTitle = "sheet1"; |
|
120 |
ExcelUtil.exportchart(sheetTitle, respVO, response); |
|
121 |
} catch (Exception ex) { |
|
122 |
ex.printStackTrace(); |
|
123 |
} |
|
124 |
} |
ead005
|
125 |
} |