|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|