This commit is contained in:
Igor I
2025-01-09 18:41:02 +05:00
parent 96b3c3ed1e
commit 29888de73b
5 changed files with 145 additions and 149 deletions

View File

@ -1,5 +1,10 @@
server: server:
port: 8081 port: 8081
ssl:
key-store: classpath:keystore.jks
key-store-password: QyKtWPZB
key-store-type: JKS
key-alias: weather
servlet: servlet:
session: session:
timeout: 300s timeout: 300s
@ -17,14 +22,14 @@ custom:
data_dir: /data/ data_dir: /data/
db_all: db_all:
#url: jdbc:postgresql://92.46.48.43:5444/weather?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://92.46.48.43:5444/weather?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require url: jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
login: postgres login: postgres
password: PasSecrKey1 password: PasSecrKey1
db_ru: db_ru:
#url: jdbc:postgresql://92.46.48.43:5444/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://92.46.48.43:5444/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://192.168.0.90:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require url: jdbc:postgresql://192.168.0.90:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://127.0.0.1:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://127.0.0.1:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
login: postgres login: postgres
password: PasSecrKey1 password: PasSecrKey1

View File

@ -318,7 +318,7 @@ public class AirTemperature implements ServletContextAware {
if(!country_id.isEmpty()) db_ru=true; if(!country_id.isEmpty()) db_ru=true;
} }
if(country_id!=null && !country_id.equals("") && !country_id.equals("null")) if(country_id!=null && !country_id.isEmpty() && !country_id.equals("null"))
{ {
String sql= """ String sql= """
insert into main.air_temperature( insert into main.air_temperature(
@ -333,14 +333,10 @@ public class AirTemperature implements ServletContextAware {
main.get_point_id(?,?,?) main.get_point_id(?,?,?)
); );
"""; """;
//String point_id=null;
if(db_all) { if(db_all) {
//point_id = DBTools.getPointId(st_all, country_id, lon, lat);
//if(point_id!=null) {
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) { try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setLong(2, Long.valueOf(country_id));
//pstmt.setLong(3, Long.valueOf(point_id));
pstmt.setString(3, date + " " + time); pstmt.setString(3, date + " " + time);
pstmt.setInt(4, Integer.valueOf(forecast)); pstmt.setInt(4, Integer.valueOf(forecast));
pstmt.setLong(5, Long.valueOf(country_id)); pstmt.setLong(5, Long.valueOf(country_id));
@ -351,15 +347,12 @@ public class AirTemperature implements ServletContextAware {
logger.error("E10:"+ex.getMessage(),ex); logger.error("E10:"+ex.getMessage(),ex);
throw new Exception("Failed insert ..."); throw new Exception("Failed insert ...");
} }
//}
} }
if(db_ru) { if(db_ru) {
//point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
//if(point_id!=null) {
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) { try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setLong(2, Long.valueOf(country_id));
//pstmt.setLong(3, Long.valueOf(point_id));
pstmt.setString(3, date + " " + time); pstmt.setString(3, date + " " + time);
pstmt.setInt(4, Integer.valueOf(forecast)); pstmt.setInt(4, Integer.valueOf(forecast));
pstmt.setLong(5, Long.valueOf(country_id)); pstmt.setLong(5, Long.valueOf(country_id));
@ -370,7 +363,6 @@ public class AirTemperature implements ServletContextAware {
logger.error("E11:"+ex.getMessage(),ex); logger.error("E11:"+ex.getMessage(),ex);
throw new Exception("Failed insert ..."); throw new Exception("Failed insert ...");
} }
//}
} }
} }
} }

View File

@ -312,6 +312,7 @@ public class Precipitation implements ServletContextAware {
} }
int pos=0; int pos=0;
try{
for(int nLat=0;nLat<dataArrayLat.getSize();nLat++) for(int nLat=0;nLat<dataArrayLat.getSize();nLat++)
{ {
for(int nLon=0;nLon<dataArrayLon.getSize();nLon++) for(int nLon=0;nLon<dataArrayLon.getSize();nLon++)
@ -337,47 +338,45 @@ public class Precipitation implements ServletContextAware {
if(!country_id.isEmpty()) db_ru=true; if(!country_id.isEmpty()) db_ru=true;
} }
if(country_id!=null && !country_id.equals("") && !country_id.equals("null")) if(country_id!=null && !country_id.isEmpty() && !country_id.equals("null"))
{ {
String sql= """ String sql= """
insert into main.precipitation( insert into main.precipitation(
val, val,
country_id, country_id,
point_id, air_temperature_date_id,
air_temperature_date_id point_id
)values( )values(
?, ?,
?, ?,
?, main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?),
main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?) main.get_point_id(?,?,?)
); );
"""; """;
String point_id=null;
if(db_all) { if(db_all) {
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
if(point_id!=null) {
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) { try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setLong(2, Long.valueOf(country_id));
pstmt.setLong(3, Long.valueOf(point_id)); pstmt.setString(3, date + " " + time);
pstmt.setString(4, date + " " + time); pstmt.setInt(4, Integer.valueOf(forecast));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setLong(5, Long.valueOf(country_id));
pstmt.setDouble(6, lon);
pstmt.setDouble(7, lat);
pstmt.executeUpdate(); pstmt.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
logger.error("E10:"+ex.getMessage(),ex); logger.error("E10:"+ex.getMessage(),ex);
throw new Exception("Failed insert precipitation..."); throw new Exception("Failed insert precipitation...");
} }
} }
}
if(db_ru) { if(db_ru) {
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
if(point_id!=null) {
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) { try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setLong(2, Long.valueOf(country_id));
pstmt.setLong(3, Long.valueOf(point_id)); pstmt.setString(3, date + " " + time);
pstmt.setString(4, date + " " + time); pstmt.setInt(4, Integer.valueOf(forecast));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setLong(5, Long.valueOf(country_id));
pstmt.setDouble(6, lon);
pstmt.setDouble(7, lat);
pstmt.executeUpdate(); pstmt.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
logger.error("E10:"+ex.getMessage(),ex); logger.error("E10:"+ex.getMessage(),ex);
@ -385,14 +384,15 @@ public class Precipitation implements ServletContextAware {
} }
} }
} }
}
} }
} }
pos++; pos++;
} }
} }
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
//Cut data piece from big country of Russia //Cut data piece from big country of Russia
try { try {
String sql="delete from main.points p where country_id=7 and not ST_Contains(ST_SetSRID(ST_GeomFromText('POLYGON((10.00 66.00,10.00 40.00,179.00 40.00,179.00 66.00,10.00 66.00))'),4326),ST_SetSRID(st_makepoint(p.lon,p.lat),4326));"; String sql="delete from main.points p where country_id=7 and not ST_Contains(ST_SetSRID(ST_GeomFromText('POLYGON((10.00 66.00,10.00 40.00,179.00 40.00,179.00 66.00,10.00 66.00))'),4326),ST_SetSRID(st_makepoint(p.lon,p.lat),4326));";

View File

@ -331,6 +331,7 @@ public class SoilTmperature implements ServletContextAware {
} }
int pos=0; int pos=0;
try{
for(int nLat=0;nLat<dataArrayLat.getSize();nLat++) for(int nLat=0;nLat<dataArrayLat.getSize();nLat++)
{ {
for(int nLon=0;nLon<dataArrayLon.getSize();nLon++) for(int nLon=0;nLon<dataArrayLon.getSize();nLon++)
@ -356,48 +357,45 @@ public class SoilTmperature implements ServletContextAware {
if(!country_id.isEmpty()) db_ru=true; if(!country_id.isEmpty()) db_ru=true;
} }
if(!country_id.isEmpty() && !country_id.equals("null")) if(country_id!=null && !country_id.isEmpty() && !country_id.equals("null"))
{ {
String sql=""" String sql="""
insert into main.soil_temperature( insert into main.soil_temperature(
val, val,
country_id, country_id,
point_id, soil_temperature_date_id,
soil_temperature_date_id point_id
)values( )values(
?, ?,
?, ?,
?, main.get_soil_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?),
main.get_soil_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?) main.get_point_id(?,?,?)
); );
"""; """;
String point_id=null;
if(db_all) { if(db_all) {
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
if(point_id!=null) {
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) { try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setLong(2, Long.valueOf(country_id));
pstmt.setLong(3, Long.valueOf(point_id)); pstmt.setString(3, date + " " + time);
pstmt.setString(4, date + " " + time); pstmt.setInt(4, Integer.valueOf(forecast));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setLong(5, Long.valueOf(country_id));
pstmt.setDouble(6, lon);
pstmt.setDouble(7, lat);
pstmt.executeUpdate(); pstmt.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
logger.error("E10:"+ex.getMessage(),ex); logger.error("E10:"+ex.getMessage(),ex);
throw new Exception("Failed insert soil temperature..."); throw new Exception("Failed insert soil temperature...");
} }
} }
}
if(db_ru) { if(db_ru) {
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
if(point_id!=null) {
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) { try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setLong(2, Long.valueOf(country_id));
pstmt.setLong(3, Long.valueOf(point_id)); pstmt.setString(3, date + " " + time);
pstmt.setString(4, date + " " + time); pstmt.setInt(4, Integer.valueOf(forecast));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setLong(5, Long.valueOf(country_id));
pstmt.setDouble(6, lon);
pstmt.setDouble(7, lat);
pstmt.executeUpdate(); pstmt.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
logger.error("E10:"+ex.getMessage(),ex); logger.error("E10:"+ex.getMessage(),ex);
@ -406,12 +404,13 @@ public class SoilTmperature implements ServletContextAware {
} }
} }
} }
}
} }
pos++; pos++;
} }
} }
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
//Cut data piece from big country of Russia //Cut data piece from big country of Russia
try { try {

Binary file not shown.