Merge branch 'develop' of https://git.ccalm.org/igor/org.ccalm.main into develop
This commit is contained in:
@ -2563,14 +2563,16 @@ public class AcceptASDCController implements ServletContextAware {
|
|||||||
String sql;
|
String sql;
|
||||||
|
|
||||||
if(pN.equals("frmlocustdel_locations") && days>0 && country_id>0){
|
if(pN.equals("frmlocustdel_locations") && days>0 && country_id>0){
|
||||||
|
sql = "select fldl.* from main.frmlocustdel_locations fldl join main.frmlocustdel fld on main.strtouuid(fld.uid)=main.strtouuid(fldl.frmlocustdel_uid) where fld.date>now()-interval '"+String.valueOf(days)+" days' and fld.country_id="+String.valueOf(country_id)+" and fld.device_id!='"+device_id+"' order by fldl.seq";
|
||||||
//sql = "select fldl.* from main.frmlocustdel_locations fldl join main.frmlocustdel fld on main.strtouuid(fld.uid)=main.strtouuid(fldl.frmlocustdel_uid) where fld.date>now()-interval '"+String.valueOf(days)+" days' and fld.country_id="+String.valueOf(country_id)+" and fldl.seq>"+pS+" and fld.device_id!='"+device_id+"' order by fldl.seq";
|
//sql = "select fldl.* from main.frmlocustdel_locations fldl join main.frmlocustdel fld on main.strtouuid(fld.uid)=main.strtouuid(fldl.frmlocustdel_uid) where fld.date>now()-interval '"+String.valueOf(days)+" days' and fld.country_id="+String.valueOf(country_id)+" and fldl.seq>"+pS+" and fld.device_id!='"+device_id+"' order by fldl.seq";
|
||||||
sql = "select fldl.* from main.frmlocustdel_locations fldl join main.frmlocustdel fld on main.strtouuid(fld.uid)=main.strtouuid(fldl.frmlocustdel_uid) where fld.date>now()-interval '"+String.valueOf(days)+" days' and fld.country_id="+String.valueOf(country_id)+" and fldl.seq>"+pS+" order by fldl.seq"; //TODO удалить
|
//sql = "select fldl.* from main.frmlocustdel_locations fldl join main.frmlocustdel fld on main.strtouuid(fld.uid)=main.strtouuid(fldl.frmlocustdel_uid) where fld.date>now()-interval '"+String.valueOf(days)+" days' and fld.country_id="+String.valueOf(country_id)+" and fldl.seq>"+pS+" order by fldl.seq"; //TODO удалить
|
||||||
}else
|
}else
|
||||||
if(pN.equals("frmlocustdel") && days>0 && country_id>0){
|
if(pN.equals("frmlocustdel") && days>0 && country_id>0){
|
||||||
Map<String, String> fields = TCTableTools.getTableSchema(conn, "main.frmlocustdel");
|
Map<String, String> fields = TCTableTools.getTableSchema(conn, "main.frmlocustdel");
|
||||||
STools.delFromMapByValue(fields, "geometry"); //Исключаем поля с типом геометрия, SQLite в android их не понимает
|
STools.delFromMapByValue(fields, "geometry"); //Исключаем поля с типом геометрия, SQLite в android их не понимает
|
||||||
|
sql = "select "+String.join(", ", fields.keySet())+" from main.frmlocustdel where date>now()-interval '"+String.valueOf(days)+" days' and country_id="+String.valueOf(country_id)+" and device_id!='"+device_id+"' order by seq";
|
||||||
//sql = "select "+String.join(", ", fields.keySet())+" from main.frmlocustdel where date>now()-interval '"+String.valueOf(days)+" days' and country_id="+String.valueOf(country_id)+" and seq>"+pS+" and device_id!='"+device_id+"' order by seq";
|
//sql = "select "+String.join(", ", fields.keySet())+" from main.frmlocustdel where date>now()-interval '"+String.valueOf(days)+" days' and country_id="+String.valueOf(country_id)+" and seq>"+pS+" and device_id!='"+device_id+"' order by seq";
|
||||||
sql = "select "+String.join(", ", fields.keySet())+" from main.frmlocustdel where date>now()-interval '"+String.valueOf(days)+" days' and country_id="+String.valueOf(country_id)+" and seq>"+pS+" order by seq"; //TODO удалить
|
//sql = "select "+String.join(", ", fields.keySet())+" from main.frmlocustdel where date>now()-interval '"+String.valueOf(days)+" days' and country_id="+String.valueOf(country_id)+" and seq>"+pS+" order by seq"; //TODO удалить
|
||||||
}else
|
}else
|
||||||
if(pN.equals("_translations"))
|
if(pN.equals("_translations"))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,395 +0,0 @@
|
|||||||
package org.ccalm.main;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
//import java.io.FileInputStream;
|
|
||||||
//import java.io.OutputStream;
|
|
||||||
//import java.io.UnsupportedEncodingException;
|
|
||||||
//import java.nio.file.Paths;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Properties;
|
|
||||||
//import java.util.zip.CRC32;
|
|
||||||
//import java.util.zip.Checksum;
|
|
||||||
|
|
||||||
//import javax.servlet.ServletContext;
|
|
||||||
//import javax.servlet.http.Part;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
|
|
||||||
import jakarta.servlet.ServletContext;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
//import org.apache.commons.io.FileUtils;
|
|
||||||
//import org.springframework.core.io.FileSystemResource;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
//import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
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.context.ServletContextAware;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import tools.User;
|
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class AcceptEXCEL implements ServletContextAware {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AcceptEXCEL.class);
|
|
||||||
|
|
||||||
private ServletContext context;
|
|
||||||
|
|
||||||
@Value("${spring.datasource.url}")
|
|
||||||
String db_url="";
|
|
||||||
@Value("${spring.datasource.username}")
|
|
||||||
String db_login="";
|
|
||||||
@Value("${spring.datasource.password}")
|
|
||||||
String db_password="";
|
|
||||||
@Value("${data.dir}")
|
|
||||||
String data_dir = "";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setServletContext(ServletContext context) {
|
|
||||||
this.context=context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = {"/AcceptCSV", "/api/locust/v01/"}, method = { RequestMethod.GET, RequestMethod.POST })
|
|
||||||
public String acceptCSV(@ModelAttribute User user, Model model,@RequestParam(required=false,name="file") MultipartFile file,@RequestParam(required=false,name="skip",defaultValue = "0") Boolean skip) {
|
|
||||||
|
|
||||||
Connection conn = null;
|
|
||||||
try {
|
|
||||||
Class.forName("org.postgresql.Driver");
|
|
||||||
conn = DriverManager.getConnection(db_url, db_login, db_password);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
String sqlData="";
|
|
||||||
String json="{\"type\": \"FeatureCollection\",\"features\":[";
|
|
||||||
|
|
||||||
|
|
||||||
String table="<table border=\"1\">";
|
|
||||||
table+="<tr style=\"background-color: #e0e0e0;\"><th>№</th><th>Latitude (Широта)</th><th>Longitude (Долгота)</th><th>Oblast (область)</th><th>District (Район)</th><th>Сельский округ</th><th>Хозяйство или местность</th><th>Вид саранчи</th><th>Фаза</th><th>ЭПВ</th><th>Заселено Га</th><th>Дата</th></tr>";
|
|
||||||
|
|
||||||
//row+="<td>"+i+"</td><td>"+locust.lat+"</td><td>"+locust.lon+"</td><td>"+locust.region+" = "+locust.region_id+"</td><td>"+locust.district+" = "+locust.district_id+"</td><td>"+locust.terrain+"</td><td>"+locust.village+"<td>";
|
|
||||||
|
|
||||||
if (file!=null && !file.isEmpty()) {
|
|
||||||
|
|
||||||
BufferedReader reader;
|
|
||||||
try {
|
|
||||||
int i=1; //for testing
|
|
||||||
|
|
||||||
reader = new BufferedReader(new InputStreamReader(file.getInputStream(), "UTF-8"));
|
|
||||||
//reader = new BufferedReader(new FileReader(file));
|
|
||||||
|
|
||||||
String line = reader.readLine();
|
|
||||||
if(skip) line = reader.readLine();
|
|
||||||
while (line != null) {
|
|
||||||
|
|
||||||
StringBuffer data=new StringBuffer(line);
|
|
||||||
Boolean error=false;
|
|
||||||
|
|
||||||
Locust locust = new Locust();
|
|
||||||
try {
|
|
||||||
String lat=CutBeforeFirst(data,";");
|
|
||||||
if(lat.equals("46.3104.6")) lat="46.31046";
|
|
||||||
if(lat.equals("43.21303.")) lat="43.21303";
|
|
||||||
if(lat.equals("43.26067.")) lat="43.26067";
|
|
||||||
if(lat.equals("43.20181.")) lat="43.20181";
|
|
||||||
if(lat.equals("43.20181.")) lat="43.20181";
|
|
||||||
if(lat.equals("43.74691.")) lat="43.74691";
|
|
||||||
if(lat.equals("43.41954.")) lat="43.41954";
|
|
||||||
if(lat.equals("43.78288.")) lat="43.78288";
|
|
||||||
if(lat.equals("43.26260.")) lat="43.26260";
|
|
||||||
if(lat.equals("43.79702.")) lat="43.79702";
|
|
||||||
if(lat.equals("43.64891.")) lat="43.64891";
|
|
||||||
if(lat.equals("43.64891.")) lat="43.64891";
|
|
||||||
if(lat.equals("43.42271.")) lat="43.42271";
|
|
||||||
if(lat.equals("43.64891.")) lat="43.64891";
|
|
||||||
if(lat.equals("43.89990.")) lat="43.89990";
|
|
||||||
if(lat.equals("43.96273.")) lat="43.96273";
|
|
||||||
if(lat.equals("43.26907.")) lat="43.26907";
|
|
||||||
if(lat.equals("43.26630.")) lat="43.26630";
|
|
||||||
if(lat.equals("43.50605.")) lat="43.50605";
|
|
||||||
if(lat.equals("43.74965.")) lat="43.74965";
|
|
||||||
if(lat.equals("43.20813.")) lat="43.20813";
|
|
||||||
if(lat.equals("43.23298.")) lat="43.23298";
|
|
||||||
if(lat.equals("43.74774.")) lat="43.74774";
|
|
||||||
if(lat.equals("43.77144.")) lat="43.77144";
|
|
||||||
if(lat.equals("43.58847.")) lat="43.58847";
|
|
||||||
if(lat.equals("43.58944.")) lat="43.58944";
|
|
||||||
if(lat.equals("4342755.")) lat="43.42755";
|
|
||||||
if(lat.equals("43.80416.")) lat="43.80416";
|
|
||||||
if(lat.equals("43.79536.")) lat="43.79536";
|
|
||||||
if(lat.equals("50.75 767")) lat="50.75767";
|
|
||||||
if(lat.equals("50.77 542")) lat="50.77542";
|
|
||||||
if(lat.equals("50.85 140")) lat="50.85140";
|
|
||||||
if(lat.equals("50.79 773")) lat="50.79773";
|
|
||||||
if(lat.equals("50.63 469")) lat="50.63469";
|
|
||||||
if(lat.equals("51.23 130")) lat="51.23130";
|
|
||||||
if(lat.equals("51.03 220")) lat="51.03220";
|
|
||||||
if(lat.equals("51.38 922")) lat="51.38922";
|
|
||||||
if(lat.equals("51.06.940")) lat="51.06940";
|
|
||||||
if(lat.equals("51.08 273")) lat="51.08273";
|
|
||||||
if(lat.equals("50.96 705")) lat="50.96705";
|
|
||||||
if(lat.equals("51.03 021")) lat="51.03021";
|
|
||||||
if(lat.equals("51.01 764")) lat="51.01764";
|
|
||||||
if(lat.equals("50.99 388")) lat="50.99388";
|
|
||||||
if(lat.equals("50.50 509")) lat="50.50509";
|
|
||||||
if(lat.equals("43.109.94")) lat="43.10994";
|
|
||||||
if(lat.equals("50.11.926")) lat="50.11926";
|
|
||||||
if(lat.equals("50.04.966")) lat="50.04966";
|
|
||||||
if(lat.equals("49.26.385")) lat="49.26385";
|
|
||||||
if(lat.equals("49.26.251")) lat="49.26251";
|
|
||||||
if(lat.equals("49.25.307")) lat="49.25307";
|
|
||||||
if(lat.equals("44.4930.")) lat="49.25307";
|
|
||||||
|
|
||||||
locust.lat=Double.parseDouble(lat);
|
|
||||||
|
|
||||||
String lon=CutBeforeFirst(data,";");
|
|
||||||
if(lon.equals("51.25 560")) lon="51.25560";
|
|
||||||
if(lon.equals("51.25 099")) lon="51.25099";
|
|
||||||
if(lon.equals("51.26 378")) lon="51.26378";
|
|
||||||
if(lon.equals("51.25 235")) lon="51.25235";
|
|
||||||
if(lon.equals("51.83 107")) lon="51.83107";
|
|
||||||
if(lon.equals("51.71 702")) lon="51.71702";
|
|
||||||
if(lon.equals("52.21 390")) lon="52.21390";
|
|
||||||
if(lon.equals("52.10 873")) lon="52.10873";
|
|
||||||
if(lon.equals("51.85 606")) lon="51.85606";
|
|
||||||
if(lon.equals("52.41 085")) lon="52.41085";
|
|
||||||
if(lon.equals("52.36 125")) lon="52.36125";
|
|
||||||
if(lon.equals("51. 56 025")) lon="51.56025";
|
|
||||||
if(lon.equals("51.56 786")) lon="51.56786";
|
|
||||||
if(lon.equals("51.57 946")) lon="51.57946";
|
|
||||||
if(lon.equals("51.16 758")) lon="51.16758";
|
|
||||||
if(lon.equals("85.09.142")) lon="85.09142";
|
|
||||||
|
|
||||||
|
|
||||||
locust.lon=Double.parseDouble(lon);
|
|
||||||
|
|
||||||
}catch(Exception ex)
|
|
||||||
{
|
|
||||||
error=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
locust.region=CutBeforeFirst(data,";");
|
|
||||||
|
|
||||||
//Выбираю ID области
|
|
||||||
Statement stt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
if(locust.region.equals("Алматинский")) locust.region="Алматинская";
|
|
||||||
if(locust.region.equals("Туркестанский")) locust.region="Туркестанская";
|
|
||||||
|
|
||||||
stt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
|
||||||
String sql_query = "select id from main.countriesregions where name like '%"+locust.region+"%';";
|
|
||||||
rs = stt.executeQuery(sql_query);
|
|
||||||
if (rs != null) {
|
|
||||||
try {
|
|
||||||
if (rs.next()) {
|
|
||||||
locust.region_id=rs.getString(1);
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
|
|
||||||
}finally {
|
|
||||||
if(rs!=null) try{rs.close();}catch(SQLException ex){}
|
|
||||||
if(stt!=null) try{stt.close();}catch(SQLException ex){}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Выбираю id региона (main.countriesdistricts)
|
|
||||||
locust.district_id="";
|
|
||||||
locust.district=CutBeforeFirst(data,";");
|
|
||||||
stt = null;
|
|
||||||
rs = null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
if(locust.district.equals("Сарканский ")) locust.district="Саркандский";
|
|
||||||
if(locust.district.equals("Уйгуский")) locust.district="Уйгурский";
|
|
||||||
if(locust.district.equals("г.Капшагай")) locust.district="Капчагайский городской округ";
|
|
||||||
if(locust.district.equals("Каратальскиий")) locust.district="Каратальский";
|
|
||||||
if(locust.district.equals("г. Талдыкорган")) locust.district="Талдыкорганский";
|
|
||||||
if(locust.district.equals("г Атырау ")) locust.district="Атырауский городской округ";
|
|
||||||
if(locust.district.equals("г. Атырау")) locust.district="Атырауский городской округ";
|
|
||||||
if(locust.district.equals("Кызылкуга")) locust.district="Кзылкогинский район";
|
|
||||||
if(locust.district.equals("Курчумский ")) locust.district="Куршимский район";
|
|
||||||
if(locust.district.equals("г.Семей")) locust.district="Семипалатинский городской округ";
|
|
||||||
if(locust.region_id.equals("4") && locust.district.equals("Жамбылский")) locust.district="Джамбулский район";
|
|
||||||
if(locust.district.equals("Т.Рыскуловский")) locust.district="Рыскуловский район";
|
|
||||||
if(locust.district.equals("Шуйский")) locust.district="Чуйский район";
|
|
||||||
if(locust.district.equals("Сарысуский")) locust.district="Сары-Суйский район";
|
|
||||||
if(locust.district.equals("Федоровский")) locust.district="Фёдоровский район";
|
|
||||||
if(locust.district.equals("Жангельдинский")) locust.district="Джангельдинский район";
|
|
||||||
if(locust.district.equals("Сырдария")) locust.district="Сырдарьинский район";
|
|
||||||
if(locust.district.equals("Кызылорда")) locust.district="Кызылординский городской округ";
|
|
||||||
if(locust.district.equals("к.Кызылорда")) locust.district="Кызылординский городской округ";
|
|
||||||
if(locust.district.equals("Аралский")) locust.district="Аральский район";
|
|
||||||
if(locust.district.equals("Шиелі")) locust.district="Шиелийский район";
|
|
||||||
if(locust.region_id.equals("11") && locust.district.equals("Аксуский")) locust.district="Аксуйский городской округ";
|
|
||||||
if(locust.region_id.equals("11") && locust.district.equals("Аксуский")) locust.district="Аксуйский городской округ";
|
|
||||||
if(locust.region_id.equals("11") && locust.district.equals("Ақсуский")) locust.district="Аксуйский городской округ";
|
|
||||||
if(locust.district.equals("Аққулы")) locust.district="Аккулинский район";
|
|
||||||
if(locust.district.equals("Аккулы")) locust.district="Аккулинский район";
|
|
||||||
if(locust.district.equals("Тереңкөл")) locust.district="Теренкольский";
|
|
||||||
if(locust.district.equals("г. Павлодар")) locust.district="Павлодарский городской округ";
|
|
||||||
if(locust.district.equals("Екибастузский")) locust.district="Экибастузский городской округ";
|
|
||||||
if(locust.district.equals("Шербактнский")) locust.district="Щербактинский район";
|
|
||||||
if(locust.district.equals("Толебиский ")) locust.district="Толебийский район";
|
|
||||||
if(locust.district.equals("г.Шымкент Абайский ")) locust.district="Шымкентский городской округ";
|
|
||||||
if(locust.district.equals("г.Шымкент Каратауский ")) locust.district="Шымкентский городской округ";
|
|
||||||
if(locust.district.equals("Баянауыл")) locust.district="Баянаул";
|
|
||||||
if(locust.district.equals("Екібастұз")) locust.district="Экибастуз";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
|
||||||
String sql_query = "select id from main.countriesdistricts where region_id="+locust.region_id+" and name like '%"+locust.district+"%';";
|
|
||||||
rs = stt.executeQuery(sql_query);
|
|
||||||
if (rs != null) {
|
|
||||||
try {
|
|
||||||
if (rs.next()) {
|
|
||||||
locust.district_id=rs.getString(1);
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
|
|
||||||
}finally {
|
|
||||||
if(rs!=null) try{rs.close();}catch(SQLException ex){}
|
|
||||||
if(stt!=null) try{stt.close();}catch(SQLException ex){}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Сельский округ
|
|
||||||
locust.terrain=CutBeforeFirst(data,";");
|
|
||||||
//Хозяйство или местность
|
|
||||||
locust.village=CutBeforeFirst(data,";");
|
|
||||||
//Вид саранчи
|
|
||||||
locust.locust=CutBeforeFirst(data,";");
|
|
||||||
locust.locust_id="";
|
|
||||||
if(locust.locust.equals(" итальянский прус")) locust.locust_id="1";
|
|
||||||
if(locust.locust.equals("итальянский прус")) locust.locust_id="1";
|
|
||||||
if(locust.locust.equals("Итальянский прус")) locust.locust_id="1";
|
|
||||||
if(locust.locust.equals("итальянский прус ")) locust.locust_id="1";
|
|
||||||
if(locust.locust.equals("Азиатская саранча")) locust.locust_id="3";
|
|
||||||
if(locust.locust.equals("азиатская саранча")) locust.locust_id="3";
|
|
||||||
if(locust.locust.equals("нестадные")) locust.locust_id="4";
|
|
||||||
if(locust.locust.equals("нестадные саранчовые")) locust.locust_id="4";
|
|
||||||
if(locust.locust.equals("Нестадные саранчевые")) locust.locust_id="4";
|
|
||||||
if(locust.locust.equals("Нестадная саранча ")) locust.locust_id="4";
|
|
||||||
if(locust.locust.equals("Нестадная саранча")) locust.locust_id="4";
|
|
||||||
if(locust.locust.equals("нестадная саранча")) locust.locust_id="4";
|
|
||||||
if(locust.locust.equals("Мароккская саранча")) locust.locust_id="2";
|
|
||||||
|
|
||||||
//фаза саранчи
|
|
||||||
locust.phase=CutBeforeFirst(data,";");
|
|
||||||
locust.locust_have="3";
|
|
||||||
if(locust.phase.equals("кубышки")) locust.locust_have="2";
|
|
||||||
if(locust.phase.equals("личинки")) locust.locust_have="3";
|
|
||||||
if(locust.phase.equals("имаго")) locust.locust_have="5";
|
|
||||||
|
|
||||||
locust.evp=CutBeforeFirst(data,";"); //ЭФП
|
|
||||||
locust.size=CutBeforeFirst(data,";"); //Заселённая площадь
|
|
||||||
locust.size=locust.size.replace(",",".");
|
|
||||||
locust.date=CutBeforeFirst(data,";"); //Дата
|
|
||||||
|
|
||||||
String row="<tr>";
|
|
||||||
if(error==true || locust.lat==0 || locust.lon==0 || locust.region_id.isEmpty() || locust.district_id.isEmpty() || locust.terrain.isEmpty() || locust.locust_id.isEmpty()) {
|
|
||||||
row="<tr style=\"background-color:red;\">";
|
|
||||||
}
|
|
||||||
row+="<td>"+i+"</td><td>"+locust.lat+"</td><td>"+locust.lon+"</td><td>"+locust.region+" = "+locust.region_id+"</td><td>"+locust.district+" = "+locust.district_id+"</td><td>"+locust.terrain+"</td><td>"+locust.village+"</td><td>"+locust.locust+" = "+locust.locust_id+"</td><td>"+locust.phase+" = "+locust.locust_have+"</td><td>"+locust.evp+"</td><td>"+locust.size+"</td><td>"+locust.date+"</td>";
|
|
||||||
row+="</tr>\n";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
table += row;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
json+=" \n{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":["+locust.lon+","+locust.lat+"]},\"properties\":{\"oblast\":\""+locust.region.replace("\"", "'")+"\",\"district\":\""+locust.district.replace("\"", "'")+"\",\"region\":\""+locust.terrain.replace("\"", "'")+"\",\"village\":\""+locust.village.replace("\"", "'")+"\",\"phase\":\""+locust.phase+"\",\"locust\":\""+locust.locust+"\",\"evp\": \""+locust.evp+"\",\"ga\": \""+locust.size+"\",\"date\": \""+locust.date+"\"}},";
|
|
||||||
|
|
||||||
sqlData+="insert into main.frmlocust(country_id,region_id,district,terrain,village,lon1,lat1,locust_type_id,locust_have,locust_populated,date)values(5,"+locust.region_id+",'"+locust.district.trim()+"','"+locust.terrain.trim()+"','"+locust.village.trim()+"',"+locust.lon+","+locust.lat+","+locust.locust_id+","+locust.locust_have+","+locust.size+",TO_DATE('"+locust.date+"','DD.MM.YYYY'));\n";
|
|
||||||
|
|
||||||
if(i>5000) break;
|
|
||||||
line=reader.readLine();
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else {
|
|
||||||
table="CSV file is empty! "+skip;
|
|
||||||
}
|
|
||||||
table += "</table>";
|
|
||||||
|
|
||||||
json=json.substring(0,json.length()-1); //Удаляю последнюю запятую
|
|
||||||
json+="\n]}";
|
|
||||||
|
|
||||||
model.addAttribute("PreviewTable",table);
|
|
||||||
model.addAttribute("PreviewGEOJSON",json);
|
|
||||||
model.addAttribute("PreviewSQL",sqlData);
|
|
||||||
|
|
||||||
return "excel";
|
|
||||||
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
public static String CutBeforeFirst(StringBuffer str,String ch)
|
|
||||||
{
|
|
||||||
int pos=str.indexOf(ch);
|
|
||||||
String result="";
|
|
||||||
if(pos==-1)
|
|
||||||
{
|
|
||||||
result.concat(str.toString());
|
|
||||||
str.delete(0,str.length());
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
result=str.substring(0,pos);
|
|
||||||
str.delete(0,pos+1);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
class Locust{
|
|
||||||
double lon;
|
|
||||||
double lat;
|
|
||||||
String region; //Область
|
|
||||||
String region_id;
|
|
||||||
|
|
||||||
String district; //Район
|
|
||||||
String district_id;
|
|
||||||
|
|
||||||
String terrain; //Название месности
|
|
||||||
|
|
||||||
String village; //Хозяйство или местность
|
|
||||||
|
|
||||||
String locust; //Вид саранчи
|
|
||||||
String locust_id; //Вид саранчи
|
|
||||||
|
|
||||||
String phase; //Фаза саранчи
|
|
||||||
String locust_have; //id Фазы саранчи
|
|
||||||
String evp; //ЭФП
|
|
||||||
String size; //Заселённая площадь
|
|
||||||
String date; //Дата
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -147,7 +147,7 @@ public class SendWarning {
|
|||||||
JSONObject tmp_air = getAirTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
JSONObject tmp_air = getAirTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
||||||
JSONObject tmp_soil = getSoilTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
JSONObject tmp_soil = getSoilTemperature(obj.getDouble("lat"),obj.getDouble("lon"));
|
||||||
|
|
||||||
if(tmp_air!=null && obj.getBoolean("warn_air")) {
|
if(tmp_air!=null && obj.getBoolean("warn_air") && !obj.isNull("temperature_air")) {
|
||||||
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
||||||
double value = obj.getDouble("temperature_air");
|
double value = obj.getDouble("temperature_air");
|
||||||
if (value < tmp_air.getDouble("value")) {
|
if (value < tmp_air.getDouble("value")) {
|
||||||
@ -169,7 +169,7 @@ public class SendWarning {
|
|||||||
.append("<body>")
|
.append("<body>")
|
||||||
.append("<div class='container'>")
|
.append("<div class='container'>")
|
||||||
.append("<h2>").append(trt.trt(true,"Warning")).append("</h2>")
|
.append("<h2>").append(trt.trt(true,"Warning")).append("</h2>")
|
||||||
.append("<p>").append(trt.trt(true,"The_soil_temperature_has_exceeded_the_set_value")).append(": ").append(value).append("</p>")
|
.append("<p>").append(trt.trt(true,"The_air_temperature_has_exceeded_the_set_value")).append(": ").append(value).append("</p>")
|
||||||
.append("<table>")
|
.append("<table>")
|
||||||
.append("<tr><th>").append(trt.trt(true,"Date")).append("</th><td>").append(tmp_air.getString("date")).append("</td></tr>")
|
.append("<tr><th>").append(trt.trt(true,"Date")).append("</th><td>").append(tmp_air.getString("date")).append("</td></tr>")
|
||||||
.append("<tr><th>").append(trt.trt(true,"Value")).append("</th><td>").append(tmp_air.getDouble("value")).append(" °C</td></tr>")
|
.append("<tr><th>").append(trt.trt(true,"Value")).append("</th><td>").append(tmp_air.getDouble("value")).append(" °C</td></tr>")
|
||||||
@ -192,7 +192,9 @@ public class SendWarning {
|
|||||||
main.frmcheckpoints
|
main.frmcheckpoints
|
||||||
set
|
set
|
||||||
warn_air=false
|
warn_air=false
|
||||||
where uid=CAST(:uid AS uuid)
|
where
|
||||||
|
uid=CAST(:uid AS uuid)
|
||||||
|
and (warn_hold!=true or warn_hold is null)
|
||||||
""";
|
""";
|
||||||
MapSqlParameterSource param = new MapSqlParameterSource();
|
MapSqlParameterSource param = new MapSqlParameterSource();
|
||||||
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
|
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
|
||||||
@ -202,7 +204,7 @@ public class SendWarning {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tmp_soil!=null && obj.getBoolean("warn_soil")) {
|
if(tmp_soil!=null && obj.getBoolean("warn_soil") && !obj.isNull("temperature_soil")) {
|
||||||
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
Translation trt=new Translation(obj.getString("short_name"),jdbcTemplate);
|
||||||
double value = obj.getDouble("temperature_soil");
|
double value = obj.getDouble("temperature_soil");
|
||||||
if (value < tmp_soil.getDouble("value")) {
|
if (value < tmp_soil.getDouble("value")) {
|
||||||
@ -247,7 +249,9 @@ public class SendWarning {
|
|||||||
main.frmcheckpoints
|
main.frmcheckpoints
|
||||||
set
|
set
|
||||||
warn_soil=false
|
warn_soil=false
|
||||||
where uid=CAST(:uid AS uuid)
|
where
|
||||||
|
uid=CAST(:uid AS uuid)
|
||||||
|
and (warn_hold!=true or warn_hold is null)
|
||||||
""";
|
""";
|
||||||
MapSqlParameterSource param = new MapSqlParameterSource();
|
MapSqlParameterSource param = new MapSqlParameterSource();
|
||||||
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
|
param.addValue("uid", obj.getString("uid"), Types.VARCHAR);
|
||||||
@ -260,6 +264,7 @@ public class SendWarning {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage(), ex);
|
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage(), ex);
|
||||||
|
result.put("error_code", 10000);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1915,7 +1915,7 @@ map.on('singleclick', function(evt){ //map.on('click', function(evt){
|
|||||||
'<span style="white-space: nowrap;"><b>' + trt('Creator') + '</b>: ' + feature.userName + '</span><br>' +
|
'<span style="white-space: nowrap;"><b>' + trt('Creator') + '</b>: ' + feature.userName + '</span><br>' +
|
||||||
'<span style="white-space: nowrap;"><b>' + trt('Radius') + '</b>: ' + feature.userRadius + 'm.</span><br>' +
|
'<span style="white-space: nowrap;"><b>' + trt('Radius') + '</b>: ' + feature.userRadius + 'm.</span><br>' +
|
||||||
'<span style="white-space: nowrap;"><b>' + trt('Want_air_temperature') + '</b>: ' + feature.userTemperature_air + '°C</span><br>' +
|
'<span style="white-space: nowrap;"><b>' + trt('Want_air_temperature') + '</b>: ' + feature.userTemperature_air + '°C</span><br>' +
|
||||||
'<span style="white-space: nowrap;"><b>' + trt('Want_soil_temperature') + '</b>: ' + feature.userTemperature_air + '°C</span>';
|
'<span style="white-space: nowrap;"><b>' + trt('Want_soil_temperature') + '</b>: ' + feature.userTemperature_soil + '°C</span>';
|
||||||
content.innerHTML += '<table style="width: 100%;border-spacing: 2px; border-collapse: separate;"><tr><td><button class="main" style="width: 100%;" onclick="g_density_larval.callData('+feature.userID+');">'+trt('Hopper_density')+'</button></td><td><button class="main" style="width: 100%;" onclick="g_density_imago.callData('+feature.userID+');">'+trt('Adult_density')+'</button></td></tr></table>';
|
content.innerHTML += '<table style="width: 100%;border-spacing: 2px; border-collapse: separate;"><tr><td><button class="main" style="width: 100%;" onclick="g_density_larval.callData('+feature.userID+');">'+trt('Hopper_density')+'</button></td><td><button class="main" style="width: 100%;" onclick="g_density_imago.callData('+feature.userID+');">'+trt('Adult_density')+'</button></td></tr></table>';
|
||||||
overlay.setPosition(coordinates);
|
overlay.setPosition(coordinates);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Select the file with CSV to upload and parsing.</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<form action="./AcceptJSON" method="post" enctype="multipart/form-data">
|
|
||||||
Select CSV UTF-8 file to upload and export:
|
|
||||||
<input type="file" name="file" id="fileToUpload"><br>
|
|
||||||
<input type="submit" value="Upload" name="submit">
|
|
||||||
</form>
|
|
||||||
<br><br>
|
|
||||||
|
|
||||||
${PreviewTable}
|
|
||||||
|
|
||||||
<!--br><br><br>
|
|
||||||
<textarea style="width: 1000px;height: 1000px;">${PreviewGEOJSON}</textarea>
|
|
||||||
<br><br><br>
|
|
||||||
<textarea style="width: 1400px;height: 1000px;">${PreviewSQL}</textarea-->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user