1
0

2 کامیت‌ها a5286e44a3 ... 569f800274

نویسنده SHA1 پیام تاریخ
  chenendian 569f800274 调整项目不存在,有附件信息 1 روز پیش
  chenendian 1005b47c96 一码管地全文检索service,统计空间图层数量 1 هفته پیش

+ 4 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/ProjectFilterVo.java

@@ -2,6 +2,8 @@ package com.siwei.apply.domain.vo;
 
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * 项目过滤条件
  */
@@ -20,6 +22,8 @@ public class ProjectFilterVo {
 
     private Boolean isOnchain;
 
+    private List<String> keyWords;
+
     // 分页参数
     private Integer pageNum = 1; // 当前页码
     private Integer pageSize = 10; // 每页条数

+ 14 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/NodeAttachmentMapper.java

@@ -4,6 +4,8 @@ import com.siwei.apply.domain.NodeAttachment;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 记录流程对应的附件材料 Mapper 接口
  */
@@ -25,7 +27,18 @@ public interface NodeAttachmentMapper {
      * @return NodeAttachment
      */
     NodeAttachment selectByNodeId(String nodeId);
-    
+
+
+    /**
+     * 根据节点ID查询附件信息
+     *
+     * @param nodeIdList 节点ID
+     * @return NodeAttachment
+     */
+    List<NodeAttachment> selectByNodeIdList(@Param("nodeIdList") List<String> nodeIdList);
+
+
+
     /**
      * 插入附件记录
      *

+ 2 - 5
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ProjectWorkflowMapper.java

@@ -64,11 +64,8 @@ public interface ProjectWorkflowMapper {
 
 
 
-    /**
-     *  查询当前项目下的某个节点ID的数据
-     *
-     */
-    List<ProjectWorkflow> selectOnchainInfoByNodeId(@Param("nodeId") String nodeId,@Param("nodeTableName") String nodeTableName);
+
+    List<ProjectWorkflow> selectByProjectIdList(@Param("projectIdList") List projectIdList);
 
 
 

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

@@ -2,6 +2,7 @@ package com.siwei.apply.service;
 
 import com.siwei.apply.domain.NodeAttachment;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -51,5 +52,6 @@ public interface NodeAttachmentService {
 
     String deleteFileAndSave(String path,String nodeAttachmentId ,String filePath);
 
+    List<NodeAttachment> getByNodeIdList(List<String> nodeIdList);
 
 }

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

@@ -66,5 +66,7 @@ public interface ProjectService {
 
     void countOnChinaNum(String projectId);
 
+    Map<String, Object> getListSearch(ProjectFilterVo projectFilterVo);
+
 }
 

+ 31 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/NodeAttachmentImpl.java

@@ -71,6 +71,37 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
     }
 
 
+
+    /**
+     * 根据节点ID查询附件信息
+     * @param nodeIdList 节点ID
+     * @return
+     */
+    @Override
+    public List<NodeAttachment> getByNodeIdList(List<String> nodeIdList) {
+        try {
+            if (nodeIdList == null || nodeIdList.isEmpty()) {
+                return null;
+            }
+            List<NodeAttachment> nodeAttachmentList = nodeAttachmentMapper.selectByNodeIdList(nodeIdList);
+            logger.info("查询节点附件信息,nodeIdList: {}", nodeIdList.size());
+            return nodeAttachmentList;
+        } catch (Exception e) {
+            logger.error("查询节点附件信息异常,nodeId: {}", nodeIdList, e);
+            return null;
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
     /**
      * 处理文件并保存附件信息
      * @param filePath 文件路径

+ 96 - 4
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/ProjectImpl.java

@@ -1,30 +1,43 @@
 package com.siwei.apply.service.impl;
 
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.siwei.apply.domain.BaseId;
+import com.siwei.apply.domain.NodeAttachment;
 import com.siwei.apply.domain.Project;
 import com.siwei.apply.domain.ProjectWorkflow;
 import com.siwei.apply.domain.res.*;
 import com.siwei.apply.domain.vo.ProjectFilterVo;
 import com.siwei.apply.domain.vo.ProjectUpdateVo;
 import com.siwei.apply.domain.vo.ProjectVo;
-import com.siwei.apply.mapper.ProjectMapper;
-import com.siwei.apply.mapper.ProjectWorkflowMapper;
-import com.siwei.apply.mapper.TdgyMapper;
-import com.siwei.apply.mapper.WorkflowMapper;
+import com.siwei.apply.mapper.*;
+import com.siwei.apply.service.NodeAttachmentService;
 import com.siwei.apply.service.ProjectService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
+
+import com.alibaba.fastjson2.JSON;
 
 import static com.siwei.apply.common.Common.UserId;
 
 /**
  * 项目服务实现类
  */
+@Slf4j
 @Service
 public class ProjectImpl implements ProjectService {
     @Autowired
@@ -36,6 +49,14 @@ public class ProjectImpl implements ProjectService {
     @Autowired
     private WorkflowMapper workflowMapper;
 
+    @Autowired
+    private NodeLandMapper nodeLandMapper;
+
+    @Autowired
+    private NodeAttachmentService nodeAttachmentService;
+
+
+
     @Override
     public String add(ProjectVo projectVo) {
         Project project = new Project();
@@ -167,6 +188,77 @@ public class ProjectImpl implements ProjectService {
         projectMapper.update(updateProject);
     }
 
+    @Override
+    public Map<String, Object> getListSearch(ProjectFilterVo projectFilterVo) {
+        if(StringUtils.isNotBlank(projectFilterVo.getKeyWord())){
+            List<String> keyWords = List.of(projectFilterVo.getKeyWord().trim().split("\\s+"));
+            projectFilterVo.setKeyWords(keyWords);
+        }
+        List<Project> projects = projectMapper.getListSearch(projectFilterVo);
+        Integer count = projectMapper.getSearchCount(projectFilterVo);
+        //根据项目id查询所有流程id
+        List<String> projectIdList = projects.stream().map(BaseId::getId).collect(Collectors.toList());
+        List<ProjectWorkflow> projectWorkflowList = null;
+        if(CollectionUtils.isNotEmpty(projectIdList)) {
+            projectWorkflowList = projectWorkflowMapper.selectByProjectIdList(projectIdList);
+        }
+        List<String> nodeIdList = null;
+        if(CollectionUtils.isNotEmpty(projectWorkflowList)){
+            nodeIdList = projectWorkflowList.stream().map(ProjectWorkflow::getNodeId).collect(Collectors.toList());
+        }
+        Integer graphicLayerCount = 0 ;
+        Integer attachmentCount = 0 ;
+        if(CollectionUtils.isNotEmpty(nodeIdList)){
+            graphicLayerCount = nodeLandMapper.selectCountGeomByNodeId(nodeIdList);
+            //这里获取每一个节点的附件数据:
+            List<String> allAttachmentFileList = new CopyOnWriteArrayList<>();
+            List<NodeAttachment>  nodeAttachmentList =  nodeAttachmentService.getByNodeIdList(nodeIdList);
+            nodeAttachmentList.parallelStream().forEach(nodeAttachment->{
+                String attachmentJsonString = JSONObject.toJSONString(nodeAttachment.getAttachment());
+                JSONObject attachmentJsonObj = JSON.parseObject(attachmentJsonString);
+                try {
+                    List<String>  tmpList = getAllAttachmentList(attachmentJsonObj);
+                    allAttachmentFileList.addAll(tmpList);
+                } catch (IOException e) {
+                    log.error("解析节点附件json失败",e);
+                    e.printStackTrace();
+                }
+            });
+            attachmentCount = allAttachmentFileList.size();
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put("projects", projects);
+        map.put("count", count);
+        map.put("attachmentCount", attachmentCount);
+        map.put("graphicLayerCount", graphicLayerCount);
+        return map;
+    }
+
+
+    /**
+     * 递归解析json文件数据
+     * @param jsonObj
+     * @return
+     * @throws IOException
+     */
+    public static List<String> getAllAttachmentList(JSONObject jsonObj) throws IOException {
+        List<String> list = new ArrayList<>();
+        if(jsonObj!=null && jsonObj.getString("type").equals("directory") && jsonObj.getJSONArray("children")!=null){
+            JSONArray arr = jsonObj.getJSONArray("children");
+            for(Object key : arr){
+                JSONObject tmp = (JSONObject) key;
+                if(tmp.getString("type").equals("directory")){
+                    List<String> tmpList = getAllAttachmentList(tmp);
+                    list.addAll(tmpList);
+                }else if(tmp.getString("type").equals("file")){
+                    list.add(tmp.getString("path"));
+                }
+            }
+        }
+        return list;
+    }
+
+
 
 
 }

+ 20 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/NodeAttachmentMapper.xml

@@ -34,6 +34,26 @@
         LIMIT 1
     </select>
 
+    <!-- 根据节点ID查询附件信息(多条) -->
+    <select id="selectByNodeIdList" resultMap="BaseResultMap" parameterType="List">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM t_node_attachment
+        <where>
+            <if test="nodeIdList != null and nodeIdList.size() > 0">
+                AND node_id IN
+                <foreach collection="nodeIdList" item="id" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
+
+
+
+
+
     <!-- 插入附件记录 -->
     <insert id="insert" parameterType="com.siwei.apply.domain.NodeAttachment">
         INSERT INTO t_node_attachment (

+ 21 - 1
siwei-modules/siwei-apply/src/main/resources/mapper/ProjectWorkflowMapper.xml

@@ -157,7 +157,27 @@
 <!--            WHERE id = #{nodeId}-->
 <!--        limit 1-->
 <!--    </select>-->
-
+    <select id="selectByProjectIdList" parameterType="List" resultMap="ProjectWorkflowResultMap">
+        SELECT id,
+               project_id,
+               workflow_id,
+               parent_id,
+               node_id,
+               node_table_name,
+               workflow_name,
+               created_at,
+               updated_at
+        FROM t_project_workflow
+        <where>
+            <if test="projectIdList!=null and projectIdList.size()>0">
+                project_id IN
+                <foreach collection="projectIdList" item="id" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+        ORDER BY created_at
+    </select>
 
 
 </mapper>