| | |
| | | package com.iailab.module.data.point.collection.handler; |
| | | |
| | | import com.iailab.module.data.channel.http.collector.SourceApiEnum; |
| | | import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd; |
| | | import com.iailab.module.data.channel.opcda.collector.OpcDACollector; |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | |
| | | import com.iailab.module.data.point.common.PointDataTypeEnum; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | | import com.iailab.module.data.http.collector.HttpCollectorForZxzk; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | |
| | | @Autowired |
| | | private OpcDACollector opcDACollector; |
| | | |
| | | @Resource |
| | | private HttpCollectorForZxzk httpCollectorForZxzk; |
| | | @Autowired |
| | | private HttpCollectorForIhd httpCollectorForIhd; |
| | | |
| | | @Resource |
| | | private DaPointService daPointService; |
| | |
| | | List<String[]> opcDaTagIds = new ArrayList<>(); |
| | | List<String[]> modbusTagIds = new ArrayList<>(); |
| | | List<String[]> kioTagIds = new ArrayList<>(); |
| | | List<String[]> httpTagZxzk = new ArrayList<>(); |
| | | List<Object[]> httpTagIhd = new ArrayList<>(); |
| | | |
| | | |
| | | dtos.stream().forEach(item -> { |
| | |
| | | modbusTagIds.add(new String[]{item.getSourceId(), item.getTagNo()}); |
| | | } else if (DataSourceType.KIO.getCode().equals(item.getSourceType())) { |
| | | kioTagIds.add(new String[]{item.getSourceId(), item.getTagNo()}); |
| | | } else if (DataSourceType.HTTP.getCode().equals(item.getSourceType())) { |
| | | if (SourceApiEnum.iHyperDB.getCode().equals(item.getSourceName())) { |
| | | if (item.getTagNo() != null && item.getDimension() != null && item.getValueType() != null) { |
| | | httpTagIhd.add(new Object[]{item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType()}); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | if (!CollectionUtils.isEmpty(kioTagIds)) { |
| | | tagValues.putAll(kingIOCollector.getTagValues(kioTagIds)); |
| | | } |
| | | if (!CollectionUtils.isEmpty(httpTagZxzk)) { |
| | | tagValues.putAll(httpCollectorForZxzk.getTagValues(httpTagZxzk)); |
| | | |
| | | if (!CollectionUtils.isEmpty(httpTagIhd)) { |
| | | tagValues.putAll(httpCollectorForIhd.getTagValues(httpTagIhd, collectTime)); |
| | | } |
| | | this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); |
| | | log.info("测量点处理结束"); |
| | |
| | | private Object handleData(DaPointDTO dto, Object value) { |
| | | Object result = value; |
| | | try { |
| | | if (value == null) { |
| | | return CommonConstant.BAD_VALUE; |
| | | } |
| | | if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType()) || DataTypeEnum.INT.getCode().equals(dto.getDataType())) { |
| | | BigDecimal rawValue = new BigDecimal(value.toString()); |
| | | |
| | | if(CommonConstant.BAD_VALUE.compareTo(rawValue) == 0) { |
| | | return CommonConstant.BAD_VALUE; |
| | | } |
| | | // 异常值处理 |
| | | if (rawValue.compareTo(maxValue) > 0 || rawValue.compareTo(minValue) < 0) { |
| | | rawValue = CommonConstant.BAD_VALUE; |
| | | return CommonConstant.BAD_VALUE; |
| | | } |
| | | BigDecimal coefficient = dto.getUnittransfactor() == null ? BigDecimal.ONE : dto.getUnittransfactor(); |
| | | BigDecimal calValue = rawValue.multiply(coefficient); |
| | |
| | | } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType())) { |
| | | result = Boolean.parseBoolean(value.toString()); |
| | | } |
| | | |
| | | } catch (Exception ex) { |
| | | log.warn("handleData异常,PointNo=" + dto.getPointNo()); |
| | | ex.printStackTrace(); |
| | |
| | | } else if (DataSourceType.KIO.getCode().equals(item.getSourceType())) { |
| | | value = kingIOCollector.getTagValue(item.getSourceId(), item.getTagNo()); |
| | | } else if (DataSourceType.HTTP.getCode().equals(item.getSourceType())) { |
| | | if (CommonConstant.HTTP_API_ZXZK_IH.equals(item.getSourceName())) { |
| | | value = httpCollectorForZxzk.getTagValue(item.getSourceId(), item.getTagNo()); |
| | | } |
| | | value = httpCollectorForIhd.getTagValue(item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType()); |
| | | } else { |
| | | log.info("没有匹配的TagNo=" + item.getTagNo()); |
| | | } |