ljy121 1 سال پیش
والد
کامیت
5b15d6bbcc

+ 5 - 0
zjugis-business/src/main/java/com/zjugis/business/bean/request/FileRequest.java

@@ -1,5 +1,6 @@
 package com.zjugis.business.bean.request;
 
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -12,4 +13,8 @@ import org.springframework.web.multipart.MultipartFile;
 public class FileRequest {
 
     private MultipartFile file;
+
+    private String path;
+
+    private Long clientId;
 }

+ 4 - 0
zjugis-business/src/main/java/com/zjugis/business/bean/request/ProjectMaterialRequest.java

@@ -19,4 +19,8 @@ public class ProjectMaterialRequest {
     private MultipartFile file;
 
     private Long categoryId;
+
+    private String prePath;
+
+    private String flowMaterialsId;
 }

+ 35 - 0
zjugis-business/src/main/java/com/zjugis/business/controller/ProjectController.java

@@ -4,14 +4,24 @@ package com.zjugis.business.controller;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.business.bean.dto.ProjectDto;
 import com.zjugis.business.bean.entity.Project;
+import com.zjugis.business.bean.entity.ProjectMaterial;
+import com.zjugis.business.bean.request.FileRequest;
 import com.zjugis.business.bean.request.ProjectChildRequest;
+import com.zjugis.business.bean.request.ProjectMaterialRequest;
 import com.zjugis.business.bean.request.ProjectRequest;
 import com.zjugis.business.bean.response.*;
+import com.zjugis.business.remote.FileClient;
 import com.zjugis.business.service.ProjectService;
 import com.zjugis.framework.common.pojo.CommonResult;
 import com.zjugis.framework.excel.core.util.ExcelUtils;
+import com.zjugis.framework.workflow.model.IFlowInstance;
+import com.zjugis.framework.workflow.model.IFlowMaterialsFile;
+import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
+import com.zjugis.framework.workflow.utils.zTree;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
@@ -37,6 +47,9 @@ public class ProjectController{
     @Autowired
     private ProjectService projectService;
 
+    @Autowired
+    WorkflowClient workflowClient;
+
     /**
      * 分页查询所有数据
      *
@@ -161,5 +174,27 @@ public class ProjectController{
         projectDto.setIsRelContract(1);
         return CommonResult.success(projectService.getList( projectDto));
     }
+
+    @GetMapping("/project-material-tree")
+    public CommonResult<List<zTree>> materialTree(@RequestParam("projectId") String projectId) {
+        Project project = projectService.selectDOById(projectId);
+        return workflowClient.getTree(project.getInstanceId());
+    }
+
+    @PostMapping("/project-material-upload")
+    public CommonResult<IFlowMaterialsFile> materialUpload(@Valid ProjectMaterialRequest projectMaterial) {
+        return CommonResult.success(projectService.materialUpload(projectMaterial));
+    }
+
+    @PostMapping("/project-material-delete")
+    public CommonResult materialDelete(@RequestParam("id") String id) {
+        return workflowClient.delById(id);
+    }
+
+
+    @GetMapping("/project-material-get")
+    public CommonResult<IFlowMaterialsFile> materialGet(@RequestParam("id") String id) {
+        return workflowClient.getById(id);
+    }
 }
 

+ 6 - 0
zjugis-business/src/main/java/com/zjugis/business/service/ProjectService.java

@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.business.bean.dto.ProjectDto;
 import com.zjugis.business.bean.entity.Project;
 import com.zjugis.business.bean.request.ProjectChildRequest;
+import com.zjugis.business.bean.request.ProjectMaterialRequest;
 import com.zjugis.business.bean.request.ProjectRequest;
 import com.zjugis.business.bean.response.*;
+import com.zjugis.framework.common.pojo.CommonResult;
+import com.zjugis.framework.workflow.model.IFlowMaterialsFile;
+import com.zjugis.framework.workflow.utils.zTree;
 
 import java.util.List;
 import java.util.Set;
@@ -78,5 +82,7 @@ public interface ProjectService {
     List<Project> getList(ProjectDto projectDto);
 
     List<Project> getAllList(ProjectDto projectDto);
+
+    IFlowMaterialsFile materialUpload(ProjectMaterialRequest projectMaterial);
 }
 

+ 46 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/ProjectServiceImpl.java

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.business.bean.dto.*;
 import com.zjugis.business.bean.entity.*;
+import com.zjugis.business.bean.request.FileRequest;
 import com.zjugis.business.bean.request.ProjectChildRequest;
+import com.zjugis.business.bean.request.ProjectMaterialRequest;
 import com.zjugis.business.bean.request.ProjectRequest;
 import com.zjugis.business.bean.response.*;
 import com.zjugis.business.constants.FlowStatusConstants;
@@ -12,11 +14,15 @@ import com.zjugis.business.constants.ResponseStatusEnum;
 import com.zjugis.business.constants.XmztConstants;
 import com.zjugis.business.mapper.ContractMapper;
 import com.zjugis.business.mapper.ProjectMapper;
+import com.zjugis.business.remote.FileClient;
 import com.zjugis.business.service.*;
 import com.zjugis.framework.common.exception.ServiceException;
 import com.zjugis.framework.common.pojo.CommonResult;
 import com.zjugis.framework.security.core.util.SecurityFrameworkUtils;
+import com.zjugis.framework.workflow.model.IFlowInstance;
+import com.zjugis.framework.workflow.model.IFlowMaterialsFile;
 import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
+import com.zjugis.framework.workflow.utils.zTree;
 import com.zjugis.module.system.api.dept.DeptApi;
 import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
 import com.zjugis.module.system.api.permission.PermissionApi;
@@ -26,10 +32,13 @@ import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -49,6 +58,12 @@ public class ProjectServiceImpl implements ProjectService {
     @Autowired
     WorkflowClient workflowClient;
 
+    @Autowired
+    FileClient fileClient;
+
+    @Value("${file.client}")
+    private String fileClientId;
+
     @Autowired
     AdminUserApi adminUserApi;
 
@@ -497,5 +512,36 @@ public class ProjectServiceImpl implements ProjectService {
     public List<Project> getAllList(ProjectDto projectDto) {
         return  projectMapper.getList(projectDto);
     }
+
+    @Override
+    public IFlowMaterialsFile materialUpload(ProjectMaterialRequest projectMaterial) {
+        Project project = selectDOById(projectMaterial.getProjectId());
+        FileRequest fileRequest = new FileRequest();
+        MultipartFile file = projectMaterial.getFile();
+        fileRequest.setFile(file);
+        fileRequest.setClientId(Long.valueOf(fileClientId));
+        CommonResult<IFlowInstance> flowResult = workflowClient.flowInstance(project.getInstanceId());
+        IFlowInstance flowInstance = flowResult.getCheckedData();
+
+        String path = "workFlow" + flowInstance.getFlowMark() + "/"
+                + flowInstance.getCode() + "/"
+                + new SimpleDateFormat("yyyy-MM-dd").format(new Date())
+                + projectMaterial.getPrePath();
+        fileRequest.setPath(path);
+        CommonResult<FileResponse> res = fileClient.uploadFile(fileRequest);
+        FileResponse fileResponse = res.getCheckedData();
+        IFlowMaterialsFile item = new IFlowMaterialsFile();
+        item.setFileId(String.valueOf(fileResponse.getId()));
+        item.setFlowMaterialsId(projectMaterial.getFlowMaterialsId());
+        int dotIndex = fileResponse.getName().lastIndexOf(".");
+        if(dotIndex == -1){
+            item.setName(fileResponse.getName());
+        } else {
+            item.setName(fileResponse.getName().substring(0,dotIndex));
+            item.setSuffix(fileResponse.getName().substring((dotIndex)));
+        }
+        item.setFileUrl(fileResponse.getUrl());
+        return workflowClient.addList(item).getCheckedData();
+    }
 }
 

+ 4 - 0
zjugis-business/src/main/resources/application-dev.yaml

@@ -96,3 +96,7 @@ contract:
     #    销售经理
     sale: 5
 
+file:
+  client: 11
+file:
+  client: 11

+ 4 - 0
zjugis-business/src/main/resources/application-prod.yaml

@@ -95,3 +95,7 @@ contract:
     #    销售经理
     sale: 5
 
+file:
+  client: 11
+file:
+  client: 11

+ 2 - 0
zjugis-framework/zjugis-spring-boot-starter-workflow/src/main/java/com/zjugis/framework/workflow/model/IFlowInstance.java

@@ -130,4 +130,6 @@ public class IFlowInstance {
 	 * 是否工作日(1:是 0:否)
 	 */
 	private Integer iWorkDay;
+
+    private String flowMark;
 }

+ 60 - 0
zjugis-framework/zjugis-spring-boot-starter-workflow/src/main/java/com/zjugis/framework/workflow/model/IFlowMaterialsFile.java

@@ -0,0 +1,60 @@
+package com.zjugis.framework.workflow.model;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 收件材料文件表
+ */
+@Data
+public class IFlowMaterialsFile{
+
+	/**
+	 * 主键
+	 */
+	private String id;
+	/**
+	 * 收件材料实例表外键
+	 */
+	private String flowMaterialsId;
+	/**
+	 * 文件名
+	 */
+	private String name;
+	/**
+	 * 后缀
+	 */
+	private String suffix;
+	/**
+	 * 文件地址
+	 */
+	private String fileUrl;
+	/**
+	 * 文件管理系统ID
+	 */
+	private String fileId;
+	/**
+	 * 是否归档
+	 */
+	private Integer iEnd;
+	/**
+	 * 外部文件站点地址
+	 */
+	private String externalFileSite;
+
+
+    private String tMaterialsId;
+
+    private String iMaterialsId;
+
+    private String path;
+
+    private String iconClass;
+
+    private String tCatalogId;
+
+    private String flowInstanceId;
+
+    private String fileContent;
+}

+ 14 - 4
zjugis-framework/zjugis-spring-boot-starter-workflow/src/main/java/com/zjugis/framework/workflow/rpc/remote/WorkflowClient.java

@@ -4,10 +4,7 @@ import com.zjugis.framework.common.pojo.CommonResult;
 import com.zjugis.framework.workflow.model.*;
 import com.zjugis.framework.workflow.utils.zTree;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.List;
@@ -61,4 +58,17 @@ public interface WorkflowClient {
 
     @PostMapping("/ActivityInstanceApi/getMaterialTree")
     CommonResult<List<zTree>> getMaterialTree(@RequestParam("flowInstanceId")String flowInstanceId, @RequestParam("activityInstanceId")String activityInstanceId);
+
+    @GetMapping("/IFlowMaterialsApi/getTree")
+    CommonResult<List<zTree>> getTree(@RequestParam("flowInstanceId")String flowInstanceId);
+
+    @PostMapping("/IFlowMaterialsApi/addList")
+    CommonResult<IFlowMaterialsFile> addList(@RequestBody IFlowMaterialsFile file);
+
+    @PostMapping("/IFlowMaterialsApi/delById")
+    CommonResult delById(@RequestParam("id") String id);
+
+    @GetMapping("/IFlowMaterialsApi/getById")
+    CommonResult<IFlowMaterialsFile> getById(@RequestParam("id") String id);
+
 }

+ 9 - 1
zjugis-workflow/src/main/java/com/zjugis/z_workflow/service/IFlowMaterialsFileService.java

@@ -460,5 +460,13 @@ public class IFlowMaterialsFileService extends ServiceImpl<IFlowMaterialsFileDao
 		}
 		return false;
 	}
-	//endregion
+
+    public void delOneById(String id) throws Exception {
+        IFlowMaterialsFile file = IFlowMaterialsFileDao.selectById(id);
+        if(!StringUtils.isBlank(file.getFileId())){
+            fileApi.delById(Long.valueOf(file.getFileId()));
+        }
+        IFlowMaterialsFileDao.deleteById(file.getId());
+    }
+    //endregion
 }

+ 87 - 0
zjugis-workflow/src/main/java/com/zjugis/z_workflow/service/IFlowMaterialsTreeService.java

@@ -63,6 +63,22 @@ public class IFlowMaterialsTreeService {
 		return rtnList.stream().sorted(Comparator.comparing(zTree::getSortNum)).collect(Collectors.toList());
 	}
 
+    public List<zTree> getAllTree(String flowInstanceId) throws Exception {
+        List<zTree> rtnList = null;
+        Comm comm = buildComm(flowInstanceId);
+        buildCatalogNode(comm);
+        buildAllIMaterialsNode(comm);
+        buildIMaterialsFileNode(comm);
+        //删除无子级的目录
+        comm.getTrees().removeIf(t -> (t.getType().equals(1) || t.getType().equals(0)) && comm.getTrees().stream().filter(r -> r.getPid() != null && r.getPid().equals(t.getId())).count() == 0);
+        if (Integer.valueOf(1).equals(comm.getMaterialsTop())) {
+            rtnList = comm.reloadIndexCode().getTrees();
+        } else {
+            rtnList = comm.getTrees();
+        }
+        return rtnList.stream().sorted(Comparator.comparing(zTree::getSortNum)).collect(Collectors.toList());
+    }
+
 	/**
 	 * 生成目录节点
 	 *
@@ -159,6 +175,32 @@ public class IFlowMaterialsTreeService {
 		});
 	}
 
+    private void buildAllIMaterialsNode(Comm comm) {
+        comm.getiFlowMaterials().forEach(t -> {
+            if ((t.getDiscriminator() == null || t.getDiscriminator() == 0)) {
+                //当前实例
+                if (!comm.flowInstanceId.equals(t.getFlowInstanceId()) || (comm.flowInstanceId.equals(t.getFlowInstanceId()))) {
+                    zTree node = new zTree();
+                    node.setId(t.getId());
+                    node.setName(t.getName());
+                    node.setSortNum(ConvertUtils.toInteger(t.getIndexCode(), 0));
+                    if (StringUtils.isBlank(t.getFlowMaterialsCatalogId()) && comm.map.size() > 1)
+                        node.setPid(t.getFlowInstanceId());
+                    else
+                        node.setPid(t.getFlowMaterialsCatalogId());
+                    node.setType(2);
+                    node.setExtendData(t);
+                    node.setIconClass(iFlowMaterialsFileService.getIconClassBy(".materials"));
+                    //非当前实例 只读
+                    node.setReadOnly(false);
+                    node.setiMust(false);
+                    //查询此材料对应的目录
+                    comm.getTrees().add(node);
+                }
+            }
+        });
+    }
+
 	/**
 	 * 文件节点
 	 *
@@ -229,6 +271,51 @@ public class IFlowMaterialsTreeService {
 				.setMap(map).setMaterialsTop(ConvertUtils.toInteger(cfgMap.get("materials-top"), 1)).setRight(isRight);
 	}
 
+    public Comm buildComm(String flowInstanceId) throws Exception {
+        List<ActivityInstanceDTO> treeList = iActivityInstanceService.findActivityInstanceTreeList(flowInstanceId);
+        if (treeList.isEmpty()) {
+            throw new Exception("流程实例不存在!");
+        }
+
+        //去除作废状态的子流程
+        treeList.removeIf(t -> t.getType() > 1 && Integer.valueOf(160).equals(t.getfStatus()));
+
+        List<IActivityInstance> iActivityInstances = iActivityInstanceService.findByFlowInstanceId(flowInstanceId);
+
+        Map<String, Object> cfgMap = persionKeyValueService.findValue(Constant.getUserId(), "workflow.handle");
+
+        Map<String, List<ActivityInstanceDTO>> map = treeList.stream().collect(Collectors.groupingBy(ActivityInstanceDTO::getFlowInstanceId));
+        //目录
+        List<String> flowInstanceIdList = new ArrayList<>(map.keySet());
+        List<IFlowMaterialsCatalog> iFlowMaterialsCatalogsList = iFlowMaterialsCatalogService.findByInstanceList(flowInstanceIdList);
+        //材料
+        List<IFlowMaterials> iFlowMaterialsList = iFlowMaterialsService.findByInstanceList(flowInstanceIdList);
+        //材料附件
+        Set<String> iMaterialsIds = iFlowMaterialsList.stream().map(IFlowMaterials::getId).filter(t -> !StringUtils.isBlank(t)).collect(Collectors.toSet());
+        List<IFlowMaterialsFile> files = iFlowMaterialsFileService.findByIDs(new ArrayList<>(iMaterialsIds));
+        //根据时间倒序后,重新设置IndexCode
+        if (!CollectionUtils.isEmpty(files)) {
+            iMaterialsIds.stream().forEach(m -> {
+                IterableUtils.forEach(files.stream().filter(f ->
+                        m.equals(f.getFlowMaterialsId())).collect(Collectors.toList()), (index, item) -> {
+                    item.setIndexCode(index);
+                });
+            });
+        }
+        //非管理员角色,只有流程的参与人才有只读可上传操作权限
+        boolean isRight = true;
+        if (!orgRightApiService.isAdminWithUser(Constant.getUserId())) {
+            isRight = iActivityInsParticiPantService.findUserListByFlowInstanceId(flowInstanceId, false).contains(Constant.getUserId());
+        }
+        return new Comm()
+                .setFlowInstanceId(flowInstanceId)
+                .setiFlowMaterialsCatalogs(iFlowMaterialsCatalogsList)
+                .setiFlowMaterials(iFlowMaterialsList)
+                .setiFlowMaterialsFiles(files)
+                .setActivityTemplateIdList(new ArrayList<>(iActivityInstances.stream().map(IActivityInstance::getActivityTemplateId).collect(Collectors.toSet())))
+                .setMap(map).setMaterialsTop(ConvertUtils.toInteger(cfgMap.get("materials-top"), 1)).setRight(isRight);
+    }
+
 	/**
 	 * 辅助内部类
 	 */

+ 414 - 0
zjugis-workflow/src/main/java/com/zjugis/z_workflow/serviceApi/IFlowMaterialsApiController.java

@@ -0,0 +1,414 @@
+package com.zjugis.z_workflow.serviceApi;
+
+import com.google.common.base.Strings;
+import com.zjugis.framework.common.pojo.CommonResult;
+import com.zjugis.framework.security.core.util.SecurityFrameworkUtils;
+import com.zjugis.framework.workflow.exception.BusinessException;
+import com.zjugis.framework.workflow.model.BaseController;
+import com.zjugis.framework.workflow.spring.resovler.ParamModel;
+import com.zjugis.z_workflow.entity.*;
+import com.zjugis.z_workflow.entityExtend.MaterialsCopyByTemplateVo;
+import com.zjugis.z_workflow.service.*;
+import com.zjugis.z_workflow.utils.zTree;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 流程附件材料实例接口服务
+ */
+@RestController
+public class IFlowMaterialsApiController extends BaseController {
+
+	@Autowired
+	private IFlowMaterialsService IFlowMaterialsService;
+	@Autowired
+	private IFlowMaterialsFileService iFlowMaterialsFileService;
+    @Autowired
+    private IFlowMaterialsTreeService iFlowMaterialsTreeService;
+	@Autowired
+	private IFlowInstanceService iFlowInstanceService;
+	@Autowired
+	private TFlowMaterialsService tFlowMaterialsService;
+	@Autowired
+	private TFlowMaterialsCatalogService tFlowMaterialsCatalogService;
+	@Autowired
+	private IFlowMaterialsApiService iFlowMaterialsApiService;
+	@Autowired
+	private TFlowTemplateVersionService tFlowTemplateVersionService;
+
+	/**
+	 * 获取收件材料GridHTML
+	 * @param flowInstanceId
+	 * @param activityInstanceId
+	 * @param readOnly
+	 * @param iHideDel
+	 * @return
+	 * @throws Exception
+	 */
+	@PostMapping
+	public String GetMaterialsGridHtml(String flowInstanceId, String activityInstanceId, boolean readOnly, boolean iHideDel) throws Exception {
+		try {
+			return IFlowMaterialsService.getGridHtml(flowInstanceId, activityInstanceId, readOnly, iHideDel);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 收件材料与目录查询
+	 *
+	 * @param flowTemplateId 流程模板id
+	 * @return
+	 */
+	@PostMapping
+	public String getMeterialsByTempId(String flowTemplateId) {
+		Map<String, Object> rtnMap = new HashMap<>();
+		try {
+			TFlowTemplateVersion flowTemplate = tFlowTemplateVersionService.GetEnableVersion(flowTemplateId);
+			if (flowTemplate != null) {
+				List<TFlowMaterialsCatalog> tFlowMaterialsCatalogs = tFlowMaterialsCatalogService.findByFlowTemplateVersionId(flowTemplate.getId());
+				rtnMap.put("catelogList", tFlowMaterialsCatalogService.setFullName(tFlowMaterialsCatalogs));
+				List<TFlowMaterials> tFlowMaterialsList = tFlowMaterialsService.findNoConfigByTempVersionId(flowTemplate.getId());
+				tFlowMaterialsList.stream().forEach(t -> {
+					Optional<TFlowMaterialsCatalog> optional = tFlowMaterialsCatalogs.stream().filter(c -> c.getId().equals(t.getFlowMaterialsCatalogId())).findFirst();
+					if (optional.isPresent()) {
+						t.setPath(optional.get().getPath() + "/" + t.getName());
+					} else {
+						t.setPath("/" + t.getName());
+					}
+				});
+				rtnMap.put("materialsList", tFlowMaterialsList);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+		return ok(rtnMap);
+	}
+
+	/**
+	 * 根据材料模板ID获取材料模板对象
+	 * @param tMaterialsId
+	 * @return
+	 */
+	@PostMapping
+	public String getTMaterialsById(String tMaterialsId) {
+		try {
+			TFlowMaterials tFlowMaterials = tFlowMaterialsService.findByID(tMaterialsId);
+			if (tFlowMaterials != null && !Strings.isNullOrEmpty(tFlowMaterials.getFlowMaterialsCatalogId())) {
+				List<TFlowMaterialsCatalog> catalogList = tFlowMaterialsCatalogService.findParentById(tFlowMaterials.getFlowMaterialsCatalogId());
+				if (!catalogList.isEmpty()) {
+					tFlowMaterialsCatalogService.setFullName(catalogList);
+					Optional<TFlowMaterialsCatalog> optional = catalogList.stream().filter(t ->
+							t.getId().equals(tFlowMaterials.getFlowMaterialsCatalogId())).findFirst();
+                    optional.ifPresent(tFlowMaterialsCatalog -> tFlowMaterials.setPath(tFlowMaterialsCatalog.getPath() + "/" + tFlowMaterials.getName()));
+				}
+			}
+			return ok(tFlowMaterials);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 根据材料id 获取文件信息
+	 *
+	 * @param materialId 材料id
+	 * @return
+	 */
+	@PostMapping
+	public String getMaterialFiles(String materialId) {
+		try {
+			return ok(iFlowMaterialsFileService.findByIDs(Arrays.asList(materialId)));
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 流程附件上传到指定目录
+	 *
+	 * @param flowInstanceId 流程实例ID
+	 * @param files          材料文件
+	 */
+	@PostMapping
+	public String materialsAdd(String flowInstanceId, @ParamModel List<IFlowMaterialsFile> files) {
+		try {
+			IFlowInstance flowInstance = iFlowInstanceService.findByID(flowInstanceId);
+			if (flowInstance == null) {
+				throw new Exception("流程实例不存在!");
+			}
+			iFlowMaterialsApiService.addMaterialsFile(flowInstance, files);
+			return ok(true);
+		} catch (Exception ex) {
+			ex.printStackTrace();
+			return error(ex.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 材料拷贝接口(按指定材料路径)
+	 * @param templateVos
+	 * @return
+	 */
+	@PostMapping
+	public String iMaterialsCopyByTemplate(@ParamModel List<MaterialsCopyByTemplateVo> templateVos) {
+		try {
+			if (!CollectionUtils.isEmpty(templateVos)) {
+				iFlowMaterialsApiService.iMaterialsCopyByTemplate(templateVos);
+			}
+			return ok(true);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 材料拷贝接口
+	 * 将源流程 指定收件目录或材料名称下所有收件拷贝至目标目录或材料
+	 * 1,源目录不存在 返回异常
+	 * 2,目标目录不存在 创建与源相同目录结构的材料数据
+	 *
+	 * @param fromFlowInstanceId 源流程实例id
+	 * @param toFlowInstanceId   目标流程实例id
+	 * @return
+	 */
+	@PostMapping
+	public String materialsCopy(String fromFlowInstanceId, String toFlowInstanceId) {
+		try {
+			IFlowInstance fromInstance = iFlowInstanceService.findByID(fromFlowInstanceId);
+			if (fromInstance == null) {
+                throw new BusinessException("源流程实例不存在");
+            }
+			IFlowInstance toInstance = iFlowInstanceService.findByID(toFlowInstanceId);
+			if (toInstance == null) {
+                throw new BusinessException("目标流程实例不存在!");
+            }
+			iFlowMaterialsApiService.materialsCopy(fromInstance, toInstance);
+			return ok(true);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	@PostMapping
+	public String materialsInstanceCopy(String fromFlowTempId, String toFlowInstanceId) {
+		try {
+			IFlowInstance flowInstance = iFlowInstanceService.findByID(toFlowInstanceId);
+			TFlowTemplateVersion tFlowTemplateVersion = tFlowTemplateVersionService.GetEnableVersion(fromFlowTempId);
+			if (flowInstance == null) {
+				throw new BusinessException("目标流程实例不存在");
+			}
+			if (tFlowTemplateVersion == null) {
+                throw new BusinessException("源流程模板暂无启用版本");
+            }
+			iFlowMaterialsApiService.materialsInstanceCopy(tFlowTemplateVersion.getId(), flowInstance);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+		return ok(true);
+	}
+
+	/**
+	 * 材料清单获取接口
+	 * 传入流程实例ID与材料目录名称(可选、可多个)获取材料清单
+	 *
+	 * @param flowInstanceId 流程实例id
+	 * @param paths          材料路径(可多个) 目录父->目录子->材料a
+	 * @return 材料路径 目录id 目录名称 材料id 材料名称 附件信息
+	 */
+	@PostMapping
+	public String getMaterials(String flowInstanceId, @ParamModel List<String> paths, Integer hasContent) {
+		try {
+			IFlowInstance flowInstance = iFlowInstanceService.findByID(flowInstanceId);
+			if (flowInstance == null) {
+                throw new Exception("源流程实例不存在!");
+            }
+			return ok(iFlowMaterialsApiService.getMaterials(flowInstance, paths, hasContent));
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 删除材料目录
+	 *
+	 * @param flowInstanceId
+	 * @param materialsList
+	 * @return
+	 */
+	@PostMapping
+	public String delMaterials(String flowInstanceId, @ParamModel List<IFlowMaterialsFile> materialsList) {
+		IFlowInstance flowInstance = iFlowInstanceService.findByID(flowInstanceId);
+		try {
+			if (flowInstance == null) {
+                throw new Exception("流程实例不存在!");
+            }
+			iFlowMaterialsApiService.delMaterials(flowInstance, materialsList);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+		return ok(true);
+	}
+
+	/**
+	 * 材料下载
+	 * @param flowInstanceId
+	 * @param paths
+	 * @param iZip
+	 * @return
+	 */
+	@PostMapping
+	public String materilasDownload(String flowInstanceId, @ParamModel List<String> paths, Integer iZip) {
+		IFlowInstance flowInstance = iFlowInstanceService.findByID(flowInstanceId);
+		try {
+			if (flowInstance == null) {
+                throw new Exception("流程实例不存在!");
+            }
+			return iFlowMaterialsApiService.materilasDownload(flowInstanceId, paths, iZip);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 重新设置材料权限
+	 * @param flowInstanceId
+	 * @param configs
+	 * @return
+	 */
+	@PostMapping
+	public String materialsCfgRefresh(String flowInstanceId, @ParamModel List<Map> configs) {
+		IFlowInstance flowInstance = iFlowInstanceService.findByID(flowInstanceId);
+		try {
+			if (flowInstance == null) {
+                throw new Exception("流程实例不存在!");
+            }
+			iFlowMaterialsApiService.materialsCfgRefresh(flowInstance, configs);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+		return ok(true);
+	}
+
+	/**
+	 * 根据文件ID更新附件材料格式
+	 * @param fileId
+	 * @return
+	 */
+	@PostMapping
+	public String updateMaterialFormat(String fileId, String fileFormat) {
+		try {
+			if (Strings.isNullOrEmpty(fileId)) {
+				throw new Exception("参数fileId不能为空!");
+			}
+			if (Strings.isNullOrEmpty(fileFormat)) {
+				throw new Exception("参数fileFormat不能为空!");
+			}
+			return ok(iFlowMaterialsFileService.updateMaterialFormatByFileId(fileId, fileFormat));
+		} catch (Exception e) {
+			return error(e.getMessage(), ErrorCode.DEFAULT);
+		}
+	}
+
+	/**
+	 * 根据流程实例ID获取附件材料袋实例列表
+	 * @param flowInstanceId 流程实例ID
+	 * @return
+	 */
+	@PostMapping
+	@ResponseBody
+	public String getListByFlowInstanceId(String flowInstanceId) {
+		try {
+			if (!StringUtils.hasText(flowInstanceId)) {
+				return error(ErrorCode.DEFAULT.getCode(), "参数flowInstanceId为空!");
+			}
+			return success(IFlowMaterialsService.listByFlowInstanceId(flowInstanceId));
+		} catch (Exception ex) {
+			return error(ErrorCode.DEFAULT.getCode(), ex.getMessage());
+		}
+	}
+
+	/**
+	 * 批量新增附件材料袋实例列表
+	 * @param list 附件材料袋实例列表
+	 * @return
+	 */
+	@PostMapping
+	@ResponseBody
+	public String batchInsertList(@ParamModel List<IFlowMaterials> list) {
+		try {
+			if (CollectionUtils.isEmpty(list)) {
+				return error(ErrorCode.DEFAULT.getCode(), "参数list为空!");
+			}
+			return success(IFlowMaterialsService.batchInsertList(list));
+		} catch (Exception ex) {
+			return error(ErrorCode.DEFAULT.getCode(), ex.getMessage());
+		}
+	}
+
+	/**
+	 * 根据流程实例ID删除附件材料及关联目录实例
+	 * @param flowInstanceId 流程实例ID
+	 * @return
+	 */
+	@PostMapping
+	@ResponseBody
+	public String deleteByFlowInstanceId(String flowInstanceId) {
+		try {
+			if (Strings.isNullOrEmpty(flowInstanceId)) {
+				return error(ErrorCode.DEFAULT.getCode(), "参数flowInstanceId为空!");
+			}
+			return success(IFlowMaterialsService.deleteMaterialByFlowInstanceId(flowInstanceId));
+		} catch (Exception ex) {
+			return error(ErrorCode.DEFAULT.getCode(), ex.getMessage());
+		}
+	}
+
+    @GetMapping
+    public CommonResult<List<zTree>> getTree(@RequestParam("flowInstanceId") String flowInstanceId) throws Exception {
+        return CommonResult.success(iFlowMaterialsTreeService.getAllTree(flowInstanceId));
+    }
+
+
+    @PostMapping
+    public CommonResult<IFlowMaterialsFile> addList(@RequestBody IFlowMaterialsFile file) {
+        List<IFlowMaterialsFile> list = new ArrayList<>();
+        list.add(file);
+        iFlowMaterialsFileService.addList(list);
+        list.forEach(t -> {
+            t.setCreateWorker(SecurityFrameworkUtils.getLoginUserId());
+        });
+        return CommonResult.success(file);
+    }
+
+    @PostMapping
+    public CommonResult delById(@RequestParam("id") String id) throws Exception {
+        iFlowMaterialsFileService.delOneById(id);
+        return CommonResult.success();
+    }
+
+    @GetMapping
+    public CommonResult<IFlowMaterialsFile> getById(@RequestParam("id") String id) {
+        IFlowMaterialsFile uEntity = iFlowMaterialsFileService.findByID(id);
+        return CommonResult.success(uEntity);
+    }
+
+
+
+}