Parcourir la source

地块切割逻辑完成

gushoubang il y a 9 mois
Parent
commit
3fcbfd02ef

+ 0 - 6
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/vector/GhdkaMapper.java

@@ -34,10 +34,4 @@ public interface GhdkaMapper extends BaseMapper<GhdkaDTO> {
      * @return 数据源中全部的字段信息
      */
     List<Map<String, Object>> getInfo(Map<String, Object> params);
-
-    Integer delByLandType(@Param("temporaryTable") String temporaryTable,
-                          @Param("rawTable") String rawTable,
-                          @Param("landTypeCode") String landTypeCode);
-
-    Integer getTableCount(String tableName);
 }

+ 7 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/vector/TableDataMapper.java

@@ -5,6 +5,7 @@ import com.onemap.analyse.domain.vo.RawTableVo;
 import com.onemap.analyse.domain.vo.TableNameIdsVo;
 import com.onemap.analyse.domain.vo.TargetTableVo;
 import com.onemap.common.datasource.annotation.Slave;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -18,4 +19,10 @@ public interface TableDataMapper {
     List<Map<String, Object>> getTargetTable(TargetTableVo targetTableVo);
 
     String getGeomUnion(TableNameIdsVo tableNameIdsVo);
+
+    Integer getTableCount(String tableName);
+
+    Integer delByLandType(@Param("temporaryTable") String temporaryTable,
+                          @Param("rawTable") String rawTable,
+                          @Param("landTypeCode") String landTypeCode);
 }

+ 7 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/ITableDateService.java

@@ -4,6 +4,7 @@ import com.onemap.analyse.domain.vo.RawTableLengthVo;
 import com.onemap.analyse.domain.vo.RawTableVo;
 import com.onemap.analyse.domain.vo.TableNameIdsVo;
 import com.onemap.analyse.domain.vo.TargetTableVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -19,4 +20,10 @@ public interface ITableDateService {
     List<Map<String, Object>> getTargetTable(TargetTableVo targetTableVo);
 
     String getGeomUnion(TableNameIdsVo tableNameIdsVo);
+
+    Integer getTableCount(String tableName);
+
+    void delByLandType(String temporaryTable,
+                       String rawTable,
+                       String landTypeCode);
 }

+ 44 - 27
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/FzssServiceImpl.java

@@ -2,6 +2,7 @@ package com.onemap.analyse.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.onemap.analyse.controller.analyse.GetTableDateController;
 import com.onemap.analyse.domain.*;
 import com.onemap.analyse.domain.calculation.FzxzCalc;
 import com.onemap.analyse.domain.res.FzxzResultDTO;
@@ -22,6 +23,7 @@ import com.onemap.common.core.utils.StringUtils;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.common.datasource.annotation.Master;
 import com.onemap.common.security.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -69,6 +71,15 @@ public class FzssServiceImpl implements IFzssService {
     @Resource
     private ILogService iLogService;
 
+    // **需要拿出来的逻辑**//
+    // @Resource
+    // AnalyseUtilsDBController analyseUtilsDBController;
+    @Resource
+    private CreateUtilsDBService createUtilsDBService;
+    @Resource
+    private TableDateServiceImpl tableDateService;
+    //**需要拿出来的逻辑**//
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public RequestResult AddHgxfx(HgxfxEntityDTO hgxfxEntityDTO) throws IOException {
@@ -105,15 +116,6 @@ public class FzssServiceImpl implements IFzssService {
     }
 
 
-    // **需要拿出来的逻辑**//
-    // @Resource
-    // AnalyseUtilsDBController analyseUtilsDBController;
-    @Resource
-    private CreateUtilsDBService createUtilsDBService;
-    @Resource
-    private TableDateServiceImpl tableDateService;
-    //**需要拿出来的逻辑**//
-
     /**
      * 保存选址参数
      *
@@ -215,7 +217,7 @@ public class FzssServiceImpl implements IFzssService {
         intersectionTableWktVo.setEwkt(ewkt);
         String temporaryTable = createUtilsDBService.intersectionTableWkt(intersectionTableWktVo.getTableName(), null, intersectionTableWktVo.getEwkt());
 
-        Integer integer = ghdkaMapper.getTableCount(temporaryTable);
+        Integer integer = tableDateService.getTableCount(temporaryTable);
         if (integer == 0) {
             iLogService.saveLog(taskId, "辅助选址", "计算完成,未找到区域内数据", "info");
             updateFzxzStatus(taskId, Rwzt.getNoJX());
@@ -239,16 +241,17 @@ public class FzssServiceImpl implements IFzssService {
         // iLogService.saveLog(taskId, "辅助选址", "地块面积分析完成", "info");
 
         //  3.用地类型(性质)筛选
-        ghdkaMapper.delByLandType(temporaryTable, fzxzDTO.getSjy(), fzxzDTO.getYdxz_bsm());
-        integer = ghdkaMapper.getTableCount(temporaryTable);
+        tableDateService.delByLandType(temporaryTable, fzxzDTO.getSjy(), fzxzDTO.getYdxz_bsm());
+        integer = tableDateService.getTableCount(temporaryTable);
         if (integer == 0) {
             iLogService.saveLog(taskId, "辅助选址", "计算完成,未找到符合用地性质条件数据", "info");
             updateFzxzStatus(taskId, Rwzt.getNoJX());
             return RequestResult.error("区域筛选条件筛选未找到符合条件数据!", null);
         }
 
-        // 4.规划因子筛选
-        factorFilter(taskId, temporaryTable, fzxzCalc.getFactorUseList(), ewkt);
+        // 4.根据因子切割地块
+        String rawTable = factorClip(taskId, temporaryTable, fzxzCalc.getFactorUseList(), ewkt);
+        if (rawTable.equals("")) return RequestResult.error("区域筛选条件筛选未找到符合条件数据!", null);
 
         // 5.保存规划结果
         Map<String, Object> scheduleResMap = new HashMap<>();
@@ -285,7 +288,7 @@ public class FzssServiceImpl implements IFzssService {
 
         // 1.查询因子地块
         String tempTable = createUtilsDBService.intersectionTableWkt(tableName, null, ewkt);
-        Integer integer = ghdkaMapper.getTableCount(tempTable);
+        Integer integer = tableDateService.getTableCount(tempTable);
         if (integer == 0) return "";
         // 2.生成因子地块缓冲区
         if (factorRadius != 0) {
@@ -298,10 +301,6 @@ public class FzssServiceImpl implements IFzssService {
         return calculateEwkt;
     }
 
-
-    // iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
-    // iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
-
     /**
      * 根据因子筛选地块
      *
@@ -310,13 +309,18 @@ public class FzssServiceImpl implements IFzssService {
      * @param factorUseDTOS
      * @param ewkt
      */
-    private String factorFilter(String taskId, String rawTable, List<FactorUseDTO> factorUseDTOS, String ewkt) {
+    private String factorClip(String taskId, String rawTable, List<FactorUseDTO> factorUseDTOS, String ewkt) {
         for (FactorUseDTO factorUseDTO : factorUseDTOS) {
             if (factorUseDTO.getSpatialType().equals("intersect")) {
                 // 1.先切割因子地块
-                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorName(), ewkt, factorUseDTO.getDefaultValue());
+                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorBsm(), ewkt, factorUseDTO.getDefaultValue(), 0);
                 // 2.切割地块
                 if (factorUseDTO.getDefaultType().equals("intersect")) {
+                    if (calculateEwkt.equals("")) {
+                        iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成,未找到符合要求地块", "info");
+                        updateFzxzStatus(taskId, Rwzt.getNoJX());
+                        return "";
+                    }
                     // 地块与因子求交集
                     rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
                 } else {
@@ -326,9 +330,14 @@ public class FzssServiceImpl implements IFzssService {
             } else if (factorUseDTO.getSpatialType().equals("contain")) {
                 // TODO 计算地块缓冲区可能有问题,但是现在包含没有缓冲区
                 // 1.先切割因子地块
-                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorName(), ewkt, factorUseDTO.getDefaultValue(), 0);
+                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorBsm(), ewkt, factorUseDTO.getDefaultValue(), 0);
                 // 包含判断
                 if (factorUseDTO.getDefaultType().equals("contain")) {
+                    if (calculateEwkt.equals("")) {
+                        iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成,未找到符合要求地块", "info");
+                        updateFzxzStatus(taskId, Rwzt.getNoJX());
+                        return "";
+                    }
                     // 地块与因子求差集
                     rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
                 } else {
@@ -336,21 +345,29 @@ public class FzssServiceImpl implements IFzssService {
                     rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
                 }
             } else if (factorUseDTO.getSpatialType().equals("distance")) {
-                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorName(), ewkt, factorUseDTO.getDefaultValue(), factorUseDTO.getDefaultValue());
+                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorBsm(), ewkt, factorUseDTO.getDefaultValue(), factorUseDTO.getDefaultValue());
                 // 距离判断
                 if (factorUseDTO.getDefaultType().equals("lt") || factorUseDTO.getDefaultType().equals("let")) {
                     // 地块与因子求差集
+                    if (calculateEwkt.equals("")) {
+                        iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成,未找到符合要求地块", "info");
+                        updateFzxzStatus(taskId, Rwzt.getNoJX());
+                        return "";
+                    }
                     rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
                 } else {
                     // 地块与因子求差集
                     rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
                 }
             }
-            if (0 == 0) {
-                iLogService.saveLog(taskId, "辅助选址", "计算完成,未找到符合条件数据", "info");
+
+            Integer tableCount = tableDateService.getTableCount(rawTable);
+            if (tableCount == 0) {
+                iLogService.saveLog(taskId, "辅助选址",
+                        factorUseDTO.getFactorName() + "计算完成,未找到符合条件数据",
+                        "info");
                 updateFzxzStatus(taskId, Rwzt.getNoJX());
-                // TODO
-                // return RequestResult.error(fzxzXzyzDTO.getFactorName() + "条件筛选未找到符合条件数据!", null);
+                return "";
             }
             iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
         }

+ 11 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/TableDateServiceImpl.java

@@ -40,4 +40,15 @@ public class TableDateServiceImpl implements ITableDateService {
         String ewkt = tableDataMapper.getGeomUnion(tableNameIdsVo);
         return ewkt;
     }
+
+    @Override
+    public Integer getTableCount(String tableName) {
+        Integer integer = tableDataMapper.getTableCount(tableName);
+        return integer;
+    }
+
+    @Override
+    public void delByLandType(String temporaryTable, String rawTable, String landTypeCode) {
+        tableDataMapper.delByLandType(temporaryTable, rawTable, landTypeCode);
+    }
 }

+ 0 - 14
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/GhdkaMapper.xml

@@ -93,18 +93,4 @@
             #{id}
         </foreach>
     </select>
-
-    <delete id="delByLandType">
-        DELETE
-        FROM "${temporaryTable}" temp
-        WHERE NOT EXISTS (SELECT 1
-                          FROM "${rawTable}" raw
-                          WHERE raw.id = temp.id
-                            AND raw.kzxxgyddm like '%${landTypeCode}%')
-    </delete>
-
-    <select id="getTableCount" resultType="Integer">
-        SELECT count(1)
-        FROM "${sjy}"
-    </select>
 </mapper>

+ 14 - 0
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/TableDateMapper.xml

@@ -123,4 +123,18 @@
             </foreach>
         </if>
     </select>
+
+    <select id="getTableCount" resultType="Integer">
+        SELECT count(1)
+        FROM "${sjy}"
+    </select>
+
+    <delete id="delByLandType">
+        DELETE
+        FROM "${temporaryTable}" temp
+        WHERE NOT EXISTS (SELECT 1
+                          FROM "${rawTable}" raw
+                          WHERE raw.id = temp.id
+                            AND raw.kzxxgyddm like '%${landTypeCode}%')
+    </delete>
 </mapper>