|
@@ -1,16 +1,24 @@
|
|
|
package com.siwei.apply.service.impl;
|
|
package com.siwei.apply.service.impl;
|
|
|
|
|
|
|
|
import com.siwei.apply.domain.DecisionTask;
|
|
import com.siwei.apply.domain.DecisionTask;
|
|
|
|
|
+import com.siwei.apply.domain.vo.DecisionIntersectsDetailsVo;
|
|
|
import com.siwei.apply.domain.vo.DecisionTaskFilterVo;
|
|
import com.siwei.apply.domain.vo.DecisionTaskFilterVo;
|
|
|
import com.siwei.apply.domain.vo.DecisionTaskVo;
|
|
import com.siwei.apply.domain.vo.DecisionTaskVo;
|
|
|
|
|
+import com.siwei.apply.enums.DecisionType;
|
|
|
import com.siwei.apply.mapper.DecisionTaskMapper;
|
|
import com.siwei.apply.mapper.DecisionTaskMapper;
|
|
|
import com.siwei.apply.service.DecisionTaskService;
|
|
import com.siwei.apply.service.DecisionTaskService;
|
|
|
|
|
+import com.siwei.common.core.exception.ServiceException;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class DecisionTaskServiceImpl implements DecisionTaskService {
|
|
public class DecisionTaskServiceImpl implements DecisionTaskService {
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -55,21 +63,56 @@ public class DecisionTaskServiceImpl implements DecisionTaskService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- //todo 这里的分析逻辑比较复杂,后续再完善,目前先占位
|
|
|
|
|
- //1.先把分析结果保存到数据库,状态为处理中
|
|
|
|
|
- //2.分析完成后更新数据库状态为已完成,并保存分析结果的文件路径
|
|
|
|
|
- //3.分析过程中可以通过查询接口查询分析状态和结果
|
|
|
|
|
- //4.异步方法进行返回,并且可以返回数据id
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public DecisionTask analyse(String name, String shape, Integer shapeType, String shapeFilePath, List<Integer> dataType) {
|
|
public DecisionTask analyse(String name, String shape, Integer shapeType, String shapeFilePath, List<Integer> dataType) {
|
|
|
|
|
+ if (StringUtils.isBlank(name)) {
|
|
|
|
|
+ throw new ServiceException("任务名称不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ // shape(EWKT) 为必填项
|
|
|
|
|
+ if (StringUtils.isBlank(shape)) {
|
|
|
|
|
+ throw new ServiceException("几何形状(EWKT)不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (shapeType == null) {
|
|
|
|
|
+ throw new ServiceException("分析方式不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollectionUtils.isEmpty(dataType)) {
|
|
|
|
|
+ throw new ServiceException("分析数据类型不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // shapeType 如果为2时候,shapeFilePath 为必填项
|
|
|
|
|
+ if (shapeType == 2 && StringUtils.isBlank(shapeFilePath)) {
|
|
|
|
|
+ throw new ServiceException("SHP文件路径不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-// String name = Objects.nonNull(paramData.get("name")) ? String.valueOf(paramData.get("name")):"";
|
|
|
|
|
-// String shape = Objects.nonNull(paramData.get("shape")) ? String.valueOf(paramData.get("shape")):"";//ewkt
|
|
|
|
|
-// Integer shapeType = Objects.nonNull(paramData.get("shapeType")) ? (Integer) paramData.get("shapeType") : -1;
|
|
|
|
|
-// String shapeFilePath = Objects.nonNull(paramData.get("shapeFilePath")) ? String.valueOf(paramData.get("shapeFilePath")):"";
|
|
|
|
|
-// List<Integer> dataType = Objects.nonNull(paramData.get("dataType")) ? (List<Integer>) paramData.get("dataType"):new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ DecisionTask decisionTask = new DecisionTask();
|
|
|
|
|
+ decisionTask.generateId();
|
|
|
|
|
+ decisionTask.setName(name);
|
|
|
|
|
+ decisionTask.setStatus("1"); // 任务状态 0 创建 1 执行中 2 成功 3 失败
|
|
|
|
|
+ decisionTask.setCreateTime(new Date());
|
|
|
|
|
+ decisionTask.setGeom(shape);
|
|
|
|
|
+ decisionTask.setShapeArea(BigDecimal.valueOf(0.0)); // 这里进行占位符
|
|
|
|
|
+ decisionTask.setFilePath(shapeFilePath);
|
|
|
|
|
+ decisionTaskMapper.add(decisionTask);
|
|
|
|
|
+ //return decisionTask;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Arrays.stream(DecisionType.values()).forEach(type -> {
|
|
|
|
|
+ if(dataType.contains(Integer.parseInt(type.getCode()))) {
|
|
|
|
|
+ List<String> tableIds = new ArrayList<>();
|
|
|
|
|
+ DecisionIntersectsDetailsVo param = new DecisionIntersectsDetailsVo();
|
|
|
|
|
+ param.setTaskId(decisionTask.getId());
|
|
|
|
|
+ param.setTableName(type.getTable());
|
|
|
|
|
+ param.setType(Integer.parseInt(type.getCode()));
|
|
|
|
|
+ param.setSourceId(type.getSourceId());
|
|
|
|
|
+ param.setDetailsName(type.getDetailsName());
|
|
|
|
|
+ param.setEwkt(shape);
|
|
|
|
|
+ param.setTableIds(tableIds);
|
|
|
|
|
+ decisionTaskMapper.insertDecisionIntersection(param);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return decisionTask;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|