refactor(data-push): 优化指标值转换逻辑并调整打包方式
- 修改项目打包方式从 jar 调整为 war - 优化 CURRENT_VALUE 字段的类型转换逻辑,确保其能正确解析为 Float 类型 - 增强对空值的处理,避免因数据缺失导致异常 - 将错误输出语句调整为标准输出,统一日志记录方式 - 更新项目名称及 groupId 以匹配新的命名规范dev
parent
c6229f43b2
commit
0404522f9c
8
pom.xml
8
pom.xml
|
|
@ -2,12 +2,12 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.integrated_yjb_dataDocking</groupId>
|
<groupId>com.sx_yjb_dataDocking</groupId>
|
||||||
<artifactId>integrated_yjb_dataDocking</artifactId>
|
<artifactId>sx_yjb_dataDocking</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<name>integrated_yjb_dataDocking</name>
|
<name>sx_yjb_dataDocking</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,20 @@ public class ProvincialPlatformDataPushScheduled {
|
||||||
if (dataPd.containsKey("REPORT_ID") && !Tools.isEmpty(dataPd.getString("REPORT_ID"))) {
|
if (dataPd.containsKey("REPORT_ID") && !Tools.isEmpty(dataPd.getString("REPORT_ID"))) {
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
data.put("quotaId", dataPd.get("REPORT_ID")); // 传感编码
|
data.put("quotaId", dataPd.get("REPORT_ID")); // 传感编码
|
||||||
data.put("value", dataPd.get("CURRENT_VALUE")); // 指标当前采集值
|
// 确保 CURRENT_VALUE 转换为 Float 类型
|
||||||
data.put("datas", true); // 质量戳
|
Object currentValue = dataPd.get("CURRENT_VALUE");
|
||||||
|
if (currentValue != null) {
|
||||||
|
if (currentValue instanceof String) {
|
||||||
|
data.put("value", Float.parseFloat((String) currentValue));
|
||||||
|
} else if (currentValue instanceof Number) {
|
||||||
|
data.put("value", ((Number) currentValue).floatValue());
|
||||||
|
} else {
|
||||||
|
data.put("value", currentValue);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.put("value", null);
|
||||||
|
}
|
||||||
|
data.put("isValid", true); // 质量戳
|
||||||
dataList.add(data);
|
dataList.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +199,7 @@ public class ProvincialPlatformDataPushScheduled {
|
||||||
if (response.getStatusCode().is2xxSuccessful()) {
|
if (response.getStatusCode().is2xxSuccessful()) {
|
||||||
System.out.println("数据推送成功,响应内容:" + response.getBody());
|
System.out.println("数据推送成功,响应内容:" + response.getBody());
|
||||||
} else {
|
} else {
|
||||||
System.err.println("数据推送失败,状态码:" + response.getStatusCodeValue() +
|
System.out.println("数据推送失败,状态码:" + response.getStatusCodeValue() +
|
||||||
",响应内容:" + response.getBody());
|
",响应内容:" + response.getBody());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue