package com.iailab.module.model.mcs.pre.service.impl;
|
|
import com.iailab.framework.common.util.date.DateUtils;
|
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 java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年11月14日
|
*/
|
@Service
|
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<>();
|
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(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;
|
}
|
}
|