Repair send threshold warnings for soil and air temperature
This commit is contained in:
@ -147,7 +147,7 @@ public class SendWarning {
|
||||
JSONObject tmp_air = getAirTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
||||
JSONObject tmp_soil = getSoilTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
||||
|
||||
if(tmp_air!=null && obj.getBoolean("warn_air")) {
|
||||
if(tmp_air!=null && obj.getBoolean("warn_air") && !obj.isNull("temperature_air")) {
|
||||
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
||||
double value = obj.getDouble("temperature_air");
|
||||
if (value < tmp_air.getDouble("value")) {
|
||||
@ -169,7 +169,7 @@ public class SendWarning {
|
||||
.append("<body>")
|
||||
.append("<div class='container'>")
|
||||
.append("<h2>").append(trt.trt(true,"Warning")).append("</h2>")
|
||||
.append("<p>").append(trt.trt(true,"The_soil_temperature_has_exceeded_the_set_value")).append(": ").append(value).append("</p>")
|
||||
.append("<p>").append(trt.trt(true,"The_air_temperature_has_exceeded_the_set_value")).append(": ").append(value).append("</p>")
|
||||
.append("<table>")
|
||||
.append("<tr><th>").append(trt.trt(true,"Date")).append("</th><td>").append(tmp_air.getString("date")).append("</td></tr>")
|
||||
.append("<tr><th>").append(trt.trt(true,"Value")).append("</th><td>").append(tmp_air.getDouble("value")).append(" °C</td></tr>")
|
||||
@ -192,7 +192,9 @@ public class SendWarning {
|
||||
main.frmcheckpoints
|
||||
set
|
||||
warn_air=false
|
||||
where uid=CAST(:uid AS uuid)
|
||||
where
|
||||
uid=CAST(:uid AS uuid)
|
||||
and (warn_hold!=true or warn_hold is null)
|
||||
""";
|
||||
MapSqlParameterSource param = new MapSqlParameterSource();
|
||||
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
|
||||
@ -202,7 +204,7 @@ public class SendWarning {
|
||||
}
|
||||
}
|
||||
|
||||
if(tmp_soil!=null && obj.getBoolean("warn_soil")) {
|
||||
if(tmp_soil!=null && obj.getBoolean("warn_soil") && !obj.isNull("temperature_soil")) {
|
||||
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
||||
double value = obj.getDouble("temperature_soil");
|
||||
if (value < tmp_soil.getDouble("value")) {
|
||||
@ -247,7 +249,9 @@ public class SendWarning {
|
||||
main.frmcheckpoints
|
||||
set
|
||||
warn_soil=false
|
||||
where uid=CAST(:uid AS uuid)
|
||||
where
|
||||
uid=CAST(:uid AS uuid)
|
||||
and (warn_hold!=true or warn_hold is null)
|
||||
""";
|
||||
MapSqlParameterSource param = new MapSqlParameterSource();
|
||||
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
|
||||
@ -260,6 +264,7 @@ public class SendWarning {
|
||||
} catch (Exception ex) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage(), ex);
|
||||
result.put("error_code", 10000);
|
||||
}
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user