Update "/api/locust/v01/AcceptJSON_KAZ"
This commit is contained in:
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>org.ccalm</groupId>
|
<groupId>org.ccalm</groupId>
|
||||||
<artifactId>main</artifactId>
|
<artifactId>main</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.3</version>
|
||||||
<name>main</name>
|
<name>main</name>
|
||||||
<description>main</description>
|
<description>main</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import java.sql.Types;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.Year;
|
import java.time.Year;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@ -133,17 +134,7 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
@RequestParam(required=false,name="skip",defaultValue = "0") Boolean skip
|
@RequestParam(required=false,name="skip",defaultValue = "0") Boolean skip
|
||||||
) {
|
) {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
int count=0;
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Connection conn = null;
|
|
||||||
try {
|
|
||||||
Class.forName("org.postgresql.Driver");
|
|
||||||
conn = DriverManager.getConnection(db_url, db_login, db_password);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalDate lastDate = null;
|
LocalDate lastDate = null;
|
||||||
String sql= """
|
String sql= """
|
||||||
select to_char(max(date), 'YYYY-MM-DD') as date from integration.days_kz
|
select to_char(max(date), 'YYYY-MM-DD') as date from integration.days_kz
|
||||||
@ -157,9 +148,9 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
lastDate = LocalDate.parse(obj.getString("date"));
|
lastDate = LocalDate.parse(obj.getString("date"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(lastDate==null)
|
if(lastDate==null) {
|
||||||
lastDate = LocalDate.parse("2025-07-01");
|
lastDate = LocalDate.parse("2025-07-16");
|
||||||
//lastDate = LocalDate.parse("2025-07-16");
|
}
|
||||||
|
|
||||||
//By number of day downloading data and write result of downloading to database, try or false, after repair need repeat download
|
//By number of day downloading data and write result of downloading to database, try or false, after repair need repeat download
|
||||||
while(lastDate.isBefore(LocalDate.now().minusDays(3))) {
|
while(lastDate.isBefore(LocalDate.now().minusDays(3))) {
|
||||||
@ -172,10 +163,11 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
|
|
||||||
StringBuilder sb = new StringBuilder(1024);
|
StringBuilder sb = new StringBuilder(1024);
|
||||||
try {
|
try {
|
||||||
//String strURL = "http://91.185.13.233:98/get_fito?start_date="+dateBegin+"&end_date="+dateEnd;
|
|
||||||
String strURL = "http://95.56.225.145:98/get_fito?start_date="+dateBegin+"&end_date="+dateEnd;
|
String strURL = "http://95.56.225.145:98/get_fito?start_date="+dateBegin+"&end_date="+dateEnd;
|
||||||
|
|
||||||
URL url = new URL(strURL);
|
URI uri = new URI(strURL);
|
||||||
|
URL url = uri.toURL();
|
||||||
HttpURLConnection hConn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection hConn = (HttpURLConnection) url.openConnection();
|
||||||
hConn.setRequestMethod("GET");
|
hConn.setRequestMethod("GET");
|
||||||
hConn.setRequestProperty("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEyMyIsInVzZXJuYW1lIjoiQ0NBTE0iLCJyb2xlIjoidXNlciIsImlhdCI6MTcwNjc4NjQ0Nn0.bypDbAZYjbQu8hWrb6MnnAZ80AbO4ZifP3inEnpbabI");
|
hConn.setRequestProperty("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEyMyIsInVzZXJuYW1lIjoiQ0NBTE0iLCJyb2xlIjoidXNlciIsImlhdCI6MTcwNjc4NjQ0Nn0.bypDbAZYjbQu8hWrb6MnnAZ80AbO4ZifP3inEnpbabI");
|
||||||
@ -195,30 +187,13 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
inputStream.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new CustomException(200, 10000, "Error download: "+e.getMessage(), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
String content = sb.toString();
|
String content = sb.toString();
|
||||||
|
|
||||||
//int year = 2025;
|
int count=0;
|
||||||
|
if (content != null || !content.isEmpty()) {
|
||||||
|
|
||||||
if (content == null || content.isEmpty()) {
|
|
||||||
System.out.println("Content is null");
|
|
||||||
} else {
|
|
||||||
System.out.println("Start");
|
|
||||||
|
|
||||||
//String sql = "delete from main.frmlocust where country_id=5 and eid=0 and extract(year from date)=" + String.valueOf(year);
|
|
||||||
//try {
|
|
||||||
// PreparedStatement stmt = conn.prepareStatement(sql);
|
|
||||||
// int cont = stmt.executeUpdate();
|
|
||||||
// System.out.println("cnt: " + String.valueOf(cont));
|
|
||||||
//} catch (SQLException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//System.out.println(content);
|
|
||||||
//Iterate over the elements of the array.
|
|
||||||
JSONObject jsonObject = new JSONObject(content);
|
JSONObject jsonObject = new JSONObject(content);
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("data");
|
JSONArray jsonArray = jsonObject.getJSONArray("data");
|
||||||
for (Object o : jsonArray) {
|
for (Object o : jsonArray) {
|
||||||
@ -228,241 +203,23 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
|
|
||||||
//I check if there is already such a record in the database, if not, I insert it, if there is, I update it
|
//I check if there is already such a record in the database, if not, I insert it, if there is, I update it
|
||||||
UpdateLocust updateLocust = new UpdateLocust(jdbcTemplate);
|
UpdateLocust updateLocust = new UpdateLocust(jdbcTemplate);
|
||||||
//if(updateLocust.update(locust))
|
if(updateLocust.update(locust)) {
|
||||||
// count++;
|
count++;
|
||||||
|
}else{
|
||||||
|
throw new CustomException(200, 10000, "Error insert or update", null, true);
|
||||||
|
}
|
||||||
System.out.println( "count = " + count );
|
System.out.println( "count = " + count );
|
||||||
|
|
||||||
/*
|
|
||||||
//I don't miss other dates
|
|
||||||
ZonedDateTime dateTime = ZonedDateTime.parse(jsonObj.getString("examination_date"), DateTimeFormatter.ISO_ZONED_DATE_TIME);
|
|
||||||
if (dateTime.getYear() != year)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sql = """
|
|
||||||
insert into main.frmlocust(
|
|
||||||
eid, --1
|
|
||||||
lat_center, --2
|
|
||||||
lon_center, --3
|
|
||||||
lat1, --4
|
|
||||||
lon1, --5
|
|
||||||
date, --6
|
|
||||||
village, --7
|
|
||||||
terrain, --8
|
|
||||||
district, --9
|
|
||||||
country_id, --10
|
|
||||||
region_id, --11
|
|
||||||
locust_type_id, --12
|
|
||||||
bio_hectare, --13
|
|
||||||
locust_populated, --14
|
|
||||||
description, --15
|
|
||||||
eggs, --16
|
|
||||||
hoppers, --17
|
|
||||||
bands, --18
|
|
||||||
adults, --19
|
|
||||||
swarms --20
|
|
||||||
)values(
|
|
||||||
?, --1 eid
|
|
||||||
?, --2 lat_center
|
|
||||||
?, --3 lon_center
|
|
||||||
?, --4 lat1
|
|
||||||
?, --5 lon1
|
|
||||||
TO_TIMESTAMP(?, 'YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"'), --6 date
|
|
||||||
LEFT(?, 100), --7 village
|
|
||||||
LEFT(?, 100), --8 terrain
|
|
||||||
LEFT(?, 100), --9 district
|
|
||||||
?, --10 country_id
|
|
||||||
?, --11 region_id
|
|
||||||
?, --12 locust_type_id
|
|
||||||
?, --13 bio_hectare
|
|
||||||
?, --14 locust_populated
|
|
||||||
?, --15 description
|
|
||||||
?, --16 eggs CheckBox
|
|
||||||
?, --17 hoppers CheckBox
|
|
||||||
?, --18 bands CheckBox
|
|
||||||
?, --19 adults CheckBox
|
|
||||||
? --20 swarms CheckBox
|
|
||||||
)""";
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
try {
|
|
||||||
stmt = conn.prepareStatement(sql);
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
model.addAttribute("PreviewTable", "Error prepare 2");
|
|
||||||
return "json";
|
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
String description = "";
|
throw new CustomException(200, 10000, "Data content kz is null", null, true);
|
||||||
description += "city: " + jsonObj.getString("city") + "\n";
|
|
||||||
description += "message_type: " + jsonObj.getString("message_type") + "\n";
|
|
||||||
if (jsonObj.has("development_stage") && !jsonObj.isNull("development_stage"))
|
|
||||||
description += "stage: " + jsonObj.getString("development_stage") + "\n";
|
|
||||||
|
|
||||||
try {
|
|
||||||
stmt.setLong(1, 0);
|
|
||||||
stmt.setDouble(2, jsonObj.getDouble("latitude"));
|
|
||||||
stmt.setDouble(3, jsonObj.getDouble("longitude"));
|
|
||||||
stmt.setDouble(4, jsonObj.getDouble("latitude"));
|
|
||||||
stmt.setDouble(5, jsonObj.getDouble("longitude"));
|
|
||||||
stmt.setString(6, jsonObj.getString("examination_date")); //2023-03-20T06:23:20.000Z
|
|
||||||
if (jsonObj.has("village") && !jsonObj.isNull("village"))
|
|
||||||
stmt.setString(7, jsonObj.getString("village"));
|
|
||||||
else
|
|
||||||
stmt.setNull(7, Types.VARCHAR);
|
|
||||||
if (jsonObj.has("farm") && !jsonObj.isNull("farm"))
|
|
||||||
stmt.setString(8, jsonObj.getString("farm"));
|
|
||||||
else
|
|
||||||
stmt.setNull(8, Types.VARCHAR);
|
|
||||||
if (jsonObj.has("district") && !jsonObj.isNull("district"))
|
|
||||||
stmt.setString(9, jsonObj.getString("district"));
|
|
||||||
else
|
|
||||||
stmt.setNull(9, Types.VARCHAR);
|
|
||||||
|
|
||||||
stmt.setInt(10, 5); //country_id
|
|
||||||
|
|
||||||
|
|
||||||
int region_id = -1;
|
|
||||||
switch (jsonObj.getString("region")) {
|
|
||||||
case "Туркестанская": //5 false -215739 1691403679 5 "Түркістан облысы (Туркестанская область)"
|
|
||||||
region_id = 5;
|
|
||||||
break;
|
|
||||||
case "Жамбылская": //4 false -215722 1691403679 5 "Жамбыл облысы (Жамбылская область)"
|
|
||||||
region_id = 4;
|
|
||||||
break;
|
|
||||||
case "Алматинская": //3 false -215718 1691403679 5 "Алматы облысы (Алматинская область)"
|
|
||||||
region_id = 3;
|
|
||||||
break;
|
|
||||||
case "Карагандинская": //2 false -215776 1691403679 5 "Қарағанды облысы (Карагандинская область)"
|
|
||||||
region_id = 2;
|
|
||||||
break;
|
|
||||||
case "Жетысу": //478 false -14312169 1691403679 5 "Жетісу облысы"
|
|
||||||
region_id = 478;
|
|
||||||
break;
|
|
||||||
case "Кызылординская": //6 false -215727 1691403679 5 "Қызылорда облысы (Кызылординская область)"
|
|
||||||
region_id = 6;
|
|
||||||
break;
|
|
||||||
case "Атырауская": //13 false -214834 1691403679 5 "Атырау облысы (Атырауская область)"
|
|
||||||
region_id = 13;
|
|
||||||
break;
|
|
||||||
case "Западно-Казахстанская": //12 false -215441 1691403679 5 "Батыс Қазақстан облысы (Западно-Казахстанская область)"
|
|
||||||
region_id = 12;
|
|
||||||
break;
|
|
||||||
case "Акмолинская": //10 false -215743 1691403679 5 "Ақмола облысы (Акмолинская область)"
|
|
||||||
region_id = 10;
|
|
||||||
break;
|
|
||||||
case "Восточно-Казахстанская": //1 false -215699 1691403679 5 "Шығыс Қазақстан облысы (Восточно-Казахстанская область)"
|
|
||||||
region_id = 1;
|
|
||||||
break;
|
|
||||||
case "Абай": //477 false -14243026 1691473439 5 "Абай облысы"
|
|
||||||
region_id = 477;
|
|
||||||
break;
|
|
||||||
case "Костанайская": //8 false -1288730 1691403679 5 "Қостанай облысы (Костанайская область)"
|
|
||||||
region_id = 8;
|
|
||||||
break;
|
|
||||||
case "Павлодарская": //11 false -215772 1691403679 5 "Павлодар облысы (Павлодарская область)"
|
|
||||||
region_id = 11;
|
|
||||||
break;
|
|
||||||
case "Северо-Казахстанская": //9 false -215760 1691403679 5 "Солтүстік Қазақстан облысы (Северо-Казахстанская область)"
|
|
||||||
region_id = 9;
|
|
||||||
break;
|
|
||||||
case "Актюбинская": //7 false -215683 1691403679 5 "Ақтөбе облысы (Актюбинская область)"
|
|
||||||
region_id = 7;
|
|
||||||
break;
|
|
||||||
case "Мангистауская": //14 false -215686 1691403679 5 "Маңғыстау облысы (Мангистауская область)"
|
|
||||||
region_id = 14;
|
|
||||||
break;
|
|
||||||
case "Улытау": //479 false -14312737 1691462768 5 "Ұлытау облысы"
|
|
||||||
region_id = 14;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new CustomException(200, 10000, "Not find region: " + jsonObj.getString("region"), null, true);
|
|
||||||
}
|
}
|
||||||
if (region_id == -1)
|
//Save last download date
|
||||||
stmt.setInt(11, region_id); //region_id
|
sql = "INSERT INTO integration.days_kz(date, count) VALUES (:date, :count)";
|
||||||
else
|
parameters = new MapSqlParameterSource();
|
||||||
stmt.setNull(11, Types.INTEGER);
|
parameters.addValue("date", java.sql.Date.valueOf(lastDate));
|
||||||
|
parameters.addValue("count", count);
|
||||||
//Вид саранчи
|
jdbcTemplate.update(sql, parameters);
|
||||||
int locust_id = -1;
|
|
||||||
switch (jsonObj.getString("grasshopper_type")) {
|
|
||||||
case "Мароккская саранча":
|
|
||||||
locust_id = 2;
|
|
||||||
break;
|
|
||||||
case "Итальянский прус":
|
|
||||||
locust_id = 1;
|
|
||||||
break;
|
|
||||||
case "Азиатская саранча":
|
|
||||||
locust_id = 3;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new CustomException(200, 10000, "Not grasshopper_type: " + jsonObj.getString("grasshopper_type"), null, true);
|
|
||||||
}
|
}
|
||||||
stmt.setInt(12, locust_id); //locust_id
|
|
||||||
|
|
||||||
//Обследованно
|
|
||||||
if (jsonObj.has("examination_area") && !jsonObj.isNull("examination_area"))
|
|
||||||
stmt.setDouble(13, Double.parseDouble(jsonObj.get("examination_area").toString()));
|
|
||||||
else
|
|
||||||
stmt.setNull(13, Types.DOUBLE);
|
|
||||||
|
|
||||||
//Площадь заселения
|
|
||||||
if (jsonObj.has("settlement_area") && !jsonObj.isNull("settlement_area"))
|
|
||||||
stmt.setDouble(14, Double.parseDouble(jsonObj.get("settlement_area").toString()));
|
|
||||||
else
|
|
||||||
stmt.setNull(14, Types.DOUBLE);
|
|
||||||
|
|
||||||
//Прочее описание
|
|
||||||
stmt.setString(15, description); //description
|
|
||||||
|
|
||||||
boolean eggs = false; // Яйца
|
|
||||||
boolean hoppers = false; // Личинки
|
|
||||||
boolean bands = false; // Кулиги
|
|
||||||
boolean adults = false; // Имаго
|
|
||||||
boolean swarms = false; // Стаи
|
|
||||||
if (jsonObj.has("development_stage") && !jsonObj.isNull("development_stage")) {
|
|
||||||
if (jsonObj.getString("development_stage").equals("Яйца")) eggs = true;
|
|
||||||
if (jsonObj.getString("development_stage").equals("Личинки") || jsonObj.getString("development_stage").equals("Заселенность личинками") || jsonObj.getString("development_stage").equals("Личинка"))
|
|
||||||
hoppers = true;
|
|
||||||
if (jsonObj.getString("development_stage").equals("Кулиги")) bands = true;
|
|
||||||
if (jsonObj.getString("development_stage").equals("Имаго")) adults = true;
|
|
||||||
if (jsonObj.getString("development_stage").equals("Стаи")) swarms = true;
|
|
||||||
}
|
|
||||||
if (eggs)
|
|
||||||
stmt.setBoolean(16, true);
|
|
||||||
else
|
|
||||||
stmt.setNull(16, Types.BOOLEAN);
|
|
||||||
if (hoppers)
|
|
||||||
stmt.setBoolean(17, true);
|
|
||||||
else
|
|
||||||
stmt.setNull(17, Types.BOOLEAN);
|
|
||||||
if (bands)
|
|
||||||
stmt.setBoolean(18, true);
|
|
||||||
else
|
|
||||||
stmt.setNull(18, Types.BOOLEAN);
|
|
||||||
if (adults)
|
|
||||||
stmt.setBoolean(19, true);
|
|
||||||
else
|
|
||||||
stmt.setNull(19, Types.BOOLEAN);
|
|
||||||
if (swarms)
|
|
||||||
stmt.setBoolean(20, true);
|
|
||||||
else
|
|
||||||
stmt.setNull(20, Types.BOOLEAN);
|
|
||||||
|
|
||||||
if (region_id != -1) {
|
|
||||||
stmt.execute();
|
|
||||||
} else {
|
|
||||||
System.out.println("region: " + jsonObj.getString("region"));
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
model.addAttribute("PreviewTable", "Error set data");
|
|
||||||
return "json";
|
|
||||||
}
|
|
||||||
cnt++;*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
@ -483,65 +240,24 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
|
|
||||||
result.company_uid = "f52a99a6-db5a-4d15-b29c-5a7989d548eb"; //Company: "Kazakhstan Locust"
|
result.company_uid = "f52a99a6-db5a-4d15-b29c-5a7989d548eb"; //Company: "Kazakhstan Locust"
|
||||||
//result.uid = obj.getString("uuid");
|
//result.uid = obj.getString("uuid");
|
||||||
//result.eid = String.valueOf(obj.getInt("id")); //Internal identifier in the Uzbek database
|
result.eid = String.valueOf(obj.getLong("OBJECTID"));
|
||||||
|
|
||||||
//result.seq = obj.getLong("seq")*1000;
|
//result.seq = obj.getLong("seq")*1000;
|
||||||
result.country_id = "5"; //Kazakhstan
|
result.country_id = "5"; //Kazakhstan
|
||||||
result.country_uid = "3c7df90e-9632-4e71-8f36-c184751216df"; //Kazakhstan
|
result.country_uid = "3c7df90e-9632-4e71-8f36-c184751216df"; //Kazakhstan
|
||||||
|
|
||||||
/*
|
|
||||||
sql = """
|
|
||||||
insert into main.frmlocust(
|
|
||||||
eid, --1
|
|
||||||
lat_center, --2
|
|
||||||
lon_center, --3
|
|
||||||
lat1, --4
|
|
||||||
lon1, --5
|
|
||||||
date, --6
|
|
||||||
village, --7
|
|
||||||
terrain, --8
|
|
||||||
district, --9
|
|
||||||
country_id, --10
|
|
||||||
region_id, --11
|
|
||||||
locust_type_id, --12
|
|
||||||
bio_hectare, --13
|
|
||||||
locust_populated, --14
|
|
||||||
description, --15
|
|
||||||
eggs, --16
|
|
||||||
hoppers, --17
|
|
||||||
bands, --18
|
|
||||||
adults, --19
|
|
||||||
swarms --20
|
|
||||||
)values(
|
|
||||||
?, --1 eid
|
|
||||||
?, --2 lat_center
|
|
||||||
?, --3 lon_center
|
|
||||||
?, --4 lat1
|
|
||||||
?, --5 lon1
|
|
||||||
TO_TIMESTAMP(?, 'YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"'), --6 date
|
|
||||||
LEFT(?, 100), --7 village
|
|
||||||
LEFT(?, 100), --8 terrain
|
|
||||||
LEFT(?, 100), --9 district
|
|
||||||
?, --10 country_id
|
|
||||||
?, --11 region_id
|
|
||||||
?, --12 locust_type_id
|
|
||||||
?, --13 bio_hectare
|
|
||||||
?, --14 locust_populated
|
|
||||||
?, --15 description
|
|
||||||
?, --16 eggs CheckBox
|
|
||||||
?, --17 hoppers CheckBox
|
|
||||||
?, --18 bands CheckBox
|
|
||||||
?, --19 adults CheckBox
|
|
||||||
? --20 swarms CheckBox
|
|
||||||
)""";
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
result.eid = "0";
|
|
||||||
result.lat_center = String.valueOf(obj.getDouble("latitude"));
|
result.lat_center = String.valueOf(obj.getDouble("latitude"));
|
||||||
result.lon_center = String.valueOf(obj.getDouble("longitude"));
|
result.lon_center = String.valueOf(obj.getDouble("longitude"));
|
||||||
result.date = obj.getString("examination_date"); //2023-03-20T06:23:20.000Z
|
|
||||||
|
try{
|
||||||
|
String dateStr = obj.getString("examination_date").replace("Z", "");
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||||
|
LocalDateTime dateTime = LocalDateTime.parse(dateStr, formatter);
|
||||||
|
result.date = java.sql.Timestamp.valueOf(dateTime);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new CustomException(200, 10000, "Date error: " + obj.optString("examination_date","null"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (obj.has("village") && !obj.isNull("village"))
|
if (obj.has("village") && !obj.isNull("village"))
|
||||||
result.village = obj.getString("village");
|
result.village = obj.getString("village");
|
||||||
if (obj.has("farm") && !obj.isNull("farm"))
|
if (obj.has("farm") && !obj.isNull("farm"))
|
||||||
@ -551,105 +267,76 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
|
|
||||||
if(!obj.isNull("region") && !obj.optString("region","").isBlank()) {
|
if(!obj.isNull("region") && !obj.optString("region","").isBlank()) {
|
||||||
switch (obj.optString("region",null).trim()) {
|
switch (obj.optString("region",null).trim()) {
|
||||||
|
case "Акмолинская":
|
||||||
|
result.region_id = "10";
|
||||||
|
result.region_uid = "3a3deedc-45ef-4fe5-a77a-17092f11b55e";
|
||||||
case "Туркестанская":
|
case "Туркестанская":
|
||||||
result.region_id = "5";
|
result.region_id = "5";
|
||||||
//result.region_uid = "8f4f586f-6159-4fbf-a627-2c8d637abb5e";
|
result.region_uid = "d7da7b40-dad8-450d-b455-8f39f3c9e824";
|
||||||
break;
|
break;
|
||||||
case "Жамбылская":
|
case "Жамбылская":
|
||||||
result.region_id = "4";
|
result.region_id = "4";
|
||||||
//result.region_uid = "2a6adb56-19a7-4f28-9a00-87559db91db9";
|
result.region_uid = "1d7c0ab2-62d2-4645-be90-9675c5cc7d3b";
|
||||||
break;
|
break;
|
||||||
case "Алматинская":
|
case "Алматинская":
|
||||||
result.region_id = "3";
|
result.region_id = "3";
|
||||||
//result.region_uid = "2a6adb56-19a7-4f28-9a00-87559db91db9";
|
result.region_uid = "ffcb6886-531a-4559-af6c-902a3f3dbcca";
|
||||||
break;
|
break;
|
||||||
case "Карагандинская":
|
case "Карагандинская":
|
||||||
result.region_id = "2";
|
result.region_id = "2";
|
||||||
//result.region_uid = "2a6adb56-19a7-4f28-9a00-87559db91db9";
|
result.region_uid = "f6cc2454-f78e-48d4-aa91-d36aa6873f07";
|
||||||
break;
|
break;
|
||||||
case "Жетысу":
|
case "Жетысу":
|
||||||
result.region_id = "478";
|
result.region_id = "478";
|
||||||
//result.region_uid = "2a6adb56-19a7-4f28-9a00-87559db91db9";
|
result.region_uid = "327f5e9c-91eb-477c-ba02-0a1e1e49ebc6";
|
||||||
break;
|
|
||||||
case "Кызылординская":
|
|
||||||
result.region_id = "478";
|
|
||||||
//result.region_uid = "2a6adb56-19a7-4f28-9a00-87559db91db9";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
System.out.println(obj.optString("region",null));
|
|
||||||
throw new CustomException(200, 10000, "Not find region by region: " + obj.optString("region",null), null, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!obj.isNull("region") && !obj.optString("region","").isBlank()) {
|
|
||||||
switch (obj.optString("region",null).trim()) {
|
|
||||||
case "Туркестанская":
|
|
||||||
result.region_id = "5";
|
|
||||||
//result.region_uid = "";
|
|
||||||
break;
|
|
||||||
case "Жамбылская":
|
|
||||||
result.region_id = "4";
|
|
||||||
//result.region_uid = "";
|
|
||||||
break;
|
|
||||||
case "Алматинская":
|
|
||||||
result.region_id = "3";
|
|
||||||
//result.region_uid = "";
|
|
||||||
break;
|
|
||||||
case "Карагандинская":
|
|
||||||
result.region_id = "2";
|
|
||||||
//result.region_uid = "";
|
|
||||||
break;
|
|
||||||
case "Жетысу":
|
|
||||||
result.region_id = "478";
|
|
||||||
//result.region_uid = "";
|
|
||||||
break;
|
break;
|
||||||
case "Кызылординская":
|
case "Кызылординская":
|
||||||
result.region_id = "6";
|
result.region_id = "6";
|
||||||
//result.region_uid = "";
|
result.region_uid = "54caa739-fa8b-4196-a64c-0df12bfb60bc";
|
||||||
break;
|
break;
|
||||||
case "Атырауская":
|
case "Атырауская":
|
||||||
result.region_id = "13";
|
result.region_id = "13";
|
||||||
//result.region_uid = "";
|
result.region_uid = "51f7f494-a700-42f3-8006-4233655bf6a8";
|
||||||
break;
|
break;
|
||||||
case "Западно-Казахстанская":
|
case "Западно-Казахстанская":
|
||||||
result.region_id = "12";
|
result.region_id = "12";
|
||||||
//result.region_uid = "";
|
result.region_uid = "b87f6741-e01a-45fc-a9da-2b8f9f0aad97";
|
||||||
break;
|
|
||||||
case "Акмолинская":
|
|
||||||
result.region_id = "10";
|
|
||||||
//result.region_uid = "";
|
|
||||||
break;
|
break;
|
||||||
case "Восточно-Казахстанская":
|
case "Восточно-Казахстанская":
|
||||||
result.region_id = "1";
|
result.region_id = "1";
|
||||||
//result.region_uid = "";
|
result.region_uid = "73d12ffe-55f9-4294-bcb4-0ee78f1875a5";
|
||||||
break;
|
break;
|
||||||
case "Абай":
|
case "Абай":
|
||||||
result.region_id = "477";
|
result.region_id = "477";
|
||||||
//result.region_uid = "";
|
result.region_uid = "992ce0b6-85e9-406a-a031-a23b62f167ea";
|
||||||
break;
|
break;
|
||||||
case "Костанайская":
|
case "Костанайская":
|
||||||
result.region_id = "8";
|
result.region_id = "8";
|
||||||
//result.region_uid = "";
|
result.region_uid = "1b9299a2-43a8-4a27-a0f0-ab36b33b8d5c";
|
||||||
break;
|
break;
|
||||||
case "Павлодарская":
|
case "Павлодарская":
|
||||||
result.region_id = "11";
|
result.region_id = "11";
|
||||||
//result.region_uid = "";
|
result.region_uid = "c7894755-1ac6-4fbe-8d60-af9b0c3ec3a5";
|
||||||
break;
|
break;
|
||||||
case "Северо-Казахстанская":
|
case "Северо-Казахстанская":
|
||||||
result.region_id = "9";
|
result.region_id = "9";
|
||||||
//result.region_uid = "";
|
result.region_uid = "5d9e75b4-b7d2-4af8-9aa2-14b5fa38842e";
|
||||||
break;
|
break;
|
||||||
case "Актюбинская":
|
case "Актюбинская":
|
||||||
result.region_id = "7";
|
result.region_id = "7";
|
||||||
//result.region_uid = "";
|
result.region_uid = "9e6889d3-aa2f-47a0-a0b9-90973e3971c6";
|
||||||
break;
|
break;
|
||||||
case "Мангистауская":
|
case "Мангистауская":
|
||||||
result.region_id = "14";
|
result.region_id = "14";
|
||||||
//result.region_uid = "";
|
result.region_uid = "87a47fe7-3cdf-4d96-924d-5d4888972a82";
|
||||||
break;
|
break;
|
||||||
case "Улытау":
|
case "Улытау":
|
||||||
result.region_id = "479";
|
result.region_id = "479";
|
||||||
//result.region_uid = "";
|
result.region_uid = "76468ad3-5f73-4c33-bf7d-ce2ff1006fdd";
|
||||||
|
break;
|
||||||
|
case "-----------":
|
||||||
|
result.region_id = null;
|
||||||
|
result.region_uid = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println(obj.optString("region",null));
|
System.out.println(obj.optString("region",null));
|
||||||
@ -657,20 +344,21 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Вид саранчи
|
//Вид саранчи
|
||||||
if(!obj.isNull("region") && !obj.optString("region","").isBlank()) {
|
if(!obj.isNull("grasshopper_type") && !obj.optString("grasshopper_type","").isBlank()) {
|
||||||
switch (obj.getString("grasshopper_type")) {
|
switch (obj.getString("grasshopper_type")) {
|
||||||
case "Мароккская саранча":
|
case "Мароккская саранча":
|
||||||
result.locust_type_id = "2";
|
result.locust_type_id = "2";
|
||||||
//result.locust_type_uid = "";
|
result.locust_type_uid = "8dd9e74f-d7ba-492a-8c75-7aed4f0847c6";
|
||||||
break;
|
break;
|
||||||
case "Итальянский прус":
|
case "Итальянский прус":
|
||||||
result.locust_type_id = "1";
|
result.locust_type_id = "1";
|
||||||
//result.locust_type_uid = "";
|
result.locust_type_uid = "688e484b-babd-4a48-b318-be85e40682b0";
|
||||||
break;
|
break;
|
||||||
case "Азиатская саранча":
|
case "Азиатская саранча":
|
||||||
result.locust_type_id = "3";
|
result.locust_type_id = "3";
|
||||||
//result.locust_type_uid = "";
|
result.locust_type_uid = "d61a5325-e8c7-497a-9cff-7ee4c4e1e37d";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println(obj.optString("grasshopper_type",null));
|
System.out.println(obj.optString("grasshopper_type",null));
|
||||||
@ -680,54 +368,53 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
|
|
||||||
//Обследованно
|
//Обследованно
|
||||||
if (obj.has("examination_area") && !obj.isNull("examination_area"))
|
if (obj.has("examination_area") && !obj.isNull("examination_area"))
|
||||||
stmt.setDouble(13, Double.parseDouble(obj.get("examination_area").toString()));
|
result.bio_hectare = obj.get("examination_area").toString();
|
||||||
else
|
|
||||||
stmt.setNull(13, Types.DOUBLE);
|
|
||||||
|
|
||||||
//Площадь заселения
|
//Площадь заселения
|
||||||
if (obj.has("settlement_area") && !obj.isNull("settlement_area"))
|
if (obj.has("settlement_area") && !obj.isNull("settlement_area"))
|
||||||
stmt.setDouble(14, Double.parseDouble(obj.get("settlement_area").toString()));
|
result.locust_populated = obj.get("settlement_area").toString();
|
||||||
else
|
|
||||||
stmt.setNull(14, Types.DOUBLE);
|
|
||||||
|
|
||||||
boolean eggs = false; // Яйца
|
if(!obj.isNull("development_stage") && !obj.optString("development_stage","").isBlank()) {
|
||||||
boolean hoppers = false; // Личинки
|
switch (obj.getString("development_stage")) {
|
||||||
boolean bands = false; // Кулиги
|
case "Яйца":
|
||||||
boolean adults = false; // Имаго
|
|
||||||
boolean swarms = false; // Стаи
|
|
||||||
if (obj.has("development_stage") && !obj.isNull("development_stage")) {
|
|
||||||
if (obj.getString("development_stage").equals("Яйца")) eggs = true;
|
|
||||||
if (obj.getString("development_stage").equals("Личинки") || obj.getString("development_stage").equals("Заселенность личинками") || obj.getString("development_stage").equals("Личинка"))
|
|
||||||
hoppers = true;
|
|
||||||
if (obj.getString("development_stage").equals("Кулиги")) bands = true;
|
|
||||||
if (obj.getString("development_stage").equals("Имаго")) adults = true;
|
|
||||||
if (obj.getString("development_stage").equals("Стаи")) swarms = true;
|
|
||||||
}
|
|
||||||
if (eggs)
|
|
||||||
result.eggs = "true";
|
result.eggs = "true";
|
||||||
//stmt.setBoolean(16, true);
|
break;
|
||||||
|
case "Личинки","Заселенность личинками","Личинка","личинки","личинка","2-5","дернасил","дернәсіл","дернасіл","дернәсілдері":
|
||||||
if (hoppers)
|
result.larva = "true";
|
||||||
result.hoppers = "true";
|
break;
|
||||||
//stmt.setBoolean(17, true);
|
case "Кулиги":
|
||||||
|
result.kuliguli = "true";
|
||||||
if (bands)
|
break;
|
||||||
result.bands = "true";
|
case "Имаго":
|
||||||
//stmt.setBoolean(18, true);
|
result.imago = "true";
|
||||||
|
break;
|
||||||
if (adults)
|
case "спаривание","шағылысу":
|
||||||
result.adults = "true";
|
result.imago = "true";
|
||||||
//stmt.setBoolean(19, true);
|
result.imago_copulation="true";
|
||||||
|
break;
|
||||||
if (swarms)
|
case "жұмыртқа салу","тұқым": //Кладка яиц
|
||||||
|
result.imago = "true";
|
||||||
|
result.imago_laying="true";
|
||||||
|
break;
|
||||||
|
case "спаривание и яйцекладка", "Спаривания и яйцекладки":
|
||||||
|
result.imago = "true";
|
||||||
|
result.imago_copulation="true";
|
||||||
|
result.imago_laying="true";
|
||||||
|
break;
|
||||||
|
case "Стаи","Ұшу шағылысу":
|
||||||
result.swarms = "true";
|
result.swarms = "true";
|
||||||
//stmt.setBoolean(20, true);
|
break;
|
||||||
|
//default: закомментировал так как люди понаписали ерунды....
|
||||||
|
// System.out.println(obj.optString("development_stage",null));
|
||||||
|
// throw new CustomException(200, 10000, "Not find development_stage: " + obj.optString("development_stage",null), null, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result.description = "";
|
result.description = "";
|
||||||
result.description += "city: " + obj.getString("city") + "\n";
|
result.description += "city: " + obj.getString("city") + "\n";
|
||||||
|
if(!obj.isNull("message_type")) {
|
||||||
result.description += "message_type: " + obj.getString("message_type") + "\n";
|
result.description += "message_type: " + obj.getString("message_type") + "\n";
|
||||||
|
}
|
||||||
if (obj.has("development_stage") && !obj.isNull("development_stage"))
|
if (obj.has("development_stage") && !obj.isNull("development_stage"))
|
||||||
result.description += "stage: " + obj.getString("development_stage") + "\n";
|
result.description += "stage: " + obj.getString("development_stage") + "\n";
|
||||||
|
|
||||||
@ -735,7 +422,6 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Пример запроса: http://127.0.0.1:8081/AcceptJSON но в теле нужно поменять строку "Year y = Year.of(2024);" а также номер дня
|
* Пример запроса: http://127.0.0.1:8081/AcceptJSON но в теле нужно поменять строку "Year y = Year.of(2024);" а также номер дня
|
||||||
* @param user
|
* @param user
|
||||||
@ -873,7 +559,13 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
JSONObject jsonObj = (JSONObject) o;
|
JSONObject jsonObj = (JSONObject) o;
|
||||||
FrmLocustModel locust = new FrmLocustModel();
|
FrmLocustModel locust = new FrmLocustModel();
|
||||||
|
|
||||||
locust.date = jsonObj.getString("date");
|
try{
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm");
|
||||||
|
LocalDateTime dateTime = LocalDateTime.parse(jsonObj.getString("date"), formatter);
|
||||||
|
locust.date = java.sql.Timestamp.valueOf(dateTime);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new CustomException(200, 10000, "Date error: " + jsonObj.optString("date","null"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
String regionName="";
|
String regionName="";
|
||||||
if (!jsonObj.isNull("regionName"))
|
if (!jsonObj.isNull("regionName"))
|
||||||
@ -1203,7 +895,7 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
stmt.setInt(5, Integer.parseInt(locust.region_id)); //region_id
|
stmt.setInt(5, Integer.parseInt(locust.region_id)); //region_id
|
||||||
stmt.setString(6, locust.district); //Пишу в поле "area"
|
stmt.setString(6, locust.district); //Пишу в поле "area"
|
||||||
stmt.setString(7, null);
|
stmt.setString(7, null);
|
||||||
stmt.setString(8, locust.date); //27.04.2020 09:17
|
stmt.setTimestamp(8, locust.date); //27.04.2020 09:17
|
||||||
stmt.setString(9, locust.description);
|
stmt.setString(9, locust.description);
|
||||||
stmt.setString(10, locust.drawPolygon);
|
stmt.setString(10, locust.drawPolygon);
|
||||||
|
|
||||||
@ -1528,7 +1220,7 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
stmt.setInt(5, Integer.parseInt(locust.region_id));
|
stmt.setInt(5, Integer.parseInt(locust.region_id));
|
||||||
stmt.setString(6, locust.district); //Пишу в поле "area"
|
stmt.setString(6, locust.district); //Пишу в поле "area"
|
||||||
stmt.setString(7, null);
|
stmt.setString(7, null);
|
||||||
stmt.setString(8, locust.date); //27.04.2020 09:17
|
stmt.setTimestamp(8, locust.date);
|
||||||
stmt.setString(9, locust.description);
|
stmt.setString(9, locust.description);
|
||||||
stmt.setString(10, locust.drawPolygon);
|
stmt.setString(10, locust.drawPolygon);
|
||||||
stmt.setInt(11, Integer.parseInt(locust.locust_type_id));
|
stmt.setInt(11, Integer.parseInt(locust.locust_type_id));
|
||||||
@ -1800,7 +1492,6 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
|
|
||||||
int count=0;
|
int count=0;
|
||||||
if(content!=null && !content.isEmpty()) {
|
if(content!=null && !content.isEmpty()) {
|
||||||
|
|
||||||
JSONArray jsonArray = new JSONArray(content);
|
JSONArray jsonArray = new JSONArray(content);
|
||||||
for (Object o : jsonArray) {
|
for (Object o : jsonArray) {
|
||||||
JSONObject jsonObj = (JSONObject) o;
|
JSONObject jsonObj = (JSONObject) o;
|
||||||
@ -1814,11 +1505,13 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
|
|
||||||
System.out.println( "count = " + count );
|
System.out.println( "count = " + count );
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
throw new CustomException(200, 10000, "Data content uz is null", null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save last download date
|
//Save last download date
|
||||||
String insertSql = """
|
String insertSql = """
|
||||||
insert into integration.days_uz (date, count) values (:date, :count)
|
insert into integration.days_uz(date, count) values (:date, :count)
|
||||||
""";
|
""";
|
||||||
MapSqlParameterSource insertParams = new MapSqlParameterSource();
|
MapSqlParameterSource insertParams = new MapSqlParameterSource();
|
||||||
insertParams.addValue("date", lastDate, Types.DATE);
|
insertParams.addValue("date", lastDate, Types.DATE);
|
||||||
@ -1951,7 +1644,14 @@ public class AcceptJSON implements ServletContextAware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.district = obj.optString("town_name",null);
|
result.district = obj.optString("town_name",null);
|
||||||
result.date = obj.optString("date",null);
|
|
||||||
|
try{
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||||
|
LocalDateTime dateTime = LocalDateTime.parse(obj.getString("date"), formatter);
|
||||||
|
result.date = java.sql.Timestamp.valueOf(dateTime);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new CustomException(200, 10000, "Date error: " + obj.optString("date","null"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
result.bio_hectare = obj.optString("surveyed_area",null);
|
result.bio_hectare = obj.optString("surveyed_area",null);
|
||||||
if (!obj.isNull("point")) {
|
if (!obj.isNull("point")) {
|
||||||
|
|||||||
@ -36,14 +36,18 @@ public class UpdateLocust {
|
|||||||
boolean exists=false; //Is there a record.
|
boolean exists=false; //Is there a record.
|
||||||
MapSqlParameterSource parameters;
|
MapSqlParameterSource parameters;
|
||||||
|
|
||||||
//Если данные пришли из внешнего источника то проверяем по ID компании и eid
|
//Если данные пришли из внешнего источника то выбираю uid по eid
|
||||||
if(locust.eid!=null && locust.uid==null) {
|
if(locust.eid!=null && locust.uid==null) {
|
||||||
|
|
||||||
|
int year = locust.date.toLocalDateTime().getYear();
|
||||||
|
|
||||||
sql = """
|
sql = """
|
||||||
select uid from main.frmlocust where eid=:eid and company_uid=CAST(:company_uid AS uuid)
|
select uid from main.frmlocust where eid=:eid and company_uid=CAST(:company_uid AS uuid) and EXTRACT(YEAR FROM date)=:year
|
||||||
""";
|
""";
|
||||||
parameters = new MapSqlParameterSource();
|
parameters = new MapSqlParameterSource();
|
||||||
parameters.addValue("eid", locust.eid, Types.BIGINT);
|
parameters.addValue("eid", locust.eid, Types.BIGINT);
|
||||||
parameters.addValue("company_uid", locust.company_uid, Types.VARCHAR);
|
parameters.addValue("company_uid", locust.company_uid, Types.VARCHAR);
|
||||||
|
parameters.addValue("year", year, Types.INTEGER);
|
||||||
List<String> ret = jdbcTemplate.query(sql, parameters, new DBTools.JsonRowMapper());
|
List<String> ret = jdbcTemplate.query(sql, parameters, new DBTools.JsonRowMapper());
|
||||||
for (String s : ret) {
|
for (String s : ret) {
|
||||||
JSONObject obj = new JSONObject(s);
|
JSONObject obj = new JSONObject(s);
|
||||||
@ -68,6 +72,7 @@ public class UpdateLocust {
|
|||||||
{
|
{
|
||||||
sql= """
|
sql= """
|
||||||
update main.frmlocust set
|
update main.frmlocust set
|
||||||
|
eid=:eid,
|
||||||
changed = false,
|
changed = false,
|
||||||
company_uid=CAST(:company_uid AS uuid),
|
company_uid=CAST(:company_uid AS uuid),
|
||||||
user_id=:user_id,
|
user_id=:user_id,
|
||||||
@ -140,6 +145,7 @@ public class UpdateLocust {
|
|||||||
}else{
|
}else{
|
||||||
sql="""
|
sql="""
|
||||||
insert into main.frmlocust(
|
insert into main.frmlocust(
|
||||||
|
eid,
|
||||||
changed,
|
changed,
|
||||||
company_uid,
|
company_uid,
|
||||||
user_id,
|
user_id,
|
||||||
@ -209,6 +215,7 @@ public class UpdateLocust {
|
|||||||
test,
|
test,
|
||||||
uid
|
uid
|
||||||
)values(
|
)values(
|
||||||
|
:eid,
|
||||||
false,
|
false,
|
||||||
CAST(:company_uid AS uuid),
|
CAST(:company_uid AS uuid),
|
||||||
:user_id,
|
:user_id,
|
||||||
@ -276,12 +283,13 @@ public class UpdateLocust {
|
|||||||
:description,
|
:description,
|
||||||
ST_SetSRID(ST_GeomFromGeoJSON(:geom),4326),
|
ST_SetSRID(ST_GeomFromGeoJSON(:geom),4326),
|
||||||
:test,
|
:test,
|
||||||
main.strtouuid(:uid)
|
COALESCE(main.strtouuid(:uid),gen_random_uuid())
|
||||||
)
|
)
|
||||||
""";
|
""";
|
||||||
}
|
}
|
||||||
parameters = new MapSqlParameterSource();
|
parameters = new MapSqlParameterSource();
|
||||||
parameters.addValue("uid", locust.uid, Types.VARCHAR);
|
parameters.addValue("uid", locust.uid, Types.VARCHAR);
|
||||||
|
if(locust.eid==null) parameters.addValue("eid", null, Types.INTEGER); else parameters.addValue("eid", Integer.parseInt(locust.eid), Types.INTEGER);
|
||||||
parameters.addValue("company_uid", locust.company_uid, Types.VARCHAR);
|
parameters.addValue("company_uid", locust.company_uid, Types.VARCHAR);
|
||||||
|
|
||||||
|
|
||||||
@ -310,22 +318,7 @@ public class UpdateLocust {
|
|||||||
parameters.addValue("date", null, Types.DATE);
|
parameters.addValue("date", null, Types.DATE);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
if(locust.date.indexOf("-")==-1) //If old date format in UNIX time
|
parameters.addValue("date", locust.date, Types.TIMESTAMP);
|
||||||
{
|
|
||||||
long uDate=Long.parseLong(locust.date)+1;
|
|
||||||
java.sql.Timestamp timestamp=new java.sql.Timestamp((long)uDate*1000);
|
|
||||||
parameters.addValue("date", timestamp, Types.TIMESTAMP);
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; // ISO 8601 (2025-02-12T14:17:43)
|
|
||||||
LocalDateTime dateTime = LocalDateTime.parse(locust.date, formatter);
|
|
||||||
java.sql.Timestamp timestamp = java.sql.Timestamp.valueOf(dateTime);
|
|
||||||
parameters.addValue("date", timestamp, Types.TIMESTAMP);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error(ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters.addValue("timezone", locust.timezone, Types.VARCHAR);
|
parameters.addValue("timezone", locust.timezone, Types.VARCHAR);
|
||||||
@ -436,5 +429,4 @@ public class UpdateLocust {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,10 @@ public class FrmLocustModel {
|
|||||||
public String locust_type_uid; //Locust species (Вид саранчи)
|
public String locust_type_uid; //Locust species (Вид саранчи)
|
||||||
public String locust_populated; //Area infested (ha)
|
public String locust_populated; //Area infested (ha)
|
||||||
|
|
||||||
|
|
||||||
|
public String bio_hectare=null; //Обследованная площадь
|
||||||
|
public String bio_biotope_id=null; //Тип биотопа
|
||||||
|
public String bio_biotope_uid=null; //Тип биотопа
|
||||||
public String bio_temperature; //air temperature
|
public String bio_temperature; //air temperature
|
||||||
public String bio_wind; //Ветер (м/с)
|
public String bio_wind; //Ветер (м/с)
|
||||||
public String bio_greenery_id; //растительность
|
public String bio_greenery_id; //растительность
|
||||||
@ -51,18 +55,31 @@ public class FrmLocustModel {
|
|||||||
public String bio_greenery_cover_id; //Густота растительного покрова
|
public String bio_greenery_cover_id; //Густота растительного покрова
|
||||||
public String bio_greenery_cover_uid; //Густота растительного покрова
|
public String bio_greenery_cover_uid; //Густота растительного покрова
|
||||||
|
|
||||||
|
|
||||||
public String phase=null; //Фаза саранчи
|
public String phase=null; //Фаза саранчи
|
||||||
public String locust_have; //id Фазы саранчи
|
public String locust_have; //id Фазы саранчи
|
||||||
public String evp; //ЭФП
|
public String evp; //ЭФП
|
||||||
public String drawPolygon="null"; //Область обследования GeoGSON
|
public String drawPolygon="null"; //Область обследования GeoGSON
|
||||||
public String size; //Заселённая площадь (polygonArea Площадь контура зоны распространения, в случае если специалист указал его)
|
public String size; //Заселённая площадь (polygonArea Площадь контура зоны распространения, в случае если специалист указал его)
|
||||||
public String date; //Дата
|
//public String date; //Дата
|
||||||
|
public java.sql.Timestamp date; //Дата
|
||||||
public String timezone;
|
public String timezone;
|
||||||
|
|
||||||
public String description="";
|
public String description="";
|
||||||
public String geom;
|
public String geom;
|
||||||
|
|
||||||
//Hopper
|
//Eggs
|
||||||
|
public String eggs = null; // For CheckBox
|
||||||
|
public String eggs_capsules_area = null; //Egg-bed (surface in ha)
|
||||||
|
public String eggs_capsules_density = null; //Плотность яиц
|
||||||
|
public String eggs_capsules_density_to = null; //Egg-pods (density) to
|
||||||
|
public String eggs_capsules = null; //Eggs (average)
|
||||||
|
public String eggs_live = null; //Eggs (viable)
|
||||||
|
public String eggs_enemies_id = null; //Natural enemies present
|
||||||
|
public String eggs_enemies_uid = null; //Natural enemies present
|
||||||
|
//public String eggs_enemies = null; //not using TODO delete field from database
|
||||||
|
|
||||||
|
//Hopper (личинки разряженные)
|
||||||
public String larva = null;
|
public String larva = null;
|
||||||
public String larva_born = null; //Hatching character varying(255) COLLATE pg_catalog."default" DEFAULT NULL::character varying,
|
public String larva_born = null; //Hatching character varying(255) COLLATE pg_catalog."default" DEFAULT NULL::character varying,
|
||||||
public String larva_born_id = null; // integer,
|
public String larva_born_id = null; // integer,
|
||||||
@ -76,19 +93,8 @@ public class FrmLocustModel {
|
|||||||
public String larva_density = null; //Hopper density numeric, (Плотность личинок)
|
public String larva_density = null; //Hopper density numeric, (Плотность личинок)
|
||||||
public String larva_density_to = null; //Hopper density to numeric,
|
public String larva_density_to = null; //Hopper density to numeric,
|
||||||
|
|
||||||
//Eggs
|
|
||||||
public String eggs = null; // For CheckBox
|
|
||||||
public String eggs_capsules_area = null; //Egg-bed (surface in ha)
|
|
||||||
public String eggs_capsules_density = null; //Плотность яиц
|
|
||||||
public String eggs_capsules_density_to = null; //Egg-pods (density) to
|
|
||||||
public String eggs_capsules = null; //Eggs (average)
|
|
||||||
public String eggs_live = null; //Eggs (viable)
|
|
||||||
public String eggs_enemies_id = null; //Natural enemies present
|
|
||||||
public String eggs_enemies_uid = null; //Natural enemies present
|
|
||||||
//public String eggs_enemies = null; //not using TODO delete field from database
|
|
||||||
|
|
||||||
//Bands (кулиги)
|
//Bands (кулиги)
|
||||||
public String kuliguli = null;
|
public String kuliguli = null; // For CheckBox
|
||||||
public String kuliguli_density=null; //Плотность кулиг на м²
|
public String kuliguli_density=null; //Плотность кулиг на м²
|
||||||
public String kuliguli_density_to = null; //плотность максимальная в кулиге
|
public String kuliguli_density_to = null; //плотность максимальная в кулиге
|
||||||
public String kuliguli_size = null; // Размер кулиг
|
public String kuliguli_size = null; // Размер кулиг
|
||||||
@ -99,7 +105,7 @@ public class FrmLocustModel {
|
|||||||
public String kuliguli_age_uid = null; // Возраст личинок
|
public String kuliguli_age_uid = null; // Возраст личинок
|
||||||
|
|
||||||
//Adults (Имаго)
|
//Adults (Имаго)
|
||||||
public String imago = null;
|
public String imago = null; // For CheckBox
|
||||||
public String imago_wing_id = null;
|
public String imago_wing_id = null;
|
||||||
public String imago_wing_uid = null;
|
public String imago_wing_uid = null;
|
||||||
public String imago_maturity = null;
|
public String imago_maturity = null;
|
||||||
@ -113,13 +119,10 @@ public class FrmLocustModel {
|
|||||||
public String imago_density_ga = null;
|
public String imago_density_ga = null;
|
||||||
public String imago_feeding = null;
|
public String imago_feeding = null;
|
||||||
public String imago_copulation = null;
|
public String imago_copulation = null;
|
||||||
public String imago_laying = null;
|
public String imago_laying = null; //Кладка яиц
|
||||||
public String imago_flying = null;
|
public String imago_flying = null;
|
||||||
|
|
||||||
|
|
||||||
public String bio_hectare=null; //Обследованная площадь
|
|
||||||
public String bio_biotope_id=null; //Тип тиотопа
|
|
||||||
public String bio_biotope_uid=null; //Тип тиотопа
|
|
||||||
|
|
||||||
public String swarms = null; // For CheckBox
|
public String swarms = null; // For CheckBox
|
||||||
public String swarm_maturity = null; //Maturity boolean,
|
public String swarm_maturity = null; //Maturity boolean,
|
||||||
|
|||||||
Reference in New Issue
Block a user