|
@@ -53,7 +53,7 @@ public class DmpDataInfoServiceImpl extends AbstractCrudService<DmpDataInfoMappe
|
|
|
|
|
|
@Override
|
|
|
public void data(DmpDeviceDataRequestVO dmpDeviceDataRequestVO){
|
|
|
- List<DeviceDataInfoVO> dataInfo = new ArrayList<>();
|
|
|
+ DeviceDataInfoVO dataInfo = new DeviceDataInfoVO();
|
|
|
|
|
|
LambdaQueryWrapper<DmpDeviceInfo> dmpDeviceQuery = Wrappers.lambdaQuery();
|
|
|
dmpDeviceQuery.eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
@@ -90,17 +90,14 @@ public class DmpDataInfoServiceImpl extends AbstractCrudService<DmpDataInfoMappe
|
|
|
if(CollectionUtils.isNotEmpty(list1)){
|
|
|
Map<String,Float> metrics = dmpDeviceDataRequestVO.getMetrics();
|
|
|
if(metrics.size()>0){
|
|
|
- DeviceDataInfoVO deviceDataInfoVO = new DeviceDataInfoVO();
|
|
|
- List<Map<String,Object>> list2 = new ArrayList<>();
|
|
|
+ Map<String,Object> mp = new HashMap<>();
|
|
|
for(Map.Entry<String,Float> map:metrics.entrySet()){
|
|
|
- Map<String,Object> mp = new HashMap<>();
|
|
|
boolean find = false;
|
|
|
String key = map.getKey();
|
|
|
float value = map.getValue();
|
|
|
for(int i=0;i<list1.size();i++){
|
|
|
if(key.equals(list1.get(i).getAttributeCode())){ //属性名需和产品注册信息一致
|
|
|
mp.put(key,value);
|
|
|
- list2.add(mp);
|
|
|
find = true;
|
|
|
}
|
|
|
}
|
|
@@ -108,12 +105,11 @@ public class DmpDataInfoServiceImpl extends AbstractCrudService<DmpDataInfoMappe
|
|
|
throw new BusinessException("对应这个产品下面的设备属性"+key+" 在产品属性表中不存在");
|
|
|
}
|
|
|
}
|
|
|
- deviceDataInfoVO.setMetrics(list2);
|
|
|
- deviceDataInfoVO.setDevice_id(dmpDeviceDataRequestVO.getDeviceId());
|
|
|
- deviceDataInfoVO.setProduct_id(list.get(0).getId().toString());
|
|
|
- deviceDataInfoVO.setTimestamp(dmpDeviceDataRequestVO.getTimestamp());
|
|
|
- deviceDataInfoVO.setDevice_type(list.get(0).getDeviceType()+"-"+shortName);
|
|
|
- dataInfo.add(deviceDataInfoVO);
|
|
|
+ dataInfo.setMetrics(mp);
|
|
|
+ dataInfo.setDevice_id(dmpDeviceDataRequestVO.getDeviceId());
|
|
|
+ dataInfo.setProduct_id(list.get(0).getId().toString());
|
|
|
+ dataInfo.setTimestamp(dmpDeviceDataRequestVO.getTimestamp());
|
|
|
+ dataInfo.setDevice_type(list.get(0).getDeviceType()+"-"+shortName);
|
|
|
}
|
|
|
}else{
|
|
|
throw new BusinessException("查找产品属性表失败,"+dmpDeviceDataRequestVO.getProductCode()+" 该产品对应的属性在产品信息表没有信息");
|
|
@@ -121,9 +117,8 @@ public class DmpDataInfoServiceImpl extends AbstractCrudService<DmpDataInfoMappe
|
|
|
}else{
|
|
|
throw new BusinessException("查找产品信息失败,"+dmpDeviceDataRequestVO.getProductCode()+" 在产品信息表中不存在");
|
|
|
}
|
|
|
- if(CollectionUtils.isNotEmpty(dataInfo)){
|
|
|
+ if(dataInfo != null){
|
|
|
mqttGateway.sendToMqtt("data-collector", JSONArray.toJSON(dataInfo).toString());
|
|
|
- String data = dataInfo.toString();
|
|
|
System.out.println(JSONArray.toJSON(dataInfo).toString());
|
|
|
}
|
|
|
}
|