На работе попытался поработать :-)
This commit is contained in:
@ -10,19 +10,21 @@ spring:
|
|||||||
cache:
|
cache:
|
||||||
type: none
|
type: none
|
||||||
|
|
||||||
#custom.config.db_url=jdbc:postgresql://192.168.0.90:5432/weather
|
#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: /temp/CCALM/
|
||||||
db_all:
|
db_all:
|
||||||
#url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather
|
url: jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
|
||||||
url: jdbc:postgresql://92.46.48.43:5433/weather?ApplicationName=kz_mcp_weather
|
#url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
|
||||||
|
#url: jdbc:postgresql://92.46.48.43:5433/weather?ApplicationName=kz_mcp_weather&sslmode=require
|
||||||
login: postgres
|
login: postgres
|
||||||
password: PasSecrKey10
|
password: PasSecrKey1
|
||||||
db_ru:
|
db_ru:
|
||||||
#url: jdbc:postgresql://92.46.48.43:5433/weather_ru?ApplicationName=kz_mcp_weather
|
url: jdbc:postgresql://192.168.0.90:5433/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
|
||||||
url: jdbc:postgresql://127.0.0.1:5432/weather_ru?ApplicationName=kz_mcp_weather
|
#url: jdbc:postgresql://92.46.48.43:5433/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
|
||||||
|
|
||||||
|
|||||||
24
pom.xml
24
pom.xml
@ -12,10 +12,9 @@
|
|||||||
<artifactId>weather</artifactId>
|
<artifactId>weather</artifactId>
|
||||||
<version>0.0.7-SNAPSHOT</version>
|
<version>0.0.7-SNAPSHOT</version>
|
||||||
<name>weather</name>
|
<name>weather</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Weather APP</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>21</java.version>
|
||||||
<start-class>org.ccalm.weather.WeatherApplication</start-class>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -24,11 +23,6 @@
|
|||||||
<name>Unidata UCAR Repository</name>
|
<name>Unidata UCAR Repository</name>
|
||||||
<url>https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/</url>
|
<url>https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<!--repository>
|
|
||||||
<id>boundless</id>
|
|
||||||
<name>Boundless Repository</name>
|
|
||||||
<url>https://repo.boundlessgeo.com/main/</url>
|
|
||||||
</repository-->
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -36,7 +30,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
@ -47,22 +40,12 @@
|
|||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.logstash.logback</groupId>
|
<groupId>net.logstash.logback</groupId>
|
||||||
<artifactId>logstash-logback-encoder</artifactId>
|
<artifactId>logstash-logback-encoder</artifactId>
|
||||||
<version>6.6</version>
|
<version>6.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.gdal/gdal -->
|
|
||||||
<!--dependency>
|
|
||||||
<groupId>org.gdal</groupId>
|
|
||||||
<artifactId>gdal</artifactId>
|
|
||||||
<version>2.4.0</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>O:/projects/_Libs/gdal-2.4.0.jar</systemPath>
|
|
||||||
</dependency-->
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/edu.ucar/netcdfAll -->
|
<!-- https://mvnrepository.com/artifact/edu.ucar/netcdfAll -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>edu.ucar</groupId>
|
<groupId>edu.ucar</groupId>
|
||||||
@ -85,7 +68,7 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin-->
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -100,5 +83,4 @@
|
|||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -17,23 +17,20 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.http.CacheControl;
|
import org.springframework.http.CacheControl;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.context.ServletContextAware;
|
import org.springframework.web.context.ServletContextAware;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
@ -75,58 +72,7 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
public void setServletContext(jakarta.servlet.ServletContext servletContext) {
|
public void setServletContext(jakarta.servlet.ServletContext servletContext) {
|
||||||
this.context = servletContext;
|
this.context = servletContext;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
public String getCountryId(Statement st,double lon,double lat) {
|
|
||||||
String country_id = "";
|
|
||||||
try {
|
|
||||||
String sql = "select c.id from main.countries c where del=false and ST_Contains(c.geom,ST_SetSRID(st_makepoint(" + lon + "," + lat + "),4326)) limit 1";
|
|
||||||
try (ResultSet rs = st.executeQuery(sql)) {
|
|
||||||
if (rs.next()) {
|
|
||||||
country_id = rs.getString(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
logger.error("N9: " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
return country_id;
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
public String getPointId(Statement st, String country_id, double lon, double lat) {
|
|
||||||
String point_id = "";
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
try {
|
|
||||||
String sql = "SELECT id FROM main.points WHERE lon = ? AND lat = ? LIMIT 1";
|
|
||||||
pstmt = st.getConnection().prepareStatement(sql);
|
|
||||||
pstmt.setDouble(1, lon);
|
|
||||||
pstmt.setDouble(2, lat);
|
|
||||||
try (ResultSet rs = pstmt.executeQuery()) {
|
|
||||||
if (rs.next()) {
|
|
||||||
point_id = rs.getString(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
logger.error("N9: " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
if(point_id.isEmpty()){
|
|
||||||
try {
|
|
||||||
String sql = "insert into main.points(country_id,geom,lon,lat)values(?,ST_SetSRID(st_makepoint(?,?),4326),?,?) RETURNING id";
|
|
||||||
pstmt = st.getConnection().prepareStatement(sql);
|
|
||||||
pstmt.setLong(1, Long.valueOf(country_id));
|
|
||||||
pstmt.setDouble(2, lon);
|
|
||||||
pstmt.setDouble(3, lat);
|
|
||||||
pstmt.setDouble(4, lon);
|
|
||||||
pstmt.setDouble(5, lat);
|
|
||||||
try (ResultSet rs = pstmt.executeQuery()) {
|
|
||||||
if (rs.next()) {
|
|
||||||
point_id = rs.getString(1); // Получаем ID, возвращаемый SQL-запросом
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
logger.error("N11: " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return point_id;
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
public Connection getConn(String url, String login,String password){
|
public Connection getConn(String url, String login,String password){
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
@ -363,27 +309,52 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
String country_id="";
|
String country_id="";
|
||||||
boolean db_all=false,db_ru=false;
|
boolean db_all=false,db_ru=false;
|
||||||
if(st_all!=null && country_id.isEmpty()) {
|
if(st_all!=null && country_id.isEmpty()) {
|
||||||
country_id = getCountryId(st_all, lon, lat);
|
country_id = DBTools.getCountryId(st_all, lon, lat);
|
||||||
if(!country_id.isEmpty()) db_all=true;
|
if(!country_id.isEmpty()) db_all=true;
|
||||||
}
|
}
|
||||||
if(st_ru!=null && country_id.isEmpty()) {
|
if(st_ru!=null && country_id.isEmpty()) {
|
||||||
country_id = getCountryId(st_ru, lon, lat);
|
country_id = DBTools.getCountryId(st_ru, lon, lat);
|
||||||
if(!country_id.isEmpty()) db_ru=true;
|
if(!country_id.isEmpty()) db_ru=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
|
if(country_id!=null && !country_id.equals("") && !country_id.equals("null"))
|
||||||
{
|
{
|
||||||
try {
|
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="";
|
String point_id="";
|
||||||
if(db_all) {
|
if(db_all) {
|
||||||
point_id = getPointId(st_all, country_id, lon, lat);
|
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||||
String sql="insert into main.air_temperature(val,point_id,country_id,air_temperature_date_id)values("+dataArrayTmp.getFloat(pos)+","+point_id+","+country_id+",main.get_air_temperature_date(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+"));";
|
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||||
st_all.executeUpdate(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) {
|
if(db_ru) {
|
||||||
point_id = getPointId(st_ru, country_id, lon, lat);
|
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
|
||||||
String sql="insert into main.air_temperature(val,point_id,country_id,air_temperature_date_id)values("+dataArrayTmp.getFloat(pos)+","+point_id+","+country_id+",main.get_air_temperature_date(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+"));";
|
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||||
st_ru.executeUpdate(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) {
|
} catch (SQLException ex) {
|
||||||
logger.error("N10:"+ex.getMessage(),ex);
|
logger.error("N10:"+ex.getMessage(),ex);
|
||||||
@ -398,14 +369,13 @@ 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="update main.points w set country_id=null 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 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);";
|
||||||
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) {
|
||||||
logger.error("N11:"+ex.getMessage(),ex);
|
logger.error("N11:"+ex.getMessage(),ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete values where country_id is null
|
|
||||||
try {
|
try {
|
||||||
String sql="delete from main.points where country_id is null;";
|
String sql="delete from main.points where country_id is null;";
|
||||||
if(st_all!=null) st_all.executeUpdate(sql);
|
if(st_all!=null) st_all.executeUpdate(sql);
|
||||||
@ -451,21 +421,34 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
//@Autowired
|
||||||
|
@GetMapping("/geodatalist/AirTemperatureDates0")
|
||||||
|
@ResponseBody
|
||||||
|
public String getGeoDataList0(HttpServletResponse response) {
|
||||||
|
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();
|
||||||
|
response.addHeader("Cache-Control", headerValue);
|
||||||
|
|
||||||
|
String html="";
|
||||||
|
html+="<a href=\"./geodatalist/AirTemperatureDates\">AirTemperatureDates</a><br><form action=\"./AirTemperature\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"20240420\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
||||||
|
html+="<a href=\"./geodatalist/PrecipitationDates\">PrecipitationDates</a><br><form action=\"./Precipitation\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"\"20240420\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
||||||
|
html+="<a href=\"./geodatalist/SoilDates\">SoilDates</a><br><form action=\"./DownloadSoil\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"\"20240420\"><label for=\"forecast\">Forecast:</label><input type=\"text\" name=\"forecast\" value=\"000\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
//List of "Air temperature" dates from database in JSON
|
//List of "Air temperature" dates from database in JSON
|
||||||
//@CacheControl(maxAge = 300)
|
//@CacheControl(maxAge = 300)
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RequestMapping(value = "/geodatalist/AirTemperatureDates",method = RequestMethod.GET,produces = "text/html;charset=UTF-8")
|
@RequestMapping(value = "/geodatalist/AirTemperatureDates",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object ajaxAirDates(HttpServletResponse response) {
|
public Object ajaxAirDates(HttpServletResponse response) {
|
||||||
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();
|
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();
|
||||||
response.addHeader("Cache-Control", headerValue);
|
response.addHeader("Cache-Control", headerValue);
|
||||||
|
|
||||||
boolean error=false;
|
|
||||||
String result="";
|
String result="";
|
||||||
|
|
||||||
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all);
|
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all);
|
||||||
|
|
||||||
if(!error)
|
if(conn_all!=null)
|
||||||
{
|
{
|
||||||
Statement st_all;
|
Statement st_all;
|
||||||
try {
|
try {
|
||||||
|
|||||||
64
src/main/java/org/ccalm/weather/DBTools.java
Normal file
64
src/main/java/org/ccalm/weather/DBTools.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package org.ccalm.weather;
|
||||||
|
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class DBTools {
|
||||||
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(DBTools.class);
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
public static String getCountryId(Statement st,double lon,double lat) {
|
||||||
|
String country_id = "";
|
||||||
|
try {
|
||||||
|
String sql = "select c.id from main.countries c where del=false and ST_Contains(c.geom,ST_SetSRID(st_makepoint(" + lon + "," + lat + "),4326)) limit 1";
|
||||||
|
try (ResultSet rs = st.executeQuery(sql)) {
|
||||||
|
if (rs.next()) {
|
||||||
|
country_id = rs.getString(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
logger.error("N9: " + ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
return country_id;
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
public static String getPointId(Statement st, String country_id, double lon, double lat) {
|
||||||
|
String point_id = "";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try {
|
||||||
|
String sql = "SELECT id FROM main.points WHERE lon = ? AND lat = ? LIMIT 1";
|
||||||
|
pstmt = st.getConnection().prepareStatement(sql);
|
||||||
|
pstmt.setDouble(1, lon);
|
||||||
|
pstmt.setDouble(2, lat);
|
||||||
|
try (ResultSet rs = pstmt.executeQuery()) {
|
||||||
|
if (rs.next()) {
|
||||||
|
point_id = rs.getString(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
logger.error("N9: " + ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
if(point_id.isEmpty()){
|
||||||
|
try {
|
||||||
|
String sql = "insert into main.points(country_id,geom,lon,lat)values(?,ST_SetSRID(st_makepoint(?,?),4326),?,?) RETURNING id";
|
||||||
|
pstmt = st.getConnection().prepareStatement(sql);
|
||||||
|
pstmt.setLong(1, Long.valueOf(country_id));
|
||||||
|
pstmt.setDouble(2, lon);
|
||||||
|
pstmt.setDouble(3, lat);
|
||||||
|
pstmt.setDouble(4, lon);
|
||||||
|
pstmt.setDouble(5, lat);
|
||||||
|
try (ResultSet rs = pstmt.executeQuery()) {
|
||||||
|
if (rs.next()) {
|
||||||
|
point_id = rs.getString(1); // Получаем ID, возвращаемый SQL-запросом
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
logger.error("N11: " + ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,7 +16,7 @@ public class MainController {
|
|||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getIndex(Model model) {
|
public String getIndex(Model model) {
|
||||||
return "The weather list is working! <br><a href=\"./geodatalist/\">/geodatalist/</a>";
|
return "The weather list is working! <br><a href=\"./geodatalist\">/geodatalist</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@ -24,9 +24,9 @@ public class MainController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getGeoDataList(Model model) {
|
public String getGeoDataList(Model model) {
|
||||||
String html="";
|
String html="";
|
||||||
html+="<a href=\"./AirTemperatureDates\">AirTemperatureDates</a><br><form action=\"./AirTemperature\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"20240420\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
html+="<a href=\"/geodatalist/AirTemperatureDates\">AirTemperatureDates</a><br><form action=\"./AirTemperature\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"20240420\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
||||||
html+="<a href=\"./PrecipitationDates\">PrecipitationDates</a><br><form action=\"./Precipitation\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"\"20240420\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
html+="<a href=\"/geodatalist/PrecipitationDates\">PrecipitationDates</a><br><form action=\"./Precipitation\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"\"20240420\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
||||||
html+="<a href=\"./SoilDates\">SoilDates</a><br><form action=\"./DownloadSoil\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"\"20240420\"><label for=\"forecast\">Forecast:</label><input type=\"text\" name=\"forecast\" value=\"000\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
html+="<a href=\"/geodatalist/SoilDates\">SoilDates</a><br><form action=\"./DownloadSoil\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"\"20240420\"><label for=\"forecast\">Forecast:</label><input type=\"text\" name=\"forecast\" value=\"000\"><input type=\"submit\" value=\"Submit\"></form><br>";
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,11 +5,7 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.sql.Connection;
|
import java.sql.*;
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -20,7 +16,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
@ -98,26 +95,6 @@ public class Precipitation implements ServletContextAware {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
public String getCountryId(Statement st,double lon,double lat) {
|
|
||||||
String country_id = "";
|
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
|
||||||
rs = st.executeQuery("select c.id from main.countries c where del=false and ST_Contains(c.geom,ST_SetSRID(st_makepoint(" + lon + "," + lat + "),4326)) limit 1");
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
logger.error("N9: " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
if (rs != null) {
|
|
||||||
try {
|
|
||||||
if (rs.next())
|
|
||||||
country_id = rs.getString(1);
|
|
||||||
rs.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
logger.error("N10: " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return country_id;
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
public Connection getConn(String url, String login,String password){
|
public Connection getConn(String url, String login,String password){
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try{
|
try{
|
||||||
@ -352,23 +329,53 @@ public class Precipitation implements ServletContextAware {
|
|||||||
String country_id="";
|
String country_id="";
|
||||||
boolean db_all=false,db_ru=false;
|
boolean db_all=false,db_ru=false;
|
||||||
if(country_id.isEmpty()) {
|
if(country_id.isEmpty()) {
|
||||||
country_id = getCountryId(st_all, lon, lat);
|
country_id = DBTools.getCountryId(st_all, lon, lat);
|
||||||
if(!country_id.isEmpty()) db_all=true;
|
if(!country_id.isEmpty()) db_all=true;
|
||||||
}
|
}
|
||||||
if(country_id.isEmpty()) {
|
if(country_id.isEmpty()) {
|
||||||
country_id = getCountryId(st_ru, lon, lat);
|
country_id = DBTools.getCountryId(st_ru, lon, lat);
|
||||||
if(!country_id.isEmpty()) db_ru=true;
|
if(!country_id.isEmpty()) db_ru=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
|
||||||
try {
|
try {
|
||||||
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+"));";
|
String sql= """
|
||||||
if(db_all)
|
insert into main.precipitation(
|
||||||
st_all.executeUpdate(sql);
|
val,
|
||||||
if(db_ru)
|
country_id,
|
||||||
st_ru.executeUpdate(sql);
|
point_id,
|
||||||
|
air_temperature_date_id
|
||||||
|
)values(
|
||||||
|
?,
|
||||||
|
?,
|
||||||
|
?,
|
||||||
|
main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||||
|
);
|
||||||
|
""";
|
||||||
|
String point_id="";
|
||||||
|
if(db_all) {
|
||||||
|
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(db_ru) {
|
||||||
|
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
|
||||||
|
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) {
|
} catch (SQLException ex) {
|
||||||
logger.error("N10:"+ex.getMessage(),ex);
|
logger.error("N10:"+ex.getMessage(),ex);
|
||||||
throw new Exception("Failed insert precipitation...");
|
throw new Exception("Failed insert precipitation...");
|
||||||
@ -383,16 +390,15 @@ 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="update main.precipitation w set country_id=null 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 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);";
|
||||||
st_all.executeUpdate(sql);
|
st_all.executeUpdate(sql);
|
||||||
st_ru.executeUpdate(sql);
|
st_ru.executeUpdate(sql);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logger.error("N11:"+ex.getMessage(),ex);
|
logger.error("N11:"+ex.getMessage(),ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete values where country_id is null
|
|
||||||
try {
|
try {
|
||||||
String sql="delete from main.precipitation where country_id is null;";
|
String sql="delete from main.points where country_id is null;";
|
||||||
st_all.executeUpdate(sql);
|
st_all.executeUpdate(sql);
|
||||||
st_ru.executeUpdate(sql);
|
st_ru.executeUpdate(sql);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -423,19 +429,18 @@ public class Precipitation implements ServletContextAware {
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//List of "Air temperature" dates from database in JSON
|
//List of "Air temperature" dates from database in JSON
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RequestMapping(value = "/geodatalist/PrecipitationDates",method = RequestMethod.GET,produces = "text/html;charset=UTF-8")
|
@RequestMapping(value = "/geodatalist/PrecipitationDates",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object ajaxAirDates(HttpServletResponse response) {
|
public Object ajaxAirDates(HttpServletResponse response) {
|
||||||
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();
|
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();
|
||||||
response.addHeader("Cache-Control", headerValue);
|
response.addHeader("Cache-Control", headerValue);
|
||||||
|
|
||||||
boolean error=false;
|
|
||||||
String result="";
|
String result="";
|
||||||
|
|
||||||
//Load DB configuration from "config.xml"
|
//Load DB configuration from "config.xml"
|
||||||
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all);
|
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all);
|
||||||
|
|
||||||
if(!error)
|
if(conn_all!=null)
|
||||||
{
|
{
|
||||||
Statement st_all=null;
|
Statement st_all=null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -17,7 +18,8 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
@ -89,26 +91,6 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
public String getCountryId(Statement st,double lon,double lat) {
|
|
||||||
String country_id = "";
|
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
|
||||||
rs = st.executeQuery("select c.id from main.countries c where del=false and ST_Contains(c.geom,ST_SetSRID(st_makepoint(" + lon + "," + lat + "),4326)) limit 1");
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
logger.error("N9: " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
if (rs != null) {
|
|
||||||
try {
|
|
||||||
if (rs.next())
|
|
||||||
country_id = rs.getString(1);
|
|
||||||
rs.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
logger.error("N10: " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return country_id;
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
public static String CutBeforeFirst(StringBuffer str,String ch)
|
public static String CutBeforeFirst(StringBuffer str,String ch)
|
||||||
{
|
{
|
||||||
int pos=str.indexOf(ch);
|
int pos=str.indexOf(ch);
|
||||||
@ -366,18 +348,17 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
String country_id="";
|
String country_id="";
|
||||||
boolean db_all=false,db_ru=false;
|
boolean db_all=false,db_ru=false;
|
||||||
if(country_id.isEmpty()) {
|
if(country_id.isEmpty()) {
|
||||||
country_id = getCountryId(st_all, lon, lat);
|
country_id = DBTools.getCountryId(st_all, lon, lat);
|
||||||
if(!country_id.isEmpty()) db_all=true;
|
if(!country_id.isEmpty()) db_all=true;
|
||||||
}
|
}
|
||||||
if(country_id.isEmpty()) {
|
if(country_id.isEmpty()) {
|
||||||
country_id = getCountryId(st_ru, lon, lat);
|
country_id = DBTools.getCountryId(st_ru, lon, lat);
|
||||||
if(!country_id.isEmpty()) db_ru=true;
|
if(!country_id.isEmpty()) db_ru=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!country_id.isEmpty() && !country_id.equals("null"))
|
if(!country_id.isEmpty() && !country_id.equals("null"))
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
+++++++
|
|
||||||
String sql="""
|
String sql="""
|
||||||
insert into main.soil_temperature(
|
insert into main.soil_temperature(
|
||||||
val,
|
val,
|
||||||
@ -387,29 +368,32 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
)values(
|
)values(
|
||||||
?,
|
?,
|
||||||
?,
|
?,
|
||||||
main.get_point_id(?,?,?),
|
?,
|
||||||
"+country_id+",
|
main.get_soil_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||||
main.get_soil_temperature_date(cast(to_timestamp('"+date+" "+time+"', 'YYYYMMDD HH24') as timestamp without time zone),"+forecast+")
|
|
||||||
);
|
);
|
||||||
""";
|
""";
|
||||||
|
String point_id="";
|
||||||
if(db_all) {
|
if(db_all) {
|
||||||
|
point_id = DBTools.getPointId(st_all, country_id, lon, lat);
|
||||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||||
// Устанавливаем параметры в PreparedStatement
|
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos)); // val
|
pstmt.setLong(2, Long.valueOf(country_id));
|
||||||
pstmt.setLong(2, country_id); // country_id
|
pstmt.setLong(3, Long.valueOf(point_id));
|
||||||
|
pstmt.setString(4, date+" "+time);
|
||||||
pstmt.setString(2, lon); // lon
|
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||||
pstmt.setString(3, lat); // lat
|
|
||||||
|
|
||||||
pstmt.setString(5, date); // date
|
|
||||||
pstmt.setString(6, time); // time
|
|
||||||
pstmt.setInt(7, forecast); // forecast
|
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(db_ru) {
|
if(db_ru) {
|
||||||
st_ru.executeUpdate(sql);
|
point_id = DBTools.getPointId(st_ru, country_id, lon, lat);
|
||||||
|
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) {
|
} catch (SQLException ex) {
|
||||||
logger.error("N11: "+ex.getMessage(),ex);
|
logger.error("N11: "+ex.getMessage(),ex);
|
||||||
@ -425,16 +409,15 @@ 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="update main.soil_temperature w set country_id=null 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 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);";
|
||||||
st_all.executeUpdate(sql);
|
st_all.executeUpdate(sql);
|
||||||
st_ru.executeUpdate(sql);
|
st_ru.executeUpdate(sql);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logger.error("N12: "+ex.getMessage(),ex);
|
logger.error("N12: "+ex.getMessage(),ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete values where country_id is null
|
|
||||||
try {
|
try {
|
||||||
String sql="delete from main.soil_temperature where country_id is null;";
|
String sql="delete from main.points where country_id is null;";
|
||||||
st_all.executeUpdate(sql);
|
st_all.executeUpdate(sql);
|
||||||
st_ru.executeUpdate(sql);
|
st_ru.executeUpdate(sql);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -465,19 +448,17 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//List of "Soil temperature" dates from database in JSON
|
//List of "Soil temperature" dates from database in JSON
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RequestMapping(value = "/geodatalist/SoilDates",method = RequestMethod.GET,produces = "text/html;charset=UTF-8")
|
@RequestMapping(value = "/geodatalist/SoilDates",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object ajaxSoilDates(HttpServletResponse response) {
|
public Object ajaxSoilDates(HttpServletResponse response) {
|
||||||
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();
|
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();
|
||||||
response.addHeader("Cache-Control", headerValue);
|
response.addHeader("Cache-Control", headerValue);
|
||||||
|
|
||||||
boolean error=false;
|
|
||||||
String result="";
|
String result="";
|
||||||
|
|
||||||
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all);
|
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all);
|
||||||
//Connection conn_ru = getConn(db_url_ru,db_login_ru,db_password_ru);
|
|
||||||
|
|
||||||
if(!error)
|
if(conn_all!=null)
|
||||||
{
|
{
|
||||||
Statement st;
|
Statement st;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user