提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.point.collection.handler; |
H |
2 |
|
|
3 |
import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; |
|
4 |
import com.iailab.module.data.point.dto.DaPointDTO; |
|
5 |
import com.iailab.module.data.point.service.DaPointService; |
|
6 |
import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
|
7 |
import lombok.extern.slf4j.Slf4j; |
|
8 |
import javax.annotation.Resource; |
|
9 |
import org.springframework.stereotype.Component; |
|
10 |
import org.springframework.util.CollectionUtils; |
|
11 |
|
|
12 |
import java.util.*; |
|
13 |
|
|
14 |
/** |
|
15 |
* 常量点处理 |
|
16 |
* |
|
17 |
* @author PanZhibao |
|
18 |
* @Description |
|
19 |
* @createTime 2023年05月03日 22:28:00 |
|
20 |
*/ |
|
21 |
@Slf4j |
|
22 |
@Component |
|
23 |
public class ConstantHandle { |
|
24 |
|
|
25 |
@Resource |
|
26 |
private DaPointService daPointService; |
|
27 |
|
|
28 |
public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap) { |
|
29 |
log.info("常量点处理开始"); |
|
30 |
List<InfluxPointValuePOJO> result = new ArrayList<>(); |
|
31 |
if (CollectionUtils.isEmpty(dtos)) { |
|
32 |
return result; |
|
33 |
} |
|
34 |
dtos.forEach(dto -> { |
|
35 |
InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto); |
|
36 |
pojo.setTimestamp(collectTime.toInstant()); |
|
37 |
dataMap.put(dto.getPointNo(), dto.getDefaultValue()); |
|
38 |
result.add(pojo); |
|
39 |
}); |
|
40 |
log.info("常量点处理结束"); |
|
41 |
return result; |
|
42 |
} |
|
43 |
|
|
44 |
public Map<String, Object> getCurrent(List<String> pointNos) { |
|
45 |
Map<String, Object> data = new HashMap<>(); |
|
46 |
|
|
47 |
List<DaPointDTO> pointConstantList = daPointService.getConstantPoint(pointNos); |
|
48 |
if (!CollectionUtils.isEmpty(pointConstantList)) { |
|
49 |
pointConstantList.forEach(item -> { |
|
50 |
data.put(item.getPointNo(), item.getDefaultValue()); |
|
51 |
}); |
|
52 |
} |
|
53 |
return data; |
|
54 |
} |
|
55 |
|
|
56 |
} |