Финишная прямая, тестирую
This commit is contained in:
@ -319,52 +319,53 @@ public class AirTemperature implements ServletContextAware {
|
||||
|
||||
if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
|
||||
{
|
||||
try {
|
||||
String sql= """
|
||||
insert into main.air_temperature(
|
||||
val,
|
||||
country_id,
|
||||
point_id,
|
||||
air_temperature_date_id
|
||||
)values(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
main.get_air_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||
);
|
||||
""";
|
||||
String point_id=null;
|
||||
if(db_all) {
|
||||
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
String sql= """
|
||||
insert into main.air_temperature(
|
||||
val,
|
||||
country_id,
|
||||
point_id,
|
||||
air_temperature_date_id
|
||||
)values(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
main.get_air_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||
);
|
||||
""";
|
||||
String point_id=null;
|
||||
if(db_all) {
|
||||
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
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(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
if(db_ru) {
|
||||
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
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++;
|
||||
@ -373,7 +374,7 @@ public class AirTemperature implements ServletContextAware {
|
||||
|
||||
//Cut data piece from big country of Russia
|
||||
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_ru!=null) st_ru.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
@ -390,8 +391,12 @@ public class AirTemperature implements ServletContextAware {
|
||||
|
||||
try {
|
||||
String sql = "END TRANSACTION;";
|
||||
if(st_all!=null) st_all.executeUpdate(sql);
|
||||
if(st_ru!=null) st_ru.executeUpdate(sql);
|
||||
if(st_all!=null) {
|
||||
st_all.executeUpdate(sql);
|
||||
}
|
||||
if(st_ru!=null) {
|
||||
st_ru.executeUpdate(sql);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.error("N13:"+ex.getMessage(),ex);
|
||||
}
|
||||
|
||||
@ -19,7 +19,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import tctable.Tools;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
/*
|
||||
* Server buffer for map tiles.
|
||||
*/
|
||||
|
||||
@ -339,50 +339,51 @@ public class Precipitation implements ServletContextAware {
|
||||
|
||||
if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
|
||||
{
|
||||
try {
|
||||
String sql= """
|
||||
insert into main.precipitation(
|
||||
val,
|
||||
country_id,
|
||||
point_id,
|
||||
air_temperature_date_id
|
||||
)values(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||
);
|
||||
""";
|
||||
String point_id=null;
|
||||
if(db_all) {
|
||||
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
String sql= """
|
||||
insert into main.precipitation(
|
||||
val,
|
||||
country_id,
|
||||
point_id,
|
||||
air_temperature_date_id
|
||||
)values(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||
);
|
||||
""";
|
||||
String point_id=null;
|
||||
if(db_all) {
|
||||
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
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(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
if(db_ru) {
|
||||
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
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
|
||||
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_ru.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
|
||||
@ -358,50 +358,52 @@ public class SoilTmperature implements ServletContextAware {
|
||||
|
||||
if(!country_id.isEmpty() && !country_id.equals("null"))
|
||||
{
|
||||
try {
|
||||
String sql="""
|
||||
insert into main.soil_temperature(
|
||||
val,
|
||||
country_id,
|
||||
point_id,
|
||||
soil_temperature_date_id
|
||||
)values(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
main.get_soil_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||
);
|
||||
""";
|
||||
String point_id=null;
|
||||
if(db_all) {
|
||||
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
|
||||
String sql="""
|
||||
insert into main.soil_temperature(
|
||||
val,
|
||||
country_id,
|
||||
point_id,
|
||||
soil_temperature_date_id
|
||||
)values(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
main.get_soil_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||
);
|
||||
""";
|
||||
String point_id=null;
|
||||
if(db_all) {
|
||||
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
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(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
if(db_ru) {
|
||||
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
|
||||
if(point_id!=null) {
|
||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||
pstmt.setLong(2, Long.valueOf(country_id));
|
||||
pstmt.setLong(3, Long.valueOf(point_id));
|
||||
pstmt.setString(4, date + " " + time);
|
||||
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
|
||||
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_ru.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
|
||||
Reference in New Issue
Block a user