| | |
| | | package com.iailab.module.model.sample.constructor; |
| | | import com.iailab.module.data.dto.ApiDataDTO; |
| | | import com.iailab.module.data.api.IFeignDataApi; |
| | | import com.iailab.module.data.dto.ApiDataPointDTO; |
| | | import com.iailab.module.data.dto.FeignQueryPointDTO; |
| | | import com.iailab.module.device.service.DeviceMainService; |
| | | import com.iailab.module.event.service.EventInfoService; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointDTO; |
| | | import com.iailab.module.mcs.service.StModelResultService; |
| | | import com.iailab.module.model.sample.dto.ColumnItem; |
| | | import com.iailab.module.model.sample.dto.ColumnItemPort; |
| | | import com.iailab.module.model.sample.dto.SampleData; |
| | | import com.iailab.module.model.sample.dto.SampleInfo; |
| | | import com.iailab.module.model.sample.entity.DataEntity; |
| | | import com.iailab.module.prod.service.IndexEvaluateSystemService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | public class SampleDataConstructor { |
| | | |
| | | @Resource |
| | | private IFeignDataApi iFeignDataApi; |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Resource |
| | | private StModelResultService modelResultService; |
| | | |
| | | @Resource |
| | | private EventInfoService eventInfoService; |
| | | |
| | | @Resource |
| | | private DeviceMainService deviceMainService; |
| | | |
| | | @Resource |
| | | private IndexEvaluateSystemService indexEvaluateSystemService; |
| | | |
| | | @Resource |
| | | private IFeignDataApi feignDataController; |
| | | |
| | | public List<SampleData> prepareSampleData(SampleInfo sampleInfo) { |
| | | List<SampleData> sampleDataList = new ArrayList<>(); |
| | |
| | | break; |
| | | case "point": |
| | | // 测点值 |
| | | FeignQueryPointDTO dto = new FeignQueryPointDTO(); |
| | | dto.setEndTime(columnItem.endTime); |
| | | dto.setStartTime(columnItem.startTime); |
| | | dto.setPointCode(columnItem.getParamId()); |
| | | List<ApiDataDTO> pointValues = iFeignDataApi.queryPointValues(dto); |
| | | ApiPointValueQueryDTO dto = new ApiPointValueQueryDTO(); |
| | | dto.setEnd(columnItem.endTime); |
| | | dto.setStart(columnItem.startTime); |
| | | dto.setPointNo(columnItem.getParamId()); |
| | | List<ApiPointValueDTO> pointValues = dataPointApi.getValue(dto); |
| | | |
| | | List<DataEntity> tempList = new ArrayList<>(); |
| | | pointValues.forEach(item -> { |
| | | DataEntity dataEntity = new DataEntity(); |
| | | dataEntity.setDataValue(item.getDataValue()); |
| | | dataEntity.setTimeStamp(item.getTimeStamp()); |
| | | dataEntity.setTimeStamp(item.getDataTime()); |
| | | tempList.add(dataEntity); |
| | | }); |
| | | dataEntityList = tempList; |
| | | break; |
| | | case "wz": |
| | | FeignQueryPointDTO queryTag = new FeignQueryPointDTO(); |
| | | queryTag.setEndTime(columnItem.endTime); |
| | | queryTag.setStartTime(columnItem.startTime); |
| | | queryTag.setPointCode(columnItem.getParamId()); |
| | | List<ApiDataDTO> tagValues = iFeignDataApi.querySimTagValues(queryTag); |
| | | |
| | | List<DataEntity> tempListTag = new ArrayList<>(); |
| | | tagValues.forEach(item -> { |
| | | DataEntity dataEntity = new DataEntity(); |
| | | dataEntity.setDataValue(item.getDataValue()); |
| | | dataEntity.setTimeStamp(item.getTimeStamp()); |
| | | tempListTag.add(dataEntity); |
| | | }); |
| | | dataEntityList = tempListTag; |
| | | break; |
| | | case "real": |
| | | // 实时值 |
| | | List<String> pointNos = new ArrayList<>(); |
| | | pointNos.add(columnItem.getParamId()); |
| | | Map<String, Object> data = iFeignDataApi.getCurrentValue(pointNos); |
| | | DataEntity realData = new DataEntity(); |
| | | realData.setTimeStamp(new Date()); |
| | | realData.setDataValue(Double.parseDouble(data.get(columnItem.getParamId()).toString())); |
| | | dataEntityList.add(realData); |
| | | break; |
| | | case "ind": |
| | | // 指标数据 |
| | | FeignQueryPointDTO dto1 = new FeignQueryPointDTO(); |
| | | dto1.setEndTime(columnItem.endTime); |
| | | dto1.setStartTime(columnItem.startTime); |
| | | dto1.setPointCode(columnItem.getParamId()); |
| | | List<ApiDataDTO> indItemValues = iFeignDataApi.queryIndItemValues(dto1); |
| | | List<DataEntity> tempList1 = new ArrayList<>(); |
| | | indItemValues.forEach(item -> { |
| | | DataEntity dataEntity = new DataEntity(); |
| | | dataEntity.setDataValue(item.getDataValue()); |
| | | dataEntity.setTimeStamp(item.getTimeStamp()); |
| | | tempList1.add(dataEntity); |
| | | }); |
| | | dataEntityList = tempList1; |
| | | break; |
| | | case "device-main": |
| | | // 检修记录 |
| | | Integer mainTimes = deviceMainService.getCount(columnItem.getParamId(), columnItem.startTime, columnItem.endTime); |
| | | DataEntity mainData = new DataEntity(); |
| | | mainData.setTimeStamp(columnItem.endTime); |
| | | mainData.setDataValue(mainTimes.doubleValue()); |
| | | dataEntityList.add(mainData); |
| | | break; |
| | | case "event": |
| | | // 报警事件 |
| | | Long eventTimes = eventInfoService.getCount(columnItem.getParamId(), columnItem.startTime, columnItem.endTime); |
| | | DataEntity eventData = new DataEntity(); |
| | | eventData.setTimeStamp(columnItem.endTime); |
| | | eventData.setDataValue(eventTimes.doubleValue()); |
| | | dataEntityList.add(eventData); |
| | | break; |
| | | case "evaluate_weight": |
| | | // 指标权重 |
| | | List<Double> weightList = indexEvaluateSystemService.getWeight(); |
| | | List<DataEntity> weightDataList = new ArrayList<>(); |
| | | weightList.forEach(item -> { |
| | | DataEntity weightData = new DataEntity(); |
| | | weightData.setTimeStamp(columnItem.endTime); |
| | | weightData.setDataValue(item); |
| | | weightDataList.add(weightData); |
| | | }); |
| | | dataEntityList = weightDataList; |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | if (CollectionUtils.isEmpty(dataEntityList) || length <= dataEntityList.size()) { |
| | | return dataEntityList; |
| | | } |
| | | // log.info("补全数据, length =" + length + "; size = " + dataEntityList.size() + "; startTime = " + startTime + "; endTime = " + endTime); |
| | | // log.info("补全前:" + dataEntityList); |
| | | /*log.info("补全数据, length =" + length + "; size = " + dataEntityList.size() + "; startTime = " + startTime + "; endTime = " + endTime); |
| | | log.info("补全前:" + dataEntityList);*/ |
| | | |
| | | ApiDataPointDTO dataPoint = feignDataController.getPoint(paramId); |
| | | ApiPointDTO dataPoint = dataPointApi.getPoint(paramId); |
| | | |
| | | Map<Long, Double> sourceDataMap = new HashMap<>(dataEntityList.size()); |
| | | for (DataEntity dataEntity : dataEntityList) { |