Почти подправил

This commit is contained in:
2025-01-09 07:41:58 +05:00
parent 7081e6ea20
commit 96b3c3ed1e
4 changed files with 87 additions and 76 deletions

View File

@ -17,14 +17,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

@ -292,6 +292,7 @@ public class AirTemperature 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++)
@ -323,47 +324,53 @@ public class AirTemperature implements ServletContextAware {
insert into main.air_temperature( insert into main.air_temperature(
val, val,
country_id, country_id,
point_id, air_temperature_date_id,
air_temperature_date_id point_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),?) main.get_point_id(?,?,?)
); );
"""; """;
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(3, date + " " + time);
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setInt(4, 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 ..."); throw new Exception("Failed insert ...");
}
} }
//}
} }
if(db_ru) { if(db_ru) {
point_id = DBTools.getPointId(st_ru, country_id, lon, lat); //point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
if(point_id!=null) { //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.setLong(3, Long.valueOf(point_id));
pstmt.setString(4, date + " " + time); pstmt.setString(3, date + " " + time);
pstmt.setInt(5, Integer.valueOf(forecast)); pstmt.setInt(4, 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("E11:"+ex.getMessage(),ex); logger.error("E11:"+ex.getMessage(),ex);
//throw new Exception("Failed insert ..."); throw new Exception("Failed insert ...");
}
} }
//}
} }
} }
} }
@ -371,6 +378,9 @@ public class AirTemperature 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 {
@ -410,6 +420,7 @@ public class AirTemperature implements ServletContextAware {
try { if(conn_ru!=null) conn_ru.close();} catch (SQLException ex) {logger.error("N15:"+ex.getMessage(),ex);} try { if(conn_ru!=null) conn_ru.close();} catch (SQLException ex) {logger.error("N15:"+ex.getMessage(),ex);}
result+="End!<br>"; result+="End!<br>";
System.out.println("Done download and save");
return result; return result;
} }

View File

@ -365,7 +365,7 @@ public class Precipitation implements ServletContextAware {
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...");
} }
} }
} }
@ -381,7 +381,7 @@ public class Precipitation implements ServletContextAware {
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...");
} }
} }
} }

View File

@ -385,7 +385,7 @@ public class SoilTmperature implements ServletContextAware {
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...");
} }
} }
} }
@ -401,7 +401,7 @@ public class SoilTmperature implements ServletContextAware {
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...");
} }
} }
} }