IVI modif

This commit is contained in:
2025-07-03 07:35:02 +05:00
parent 36783d2de7
commit 91a1e86415
4 changed files with 146 additions and 146 deletions

View File

@ -143,6 +143,7 @@
<version>1.18.36</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

View File

@ -110,6 +110,7 @@ public class SendWarning {
return result;
}
//https://ccalm.test/api/locust/v01/SendWarning
@RequestMapping(value = {"/api/locust/v01/SendWarning"},method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
@ResponseBody
public ResponseEntity<Object> send() {
@ -143,24 +144,22 @@ public class SendWarning {
for (String jsonString : ret) {
JSONObject obj = new JSONObject(jsonString);
JSONObject tmp_soil = getSoilTemperature(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"));
if(tmp_air!=null) {
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
double value = obj.getDouble("value");
double value = obj.getDouble("temperature_air");
if (value < tmp_air.getDouble("value")) {
String email = obj.getString("email");
if(email.equals("irigm@mail.ru") || email.equals("ivanov.i@istt.kz")){ //TODO для тестирования потом удалить
StringBuilder html = new StringBuilder(1024);
html.append("<html>")
.append("<head>")
.append("<style>")
.append("body { font-family: Arial, sans-serif; background-color: #f4f4f4; color: #333; margin: 0; padding: 0; }")
.append(".container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fff; border: 1px solid #ddd; position: relative; }")
.append(".container { max-width: 600px; margin: 20px auto 0 auto; padding: 20px; background-color: #fff; border: 1px solid #ddd; position: relative; }")
.append(".logo { position: absolute; top: 10px; right: 10px; width: 100px; height: auto; }")
.append("h2 { color: #d9534f; margin-top: 50px; }") // Отступ для логотипа
.append("h2 { color: #d9534f; }")
.append("table { border-collapse: collapse; width: 100%; margin: 20px 0; }")
.append("th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }")
.append("th { background-color: #f9f9f9; }")
@ -169,7 +168,6 @@ public class SendWarning {
.append("</head>")
.append("<body>")
.append("<div class='container'>")
.append("<img src='https://ccalm.org/resources/images/locust.png' alt='Logo' class='logo'>") // Логотип
.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("<table>")
@ -193,33 +191,30 @@ public class SendWarning {
update
main.frmcheckpoints
set
warn=true
where uid=:uid
warn_air=true
where uid=CAST(:uid AS uuid)
""";
MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue("uid", obj.getString("uid"), Types.INTEGER);
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
int rowsUpdated = jdbcTemplate.update(sql, param);
System.out.println("rowsUpdated = "+String.valueOf(rowsUpdated));
}
}
}
}
if(tmp_soil!=null) {
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
double value = obj.getDouble("value");
double value = obj.getDouble("temperature_soil");
if (value < tmp_soil.getDouble("value")) {
String email = obj.getString("email");
if(email.equals("irigm@mail.ru") || email.equals("ivanov.i@istt.kz")){ //TODO для тестирования потом удалить
StringBuilder html = new StringBuilder(1024);
html.append("<html>")
.append("<head>")
.append("<style>")
.append("body { font-family: Arial, sans-serif; background-color: #f4f4f4; color: #333; margin: 0; padding: 0; }")
.append(".container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fff; border: 1px solid #ddd; position: relative; }")
.append(".container { max-width: 600px; margin: 20px auto 0 auto; padding: 20px; background-color: #fff; border: 1px solid #ddd; position: relative; }")
.append(".logo { position: absolute; top: 10px; right: 10px; width: 100px; height: auto; }")
.append("h2 { color: #d9534f; margin-top: 50px; }") // Отступ для логотипа
.append("h2 { color: #d9534f; }")
.append("table { border-collapse: collapse; width: 100%; margin: 20px 0; }")
.append("th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }")
.append("th { background-color: #f9f9f9; }")
@ -228,7 +223,6 @@ public class SendWarning {
.append("</head>")
.append("<body>")
.append("<div class='container'>")
.append("<img src='https://ccalm.org/resources/images/locust.png' alt='Logo' class='logo'>") // Логотип
.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("<table>")
@ -252,20 +246,17 @@ public class SendWarning {
update
main.frmcheckpoints
set
warn=true
where uid=:uid
warn_soil=true
where uid=CAST(:uid AS uuid)
""";
MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue("uid", obj.getString("uid"), Types.INTEGER);
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
int rowsUpdated = jdbcTemplate.update(sql, param);
System.out.println("rowsUpdated = "+String.valueOf(rowsUpdated));
}
}
}
}
}
} catch (Exception ex) {
String uuid = UUID.randomUUID().toString();
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage(), ex);

View File

@ -14,11 +14,6 @@ import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
/**
* A utility class for sending e-mail messages
* @author www.codejava.net
*
*/
public class EmailUtility {
public static void sendEmail(String host, String port,
@ -26,7 +21,6 @@ public class EmailUtility {
String subject, String message) throws AddressException,
MessagingException
{
// sets SMTP server properties
Properties properties = new Properties();
@ -63,4 +57,5 @@ public class EmailUtility {
// sends the e-mail
Transport.send(msg);
}
}

View File

@ -1171,8 +1171,21 @@ new Calendar({
<td style="padding: 1px; width: 158px; white-space: nowrap;" th:text="${Year}">Year</td>
<td style="padding: 1px;">
<select style="width: 100%;" id="filter_ivi_year">
<option value="2023_03_05">2023 (03..05)</option>
<option value="2025_02_04">2025 (02..04)</option>
<option value="2025_03_05">2025 (03..05)</option>
<option value="2025_04_06">2025 (04..06)</option>
<option value="2025_05_07">2025 (05..07)</option>
<option value="2024_02_04">2024 (02..04)</option>
<option value="2024_03_05">2024 (03..05)</option>
<option value="2024_04_06">2024 (04..06)</option>
<option value="2024_05_07">2024 (05..07)</option>
<option value="2023_02_04">2023 (02..04)</option>
<option value="2023_03_05">2023 (03..05)</option>
<option value="2023_04_06">2023 (04..06)</option>
<option value="2023_05_07">2023 (05..07)</option>
<option value="2022_02_04">2022 (02..04)</option>
<option value="2022_03_05">2022 (03..05)</option>