+Таблица даты
This commit is contained in:
22
pom.xml
22
pom.xml
@ -10,13 +10,20 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>org.ccalm</groupId>
|
<groupId>org.ccalm</groupId>
|
||||||
<artifactId>weather</artifactId>
|
<artifactId>weather</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.4-SNAPSHOT</version>
|
||||||
<name>weather</name>
|
<name>weather</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>11</java.version>
|
<java.version>17</java.version>
|
||||||
<start-class>org.ccalm.weather.WeatherApplication</start-class>
|
<start-class>org.ccalm.weather.WeatherApplication</start-class>
|
||||||
</properties>
|
</properties>
|
||||||
|
<!--repositories>
|
||||||
|
<repository>
|
||||||
|
<id>boundless</id>
|
||||||
|
<name>Boundless Repository</name>
|
||||||
|
<url>https://repo.boundlessgeo.com/main/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories-->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -48,12 +55,11 @@
|
|||||||
<groupId>edu.ucar</groupId>
|
<groupId>edu.ucar</groupId>
|
||||||
<artifactId>netcdfAll</artifactId>
|
<artifactId>netcdfAll</artifactId>
|
||||||
<version>5.3.1</version>
|
<version>5.3.1</version>
|
||||||
<!-- Look: https://newbedev.com/how-to-include-system-dependencies-in-war-built-using-maven
|
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${basedir}/lib/netcdfAll-5.3.1.jar</systemPath>
|
<systemPath>O:/projects/Workspace_Java/CCALM_weather/src/main/lib/netcdfAll-5.3.1.jar</systemPath>
|
||||||
-->
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -63,7 +69,7 @@
|
|||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<!--plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
@ -71,7 +77,7 @@
|
|||||||
<id>install-external</id>
|
<id>install-external</id>
|
||||||
<phase>clean</phase>
|
<phase>clean</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<file>${basedir}/src/main/lib/netcdfAll-5.3.1.jar</file>
|
<file>O:/projects/Workspace_Java/CCALM_weather/src/main/lib/netcdfAll-5.3.1.jar</file>
|
||||||
<repositoryLayout>default</repositoryLayout>
|
<repositoryLayout>default</repositoryLayout>
|
||||||
<groupId>edu.ucar</groupId>
|
<groupId>edu.ucar</groupId>
|
||||||
<artifactId>netcdfAll</artifactId>
|
<artifactId>netcdfAll</artifactId>
|
||||||
@ -84,7 +90,7 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin-->
|
||||||
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|||||||
@ -248,6 +248,13 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
}
|
}
|
||||||
System.out.println("Delete old data 2");
|
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 {
|
try {
|
||||||
String sql="delete from main.air_temperature where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
String sql="delete from main.air_temperature where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
||||||
st.executeUpdate(sql);
|
st.executeUpdate(sql);
|
||||||
@ -255,8 +262,6 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int pos=0;
|
int pos=0;
|
||||||
for(int nLat=0;nLat<dataArrayLat.getSize();nLat++)
|
for(int nLat=0;nLat<dataArrayLat.getSize();nLat++)
|
||||||
{
|
{
|
||||||
@ -289,11 +294,12 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
|
if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
|
||||||
{
|
{
|
||||||
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
||||||
try {
|
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);
|
st.executeUpdate(sql);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
@ -395,7 +401,17 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
Statement st;
|
Statement st;
|
||||||
try {
|
try {
|
||||||
st = conn.createStatement();
|
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);
|
ResultSet rs = st.executeQuery(sql);
|
||||||
if(rs!=null)
|
if(rs!=null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public class Precipitation implements ServletContextAware {
|
|||||||
@Value("${custom.config.data_dir}")
|
@Value("${custom.config.data_dir}")
|
||||||
private String 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;
|
private ServletContext context;
|
||||||
|
|
||||||
@ -250,6 +250,13 @@ public class Precipitation implements ServletContextAware {
|
|||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
}
|
}
|
||||||
System.out.println("Delete old data 2");
|
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 {
|
try {
|
||||||
String sql="delete from main.precipitation where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
String sql="delete from main.precipitation where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
||||||
st.executeUpdate(sql);
|
st.executeUpdate(sql);
|
||||||
@ -294,7 +301,7 @@ public class Precipitation implements ServletContextAware {
|
|||||||
{
|
{
|
||||||
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
||||||
try {
|
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);
|
st.executeUpdate(sql);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
@ -396,7 +403,19 @@ public class Precipitation implements ServletContextAware {
|
|||||||
Statement st;
|
Statement st;
|
||||||
try {
|
try {
|
||||||
st = conn.createStatement();
|
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);
|
ResultSet rs = st.executeQuery(sql);
|
||||||
if(rs!=null)
|
if(rs!=null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -266,6 +266,13 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
}
|
}
|
||||||
System.out.println("Delete old data 2");
|
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 {
|
try {
|
||||||
String sql="delete from main.soil_temperature where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
String sql="delete from main.soil_temperature where date<=CURRENT_DATE-'730 days'::INTERVAL";
|
||||||
st.executeUpdate(sql);
|
st.executeUpdate(sql);
|
||||||
@ -273,7 +280,7 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
}
|
}
|
||||||
if(Integer.parseInt(forecast)!=0) {
|
if(Integer.parseInt(forecast)!=0) {
|
||||||
System.out.println("Delete old data 3");
|
System.out.println("Delete old data 4");
|
||||||
try {
|
try {
|
||||||
String sql="delete from main.soil_temperature where hours="+forecast;
|
String sql="delete from main.soil_temperature where hours="+forecast;
|
||||||
st.executeUpdate(sql);
|
st.executeUpdate(sql);
|
||||||
@ -317,9 +324,7 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
{
|
{
|
||||||
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
//logger.info(lon + "," + lat +","+dataArrayTmp.getFloat(pos));
|
||||||
try {
|
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(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+"));";
|
||||||
//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+");";
|
|
||||||
st.executeUpdate(sql);
|
st.executeUpdate(sql);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logger.info(ex.getMessage());
|
logger.info(ex.getMessage());
|
||||||
@ -420,7 +425,17 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
Statement st;
|
Statement st;
|
||||||
try {
|
try {
|
||||||
st = conn.createStatement();
|
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);
|
ResultSet rs = st.executeQuery(sql);
|
||||||
if(rs!=null)
|
if(rs!=null)
|
||||||
|
|||||||
19
src/main/resources/log4j2.xml
Normal file
19
src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="INFO">
|
||||||
|
<Appenders>
|
||||||
|
<!-- Ротирующий файловый аппендер -->
|
||||||
|
<RollingFile name="RollingFile" fileName="logs/application.log"
|
||||||
|
filePattern="logs/application-%d{MM-dd-yyyy}-%i.log.gz">
|
||||||
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="100 MB"/>
|
||||||
|
</Policies>
|
||||||
|
<DefaultRolloverStrategy max="10"/>
|
||||||
|
</RollingFile>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="ALL">
|
||||||
|
<AppenderRef ref="RollingFile"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
Reference in New Issue
Block a user