作者 张晓杰

文件上传、启动流程返回

... ... @@ -201,8 +201,8 @@ public class WfProcessController extends BaseController {
*/
@SaCheckPermission("workflow:process:start")
@PostMapping("/start/{processDefId}")
public R<ProcessInstance> start(@PathVariable(value = "processDefId") String processDefId, @RequestBody Map<String, Object> variables) {
ProcessInstance processInstance = processService.startProcessByDefId(processDefId, variables);
public R<org.flowable.engine.runtime.ProcessInstance> start(@PathVariable(value = "processDefId") String processDefId, @RequestBody Map<String, Object> variables) {
org.flowable.engine.runtime.ProcessInstance processInstance = processService.startProcessByDefId(processDefId, variables);
// return R.ok("流程启动成功");
return R.ok(processInstance);
}
... ...
... ... @@ -52,7 +52,7 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://rm-2zeiuncjm75qti641ho.mysql.rds.aliyuncs.com:3306/compliance_management?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-2zeiuncjm75qti641ho.mysql.rds.aliyuncs.com:3306/cm_secondmenu?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: ntsd_root
password: L3bHRJwg6lJ2SC4WFfGA
# 从库数据源
... ... @@ -60,7 +60,7 @@ spring:
lazy: true
type: ${spring.datasource.type}
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-2zeiuncjm75qti641ho.mysql.rds.aliyuncs.com:3306/compliance_management?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-2zeiuncjm75qti641ho.mysql.rds.aliyuncs.com:3306/cm_secondmenu?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: ntsd_root
password: L3bHRJwg6lJ2SC4WFfGA
# oracle:
... ... @@ -105,8 +105,7 @@ spring:
spring:
redis:
# 地址
# host: 172.18.0.4
host: localhost
host: 172.18.0.4
# 端口,默认为6379
port: 6379
# 数据库索引
... ...
package com.ruoyi.common.exception.file;
import java.io.PrintStream;
import java.io.PrintWriter;
/**
* 文件上传异常类
*
* @author ruoyi
*/
public class FileUploadException extends Exception
{
private static final long serialVersionUID = 1L;
private final Throwable cause;
public FileUploadException()
{
this(null, null);
}
public FileUploadException(final String msg)
{
this(msg, null);
}
public FileUploadException(String msg, Throwable cause)
{
super(msg);
this.cause = cause;
}
@Override
public void printStackTrace(PrintStream stream)
{
super.printStackTrace(stream);
if (cause != null)
{
stream.println("Caused by:");
cause.printStackTrace(stream);
}
}
@Override
public void printStackTrace(PrintWriter writer)
{
super.printStackTrace(writer);
if (cause != null)
{
writer.println("Caused by:");
cause.printStackTrace(writer);
}
}
@Override
public Throwable getCause()
{
return cause;
}
}
... ...
package com.ruoyi.common.exception.file;
import org.apache.tomcat.util.http.fileupload.FileUploadException;
import java.util.Arrays;
... ...
... ... @@ -100,8 +100,8 @@ public class FileUploadUtils
* @throws InvalidExtensionException 文件校验异常
*/
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
InvalidExtensionException
throws Exception
{
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
... ... @@ -158,7 +158,7 @@ public class FileUploadUtils
* @throws InvalidExtensionException
*/
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, InvalidExtensionException
throws Exception
{
long size = file.getSize();
if (size > DEFAULT_MAX_SIZE)
... ...
... ... @@ -87,7 +87,7 @@ public interface IWfProcessService {
* @param procDefId 流程定义ID
* @param variables 扩展参数
*/
ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables);
org.flowable.engine.runtime.ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables);
/**
* 通过DefinitionKey启动流程
... ...
... ... @@ -583,11 +583,11 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables) {
public org.flowable.engine.runtime.ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables) {
try {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(procDefId).singleResult();
ProcessInstance processInstance= startProcess(processDefinition, variables);
org.flowable.engine.runtime.ProcessInstance processInstance= startProcess(processDefinition, variables);
return processInstance;
} catch (Exception e) {
e.printStackTrace();
... ... @@ -705,7 +705,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
/**
* 启动流程实例
*/
private ProcessInstance startProcess(ProcessDefinition procDef, Map<String, Object> variables) {
private org.flowable.engine.runtime.ProcessInstance startProcess(ProcessDefinition procDef, Map<String, Object> variables) {
if (ObjectUtil.isNotNull(procDef) && procDef.isSuspended()) {
throw new ServiceException("流程已被挂起,请先激活流程");
}
... ... @@ -716,7 +716,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
// 设置流程状态为进行中
variables.put(ProcessConstants.PROCESS_STATUS_KEY, ProcessStatus.RUNNING.getStatus());
// 发起流程实例
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDef.getId(), variables);
org.flowable.engine.runtime.ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDef.getId(), variables);
// 第一个用户任务为发起人,则自动完成任务
wfTaskService.startFirstTask(processInstance, variables);
... ...