+Таблица даты
This commit is contained in:
@ -248,15 +248,20 @@ public class AirTemperature implements ServletContextAware {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
System.out.println("Delete old data 2");
|
||||
try {
|
||||
String sql="delete from main.air_temperature_dates where date=cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone) and hours="+forecast;
|
||||
st.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
System.out.println("Delete old data 3");
|
||||
try {
|
||||
String sql="delete from main.air_temperature where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
||||
st.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int pos=0;
|
||||
for(int nLat=0;nLat<dataArrayLat.getSize();nLat++)
|
||||
{
|
||||
@ -289,11 +294,12 @@ public class AirTemperature implements ServletContextAware {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
|
||||
{
|
||||
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
||||
try {
|
||||
String sql="insert into main.air_temperature(date,hours,val,geom,country_id)values(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326),"+country_id+");";
|
||||
String sql="insert into main.air_temperature(date,hours,val,geom,country_id,air_temperature_date_id)values(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326),"+country_id+",main.get_air_temperature_date(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+"));";
|
||||
st.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
@ -395,7 +401,17 @@ public class AirTemperature implements ServletContextAware {
|
||||
Statement st;
|
||||
try {
|
||||
st = conn.createStatement();
|
||||
String sql = "SELECT to_char(date, 'YYYY-MM-DD') as date,hours as hour,EXTRACT(DAY FROM CURRENT_DATE-date) as day FROM main.air_temperature group by date,hours order by date,hours;";
|
||||
//String sql = "SELECT to_char(date, 'YYYY-MM-DD') as date,hours as hour,EXTRACT(DAY FROM CURRENT_DATE-date) as day FROM main.air_temperature group by date,hours order by date,hours;";
|
||||
String sql = """
|
||||
SELECT
|
||||
to_char(date, 'YYYY-MM-DD') as date,
|
||||
hours as hour,
|
||||
EXTRACT(DAY FROM CURRENT_DATE-date) as day
|
||||
FROM
|
||||
main.air_temperature_dates
|
||||
group by date,hours
|
||||
order by date,hours
|
||||
""";
|
||||
ResultSet rs = st.executeQuery(sql);
|
||||
if(rs!=null)
|
||||
{
|
||||
|
||||
@ -63,7 +63,7 @@ public class Precipitation implements ServletContextAware {
|
||||
@Value("${custom.config.data_dir}")
|
||||
private String data_dir;
|
||||
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SoilTmperature.class);
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Precipitation.class);
|
||||
|
||||
private ServletContext context;
|
||||
|
||||
@ -250,6 +250,13 @@ public class Precipitation implements ServletContextAware {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
System.out.println("Delete old data 2");
|
||||
try {
|
||||
String sql="delete from main.precipitation_dates where date=cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone) and hours="+forecast;
|
||||
st.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
System.out.println("Delete old data 3");
|
||||
try {
|
||||
String sql="delete from main.precipitation where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
||||
st.executeUpdate(sql);
|
||||
@ -294,7 +301,7 @@ public class Precipitation implements ServletContextAware {
|
||||
{
|
||||
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
||||
try {
|
||||
String sql="insert into main.precipitation(date,hours,val,geom,country_id)values(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326),"+country_id+");";
|
||||
String sql="insert into main.precipitation(date,hours,val,geom,country_id,precipitation_date_id)values(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326),"+country_id+",main.get_precipitation_date(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+"));";
|
||||
st.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
@ -396,7 +403,19 @@ public class Precipitation implements ServletContextAware {
|
||||
Statement st;
|
||||
try {
|
||||
st = conn.createStatement();
|
||||
String sql = "SELECT to_char(date, 'YYYY-MM-DD') as date,hours as hour,DATE_PART('doy',date)-1 as day FROM main.precipitation group by date,hours order by date,hours";
|
||||
//String sql = "SELECT to_char(date, 'YYYY-MM-DD') as date,hours as hour,DATE_PART('doy',date)-1 as day FROM main.precipitation group by date,hours order by date,hours";
|
||||
String sql = """
|
||||
SELECT
|
||||
to_char(date, 'YYYY-MM-DD') as date,
|
||||
hours as hour,
|
||||
DATE_PART('doy',date)-1 as day
|
||||
FROM
|
||||
main.precipitation_dates
|
||||
group by
|
||||
date,
|
||||
hours
|
||||
order by date,hours
|
||||
""";
|
||||
ResultSet rs = st.executeQuery(sql);
|
||||
if(rs!=null)
|
||||
{
|
||||
|
||||
@ -266,6 +266,13 @@ public class SoilTmperature implements ServletContextAware {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
System.out.println("Delete old data 2");
|
||||
try {
|
||||
String sql="delete from main.soil_temperature_dates where date=cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone) and hours="+forecast;
|
||||
st.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
System.out.println("Delete old data 3");
|
||||
try {
|
||||
String sql="delete from main.soil_temperature where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
||||
st.executeUpdate(sql);
|
||||
@ -273,7 +280,7 @@ public class SoilTmperature implements ServletContextAware {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
if(Integer.parseInt(forecast)!=0) {
|
||||
System.out.println("Delete old data 3");
|
||||
System.out.println("Delete old data 4");
|
||||
try {
|
||||
String sql="delete from main.soil_temperature where hours="+forecast;
|
||||
st.executeUpdate(sql);
|
||||
@ -317,9 +324,7 @@ public class SoilTmperature implements ServletContextAware {
|
||||
{
|
||||
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
||||
try {
|
||||
//String sql="insert into main.soil_temperature(weather_type_id,date,hours,val,geom)values(1,cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326));";
|
||||
//String sql="insert into main.soil_temperature(weather_type_id,date,hours,val,geom,country_id)values(1,cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326),(select c.id from main.countries c where ST_Contains(c.geom,ST_SetSRID(st_makepoint("+lon+","+lat+"),4326)) limit 1));";
|
||||
String sql="insert into main.soil_temperature(date,hours,val,geom,country_id)values(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326),"+country_id+");";
|
||||
String sql="insert into main.soil_temperature(date,hours,val,geom,country_id,soil_temperature_date_id)values(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+","+dataArrayTmp.getFloat(pos)+",ST_SetSRID(st_makepoint("+lon+","+lat+"),4326),"+country_id+",main.get_soil_temperature_date(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+"));";
|
||||
st.executeUpdate(sql);
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
@ -420,8 +425,18 @@ public class SoilTmperature implements ServletContextAware {
|
||||
Statement st;
|
||||
try {
|
||||
st = conn.createStatement();
|
||||
String sql = "SELECT to_char(date, 'YYYY-MM-DD') as date,hours as hour,EXTRACT(DAY FROM CURRENT_DATE-date) as day FROM main.soil_temperature group by date,hours order by date,hours";
|
||||
|
||||
//String sql = "SELECT to_char(date, 'YYYY-MM-DD') as date,hours as hour,EXTRACT(DAY FROM CURRENT_DATE-date) as day FROM main.soil_temperature group by date,hours order by date,hours";
|
||||
String sql = """
|
||||
SELECT
|
||||
to_char(date, 'YYYY-MM-DD') as date,
|
||||
hours as hour,
|
||||
EXTRACT(DAY FROM CURRENT_DATE-date) as day
|
||||
FROM
|
||||
main.soil_temperature_dates
|
||||
group by date,hours
|
||||
order by date,hours
|
||||
""";
|
||||
|
||||
ResultSet rs = st.executeQuery(sql);
|
||||
if(rs!=null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user