适配乌班图新数据格式
This commit is contained in:
parent
3d3e03513a
commit
77602032ab
|
|
@ -71,6 +71,7 @@ public class LhIotUtil {
|
|||
public static WaterCommonTransVo transData(List<ScEquZhibiao> zhibiaoList, String mqttMessage) {
|
||||
WaterCommonTransVo waterCommonTransVo = new WaterCommonTransVo();
|
||||
ResponseCmd responseCmd = JSONObject.parseObject(mqttMessage,ResponseCmd.class);
|
||||
int counts = 0; //计数器,如果没有任何监测项与配置匹配,则放弃此数据
|
||||
if(responseCmd!=null){
|
||||
if(responseCmd.getRw_prot()!=null){
|
||||
if("rsp".equals(responseCmd.getRw_prot().getDir())) {
|
||||
|
|
@ -79,21 +80,23 @@ public class LhIotUtil {
|
|||
for (ScEquZhibiao scEquZhibiao : zhibiaoList) {
|
||||
eleMap.put(scEquZhibiao.getCode(), scEquZhibiao.getEntityField());
|
||||
}
|
||||
|
||||
if (!responseCmd.getRw_prot().getR_data().isEmpty()) {
|
||||
if (responseCmd.getRw_prot().getR_data()!=null && !responseCmd.getRw_prot().getR_data().isEmpty()) {
|
||||
//因为数据中不包含时间,所以使用当前时间
|
||||
waterCommonTransVo.setDataDateTime(LocalDateTime.now());
|
||||
waterCommonTransVo.setDataGatherType(IotConstants.MARK_REALDATA);
|
||||
|
||||
for (ResponseCmdData rDatum : responseCmd.getRw_prot().getR_data()) {
|
||||
String entityName = eleMap.get(rDatum.getName());//字段名称
|
||||
if (StringUtils.isNotBlank(entityName)) {
|
||||
TUtil.setFieldValue(waterCommonTransVo, entityName, rDatum.getValue());
|
||||
counts++;
|
||||
} else {
|
||||
log.error("指令:{}----未匹配到监测项目:{}", mqttMessage, rDatum.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.warn("{}-----------指令解析结果=============={}",mqttMessage,JSONObject.toJSONString(waterCommonTransVo));
|
||||
}else{
|
||||
log.error("----非主动请求数据,跳过解析==============回执:{}",mqttMessage);
|
||||
|
|
@ -104,6 +107,10 @@ public class LhIotUtil {
|
|||
}else{
|
||||
log.error("xxxxxxxxxxxxx解析失败,回执格式有误1xxxxxxxxxxxxx");
|
||||
}
|
||||
if(counts==0){
|
||||
log.error("xxxxxxxxxx未匹配到监测项,丢弃此数据{}xxxxxxxxxxxxxxx",mqttMessage);
|
||||
return null;
|
||||
}
|
||||
return waterCommonTransVo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue