|
@@ -2,16 +2,20 @@ 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.AnalyseUtilsDBController;
|
|
|
+import com.onemap.analyse.controller.analyse.CreateUtilsDBController;
|
|
|
import com.onemap.analyse.domain.*;
|
|
|
import com.onemap.analyse.domain.calculation.FzxzCalc;
|
|
|
import com.onemap.analyse.domain.query.GhdkaFilter;
|
|
|
import com.onemap.analyse.domain.res.FzxzResultDTO;
|
|
|
import com.onemap.analyse.domain.res.GeomRes;
|
|
|
-import com.onemap.analyse.domain.vo.FzxzFactorDTO;
|
|
|
+import com.onemap.analyse.domain.vo.IntersectionTableWktVo;
|
|
|
+import com.onemap.analyse.domain.vo.SelectPilotVo;
|
|
|
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.CreateUtilsDBService;
|
|
|
import com.onemap.analyse.service.IFzssService;
|
|
|
import com.onemap.analyse.service.ILogService;
|
|
|
import com.onemap.analyse.service.IReportService;
|
|
@@ -32,7 +36,6 @@ import static com.onemap.analyse.utils.Fxfw2SdeUtils.vector2Sde;
|
|
|
|
|
|
@Service
|
|
|
public class FzssServiceImpl implements IFzssService {
|
|
|
- private FxfwDictDTO fxfwDictDTO = new FxfwDictDTO();
|
|
|
@Value("${Hgxfx.temp}")
|
|
|
private String temp;
|
|
|
// 任务状态标识码
|
|
@@ -68,10 +71,6 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
@Resource
|
|
|
private ILogService iLogService;
|
|
|
|
|
|
- // 选址结果汇总
|
|
|
- @Resource
|
|
|
- private FzxzTbMapper fzxzTbMapper;
|
|
|
-
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public RequestResult AddHgxfx(HgxfxEntityDTO hgxfxEntityDTO) throws IOException {
|
|
@@ -107,30 +106,36 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
return RequestResult.success("保存成功!", requestHgxfxDTO.getBsm());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // **需要拿出来的逻辑**//
|
|
|
+ // @Resource
|
|
|
+ // AnalyseUtilsDBController analyseUtilsDBController;
|
|
|
+ @Resource
|
|
|
+ private CreateUtilsDBService createUtilsDBService;
|
|
|
+ //**需要拿出来的逻辑**//
|
|
|
+
|
|
|
/**
|
|
|
* 保存选址参数
|
|
|
*
|
|
|
- * @param params
|
|
|
+ * @param selectPilotVo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Master
|
|
|
- public FzxzCalc saveScheduleParam(Map params) {
|
|
|
+ public FzxzCalc saveScheduleParam(SelectPilotVo selectPilotVo) {
|
|
|
FzxzCalc fzxzCalc = new FzxzCalc();
|
|
|
// 辅助选址
|
|
|
- FzxzDTO fzxzDTO = DozerUtils.map(params, FzxzDTO.class);
|
|
|
+ FzxzDTO fzxzDTO = selectPilotVo;
|
|
|
fzxzDTO.setBsm(StringUtils.getUUID());
|
|
|
fzxzDTO.setCjsj(new Date());
|
|
|
fzxzDTO.setYdxz_bsm(fzxzDTO.getYdxz_bsm().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
|
|
// 选址因子
|
|
|
- ArrayList xzyx = (ArrayList) params.get("yxyz");
|
|
|
- List<FactorUseDTO> xzyxList = new ArrayList<>();
|
|
|
- for (int i = 0; i < xzyx.size(); i++) {
|
|
|
- FactorUseDTO factorUseDTO = DozerUtils.map(xzyx.get(i), FactorUseDTO.class);
|
|
|
+ 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());
|
|
|
- xzyxList.add(factorUseDTO);
|
|
|
}
|
|
|
|
|
|
// 存储规划任务
|
|
@@ -138,9 +143,9 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
fzxzDTO.setUserId(SecurityUtils.getUserId());
|
|
|
|
|
|
fzxzCalc.setFzxzDTO(fzxzDTO);
|
|
|
- fzxzCalc.setXzyxList(xzyxList);
|
|
|
+ fzxzCalc.setFactorUseList(factorUseDTOS);
|
|
|
|
|
|
- for (FactorUseDTO dto : fzxzCalc.getXzyxList()) {
|
|
|
+ for (FactorUseDTO dto : fzxzCalc.getFactorUseList()) {
|
|
|
fzxzXzyzMapper.insert(dto);
|
|
|
}
|
|
|
fzxzMapper.insert(fzxzCalc.getFzxzDTO());
|
|
@@ -180,8 +185,10 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
@Override
|
|
|
public RequestResult startSchedule(FzxzCalc fzxzCalc) {
|
|
|
FzxzDTO fzxzDTO = fzxzCalc.getFzxzDTO();
|
|
|
+ String taskId = fzxzDTO.getBsm();
|
|
|
+
|
|
|
// 0.开始规划,更新任务状态
|
|
|
- updateFzxzStatus(fzxzDTO.getBsm(), Rwzt.getRun());
|
|
|
+ updateFzxzStatus(taskId, Rwzt.getRun());
|
|
|
|
|
|
// TODO 数据源
|
|
|
String sjyName = "";
|
|
@@ -190,83 +197,62 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
}
|
|
|
|
|
|
// 开始分析
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "开始分析", "info");
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", "开始分析", "info");
|
|
|
List<String> factorBsmList = new ArrayList<>();
|
|
|
- for (FactorUseDTO fzxzXzyzDTO : fzxzCalc.getXzyxList()) {
|
|
|
+ for (FactorUseDTO fzxzXzyzDTO : fzxzCalc.getFactorUseList()) {
|
|
|
factorBsmList.add(fzxzXzyzDTO.getFactorBsm());
|
|
|
}
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "选址参数", "info");
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", "选址参数", "info");
|
|
|
|
|
|
// 1.区域筛选
|
|
|
- // TODO:每一步都要判断ids是否为空
|
|
|
GeomRes geomRes = shpFileMapper.getOne(fzxzDTO.getGeomId());
|
|
|
-
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "载入选址范围完成", "info");
|
|
|
-
|
|
|
- Map<String, String> paramMap = new HashMap<>();
|
|
|
- paramMap.put("geom", geomRes.getGeom());
|
|
|
- paramMap.put("sjy", fzxzDTO.getSjy());
|
|
|
- List<Integer> ids = ghdkaMapper.getIdByGeom(paramMap);
|
|
|
- if (ids.size() == 0) {
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "计算完成,未找到符合条件数据", "info");
|
|
|
- updateFzxzStatus(fzxzDTO.getBsm(), Rwzt.getNoJX());
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", "载入选址范围完成", "info");
|
|
|
+
|
|
|
+ // 地块切割
|
|
|
+ String ewkt = geomRes.getGeom();
|
|
|
+ IntersectionTableWktVo intersectionTableWktVo = new IntersectionTableWktVo();
|
|
|
+ intersectionTableWktVo.setTableName(fzxzDTO.getSjy());
|
|
|
+ intersectionTableWktVo.setEwkt(ewkt);
|
|
|
+ String temporaryTable = createUtilsDBService.intersectionTableWkt(intersectionTableWktVo.getTableName(), null, intersectionTableWktVo.getEwkt());
|
|
|
+
|
|
|
+ Integer integer = ghdkaMapper.getTableCount(temporaryTable);
|
|
|
+ if (integer == 0) {
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", "计算完成,未找到区域内数据", "info");
|
|
|
+ updateFzxzStatus(taskId, Rwzt.getNoJX());
|
|
|
return RequestResult.error("区域筛选条件筛选未找到符合条件数据!", null);
|
|
|
}
|
|
|
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "相交裁剪" + sjyName, "info");
|
|
|
- // 2.面积筛选
|
|
|
- Map<String, Object> areaMap = new HashMap<>();
|
|
|
- areaMap.put("sjy", fzxzDTO.getSjy());
|
|
|
- areaMap.put("beginArea", fzxzDTO.getYdmjbegin());
|
|
|
- areaMap.put("endArea", fzxzDTO.getYdmjend());
|
|
|
- areaMap.put("idList", ids);
|
|
|
- ids = ghdkaMapper.getIdByArea(areaMap);
|
|
|
- if (ids.size() == 0) {
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "计算完成,未找到符合条件数据", "info");
|
|
|
- updateFzxzStatus(fzxzDTO.getBsm(), Rwzt.getNoJX());
|
|
|
- return RequestResult.error("面积筛选条件筛选未找到符合条件数据!", null);
|
|
|
- }
|
|
|
-
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "地块面积分析完成", "info");
|
|
|
-
|
|
|
- // 3.用地类型(性质)筛选
|
|
|
- Map<String, Object> landTypeMap = new HashMap<>();
|
|
|
- landTypeMap.put("sjy", fzxzDTO.getSjy());
|
|
|
- landTypeMap.put("landTypeCode", fzxzDTO.getYdxz_bsm());
|
|
|
- landTypeMap.put("idList", ids);
|
|
|
- ids = ghdkaMapper.getIdLandType(landTypeMap);
|
|
|
- if (ids.size() == 0) {
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "计算完成,未找到符合条件数据", "info");
|
|
|
- updateFzxzStatus(fzxzDTO.getBsm(), Rwzt.getNoJX());
|
|
|
- return RequestResult.error("用地性质条件筛选未找到符合条件数据!", null);
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", "相交裁剪" + sjyName, "info");
|
|
|
+ // TODO 2.面积筛选
|
|
|
+ // Map<String, Object> areaMap = new HashMap<>();
|
|
|
+ // areaMap.put("sjy", fzxzDTO.getSjy());
|
|
|
+ // areaMap.put("beginArea", fzxzDTO.getYdmjbegin());
|
|
|
+ // areaMap.put("endArea", fzxzDTO.getYdmjend());
|
|
|
+ // areaMap.put("idList", ids);
|
|
|
+ // ids = ghdkaMapper.getIdByArea(areaMap);
|
|
|
+ // if (ids.size() == 0) {
|
|
|
+ // iLogService.saveLog(taskId, "辅助选址", "计算完成,未找到符合条件数据", "info");
|
|
|
+ // updateFzxzStatus(taskId, Rwzt.getNoJX());
|
|
|
+ // return RequestResult.error("面积筛选条件筛选未找到符合条件数据!", null);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // iLogService.saveLog(taskId, "辅助选址", "地块面积分析完成", "info");
|
|
|
+
|
|
|
+ // 3.用地类型(性质)筛选
|
|
|
+ ghdkaMapper.delByLandType(temporaryTable, fzxzDTO.getSjy(), fzxzDTO.getYdxz_bsm());
|
|
|
+ integer = ghdkaMapper.getTableCount(temporaryTable);
|
|
|
+ if (integer == 0) {
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", "计算完成,未找到符合用地性质条件数据", "info");
|
|
|
+ updateFzxzStatus(taskId, Rwzt.getNoJX());
|
|
|
+ return RequestResult.error("区域筛选条件筛选未找到符合条件数据!", null);
|
|
|
}
|
|
|
|
|
|
// 4.规划因子筛选
|
|
|
- GhdkaFilter ghdkaFilter = new GhdkaFilter();
|
|
|
- ghdkaFilter.setSjy(fzxzDTO.getSjy());
|
|
|
- ghdkaFilter.setIdList(ids);
|
|
|
- for (FactorUseDTO fzxzXzyzDTO : fzxzCalc.getXzyxList()) {
|
|
|
- ghdkaFilter.setFactorUseDTO(fzxzXzyzDTO);
|
|
|
- ids = ghdkaMapper.getIdByFilter(ghdkaFilter);
|
|
|
- if (ids.size() == 0) {
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "计算完成,未找到符合条件数据", "info");
|
|
|
- updateFzxzStatus(fzxzDTO.getBsm(), Rwzt.getNoJX());
|
|
|
- return RequestResult.error(fzxzXzyzDTO.getFactorName() + "条件筛选未找到符合条件数据!", null);
|
|
|
- }
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", fzxzXzyzDTO.getFactorName() + "因子影响分析完成", "info");
|
|
|
- ghdkaFilter.setIdList(ids);
|
|
|
- }
|
|
|
-
|
|
|
- if (ids.size() == 0) {
|
|
|
- iLogService.saveLog(fzxzDTO.getBsm(), "辅助选址", "计算完成,未找到符合条件数据", "info");
|
|
|
- updateFzxzStatus(fzxzDTO.getBsm(), Rwzt.getNoJX());
|
|
|
- String yxyzmc = fzxzCalc.getXzyxList().size() != 0 ? fzxzCalc.getXzyxList().get(0).getFactorName() : "";
|
|
|
- return RequestResult.error(yxyzmc + "条件筛选未找到符合条件数据!", null);
|
|
|
- }
|
|
|
+ factorFilter(taskId, temporaryTable, fzxzCalc.getFactorUseList(), ewkt);
|
|
|
|
|
|
// 5.保存规划结果
|
|
|
Map<String, Object> scheduleResMap = new HashMap<>();
|
|
|
- scheduleResMap.put("dkIds", ids);
|
|
|
+ // TODO scheduleResMap.put("dkIds", ids);
|
|
|
scheduleResMap.put("rwbsm", fzxzDTO.getBsm());
|
|
|
scheduleResMap.put("sjyb", fzxzDTO.getSjy());
|
|
|
// TODO 用地性质待定
|
|
@@ -284,10 +270,77 @@ public class FzssServiceImpl implements IFzssService {
|
|
|
updateFzxzStatus(fzxzDTO.getBsm(), Rwzt.getComplete());
|
|
|
Map<String, Object> resMap = new HashMap<>();
|
|
|
resMap.put("rwbsm", fzxzDTO.getBsm());
|
|
|
- resMap.put("dkIds", ids);
|
|
|
+ // resMap.put("dkIds", ids);
|
|
|
return RequestResult.success(resMap);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据因子筛选地块
|
|
|
+ *
|
|
|
+ * @param taskId
|
|
|
+ * @param rawTable
|
|
|
+ * @param factorUseDTOS
|
|
|
+ * @param ewkt
|
|
|
+ */
|
|
|
+ private void factorFilter(String taskId, String rawTable, List<FactorUseDTO> factorUseDTOS, String ewkt) {
|
|
|
+ for (FactorUseDTO factorUseDTO : factorUseDTOS) {
|
|
|
+ if (factorUseDTO.getSpatialType().equals("intersect")) {
|
|
|
+ // 相交判断
|
|
|
+ // 1.先切割因子地块
|
|
|
+ String temporaryTable = createUtilsDBService.intersectionTableWkt(factorUseDTO.getFactorBsm(), null, ewkt);
|
|
|
+ Integer integer = ghdkaMapper.getTableCount(temporaryTable);
|
|
|
+ if (integer == 0) {
|
|
|
+ // TODO 再定
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 2.生成因子地块缓冲区
|
|
|
+ if (factorUseDTO.getDefaultValue() == 0) {
|
|
|
+ // 没有值直接计算
|
|
|
+ temporaryTable = createUtilsDBService.bufferTable(temporaryTable, factorUseDTO.getDefaultValue());
|
|
|
+
|
|
|
+ integer = ghdkaMapper.getTableCount(temporaryTable);
|
|
|
+ if (integer == 0) {
|
|
|
+ // TODO 再定
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.地块切割
|
|
|
+ if (factorUseDTO.getDefaultType().equals("intersect")) {
|
|
|
+ // 相交判断
|
|
|
+ temporaryTable = createUtilsDBService.differenceTables(rawTable, null, temporaryTable);
|
|
|
+ } else {
|
|
|
+ // 不相交判断
|
|
|
+ temporaryTable = createUtilsDBService.differenceTables(rawTable, null, temporaryTable);
|
|
|
+ }
|
|
|
+ System.out.println(temporaryTable);
|
|
|
+ } else if (factorUseDTO.getSpatialType().equals("contain")) {
|
|
|
+ // 包含判断
|
|
|
+ if (factorUseDTO.getDefaultValue() == 0) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if (factorUseDTO.getSpatialType().equals("distance")) {
|
|
|
+ // 距离判断
|
|
|
+ if (factorUseDTO.getDefaultValue() == 0) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (0 == 0) {
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", "计算完成,未找到符合条件数据", "info");
|
|
|
+ updateFzxzStatus(taskId, Rwzt.getNoJX());
|
|
|
+ // TODO
|
|
|
+ // return RequestResult.error(fzxzXzyzDTO.getFactorName() + "条件筛选未找到符合条件数据!", null);
|
|
|
+ }
|
|
|
+ iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存选址结果
|
|
|
*
|