This commit is contained in:
lmc 2024-10-28 09:27:03 +08:00
commit 490bd84309
3 changed files with 25 additions and 25 deletions

View File

@ -9,7 +9,7 @@ public class SensorData {
* 上报时间 * 上报时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reportTime; private String reportTime;
/** /**
* 设备编码 * 设备编码
*/ */
@ -97,11 +97,11 @@ public class SensorData {
return zl; return zl;
} }
public Date getReportTime() { public String getReportTime() {
return reportTime; return reportTime;
} }
public void setReportTime(Date reportTime) { public void setReportTime(String reportTime) {
this.reportTime = reportTime; this.reportTime = reportTime;
} }

View File

@ -29,7 +29,7 @@ public class OutSideServiceImpl implements OutSideService {
String jsonData = data.substring(16); String jsonData = data.substring(16);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonData); JsonNode rootNode = objectMapper.readTree(jsonData);
JsonNode sensorNode = rootNode.get("sensorDatas").get(0); // 获取第一个 sensorData for (JsonNode sensorNode : rootNode.get("sensorDatas")) {
sensorData.setSn(sn); sensorData.setSn(sn);
sensorData.setFlag(sensorNode.get("flag").asText()); sensorData.setFlag(sensorNode.get("flag").asText());
sensorData.setDs(sensorNode.get("gas_value").asText()); sensorData.setDs(sensorNode.get("gas_value").asText());
@ -38,8 +38,7 @@ public class OutSideServiceImpl implements OutSideService {
int gasStatus = sensorNode.get("gas_status").asInt(); int gasStatus = sensorNode.get("gas_status").asInt();
String statusDescription = getStatusDescription(gasStatus); // 调用转换方法 String statusDescription = getStatusDescription(gasStatus); // 调用转换方法
sensorData.setZt(statusDescription); sensorData.setZt(statusDescription);
// sensorData.setZl(sensorNode.get("gas_type").asText()); 写死了 都是VOCS sensorData.setZl(sensorNode.get("gas_type").asText());
sensorData.setZl("VOCS");
// gas_unit 转换为对应单位 // gas_unit 转换为对应单位
int gasUnit = sensorNode.get("gas_unit").asInt(); int gasUnit = sensorNode.get("gas_unit").asInt();
String unitDescription = getUnitDescription(gasUnit); // 调用转换方法 String unitDescription = getUnitDescription(gasUnit); // 调用转换方法
@ -48,8 +47,9 @@ public class OutSideServiceImpl implements OutSideService {
sensorData.setGbz(sensorNode.get("alarmh").asText()); sensorData.setGbz(sensorNode.get("alarmh").asText());
sensorData.setLc(sensorNode.get("gas_range").asText()); sensorData.setLc(sensorNode.get("gas_range").asText());
sensorData.setJcjd(sensorNode.get("gas_dec").asInt());//检测精度 sensorData.setJcjd(sensorNode.get("gas_dec").asInt());//检测精度
sensorData.setReportTime(DateUtils.getNowDate()); sensorData.setReportTime(DateUtils.getTime());
outSideMapper.insertDevice(sensorData); outSideMapper.insertDevice(sensorData);
}
return 1; return 1;
}catch (Exception e) { }catch (Exception e) {
System.out.println(e); System.out.println(e);

View File

@ -25,7 +25,7 @@
LC LC
) VALUES ( ) VALUES (
#{sn, jdbcType=NVARCHAR}, #{sn, jdbcType=NVARCHAR},
#{reportTime, jdbcType=DATE}, TO_DATE(#{reportTime}, 'yyyy-mm-dd hh24:mi:ss'),
#{ds, jdbcType=NVARCHAR}, #{ds, jdbcType=NVARCHAR},
#{gbz, jdbcType=NVARCHAR}, #{gbz, jdbcType=NVARCHAR},
#{dbz, jdbcType=NVARCHAR}, #{dbz, jdbcType=NVARCHAR},