浏览代码

资源字段属性和共享字段属性,接口设置。

DESKTOP-2K9OVK9\siwei 8 月之前
父节点
当前提交
13fb6d69d7

+ 5 - 0
onemap-modules/onemap-apply/pom.xml

@@ -162,6 +162,11 @@
             <artifactId>dom4j</artifactId>
             <version>1.6.1</version>
         </dependency>
+        <!-- JSON 解析器和生成器 -->
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba.fastjson2</groupId>-->
+<!--            <artifactId>fastjson2</artifactId>-->
+<!--        </dependency>-->
     </dependencies>
 
     <build>

+ 5 - 4
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/controller/zymlapplication/ShareConfigurationController.java

@@ -2,6 +2,7 @@ package com.onemap.apply.controller.zymlapplication;
 
 import com.onemap.apply.domain.zymlapplication.TZymlApplicationRecord;
 import com.onemap.apply.domain.zymlapplication.TZymlFiled;
+import com.onemap.apply.domain.zymlapplication.TZymlFiledVo;
 import com.onemap.apply.service.zymlapplication.IShareConfigurationService;
 import com.onemap.apply.service.zymlapplication.ITZymlApplicationRecordService;
 import com.onemap.common.core.utils.StringUtils;
@@ -50,14 +51,14 @@ public class ShareConfigurationController extends BaseController {
      */
 //    @RequiresPermissions("@ss.hasPermi('share:resources:application:list')")
     @GetMapping("/fileds/list")
-    public AjaxResult filedsList(TZymlApplicationRecord tZymlApplicationRecord) {
-        if (StringUtils.isNull(tZymlApplicationRecord)) {
+    public AjaxResult filedsList(TZymlFiledVo tZymlFiledVo) {
+        if (StringUtils.isNull(tZymlFiledVo)) {
             return AjaxResult.error("参数缺失");
         }
-        if (StringUtils.isEmpty(tZymlApplicationRecord.getId())) {
+        if (StringUtils.isEmpty(tZymlFiledVo.getZymlBsm())) {
             return AjaxResult.error("参数缺失");
         }
-        return AjaxResult.success(shareConfigurationService.selectTZymlFiledList(tZymlApplicationRecord.getId()));
+        return AjaxResult.success(shareConfigurationService.selectTZymlFiledList(tZymlFiledVo));
     }
 
     @PutMapping("/filed")

+ 10 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/zymlapplication/TZymlFiled.java

@@ -24,9 +24,11 @@ public class TZymlFiled extends BaseEntity {
     private String filedName;
     //    private String filed_name_zh;
     private String filedNameZh;
+    // 字段类型,超图和geoserver的格式不一致,暂时没有做强制映射配置
     private String filedType;
     //    private String share_display;
     private Integer shareDisplay;
+    private Boolean status;
     private Integer sort;
 
     public String getId() {
@@ -81,6 +83,14 @@ public class TZymlFiled extends BaseEntity {
         return sort;
     }
 
+    public Boolean getStatus() {
+        return status;
+    }
+
+    public void setStatus(Boolean status) {
+        this.status = status;
+    }
+
     public void setSort(Integer sort) {
         this.sort = sort;
     }

+ 24 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/zymlapplication/TZymlFiledVo.java

@@ -0,0 +1,24 @@
+package com.onemap.apply.domain.zymlapplication;
+
+public class TZymlFiledVo {
+    // 资源目录的ID
+    private String zymlBsm;
+    //是否重置
+    private Boolean resetType = false;
+
+    public String getZymlBsm() {
+        return zymlBsm;
+    }
+
+    public void setZymlBsm(String zymlBsm) {
+        this.zymlBsm = zymlBsm;
+    }
+
+    public Boolean getResetType() {
+        return resetType;
+    }
+
+    public void setResetType(Boolean resetType) {
+        this.resetType = resetType;
+    }
+}

+ 2 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/mapper/zymlapplication/TZymlFiledMapper.java

@@ -54,6 +54,8 @@ public interface TZymlFiledMapper {
      */
     public int deleteTZymlFiledById(String id);
 
+    public int deleteTZymlFiledByZymlId(String zymlId);
+
     /**
      * 批量删除我的申请
      *

+ 141 - 42
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/zymlapplication/ShareConfigurationServiceImp.java

@@ -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;
+    }
+
 }

+ 2 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/zymlapplication/IShareConfigurationService.java

@@ -1,6 +1,7 @@
 package com.onemap.apply.service.zymlapplication;
 
 import com.onemap.apply.domain.zymlapplication.TZymlFiled;
+import com.onemap.apply.domain.zymlapplication.TZymlFiledVo;
 
 import java.util.List;
 
@@ -8,7 +9,7 @@ public interface IShareConfigurationService {
 
     int updateZymlShareStateById(String bsm);
 
-    public List<TZymlFiled> selectTZymlFiledList(String bsm);
+    public List<TZymlFiled> selectTZymlFiledList(TZymlFiledVo tZymlFiledVo);
 
     int updateTZymlFiledList(TZymlFiled filed);
 }

+ 9 - 1
onemap-modules/onemap-apply/src/main/resources/mapper/postgresql/zymlapplication/TZymlFiledMapper.xml

@@ -12,10 +12,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="filedType"    column="filed_type"    />
         <result property="shareDisplay"    column="share_display"    />
         <result property="sort"    column="sort"    />
+        <result property="status"    column="status"    />
     </resultMap>
 
     <sql id="selectTZymlFiledVo">
-        select id, zyml_id, filed_name, filed_name_zh, share_display, sort from t_zyml_filed
+        select id, zyml_id, filed_name, filed_name_zh, share_display, sort,status from t_zyml_filed
     </sql>
 
     <select id="selectTZymlFiledList" parameterType="TZymlFiled" resultMap="TZymlFiledResult">
@@ -43,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="filedType != null">filed_type,</if>
             <if test="shareDisplay != null">share_display,</if>
             <if test="sort != null">sort,</if>
+            <if test="status != null">status,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -52,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="filedType != null">#{filedType},</if>
             <if test="shareDisplay != null">#{shareDisplay},</if>
             <if test="sort != null">#{sort},</if>
+            <if test="status != null">#{status},</if>
         </trim>
     </insert>
 
@@ -62,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="filedNameZh != null">filed_name_zh = #{filedNameZh},</if>
             <if test="shareDisplay != null">share_display = #{shareDisplay},</if>
             <if test="sort != null">sort = #{sort},</if>
+            <if test="status != null">status = #{status},</if>
         </trim>
         where id = #{id}
     </update>
@@ -70,6 +74,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from t_zyml_filed where id = #{id}
     </delete>
 
+    <delete id="deleteTZymlFiledByZymlId" parameterType="String">
+        delete from t_zyml_filed where zyml_id = #{zymlId}
+    </delete>
+
     <delete id="deleteTZymlFiledByIds" parameterType="String">
         delete from t_zyml_filed where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">