IVI modif
This commit is contained in:
1
pom.xml
1
pom.xml
@ -143,6 +143,7 @@
|
|||||||
<version>1.18.36</version>
|
<version>1.18.36</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -110,6 +110,7 @@ public class SendWarning {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//https://ccalm.test/api/locust/v01/SendWarning
|
||||||
@RequestMapping(value = {"/api/locust/v01/SendWarning"},method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
|
@RequestMapping(value = {"/api/locust/v01/SendWarning"},method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<Object> send() {
|
public ResponseEntity<Object> send() {
|
||||||
@ -143,24 +144,22 @@ public class SendWarning {
|
|||||||
for (String jsonString : ret) {
|
for (String jsonString : ret) {
|
||||||
JSONObject obj = new JSONObject(jsonString);
|
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_air = getAirTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
||||||
|
JSONObject tmp_soil = getSoilTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
||||||
|
|
||||||
if(tmp_air!=null) {
|
if(tmp_air!=null) {
|
||||||
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
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")) {
|
if (value < tmp_air.getDouble("value")) {
|
||||||
String email = obj.getString("email");
|
String email = obj.getString("email");
|
||||||
if(email.equals("irigm@mail.ru") || email.equals("ivanov.i@istt.kz")){ //TODO для тестирования потом удалить
|
|
||||||
|
|
||||||
StringBuilder html = new StringBuilder(1024);
|
StringBuilder html = new StringBuilder(1024);
|
||||||
html.append("<html>")
|
html.append("<html>")
|
||||||
.append("<head>")
|
.append("<head>")
|
||||||
.append("<style>")
|
.append("<style>")
|
||||||
.append("body { font-family: Arial, sans-serif; background-color: #f4f4f4; color: #333; margin: 0; padding: 0; }")
|
.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(".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("table { border-collapse: collapse; width: 100%; margin: 20px 0; }")
|
||||||
.append("th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }")
|
.append("th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }")
|
||||||
.append("th { background-color: #f9f9f9; }")
|
.append("th { background-color: #f9f9f9; }")
|
||||||
@ -169,7 +168,6 @@ public class SendWarning {
|
|||||||
.append("</head>")
|
.append("</head>")
|
||||||
.append("<body>")
|
.append("<body>")
|
||||||
.append("<div class='container'>")
|
.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("<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_soil_temperature_has_exceeded_the_set_value")).append(": ").append(value).append("</p>")
|
||||||
.append("<table>")
|
.append("<table>")
|
||||||
@ -193,33 +191,30 @@ public class SendWarning {
|
|||||||
update
|
update
|
||||||
main.frmcheckpoints
|
main.frmcheckpoints
|
||||||
set
|
set
|
||||||
warn=true
|
warn_air=true
|
||||||
where uid=:uid
|
where uid=CAST(:uid AS uuid)
|
||||||
""";
|
""";
|
||||||
MapSqlParameterSource param = new MapSqlParameterSource();
|
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);
|
int rowsUpdated = jdbcTemplate.update(sql, param);
|
||||||
System.out.println("rowsUpdated = "+String.valueOf(rowsUpdated));
|
System.out.println("rowsUpdated = "+String.valueOf(rowsUpdated));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(tmp_soil!=null) {
|
if(tmp_soil!=null) {
|
||||||
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
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")) {
|
if (value < tmp_soil.getDouble("value")) {
|
||||||
String email = obj.getString("email");
|
String email = obj.getString("email");
|
||||||
if(email.equals("irigm@mail.ru") || email.equals("ivanov.i@istt.kz")){ //TODO для тестирования потом удалить
|
|
||||||
|
|
||||||
StringBuilder html = new StringBuilder(1024);
|
StringBuilder html = new StringBuilder(1024);
|
||||||
html.append("<html>")
|
html.append("<html>")
|
||||||
.append("<head>")
|
.append("<head>")
|
||||||
.append("<style>")
|
.append("<style>")
|
||||||
.append("body { font-family: Arial, sans-serif; background-color: #f4f4f4; color: #333; margin: 0; padding: 0; }")
|
.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(".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("table { border-collapse: collapse; width: 100%; margin: 20px 0; }")
|
||||||
.append("th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }")
|
.append("th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }")
|
||||||
.append("th { background-color: #f9f9f9; }")
|
.append("th { background-color: #f9f9f9; }")
|
||||||
@ -228,7 +223,6 @@ public class SendWarning {
|
|||||||
.append("</head>")
|
.append("</head>")
|
||||||
.append("<body>")
|
.append("<body>")
|
||||||
.append("<div class='container'>")
|
.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("<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_soil_temperature_has_exceeded_the_set_value")).append(": ").append(value).append("</p>")
|
||||||
.append("<table>")
|
.append("<table>")
|
||||||
@ -252,20 +246,17 @@ public class SendWarning {
|
|||||||
update
|
update
|
||||||
main.frmcheckpoints
|
main.frmcheckpoints
|
||||||
set
|
set
|
||||||
warn=true
|
warn_soil=true
|
||||||
where uid=:uid
|
where uid=CAST(:uid AS uuid)
|
||||||
""";
|
""";
|
||||||
MapSqlParameterSource param = new MapSqlParameterSource();
|
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);
|
int rowsUpdated = jdbcTemplate.update(sql, param);
|
||||||
System.out.println("rowsUpdated = "+String.valueOf(rowsUpdated));
|
System.out.println("rowsUpdated = "+String.valueOf(rowsUpdated));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} 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);
|
||||||
|
|||||||
@ -14,11 +14,6 @@ import javax.mail.internet.AddressException;
|
|||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
/**
|
|
||||||
* A utility class for sending e-mail messages
|
|
||||||
* @author www.codejava.net
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class EmailUtility {
|
public class EmailUtility {
|
||||||
|
|
||||||
public static void sendEmail(String host, String port,
|
public static void sendEmail(String host, String port,
|
||||||
@ -26,7 +21,6 @@ public class EmailUtility {
|
|||||||
String subject, String message) throws AddressException,
|
String subject, String message) throws AddressException,
|
||||||
MessagingException
|
MessagingException
|
||||||
{
|
{
|
||||||
|
|
||||||
// sets SMTP server properties
|
// sets SMTP server properties
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
|
||||||
@ -63,4 +57,5 @@ public class EmailUtility {
|
|||||||
// sends the e-mail
|
// sends the e-mail
|
||||||
Transport.send(msg);
|
Transport.send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1171,8 +1171,21 @@ new Calendar({
|
|||||||
<td style="padding: 1px; width: 158px; white-space: nowrap;" th:text="${Year}">Year</td>
|
<td style="padding: 1px; width: 158px; white-space: nowrap;" th:text="${Year}">Year</td>
|
||||||
<td style="padding: 1px;">
|
<td style="padding: 1px;">
|
||||||
<select style="width: 100%;" id="filter_ivi_year">
|
<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_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_02_04">2022 (02..04)</option>
|
||||||
<option value="2022_03_05">2022 (03..05)</option>
|
<option value="2022_03_05">2022 (03..05)</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user