浏览代码

行政区查询接口提交

wanger 1 年之前
父节点
当前提交
340dbe8b1f

+ 12 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/controller/yzt/XzqController.java

@@ -38,4 +38,16 @@ public class XzqController extends BaseController {
         RequestResult list = xzqService.GetXzqList(city);
         return list;
     }
+
+    /**
+     * 根据代码获取相应的GEOM WKT
+     *
+     * @param id 行政区划代码
+     * @return
+     */
+    @GetMapping("/GetGeom")
+    public RequestResult GetGeom(String id) {
+        RequestResult list = xzqService.GetGeom(id);
+        return list;
+    }
 }

+ 1 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/yzt/XzqDTO.java

@@ -9,7 +9,7 @@ public class XzqDTO {
     private String label;
     private String parent;
     private Boolean isparent;
-    private List<XzqDTO> children = new ArrayList<XzqDTO>();
+    private List<XzqDTO> children;
 
     public String getValue() {
         return value;

+ 2 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/mapper/yzt/XzqMapper.java

@@ -16,4 +16,6 @@ public interface XzqMapper
     public List<XzqSqlDTO> GetXzq(@Param("city") Boolean city , @Param("xzqCode") String xzqCode);
 
     public List<XzqSqlDTO> GetXzqList(Boolean city);
+
+    String GetGeom(String id);
 }

+ 20 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/yzt/XzqServiceImpl.java

@@ -6,6 +6,7 @@ import com.onemap.apply.mapper.yzt.XzqMapper;
 import com.onemap.apply.service.yzt.IXzqService;
 import com.onemap.common.core.utils.StringUtils;
 import com.onemap.common.core.web.domain.RequestResult;
+import com.onemap.common.datasource.annotation.Slave;
 import com.onemap.system.api.domain.SysDept;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -21,6 +22,7 @@ public class XzqServiceImpl implements IXzqService {
     private XzqMapper xzqMapper;
 
     @Override
+    @Slave
     public RequestResult GetXzq(Boolean city) {
         try{
             List<XzqSqlDTO> res = xzqMapper.GetXzq(city,"");
@@ -44,6 +46,7 @@ public class XzqServiceImpl implements IXzqService {
     }
 
     @Override
+    @Slave
     public RequestResult GetXzqList(Boolean city) {
         try{
             List<XzqSqlDTO> res = xzqMapper.GetXzqList(city);
@@ -65,6 +68,18 @@ public class XzqServiceImpl implements IXzqService {
         }
     }
 
+    @Override
+    @Slave
+    public RequestResult GetGeom(String id) {
+        try{
+            String wkt = xzqMapper.GetGeom(id);
+            return RequestResult.success("成功", wkt);
+        }catch (Exception e){
+            e.printStackTrace();
+            return RequestResult.error("失败", null);
+        }
+    }
+
     /**
      * 构建前端所需要树结构
      *
@@ -96,7 +111,11 @@ public class XzqServiceImpl implements IXzqService {
     private void recursionFn(List<XzqDTO> list, XzqDTO t) {
         // 得到子节点列表
         List<XzqDTO> childList = getChildList(list, t);
-        t.setChildren(childList);
+        if(childList.size() > 0){
+            t.setChildren(childList);
+        }else{
+            t.setChildren(null);
+        }
         for (XzqDTO tChild : childList) {
             if (hasChild(list, tChild)) {
                 recursionFn(list, tChild);

+ 2 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/yzt/IXzqService.java

@@ -6,4 +6,6 @@ public interface IXzqService {
     RequestResult GetXzq(Boolean city);
 
     RequestResult GetXzqList(Boolean city);
+
+    RequestResult GetGeom(String id);
 }

+ 13 - 9
onemap-modules/onemap-apply/src/main/resources/mapper/postgresql/yzt/XzqMapper.xml

@@ -9,9 +9,9 @@
         select t.id as "value",
         t.name as "label",
         t.pid as "parent",
-        case when (select count(*) from v_yzt_zysxcx p where p.type = 'XZQ' and p.pid = t.id) > 0 then '1'
+        case when (select count(*) from xzqh p where p.pid = t.id) > 0 then '1'
         else '0' end as "isparent"
-        from v_yzt_zysxcx t where t.type = 'XZQ'
+        from xzqh t where 1 = 1
         <if test="city == null or city == false">
             and t.pid is not null
         </if>
@@ -24,26 +24,30 @@
         select t.id as "value",
         t.name as "label",
         t.pid as "parent",
-        case when (select count(1) from v_yzt_zysxcx p where p.type = 'XZQ' and p.pid = t.id) > 0 then '1'
+        case when (select count(1) from xzqh p where p.pid = t.id) > 0 then '1'
         else '0' end as "isparent"
-        from v_yzt_zysxcx t where t.type = 'XZQ'
+        from xzqh t where 1 = 1
         <if test="city == null or city == false">
-            and t.pid is not null and length(t.id) &lt;= (select case (select length(t.id) from v_yzt_zysxcx t where
-            t.type = 'XZQ' and t.pid is null)
+            and t.pid is not null and length(t.id) &lt;= (select case (select length(t.id) from xzqh t where
+             t.pid is null)
             when 2 then 4
             when 4 then 6
             when 6 then 9
             when 9 then 12
-            end from dual)
+            end)
         </if>
         <if test="city != null or city == true">
-            and length(t.id) &lt;= (select case (select length(t.id) from v_yzt_zysxcx t where t.type = 'XZQ' and t.pid
+            and length(t.id) &lt;= (select case (select length(t.id) from xzqh t where  t.pid
             is null)
             when 2 then 4
             when 4 then 6
             when 6 then 9
             when 9 then 12
-            end from dual)
+            end )
         </if>
     </select>
+
+    <select id="GetGeom" resultType="java.lang.String" parameterType="java.lang.String">
+        select st_asewkt(t.geom) from xzqh t where t.id = #{id}
+    </select>
 </mapper>