Ver código fonte

调整资源依赖关系,json解析

chenendian 3 meses atrás
pai
commit
5f3fc62080

+ 1 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/ProjectController.java

@@ -177,6 +177,7 @@ public class ProjectController extends BaseController {
     @PostMapping("/listSearch")
     @PostMapping("/listSearch")
     public R<Map<String, Object>> GetListByKeyWord(@RequestBody ProjectFilterVo projectFilterVo) {
     public R<Map<String, Object>> GetListByKeyWord(@RequestBody ProjectFilterVo projectFilterVo) {
         try {
         try {
+            projectService.testData();
             Map<String, Object> projects = projectService.getListSearch(projectFilterVo);
             Map<String, Object> projects = projectService.getListSearch(projectFilterVo);
             return R.ok(projects);
             return R.ok(projects);
         } catch (Exception e) {
         } catch (Exception e) {

+ 1 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/enums/TdgyAttachmentNameEnum.java

@@ -8,7 +8,7 @@ import com.siwei.apply.common.UnifyAttachmentEnum;
  */
  */
 public enum TdgyAttachmentNameEnum implements UnifyAttachmentEnum {
 public enum TdgyAttachmentNameEnum implements UnifyAttachmentEnum {
     NAME_1("1", "土地权属来源文件", "用地批复", "土地供应阶段"),
     NAME_1("1", "土地权属来源文件", "用地批复", "土地供应阶段"),
-    NAME_2("2", "规划条件出具", "用地红线|规划条件出具", "土地供应阶段"),
+    NAME_2("2", "规划条件出具", "用地红线:t_tjyydhx|规划条件出具:t_tjyydhx", "土地供应阶段"),
     NAME_3("3", "出让图形", "用地红线", "土地供应阶段"),
     NAME_3("3", "出让图形", "用地红线", "土地供应阶段"),
     NAME_4("4", "出让方案批复文件", "", "土地供应阶段"),
     NAME_4("4", "出让方案批复文件", "", "土地供应阶段"),
     NAME_5("5", "主体资格文件", "", "土地供应阶段"),
     NAME_5("5", "主体资格文件", "", "土地供应阶段"),

+ 1 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/NodeAttachmentService.java

@@ -56,5 +56,6 @@ public interface NodeAttachmentService {
 
 
     NodeAttachment getNodeAttachmentData(String nodeId);
     NodeAttachment getNodeAttachmentData(String nodeId);
 
 
+    NodeAttachment getAttachmentByProjectIdAndTable(String projectId,String nodeTableName) ;
 
 
     }
     }

+ 1 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/ProjectService.java

@@ -74,8 +74,7 @@ public interface ProjectService {
 
 
     JSONArray getResourceData() throws IOException;
     JSONArray getResourceData() throws IOException;
 
 
-
-
+    void testData() ;
 
 
 }
 }
 
 

+ 85 - 23
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/NodeAttachmentImpl.java

@@ -1,5 +1,6 @@
 package com.siwei.apply.service.impl;
 package com.siwei.apply.service.impl;
 
 
+import com.siwei.apply.common.UnifyAttachmentEnum;
 import com.siwei.apply.domain.NodeAttachment;
 import com.siwei.apply.domain.NodeAttachment;
 import com.siwei.apply.domain.Project;
 import com.siwei.apply.domain.Project;
 import com.siwei.apply.domain.ProjectWorkflow;
 import com.siwei.apply.domain.ProjectWorkflow;
@@ -12,10 +13,10 @@ import com.siwei.apply.service.NodeAttachmentService;
 import com.siwei.apply.service.TdgyService;
 import com.siwei.apply.service.TdgyService;
 import com.siwei.apply.utils.FileExtractUtil;
 import com.siwei.apply.utils.FileExtractUtil;
 import com.siwei.apply.utils.ServiceUtil;
 import com.siwei.apply.utils.ServiceUtil;
-import com.siwei.common.core.domain.R;
 import com.siwei.common.core.exception.ServiceException;
 import com.siwei.common.core.exception.ServiceException;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.annotations.Param;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +26,6 @@ import org.springframework.transaction.annotation.Transactional;
 import java.nio.file.*;
 import java.nio.file.*;
 import java.util.*;
 import java.util.*;
 
 
-import static com.siwei.apply.utils.ServiceUtil.assemblyAttachment;
 
 
 /**
 /**
  * 记录流程对应的附件材料 服务实现类
  * 记录流程对应的附件材料 服务实现类
@@ -268,8 +268,6 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
         }
         }
     }
     }
     
     
-
-    
     /**
     /**
      * 保存附件信息
      * 保存附件信息
      */
      */
@@ -284,6 +282,7 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
     }
     }
 
 
 
 
+
     /**
     /**
      * 修改节点附件信息
      * 修改节点附件信息
      */
      */
@@ -297,6 +296,20 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
     }
     }
 
 
 
 
+    @Override
+    public NodeAttachment getAttachmentByProjectIdAndTable(String projectId,String nodeTableName) {
+        NodeAttachment nodeAttachment = null;
+        List<ProjectWorkflow> projectWorkflows = projectWorkflowMapper.selectByProjectIdAndNodeTableName(projectId, nodeTableName);
+        Optional<ProjectWorkflow> res = projectWorkflows.stream().findFirst();
+        if(res.isPresent()){
+            String nodeId = res.get().getNodeId();
+            logger.info("-------getAttachmentByProjectIdAndTable-----"+nodeId);
+            nodeAttachment = this.getByNodeId(nodeId);
+        }
+        return nodeAttachment;
+    }
+
+
 
 
     /**
     /**
      * 根据节点ID获取当前节点的附件信息
      * 根据节点ID获取当前节点的附件信息
@@ -312,7 +325,6 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
      *             3.查询出当前节点信息,解析object对象
      *             3.查询出当前节点信息,解析object对象
      *             4.如果存在引用关系,查询出所有被引用节点的附件信息
      *             4.如果存在引用关系,查询出所有被引用节点的附件信息
      *             5.重新组装object信息并且生成json对象展示。
      *             5.重新组装object信息并且生成json对象展示。
-     *
      *              找到当前枚举类,
      *              找到当前枚举类,
      *              查看其依赖关系
      *              查看其依赖关系
      *              根据依赖关系把其它数据进行整理。
      *              根据依赖关系把其它数据进行整理。
@@ -333,12 +345,12 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
                 throw new ServiceException("未查询到节点对应的流程信息,nodeId: " + nodeId);
                 throw new ServiceException("未查询到节点对应的流程信息,nodeId: " + nodeId);
             }
             }
             String nodeTableName = projectWorkflow.getNodeTableName();
             String nodeTableName = projectWorkflow.getNodeTableName();
-            Project project =projectMapper.get(projectWorkflow.getProjectId());
+            String projectId = projectWorkflow.getProjectId();
+            Project project =projectMapper.get(projectId);
             Integer projectType = project.getProjectType();
             Integer projectType = project.getProjectType();
 
 
             //最终结果集合
             //最终结果集合
-            Map <String, List<String>> currentNodeAttachmentMap = new LinkedHashMap<>();
-            Map <String, List<String>> relationNodeAttachmentMap = new LinkedHashMap<>();
+            Map <String, Object> currentNodeAttachmentMap = null;
 
 
             //单独选址
             //单独选址
             if(ProjectType.ALONE.getCode().equals(String.valueOf(projectType))){
             if(ProjectType.ALONE.getCode().equals(String.valueOf(projectType))){
@@ -349,50 +361,51 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
                     //取当前节点数据内容;
                     //取当前节点数据内容;
                     TdgyRes tdgy = tdgyService.getById(nodeId);
                     TdgyRes tdgy = tdgyService.getById(nodeId);
                     String gdType = tdgy.getGdType();
                     String gdType = tdgy.getGdType();
+
+
                     if("出让".equals(gdType)) {
                     if("出让".equals(gdType)) {
                         //处理-规划条件出具依赖
                         //处理-规划条件出具依赖
-                        currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(TdgyAttachmentNameEnum.NAME_2,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                        currentNodeAttachmentMap = this.assemblyAttachment(projectId,TdgyAttachmentNameEnum.NAME_2,nodeAttachment);
                         //处理-出让图形依赖
                         //处理-出让图形依赖
-                        relationNodeAttachmentMap = new LinkedHashMap<>();
-                        currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(TdgyAttachmentNameEnum.NAME_3,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                        currentNodeAttachmentMap = this.assemblyAttachment(projectId,TdgyAttachmentNameEnum.NAME_3,nodeAttachment);
 
 
                     }else if("划拨".equals(gdType)) {
                     }else if("划拨".equals(gdType)) {
 
 
                     }
                     }
-                } else if(AloneWorkFlowEnum.NODE_3.getTableName().equalsIgnoreCase(nodeTableName)){
+                }
+                /*
+                else if(AloneWorkFlowEnum.NODE_3.getTableName().equalsIgnoreCase(nodeTableName)){
                     //处理-规划条件出具依赖
                     //处理-规划条件出具依赖
                     relationNodeAttachmentMap = new LinkedHashMap<>();
                     relationNodeAttachmentMap = new LinkedHashMap<>();
-                    currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(GyjsydscdjAttachmentNameEnum.NAME_2,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                    currentNodeAttachmentMap = this.assemblyAttachment(GyjsydscdjAttachmentNameEnum.NAME_2,currentNodeAttachmentMap,relationNodeAttachmentMap);
 
 
                     relationNodeAttachmentMap = new LinkedHashMap<>();
                     relationNodeAttachmentMap = new LinkedHashMap<>();
-                    currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(GyjsydscdjAttachmentNameEnum.NAME_3,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                    currentNodeAttachmentMap = this.assemblyAttachment(GyjsydscdjAttachmentNameEnum.NAME_3,currentNodeAttachmentMap,relationNodeAttachmentMap);
 
 
                     relationNodeAttachmentMap = new LinkedHashMap<>();
                     relationNodeAttachmentMap = new LinkedHashMap<>();
-                    currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(GyjsydscdjAttachmentNameEnum.NAME_4,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                    currentNodeAttachmentMap = this.assemblyAttachment(GyjsydscdjAttachmentNameEnum.NAME_4,currentNodeAttachmentMap,relationNodeAttachmentMap);
 
 
                 } else if(AloneWorkFlowEnum.NODE_4.getTableName().equalsIgnoreCase(nodeTableName)){
                 } else if(AloneWorkFlowEnum.NODE_4.getTableName().equalsIgnoreCase(nodeTableName)){
                     //处理-规划条件出具依赖
                     //处理-规划条件出具依赖
                     relationNodeAttachmentMap = new LinkedHashMap<>();
                     relationNodeAttachmentMap = new LinkedHashMap<>();
-                    currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(JsydghxkAttachmentNameEnum.NAME_3,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                    currentNodeAttachmentMap = this.assemblyAttachment(JsydghxkAttachmentNameEnum.NAME_3,currentNodeAttachmentMap,relationNodeAttachmentMap);
 
 
                 } else if(AloneWorkFlowEnum.NODE_5.getTableName().equalsIgnoreCase(nodeTableName)){
                 } else if(AloneWorkFlowEnum.NODE_5.getTableName().equalsIgnoreCase(nodeTableName)){
                     //处理-规划条件出具依赖
                     //处理-规划条件出具依赖
                     relationNodeAttachmentMap = new LinkedHashMap<>();
                     relationNodeAttachmentMap = new LinkedHashMap<>();
-                    currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(JsgcghxkAttachmentNameEnum.NAME_2,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                    currentNodeAttachmentMap = this.assemblyAttachment(JsgcghxkAttachmentNameEnum.NAME_2,currentNodeAttachmentMap,relationNodeAttachmentMap);
 
 
                 } else if(AloneWorkFlowEnum.NODE_6.getTableName().equalsIgnoreCase(nodeTableName)){
                 } else if(AloneWorkFlowEnum.NODE_6.getTableName().equalsIgnoreCase(nodeTableName)){
                     //处理-规划条件出具依赖
                     //处理-规划条件出具依赖
                     relationNodeAttachmentMap = new LinkedHashMap<>();
                     relationNodeAttachmentMap = new LinkedHashMap<>();
-                    currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(TdhyhsAttachmentNameEnum.NAME_2,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                    currentNodeAttachmentMap = this.assemblyAttachment(TdhyhsAttachmentNameEnum.NAME_2,currentNodeAttachmentMap,relationNodeAttachmentMap);
                 }else if(AloneWorkFlowEnum.NODE_7.getTableName().equalsIgnoreCase(nodeTableName)){
                 }else if(AloneWorkFlowEnum.NODE_7.getTableName().equalsIgnoreCase(nodeTableName)){
                     //处理-规划条件出具依赖
                     //处理-规划条件出具依赖
                     relationNodeAttachmentMap = new LinkedHashMap<>();
                     relationNodeAttachmentMap = new LinkedHashMap<>();
-                    currentNodeAttachmentMap = ServiceUtil.assemblyAttachment(GyjsydjfwscdjAttachmentNameEnum.NAME_1,currentNodeAttachmentMap,relationNodeAttachmentMap);
-                }
-            }
-
-
+                    currentNodeAttachmentMap = this.assemblyAttachment(GyjsydjfwscdjAttachmentNameEnum.NAME_1,currentNodeAttachmentMap,relationNodeAttachmentMap);
+                }*/
 
 
+            }
             return null;
             return null;
         } catch (Exception e) {
         } catch (Exception e) {
             logger.error("查询节点附件信息异常,nodeId: {}", nodeId, e);
             logger.error("查询节点附件信息异常,nodeId: {}", nodeId, e);
@@ -400,6 +413,55 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
         }
         }
     }
     }
 
 
+    /**
+     *
+     * 这里处理依赖关系
+     * 先判断当前是否存在该资料
+     * 1.如果当前节点附件信息不包含该资料,则进行合并
+     * 获取依赖的map,写一个方法:
+     *
+     *
+     */
+    public  Map <String, Object>  assemblyAttachment(String projectId,UnifyAttachmentEnum attachmentEnum,NodeAttachment nodeAttachment){
+        //最终结果集合
+        Map <String, Object> currentNodeAttachmentMap = new LinkedHashMap<>();
+        Map <String, Object> relationNodeAttachmentMap = new LinkedHashMap<>();
+        if(Objects.nonNull(nodeAttachment) && Objects.nonNull(nodeAttachment.getAttachment())) {
+            currentNodeAttachmentMap = nodeAttachment.getAttachment();
+        }
+        String name =  attachmentEnum.getName();
+        List<String> currentAttachmentList = new ArrayList<>();
+
+
+
+
+        if(!currentNodeAttachmentMap.containsKey(name) || Objects.isNull(currentNodeAttachmentMap.get(name))) {
+            List<String> relationNameList = new ArrayList();
+            String relationNameStr = attachmentEnum.getRelationName();
+            if (StringUtils.isNotBlank(relationNameStr)) {
+                relationNameList = Arrays.asList(relationNameStr.split("\\|"));
+                if (CollectionUtils.isNotEmpty(relationNameList)) {
+                    for (String innerRelationNameStr : relationNameList) {
+                        List<String> innerRelationNameList = Arrays.asList(innerRelationNameStr.split("\\:"));
+                        String relationName = innerRelationNameList.get(0);
+                        String tableName = innerRelationNameList.get(1);
+                        NodeAttachment relationNodeAttachment = this.getAttachmentByProjectIdAndTable(projectId, tableName);
+                        if (Objects.nonNull(relationNodeAttachment) && Objects.nonNull(relationNodeAttachment.getAttachment())) {
+                            relationNodeAttachmentMap.putAll(relationNodeAttachment.getAttachment());
+                        }
+                        //获取两个合并的map
+                        if (relationNodeAttachmentMap.containsKey(relationName) && Objects.nonNull(relationNodeAttachmentMap.get(relationName))) {
+                            currentAttachmentList.addAll((Collection<? extends String>) relationNodeAttachmentMap.get(relationName));
+                        }
+                    }
+                }//end for
+            }
+            //第一个依赖关系解决
+            currentNodeAttachmentMap.put(name,currentAttachmentList);
+        }
+        return currentNodeAttachmentMap;
+    }
+
 
 
 
 
 
 

+ 21 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/ProjectImpl.java

@@ -1,5 +1,6 @@
 package com.siwei.apply.service.impl;
 package com.siwei.apply.service.impl;
 
 
+import com.alibaba.druid.support.json.JSONUtils;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONObject;
 import com.siwei.apply.domain.BaseId;
 import com.siwei.apply.domain.BaseId;
@@ -15,6 +16,7 @@ import com.siwei.apply.mapper.*;
 import com.siwei.apply.service.NodeAttachmentService;
 import com.siwei.apply.service.NodeAttachmentService;
 import com.siwei.apply.service.NodeLandService;
 import com.siwei.apply.service.NodeLandService;
 import com.siwei.apply.service.ProjectService;
 import com.siwei.apply.service.ProjectService;
+import com.siwei.apply.utils.JsonUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
@@ -390,5 +392,24 @@ public class ProjectImpl implements ProjectService {
         return aa;
         return aa;
     }
     }
 
 
+
+    @Override
+    public void testData() {
+        String nodeId = null;
+        List<ProjectWorkflow> projectWorkflows = projectWorkflowMapper.selectByProjectIdAndNodeTableName("11111", "22222");
+        Optional<ProjectWorkflow> res = projectWorkflows.stream().findFirst();
+        if(res.isPresent()){
+            nodeId = res.get().getNodeId();
+        }
+        log.info("------------"+nodeId);
+
+        NodeAttachment ccc = nodeAttachmentService.getByNodeId("4eafe114-a812-4c2b-bcb3-ad470ff96fa9");
+        String sss = JsonUtil.toJson(ccc);
+        System.out.println(sss);
+
+    }
+
+
+
 }
 }
 
 

+ 2 - 3
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/utils/ServiceUtil.java

@@ -24,7 +24,6 @@ public class ServiceUtil {
         TdhyhsAttachmentNameEnum obj = zz.getDeclaredConstructor().newInstance();
         TdhyhsAttachmentNameEnum obj = zz.getDeclaredConstructor().newInstance();
         obj.values();
         obj.values();
 
 
-
 //        GyjsydjfwscdjAttachmentNameEnum 国有建设用地使用权及房屋所有权首次登记
 //        GyjsydjfwscdjAttachmentNameEnum 国有建设用地使用权及房屋所有权首次登记
 //        GyjsydscdjAttachmentNameEnum        国有建设用地使用权首次登记阶段
 //        GyjsydscdjAttachmentNameEnum        国有建设用地使用权首次登记阶段
 //        JsgcghxkAttachmentNameEnum          建设工程规划许可阶段
 //        JsgcghxkAttachmentNameEnum          建设工程规划许可阶段
@@ -47,7 +46,7 @@ public class ServiceUtil {
      * @param relationNodeAttachmentMap
      * @param relationNodeAttachmentMap
      * @return
      * @return
      */
      */
-    public static Map <String, List<String>>  assemblyAttachment(UnifyAttachmentEnum attachmentEnum,Map <String, List<String>> currentNodeAttachmentMap, Map <String, List<String>> relationNodeAttachmentMap){
+    public static Map <String, Object>  assemblyAttachment2(UnifyAttachmentEnum attachmentEnum,Map <String, Object> currentNodeAttachmentMap, Map <String, List<String>> relationNodeAttachmentMap){
         String name =  attachmentEnum.getName();
         String name =  attachmentEnum.getName();
         List<String> relationNameList = new ArrayList();
         List<String> relationNameList = new ArrayList();
         String relationNameStr =  attachmentEnum.getRelationName();
         String relationNameStr =  attachmentEnum.getRelationName();
@@ -64,7 +63,7 @@ public class ServiceUtil {
          *
          *
          */
          */
         List<String> currentAttachmentList = new ArrayList<>();
         List<String> currentAttachmentList = new ArrayList<>();
-        if(!currentNodeAttachmentMap.containsKey(name) || CollectionUtils.isEmpty(currentNodeAttachmentMap.get(name))) {
+        if(!currentNodeAttachmentMap.containsKey(name) || Objects.isNull(currentNodeAttachmentMap.get(name))) {
             //这里需要查询并整理所有批次报批节点,查询,
             //这里需要查询并整理所有批次报批节点,查询,
             if(CollectionUtils.isNotEmpty(relationNameList)) {
             if(CollectionUtils.isNotEmpty(relationNameList)) {
                 for(String relationName : relationNameList) {
                 for(String relationName : relationNameList) {