package com.iailab.module.data.point.collection.handler;
|
|
import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils;
|
import com.iailab.module.data.point.dto.DaPointDTO;
|
import com.iailab.module.data.point.service.DaPointService;
|
import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO;
|
import lombok.extern.slf4j.Slf4j;
|
import javax.annotation.Resource;
|
import org.springframework.stereotype.Component;
|
import org.springframework.util.CollectionUtils;
|
|
import java.util.*;
|
|
/**
|
* 常量点处理
|
*
|
* @author PanZhibao
|
* @Description
|
* @createTime 2023年05月03日 22:28:00
|
*/
|
@Slf4j
|
@Component
|
public class ConstantHandle {
|
|
@Resource
|
private DaPointService daPointService;
|
|
public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap) {
|
log.info("常量点处理开始");
|
List<InfluxPointValuePOJO> result = new ArrayList<>();
|
if (CollectionUtils.isEmpty(dtos)) {
|
return result;
|
}
|
dtos.forEach(dto -> {
|
InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto);
|
pojo.setTimestamp(collectTime.toInstant());
|
dataMap.put(dto.getPointNo(), dto.getDefaultValue());
|
result.add(pojo);
|
});
|
log.info("常量点处理结束");
|
return result;
|
}
|
|
public Map<String, Object> getCurrent(List<String> pointNos) {
|
Map<String, Object> data = new HashMap<>();
|
|
List<DaPointDTO> pointConstantList = daPointService.getConstantPoint(pointNos);
|
if (!CollectionUtils.isEmpty(pointConstantList)) {
|
pointConstantList.forEach(item -> {
|
data.put(item.getPointNo(), item.getDefaultValue());
|
});
|
}
|
return data;
|
}
|
|
}
|