提交 | 用户 | 时间
|
b368e6
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
潘 |
2 |
|
|
3 |
import com.iailab.framework.common.util.date.DateUtils; |
a955f1
|
4 |
import com.iailab.module.model.common.enums.DataTypeEnum; |
D |
5 |
import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO; |
|
6 |
import com.iailab.module.model.influxdb.service.InfluxDBService; |
|
7 |
import com.iailab.module.model.influxdb.vo.InfluxModelResultVO; |
b368e6
|
8 |
import com.iailab.module.model.mcs.pre.service.MmItemResultLastPointService; |
a955f1
|
9 |
import org.springframework.beans.factory.annotation.Autowired; |
b368e6
|
10 |
import org.springframework.stereotype.Service; |
潘 |
11 |
|
a955f1
|
12 |
import java.math.BigDecimal; |
b368e6
|
13 |
import java.util.ArrayList; |
潘 |
14 |
import java.util.Date; |
|
15 |
import java.util.List; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author PanZhibao |
|
19 |
* @Description |
|
20 |
* @createTime 2024年11月14日 |
|
21 |
*/ |
|
22 |
@Service |
a955f1
|
23 |
public class MmItemResultLastPointServiceImpl implements MmItemResultLastPointService { |
D |
24 |
@Autowired |
|
25 |
private InfluxDBService influxDBService; |
b368e6
|
26 |
|
潘 |
27 |
@Override |
977edc
|
28 |
public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat) { |
b368e6
|
29 |
List<Object[]> result = new ArrayList<>(); |
a955f1
|
30 |
InfluxModelResultPOJO pojo = new InfluxModelResultPOJO(); |
D |
31 |
pojo.setType(DataTypeEnum.FLOAT_LAST.getCode()); |
|
32 |
pojo.setOutPutId(outputid); |
|
33 |
List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, startTime, endTime); |
|
34 |
influxModelResultVOS.forEach(item -> { |
b368e6
|
35 |
Object[] dataItem = new Object[2]; |
a955f1
|
36 |
dataItem[0] = DateUtils.format(Date.from(item.getTimestamp()), timeFormat); |
D |
37 |
dataItem[1] = BigDecimal.valueOf(Double.valueOf(item.getValue().toString())).setScale(2, BigDecimal.ROUND_HALF_UP); |
b368e6
|
38 |
result.add(dataItem); |
潘 |
39 |
}); |
|
40 |
return result; |
|
41 |
} |
|
42 |
} |