diff --git a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java index ff34926..a249219 100644 --- a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java +++ b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java @@ -602,7 +602,7 @@ // 获取加解密方式 String encipherType = deviceService.getDeviceEncipherTypeByDeviceCode(deviceCode); if (StrUtil.isEmpty(encipherType)) { - switch (BirmmDeviceTypeEnums.toType(deviceCode.substring(0, 2))) { + switch (BirmmDeviceTypeEnums.toTypeByDevPre(deviceCode.substring(0, 2))) { case METHANE: case INTG_METHANE: case SENTINEL: diff --git a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java index ff34926..a249219 100644 --- a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java +++ b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java @@ -602,7 +602,7 @@ // 获取加解密方式 String encipherType = deviceService.getDeviceEncipherTypeByDeviceCode(deviceCode); if (StrUtil.isEmpty(encipherType)) { - switch (BirmmDeviceTypeEnums.toType(deviceCode.substring(0, 2))) { + switch (BirmmDeviceTypeEnums.toTypeByDevPre(deviceCode.substring(0, 2))) { case METHANE: case INTG_METHANE: case SENTINEL: diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java index 7ec9224..6865e45 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java @@ -87,7 +87,7 @@ for (MethaneBizData data : bizDataList) { Map bizData = new HashMap<>(); bizData.put("bizType", String.valueOf(data.getBizType())); - bizData.put("value", String.format("%.3f", data.getValue())); + bizData.put("value", data.getValue()); bizData.put("uptime", data.getUptime()); // 电量 @@ -164,12 +164,13 @@ switch (BirmmDataBizTypeEnums.toType(uploadTag.getBizType())) { case TYPE_GAS_CONCENTRATION: case TYPE_TEMPERATURE: - bizData.setValue(BytesUtil.hexStringToFloat(hexReversStr)); // 转成浮点数 + float value = BytesUtil.hexStringToFloat(hexReversStr); + bizData.setValue(String.format("%.3f", value)); // 转成浮点数 break; case TYPE_WELL_STATE: case TYPE_INUNDATE_STATE: - bizData.setStateValue(hexReversStr); + bizData.setValue(hexReversStr); break; } diff --git a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java index ff34926..a249219 100644 --- a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java +++ b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java @@ -602,7 +602,7 @@ // 获取加解密方式 String encipherType = deviceService.getDeviceEncipherTypeByDeviceCode(deviceCode); if (StrUtil.isEmpty(encipherType)) { - switch (BirmmDeviceTypeEnums.toType(deviceCode.substring(0, 2))) { + switch (BirmmDeviceTypeEnums.toTypeByDevPre(deviceCode.substring(0, 2))) { case METHANE: case INTG_METHANE: case SENTINEL: diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java index 7ec9224..6865e45 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java @@ -87,7 +87,7 @@ for (MethaneBizData data : bizDataList) { Map bizData = new HashMap<>(); bizData.put("bizType", String.valueOf(data.getBizType())); - bizData.put("value", String.format("%.3f", data.getValue())); + bizData.put("value", data.getValue()); bizData.put("uptime", data.getUptime()); // 电量 @@ -164,12 +164,13 @@ switch (BirmmDataBizTypeEnums.toType(uploadTag.getBizType())) { case TYPE_GAS_CONCENTRATION: case TYPE_TEMPERATURE: - bizData.setValue(BytesUtil.hexStringToFloat(hexReversStr)); // 转成浮点数 + float value = BytesUtil.hexStringToFloat(hexReversStr); + bizData.setValue(String.format("%.3f", value)); // 转成浮点数 break; case TYPE_WELL_STATE: case TYPE_INUNDATE_STATE: - bizData.setStateValue(hexReversStr); + bizData.setValue(hexReversStr); break; } diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java index d1b45eb..fa119ff 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java @@ -12,8 +12,7 @@ LocalDateTime uptime; int bizType; - float value; - String stateValue; + String value; @Override public String toString() { @@ -22,18 +21,7 @@ public JSONObject toJSON() { JSONObject json = new JSONObject(); - switch (BirmmDataBizTypeEnums.toType(bizType)) { - case TYPE_GAS_CONCENTRATION: - case TYPE_TEMPERATURE: - // 气体浓度和温度为浮点数,保留3位小数 - json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), String.format("%.3f", value)); - break; - case TYPE_WELL_STATE: - case TYPE_INUNDATE_STATE: - // 水浸状态和震动状态为开关量,直接显示 - json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), stateValue); - } - + json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), value); json.put("uptime", uptime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); return json; } diff --git a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java index ff34926..a249219 100644 --- a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java +++ b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java @@ -602,7 +602,7 @@ // 获取加解密方式 String encipherType = deviceService.getDeviceEncipherTypeByDeviceCode(deviceCode); if (StrUtil.isEmpty(encipherType)) { - switch (BirmmDeviceTypeEnums.toType(deviceCode.substring(0, 2))) { + switch (BirmmDeviceTypeEnums.toTypeByDevPre(deviceCode.substring(0, 2))) { case METHANE: case INTG_METHANE: case SENTINEL: diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java index 7ec9224..6865e45 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java @@ -87,7 +87,7 @@ for (MethaneBizData data : bizDataList) { Map bizData = new HashMap<>(); bizData.put("bizType", String.valueOf(data.getBizType())); - bizData.put("value", String.format("%.3f", data.getValue())); + bizData.put("value", data.getValue()); bizData.put("uptime", data.getUptime()); // 电量 @@ -164,12 +164,13 @@ switch (BirmmDataBizTypeEnums.toType(uploadTag.getBizType())) { case TYPE_GAS_CONCENTRATION: case TYPE_TEMPERATURE: - bizData.setValue(BytesUtil.hexStringToFloat(hexReversStr)); // 转成浮点数 + float value = BytesUtil.hexStringToFloat(hexReversStr); + bizData.setValue(String.format("%.3f", value)); // 转成浮点数 break; case TYPE_WELL_STATE: case TYPE_INUNDATE_STATE: - bizData.setStateValue(hexReversStr); + bizData.setValue(hexReversStr); break; } diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java index d1b45eb..fa119ff 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java @@ -12,8 +12,7 @@ LocalDateTime uptime; int bizType; - float value; - String stateValue; + String value; @Override public String toString() { @@ -22,18 +21,7 @@ public JSONObject toJSON() { JSONObject json = new JSONObject(); - switch (BirmmDataBizTypeEnums.toType(bizType)) { - case TYPE_GAS_CONCENTRATION: - case TYPE_TEMPERATURE: - // 气体浓度和温度为浮点数,保留3位小数 - json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), String.format("%.3f", value)); - break; - case TYPE_WELL_STATE: - case TYPE_INUNDATE_STATE: - // 水浸状态和震动状态为开关量,直接显示 - json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), stateValue); - } - + json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), value); json.put("uptime", uptime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); return json; } diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java index eb961b0..2611ab8 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java @@ -86,34 +86,27 @@ for (MethaneBizData data : bizDataList) { Map bizData = new HashMap<>(); bizData.put("bizType", String.valueOf(data.getBizType())); - bizData.put("value", String.format("%.3f", data.getValue())); + bizData.put("value", data.getValue()); bizData.put("uptime", data.getUptime()); -// bizData.setBizType(String.valueOf(data.getBizType())); -// bizData.setValue(String.format("%.3f", data.getValue())); -// bizData.setUptime(data.getUptime()); // 电量 if (getTagList().containsKey(CellTag.class.getSimpleName())) { CellTag cellTag = (CellTag) getTagList().get(CellTag.class.getSimpleName()).get(0); bizData.put("cell", cellTag.getCellVal()); -// bizData.setCell(cellTag.getCellVal()); } // 信号质量 if (getTagList().containsKey(PCITag.class.getSimpleName())) { PCITag pciTag = (PCITag) getTagList().get(PCITag.class.getSimpleName()).get(0); bizData.put("pci", pciTag.getPci()); -// bizData.setPci(pciTag.getPci()); } if (getTagList().containsKey(RSRPTag.class.getSimpleName())) { RSRPTag rsrpTag = (RSRPTag) getTagList().get(RSRPTag.class.getSimpleName()).get(0); bizData.put("rsrp", rsrpTag.getRsrp()); -// bizData.setRsrp(rsrpTag.getRsrp()); } if (getTagList().containsKey(SNRTag.class.getSimpleName())) { SNRTag snrTag = (SNRTag) getTagList().get(SNRTag.class.getSimpleName()).get(0); bizData.put("snr", snrTag.getSnr()); -// bizData.setSnr(snrTag.getSnr()); } resultList.add(bizData); @@ -164,7 +157,8 @@ bizData.setBizType(uploadTag.getBizType()); bizData.setUptime(start); String hexReversStr = BytesUtil.reverseHexString(uploadTag.getValueStr().substring(i * 4 * 2, (i + 1) * 4 * 2)); - bizData.setValue(BytesUtil.hexStringToFloat(hexReversStr)); // 转成浮点数 + float value = BytesUtil.hexStringToFloat(hexReversStr); + bizData.setValue(String.format("%.3f", value)); // 转成浮点数 bizDataList.add(bizData); diff --git a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java index ff34926..a249219 100644 --- a/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java +++ b/sensorhub-core/src/main/java/com/casic/missiles/service/impl/GeneralServiceImpl.java @@ -602,7 +602,7 @@ // 获取加解密方式 String encipherType = deviceService.getDeviceEncipherTypeByDeviceCode(deviceCode); if (StrUtil.isEmpty(encipherType)) { - switch (BirmmDeviceTypeEnums.toType(deviceCode.substring(0, 2))) { + switch (BirmmDeviceTypeEnums.toTypeByDevPre(deviceCode.substring(0, 2))) { case METHANE: case INTG_METHANE: case SENTINEL: diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java index 7ec9224..6865e45 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/LGTrapRequestFrame.java @@ -87,7 +87,7 @@ for (MethaneBizData data : bizDataList) { Map bizData = new HashMap<>(); bizData.put("bizType", String.valueOf(data.getBizType())); - bizData.put("value", String.format("%.3f", data.getValue())); + bizData.put("value", data.getValue()); bizData.put("uptime", data.getUptime()); // 电量 @@ -164,12 +164,13 @@ switch (BirmmDataBizTypeEnums.toType(uploadTag.getBizType())) { case TYPE_GAS_CONCENTRATION: case TYPE_TEMPERATURE: - bizData.setValue(BytesUtil.hexStringToFloat(hexReversStr)); // 转成浮点数 + float value = BytesUtil.hexStringToFloat(hexReversStr); + bizData.setValue(String.format("%.3f", value)); // 转成浮点数 break; case TYPE_WELL_STATE: case TYPE_INUNDATE_STATE: - bizData.setStateValue(hexReversStr); + bizData.setValue(hexReversStr); break; } diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java index d1b45eb..fa119ff 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneBizData.java @@ -12,8 +12,7 @@ LocalDateTime uptime; int bizType; - float value; - String stateValue; + String value; @Override public String toString() { @@ -22,18 +21,7 @@ public JSONObject toJSON() { JSONObject json = new JSONObject(); - switch (BirmmDataBizTypeEnums.toType(bizType)) { - case TYPE_GAS_CONCENTRATION: - case TYPE_TEMPERATURE: - // 气体浓度和温度为浮点数,保留3位小数 - json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), String.format("%.3f", value)); - break; - case TYPE_WELL_STATE: - case TYPE_INUNDATE_STATE: - // 水浸状态和震动状态为开关量,直接显示 - json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), stateValue); - } - + json.put(BirmmDataBizTypeEnums.toType(bizType).getName(), value); json.put("uptime", uptime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); return json; } diff --git a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java index eb961b0..2611ab8 100644 --- a/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java +++ b/sensorhub-service-birmm/src/main/java/com/casic/missiles/frame/methane/MethaneTrapRequestFrame.java @@ -86,34 +86,27 @@ for (MethaneBizData data : bizDataList) { Map bizData = new HashMap<>(); bizData.put("bizType", String.valueOf(data.getBizType())); - bizData.put("value", String.format("%.3f", data.getValue())); + bizData.put("value", data.getValue()); bizData.put("uptime", data.getUptime()); -// bizData.setBizType(String.valueOf(data.getBizType())); -// bizData.setValue(String.format("%.3f", data.getValue())); -// bizData.setUptime(data.getUptime()); // 电量 if (getTagList().containsKey(CellTag.class.getSimpleName())) { CellTag cellTag = (CellTag) getTagList().get(CellTag.class.getSimpleName()).get(0); bizData.put("cell", cellTag.getCellVal()); -// bizData.setCell(cellTag.getCellVal()); } // 信号质量 if (getTagList().containsKey(PCITag.class.getSimpleName())) { PCITag pciTag = (PCITag) getTagList().get(PCITag.class.getSimpleName()).get(0); bizData.put("pci", pciTag.getPci()); -// bizData.setPci(pciTag.getPci()); } if (getTagList().containsKey(RSRPTag.class.getSimpleName())) { RSRPTag rsrpTag = (RSRPTag) getTagList().get(RSRPTag.class.getSimpleName()).get(0); bizData.put("rsrp", rsrpTag.getRsrp()); -// bizData.setRsrp(rsrpTag.getRsrp()); } if (getTagList().containsKey(SNRTag.class.getSimpleName())) { SNRTag snrTag = (SNRTag) getTagList().get(SNRTag.class.getSimpleName()).get(0); bizData.put("snr", snrTag.getSnr()); -// bizData.setSnr(snrTag.getSnr()); } resultList.add(bizData); @@ -164,7 +157,8 @@ bizData.setBizType(uploadTag.getBizType()); bizData.setUptime(start); String hexReversStr = BytesUtil.reverseHexString(uploadTag.getValueStr().substring(i * 4 * 2, (i + 1) * 4 * 2)); - bizData.setValue(BytesUtil.hexStringToFloat(hexReversStr)); // 转成浮点数 + float value = BytesUtil.hexStringToFloat(hexReversStr); + bizData.setValue(String.format("%.3f", value)); // 转成浮点数 bizDataList.add(bizData); diff --git a/sensorhub-support/src/main/java/com/casic/missiles/enums/BirmmDeviceTypeEnums.java b/sensorhub-support/src/main/java/com/casic/missiles/enums/BirmmDeviceTypeEnums.java index 91011d1..b97cff0 100644 --- a/sensorhub-support/src/main/java/com/casic/missiles/enums/BirmmDeviceTypeEnums.java +++ b/sensorhub-support/src/main/java/com/casic/missiles/enums/BirmmDeviceTypeEnums.java @@ -41,4 +41,8 @@ public static BirmmDeviceTypeEnums toType(String value) { return Stream.of(BirmmDeviceTypeEnums.values()).filter(p -> p.value.equalsIgnoreCase(value)).findAny().orElse(null); } + + public static BirmmDeviceTypeEnums toTypeByDevPre(String value) { + return Stream.of(BirmmDeviceTypeEnums.values()).filter(p -> p.devPrefix.equalsIgnoreCase(value)).findAny().orElse(null); + } }