| | |
| | | package com.iailab.module.data.api.controller; |
| | | |
| | | import com.iailab.api.IFeignModelApi; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.data.common.dto.IndexQueryDTO; |
| | |
| | | |
| | | @Resource |
| | | private IndItemCollector indItemCollector; |
| | | |
| | | @Resource |
| | | private IFeignModelApi feignModelApi; |
| | | |
| | | @PostMapping("/point/history") |
| | | @Operation(summary = "point历史数据") |
| | |
| | | }); |
| | | return R.ok().put("data", data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/ind-item/values-trend") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R indItemValuesTrend(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> itemNos) { |
| | | try { |
| | | apiSecurityUtils.validate(request); |
| | | Map<String, Object> CommonResult = new HashMap<>(); |
| | | Map<String, List<IndItemValueDTO>> values = indItemCollector.getValueList(itemNos); |
| | | CommonResult.put("values", values); |
| | | |
| | | Map<String, Map<String, Object>> trend = new HashMap<>(); |
| | | Map<String, Object> params = new HashMap<>(1); |
| | | params.put("modelCode", "trend_analysis"); |
| | | values.forEach((k, v) -> { |
| | | try { |
| | | List<double[][]> sampleDataList = new ArrayList<>(); |
| | | List<IndItemValueDTO> nv = v.stream().filter(dto -> { |
| | | return dto.getDataValue() != null; |
| | | }).collect(Collectors.toList()); |
| | | double[][] mix = new double[nv.size()][1]; |
| | | for (int i = 0; i < nv.size(); i++) { |
| | | mix[i][0] = nv.get(i).getDataValue().doubleValue(); |
| | | } |
| | | sampleDataList.add(mix); |
| | | Map<String, Object> trendItem = feignModelApi.runModel(params, sampleDataList); |
| | | trend.put(k, trendItem); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | }); |
| | | CommonResult.put("trend", trend); |
| | | return R.ok().put("data", CommonResult); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |