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/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java | 34 ++++++++++++++++------------------ 1 files changed, 16 insertions(+), 18 deletions(-) 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; -- Gitblit v1.9.3