Repair send threshold warnings for soil and air temperature

This commit is contained in:
2025-08-11 07:20:50 +05:00
parent e423647a59
commit 9f06a550fc
2 changed files with 12 additions and 7 deletions

View File

@ -10,9 +10,9 @@ spring:
application: application:
name: org-ccalm-main name: org-ccalm-main
datasource: datasource:
#url: jdbc:postgresql://almaty.ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000 url: jdbc:postgresql://almaty.ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
#url: jdbc:postgresql://ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000 #url: jdbc:postgresql://ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
url: jdbc:postgresql://127.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000 #url: jdbc:postgresql://127.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
username: postgres username: postgres
password: 309A86FF65A78FB428F4E38DFE35F730 password: 309A86FF65A78FB428F4E38DFE35F730
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver

View File

@ -147,7 +147,7 @@ public class SendWarning {
JSONObject tmp_air = getAirTemperature(obj.getDouble("lat"),obj.getDouble("lon")); JSONObject tmp_air = getAirTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
JSONObject tmp_soil = getSoilTemperature(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); Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
double value = obj.getDouble("temperature_air"); double value = obj.getDouble("temperature_air");
if (value < tmp_air.getDouble("value")) { if (value < tmp_air.getDouble("value")) {
@ -169,7 +169,7 @@ public class SendWarning {
.append("<body>") .append("<body>")
.append("<div class='container'>") .append("<div class='container'>")
.append("<h2>").append(trt.trt(true,"Warning")).append("</h2>") .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("<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,"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>") .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 main.frmcheckpoints
set set
warn_air=false 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(); MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue("uid", obj.getString("uid"), Types.VARCHAR); 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); Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
double value = obj.getDouble("temperature_soil"); double value = obj.getDouble("temperature_soil");
if (value < tmp_soil.getDouble("value")) { if (value < tmp_soil.getDouble("value")) {
@ -247,7 +249,9 @@ public class SendWarning {
main.frmcheckpoints main.frmcheckpoints
set set
warn_soil=false 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(); MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue("uid", obj.getString("uid"), Types.VARCHAR); param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
@ -260,6 +264,7 @@ public class SendWarning {
} catch (Exception ex) { } catch (Exception ex) {
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage(), ex); logger.error(MarkerFactory.getMarker(uuid),ex.getMessage(), ex);
result.put("error_code", 10000);
} }
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }