|
|
@@ -77,6 +77,58 @@ public class DataImp implements DataService {
|
|
|
System.out.println("JavaFX 应用启动中...");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RequestResult upload(MultipartFile file) {
|
|
|
+ String currentTime = CustomUtils.getCurrentTime();
|
|
|
+ String currentPath = localFilePath + "/" + currentTime + "/";
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
|
+ if (StringUtils.isEmpty(username)) {
|
|
|
+ username = "admin";
|
|
|
+ }
|
|
|
+ String shpPath = "";
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String filetype = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
+ String filename = fileName.replace(filetype, "").replace(".", "");
|
|
|
+ if (!filetype.equals("zip") && !filetype.equals("rar")) {
|
|
|
+ return RequestResult.error("请上传zip/rar压缩包文件", null);
|
|
|
+ }
|
|
|
+ String filepath = currentPath + "" + fileName;
|
|
|
+ File dest = new File(filepath);
|
|
|
+ File dir = dest.getParentFile();
|
|
|
+ if (!dir.exists()) {
|
|
|
+ dir.mkdirs();
|
|
|
+ }
|
|
|
+ String unzippath = currentPath;
|
|
|
+ try {
|
|
|
+ //上传文件
|
|
|
+ file.transferTo(dest);
|
|
|
+ //解压zip格式
|
|
|
+ if (filetype.equals("zip")) {
|
|
|
+ new UnPackageUtils().unPackZip(dest, unzippath);
|
|
|
+ } else {
|
|
|
+ //解压rar格式
|
|
|
+ new UnPackageUtils().unPackRar(dest, unzippath);
|
|
|
+ }
|
|
|
+ File[] files = new File(unzippath).listFiles();
|
|
|
+ for (File file1 : files) {
|
|
|
+ if (file1.getAbsolutePath().substring(file1.getAbsolutePath().lastIndexOf(".") + 1).equals("shp")) {
|
|
|
+ shpPath = file1.getAbsolutePath();
|
|
|
+ shpPath = shpPath.replaceAll("\\\\", "/");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!"".equals(shpPath)) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return RequestResult.error("未检索到shp文件");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return RequestResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+ return RequestResult.success("上传成功", shpPath);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RequestResult importIn(MultipartFile file, String path, String type, String name, String ufield, String style) {
|
|
|
if (StringUtils.isEmpty(style)) {
|
|
|
@@ -206,7 +258,10 @@ public class DataImp implements DataService {
|
|
|
} catch (Exception w) {
|
|
|
w.printStackTrace();
|
|
|
}
|
|
|
- return RequestResult.success("上传成功", tablename);
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("tablename", tablename);
|
|
|
+ result.put("path", shpPath);
|
|
|
+ return RequestResult.success("上传成功", result);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -294,7 +349,7 @@ public class DataImp implements DataService {
|
|
|
String layername = (String) curObj.get("layername");
|
|
|
String isvalid = (String) curObj.get("isvalid");
|
|
|
String type = (String) curObj.get("type");
|
|
|
- String insertSQL = "insert into t_model (layername , type, index , isvalid, modelname) values ('" + layername + "' , '" + type + "', " + i + " , '" + isvalid + "', '" + modelname + "')";
|
|
|
+ String insertSQL = "insert into t_model (layername , type, \"index\" , isvalid, modelname) values ('" + layername + "' , '" + type + "', " + i + " , '" + isvalid + "', '" + modelname + "')";
|
|
|
statement.execute(insertSQL);
|
|
|
}
|
|
|
connection.close();
|
|
|
@@ -627,6 +682,29 @@ public class DataImp implements DataService {
|
|
|
return RequestResult.error("查询失败!", null);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RequestResult getServerConfig(String key) {
|
|
|
+ try {
|
|
|
+ Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
|
|
|
+ Statement statement = connection.createStatement();
|
|
|
+ String querySQL = "select * from t_geoserver limit 1";
|
|
|
+ ResultSet resultSet = statement.executeQuery(querySQL);
|
|
|
+ Map res = new HashMap();
|
|
|
+ ResultSetMetaData metaData = resultSet.getMetaData();
|
|
|
+ int columnCount = metaData.getColumnCount();
|
|
|
+ for (int i = 1; i <= columnCount; i++) {
|
|
|
+ String columnName = metaData.getColumnLabel(i); // 获取列名
|
|
|
+ Object columnValue = resultSet.getString(i); // 获取列值
|
|
|
+ res.put(columnName, columnValue);
|
|
|
+ }
|
|
|
+ connection.close();
|
|
|
+ return RequestResult.success("查询成功!", res);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return RequestResult.error("查询失败!", null);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RequestResult getGeoServerStyles() {
|
|
|
try {
|
|
|
@@ -664,6 +742,25 @@ public class DataImp implements DataService {
|
|
|
return RequestResult.error("失败!", null);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RequestResult updateServerConfig(HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ JSONObject parameters = (JSONObject) new JSONParser().parse(request.getReader());
|
|
|
+ Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
|
|
|
+ Statement statement = connection.createStatement();
|
|
|
+ for (Object name : parameters.keySet()) {
|
|
|
+ Object value = parameters.get(name);
|
|
|
+ String updateSQL = "update t_geoserver set " + name + " = '" + (String) value + "'";
|
|
|
+ statement.execute(updateSQL);
|
|
|
+ }
|
|
|
+ connection.close();
|
|
|
+ return RequestResult.success("修改成功!", 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return RequestResult.error("失败!", null);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RequestResult overlapAnalysis(String modelname, String tablename) {
|
|
|
try {
|
|
|
@@ -866,6 +963,34 @@ public class DataImp implements DataService {
|
|
|
return RequestResult.success("导出成功", 1);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RequestResult getAnalyseResult(String tablename) {
|
|
|
+ try {
|
|
|
+ Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
|
|
|
+ Statement statement = connection.createStatement();
|
|
|
+ String querySQL = "select 合法性判断 type, count(1) as count from " + tablename + " group by 合法性判断";
|
|
|
+ ResultSet resultSet = statement.executeQuery(querySQL);
|
|
|
+ Map hfxpd = new HashMap();
|
|
|
+ while (resultSet.next()) {
|
|
|
+ hfxpd.put(resultSet.getString("type"), Integer.valueOf(resultSet.getString("count")));
|
|
|
+ }
|
|
|
+ querySQL = "select 合法性说明 type, count(1) as count from " + tablename + " where 合法性判断 = '疑似违法' group by 合法性说明 ";
|
|
|
+ resultSet = statement.executeQuery(querySQL);
|
|
|
+ Map hfxsm = new HashMap();
|
|
|
+ while (resultSet.next()) {
|
|
|
+ hfxsm.put(resultSet.getString("type"), Integer.valueOf(resultSet.getString("count")));
|
|
|
+ }
|
|
|
+ connection.close();
|
|
|
+ Map res = new HashMap();
|
|
|
+ res.put("hfxpd", hfxpd);
|
|
|
+ res.put("hfxsm", hfxsm);
|
|
|
+ return RequestResult.success("查询成功!", res);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return RequestResult.error("查询失败!", null);
|
|
|
+ }
|
|
|
+
|
|
|
// 运行cmd
|
|
|
public String ExecuteCMD(String command) {
|
|
|
String res = "";
|