|
@@ -269,8 +269,10 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
|
|
|
|
|
|
String topic = mqttDeviceDataVO.getTopic();
|
|
|
String[] topics = topic.split("/");
|
|
|
- String productCode1 = topics[1];
|
|
|
- String deviceId1 = topics[2];
|
|
|
+ //String productCode1 = topics[1];
|
|
|
+ //String deviceId1 = topics[2];
|
|
|
+ String deviceUuid = topics[3];
|
|
|
+
|
|
|
String payload = mqttDeviceDataVO.getDeviceData();
|
|
|
|
|
|
JSONObject deviceDataJson = JSONObject.parseObject(payload);
|
|
@@ -281,25 +283,36 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
|
|
|
Object metric = JSONObject.toJSONString(deviceDataJson.get("metrics"));
|
|
|
JSONObject metricJson = JSON.parseObject(metric.toString());
|
|
|
|
|
|
- if(!productCode1.equals(productCode2) || !deviceId1.equals(deviceId2)){
|
|
|
- throw new BusinessException("Topic和请求体中的产品编码、设备Id不一致,请修改");
|
|
|
- }
|
|
|
+// if(!productCode1.equals(productCode2) || !deviceId1.equals(deviceId2)){
|
|
|
+// throw new BusinessException("Topic和请求体中的产品编码、设备Id不一致,请修改");
|
|
|
+// }
|
|
|
|
|
|
LambdaQueryWrapper<DmpProduct> lambdaQuery = Wrappers.lambdaQuery();
|
|
|
- lambdaQuery.eq(DmpProduct::getProductCode,productCode1)
|
|
|
+ lambdaQuery.eq(DmpProduct::getProductCode,productCode2)
|
|
|
.eq(DmpProduct::getDeleteFlag,0);
|
|
|
List<DmpProduct> dmpProductList = dmpProductService.list(lambdaQuery);
|
|
|
if(dmpProductList.size() <= 0){
|
|
|
throw new BusinessException("产品编码不存在,请修改");
|
|
|
}
|
|
|
LambdaQueryWrapper<DmpDevice> lambdaQuery2 = Wrappers.lambdaQuery();
|
|
|
- lambdaQuery2.eq(DmpDevice::getDeviceId,deviceId1)
|
|
|
- .eq(DmpDevice::getProductCode,productCode1)
|
|
|
+ lambdaQuery2.eq(DmpDevice::getDeviceUuid,deviceUuid)
|
|
|
+ .eq(DmpDevice::getProductCode,productCode2)
|
|
|
.eq(DmpDevice::getServiceStatus,2)
|
|
|
.eq(DmpDevice::getDeleteFlag,0);
|
|
|
List<DmpDevice> dmpDeviceList = dmpDeviceService.list(lambdaQuery2);
|
|
|
if(dmpDeviceList.size() <= 0){
|
|
|
+ throw new BusinessException("topic主题中的设备Uuid不存在或在本产品下不存在,请修改");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<DmpDevice> lambdaQuery3 = Wrappers.lambdaQuery();
|
|
|
+ lambdaQuery3.eq(DmpDevice::getDeviceId,deviceId2)
|
|
|
+ .eq(DmpDevice::getProductCode,productCode2)
|
|
|
+ .eq(DmpDevice::getServiceStatus,2)
|
|
|
+ .eq(DmpDevice::getDeleteFlag,0);
|
|
|
+ List<DmpDevice> dmpDeviceList1 = dmpDeviceService.list(lambdaQuery3);
|
|
|
+ if(dmpDeviceList1.size() <= 0){
|
|
|
throw new BusinessException("设备Id不存在或在本产品下不存在,请修改");
|
|
|
+ }else{
|
|
|
+ deviceDataJson.put("deviceUuid",dmpDeviceList1.get(0).getDeviceUuid());
|
|
|
}
|
|
|
|
|
|
List<String> metricList = new ArrayList<>();
|
|
@@ -309,10 +322,10 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
|
|
|
}
|
|
|
}
|
|
|
int count1 = metricList.size();
|
|
|
- LambdaQueryWrapper<DmpProductAttribute> lambdaQuery3 = Wrappers.lambdaQuery();
|
|
|
- lambdaQuery3.eq(DmpProductAttribute::getProductId,dmpProductList.get(0).getId())
|
|
|
+ LambdaQueryWrapper<DmpProductAttribute> lambdaQuery4 = Wrappers.lambdaQuery();
|
|
|
+ lambdaQuery4.eq(DmpProductAttribute::getProductId,dmpProductList.get(0).getId())
|
|
|
.in(DmpProductAttribute::getAttributeCode,metricList);
|
|
|
- int count2 = dmpProductAttributeService.count(lambdaQuery3);
|
|
|
+ int count2 = dmpProductAttributeService.count(lambdaQuery4);
|
|
|
if(count1 > count2){
|
|
|
throw new BusinessException("设备属性编码不存在,请检查");
|
|
|
}
|