houzhongjian
2 天以前 6e0d1d51916e4f41e06c06e984a70ebd08352d95
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/point/DataPointApiImpl.java
@@ -12,17 +12,21 @@
import com.iailab.module.data.point.dto.DaMathPointDTO;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.dto.DaPointWriteValueDTO;
import com.iailab.module.data.point.entity.DaPointBadHistoryEntity;
import com.iailab.module.data.point.service.DaMathPointService;
import com.iailab.module.data.point.service.DaPointBadHistoryService;
import com.iailab.module.data.point.service.DaPointService;
import com.iailab.module.data.point.vo.DaPointBadHistoryPageReqVO;
import com.iailab.module.data.point.vo.DaPointCountReqVO;
import com.iailab.module.data.point.vo.DaPointPageReqVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
 * @author PanZhibao
@@ -44,6 +48,9 @@
    @Autowired
    private DaMathPointService daMathPointService;
    @Autowired
    private DaPointBadHistoryService daPointBadHistoryService;
    @Override
    public ApiPointDTO getInfoById(String pointId) {
@@ -67,6 +74,86 @@
    @Override
    public Map<String, Object> queryPointsRealValue(List<String> pointNos) {
        return pointCollector.getCurrentValue(pointNos);
    }
    @Override
    public Map<String, Object> queryPointMaxValue(ApiPointValueQueryDTO queryDto) {
        Map<String, Object> result = new HashMap<>();
        if (StringUtils.isEmpty(queryDto.getPointNo())) {
            return null;
        }
        if (queryDto.getStart() == null) {
            return null;
        }
        DaPointDTO daPointDTO = daPointService.getByNo(queryDto.getPointNo());
        InfluxPointValuePOJO pojo = new InfluxPointValuePOJO();
        pojo.setPoint(queryDto.getPointNo());
        pojo.setType(daPointDTO.getDataType());
        Object val = influxDBService.queryPointMaxValue(pojo, queryDto.getStart());
        result.put(queryDto.getPointNo(), val);
        return result;
    }
    @Override
    public Map<String, Object> queryPointMaxTimeValue(ApiPointValueQueryDTO queryDto) {
        Map<String, Object> result = new HashMap<>();
        if (StringUtils.isEmpty(queryDto.getPointNo())) {
            return null;
        }
        if (queryDto.getStart() == null) {
            return null;
        }
        if (queryDto.getEnd() == null) {
            queryDto.setEnd(new Date());
        }
        DaPointDTO daPointDTO = daPointService.getByNo(queryDto.getPointNo());
        InfluxPointValuePOJO pojo = new InfluxPointValuePOJO();
        pojo.setPoint(queryDto.getPointNo());
        pojo.setType(daPointDTO.getDataType());
        result = influxDBService.queryPointMaxTimeValue(pojo, queryDto.getStart(), queryDto.getEnd());
        return result;
    }
    @Override
    public Map<String, Object> queryPointMaxValueRange(ApiPointValueQueryDTO queryDto) {
        Map<String, Object> result = new HashMap<>();
        if (StringUtils.isEmpty(queryDto.getPointNo())) {
            return null;
        }
        if (queryDto.getStart() == null) {
            return null;
        }
        if (queryDto.getEnd() == null) {
            queryDto.setEnd(new Date());
        }
        DaPointDTO daPointDTO = daPointService.getByNo(queryDto.getPointNo());
        InfluxPointValuePOJO pojo = new InfluxPointValuePOJO();
        pojo.setPoint(queryDto.getPointNo());
        pojo.setType(daPointDTO.getDataType());
        Object val = influxDBService.queryPointMaxValueRange(pojo, queryDto.getStart(), queryDto.getEnd());
        result.put(queryDto.getPointNo(), val);
        return result;
    }
    @Override
    public Map<String, Object> queryPointMinValueRange(ApiPointValueQueryDTO queryDto) {
        Map<String, Object> result = new HashMap<>();
        if (StringUtils.isEmpty(queryDto.getPointNo())) {
            return null;
        }
        if (queryDto.getStart() == null) {
            return null;
        }
        if (queryDto.getEnd() == null) {
            queryDto.setEnd(new Date());
        }
        DaPointDTO daPointDTO = daPointService.getByNo(queryDto.getPointNo());
        InfluxPointValuePOJO pojo = new InfluxPointValuePOJO();
        pojo.setPoint(queryDto.getPointNo());
        pojo.setType(daPointDTO.getDataType());
        Object val = influxDBService.queryPointMinValueRange(pojo, queryDto.getStart(), queryDto.getEnd());
        result.put(queryDto.getPointNo(), val);
        return result;
    }
    @Override
@@ -112,6 +199,7 @@
            endTime = calendar.getTime();
        }
        if (startTime == null) {
            calendar.setTime(endTime);
            calendar.add(Calendar.HOUR_OF_DAY, -1);
            startTime = calendar.getTime();
        }
@@ -165,4 +253,18 @@
        });
        return new PageResult<>(dataList, pageResult.getTotal());
    }
    @Override
    public PageResult<ApiPointBadHistoryDTO> queryPointBadHistoryPage(ApiPointBadHistoryPageReqVO reqVO) {
        DaPointBadHistoryPageReqVO req = ConvertUtils.sourceToTarget(reqVO, DaPointBadHistoryPageReqVO.class);
        PageResult<DaPointBadHistoryEntity> page = daPointBadHistoryService.queryPage(req);
        List<ApiPointBadHistoryDTO> dataList = ConvertUtils.sourceToTarget(page.getList(), ApiPointBadHistoryDTO.class);
        return new PageResult<>(dataList, page.getTotal());
    }
    @Override
    public String getPointTotalCount(ApiPointCountReqVO reqVO) {
        DaPointCountReqVO req = ConvertUtils.sourceToTarget(reqVO, DaPointCountReqVO.class);
        return daPointService.getPointCount(req).toString();
    }
}