From 69bd5efa5e2849a560e604d0aa608d5492113915 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期二, 12 十一月 2024 15:44:52 +0800 Subject: [PATCH] 模型运行输出配置 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-) 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 ca8d21a..8bc9517 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 @@ -1,12 +1,14 @@ package com.iailab.module.model.mdk.predict; +import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.data.api.point.dto.ApiPointDTO; import com.iailab.module.data.enums.DataPointFreqEnum; +import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; import com.iailab.module.model.mcs.pre.service.MmItemResultService; import com.iailab.module.model.mdk.factory.ItemEntityFactory; -import com.iailab.module.model.mdk.vo.MmItemOutputVO; import com.iailab.module.model.mdk.vo.DataValueVO; +import com.iailab.module.model.mdk.vo.MmItemOutputVO; import com.iailab.module.model.mdk.vo.PredictResultVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; @@ -40,29 +42,26 @@ resultMap.put(itemOutPutList.get(0).getId(), predictResult.getPredictList()); return resultMap; } - ApiPointDTO point = dataPointApi.getInfoById(itemOutPutList.get(0).getPointId()); - List<Date> dateTimeList = new ArrayList<>(); - Integer rows = predictResult.getPredictMatrix().length; - Integer columns = predictResult.getPredictMatrix()[0].length; - Date tempTime = predictResult.getPredictTime(); - for (Integer i = 0; i < rows; i++) { - dateTimeList.add(tempTime); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(tempTime); - calendar.add(Calendar.SECOND, DataPointFreqEnum.getEumByCode(point.getMinfreqid()).getValue()); - tempTime = calendar.getTime(); - } - for (Integer i = 0; i < columns; i++) { + Map<MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs(); + HashMap<String,List<DataValueVO>> predictLists = new HashMap<>(); + for (Map.Entry<MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) { + ApiPointDTO point = dataPointApi.getInfoById(entry.getKey().getPointid()); + Integer pointMinfreq = DataPointFreqEnum.getEumByCode(point.getMinfreqid()).getValue(); + Integer rows = entry.getValue().length; List<DataValueVO> predictDataList = new ArrayList<>(); - for (Integer j = 0; j < rows; j++) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(predictResult.getPredictTime()); + for (Integer i = 0; i < rows; i++) { DataValueVO predictData = new DataValueVO(); - predictData.setDataTime(dateTimeList.get(j)); - predictData.setDataValue(Double.valueOf(predictResult.getPredictMatrix()[j][i])); + predictData.setDataTime(calendar.getTime()); + predictData.setDataValue(Double.valueOf(entry.getValue()[i])); predictDataList.add(predictData); + + calendar.add(Calendar.SECOND, pointMinfreq); } - resultMap.put(itemOutPutList.get(i).getId(), predictDataList); - predictResult.setPredictList(predictDataList); + resultMap.put(entry.getKey().getId(), predictDataList); } + predictResult.setPredictLists(predictLists); return resultMap; } @@ -72,6 +71,7 @@ * @param predictResult */ @Async + @DSTransactional public void savePredictResult(PredictResultVO predictResult) { Map<String, List<DataValueVO>> resultMap = convertToPredictData(predictResult); mmItemResultService.savePredictValue(resultMap, predictResult.getLt(), "n", predictResult.getPredictTime()); -- Gitblit v1.9.3