|
|
@@ -16,6 +16,7 @@ import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
|
|
|
import com.yunfeiyun.agmp.iotm.device.monitor.domin.IotMonitorAddressGetReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.monitor.service.IotMonitorService;
|
|
|
+import com.yunfeiyun.agmp.iotm.device.ybq.domain.IotYbqPredictIntoDto;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotHomeDeviceListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotScreenStatReqVo;
|
|
|
@@ -306,4 +307,48 @@ public class IotScreenServiceImpl implements IIotScreenService {
|
|
|
return resVoList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IotDeviceListResVo> ybqList(IotDeviceListReqVo reqVo) {
|
|
|
+ String[] devTypeList = DevTypeUtil.getAllYbqTypes();
|
|
|
+ reqVo.setTid(SecurityUtils.getTid());
|
|
|
+ reqVo.setDevtypeBidList(Arrays.asList(devTypeList));
|
|
|
+ List<IotDeviceListResVo> devList = iIotDeviceService.selectIotDeviceListByType(reqVo);
|
|
|
+
|
|
|
+ List<String> devBidList = new ArrayList<>();
|
|
|
+ if(!devList.isEmpty()){
|
|
|
+ for(IotDeviceListResVo dev : devList){
|
|
|
+ devBidList.add(dev.getDevBid());
|
|
|
+ }
|
|
|
+ Criteria criteria = new Criteria().and("devBid").in(devBidList);
|
|
|
+ MatchOperation matchOperation = Aggregation.match(criteria);
|
|
|
+ SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "deviceId", "computeDate");
|
|
|
+ ProjectionOperation projectionOperation = Aggregation.project("devBid", "deviceId", "computeDate", "value");
|
|
|
+ GroupOperation groupOperation = Aggregation.group("devBid")
|
|
|
+ .first("$$ROOT").as("latestData");
|
|
|
+ ProjectionOperation projectionOperation2 = Aggregation.project("devBid", "deviceId", "computeDate")
|
|
|
+ .andExpression("{$round: { {$convert: {input: '$value', to: 'double', onError: 0, onNull: 0}}, 2}}").as("value");
|
|
|
+
|
|
|
+ ReplaceRootOperation replaceRootOperation = Aggregation.replaceRoot("latestData");
|
|
|
+ Aggregation aggregation = Aggregation.newAggregation(
|
|
|
+ matchOperation, sortOperation, projectionOperation, groupOperation,
|
|
|
+ replaceRootOperation, projectionOperation2
|
|
|
+ );
|
|
|
+
|
|
|
+ List<IotYbqPredictIntoDto> ybqPredictIntoResVoList = mongoService.aggregate(
|
|
|
+ IotYbqPredictData.class, aggregation, IotYbqPredictIntoDto.class
|
|
|
+ );
|
|
|
+ Map<String, IotYbqPredictIntoDto> intoResVoMap = new HashMap<>();
|
|
|
+ if(ybqPredictIntoResVoList != null && !ybqPredictIntoResVoList.isEmpty()) {
|
|
|
+ for (IotYbqPredictIntoDto ybqPredictIntoResVo : ybqPredictIntoResVoList) {
|
|
|
+ intoResVoMap.put(ybqPredictIntoResVo.getDevBid(), ybqPredictIntoResVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(IotDeviceListResVo dev : devList){
|
|
|
+ IotYbqPredictIntoDto ybqPredictIntoResVo = intoResVoMap.get(dev.getDevBid());
|
|
|
+ dev.setIotYbqPredictIntoDto(ybqPredictIntoResVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return devList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|