Дома поработал
This commit is contained in:
@ -6,7 +6,7 @@ server:
|
|||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: kz_mcp_weather
|
name: kz_ccalm_weather
|
||||||
cache:
|
cache:
|
||||||
type: none
|
type: none
|
||||||
|
|
||||||
@ -16,14 +16,14 @@ custom:
|
|||||||
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://192.168.0.90:5432/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://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
|
||||||
#url: jdbc:postgresql://92.46.48.43:5433/weather?ApplicationName=kz_mcp_weather&sslmode=require
|
|
||||||
login: postgres
|
login: postgres
|
||||||
password: PasSecrKey1
|
password: PasSecrKey1
|
||||||
db_ru:
|
db_ru:
|
||||||
url: jdbc:postgresql://192.168.0.90:5433/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://92.46.48.43:5433/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
|
#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&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
|
||||||
|
|||||||
@ -154,7 +154,7 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
logger.error("N2:"+ex.getMessage(),ex);
|
logger.error("N2:"+ex.getMessage(),ex);
|
||||||
result+=ex.getMessage()+"<br>";
|
result+=ex.getMessage()+"<br>";
|
||||||
}
|
}
|
||||||
if(!strPos1.equals(""))
|
if(!strPos1.isEmpty())
|
||||||
{
|
{
|
||||||
StringBuffer answer1=new StringBuffer(strPos1);
|
StringBuffer answer1=new StringBuffer(strPos1);
|
||||||
CutBeforeFirst(answer1,":");
|
CutBeforeFirst(answer1,":");
|
||||||
@ -333,27 +333,31 @@ public class AirTemperature implements ServletContextAware {
|
|||||||
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),?)
|
||||||
);
|
);
|
||||||
""";
|
""";
|
||||||
String point_id="";
|
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);
|
||||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
if(point_id!=null) {
|
||||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||||
pstmt.setLong(2, Long.valueOf(country_id));
|
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||||
pstmt.setLong(3, Long.valueOf(point_id));
|
pstmt.setLong(2, Long.valueOf(country_id));
|
||||||
pstmt.setString(4, date+" "+time);
|
pstmt.setLong(3, Long.valueOf(point_id));
|
||||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
pstmt.setString(4, date + " " + time);
|
||||||
pstmt.executeUpdate();
|
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
if(point_id!=null) {
|
||||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||||
pstmt.setLong(2, Long.valueOf(country_id));
|
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||||
pstmt.setLong(3, Long.valueOf(point_id));
|
pstmt.setLong(2, Long.valueOf(country_id));
|
||||||
pstmt.setString(4, date+" "+time);
|
pstmt.setLong(3, Long.valueOf(point_id));
|
||||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
pstmt.setString(4, date + " " + time);
|
||||||
pstmt.executeUpdate();
|
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -421,20 +425,6 @@ 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
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class DBTools {
|
|||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
public static String getPointId(Statement st, String country_id, double lon, double lat) {
|
public static String getPointId(Statement st, String country_id, double lon, double lat) {
|
||||||
String point_id = "";
|
String point_id = null;
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try {
|
try {
|
||||||
String sql = "SELECT id FROM main.points WHERE lon = ? AND lat = ? LIMIT 1";
|
String sql = "SELECT id FROM main.points WHERE lon = ? AND lat = ? LIMIT 1";
|
||||||
@ -41,15 +41,13 @@ public class DBTools {
|
|||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logger.error("N9: " + ex.getMessage(), ex);
|
logger.error("N9: " + ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
if(point_id.isEmpty()){
|
if(point_id==null){
|
||||||
try {
|
try {
|
||||||
String sql = "insert into main.points(country_id,geom,lon,lat)values(?,ST_SetSRID(st_makepoint(?,?),4326),?,?) RETURNING id";
|
String sql = "insert into main.points(country_id,lon,lat)values(?,?,?) RETURNING id";
|
||||||
pstmt = st.getConnection().prepareStatement(sql);
|
pstmt = st.getConnection().prepareStatement(sql);
|
||||||
pstmt.setLong(1, Long.valueOf(country_id));
|
pstmt.setLong(1, Long.valueOf(country_id));
|
||||||
pstmt.setDouble(2, lon);
|
pstmt.setDouble(2, lon);
|
||||||
pstmt.setDouble(3, lat);
|
pstmt.setDouble(3, lat);
|
||||||
pstmt.setDouble(4, lon);
|
|
||||||
pstmt.setDouble(5, lat);
|
|
||||||
try (ResultSet rs = pstmt.executeQuery()) {
|
try (ResultSet rs = pstmt.executeQuery()) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
point_id = rs.getString(1); // Получаем ID, возвращаемый SQL-запросом
|
point_id = rs.getString(1); // Получаем ID, возвращаемый SQL-запросом
|
||||||
|
|||||||
@ -23,11 +23,11 @@ public class MainController {
|
|||||||
@GetMapping("/geodatalist")
|
@GetMapping("/geodatalist")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getGeoDataList(Model model) {
|
public String getGeoDataList(Model model) {
|
||||||
String html="";
|
return """
|
||||||
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>";
|
<a href="/geodatalist/AirTemperatureDates">AirTemperatureDates</a><br><form action="/geodatalist/AirTemperature" method="get"><label for="fname">Date:</label><input type="text" name="date" value="20250107"><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>";
|
<a href="/geodatalist/PrecipitationDates">PrecipitationDates</a><br><form action="/geodatalist/Precipitation" method="get"><label for="fname">Date:</label><input type="text" name="date" value=""20250107"><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>";
|
<a href="/geodatalist/SoilDates">SoilDates</a><br><form action="/geodatalist/DownloadSoil" method="get"><label for="fname">Date:</label><input type="text" name="date" value=""20250107"><label for="forecast">Forecast:</label><input type="text" name="forecast" value="000"><input type="submit" value="Submit"></form><br>
|
||||||
return html;
|
""";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ public class Precipitation implements ServletContextAware {
|
|||||||
logger.error("N2:"+ex.getMessage(),ex);
|
logger.error("N2:"+ex.getMessage(),ex);
|
||||||
result+=ex.getMessage()+"<br>";
|
result+=ex.getMessage()+"<br>";
|
||||||
}
|
}
|
||||||
if(!strPos1.equals(""))
|
if(!strPos1.isEmpty())
|
||||||
{
|
{
|
||||||
StringBuffer answer1=new StringBuffer(strPos1);
|
StringBuffer answer1=new StringBuffer(strPos1);
|
||||||
CutBeforeFirst(answer1,":");
|
CutBeforeFirst(answer1,":");
|
||||||
@ -353,27 +353,31 @@ public class Precipitation implements ServletContextAware {
|
|||||||
main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||||
);
|
);
|
||||||
""";
|
""";
|
||||||
String point_id="";
|
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);
|
||||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
if(point_id!=null) {
|
||||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||||
pstmt.setLong(2, Long.valueOf(country_id));
|
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||||
pstmt.setLong(3, Long.valueOf(point_id));
|
pstmt.setLong(2, Long.valueOf(country_id));
|
||||||
pstmt.setString(4, date+" "+time);
|
pstmt.setLong(3, Long.valueOf(point_id));
|
||||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
pstmt.setString(4, date + " " + time);
|
||||||
pstmt.executeUpdate();
|
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
if(point_id!=null) {
|
||||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||||
pstmt.setLong(2, Long.valueOf(country_id));
|
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||||
pstmt.setLong(3, Long.valueOf(point_id));
|
pstmt.setLong(2, Long.valueOf(country_id));
|
||||||
pstmt.setString(4, date+" "+time);
|
pstmt.setLong(3, Long.valueOf(point_id));
|
||||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
pstmt.setString(4, date + " " + time);
|
||||||
pstmt.executeUpdate();
|
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
|||||||
@ -188,7 +188,7 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
logger.error("N2: "+ex.getMessage(),ex);
|
logger.error("N2: "+ex.getMessage(),ex);
|
||||||
result+=ex.getMessage()+"<br>";
|
result+=ex.getMessage()+"<br>";
|
||||||
}
|
}
|
||||||
if(!strPos1.equals(""))
|
if(!strPos1.isEmpty())
|
||||||
{
|
{
|
||||||
//String strPos1 = "250:146339365:d=2017022818:TSOIL:0-0.1 m below ground:anl:"
|
//String strPos1 = "250:146339365:d=2017022818:TSOIL:0-0.1 m below ground:anl:"
|
||||||
StringBuffer answer1=new StringBuffer(strPos1);
|
StringBuffer answer1=new StringBuffer(strPos1);
|
||||||
@ -372,27 +372,31 @@ public class SoilTmperature implements ServletContextAware {
|
|||||||
main.get_soil_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
main.get_soil_temperature_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||||
);
|
);
|
||||||
""";
|
""";
|
||||||
String point_id="";
|
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);
|
||||||
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
if(point_id!=null) {
|
||||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
try (PreparedStatement pstmt = conn_all.prepareStatement(sql)) {
|
||||||
pstmt.setLong(2, Long.valueOf(country_id));
|
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||||
pstmt.setLong(3, Long.valueOf(point_id));
|
pstmt.setLong(2, Long.valueOf(country_id));
|
||||||
pstmt.setString(4, date+" "+time);
|
pstmt.setLong(3, Long.valueOf(point_id));
|
||||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
pstmt.setString(4, date + " " + time);
|
||||||
pstmt.executeUpdate();
|
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
if(point_id!=null) {
|
||||||
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
try (PreparedStatement pstmt = conn_ru.prepareStatement(sql)) {
|
||||||
pstmt.setLong(2, Long.valueOf(country_id));
|
pstmt.setFloat(1, dataArrayTmp.getFloat(pos));
|
||||||
pstmt.setLong(3, Long.valueOf(point_id));
|
pstmt.setLong(2, Long.valueOf(country_id));
|
||||||
pstmt.setString(4, date+" "+time);
|
pstmt.setLong(3, Long.valueOf(point_id));
|
||||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
pstmt.setString(4, date + " " + time);
|
||||||
pstmt.executeUpdate();
|
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user