From 91343d9a8d97b823f1b662f980790bb901bca46b Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 18 十一月 2024 17:53:15 +0800
Subject: [PATCH] 图表数据查询

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelParamServiceImpl.java     |   31 ++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java            |    3 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java |   15 +
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java           |   20 +
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java                      |   19 +
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java                    |    2 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java          |   12 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java                 |   31 ++-
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/dto/ColumnItem.java                        |    4 
 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java                                   |    2 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java            |    4 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java                                   |   95 ++++++++
 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartRespVO.java             |   40 ++++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/PreLineTypeEnum.java                     |   32 +++
 /dev/null                                                                                                                               |  150 ---------------
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmModelParamService.java              |    4 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java     |    5 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java                |   23 +
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictModelService.java            |    4 
 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartReqVO.java              |    8 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java             |    2 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java                         |    2 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java    |   31 ++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java   |   24 ++
 24 files changed, 361 insertions(+), 202 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java
index 6e5fa27..53c2cb8 100644
--- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java
+++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java
@@ -38,7 +38,7 @@
 
     @PostMapping(PREFIX + "/predict-data/single-chart")
     @Operation(summary = "预测数据图表")
-    PreDataItemChartRespVO getPreDataSingleChart(@RequestBody PreDataSingleChartReqVO reqVO);
+    PreDataSingleChartRespVO getPreDataSingleChart(@RequestBody PreDataSingleChartReqVO reqVO);
 
     @PostMapping(PREFIX + "/alarm-message/create")
     @Operation(summary = "添加预警信息")
diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartReqVO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartReqVO.java
index 00206fd..34413e0 100644
--- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartReqVO.java
+++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartReqVO.java
@@ -22,4 +22,12 @@
     @Schema(description = "预测时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date predictTime;
+
+    @Schema(description = "开始时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startTime;
+
+    @Schema(description = "结束时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
 }
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartRespVO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartRespVO.java
new file mode 100644
index 0000000..f7d1df1
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataSingleChartRespVO.java
@@ -0,0 +1,40 @@
+package com.iailab.module.model.api.mcs.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年11月18日
+ */
+@Data
+public class PreDataSingleChartRespVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "预测时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date predictTime;
+
+    @Schema(description = "开始时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startTime;
+
+    @Schema(description = "结束时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
+
+    @Schema(description = "图例")
+    private List<String> legend;
+
+    @Schema(description = "X轴数据")
+    private List<String> categories;
+
+    private PreDataViewRespDTO dataView;
+
+}
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
index 623c97d..ea0e09e 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
@@ -7,10 +7,14 @@
 import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO;
 import com.iailab.module.model.api.mcs.McsApi;
 import com.iailab.module.model.api.mcs.dto.*;
+import com.iailab.module.model.common.enums.CommonConstant;
+import com.iailab.module.model.common.enums.PreLineTypeEnum;
 import com.iailab.module.model.mcs.pre.entity.DmModuleEntity;
 import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
 import com.iailab.module.model.mcs.pre.service.*;
 import com.iailab.module.model.mdk.vo.ItemVO;
+import com.iailab.module.model.mpk.service.ChartParamService;
+import com.iailab.module.model.mpk.service.ChartService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
@@ -47,6 +51,12 @@
 
     @Autowired
     private DataPointApi dataPointApi;
+
+    @Autowired
+    private MmItemResultJsonService mmItemResultJsonService;
+
+    @Autowired
+    private ChartService chartService;
 
     private int HOUR_MINS = 60;
 
@@ -211,20 +221,20 @@
         if (startTime == null) {
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(predictItem.getLastTime());
-            calendar.add(Calendar.HOUR_OF_DAY, -1);
+            calendar.add(Calendar.MINUTE, -1 * predictItem.getPredictLength());
             startTime = calendar.getTime();
         }
         Date endTime = reqVO.getEndTime();
         if (endTime == null) {
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(predictItem.getLastTime());
-            calendar.add(Calendar.HOUR_OF_DAY, 1);
+            calendar.add(Calendar.MINUTE, predictItem.getPredictLength());
             endTime = calendar.getTime();
         }
         if (endTime.getTime() <= startTime.getTime()) {
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(startTime);
-            calendar.add(Calendar.HOUR_OF_DAY, 1);
+            calendar.add(Calendar.MINUTE, predictItem.getPredictLength());
             endTime = calendar.getTime();
         }
 
@@ -251,10 +261,83 @@
     }
 
     @Override
-    public PreDataItemChartRespVO getPreDataSingleChart(PreDataSingleChartReqVO reqVO) {
-        PreDataItemChartRespVO result = new PreDataItemChartRespVO();
+    public PreDataSingleChartRespVO getPreDataSingleChart(PreDataSingleChartReqVO reqVO) {
+        PreDataSingleChartRespVO result = new PreDataSingleChartRespVO();
 
-
+        Map<String, String> chartParams = chartService.getByChartCode(reqVO.getChartCode());
+        if (CollectionUtils.isEmpty(chartParams)) {
+            return result;
+        }
+        String itemCode = chartParams.get(CommonConstant.ITEM_CODE);
+        if (itemCode == null) {
+            return result;
+        }
+        String resultStr = chartParams.get(CommonConstant.RESULT_STR);
+        if (resultStr == null) {
+            return result;
+        }
+        ItemVO predictItem = mmPredictItemService.getItemByItemNo(itemCode);
+        if (predictItem == null || predictItem.getLastTime() == null) {
+            return result;
+        }
+        PreLineTypeEnum lineType = chartParams.get(CommonConstant.LINE_TYPE) == null ? PreLineTypeEnum.TN : PreLineTypeEnum.valueOf(chartParams.get(CommonConstant.LINE_TYPE));
+        BigDecimal rangeH = chartParams.get(CommonConstant.RANGE_H) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.RANGE_H));
+        BigDecimal rangeL = chartParams.get(CommonConstant.RANGE_L) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.RANGE_L));
+        BigDecimal limitH = chartParams.get(CommonConstant.LIMIT_H) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.LIMIT_H));
+        BigDecimal limitL = chartParams.get(CommonConstant.LIMIT_L) == null ? BigDecimal.ZERO : new BigDecimal(chartParams.get(CommonConstant.LIMIT_L));
+        int lengthLeft = chartParams.get(CommonConstant.LENGTH_LEFT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_LEFT)).intValue();
+        int lengthRight = chartParams.get(CommonConstant.LENGTH_RIGHT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_RIGHT)).intValue();
+        result.setPredictTime(predictItem.getLastTime());
+        Date predictTime = predictItem.getLastTime();
+        Date startTime = reqVO.getStartTime();
+        if (startTime == null) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(predictItem.getLastTime());
+            calendar.add(Calendar.MINUTE, -1 * lengthLeft);
+            startTime = calendar.getTime();
+        }
+        Date endTime = reqVO.getEndTime();
+        if (endTime == null) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(predictItem.getLastTime());
+            calendar.add(Calendar.MINUTE, lengthRight);
+            endTime = calendar.getTime();
+        }
+        if (endTime.getTime() <= startTime.getTime()) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(startTime);
+            calendar.add(Calendar.MINUTE, lengthRight);
+            endTime = calendar.getTime();
+        }
+        List<String> categories = DateUtils.getTimeScale(startTime, endTime, predictItem.getGranularity());
+        List<String> legend = new ArrayList<>();
+        MmItemOutputEntity outPut = mmItemOutputService.getByItemid(predictItem.getId(), resultStr);
+        PreDataViewRespDTO dataView = new PreDataViewRespDTO();
+        dataView.setItemId(predictItem.getId());
+        dataView.setItemName(predictItem.getItemName());
+        dataView.setResultstr(resultStr);
+        dataView.setRangeH(rangeH);
+        dataView.setRangeL(rangeL);
+        dataView.setLimitH(limitH);
+        dataView.setLimitL(limitL);
+        dataView.setRealData(getHisData(outPut.getPointid(), startTime, endTime));
+        dataView.setCurData(mmItemResultJsonService.getData(outPut.getId(), predictTime));
+        switch (lineType) {
+            case TN:
+                dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), startTime, endTime));
+                break;
+            case TL:
+                dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), predictTime, endTime));
+                dataView.setPreDataL(mmItemResultLastPointService.getData(outPut.getId(), startTime, endTime));
+                break;
+            default:
+                break;
+        }
+        result.setStartTime(startTime);
+        result.setEndTime(endTime);
+        result.setCategories(categories);
+        result.setLegend(legend);
+        result.setDataView(dataView);
         return result;
     }
 
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
index affdaac..73ae82f 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java
@@ -82,10 +82,10 @@
     @PermitAll
     @GetMapping("/predict-data/single-chart")
     @Operation(summary = "预测数据图表")
-    public CommonResult<PreDataItemChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest
+    public CommonResult<PreDataSingleChartRespVO> getPreDataSingleChart(HttpServletResponse response, HttpServletRequest
             request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception {
         apiSecurityUtils.validate(request);
-        PreDataItemChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO);
+        PreDataSingleChartRespVO respVO = mcsApi.getPreDataSingleChart(reqVO);
         return CommonResult.success(respVO);
     }
 
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java
index 0594498..bcc49e6 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java
@@ -21,4 +21,23 @@
     String MDK_STATUS_CODE = "status_code";
 
     String MDK_STATUS_100 = "100";
+
+
+    String RANGE_H = "RANGE_H";
+
+    String RANGE_L = "RANGE_L";
+
+    String LIMIT_H = "LIMIT_H";
+
+    String LIMIT_L = "LIMIT_L";
+
+    String ITEM_CODE = "ITEM_CODE";
+    String RESULT_STR = "RESULT_STR";
+
+    String LENGTH_LEFT = "LENGTH_LEFT";
+
+    String LENGTH_RIGHT = "LENGTH_RIGHT";
+
+    // 趋势预测曲线类型,0:展示T+N,1:展示T+L,
+    String LINE_TYPE = "LINE_TYPE";
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/PreLineTypeEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/PreLineTypeEnum.java
new file mode 100644
index 0000000..a47c1c3
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/PreLineTypeEnum.java
@@ -0,0 +1,32 @@
+package com.iailab.module.model.common.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年11月18日
+ */
+@Getter
+@AllArgsConstructor
+public enum PreLineTypeEnum {
+    TN("0", "T+N"),
+    TL("1", "T+L");
+
+    private String code;
+    private String desc;
+
+    public static PreLineTypeEnum getEumByCode(String code) {
+        if (code == null) {
+            return null;
+        }
+
+        for (PreLineTypeEnum statusEnum : PreLineTypeEnum.values()) {
+            if (statusEnum.getCode().equals(code)) {
+                return statusEnum;
+            }
+        }
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java
index 2a40080..342ebf5 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java
@@ -1,5 +1,6 @@
 package com.iailab.module.model.framework.rpc.config;
 
+import com.iailab.module.data.api.ind.IndItemApi;
 import com.iailab.module.data.api.plan.PlanItemApi;
 import com.iailab.module.data.api.point.DataPointApi;
 import com.iailab.module.infra.api.config.ConfigApi;
@@ -9,6 +10,6 @@
 import org.springframework.context.annotation.Configuration;
 
 @Configuration(proxyBeanMethods = false)
-@EnableFeignClients(clients = {DataPointApi.class, PlanItemApi.class, ConfigApi.class, TenantApi.class, AdminUserApi.class})
+@EnableFeignClients(clients = {DataPointApi.class, PlanItemApi.class, IndItemApi.class, ConfigApi.class, TenantApi.class, AdminUserApi.class})
 public class RpcConfiguration {
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmModelParamService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmModelParamService.java
index 1d48162..830649d 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmModelParamService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmModelParamService.java
@@ -12,5 +12,9 @@
 
     void saveList(List<MmModelParamEntity> list);
 
+    List<MmModelParamEntity> getByModelidFromCatch(String modelId);
+
     List<MmModelParamEntity> getByModelid(String modelid);
+
+    void clearCache();
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
index 457cdaa..89940ad 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
@@ -30,6 +30,8 @@
 
     ItemVO getItemById(String itemId);
 
+    void clearCatch();
+
     MergeItemVO getMergeItemByItemId(String itemId);
 
     PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO);
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictModelService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictModelService.java
index 29f3e54..db336ce 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictModelService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictModelService.java
@@ -16,6 +16,8 @@
 
     void update(MmPredictModelEntity predictModel);
 
+    MmPredictModelEntity getInfoFromCatch(String id);
+
     MmPredictModelEntity getInfo(String id);
 
     BigDecimal getSampleLength(String id);
@@ -23,4 +25,6 @@
     List<MmPredictModelEntity> getNoSettingmapPredictModel(Map<String, Object> params);
 
     List<MmPredictModelEntity> getActiveModelByItemId(String itemId);
+
+    void clearCache();
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
index 409434a..ab3a581 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
@@ -8,8 +8,10 @@
 import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -32,9 +34,16 @@
         if (data == null || StringUtils.isBlank(data.getJsonvalue())) {
             return result;
         }
-        result = JSONArray.parseArray(data.getJsonvalue(), Object[].class);
-        result.forEach(item -> {
-            item[0] = new Date(Long.parseLong(item[0].toString()));
+        List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class);
+        if (CollectionUtils.isEmpty(valueList)) {
+            return result;
+        }
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(predictTime);
+        valueList.forEach(value -> {
+            Object[] dv = { calendar.getTime(), value};
+            calendar.add(Calendar.MINUTE, 1);
+            result.add(dv);
         });
         return result;
     }
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 7bd1223..777b60c 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
@@ -75,7 +75,10 @@
             resultJson.setId(UUID.randomUUID().toString());
             resultJson.setOutputid(entry.getKey());
             resultJson.setPredicttime(predictTime);
-            resultJson.setJsonvalue(JSONArray.toJSONString(entry.getValue()));
+            List<Double> jsonValueList = entry.getValue().stream().map(valueVO -> {
+                return valueVO.getDataValue();
+            }).collect(Collectors.toList());
+            resultJson.setJsonvalue(JSONArray.toJSONString(jsonValueList));
             Map<String, Object> map4 = new HashMap(2);
             map4.put("TABLENAME", "T_MM_ITEM_RESULT_JSON");
             map4.put("entity", resultJson);
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelParamServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelParamServiceImpl.java
index 4c79982..023d4d6 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelParamServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelParamServiceImpl.java
@@ -2,8 +2,6 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.iailab.framework.common.service.impl.BaseServiceImpl;
-import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao;
 import com.iailab.module.model.mcs.pre.dao.MmModelParamDao;
 import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity;
 import com.iailab.module.model.mcs.pre.service.MmModelParamService;
@@ -11,9 +9,8 @@
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * @author PanZhibao
@@ -24,6 +21,8 @@
 
     @Autowired
     private MmModelParamDao mmModelParamDao;
+
+    private static Map<String, List<MmModelParamEntity>> modelInputParamMap = new ConcurrentHashMap<>();
     
     @Override
     public void saveList(List<MmModelParamEntity> list) {
@@ -34,9 +33,31 @@
             item.setId(UUID.randomUUID().toString());
             mmModelParamDao.insert(item);
         });
+
+        // 清空缓存
+        clearCache();
     }
 
     @Override
+    public void clearCache() {
+        modelInputParamMap.clear();
+    }
+
+    @Override
+    public List<MmModelParamEntity> getByModelidFromCatch(String modelId) {
+        if (!modelInputParamMap.containsKey(modelId)) {
+            List<MmModelParamEntity> list = getByModelid(modelId);
+            if (list != null) {
+                modelInputParamMap.put(modelId, list);
+            } else {
+                return null;
+            }
+        }
+        return modelInputParamMap.get(modelId);
+    }
+
+
+    @Override
     public List<MmModelParamEntity> getByModelid(String modelid) {
         QueryWrapper<MmModelParamEntity> queryWrapper = new QueryWrapper();
         queryWrapper.eq("modelid", modelid);
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
index f595abc..3a38f00 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -58,6 +58,8 @@
     @Autowired
     private MmPredictItemDao mmPredictItemDao;
 
+    private static HashMap<String, ItemVO> itemVOHashMap = new HashMap<>();
+
     @Override
     public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) {
         IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO);
@@ -127,6 +129,9 @@
             e.setItemid(predictItem.getId());
         });
         mmItemOutputService.saveMmItemOutput(mmItemOutput);
+
+        // 清空缓存
+        clearCatch();
     }
 
     @DSTransactional(rollbackFor = Exception.class)
@@ -166,6 +171,9 @@
             e.setItemid(predictItem.getId());
         });
         mmItemOutputService.saveMmItemOutput(mmItemOutput);
+
+        // 清空缓存
+        clearCatch();
     }
 
     @DSTransactional(rollbackFor = Exception.class)
@@ -175,6 +183,9 @@
         mmPredictMergeItemService.deleteBatch(itemIds);
         mmPredictModelService.deleteBatch(itemIds);
         mmItemOutputService.deleteBatch(itemIds);
+
+        // 清空缓存
+        clearCatch();
     }
 
     @Override
@@ -235,17 +246,25 @@
     }
 
     @Override
+    public void clearCatch() {
+        itemVOHashMap.clear();
+    }
+
+    @Override
     public ItemVO getItemById(String itemId) {
         if (StringUtils.isBlank(itemId)) {
             return null;
         }
-        Map<String, Object> params = new HashMap(1);
-        params.put("ITEMID", itemId);
-        List<ItemVO> list = mmPredictItemDao.getItem(params);
-        if (CollectionUtils.isEmpty(list)) {
-            return null;
+        if (!itemVOHashMap.containsKey(itemId)) {
+            Map<String, Object> params = new HashMap<>(1);
+            params.put("ITEMID", itemId);
+            List<ItemVO> list = mmPredictItemDao.getItem(params);
+            if (CollectionUtils.isEmpty(list)) {
+                return null;
+            }
+            itemVOHashMap.put(itemId, list.get(0));
         }
-        return list.get(0);
+        return itemVOHashMap.get(itemId);
     }
 
     @Override
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java
index 2922b37..892bae3 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java
@@ -12,9 +12,11 @@
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * @author PanZhibao
@@ -25,15 +27,36 @@
 
     @Autowired
     private MmPredictModelDao mmPredictModelDao;
+
+    private static Map<String, MmPredictModelEntity> modelEntityMap = new ConcurrentHashMap<>();
+
     @Override
     public void savePredictModel(MmPredictModelEntity predictModel) {
         predictModel.setId(UUID.randomUUID().toString());
         mmPredictModelDao.insert(predictModel);
+        clearCache();
     }
 
     @Override
     public void update(MmPredictModelEntity predictModel) {
         this.updateById(predictModel);
+        clearCache();
+    }
+
+    @Override
+    public MmPredictModelEntity getInfoFromCatch(String id) {
+        if (!modelEntityMap.containsKey(id)) {
+            MmPredictModelEntity modelEntity = getInfo(id);
+            if (modelEntity != null) {
+                modelEntityMap.put(id, modelEntity);
+            }
+        }
+        return modelEntityMap.get(id);
+    }
+
+    @Override
+    public void clearCache() {
+        modelEntityMap.clear();
     }
 
     @Override
@@ -57,6 +80,7 @@
         QueryWrapper<MmPredictModelEntity> queryWrapper = new QueryWrapper<>();
         queryWrapper.in("itemid", itemIds);
         mmPredictModelDao.delete(queryWrapper);
+        clearCache();
     }
 
     public MmPredictModelEntity getByItemid(String itemid) {
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ModelEntityFactory.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ModelEntityFactory.java
deleted file mode 100644
index bc663e3..0000000
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ModelEntityFactory.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package com.iailab.module.model.mdk.factory;
-
-import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity;
-import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity;
-import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity;
-import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService;
-import com.iailab.module.model.mcs.pre.service.MmModelParamService;
-import com.iailab.module.model.mcs.pre.service.MmPredictModelService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 创建和管理模型实体
- */
-@Slf4j
-@Component
-public class ModelEntityFactory {
-
-    private Map<String, Object> modelFileMap = new HashMap<>();
-    private Map<String, MmPredictModelEntity> modelEntityMap = new HashMap<>();
-    private Map<String, List<MmModelParamEntity>> modelInputParamMap = new HashMap<>();
-    private Map<String, List<MmModelArithSettingsEntity>> modelArithParamMap = new HashMap<>();
-    private Map<String, List<MmPredictModelEntity>> modelListMap = new HashMap<>();
-
-    @Autowired
-    private MmPredictModelService mmPredictModelService;
-
-    @Autowired
-    private MmModelParamService mmModelParamService;
-
-    @Autowired
-    private MmModelArithSettingsService mmModelArithSettingsService;
-
-    /**
-     * 2.根据模型ID,获取模型实体
-     *
-     * @param modelId
-     * @return
-     */
-    public MmPredictModelEntity getModelEntity(String modelId) {
-        MmPredictModelEntity modelEntity = mmPredictModelService.getInfo(modelId);
-        if (!modelEntityMap.containsKey(modelId)) {
-            if (modelEntity != null) {
-                modelEntityMap.put(modelId, modelEntity);
-            }
-        }
-        return modelEntity;
-    }
-
-    /**
-     * 3.根据模型ID,获取模型对应的输入参数
-     *
-     * @param modelId
-     * @return
-     */
-    public List<MmModelParamEntity> getModelInputParam(String modelId) {
-        if (!modelInputParamMap.containsKey(modelId)) {
-            List<MmModelParamEntity> modelInputParamEntities = mmModelParamService.getByModelid(modelId);
-            if (modelInputParamEntities != null) {
-                modelInputParamMap.put(modelId, modelInputParamEntities);
-            } else {
-                return null;
-            }
-        }
-        return mmModelParamService.getByModelid(modelId);
-    }
-
-    /**
-     * 4.根据模型ID,获取模型对应的输入参数的维数
-     *
-     * @param modelId
-     * @return
-     */
-    public Integer getModelInputCount(String modelId) {
-        if (!modelInputParamMap.containsKey(modelId)) {
-            List<MmModelParamEntity> modelInputParamEntityList = mmModelParamService.getByModelid(modelId);
-            if (modelInputParamEntityList != null) {
-                modelInputParamMap.put(modelId, modelInputParamEntityList);
-            } else {
-                return 0;
-            }
-        }
-        return modelInputParamMap.get(modelId).size();
-    }
-
-    /**
-     * 5.根据模型ID,获取模型对应的算法参数
-     *
-     * @param modelId
-     * @return
-     */
-    public List<MmModelArithSettingsEntity> getModelArithParam(String modelId) {
-        if (!modelArithParamMap.containsKey(modelId)) {
-            List<MmModelArithSettingsEntity> modelArithParamEntityList = mmModelArithSettingsService.getByModelId(modelId);
-            if (modelArithParamEntityList != null) {
-                modelArithParamMap.put(modelId, modelArithParamEntityList);
-            } else {
-                return null;
-            }
-        }
-        return modelArithParamMap.get(modelId);
-    }
-
-    /**
-     * 7.根据预测项itemID,获取status=1的模型列表
-     *
-     * @param itemId
-     * @return
-     */
-    public List<MmPredictModelEntity> getActiveModelByItemId(String itemId) {
-        if (!modelListMap.containsKey(itemId)) {
-            List<MmPredictModelEntity> modelEntityList = mmPredictModelService.getActiveModelByItemId(itemId);
-            if (modelEntityList != null) {
-                modelListMap.put(itemId, modelEntityList);
-            } else {
-                return null;
-            }
-        }
-        return modelListMap.get(itemId);
-    }
-
-    /**
-     * 8.根据模型ID,删除模型对应的输入参数
-     *
-     * @param modelId
-     * @return
-     */
-    public void removeModelInputParam(String modelId) {
-        if (modelInputParamMap.containsKey(modelId)) {
-            log.info("removeModelInputParam:modelId=" + modelId);
-            modelInputParamMap.remove(modelId);
-        }
-    }
-
-    /**
-     * 清除缓存
-     */
-    public void removeModelEntity() {
-        modelFileMap.clear();
-        modelEntityMap.clear();
-        modelInputParamMap.clear();
-        modelArithParamMap.clear();
-        modelListMap.clear();
-    }
-}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
index 8b45b26..88b2f9a 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
@@ -1,9 +1,9 @@
 package com.iailab.module.model.mdk.sample;
 
 import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity;
+import com.iailab.module.model.mcs.pre.service.MmModelParamService;
+import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
 import com.iailab.module.model.mcs.pre.service.MmPredictModelService;
-import com.iailab.module.model.mdk.factory.ItemEntityFactory;
-import com.iailab.module.model.mdk.factory.ModelEntityFactory;
 import com.iailab.module.model.mdk.sample.dto.ColumnItem;
 import com.iailab.module.model.mdk.sample.dto.ColumnItemPort;
 import com.iailab.module.model.mdk.sample.dto.SampleInfo;
@@ -27,10 +27,10 @@
     private MmPredictModelService mmPredictModelService;
 
     @Autowired
-    private ModelEntityFactory modelEntityFactory;
+    private MmModelParamService mmModelParamService;
 
     @Autowired
-    private ItemEntityFactory itemEntityFactory;
+    private MmPredictItemService mmPredictItemService;
 
     @Override
     public SampleInfo prepareSampleInfo(String modelId, Date predictTime) {
@@ -85,7 +85,7 @@
         List<ColumnItem> columnItemList = new ArrayList<>();
         ColumnItem columnInfo = new ColumnItem();
         ColumnItemPort curPort = new ColumnItemPort();  //当前端口
-        List<MmModelParamEntity> modelInputParamEntityList = modelEntityFactory.getModelInputParam(modelId);
+        List<MmModelParamEntity> modelInputParamEntityList = mmModelParamService.getByModelidFromCatch(modelId);
         if (CollectionUtils.isEmpty(modelInputParamEntityList)) {
             return null;
         }
@@ -135,7 +135,7 @@
      */
     @Override
     protected Integer getSampleCycle(String modelId) {
-        return itemEntityFactory.getItemById(modelEntityFactory.getModelEntity(modelId).getItemid()).getGranularity();
+        return mmPredictItemService.getItemById(mmPredictModelService.getInfoFromCatch(modelId).getItemid()).getGranularity();
     }
 
 
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
index f32b9be..cd5f3f0 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
@@ -1,13 +1,16 @@
 package com.iailab.module.model.mdk.sample;
 
+import com.iailab.module.data.api.ind.IndItemApi;
+import com.iailab.module.data.api.ind.dto.ApiIndItemDTO;
 import com.iailab.module.data.api.plan.PlanItemApi;
 import com.iailab.module.data.api.plan.dto.ApiPlanItemDTO;
 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.data.enums.TimeGranularityEnum;
+import com.iailab.module.data.enums.TimeGranularitySecEnum;
+import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
 import com.iailab.module.model.mdk.common.enums.ModelParamType;
-import com.iailab.module.model.mdk.factory.ItemEntityFactory;
 import com.iailab.module.model.mdk.sample.dto.ColumnItem;
 import com.iailab.module.model.mdk.sample.dto.ColumnItemPort;
 import com.iailab.module.model.mdk.sample.dto.SampleInfo;
@@ -28,10 +31,13 @@
     private DataPointApi dataPointApi;
 
     @Autowired
-    private ItemEntityFactory itemEntityFactory;
+    private PlanItemApi planItemApi;
 
     @Autowired
-    private PlanItemApi planItemApi;
+    private IndItemApi indItemApi;
+
+    @Autowired
+    private MmPredictItemService mmPredictItemService;
 
     /**
      * prepareSampleInfo
@@ -142,20 +148,23 @@
      * @throws Exception
      */
     protected Integer getGranularity(ColumnItem columnItem) {
+        // 默认60s
         Integer granularity = 60;
-        switch (columnItem.getParamType()) {
-            case "DATAPOINT":
+        switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
+            case DATAPOINT:
                 ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId());
                 granularity = DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue();
                 break;
-            case "PREDICTITEM":
-                granularity = itemEntityFactory.getItemById(columnItem.getParamId()).getGranularity();
+            case PREDICTITEM:
+                granularity = mmPredictItemService.getItemById(columnItem.getParamId()).getGranularity();
                 break;
-            case "IND-HIS":
-                granularity = 60;
+            case IND:
+                ApiIndItemDTO indItemDTO = indItemApi.getInfoById(columnItem.getParamId());
+                granularity = TimeGranularitySecEnum.getEumByCode(indItemDTO.getTimeGranularity()).getValue();;
                 break;
-            case "IND-PLAN":
-                granularity = 60;
+            case PLAN:
+                ApiPlanItemDTO apiPlanItemDTO = planItemApi.getInfoById(columnItem.getParamId());
+                granularity = TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue();
                 break;
             default:
                 break;
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/dto/ColumnItem.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/dto/ColumnItem.java
index 561f4bc..c61beb3 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/dto/ColumnItem.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/dto/ColumnItem.java
@@ -55,7 +55,7 @@
     public Date endTime;
 
     /**
-     * 采样粒度,s
+     * 采样粒度
      */
-    public int granularity;
+    public Integer granularity;
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java
index 0fbbad9..9f503d7 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java
@@ -26,4 +26,6 @@
     ChartParamEntity get(String id);
 
     void delete(String id);
+
+    Map<String, String> getByChartId(String chartId);
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java
index 8b6af57..f52bcb9 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java
@@ -22,4 +22,6 @@
     ChartEntity get(String id);
 
     void delete(String id);
+
+    Map<String, String> getByChartCode(String chartCode);
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java
index 95fef7c..782bbea 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java
@@ -13,10 +13,9 @@
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import java.util.Date;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * @description:
@@ -56,6 +55,21 @@
     }
 
     @Override
+    public Map<String, String> getByChartId(String chartId) {
+        Map<String, String> result = new HashMap<>();
+        Map<String, Object> params = new HashMap<String, Object>(1);
+        params.put("chartId", chartId);
+        List<ChartParamEntity> list = baseDao.selectList(getWrapper(params));
+        if (CollectionUtils.isEmpty(list)) {
+            return result;
+        }
+        list.forEach(item -> {
+            result.put(item.getParamCode(), item.getParamValue());
+        });
+        return result;
+    }
+
+    @Override
     public void delete(String id) {
         baseDao.deleteById(id);
     }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java
index 4c68120..fe8b633 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java
@@ -5,20 +5,18 @@
 import com.iailab.framework.common.page.PageData;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
 import com.iailab.module.model.mpk.dao.ChartDao;
-import com.iailab.module.model.mpk.dao.ChartParamDao;
 import com.iailab.module.model.mpk.dto.ChartDTO;
-import com.iailab.module.model.mpk.dto.ChartParamDTO;
 import com.iailab.module.model.mpk.entity.ChartEntity;
 import com.iailab.module.model.mpk.entity.ChartParamEntity;
 import com.iailab.module.model.mpk.service.ChartParamService;
 import com.iailab.module.model.mpk.service.ChartService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import java.util.Date;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * @description:
@@ -28,6 +26,9 @@
 @Slf4j
 @Service
 public class ChartServiceImpl extends BaseServiceImpl<ChartDao, ChartEntity> implements ChartService {
+
+    @Autowired
+    private ChartParamService chartParamService;
 
     @Override
     public PageData<ChartDTO> page(Map<String, Object> params) {
@@ -71,4 +72,16 @@
                 .like(StringUtils.isNotBlank(chartCode), "chart_code", chartCode);
         return wrapper;
     }
+
+    @Override
+    public Map<String, String> getByChartCode(String chartCode) {
+        Map<String, String> result = new HashMap<>();
+        QueryWrapper<ChartEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq("chart_code", chartCode);
+        ChartEntity entity = baseDao.selectOne(wrapper);
+        if (entity != null) {
+            return result;
+        }
+        return chartParamService.getByChartId(entity.getId());
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3