diff --git a/org-ccalm-main.yml b/org-ccalm-main.yml
index f49dccd..74cf477 100644
--- a/org-ccalm-main.yml
+++ b/org-ccalm-main.yml
@@ -10,8 +10,8 @@ spring:
application:
name: org-ccalm-main
datasource:
- url: jdbc:postgresql://10.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&connectTimeout=10000&socketTimeout=30000
- #url: jdbc:postgresql://ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
+ #url: jdbc:postgresql://10.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&connectTimeout=10000&socketTimeout=30000
+ url: jdbc:postgresql://ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
#url: jdbc:postgresql://127.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
username: postgres
password: 309A86FF65A78FB428F4E38DFE35F730
diff --git a/pom.xml b/pom.xml
index 88e45e9..718c34a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.ccalm
main
- 1.0.4
+ 1.0.7
main
main
diff --git a/src/main/java/org/ccalm/main/AcceptASDCController.java b/src/main/java/org/ccalm/main/AcceptASDCController.java
index 0216af1..776598f 100644
--- a/src/main/java/org/ccalm/main/AcceptASDCController.java
+++ b/src/main/java/org/ccalm/main/AcceptASDCController.java
@@ -2508,6 +2508,9 @@ public class AcceptASDCController implements ServletContextAware {
}
return result;
}
+ /**
+ * reqS - Миллисекунд сначала 1970 года
+ * */
@RequestMapping(value = {"/get/", "/api/locust/v01/get/"},params = {"fn"},method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public Object uploadFILE(HttpServletResponse response,@RequestHeader(required=false,name="Content-Type") String contentType,@RequestBody(required=false) String reqData,@RequestParam(required=false,name="file") MultipartFile file,@RequestParam(required=false,name="fn") String fn,@RequestParam(required=false,name="r") String reqR,@RequestParam(required=false,name="n") String reqN,@RequestParam(required=false,name="s") String reqS,@RequestParam(required=false,name="l") String reqL,@RequestParam(required=false,name="days",defaultValue = "0") int days,@RequestParam(required=false,name="country_id",defaultValue = "0") int country_id,@RequestParam(required=false,name="android_id",defaultValue = "") String device_id) {
@@ -2562,7 +2565,13 @@ public class AcceptASDCController implements ServletContextAware {
//if(val!=null) pR=Integer.parseInt(val);
pN = reqN;
val = reqS;
- if(val!=null) pS=Long.parseLong(val);
+ if(val!=null && !val.isEmpty()) {
+ try {
+ pS = Long.parseLong(val);
+ } catch (Exception ex) {
+ logger.error(UUID.randomUUID().toString(), ex.getMessage()+" val="+val, ex);
+ }
+ }
val = reqL;
//if(val!=null) pL=100;
@@ -3072,7 +3081,7 @@ public class AcceptASDCController implements ServletContextAware {
}
//@RequestMapping(value = {"/get", "/api/locust/v01/"},params = {"fn"},method = { RequestMethod.GET, RequestMethod.POST })
- //Для проверки какие фото есть на сервере а каких нет чтобы удалить из имена фотографий которых нет в базе
+ //Для проверки какие фото есть на сервере а каких нет чтобы удалить имена фотографий которых нет в базе
@RequestMapping(value = {"/photolist", "/api/locust/v01/"},method = RequestMethod.GET, produces = "text/html")
@ResponseBody
public Object getPhotoList() {
diff --git a/src/main/java/org/ccalm/main/QGIS.java b/src/main/java/org/ccalm/main/QGIS.java
index 5991d1a..f11e187 100644
--- a/src/main/java/org/ccalm/main/QGIS.java
+++ b/src/main/java/org/ccalm/main/QGIS.java
@@ -66,9 +66,11 @@ public class QGIS implements ServletContextAware {
// return new User("none");
//}
+ //TEST https://127.0.0.1:8083/api/locust/v01/QGIS?name=SMAP&date=2025-05-30
+ //TEST https://ccalm.org/api/locust/v01/QGIS?name=SMAP&day=150
@RequestMapping(value = {"/QGIS", "/api/locust/v01/QGIS"},method = RequestMethod.GET,produces = "application/octet-stream")
@ResponseBody
- public HttpEntity ajaxTamer(@ModelAttribute User user, @RequestParam(required=false,name="day") String day, @RequestParam(required=false,name="name") String name, @RequestParam(required=false,name="time") String time, @RequestParam(required=false,name="time_start") String time_start, @RequestParam(required=false,name="time_end") String time_end, @RequestParam(required=false,name="country_id") String country_id, @RequestParam(required=false,name="locust_type_id") String locust_type_id, @RequestParam(required=false,name="date_start") String date_start, @RequestParam(required=false,name="date_end") String date_end, @RequestParam(required=false,name="registered") String registered, @RequestParam(required=false,name="year") String year, @RequestParam(required=false,name="region_id") String region_id, @RequestParam(required=false,name="country_name") String country_name, @RequestParam(required=false,name="lng") String language_id, HttpServletResponse response)
+ public HttpEntity ajaxTamer(@ModelAttribute User user, @RequestParam(required=false,name="day") String day,@RequestParam(required=false,name="date") String date, @RequestParam(required=false,name="name") String name, @RequestParam(required=false,name="time") String time, @RequestParam(required=false,name="time_start") String time_start, @RequestParam(required=false,name="time_end") String time_end, @RequestParam(required=false,name="country_id") String country_id, @RequestParam(required=false,name="locust_type_id") String locust_type_id, @RequestParam(required=false,name="date_start") String date_start, @RequestParam(required=false,name="date_end") String date_end, @RequestParam(required=false,name="registered") String registered, @RequestParam(required=false,name="year") String year, @RequestParam(required=false,name="region_id") String region_id, @RequestParam(required=false,name="country_name") String country_name, @RequestParam(required=false,name="lng") String language_id, HttpServletResponse response)
{
if(language_id!=null && !language_id.isEmpty()) user.language_id=language_id;
logger.info("user.id="+user.id+" user.name="+user.name+" user.language_id="+user.language_id);
@@ -96,7 +98,7 @@ public class QGIS implements ServletContextAware {
//Pods (кубышки)
if(name!=null && (name.equals("frmlocust_pods_density") || name.equals("frmlocust_hoppers_density") || name.equals("frmlocust_bands") || name.equals("frmlocust_adults_density") || name.equals("frmlocust_swarms")))
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//String country_id=request.getParameter("country_id");
//String locust_type_id=request.getParameter("locust_type_id");
@@ -154,7 +156,7 @@ public class QGIS implements ServletContextAware {
if(name!=null && name.equals("frmlocustdel"))
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//String country_id=request.getParameter("country_id");
//String date_start=request.getParameter("date_start");
@@ -231,7 +233,7 @@ public class QGIS implements ServletContextAware {
sql+=" and locust_type_id="+locust_type_id;
}
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//Apply variables to text
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
fileAsString=fileAsString.replaceAll("\\$\\{sql\\}",sql);
@@ -254,7 +256,7 @@ public class QGIS implements ServletContextAware {
sql+=" and locust_type_id="+locust_type_id;
}
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//Apply variables to text
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
fileAsString=fileAsString.replaceAll("\\$\\{sql\\}",sql);
@@ -277,7 +279,7 @@ public class QGIS implements ServletContextAware {
}
}
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//Apply variables to text
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
@@ -301,7 +303,7 @@ public class QGIS implements ServletContextAware {
}
}
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//Apply variables to text
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
@@ -325,7 +327,7 @@ public class QGIS implements ServletContextAware {
}
}
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//Apply variables to text
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
@@ -349,7 +351,7 @@ public class QGIS implements ServletContextAware {
}
}
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
+ fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
//Apply variables to text
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
@@ -358,7 +360,7 @@ public class QGIS implements ServletContextAware {
}
if(name!=null && name.equals("NDVI"))
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDVI.qgs"));
+ fileAsString = fileToString("static/resources/QGIS/NDVI.qgs");
if(day!=null && day.length()>0)
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
else
@@ -366,7 +368,7 @@ public class QGIS implements ServletContextAware {
}
if(name!=null && name.equals("NDWI"))
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDWI.qgs"));
+ fileAsString = fileToString("static/resources/QGIS/NDWI.qgs");
if(day!=null && day.length()>0)
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
else
@@ -374,7 +376,7 @@ public class QGIS implements ServletContextAware {
}
if(name!=null && name.equals("IVI"))
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/IVI.qgs"));
+ fileAsString = fileToString("static/resources/QGIS/IVI.qgs");
if(year!=null && year.length()>0)
fileAsString = fileAsString.replaceAll("\\$\\{year\\}",year+"_");
else
@@ -382,7 +384,7 @@ public class QGIS implements ServletContextAware {
}
if(name!=null && name.equals("NDWI_CMP"))
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDWI_CMP.qgs"));
+ fileAsString = fileToString("static/resources/QGIS/NDWI_CMP.qgs");
if(day!=null && day.length()>0)
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
else
@@ -390,19 +392,19 @@ public class QGIS implements ServletContextAware {
}
if(name!=null && name.equals("NDSI"))
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDSI.qgs"));
+ fileAsString = fileToString("static/resources/QGIS/NDSI.qgs");
if(day!=null && day.length()>0)
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
else
fileAsString = fileAsString.replaceAll("\\$\\{day\\}","");
}
- if(name!=null && name.equals("SMAP"))
+ if(name!=null && name.equals("SMAP")) //https://127.0.0.1:8083/api/locust/v01/QGIS?name=SMAP&date=2025-05-30
{
- fileAsString = fileToString(context.getRealPath("/resources/QGIS/SMAP.qgs"));
- if(day!=null && day.length()>0)
- fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
+ fileAsString = fileToString("static/resources/QGIS/SMAP.qgs");
+ if(date!=null && !date.isEmpty())
+ fileAsString = fileAsString.replaceAll("\\$\\{date\\}",date);
else
- fileAsString = fileAsString.replaceAll("\\$\\{day\\}","");
+ fileAsString = fileAsString.replaceAll("\\$\\{date\\}","");
}
//Send data
@@ -415,27 +417,42 @@ public class QGIS implements ServletContextAware {
this.context=servletContext;
}
- public String fileToString(String fName)
- {
+
+ public String fileToString(String fName) {
StringBuilder sb = new StringBuilder(1024);
- try
- {
- InputStream is = new FileInputStream(fName);
- BufferedReader buf = new BufferedReader(new InputStreamReader(is));
- String line = buf.readLine();
- while(line != null)
- {
+
+ // 1. Сначала пробуем как внешний файл
+ try (InputStream is = new FileInputStream(fName);
+ BufferedReader buf = new BufferedReader(new InputStreamReader(is))) {
+
+ String line;
+ while ((line = buf.readLine()) != null) {
sb.append(line).append("\n");
- line = buf.readLine();
}
- buf.close();
+ return sb.toString();
+
+ } catch (Exception e) {
+ System.out.println("Не найден внешний файл, пробую искать в ресурсах: " + fName);
}
- catch (Exception e){
- System.out.println("Error: "+e.getMessage());
+
+ // 2. Если файла нет, пробуем как ресурс из classpath
+ try (InputStream is = new ClassPathResource(fName).getInputStream();
+ BufferedReader buf = new BufferedReader(new InputStreamReader(is))) {
+
+ String line;
+ while ((line = buf.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+
+ } catch (Exception e) {
+ System.out.println("Ошибка при чтении из ресурсов: " + e.getMessage());
}
+
return sb.toString();
}
+
+
public String trt(Connection conn,String key,User user)
{
String result="";