diff --git a/pom.xml b/pom.xml
index 05cfadf..d8402cb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,6 +30,7 @@
2.3
0.9.1
6.8.0
+ 5.8.20
@@ -205,6 +206,11 @@
mybatis-plus-boot-starter
3.4.0
+
+ cn.hutool
+ hutool-poi
+ ${hutool.version}
+
diff --git a/yanzhu-common/pom.xml b/yanzhu-common/pom.xml
index a22b200..b987260 100644
--- a/yanzhu-common/pom.xml
+++ b/yanzhu-common/pom.xml
@@ -126,6 +126,12 @@
javax.servlet-api
+
+ cn.hutool
+ hutool-core
+ ${hutool.version}
+
+
\ No newline at end of file
diff --git a/yanzhu-common/src/main/java/com/yanzhu/common/constant/Constants.java b/yanzhu-common/src/main/java/com/yanzhu/common/constant/Constants.java
index cc77bf7..9ba6d9d 100644
--- a/yanzhu-common/src/main/java/com/yanzhu/common/constant/Constants.java
+++ b/yanzhu-common/src/main/java/com/yanzhu/common/constant/Constants.java
@@ -89,6 +89,11 @@ public class Constants
*/
public static final Integer CAPTCHA_EXPIRATION = 2;
+ /**
+ * 基础数据有效期(分钟)
+ */
+ public static final Integer DATA_EXPIRATION = 2;
+
/**
* 基础数据有效期(分钟)
*/
diff --git a/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUploadUtils.java b/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUploadUtils.java
index b638eca..f4419c5 100644
--- a/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUploadUtils.java
+++ b/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUploadUtils.java
@@ -3,7 +3,11 @@ package com.yanzhu.common.utils.file;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
+import java.util.Arrays;
import java.util.Objects;
+
+import cn.hutool.core.img.ImgUtil;
+import cn.hutool.core.io.FileUtil;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import com.yanzhu.common.config.YanZhuConfig;
@@ -114,9 +118,26 @@ public class FileUploadUtils
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
file.transferTo(Paths.get(absPath));
+ makeMiniImage(absPath);
return getPathFileName(baseDir, fileName);
}
+ private static void makeMiniImage(String absPath) {
+ try {
+ String ext = FileUtils.getFileExt(absPath).toLowerCase();
+ String exts = Arrays.toString(new String[]{"jpg", "jpeg", "png", "bmp"});
+ if (exts.contains(ext)) {
+ if (new File(absPath).exists()) {
+ int w = ImgUtil.read(FileUtil.file(absPath)).getWidth();
+ ImgUtil.scale(FileUtil.file(absPath),
+ FileUtil.file(absPath + ".min.jpg"), (float) (300.0 / w));
+ }
+ }
+ }catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+
/**
* 编码文件名
*/
diff --git a/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUtils.java b/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUtils.java
index 51904f1..0ef3712 100644
--- a/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUtils.java
+++ b/yanzhu-common/src/main/java/com/yanzhu/common/utils/file/FileUtils.java
@@ -273,6 +273,10 @@ public class FileUtils
return fileName.substring(index + 1);
}
+ public static String getFileExt(String fileName){
+ return FilenameUtils.getExtension(fileName).toString();
+ }
+
/**
* 获取不带后缀文件名称 /profile/upload/2022/04/16/yanZhu.png -- yanZhu
*
diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java
index 055222a..a4416af 100644
--- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java
+++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java
@@ -3,14 +3,14 @@ package com.yanzhu.flowable.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.project.domain.ProProjectApply;
-import com.yanzhu.system.domain.flowable.FlowQueryVo;
import com.yanzhu.system.domain.FlowProcDefDto;
+import com.yanzhu.system.domain.flowable.FlowQueryVo;
import org.flowable.bpmn.model.FlowElement;
+import org.flowable.bpmn.model.UserTask;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
-import java.util.Map;
/**
* @author Tony
@@ -52,6 +52,13 @@ public interface IFlowDefinitionService {
*/
public List readNodes(String deployId);
+ /**
+ * 读取流程节点
+ * @param deployId
+ * @return
+ */
+ public List findFlowNodes(String deployId);
+
/**
* 根据流程定义ID启动流程实例
*
diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java
index 8848325..8314d70 100644
--- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java
+++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java
@@ -27,6 +27,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement;
+import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.repository.ProcessDefinitionQuery;
@@ -203,7 +204,6 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
List list = new ArrayList<>();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
//获得图片流
- DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
Collection flowElements = bpmnModel.getProcesses().get(0).getFlowElements();
if(flowElements.size()>0){
@@ -211,7 +211,20 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
list.add(fe);
}
}
- //输出为节点描述
+ return list;
+ }
+
+ /**
+ * 读取流程节点
+ * @param deployId
+ * @return
+ */
+ @Override
+ public List findFlowNodes(String deployId){
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
+ //获得图片流
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
+ List list = bpmnModel.getProcesses().get(0).findFlowElementsOfType(UserTask.class);
return list;
}
diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java
index e14fda3..f96fdc4 100644
--- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java
+++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java
@@ -660,10 +660,11 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
if(Objects.isNull(processInstance)) {
throw new RuntimeException("流程已结束或已挂起,无法执行撤回操作");
}
+ String userIdStr = Convert.toStr(SecurityUtils.getUserId());
// 获取待撤回任务实例
HistoricTaskInstance currTaskIns = historyService.createHistoricTaskInstanceQuery()
.taskId(taskId)
- .taskAssignee(flowTaskVo.getUserId())
+ .taskAssignee(userIdStr)
.singleResult();
if (Objects.isNull(currTaskIns)) {
throw new RuntimeException("当前任务不存在,无法执行撤回操作");
@@ -694,8 +695,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
// 检查激活的任务节点是否存在下一级中,如果存在,则加入到需要撤回的节点
if (StringUtils.contains(nextUserTaskKeys, task.getTaskDefinitionKey())) {
// 添加撤回审批信息
- taskService.setAssignee(task.getId(), flowTaskVo.getUserId());
- taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.REVOKE.getType(), flowTaskVo.getAssignee() + "撤回流程审批");
+ taskService.setAssignee(task.getId(), userIdStr);
+ taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.REVOKE.getType(), SecurityUtils.getLoginUser().getUser().getNickName() + "撤回流程审批");
revokeExecutionIds.add(task.getExecutionId());
}
}
diff --git a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java
index 6972981..11910cf 100644
--- a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java
+++ b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java
@@ -1,6 +1,7 @@
package com.yanzhu.wechat.controller;
import com.yanzhu.common.annotation.Log;
+import com.yanzhu.common.constant.Constants;
import com.yanzhu.common.core.controller.BaseController;
import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.common.core.domain.entity.SysRole;
@@ -21,6 +22,8 @@ import com.yanzhu.wechat.domain.StartProcessInstanceVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections4.CollectionUtils;
+import org.flowable.bpmn.model.FlowElement;
+import org.flowable.bpmn.model.UserTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -28,6 +31,7 @@ import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -85,7 +89,32 @@ public class WxFlowableController extends BaseController {
@ApiOperation(value = "查询流程节点")
@GetMapping("/readNotes/{deployId}")
public AjaxResult readNotes(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String deployId) {
- return success(flowDefinitionService.readNodes(deployId));
+ String key = "YANZHU.FLOW.readNotes:" + deployId;
+ Object object = redisCache.getCacheObject(key);
+ if (object != null) {
+ //return success(object);
+ }
+ List list = flowDefinitionService.readNodes(deployId);
+ redisCache.setCacheObject(key, list, Constants.DATA_EXPIRATION, TimeUnit.MINUTES);
+ return success(list);
+ }
+
+ /**
+ * 查询流程节点
+ * @param deployId
+ * @return
+ */
+ @ApiOperation(value = "查询流程节点")
+ @GetMapping("/readDeployNotes/{deployId}")
+ public AjaxResult readDeployNotes(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String deployId) {
+ String key = "YANZHU.FLOW.readDeployNotes:" + deployId;
+ Object object = redisCache.getCacheObject(key);
+ if (object != null) {
+ return success(object);
+ }
+ List list = flowDefinitionService.findFlowNodes(deployId);
+ redisCache.setCacheObject(key, list, Constants.DATA_EXPIRATION, TimeUnit.MINUTES);
+ return success(list);
}
/**
@@ -150,6 +179,12 @@ public class WxFlowableController extends BaseController {
return AjaxResult.success();
}
+ /**
+ * 删除流程实例
+ * @param instanceId 流程实例ID
+ * @param deleteReason 删除原因
+ * @return
+ */
@ApiOperation(value = "删除流程实例")
@Log(title = "删除流程", businessType = BusinessType.DELETE, operatorType = OperatorType.MOBILE)
@DeleteMapping(value = "/delete/{instanceId}")
@@ -159,6 +194,11 @@ public class WxFlowableController extends BaseController {
return AjaxResult.success();
}
+ /**
+ * 委派任务
+ * @param flowTaskVo
+ * @return
+ */
@ApiOperation(value = "委派任务")
@Log(title = "委派流程", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
@PostMapping(value = "/delegateTask")
@@ -167,6 +207,11 @@ public class WxFlowableController extends BaseController {
return AjaxResult.success();
}
+ /**
+ * 转办任务
+ * @param flowTaskVo
+ * @return
+ */
@ApiOperation(value = "转办任务")
@Log(title = "转办流程", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
@PostMapping(value = "/assignTask")