Explorar o código

更新获取详情数据方法

chenendian hai 1 mes
pai
achega
d40ba9dd3a

+ 38 - 43
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/DecisionTaskController.java

@@ -98,51 +98,48 @@ public class DecisionTaskController extends BaseController {
     @PostMapping("/detailsList")
     public R<Map<String, Object>> detailsByTaskId(@RequestBody DecisionTaskFilterVo filterVo) {
         try {
-
             String taskId = filterVo.getTaskId();
             System.out.println(taskId+"------------------");
-
             Map<String, Object> result = new HashMap<>();
-            DecisionTask decisionTask = new DecisionTask();
-            decisionTask.setId("123");
-            decisionTask.setName("测试任务");
-            decisionTask.setStatus("待处理");
+//            DecisionTask decisionTask = new DecisionTask();
+//            decisionTask.setId("123");
+//            decisionTask.setName("测试任务");
+//            decisionTask.setStatus("待处理");
+//            result.put("decisionTask", decisionTask);
+//
+//            DecisionDetailsVo aa = new DecisionDetailsVo();
+//            aa.setName("与权属宗地分析情况");
+//            aa.setType(4);
+//
+//            Map<String, Object> subMap1 = new HashMap<>();
+//            subMap1.put("zddm", "123456789");
+//            subMap1.put("area", 1234567);
+//            subMap1.put("qlr", "张三");
+//            subMap1.put("id", "bad6ca22b2e54f46b6c9835cc2040b57");
+//
+//            Map<String, Object> subMap2 = new HashMap<>();
+//            subMap2.put("zddm", "123456789");
+//            subMap2.put("area", 1234567);
+//            subMap2.put("qlr", "张三");
+//            subMap2.put("id", "bad6ca22b2e54f46b6c9835cc20445567");
+//
+//            List<Map<String,Object>> dataList = List.of(
+//                    subMap1,
+//                    subMap2
+//            );
+//            aa.setDataList(dataList);
+
+
+
+//            List<DecisionDetailsVo> detailsList = List.of(
+//                            aa,
+//                    new DecisionDetailsVo(),
+//                    new DecisionDetailsVo()
+//            );
+
+            DecisionTask decisionTask = decisionTaskService.get(taskId);
+            List<DecisionDetailsVo>  detailsList  = decisionTaskService.detailsList(taskId);
             result.put("decisionTask", decisionTask);
-
-            DecisionDetailsVo aa = new DecisionDetailsVo();
-            aa.setName("与权属宗地分析情况");
-            aa.setType(4);
-
-            Map<String, Object> subMap1 = new HashMap<>();
-            subMap1.put("zddm", "123456789");
-            subMap1.put("area", 1234567);
-            subMap1.put("qlr", "张三");
-            subMap1.put("id", "bad6ca22b2e54f46b6c9835cc2040b57");
-
-            Map<String, Object> subMap2 = new HashMap<>();
-            subMap2.put("zddm", "123456789");
-            subMap2.put("area", 1234567);
-            subMap2.put("qlr", "张三");
-            subMap2.put("id", "bad6ca22b2e54f46b6c9835cc20445567");
-
-            List<Map<String,Object>> dataList = List.of(
-                    subMap1,
-                    subMap2
-            );
-
-            aa.setDataList(dataList);
-
-            List<DecisionDetailsVo> detailsList = List.of(
-                            aa,
-                    new DecisionDetailsVo(),
-                    new DecisionDetailsVo()
-            );
-
-
-
-            decisionTaskService.detailsList(taskId);
-
-
             result.put("detailsList", detailsList);
             return R.ok(result);
         } catch (Exception e) {
@@ -153,6 +150,4 @@ public class DecisionTaskController extends BaseController {
 
 
 
-
-
 }

+ 2 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/DecisionTask.java

@@ -26,6 +26,8 @@ public class DecisionTask extends BaseId {
 
     private String geom;
 
+    private String typeId;
+
     private String reportPath;
 
     private String filePath;

+ 2 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/enums/DecisionType.java

@@ -20,8 +20,8 @@ public enum DecisionType {
      * extraFields:查询业务表时需要额外返回的字段名列表(动态拼接到 SELECT 中)
      * 字段名需与业务表列名完全一致
      */
-    DECISION_TYPE_4("4", "所有权宗地", "zdjbxx", "zddm", "gmjjhyfldm", "zddm", "qlrsjsyrlxm"),
-    DECISION_TYPE_5("5", "使用权宗地", "zdjbxx", "zddm", "gmjjhyfldm", "zddm", "qlrsjsyrlxm");
+    DECISION_TYPE_4("4", "所有权宗地", "zdjbxx", "zddm", "gmjjhyfldm", "zddm", "qlrsjsyrlxm","zdszx"),
+    DECISION_TYPE_5("5", "使用权宗地", "zdjbxx", "zddm", "gmjjhyfldm", "zddm", "qlrsjsyrlxm","zdszx");
 
 
     private final String name;

+ 41 - 18
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/DecisionTaskServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -89,40 +90,57 @@ public class DecisionTaskServiceImpl implements DecisionTaskService {
             shape = "SRID=" + "4326" + ";" + shape;
         }
 
+        Date now = new Date();
         DecisionTask decisionTask = new DecisionTask();
         decisionTask.generateId();
         decisionTask.setName(name);
         decisionTask.setStatus("1"); // 任务状态 0 创建 1 执行中 2 成功 3 失败
-        decisionTask.setCreateTime(new Date());
+        decisionTask.setCreateTime(now);
+        decisionTask.setStartTime(now);
         decisionTask.setGeom(shape);
+        decisionTask.setTypeId(dataType.stream().map(Object::toString).collect(Collectors.joining(",")));// 这里将数据类型列表转换为逗号分隔的字符串存储
         decisionTask.setShapeArea(BigDecimal.valueOf(0.0)); // 这里进行占位符
         decisionTask.setFilePath(shapeFilePath);
         decisionTaskMapper.add(decisionTask);
         //return decisionTask;
 
-
         String finalShape = shape;
-        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(finalShape);
-                param.setTableIds(tableIds);
-                decisionTaskMapper.insertDecisionIntersection(param);
-            }
-        });
+        try{
+            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(finalShape);
+                    param.setTableIds(tableIds);
+                    decisionTaskMapper.insertDecisionIntersection(param);
+                }
+            });
+
+            DecisionTask decisionTaskForUpdate = new DecisionTask();
+            decisionTaskForUpdate.setId(decisionTask.getId());
+            decisionTaskForUpdate.setStatus("2"); // 任务状态 0 创建 1 执行中 2 成功 3 失败
+            decisionTaskForUpdate.setEndTime(new Date());
+            decisionTaskMapper.update(decisionTaskForUpdate);
+        }catch (Exception e){
+            e.printStackTrace();
+            log.warn("------数据分析交集计算出现异常,{}",e);
+        }finally {
+            DecisionTask decisionTaskForUpdate = new DecisionTask();
+            decisionTaskForUpdate.setId(decisionTask.getId());
+            decisionTaskForUpdate.setStatus("3"); // 任务状态 0 创建 1 执行中 2 成功 3 失败
+            decisionTaskForUpdate.setEndTime(new Date());
+            decisionTaskMapper.update(decisionTaskForUpdate);
+        }
         return decisionTask;
     }
 
 
 
-
-
     /**
      *
      * 根据当前任务id,返回此次任务的所有结果,并且需要根据不同类型动态查询
@@ -150,6 +168,11 @@ public class DecisionTaskServiceImpl implements DecisionTaskService {
 
         // 遍历所有 DecisionType,逐类型查询并组装结果
         for (DecisionType decisionType : DecisionType.values()) {
+            if(!StringUtils.containsAny(task.getTypeId(), decisionType.getCode())) {
+                log.info("------当前任务id:{},不包含数据类型:{},跳过查询", taskId, decisionType.getName());
+                continue;
+            }
+
             DecisionTaskParamVo param = new DecisionTaskParamVo();
             param.setTaskId(taskId);
             param.setType(Integer.parseInt(decisionType.getCode()));

+ 6 - 4
siwei-modules/siwei-apply/src/main/resources/mapper/DecisionTaskMapper.xml

@@ -12,23 +12,24 @@
         <result column="status" property="status"/>
         <result column="shape_area" property="shapeArea"/>
         <result column="geom" property="geom"/>
+        <result column="type_id" property="typeId"/>
         <result column="report_path" property="reportPath"/>
         <result column="file_path" property="filePath"/>
     </resultMap>
 
     <insert id="add" parameterType="com.siwei.apply.domain.DecisionTask">
-        INSERT INTO t_decision_task (task_id, name, start_time, end_time, create_time, status, shape_area, geom, report_path, file_path)
-        VALUES (#{id}, #{name}, #{startTime}, #{endTime}, #{createTime}, #{status}, #{shapeArea}, ST_GeomFromEWKT(#{geom}), #{reportPath}, #{filePath})
+        INSERT INTO t_decision_task (task_id, name, start_time, end_time, create_time, status, shape_area, geom,type_id,  report_path, file_path)
+        VALUES (#{id}, #{name}, #{startTime}, #{endTime}, #{createTime}, #{status}, #{shapeArea}, ST_GeomFromEWKT(#{geom}),#{typeId}, #{reportPath}, #{filePath})
     </insert>
 
     <select id="get" resultMap="decisionTaskMap">
-        SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom, report_path, file_path
+        SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom,type_id, report_path, file_path
         FROM t_decision_task
         WHERE task_id = #{id}
     </select>
 
     <select id="getList" parameterType="com.siwei.apply.domain.vo.DecisionTaskFilterVo" resultMap="decisionTaskMap">
-        SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom, report_path, file_path
+        SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom,type_id,  report_path, file_path
         FROM t_decision_task
         <where>
             <if test="name != null and name != ''">
@@ -76,6 +77,7 @@
             <if test="status != null">status = #{status},</if>
             <if test="shapeArea != null">shape_area = #{shapeArea},</if>
             <if test="geom != null">geom = ST_GeomFromEWKT(#{geom}),</if>
+            <if test="typeId != null">type_id = #{typeId},</if>
             <if test="reportPath != null">report_path = #{reportPath},</if>
             <if test="filePath != null">file_path = #{filePath},</if>
         </set>