From af7bd200a95b9fc6b8b3f3fc603d612221e21fc7 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期三, 08 一月 2025 08:23:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/impl/InfluxDBServiceImpl.java             |   83 +++++++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java |   34 +-
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultPOJO.java                   |   25 ++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/enums/DataMeasurement.java                 |   16 +
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dto/MmPredictItemDTO.java                          |    2 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java      |    5 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultLastSimPOJO.java            |   18 +
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java                             |    2 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java               |    2 
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/vo/InfluxModelResultVO.java                       |   24 ++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/utils/MeasurementUtils.java                |   26 ++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/InfluxDBService.java                      |   17 +
 /dev/null                                                                                                                                    |   40 ---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java          |  133 +++++-------
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java          |    5 
 iailab-module-model/iailab-module-model-biz/db/mysql.sql                                                                                     |   24 --
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/config/InfluxDBInstance.java               |   71 ++++++
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultSimPOJO.java                |   18 +
 iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java                                                       |   67 ++++++
 iailab-module-model/iailab-module-model-biz/pom.xml                                                                                          |    7 
 iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml                                                               |    2 
 iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml                                                          |    7 
 22 files changed, 460 insertions(+), 168 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/db/mysql.sql b/iailab-module-model/iailab-module-model-biz/db/mysql.sql
index 832e4f4..8781409 100644
--- a/iailab-module-model/iailab-module-model-biz/db/mysql.sql
+++ b/iailab-module-model/iailab-module-model-biz/db/mysql.sql
@@ -40,18 +40,6 @@
     INDEX         idx_itemid (itemid)
 ) engine = innodb default character set utf8mb4 COMMENT = '预测项输出表';
 
-create table t_mm_item_result
-(
-    id        varchar(36) not null,
-    outputid  varchar(36),
-    datatime  datetime,
-    datavalue decimal(19, 3),
-    primary key (id),
-    UNIQUE KEY `unique_outputid_datatime` (`outputid`,`datatime`),
-    KEY `idx_outputid_datatime` (`outputid`,`datatime`) USING BTREE
-) engine = innodb
-  default character set utf8mb4 COMMENT = '预测结果表';
-
 create table t_mm_item_type
 (
     id            varchar(36) not null,
@@ -164,18 +152,6 @@
     INDEX       idx_outputid (outputid),
     INDEX       idx_predicttime (predicttime)
 ) engine = innodb default character set utf8mb4 COMMENT = '预测JSON数据表';
-
-create table
-    t_mm_item_result_last_point
-(
-    id        varchar(36) not null,
-    outputid  varchar(36),
-    datatime  datetime,
-    datavalue decimal(19, 3),
-    primary key (id),
-    INDEX     idx_outputid (outputid),
-    INDEX     idx_datatime (datatime)
-) engine = innodb default character set utf8mb4 COMMENT = '预测T+L数据表';
 
 create table t_mm_item_accuracy_rate
 (
diff --git a/iailab-module-model/iailab-module-model-biz/pom.xml b/iailab-module-model/iailab-module-model-biz/pom.xml
index 0d9bf13..5f11ebd 100644
--- a/iailab-module-model/iailab-module-model-biz/pom.xml
+++ b/iailab-module-model/iailab-module-model-biz/pom.xml
@@ -151,6 +151,13 @@
             <version>${velocity.version}</version>
         </dependency>
 
+        <!-- influxdb -->
+        <dependency>
+            <groupId>com.influxdb</groupId>
+            <artifactId>influxdb-client-java</artifactId>
+            <version>6.8.0</version>
+        </dependency>
+
 
     </dependencies>
 
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java
index adc3f8e..2d6deb1 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java
@@ -16,6 +16,8 @@
 
     FLOAT("float"),
 
+    FLOAT_LAST("float_last"),
+
     BOOLEAN("boolean");
 
     private String code;
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/config/InfluxDBInstance.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/config/InfluxDBInstance.java
new file mode 100644
index 0000000..f2d2075
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/config/InfluxDBInstance.java
@@ -0,0 +1,71 @@
+package com.iailab.module.model.influxdb.common.config;
+
+import com.iailab.framework.tenant.core.context.TenantContextHolder;
+import com.influxdb.client.InfluxDBClient;
+import com.influxdb.client.InfluxDBClientFactory;
+import com.influxdb.client.domain.Bucket;
+import com.influxdb.client.domain.Organization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2023年04月25日 17:13:00
+ */
+@Component
+public class InfluxDBInstance {
+
+    @Value("${influx-db.org}")
+    public String org;
+
+    /*@Value("${influx-db.bucket}")
+    public String bucket;*/
+
+    @Value("${influx-db.token}")
+    public String token;
+
+    @Value("${influx-db.url}")
+    public String url;
+
+    private Set<String> isExistBucket = new HashSet<>();
+
+    private final static String BUCKET_NAME = "bucket_model_";
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    private InfluxDBClient client;
+
+    public InfluxDBClient getClient() {
+        try {
+            if (client == null) {
+                client = InfluxDBClientFactory.create(url, token.toCharArray());
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            logger.error("创建InfluxDBClient失败!");
+        }
+        return client;
+    }
+
+    public String getBucket() {
+        String bucketName = BUCKET_NAME + TenantContextHolder.getRequiredTenantId();
+        // 判断Bucket是否存在,不存在则创建
+        if (!isExistBucket.contains(bucketName)) {
+            Bucket bucketByName = client.getBucketsApi().findBucketByName(bucketName);
+            if (null == bucketByName) {
+                Organization organization = client.getOrganizationsApi().findOrganizations().stream().filter(e -> e.getName().equals(org)).findFirst().orElseThrow(() -> new RuntimeException("influxdb:org不存在,org:" + org));
+                client.getBucketsApi().createBucket(bucketName,organization);
+            }else {
+                isExistBucket.add(bucketName);
+            }
+        }
+        return bucketName;
+    }
+
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/enums/DataMeasurement.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/enums/DataMeasurement.java
new file mode 100644
index 0000000..7e2fb65
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/enums/DataMeasurement.java
@@ -0,0 +1,16 @@
+package com.iailab.module.model.influxdb.common.enums;
+
+/**
+ * 数据表
+ *
+ * @author PanZhibao
+ * @Description
+ * @createTime 2023年04月24日 15:13:00
+ */
+public enum DataMeasurement {
+    t_md_sim_value,
+    t_md_last_sim_value,
+    t_md_dig_value,
+    t_md_bool_value,
+    t_md_str_value,
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/utils/MeasurementUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/utils/MeasurementUtils.java
new file mode 100644
index 0000000..6e54db1
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/common/utils/MeasurementUtils.java
@@ -0,0 +1,26 @@
+package com.iailab.module.model.influxdb.common.utils;
+
+import com.iailab.module.model.common.enums.DataTypeEnum;
+import com.iailab.module.model.influxdb.common.enums.DataMeasurement;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2023年05月08日 10:25:00
+ */
+public class MeasurementUtils {
+
+    public static String getMeasurement(String type) {
+        if (DataTypeEnum.FLOAT.getCode().equals(type)) {
+            return DataMeasurement.t_md_sim_value.name();
+        } else if (DataTypeEnum.INT.getCode().equals(type)) {
+            return DataMeasurement.t_md_dig_value.name();
+        } else if (DataTypeEnum.BOOLEAN.getCode().equals(type)) {
+            return DataMeasurement.t_md_bool_value.name();
+        } else if (DataTypeEnum.FLOAT_LAST.getCode().equals(type)) {
+            return DataMeasurement.t_md_last_sim_value.name();
+        } else {
+            return DataMeasurement.t_md_str_value.name();
+        }
+    }
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultLastSimPOJO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultLastSimPOJO.java
new file mode 100644
index 0000000..af80e69
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultLastSimPOJO.java
@@ -0,0 +1,18 @@
+package com.iailab.module.model.influxdb.pojo;
+
+import com.influxdb.annotations.Column;
+import com.influxdb.annotations.Measurement;
+import lombok.Data;
+
+/**
+ * @description:
+ * @author: dzd
+ * @date: 2025/1/7 13:43
+ **/
+@Data
+@Measurement(name = "t_md_last_sim_value")
+public class InfluxModelResultLastSimPOJO extends InfluxModelResultPOJO {
+
+    @Column
+    private Double value;
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultPOJO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultPOJO.java
new file mode 100644
index 0000000..37cb775
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultPOJO.java
@@ -0,0 +1,25 @@
+package com.iailab.module.model.influxdb.pojo;
+
+import com.influxdb.annotations.Column;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+/**
+ * @description:
+ * @author: dzd
+ * @date: 2025/1/7 13:43
+ **/
+@Data
+public class InfluxModelResultPOJO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Column(tag = true)
+    private String outPutId;
+
+    @Column(timestamp = true)
+    private Instant timestamp;
+
+    private String type;
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultSimPOJO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultSimPOJO.java
new file mode 100644
index 0000000..47b6825
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/pojo/InfluxModelResultSimPOJO.java
@@ -0,0 +1,18 @@
+package com.iailab.module.model.influxdb.pojo;
+
+import com.influxdb.annotations.Column;
+import com.influxdb.annotations.Measurement;
+import lombok.Data;
+
+/**
+ * @description:
+ * @author: dzd
+ * @date: 2025/1/7 13:43
+ **/
+@Data
+@Measurement(name = "t_md_sim_value")
+public class InfluxModelResultSimPOJO extends InfluxModelResultPOJO {
+
+    @Column
+    private Double value;
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/InfluxDBService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/InfluxDBService.java
new file mode 100644
index 0000000..45667bd
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/InfluxDBService.java
@@ -0,0 +1,17 @@
+package com.iailab.module.model.influxdb.service;
+
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO;
+import com.iailab.module.model.influxdb.vo.InfluxModelResultVO;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * InfluxDB操作类
+ */
+public interface InfluxDBService {
+
+    void asyncWriteModelResults(List<InfluxModelResultPOJO> pointValues);
+
+    List<InfluxModelResultVO> queryModelResults(InfluxModelResultPOJO pojo, Date startTime, Date endTime);
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/impl/InfluxDBServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/impl/InfluxDBServiceImpl.java
new file mode 100644
index 0000000..431a988
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/service/impl/InfluxDBServiceImpl.java
@@ -0,0 +1,83 @@
+package com.iailab.module.model.influxdb.service.impl;
+
+import com.iailab.module.model.influxdb.common.config.InfluxDBInstance;
+import com.iailab.module.model.influxdb.common.utils.MeasurementUtils;
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO;
+import com.iailab.module.model.influxdb.service.InfluxDBService;
+import com.iailab.module.model.influxdb.vo.InfluxModelResultVO;
+import com.influxdb.client.QueryApi;
+import com.influxdb.client.WriteApi;
+import com.influxdb.client.domain.WritePrecision;
+import com.influxdb.query.FluxRecord;
+import com.influxdb.query.FluxTable;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import java.util.*;
+
+/**
+ * InfluxDB操作类
+ */
+@Slf4j
+@Service
+public class InfluxDBServiceImpl implements InfluxDBService {
+    @Resource
+    private InfluxDBInstance influxDBInstance;
+    private WriteApi writeApi;
+    private QueryApi queryApi;
+
+    @PostConstruct
+    private void init() {
+        writeApi = influxDBInstance.getClient().makeWriteApi();
+        queryApi = influxDBInstance.getClient().getQueryApi();
+    }
+
+    @Override
+    public void asyncWriteModelResults(List<InfluxModelResultPOJO> pointValues) {
+        if (!CollectionUtils.isEmpty(pointValues)) {
+            pointValues.forEach(item -> {
+                String bucket = influxDBInstance.getBucket();
+                writeApi.writeMeasurement(bucket, influxDBInstance.org, WritePrecision.MS, item);
+            });
+        }
+        writeApi.flush();
+    }
+
+    @Override
+    public List<InfluxModelResultVO> queryModelResults(InfluxModelResultPOJO pojo, Date startTime, Date endTime) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MILLISECOND, 0);
+        String start = startTime.toInstant().toString();
+
+        if (startTime.getTime() == endTime.getTime()) {
+            // 如果相等,则engTime加1毫秒,负责influxdb报错(因为influxdb的range函数是左闭右开区间,所以将engTime加一毫秒,才可以查到startTime时间点的数据)
+            endTime.setTime(endTime.getTime() + 1);
+        }
+        String stop = endTime.toInstant().toString();
+
+        List<InfluxModelResultVO> dataList = new ArrayList<>();
+        String measurement = MeasurementUtils.getMeasurement(pojo.getType());
+        StringBuilder sb = new StringBuilder();
+        sb.append("from(bucket:\"" + influxDBInstance.getBucket() + "\") ");
+        sb.append("|> range(start: ").append(start).append(", stop: ").append(stop).append(") ");
+        sb.append("|> filter(fn: (r) => r[\"_measurement\"] == \"" + measurement + "\")");
+        sb.append("|> filter(fn: (r) => r[\"_field\"] == \"value\")");
+        sb.append("|> filter(fn: (r) => r[\"outPutId\"] == \"" + pojo.getOutPutId() + "\")");
+        sb.append("|> sort(columns: [\"_time\"]) ");
+        sb.append("|> yield(name: \"mean\")");
+        log.info("influxdbSql===============" + sb);
+        List<FluxTable> tables = queryApi.query(sb.toString(), influxDBInstance.org);
+
+        for (FluxTable table : tables) {
+            List<FluxRecord> records = table.getRecords();
+            for (FluxRecord record : records) {
+                InfluxModelResultVO vo = new InfluxModelResultVO(record.getValueByKey("_value"),record.getTime());
+                dataList.add(vo);
+            }
+        }
+        return dataList;
+    }
+}
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/vo/InfluxModelResultVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/vo/InfluxModelResultVO.java
new file mode 100644
index 0000000..cdaf543
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/influxdb/vo/InfluxModelResultVO.java
@@ -0,0 +1,24 @@
+package com.iailab.module.model.influxdb.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+/**
+ * @description:
+ * @author: dzd
+ * @date: 2025/1/7 9:41
+ **/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class InfluxModelResultVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Object value;
+
+    private Instant timestamp;
+}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultDao.java
deleted file mode 100644
index 264c9f9..0000000
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultDao.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.iailab.module.model.mcs.pre.dao;
-
-import com.iailab.framework.mybatis.core.mapper.BaseMapperX;
-import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
-import com.iailab.module.model.mcs.pre.entity.MmItemResultEntity;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author PanZhibao
- * @date 2021年05月28日 10:27
- */
-@TenantDS
-@Mapper
-public interface MmItemResultDao extends BaseMapperX<MmItemResultEntity> {
-
-    void deletePredictValue(Map<String, Object> params);
-
-    void savePredictValue(Map<String, Object> params);
-
-    void saveOrUpdateItemResult(@Param("list") List<MmItemResultEntity> list);
-
-    void savePredictJsonValue(Map<String, Object> params);
-}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultLastPointDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultLastPointDao.java
deleted file mode 100644
index 181ad0c..0000000
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultLastPointDao.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.iailab.module.model.mcs.pre.dao;
-
-import com.iailab.framework.mybatis.core.mapper.BaseMapperX;
-import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
-import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * @author PanZhibao
- * @Description
- * @createTime 2024年11月14日
- */
-@TenantDS
-@Mapper
-public interface MmItemResultLastPointDao extends BaseMapperX<MmItemResultLastPointEntity> {
-}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dto/MmPredictItemDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dto/MmPredictItemDTO.java
index 0fb5c26..6c5a6d0 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dto/MmPredictItemDTO.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dto/MmPredictItemDTO.java
@@ -31,8 +31,6 @@
 
     private List<MmModelParamEntity> mmModelParamList;
 
-    private List<MmItemResultEntity> mmItemResultList;
-
     /**
      * 计算预测项真实数据点
      */
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultEntity.java
deleted file mode 100644
index c5153d4..0000000
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultEntity.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.iailab.module.model.mcs.pre.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author PanZhibao
- * @date 2021年05月28日 10:18
- */
-@Data
-@TableName("T_MM_ITEM_RESULT")
-public class MmItemResultEntity implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 主键
-     */
-    @TableId(value = "id",type = IdType.INPUT)
-    private String id;
-
-    /**
-     * 输出ID
-     */
-    private String outputid;
-
-    /**
-     * 预测时间
-     */
-    private Date datatime;
-
-    /**
-     * 预测值
-     */
-    private BigDecimal datavalue;
-}
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultLastPointEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultLastPointEntity.java
deleted file mode 100644
index 022d6da..0000000
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultLastPointEntity.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.iailab.module.model.mcs.pre.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author PanZhibao
- * @Description
- * @createTime 2024年11月14日
- */
-@Data
-@TableName("t_mm_item_result_last_point")
-public class MmItemResultLastPointEntity implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 主键
-     */
-    @TableId(value = "id",type = IdType.INPUT)
-    private String id;
-
-    /**
-     * 输出ID
-     */
-    private String outputid;
-
-    /**
-     * 预测时间
-     */
-    private Date datatime;
-
-    /**
-     * 预测值
-     */
-    private BigDecimal datavalue;
-}
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java
index ef59ced..0709d14 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java
@@ -16,4 +16,6 @@
     List<Object[]> getData(String outputId, Date predictTime, String timeFormat);
 
     String getDoubleData(String outputId, Date predictTime);
+
+    void insert(List<MmItemResultJsonEntity> resultJsonList);
 }
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java
index abf5d1b..89b1d62 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java
@@ -1,8 +1,5 @@
 package com.iailab.module.model.mcs.pre.service;
 
-import com.iailab.framework.common.service.BaseService;
-import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity;
-
 import java.util.Date;
 import java.util.List;
 
@@ -11,7 +8,7 @@
  * @Description
  * @createTime 2024年11月14日
  */
-public interface MmItemResultLastPointService extends BaseService<MmItemResultLastPointEntity> {
+public interface MmItemResultLastPointService {
 
     List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat);
 }
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 8520d31..4f7c1fa 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
@@ -57,4 +57,9 @@
         MmItemResultJsonEntity mmItemResultJsonEntity = baseDao.selectOne(wrapper);
         return null == mmItemResultJsonEntity ? null : mmItemResultJsonEntity.getCumulant();
     }
+
+    @Override
+    public void insert(List<MmItemResultJsonEntity> resultJsonList) {
+        baseDao.insertBatch(resultJsonList);
+    }
 }
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java
index 7c5f775..25ee7b9 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java
@@ -1,14 +1,15 @@
 package com.iailab.module.model.mcs.pre.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.iailab.framework.common.service.impl.BaseServiceImpl;
 import com.iailab.framework.common.util.date.DateUtils;
-import com.iailab.module.model.mcs.pre.dao.MmItemResultLastPointDao;
-import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity;
+import com.iailab.module.model.common.enums.DataTypeEnum;
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO;
+import com.iailab.module.model.influxdb.service.InfluxDBService;
+import com.iailab.module.model.influxdb.vo.InfluxModelResultVO;
 import com.iailab.module.model.mcs.pre.service.MmItemResultLastPointService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -19,24 +20,21 @@
  * @createTime 2024年11月14日
  */
 @Service
-public class MmItemResultLastPointServiceImpl extends BaseServiceImpl<MmItemResultLastPointDao, MmItemResultLastPointEntity>
-        implements MmItemResultLastPointService {
+public class MmItemResultLastPointServiceImpl implements MmItemResultLastPointService {
+    @Autowired
+    private InfluxDBService influxDBService;
 
     @Override
     public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat) {
         List<Object[]> result = new ArrayList<>();
-        QueryWrapper<MmItemResultLastPointEntity> queryWrapper = new QueryWrapper<MmItemResultLastPointEntity>()
-                .eq("outputid", outputid)
-                .between("datatime", startTime, endTime)
-                .orderByAsc("datatime");
-        List<MmItemResultLastPointEntity> list = baseDao.selectList(queryWrapper);
-        if (CollectionUtils.isEmpty(list)) {
-            return result;
-        }
-        list.forEach(item -> {
+        InfluxModelResultPOJO pojo = new InfluxModelResultPOJO();
+        pojo.setType(DataTypeEnum.FLOAT_LAST.getCode());
+        pojo.setOutPutId(outputid);
+        List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, startTime, endTime);
+        influxModelResultVOS.forEach(item -> {
             Object[] dataItem = new Object[2];
-            dataItem[0] = DateUtils.format(item.getDatatime(), timeFormat);
-            dataItem[1] = item.getDatavalue();
+            dataItem[0] = DateUtils.format(Date.from(item.getTimestamp()), timeFormat);
+            dataItem[1] = BigDecimal.valueOf(Double.valueOf(item.getValue().toString())).setScale(2, BigDecimal.ROUND_HALF_UP);
             result.add(dataItem);
         });
         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 26f58e5..2eb99cf 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
@@ -1,18 +1,20 @@
 package com.iailab.module.model.mcs.pre.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-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.common.enums.DataTypeEnum;
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultLastSimPOJO;
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO;
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultSimPOJO;
+import com.iailab.module.model.influxdb.service.InfluxDBService;
+import com.iailab.module.model.influxdb.vo.InfluxModelResultVO;
 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.MmItemResultJsonService;
 import com.iailab.module.model.mcs.pre.service.MmItemResultService;
 import com.iailab.module.model.mdk.vo.DataValueVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -23,28 +25,27 @@
  * @date 2021年05月28日 10:34
  */
 @Service
-public class MmItemResultServiceImpl extends ServiceImpl<MmItemResultDao, MmItemResultEntity> implements MmItemResultService {
-
-    private final int max_group_count = 100;
-
-    private final String T_MM_ITEM_RESULT = "T_MM_ITEM_RESULT";
+public class MmItemResultServiceImpl implements MmItemResultService {
 
     @Autowired
-    private MmItemResultDao mmItemResultDao;
+    private MmItemResultJsonService mmItemResultJsonService;
+    @Autowired
+    private InfluxDBService influxDBService;
 
     @Override
     public void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime) {
-        List<MmItemResultEntity> importList = new ArrayList<>();
-        List<MmItemResultEntity> lastList = new ArrayList<>();
+        List<InfluxModelResultPOJO> importList = new ArrayList<>();
+        List<InfluxModelResultPOJO> lastList = new ArrayList<>();
+        List<MmItemResultJsonEntity> resultJsonList = new ArrayList<>();
 
         for (Map.Entry<String, List<DataValueVO>> entry : predictValueMap.entrySet()) {
             for (DataValueVO dataVo : entry.getValue()) {
-                MmItemResultEntity importData = new MmItemResultEntity();
-                importData.setId(String.valueOf(UUID.randomUUID()));
-                importData.setOutputid(entry.getKey());
-                importData.setDatatime(dataVo.getDataTime());
-                importData.setDatavalue(new BigDecimal(dataVo.getDataValue()));
-                importList.add(importData);
+                InfluxModelResultSimPOJO pojo = new InfluxModelResultSimPOJO();
+                pojo.setValue(dataVo.getDataValue());
+                pojo.setTimestamp(dataVo.getDataTime().toInstant());
+                pojo.setOutPutId(entry.getKey());
+                pojo.setType(DataTypeEnum.FLOAT.getCode());
+                importList.add(pojo);
             }
 
             List<DataValueVO> lastVoList = new ArrayList<>();
@@ -62,58 +63,39 @@
             }
 
             for (DataValueVO dataVo : lastVoList) {
-                MmItemResultEntity importData = new MmItemResultEntity();
-                importData.setId(String.valueOf(UUID.randomUUID()));
-                importData.setOutputid(entry.getKey());
-                importData.setDatatime(dataVo.getDataTime());
-                importData.setDatavalue(new BigDecimal(dataVo.getDataValue()));
-                lastList.add(importData);
+                InfluxModelResultLastSimPOJO pojo = new InfluxModelResultLastSimPOJO();
+                pojo.setValue(dataVo.getDataValue());
+                pojo.setTimestamp(dataVo.getDataTime().toInstant());
+                pojo.setOutPutId(entry.getKey());
+                pojo.setType(DataTypeEnum.FLOAT.getCode());
+                lastList.add(pojo);
             }
 
             MmItemResultJsonEntity resultJson = new MmItemResultJsonEntity();
             resultJson.setId(UUID.randomUUID().toString());
             resultJson.setOutputid(entry.getKey());
             resultJson.setPredicttime(predictTime);
-            List<Double> jsonValueList = entry.getValue().stream().map(valueVO -> {
-                return valueVO.getDataValue();
-            }).collect(Collectors.toList());
+            List<Double> jsonValueList = entry.getValue().stream().map(valueVO -> 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);
-            mmItemResultDao.savePredictJsonValue(map4);
-
-//            Map<String, Object> params = new HashMap(4);
-//            params.put("TABLENAME", T_MM_ITEM_RESULT);
-//            params.put("OUTPUTID", entry.getKey());
-//            params.put("STARTTIME", importList.get(0).getDatatime());
-//            params.put("ENDTIME", importList.get(importList.size() - 1).getDatatime());
-//            mmItemResultDao.deletePredictValue(params);
+            resultJsonList.add(resultJson);
         }
-        // 存在则修改,不存在插入
-        mmItemResultDao.saveOrUpdateItemResult(importList);
-
-        Map<String, Object> map3 = new HashMap<>(2);
-        map3.put("TABLENAME", "T_MM_ITEM_RESULT_LAST_POINT");
-        map3.put("list", lastList);
-        mmItemResultDao.savePredictValue(map3);
+        // json结果存入mysql
+        mmItemResultJsonService.insert(resultJsonList);
+        // double结果存入influxdb
+        influxDBService.asyncWriteModelResults(importList);
+        influxDBService.asyncWriteModelResults(lastList);
     }
 
     @Override
     public List<DataValueVO> getPredictValue(String outputid, Date startTime, Date endTime) {
-        List<DataValueVO> result = new ArrayList<>();
-        QueryWrapper<MmItemResultEntity> queryWrapper = new QueryWrapper<MmItemResultEntity>()
-                .eq("outputid", outputid)
-                .between("datatime", startTime, endTime)
-                .orderByAsc("datatime");
-        List<MmItemResultEntity> list = mmItemResultDao.selectList(queryWrapper);
-        if (CollectionUtils.isEmpty(list)) {
-            return result;
-        }
-        result = list.stream().map(t -> {
+        InfluxModelResultPOJO pojo = new InfluxModelResultPOJO();
+        pojo.setType(DataTypeEnum.FLOAT.getCode());
+        pojo.setOutPutId(outputid);
+        List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, startTime, endTime);
+        List<DataValueVO> result = influxModelResultVOS.stream().map(t -> {
             DataValueVO dv = new DataValueVO();
-            dv.setDataTime(t.getDatatime());
-            dv.setDataValue(t.getDatavalue().doubleValue());
+            dv.setDataTime(Date.from(t.getTimestamp()));
+            dv.setDataValue(Double.valueOf(t.getValue().toString()));
             return dv;
         }).collect(Collectors.toList());
         return result;
@@ -122,18 +104,14 @@
     @Override
     public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat) {
         List<Object[]> result = new ArrayList<>();
-        QueryWrapper<MmItemResultEntity> queryWrapper = new QueryWrapper<MmItemResultEntity>()
-                .eq("outputid", outputid)
-                .between("datatime", startTime, endTime)
-                .orderByAsc("datatime");
-        List<MmItemResultEntity> list = mmItemResultDao.selectList(queryWrapper);
-        if (CollectionUtils.isEmpty(list)) {
-            return result;
-        }
-        list.forEach(item -> {
+        InfluxModelResultPOJO pojo = new InfluxModelResultPOJO();
+        pojo.setType(DataTypeEnum.FLOAT.getCode());
+        pojo.setOutPutId(outputid);
+        List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, startTime, endTime);
+        influxModelResultVOS.forEach(item -> {
             Object[] dataItem = new Object[2];
-            dataItem[0] = DateUtils.format(item.getDatatime(), timeFormat);
-            dataItem[1] = item.getDatavalue().setScale(2, BigDecimal.ROUND_HALF_UP);
+            dataItem[0] = DateUtils.format(Date.from(item.getTimestamp()), timeFormat);
+            dataItem[1] = BigDecimal.valueOf(Double.valueOf(item.getValue().toString())).setScale(2, BigDecimal.ROUND_HALF_UP);
             result.add(dataItem);
         });
         return result;
@@ -141,16 +119,15 @@
 
     @Override
     public void savePredictValue(Map<MmItemOutputEntity, Double> predictDoubleValues, Date predictTime) {
+        List<InfluxModelResultPOJO> list = new ArrayList<>();
         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);
+            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);
     }
 }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml
index d86856e..be3bb55 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml
+++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml
@@ -52,3 +52,10 @@
   bak-file-path: D:\DLUT\mpkBakFile
   bak-resources: D:\DLUT\mpkResources
   model-file-path: D:\DLUT\MDK\Model\miail\
+
+influx-db:
+  org: iailab
+  token: NloIinwybvMwKlJ8SGOAqboXH72EhdQEsnnV7kwtstVu6sbt24LNJ0bVICepeAtl2pxpd1Hj8gDLj9m4hnB7Fw==
+  url: http://127.0.0.1:8086
+  username: dzd
+  password: qwer1234
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml
index 076632c..112a71e 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml
+++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml
@@ -181,7 +181,6 @@
       - t_dm_module
       - t_dm_module_item
       - t_mm_item_output
-      - t_mm_item_result
       - t_mm_item_type
       - t_mm_model_arith_settings
       - t_mm_model_param
@@ -191,7 +190,6 @@
       - t_mm_predict_model
       - t_mm_result_table
       - t_mm_item_result_json
-      - t_mm_item_result_last_point
       - t_mm_item_accuracy_rate
       - t_mm_item_accuracy_his
       - t_mm_predict_alarm_config
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmItemResultDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmItemResultDao.xml
deleted file mode 100644
index a0a6838..0000000
--- a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmItemResultDao.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-
-<mapper namespace="com.iailab.module.model.mcs.pre.dao.MmItemResultDao">
-
-    <delete id="deletePredictValue" parameterType="map">
-        DELETE
-        FROM ${TABLENAME}
-        WHERE outputid = #{OUTPUTID}
-          AND datatime
-            BETWEEN #{STARTTIME}
-            AND #{ENDTIME}
-    </delete>
-
-    <insert id="savePredictValue" parameterType="map">
-        INSERT INTO ${TABLENAME}
-        (id,outputid,datatime,datavalue)
-        VALUES
-        <foreach item="item" collection="list" separator=",">
-            (#{item.id},#{item.outputid},#{item.datatime},#{item.datavalue})
-        </foreach>
-    </insert>
-
-    <insert id="savePredictJsonValue" parameterType="map">
-        INSERT INTO ${TABLENAME}
-            (id,outputid,predicttime,jsonvalue,cumulant)
-        VALUES (#{entity.id},#{entity.outputid},#{entity.predicttime},#{entity.jsonvalue},#{entity.cumulant})
-    </insert>
-
-    <insert id="saveOrUpdateItemResult" parameterType="com.iailab.module.model.mcs.pre.entity.MmItemResultEntity">
-        INSERT INTO t_mm_item_result (id,outputid, datatime, datavalue) VALUES
-        <foreach item="item" collection="list" separator=",">
-            (#{item.id},#{item.outputid},#{item.datatime},#{item.datavalue})
-        </foreach>
-            ON DUPLICATE KEY UPDATE datavalue = VALUES(datavalue)
-    </insert>
-
-
-</mapper>
\ No newline at end of file
diff --git a/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java
new file mode 100644
index 0000000..528b006
--- /dev/null
+++ b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java
@@ -0,0 +1,67 @@
+package com.iailab;
+
+import com.iailab.module.model.common.enums.DataTypeEnum;
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO;
+import com.iailab.module.model.influxdb.pojo.InfluxModelResultSimPOJO;
+import com.iailab.module.model.influxdb.service.InfluxDBService;
+import com.iailab.module.model.influxdb.vo.InfluxModelResultVO;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2023年12月10日 12:19:00
+ */
+@SpringBootTest
+public class InfluxDBTest {
+
+    @Resource
+    private InfluxDBService influxDBService;
+
+
+    @Test
+    public void testWrite() {
+        try {
+            List<InfluxModelResultPOJO> pointValues = new ArrayList<>();
+            InfluxModelResultSimPOJO pojo = new InfluxModelResultSimPOJO();
+            pojo.setOutPutId("0001");
+            pojo.setType(DataTypeEnum.FLOAT.getCode());
+            pojo.setTimestamp(new Date().toInstant());
+            pojo.setValue(Double.valueOf(0.001));
+            pointValues.add(pojo);
+
+            InfluxModelResultSimPOJO pojo1 = new InfluxModelResultSimPOJO();
+            pojo1.setOutPutId("0002");
+            pojo1.setType(DataTypeEnum.FLOAT.getCode());
+            pojo1.setTimestamp(new Date().toInstant());
+            pojo1.setValue(Double.valueOf(0.002));
+            pointValues.add(pojo1);
+
+            influxDBService.asyncWriteModelResults(pointValues);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+    }
+
+    @Test
+    public void testQuery() {
+        InfluxModelResultPOJO pojo = new InfluxModelResultPOJO();
+        pojo.setType("float");
+        pojo.setOutPutId("0001");
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.HOUR_OF_DAY, -1);
+
+        List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, calendar.getTime(), Calendar.getInstance().getTime());
+
+        System.out.println("value=" + influxModelResultVOS);
+
+    }
+}

--
Gitblit v1.9.3