Финишная прямая, тестирую

This commit is contained in:
Igor I
2025-01-08 17:53:19 +05:00
parent d7fa8eea7a
commit 7081e6ea20
5 changed files with 141 additions and 132 deletions

View File

@ -13,17 +13,17 @@ spring:
#custom.config.db_url=jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=weather&sslmode=require #custom.config.db_url=jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=weather&sslmode=require
custom: custom:
config: config:
data_dir: O:\\temp\\CCALM\\ #data_dir: O:\\temp\\CCALM\\
#data_dir: /temp/CCALM/ 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:5433/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

@ -319,52 +319,53 @@ public class AirTemperature implements ServletContextAware {
if(country_id!=null && !country_id.equals("") && !country_id.equals("null")) if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
{ {
try { String sql= """
String sql= """ insert into main.air_temperature(
insert into main.air_temperature( val,
val, country_id,
country_id, point_id,
point_id, air_temperature_date_id
air_temperature_date_id )values(
)values( ?,
?, ?,
?, ?,
?, main.get_air_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
main.get_air_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?) );
); """;
"""; String point_id=null;
String point_id=null; if(db_all) {
if(db_all) { point_id = DBTools.getPointId(st_all, country_id, lon, lat);
point_id = DBTools.getPointId(st_all, country_id, lon, lat); if(point_id!=null) {
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.setLong(3, Long.valueOf(point_id)); pstmt.setString(4, date + " " + time);
pstmt.setString(4, date + " " + time); pstmt.setInt(5, Integer.valueOf(forecast));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.executeUpdate();
pstmt.executeUpdate(); } catch (SQLException ex) {
} logger.error("E10:"+ex.getMessage(),ex);
//throw new Exception("Failed insert ...");
} }
} }
if(db_ru) { }
point_id = DBTools.getPointId(st_ru, country_id, lon, lat); if(db_ru) {
if(point_id!=null) { point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) { if(point_id!=null) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(3, Long.valueOf(point_id)); pstmt.setLong(2, Long.valueOf(country_id));
pstmt.setString(4, date + " " + time); pstmt.setLong(3, Long.valueOf(point_id));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setString(4, date + " " + time);
pstmt.executeUpdate(); pstmt.setInt(5, Integer.valueOf(forecast));
} pstmt.executeUpdate();
} catch (SQLException ex) {
logger.error("E11:"+ex.getMessage(),ex);
//throw new Exception("Failed insert ...");
} }
} }
} catch (SQLException ex) {
logger.error("N10:"+ex.getMessage(),ex);
} }
} }
} }
} }
pos++; pos++;
@ -373,7 +374,7 @@ public class AirTemperature implements ServletContextAware {
//Cut data piece from big country of Russia //Cut data piece from big country of Russia
try { try {
String sql="delete from main.points 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),w.geom);"; 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));";
if(st_all!=null) st_all.executeUpdate(sql); if(st_all!=null) st_all.executeUpdate(sql);
if(st_ru!=null) st_ru.executeUpdate(sql); if(st_ru!=null) st_ru.executeUpdate(sql);
} catch (SQLException ex) { } catch (SQLException ex) {
@ -390,8 +391,12 @@ public class AirTemperature implements ServletContextAware {
try { try {
String sql = "END TRANSACTION;"; String sql = "END TRANSACTION;";
if(st_all!=null) st_all.executeUpdate(sql); if(st_all!=null) {
if(st_ru!=null) st_ru.executeUpdate(sql); st_all.executeUpdate(sql);
}
if(st_ru!=null) {
st_ru.executeUpdate(sql);
}
} catch (SQLException ex) { } catch (SQLException ex) {
logger.error("N13:"+ex.getMessage(),ex); logger.error("N13:"+ex.getMessage(),ex);
} }

View File

@ -19,7 +19,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
import tctable.Tools; import tctable.Tools;
import javax.servlet.http.HttpServletResponse; //import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
/* /*
* Server buffer for map tiles. * Server buffer for map tiles.
*/ */

View File

@ -339,50 +339,51 @@ public class Precipitation implements ServletContextAware {
if(country_id!=null && !country_id.equals("") && !country_id.equals("null")) if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
{ {
try { String sql= """
String sql= """ insert into main.precipitation(
insert into main.precipitation( val,
val, country_id,
country_id, point_id,
point_id, air_temperature_date_id
air_temperature_date_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),?) );
); """;
"""; String point_id=null;
String point_id=null; if(db_all) {
if(db_all) { point_id = DBTools.getPointId(st_all, country_id, lon, lat);
point_id = DBTools.getPointId(st_all, country_id, lon, lat); if(point_id!=null) {
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.setLong(3, Long.valueOf(point_id)); pstmt.setString(4, date + " " + time);
pstmt.setString(4, date + " " + time); pstmt.setInt(5, Integer.valueOf(forecast));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.executeUpdate();
pstmt.executeUpdate(); } catch (SQLException ex) {
} logger.error("E10:"+ex.getMessage(),ex);
//throw new Exception("Failed insert precipitation...");
} }
} }
if(db_ru) { }
point_id = DBTools.getPointId(st_ru, country_id, lon, lat); if(db_ru) {
if(point_id!=null) { point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) { if(point_id!=null) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(3, Long.valueOf(point_id)); pstmt.setLong(2, Long.valueOf(country_id));
pstmt.setString(4, date + " " + time); pstmt.setLong(3, Long.valueOf(point_id));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setString(4, date + " " + time);
pstmt.executeUpdate(); pstmt.setInt(5, Integer.valueOf(forecast));
} pstmt.executeUpdate();
} catch (SQLException ex) {
logger.error("E10:"+ex.getMessage(),ex);
//throw new Exception("Failed insert precipitation...");
} }
} }
} catch (SQLException ex) {
logger.error("N10:"+ex.getMessage(),ex);
throw new Exception("Failed insert precipitation...");
} }
} }
@ -394,7 +395,7 @@ public class Precipitation implements ServletContextAware {
//Cut data piece from big country of Russia //Cut data piece from big country of Russia
try { try {
String sql="delete from main.points 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),w.geom);"; 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));";
st_all.executeUpdate(sql); st_all.executeUpdate(sql);
st_ru.executeUpdate(sql); st_ru.executeUpdate(sql);
} catch (SQLException ex) { } catch (SQLException ex) {

View File

@ -358,50 +358,52 @@ public class SoilTmperature implements ServletContextAware {
if(!country_id.isEmpty() && !country_id.equals("null")) if(!country_id.isEmpty() && !country_id.equals("null"))
{ {
try {
String sql=""" String sql="""
insert into main.soil_temperature( insert into main.soil_temperature(
val, val,
country_id, country_id,
point_id, point_id,
soil_temperature_date_id soil_temperature_date_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),?)
); );
"""; """;
String point_id=null; String point_id=null;
if(db_all) { if(db_all) {
point_id = DBTools.getPointId(st_all, country_id, lon, lat); point_id = DBTools.getPointId(st_all, country_id, lon, lat);
if(point_id!=null) { 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.setLong(3, Long.valueOf(point_id));
pstmt.setString(4, date + " " + time); pstmt.setString(4, date + " " + time);
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setInt(5, Integer.valueOf(forecast));
pstmt.executeUpdate(); pstmt.executeUpdate();
} } catch (SQLException ex) {
logger.error("E10:"+ex.getMessage(),ex);
//throw new Exception("Failed insert soil temperature...");
} }
} }
if(db_ru) { }
point_id = DBTools.getPointId(st_ru, country_id, lon, lat); if(db_ru) {
if(point_id!=null) { point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) { if(point_id!=null) {
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
pstmt.setLong(2, Long.valueOf(country_id)); pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
pstmt.setLong(3, Long.valueOf(point_id)); pstmt.setLong(2, Long.valueOf(country_id));
pstmt.setString(4, date + " " + time); pstmt.setLong(3, Long.valueOf(point_id));
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setString(4, date + " " + time);
pstmt.executeUpdate(); pstmt.setInt(5, Integer.valueOf(forecast));
} pstmt.executeUpdate();
} catch (SQLException ex) {
logger.error("E10:"+ex.getMessage(),ex);
//throw new Exception("Failed insert soil temperature...");
} }
} }
} catch (SQLException ex) {
logger.error("N11: "+ex.getMessage(),ex);
throw new Exception("Failed insert soil temperature...");
} }
} }
@ -413,7 +415,7 @@ public class SoilTmperature implements ServletContextAware {
//Cut data piece from big country of Russia //Cut data piece from big country of Russia
try { try {
String sql="delete from main.points 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),w.geom);"; 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));";
st_all.executeUpdate(sql); st_all.executeUpdate(sql);
st_ru.executeUpdate(sql); st_ru.executeUpdate(sql);
} catch (SQLException ex) { } catch (SQLException ex) {