删除double类型的模型输出特殊处理,double转为长度为1的double数组
| | |
| | | List<DataValueVO> getPredictValue(String outputid, Date startTime, Date endTime); |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat); |
| | | |
| | | void savePredictValue(Map<MmItemOutputEntity, Double> predictDoubleValues, Date predictTime); |
| | | } |
| | |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void savePredictValue(Map<MmItemOutputEntity, Double> predictDoubleValues, Date predictTime) { |
| | | List<InfluxModelResultPOJO> list = new ArrayList<>(); |
| | | for (Map.Entry<MmItemOutputEntity, Double> entry : predictDoubleValues.entrySet()) { |
| | | InfluxModelResultSimPOJO pojo = new InfluxModelResultSimPOJO(); |
| | | pojo.setValue(entry.getValue()); |
| | | pojo.setTimestamp(predictTime.toInstant()); |
| | | pojo.setOutPutId(entry.getKey().getId()); |
| | | pojo.setType(DataTypeEnum.FLOAT.getCode()); |
| | | list.add(pojo); |
| | | } |
| | | influxDBService.asyncWriteModelResults(list); |
| | | } |
| | | } |
| | |
| | | public void savePredictResult(PredictResultVO predictResult) { |
| | | Map<String, List<DataValueVO>> resultMap = convertToPredictData(predictResult); |
| | | mmItemResultService.savePredictValue(resultMap, predictResult.getLt(), "n", predictResult.getPredictTime()); |
| | | // 存double类型输出 |
| | | if (!CollectionUtils.isEmpty(predictResult.getPredictDoubleValues())) { |
| | | mmItemResultService.savePredictValue(predictResult.getPredictDoubleValues(), predictResult.getPredictTime()); |
| | | } |
| | | } |
| | | |
| | | public List<DataValueVO> getPredictValueByItemNo(String itemNo, Date start, Date end) { |
| | |
| | | |
| | | List<MmItemOutputEntity> itemOutputList = mmItemOutputService.getByItemid(predictModel.getItemid()); |
| | | Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>(); |
| | | Map<MmItemOutputEntity, Double> predictDoubleValues = new HashMap<>(); |
| | | for (MmItemOutputEntity output : itemOutputList) { |
| | | if (!modelResult.containsKey(output.getResultstr())) { |
| | | continue; |
| | |
| | | break; |
| | | case D: |
| | | Double temp3 = (Double) modelResult.get(output.getResultstr()); |
| | | predictDoubleValues.put(output, temp3); |
| | | predictMatrixs.put(output, new double[]{temp3}); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | result.setPredictMatrixs(predictMatrixs); |
| | | result.setPredictDoubleValues(predictDoubleValues); |
| | | result.setModelResult(modelResult); |
| | | result.setPredictTime(predictTime); |
| | | } catch (ModelResultErrorException ex) { |
| | |
| | | private Map<MmItemOutputEntity, double[]> predictMatrixs; |
| | | |
| | | /** |
| | | * double类型的模型输出 |
| | | */ |
| | | private Map<MmItemOutputEntity, Double> predictDoubleValues; |
| | | |
| | | /** |
| | | * 时间间隔 (当前预测时间 与 上一次预测时间 相差的分钟数;系统计算得出) |
| | | */ |
| | | private int t; |