|
@@ -1,6 +1,10 @@
|
|
|
package com.onemap.apply.service.impl.zymlapplication;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.onemap.apply.domain.zymlapplication.TZymlFiled;
|
|
|
+import com.onemap.apply.domain.zymlapplication.TZymlFiledVo;
|
|
|
import com.onemap.apply.mapper.zymlapplication.ShareConfigurationMapper;
|
|
|
import com.onemap.apply.mapper.zymlapplication.TMyExamineMapper;
|
|
|
import com.onemap.apply.mapper.zymlapplication.TZymlFiledMapper;
|
|
@@ -13,6 +17,7 @@ import javax.annotation.Resource;
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -35,50 +40,103 @@ public class ShareConfigurationServiceImp implements IShareConfigurationService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TZymlFiled> selectTZymlFiledList(String bsm) {
|
|
|
+ public List<TZymlFiled> selectTZymlFiledList(TZymlFiledVo tZymlFiledVo) {
|
|
|
+ String bsm = tZymlFiledVo.getZymlBsm();
|
|
|
TZymlFiled tZymlFiled = new TZymlFiled();
|
|
|
tZymlFiled.setZymlId(bsm);
|
|
|
- List<TZymlFiled> list = tZymlFiledMapper.selectTZymlFiledList(tZymlFiled);
|
|
|
- if (list == null || list.size() == 0) {
|
|
|
- Map<String, Object> mapfwData = myExamineMapper.queryFwInfoByBsm(bsm);
|
|
|
- String server_type = (String) mapfwData.get("server_type");
|
|
|
- String type = (String) mapfwData.get("type");
|
|
|
- String fwmc = (String) mapfwData.get("fwmc");
|
|
|
- String fwgzkj = (String) mapfwData.get("fwgzkj");
|
|
|
- String sde = (String) mapfwData.get("sde");
|
|
|
- String url = (String) mapfwData.get("url");
|
|
|
- //判断geoserver
|
|
|
- if (StringUtils.isNotEmpty(server_type) && "geoserver".equals(server_type.toLowerCase())) {
|
|
|
- int len_o = url.indexOf("geoserver");
|
|
|
+ List<TZymlFiled> dblist = tZymlFiledMapper.selectTZymlFiledList(tZymlFiled);
|
|
|
+ if (dblist == null || dblist.size() == 0) {
|
|
|
+ dblist = getZymlFiledList(bsm);
|
|
|
+ if (dblist == null || dblist.size() == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ for (TZymlFiled kObj : dblist) {
|
|
|
+ tZymlFiledMapper.insertTZymlFiled(kObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tZymlFiledVo.getResetType()) {
|
|
|
+ List<TZymlFiled> zymlFiledList = getZymlFiledList(bsm);
|
|
|
+ List<TZymlFiled> newDbFiledList = new ArrayList<>();
|
|
|
+ int len = 0;
|
|
|
+ for (TZymlFiled dbFiled : dblist) {
|
|
|
+ for (TZymlFiled zymlFiled : zymlFiledList) {
|
|
|
+ if (dbFiled.getFiledName().equals(zymlFiled.getFiledName())) {
|
|
|
+ dbFiled.setSort(len);
|
|
|
+ newDbFiledList.add(dbFiled);
|
|
|
+ len++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TZymlFiled zymlFiled : zymlFiledList) {
|
|
|
+ boolean check = false;
|
|
|
+ for (TZymlFiled dbFiled : newDbFiledList) {
|
|
|
+ if (dbFiled.getFiledName().equals(zymlFiled.getFiledName())) {
|
|
|
+ check = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!check) {
|
|
|
+ zymlFiled.setSort(len);
|
|
|
+ newDbFiledList.add(zymlFiled);
|
|
|
+ len++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dblist = newDbFiledList;
|
|
|
+ tZymlFiledMapper.deleteTZymlFiledByZymlId(bsm);
|
|
|
+ for (TZymlFiled kObj : dblist) {
|
|
|
+ tZymlFiledMapper.insertTZymlFiled(kObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dblist;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<TZymlFiled> getZymlFiledList(String bsm) {
|
|
|
+ List<TZymlFiled> list = new ArrayList<>();
|
|
|
+ Map<String, Object> mapfwData = myExamineMapper.queryFwInfoByBsm(bsm);
|
|
|
+ String server_type = (String) mapfwData.get("server_type");
|
|
|
+ String type = (String) mapfwData.get("type");
|
|
|
+ String fwmc = (String) mapfwData.get("fwmc");
|
|
|
+ String fwgzkj = (String) mapfwData.get("fwgzkj");
|
|
|
+ if (StringUtils.isEmpty(fwgzkj) || StringUtils.isEmpty(fwmc)) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ String sde = (String) mapfwData.get("sde");
|
|
|
+ String url = (String) mapfwData.get("url");
|
|
|
+ //判断geoserver
|
|
|
+ if (StringUtils.isNotEmpty(server_type) && "geoserver".equals(server_type.toLowerCase()) && ("wms".equals(type.toLowerCase()) || "wmts".equals(type.toLowerCase()))) {
|
|
|
+ int len_o = url.indexOf("geoserver");
|
|
|
// http://192.168.60.2:8089/geoserver/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeNames=demo:ghdk20241014
|
|
|
- String getUrl = url.substring(0, len_o) + "geoserver/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeNames=";
|
|
|
- getUrl = getUrl + fwgzkj + ":" + fwmc;
|
|
|
- String xml = formaServerJsonReplace(getUrl);
|
|
|
- if (StringUtils.isEmpty(xml)) {
|
|
|
+ String getUrl = url.substring(0, len_o) + "geoserver/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeNames=";
|
|
|
+ getUrl = getUrl + fwgzkj + ":" + fwmc;
|
|
|
+ String xml = formaServerReplace(getUrl);
|
|
|
+ if (StringUtils.isEmpty(xml)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ list = analysisGeoServerFiledXml(xml, bsm);
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //超图矢量地图
|
|
|
+ if ("vector".equals(type.toLowerCase())) {
|
|
|
+ String url1 = url.replace("map-", "data-");
|
|
|
+ int len = url1.lastIndexOf("/rest/maps/");
|
|
|
+ String url2 = url1.substring(0, len);
|
|
|
+ try {
|
|
|
+ url2 = url2 + "/rest/data/datasources/" + URLEncoder.encode(fwgzkj, "UTF-8");
|
|
|
+ url2 = url2 + "/datasets/" + URLEncoder.encode(fwmc, "UTF-8") + "/fields";
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ System.out.println(e.getMessage());
|
|
|
return null;
|
|
|
}
|
|
|
- list = analysisGeoServerFiledXml(xml, bsm);
|
|
|
+ String newUrl = url2 + ".json";
|
|
|
+ String json = formaServerReplace(newUrl);
|
|
|
+ list = analysisIServerFiledjson(json, bsm, url2);
|
|
|
if (list == null || list.size() == 0) {
|
|
|
- return null;
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
- for (TZymlFiled kObj : list) {
|
|
|
- tZymlFiledMapper.insertTZymlFiled(kObj);
|
|
|
- }
|
|
|
- } else {
|
|
|
-// //判断3DTiles
|
|
|
-// if (StringUtils.isNotEmpty(type) && "3DTiles".toLowerCase().equals(type.toLowerCase())) {
|
|
|
-// String params = "";
|
|
|
-// params = params + paroxy_url.replace("{token}", fwKey) + "siwei3dtiles";
|
|
|
-// return params;
|
|
|
-// } else {
|
|
|
-// //超图的
|
|
|
-// String sde = (String) mapfwData.get("sde");
|
|
|
-// String params = "";
|
|
|
-// params = params + paroxy_url.replace("{token}", fwKey) + "siweisupermap" + "?";
|
|
|
-// params = params + paramsTogether("server_type", type, true);
|
|
|
-// params = params + paramsTogether("sde", sde, false);
|
|
|
-// return params;
|
|
|
-// }
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
@@ -90,16 +148,16 @@ public class ShareConfigurationServiceImp implements IShareConfigurationService
|
|
|
return tZymlFiledMapper.updateTZymlFiled(filed);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 发送server请求,并将数据返回,处理JSON会将参数进行替换
|
|
|
+ * 发送geoserver请求,并将数据返回,处理xml结果
|
|
|
*
|
|
|
* @param uri
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private String formaServerJsonReplace(String uri) {
|
|
|
+ private String formaServerReplace(String uri) {
|
|
|
String retString = null;
|
|
|
try {
|
|
|
- System.out.println("uri:" + uri);
|
|
|
URL url = new URL(uri);
|
|
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
|
|
if (con.getResponseCode() == 200) {
|
|
@@ -114,7 +172,6 @@ public class ShareConfigurationServiceImp implements IShareConfigurationService
|
|
|
is.close();
|
|
|
con.disconnect();
|
|
|
retString = strBuffer.toString();
|
|
|
- System.out.println("retString:" + retString);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
System.err.println("获取文件流出错," + e);
|
|
@@ -128,7 +185,6 @@ public class ShareConfigurationServiceImp implements IShareConfigurationService
|
|
|
try {
|
|
|
Document document = DocumentHelper.parseText(xmlString);
|
|
|
Element rootElement = document.getRootElement();
|
|
|
- System.out.println(rootElement.getName());
|
|
|
Element sequence1 = rootElement.element("complexType");
|
|
|
Element sequence2 = sequence1.element("complexContent");
|
|
|
Element sequence3 = sequence2.element("extension");
|
|
@@ -145,6 +201,8 @@ public class ShareConfigurationServiceImp implements IShareConfigurationService
|
|
|
filedData.setZymlId(bsm);
|
|
|
filedData.setId(StringUtils.getUUID());
|
|
|
filedData.setSort(i);
|
|
|
+ filedData.setShareDisplay(1);
|
|
|
+ filedData.setStatus(true);
|
|
|
i++;
|
|
|
ret.add(filedData);
|
|
|
}
|
|
@@ -155,4 +213,45 @@ public class ShareConfigurationServiceImp implements IShareConfigurationService
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 超图data处理
|
|
|
+ *
|
|
|
+ * @param jsonString
|
|
|
+ * @param bsm
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<TZymlFiled> analysisIServerFiledjson(String jsonString, String bsm, String fieldUrl) {
|
|
|
+ List<TZymlFiled> ret = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject1 = JSON.parseObject(jsonString);
|
|
|
+ JSONArray fieldNames = jsonObject1.getJSONArray("fieldNames");
|
|
|
+ for (int i = 0; i < fieldNames.size(); i++) {
|
|
|
+ String key = fieldNames.getString(i);
|
|
|
+ String fieldValueUrl = fieldUrl + "/" + URLEncoder.encode(key, "UTF-8") + ".json";
|
|
|
+ String fieldValueUrlJson = formaServerReplace(fieldValueUrl);
|
|
|
+ if (StringUtils.isNotEmpty(fieldValueUrlJson)) {
|
|
|
+ JSONObject fieldValueObject_0 = JSON.parseObject(fieldValueUrlJson);
|
|
|
+ JSONObject fieldInfoObj = fieldValueObject_0.getJSONObject("fieldInfo");
|
|
|
+ String filedName = fieldInfoObj.getString("name");
|
|
|
+ String filedType = fieldInfoObj.getString("type");
|
|
|
+ TZymlFiled filedData = new TZymlFiled();
|
|
|
+ filedData.setFiledName(filedName);
|
|
|
+ filedData.setFiledNameZh(filedName);
|
|
|
+ filedData.setFiledType(filedType);
|
|
|
+ filedData.setZymlId(bsm);
|
|
|
+ filedData.setId(StringUtils.getUUID());
|
|
|
+ filedData.setSort(i);
|
|
|
+ filedData.setShareDisplay(1);
|
|
|
+ filedData.setStatus(true);
|
|
|
+ i++;
|
|
|
+ ret.add(filedData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("analysisGeoServerFiledXml error:" + e);
|
|
|
+ ret = new ArrayList<>();
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
}
|