From a6e46fe2b5729e7468b6f3c4e079232801c22520 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期一, 16 十二月 2024 18:19:37 +0800 Subject: [PATCH] 模型输出类型添加double类型 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java | 16 ++++++++++++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java | 8 +++++++- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java | 3 +++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/OutResultType.java | 3 ++- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java | 4 ++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/PredictResultVO.java | 1 + 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/OutResultType.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/OutResultType.java index 55aa358..95e6608 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/OutResultType.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/OutResultType.java @@ -12,7 +12,8 @@ @AllArgsConstructor public enum OutResultType { D1(1, "一维数组"), - D2(2, "二维数组"); + D2(2, "二维数组"), + D(3, "二维数组"); private Integer code; private String desc; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java index bc61c47..55dac3f 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java @@ -1,5 +1,6 @@ package com.iailab.module.model.mcs.pre.service; +import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; import com.iailab.module.model.mdk.vo.DataValueVO; import java.util.Date; @@ -17,4 +18,6 @@ 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); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java index 99455b0..26ec871 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iailab.framework.common.util.date.DateUtils; import com.iailab.module.model.mcs.pre.dao.MmItemResultDao; +import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; import com.iailab.module.model.mcs.pre.entity.MmItemResultEntity; import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; import com.iailab.module.model.mcs.pre.service.MmItemResultService; @@ -138,4 +139,19 @@ }); return result; } + + @Override + public void savePredictValue(Map<MmItemOutputEntity, Double> predictDoubleValues, Date predictTime) { + for (Map.Entry<MmItemOutputEntity, Double> entry : predictDoubleValues.entrySet()) { + MmItemResultJsonEntity resultJson = new MmItemResultJsonEntity(); + resultJson.setId(UUID.randomUUID().toString()); + resultJson.setOutputid(entry.getKey().getId()); + resultJson.setPredicttime(predictTime); + resultJson.setCumulant(String.valueOf(entry.getValue())); + Map<String, Object> map4 = new HashMap(2); + map4.put("TABLENAME", "T_MM_ITEM_RESULT_JSON"); + map4.put("entity", resultJson); + mmItemResultDao.savePredictJsonValue(map4); + } + } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java index 39729a7..d9bfcc7 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java @@ -91,6 +91,10 @@ 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) { diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java index 88cefdd..a15f603 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java @@ -108,7 +108,8 @@ log.info(String.valueOf(jsonObjResult)); List<MmItemOutputEntity> itemOutputList = mmItemOutputService.getByItemid(predictModel.getItemid()); - Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>(itemOutputList.size()); + Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>(); + Map<MmItemOutputEntity, Double> predictDoubleValues = new HashMap<>(); for (MmItemOutputEntity output : itemOutputList) { if (!modelResult.containsKey(output.getResultstr())) { continue; @@ -127,11 +128,16 @@ } predictMatrixs.put(output, tempColumn); break; + case D: + Double temp3 = (Double) modelResult.get(output.getResultstr()); + predictDoubleValues.put(output, temp3); + break; default: break; } } result.setPredictMatrixs(predictMatrixs); + result.setPredictDoubleValues(predictDoubleValues); result.setModelResult(modelResult); result.setPredictTime(predictTime); } catch (Exception ex) { diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/PredictResultVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/PredictResultVO.java index be560fe..51b1aad 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/PredictResultVO.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/PredictResultVO.java @@ -36,6 +36,7 @@ * 统一预测入口的预测类型(循环调用、手动调用) Map<MmItemOutputEntity,double[]> */ private Map<MmItemOutputEntity, double[]> predictMatrixs; + private Map<MmItemOutputEntity, Double> predictDoubleValues; /** * 时间间隔 (当前预测时间 与 上一次预测时间 相差的分钟数;系统计算得出) -- Gitblit v1.9.3