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