潘志宝
2024-12-23 5bf42aa9950058f391805e6fb8d7376f4378924b
cumulateHandle.getCurrent
已修改2个文件
20 ■■■■■ 文件已修改
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java
@@ -116,6 +116,7 @@
            data.putAll(constantHandle.getCurrent(pointNos));
            data.putAll(measureHandle.getCurrent(pointNos));
            data.putAll(calculateHandle.getCurrent(pointNos));
            data.putAll(cumulateHandle.getCurrent(pointNos));
            return data;
        } catch (Exception ex) {
            return R.error(ex.getMessage());
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java
@@ -9,12 +9,14 @@
import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
@@ -28,6 +30,9 @@
@Slf4j
@Component
public class CumulateHandle {
    @Resource
    private DaPointService daPointService;
    @Autowired
    @Lazy
@@ -59,6 +64,20 @@
        return result;
    }
    public Map<String, Object> getCurrent(List<String> pointNos) {
        Map<String, Object> data = new HashMap<>();
        List<DaPointDTO> pointMathList = daPointService.getCumulatePoint(pointNos);
        if (CollectionUtils.isEmpty(pointMathList)) {
            return data;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MILLISECOND, 0);
        pointMathList.forEach(item -> {
            data.put(item.getPointNo(), singleCompute(item, calendar.getTime()));
        });
        return data;
    }
    private Object singleCompute(DaPointDTO dto, Date collectTime) {
        ApiPointDTO pointDTO = dataPointApi.getInfoByNo(dto.getMomentPoint());