提交代码

main
姜玉琦 2024-05-09 23:40:21 +08:00
parent a341eb2d5a
commit e32178da57
9 changed files with 116 additions and 8 deletions

View File

@ -30,6 +30,7 @@
<velocity.version>2.3</velocity.version> <velocity.version>2.3</velocity.version>
<jwt.version>0.9.1</jwt.version> <jwt.version>0.9.1</jwt.version>
<flowable.version>6.8.0</flowable.version> <flowable.version>6.8.0</flowable.version>
<hutool.version>5.8.20</hutool.version>
</properties> </properties>
<!-- 依赖声明 --> <!-- 依赖声明 -->
@ -205,6 +206,11 @@
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version> <version>3.4.0</version>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-poi</artifactId>
<version>${hutool.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

View File

@ -126,6 +126,12 @@
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>${hutool.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -89,6 +89,11 @@ public class Constants
*/ */
public static final Integer CAPTCHA_EXPIRATION = 2; public static final Integer CAPTCHA_EXPIRATION = 2;
/**
*
*/
public static final Integer DATA_EXPIRATION = 2;
/** /**
* *
*/ */

View File

@ -3,7 +3,11 @@ package com.yanzhu.common.utils.file;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.yanzhu.common.config.YanZhuConfig; import com.yanzhu.common.config.YanZhuConfig;
@ -114,9 +118,26 @@ public class FileUploadUtils
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
file.transferTo(Paths.get(absPath)); file.transferTo(Paths.get(absPath));
makeMiniImage(absPath);
return getPathFileName(baseDir, fileName); 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();
}
}
/** /**
* *
*/ */

View File

@ -273,6 +273,10 @@ public class FileUtils
return fileName.substring(index + 1); return fileName.substring(index + 1);
} }
public static String getFileExt(String fileName){
return FilenameUtils.getExtension(fileName).toString();
}
/** /**
* /profile/upload/2022/04/16/yanZhu.png -- yanZhu * /profile/upload/2022/04/16/yanZhu.png -- yanZhu
* *

View File

@ -3,14 +3,14 @@ package com.yanzhu.flowable.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yanzhu.common.core.domain.AjaxResult; import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.project.domain.ProProjectApply; import com.yanzhu.project.domain.ProProjectApply;
import com.yanzhu.system.domain.flowable.FlowQueryVo;
import com.yanzhu.system.domain.FlowProcDefDto; import com.yanzhu.system.domain.FlowProcDefDto;
import com.yanzhu.system.domain.flowable.FlowQueryVo;
import org.flowable.bpmn.model.FlowElement; import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.UserTask;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author Tony * @author Tony
@ -52,6 +52,13 @@ public interface IFlowDefinitionService {
*/ */
public List<FlowElement> readNodes(String deployId); public List<FlowElement> readNodes(String deployId);
/**
*
* @param deployId
* @return
*/
public List<UserTask> findFlowNodes(String deployId);
/** /**
* ID * ID
* *

View File

@ -27,6 +27,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement; import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.repository.ProcessDefinitionQuery; import org.flowable.engine.repository.ProcessDefinitionQuery;
@ -203,7 +204,6 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
List<FlowElement> list = new ArrayList<>(); List<FlowElement> list = new ArrayList<>();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
//获得图片流 //获得图片流
DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
Collection<FlowElement> flowElements = bpmnModel.getProcesses().get(0).getFlowElements(); Collection<FlowElement> flowElements = bpmnModel.getProcesses().get(0).getFlowElements();
if(flowElements.size()>0){ if(flowElements.size()>0){
@ -211,7 +211,20 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
list.add(fe); list.add(fe);
} }
} }
//输出为节点描述 return list;
}
/**
*
* @param deployId
* @return
*/
@Override
public List<UserTask> findFlowNodes(String deployId){
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
//获得图片流
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
List<UserTask> list = bpmnModel.getProcesses().get(0).findFlowElementsOfType(UserTask.class);
return list; return list;
} }

View File

@ -660,10 +660,11 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
if(Objects.isNull(processInstance)) { if(Objects.isNull(processInstance)) {
throw new RuntimeException("流程已结束或已挂起,无法执行撤回操作"); throw new RuntimeException("流程已结束或已挂起,无法执行撤回操作");
} }
String userIdStr = Convert.toStr(SecurityUtils.getUserId());
// 获取待撤回任务实例 // 获取待撤回任务实例
HistoricTaskInstance currTaskIns = historyService.createHistoricTaskInstanceQuery() HistoricTaskInstance currTaskIns = historyService.createHistoricTaskInstanceQuery()
.taskId(taskId) .taskId(taskId)
.taskAssignee(flowTaskVo.getUserId()) .taskAssignee(userIdStr)
.singleResult(); .singleResult();
if (Objects.isNull(currTaskIns)) { if (Objects.isNull(currTaskIns)) {
throw new RuntimeException("当前任务不存在,无法执行撤回操作"); throw new RuntimeException("当前任务不存在,无法执行撤回操作");
@ -694,8 +695,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
// 检查激活的任务节点是否存在下一级中,如果存在,则加入到需要撤回的节点 // 检查激活的任务节点是否存在下一级中,如果存在,则加入到需要撤回的节点
if (StringUtils.contains(nextUserTaskKeys, task.getTaskDefinitionKey())) { if (StringUtils.contains(nextUserTaskKeys, task.getTaskDefinitionKey())) {
// 添加撤回审批信息 // 添加撤回审批信息
taskService.setAssignee(task.getId(), flowTaskVo.getUserId()); taskService.setAssignee(task.getId(), userIdStr);
taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.REVOKE.getType(), flowTaskVo.getAssignee() + "撤回流程审批"); taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.REVOKE.getType(), SecurityUtils.getLoginUser().getUser().getNickName() + "撤回流程审批");
revokeExecutionIds.add(task.getExecutionId()); revokeExecutionIds.add(task.getExecutionId());
} }
} }

View File

@ -1,6 +1,7 @@
package com.yanzhu.wechat.controller; package com.yanzhu.wechat.controller;
import com.yanzhu.common.annotation.Log; import com.yanzhu.common.annotation.Log;
import com.yanzhu.common.constant.Constants;
import com.yanzhu.common.core.controller.BaseController; import com.yanzhu.common.core.controller.BaseController;
import com.yanzhu.common.core.domain.AjaxResult; import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.common.core.domain.entity.SysRole; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.collections4.CollectionUtils; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -28,6 +31,7 @@ import javax.validation.Valid;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -85,7 +89,32 @@ public class WxFlowableController extends BaseController {
@ApiOperation(value = "查询流程节点") @ApiOperation(value = "查询流程节点")
@GetMapping("/readNotes/{deployId}") @GetMapping("/readNotes/{deployId}")
public AjaxResult readNotes(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String 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<FlowElement> 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<UserTask> 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(); return AjaxResult.success();
} }
/**
*
* @param instanceId ID
* @param deleteReason
* @return
*/
@ApiOperation(value = "删除流程实例") @ApiOperation(value = "删除流程实例")
@Log(title = "删除流程", businessType = BusinessType.DELETE, operatorType = OperatorType.MOBILE) @Log(title = "删除流程", businessType = BusinessType.DELETE, operatorType = OperatorType.MOBILE)
@DeleteMapping(value = "/delete/{instanceId}") @DeleteMapping(value = "/delete/{instanceId}")
@ -159,6 +194,11 @@ public class WxFlowableController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
/**
*
* @param flowTaskVo
* @return
*/
@ApiOperation(value = "委派任务") @ApiOperation(value = "委派任务")
@Log(title = "委派流程", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE) @Log(title = "委派流程", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
@PostMapping(value = "/delegateTask") @PostMapping(value = "/delegateTask")
@ -167,6 +207,11 @@ public class WxFlowableController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
/**
*
* @param flowTaskVo
* @return
*/
@ApiOperation(value = "转办任务") @ApiOperation(value = "转办任务")
@Log(title = "转办流程", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE) @Log(title = "转办流程", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
@PostMapping(value = "/assignTask") @PostMapping(value = "/assignTask")