|
@@ -2,20 +2,19 @@ package com.onemap.analyse.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.onemap.analyse.domain.*;
|
|
|
import com.onemap.analyse.domain.calculation.FzxzCalc;
|
|
|
import com.onemap.analyse.domain.res.FzxzResultDTO;
|
|
|
import com.onemap.analyse.domain.res.GeomRes;
|
|
|
-import com.onemap.analyse.domain.vo.RawTableVo;
|
|
|
-import com.onemap.analyse.domain.vo.SelectPilotVo;
|
|
|
-import com.onemap.analyse.domain.vo.TableNameIdsVo;
|
|
|
-import com.onemap.analyse.domain.vo.TableWktVo;
|
|
|
+import com.onemap.analyse.domain.vo.*;
|
|
|
import com.onemap.analyse.mapper.*;
|
|
|
import com.onemap.analyse.mapper.base.FzxzResMapper;
|
|
|
import com.onemap.analyse.mapper.base.ShpFileMapper;
|
|
|
import com.onemap.analyse.mapper.vector.GhdkaMapper;
|
|
|
import com.onemap.analyse.service.*;
|
|
|
import com.onemap.analyse.utils.DozerUtils;
|
|
|
+import com.onemap.analyse.utils.JsonUtils;
|
|
|
import com.onemap.analyse.utils.NumberUtil;
|
|
|
import com.onemap.analyse.utils.UnitsUtil;
|
|
|
import com.onemap.common.core.utils.StringUtils;
|
|
@@ -24,10 +23,8 @@ import com.onemap.common.datasource.annotation.Master;
|
|
|
import com.onemap.common.security.utils.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -75,6 +72,8 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
private CreateUtilsDBService createUtilsDBService;
|
|
|
@Resource
|
|
|
private ITableDateService tableDateService;
|
|
|
+ @Resource
|
|
|
+ private AnalyseUtilsDBService analyseUtilsDBService;
|
|
|
//**需要拿出来的逻辑**//
|
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
@@ -121,7 +120,7 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Master
|
|
|
- public FzxzCalc saveScheduleParam(SelectPilotVo selectPilotVo) {
|
|
|
+ public FzxzCalc saveScheduleParam(SelectPilotVo selectPilotVo) throws JsonProcessingException {
|
|
|
FzxzCalc fzxzCalc = new FzxzCalc();
|
|
|
// 辅助选址
|
|
|
FzxzDTO fzxzDTO = selectPilotVo;
|
|
@@ -129,12 +128,17 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
fzxzDTO.setCjsj(new Date());
|
|
|
fzxzDTO.setYdxz_bsm(fzxzDTO.getYdxz_bsm().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
|
|
+
|
|
|
// 选址因子
|
|
|
List<FactorUseDTO> factorUseDTOS = selectPilotVo.getFactorList();
|
|
|
for (int i = 0; i < factorUseDTOS.size(); i++) {
|
|
|
FactorUseDTO factorUseDTO = factorUseDTOS.get(i);
|
|
|
factorUseDTO.setId(StringUtils.getUUID());
|
|
|
factorUseDTO.setTaskId(fzxzDTO.getBsm());
|
|
|
+
|
|
|
+ // 因子空间条件
|
|
|
+ FactorSpatialVo factorSpatialVo = JsonUtils.toObject(factorUseDTO.getConditionInfo(), FactorSpatialVo.class);
|
|
|
+ factorUseDTO.setConditionObj(factorSpatialVo);
|
|
|
}
|
|
|
|
|
|
// 存储规划任务
|
|
@@ -305,55 +309,94 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
* @param factorUseDTOS
|
|
|
* @param ewkt
|
|
|
*/
|
|
|
+ // TODO 重构
|
|
|
private String factorClip(String taskId, String rawTable, List<FactorUseDTO> factorUseDTOS, String ewkt) {
|
|
|
for (FactorUseDTO factorUseDTO : factorUseDTOS) {
|
|
|
- if (factorUseDTO.getSpatialType().equals("intersect")) {
|
|
|
+ FactorSpatialVo factorSpatialVo = factorUseDTO.getConditionObj();
|
|
|
+ if (factorSpatialVo.equals("intersect")) {
|
|
|
// 1.先切割因子地块
|
|
|
- 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 "";
|
|
|
+ String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorBsm(), ewkt, factorSpatialVo.getDefaultValue(), 0);
|
|
|
+ if (factorSpatialVo.isClip()) {
|
|
|
+ // 切割地块
|
|
|
+ if (factorSpatialVo.getDefaultType().equals("intersect")) {
|
|
|
+ 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);
|
|
|
}
|
|
|
- // 地块与因子求交集
|
|
|
- rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
|
|
|
} else {
|
|
|
- // 地块与因子求差集
|
|
|
- rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
|
|
|
+ // 删除不符合条件的地块
|
|
|
+ List<String> tableIds = analyseUtilsDBService.intersectsTableWkt(rawTable, null, calculateEwkt);
|
|
|
+ if (factorSpatialVo.getDefaultType().equals("intersect")) {
|
|
|
+ // 删除不想交的地块
|
|
|
+ tableDateService.delOutIds(rawTable, tableIds);
|
|
|
+ } else {
|
|
|
+ // 删除相交的地块
|
|
|
+ tableDateService.delInIds(rawTable, tableIds);
|
|
|
+ }
|
|
|
}
|
|
|
- } else if (factorUseDTO.getSpatialType().equals("contain")) {
|
|
|
+ } else if (factorSpatialVo.getSpatialType().equals("contain")) {
|
|
|
// TODO 计算地块缓冲区可能有问题,但是现在包含没有缓冲区
|
|
|
// 1.先切割因子地块
|
|
|
- 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 "";
|
|
|
+ String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorBsm(), ewkt, factorSpatialVo.getDefaultValue(), 0);
|
|
|
+ if (factorSpatialVo.isClip()) {
|
|
|
+ // 包含判断
|
|
|
+ if (factorSpatialVo.getDefaultType().equals("contain")) {
|
|
|
+ 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);
|
|
|
}
|
|
|
- // 地块与因子求差集
|
|
|
- rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
|
|
|
} else {
|
|
|
- // 地块与因子求差集
|
|
|
- rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
|
|
|
+ // 删除不符合条件的地块
|
|
|
+ List<String> tableIds = analyseUtilsDBService.intersectsTableWkt(rawTable, null, calculateEwkt);
|
|
|
+ if (factorSpatialVo.getDefaultType().equals("contain")) {
|
|
|
+ // 删除不包含的地块
|
|
|
+ tableDateService.delOutIds(rawTable, tableIds);
|
|
|
+ } else {
|
|
|
+ // 删除包含的地块
|
|
|
+ tableDateService.delInIds(rawTable, tableIds);
|
|
|
+ }
|
|
|
}
|
|
|
- } else if (factorUseDTO.getSpatialType().equals("distance")) {
|
|
|
- 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 "";
|
|
|
+ } else if (factorSpatialVo.getSpatialType().equals("distance")) {
|
|
|
+ String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorBsm(), ewkt, factorSpatialVo.getDefaultValue(), factorSpatialVo.getDefaultValue());
|
|
|
+
|
|
|
+ if (factorSpatialVo.isClip()) {
|
|
|
+ // 距离判断
|
|
|
+ if (factorSpatialVo.getDefaultType().equals("lt") || factorSpatialVo.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);
|
|
|
}
|
|
|
- rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
|
|
|
} else {
|
|
|
- // 地块与因子求差集
|
|
|
- rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
|
|
|
+ // 删除不符合条件的地块
|
|
|
+ List<String> tableIds = analyseUtilsDBService.intersectsTableWkt(rawTable, null, calculateEwkt);
|
|
|
+ if (factorSpatialVo.getDefaultType().equals("lt") || factorSpatialVo.getDefaultType().equals("let")) {
|
|
|
+ // 删除不包含的地块
|
|
|
+ tableDateService.delOutIds(rawTable, tableIds);
|
|
|
+ } else {
|
|
|
+ // 删除包含的地块
|
|
|
+ tableDateService.delInIds(rawTable, tableIds);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|