Дома поработал
This commit is contained in:
@ -6,7 +6,7 @@ server:
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: kz_mcp_weather
|
||||
name: kz_ccalm_weather
|
||||
cache:
|
||||
type: none
|
||||
|
||||
@ -16,14 +16,14 @@ custom:
|
||||
data_dir: O:\\temp\\CCALM\\
|
||||
#data_dir: /temp/CCALM/
|
||||
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://92.46.48.43:5433/weather?ApplicationName=kz_mcp_weather&sslmode=require
|
||||
login: postgres
|
||||
password: PasSecrKey1
|
||||
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: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://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
|
||||
login: postgres
|
||||
password: PasSecrKey1
|
||||
|
||||
@ -154,7 +154,7 @@ public class AirTemperature implements ServletContextAware {
|
||||
logger.error("N2:"+ex.getMessage(),ex);
|
||||
result+=ex.getMessage()+"<br>";
|
||||
}
|
||||
if(!strPos1.equals(""))
|
||||
if(!strPos1.isEmpty())
|
||||
{
|
||||
StringBuffer answer1=new StringBuffer(strPos1);
|
||||
CutBeforeFirst(answer1,":");
|
||||
@ -333,29 +333,33 @@ public class AirTemperature implements ServletContextAware {
|
||||
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) {
|
||||
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.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.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.error("N10:"+ex.getMessage(),ex);
|
||||
}
|
||||
@ -421,20 +425,6 @@ public class AirTemperature implements ServletContextAware {
|
||||
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
|
||||
//@CacheControl(maxAge = 300)
|
||||
@CrossOrigin
|
||||
|
||||
@ -26,7 +26,7 @@ public class DBTools {
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
public static String getPointId(Statement st, String country_id, double lon, double lat) {
|
||||
String point_id = "";
|
||||
String point_id = null;
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
String sql = "SELECT id FROM main.points WHERE lon = ? AND lat = ? LIMIT 1";
|
||||
@ -41,15 +41,13 @@ public class DBTools {
|
||||
} catch (SQLException ex) {
|
||||
logger.error("N9: " + ex.getMessage(), ex);
|
||||
}
|
||||
if(point_id.isEmpty()){
|
||||
if(point_id==null){
|
||||
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.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-запросом
|
||||
|
||||
@ -23,11 +23,11 @@ public class MainController {
|
||||
@GetMapping("/geodatalist")
|
||||
@ResponseBody
|
||||
public String getGeoDataList(Model model) {
|
||||
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;
|
||||
return """
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
""";
|
||||
}
|
||||
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class Precipitation implements ServletContextAware {
|
||||
logger.error("N2:"+ex.getMessage(),ex);
|
||||
result+=ex.getMessage()+"<br>";
|
||||
}
|
||||
if(!strPos1.equals(""))
|
||||
if(!strPos1.isEmpty())
|
||||
{
|
||||
StringBuffer answer1=new StringBuffer(strPos1);
|
||||
CutBeforeFirst(answer1,":");
|
||||
@ -353,29 +353,33 @@ public class Precipitation implements ServletContextAware {
|
||||
main.get_precipitation_date(cast(to_timestamp(?, 'YYYYMMDD HH24') as timestamp without time zone),?)
|
||||
);
|
||||
""";
|
||||
String point_id="";
|
||||
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.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.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.error("N10:"+ex.getMessage(),ex);
|
||||
throw new Exception("Failed insert precipitation...");
|
||||
|
||||
@ -188,7 +188,7 @@ public class SoilTmperature implements ServletContextAware {
|
||||
logger.error("N2: "+ex.getMessage(),ex);
|
||||
result+=ex.getMessage()+"<br>";
|
||||
}
|
||||
if(!strPos1.equals(""))
|
||||
if(!strPos1.isEmpty())
|
||||
{
|
||||
//String strPos1 = "250:146339365:d=2017022818:TSOIL:0-0.1 m below ground:anl:"
|
||||
StringBuffer answer1=new StringBuffer(strPos1);
|
||||
@ -372,29 +372,33 @@ public class SoilTmperature implements ServletContextAware {
|
||||
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) {
|
||||
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.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.setString(4, date + " " + time);
|
||||
pstmt.setInt(5, Integer.valueOf(forecast));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.error("N11: "+ex.getMessage(),ex);
|
||||
throw new Exception("Failed insert soil temperature...");
|
||||
|
||||
Reference in New Issue
Block a user