作者 张晓杰

文件上传、启动流程返回

@@ -201,8 +201,8 @@ public class WfProcessController extends BaseController { @@ -201,8 +201,8 @@ public class WfProcessController extends BaseController {
201 */ 201 */
202 @SaCheckPermission("workflow:process:start") 202 @SaCheckPermission("workflow:process:start")
203 @PostMapping("/start/{processDefId}") 203 @PostMapping("/start/{processDefId}")
204 - public R<ProcessInstance> start(@PathVariable(value = "processDefId") String processDefId, @RequestBody Map<String, Object> variables) {  
205 - ProcessInstance processInstance = processService.startProcessByDefId(processDefId, variables); 204 + public R<org.flowable.engine.runtime.ProcessInstance> start(@PathVariable(value = "processDefId") String processDefId, @RequestBody Map<String, Object> variables) {
  205 + org.flowable.engine.runtime.ProcessInstance processInstance = processService.startProcessByDefId(processDefId, variables);
206 // return R.ok("流程启动成功"); 206 // return R.ok("流程启动成功");
207 return R.ok(processInstance); 207 return R.ok(processInstance);
208 } 208 }
@@ -52,7 +52,7 @@ spring: @@ -52,7 +52,7 @@ spring:
52 driverClassName: com.mysql.cj.jdbc.Driver 52 driverClassName: com.mysql.cj.jdbc.Driver
53 # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 53 # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
54 # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) 54 # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
55 - 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 55 + 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
56 username: ntsd_root 56 username: ntsd_root
57 password: L3bHRJwg6lJ2SC4WFfGA 57 password: L3bHRJwg6lJ2SC4WFfGA
58 # 从库数据源 58 # 从库数据源
@@ -60,7 +60,7 @@ spring: @@ -60,7 +60,7 @@ spring:
60 lazy: true 60 lazy: true
61 type: ${spring.datasource.type} 61 type: ${spring.datasource.type}
62 driverClassName: com.mysql.cj.jdbc.Driver 62 driverClassName: com.mysql.cj.jdbc.Driver
63 - 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 63 + 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
64 username: ntsd_root 64 username: ntsd_root
65 password: L3bHRJwg6lJ2SC4WFfGA 65 password: L3bHRJwg6lJ2SC4WFfGA
66 # oracle: 66 # oracle:
@@ -105,8 +105,7 @@ spring: @@ -105,8 +105,7 @@ spring:
105 spring: 105 spring:
106 redis: 106 redis:
107 # 地址 107 # 地址
108 -# host: 172.18.0.4  
109 - host: localhost 108 + host: 172.18.0.4
110 # 端口,默认为6379 109 # 端口,默认为6379
111 port: 6379 110 port: 6379
112 # 数据库索引 111 # 数据库索引
  1 +package com.ruoyi.common.exception.file;
  2 +
  3 +import java.io.PrintStream;
  4 +import java.io.PrintWriter;
  5 +
  6 +/**
  7 + * 文件上传异常类
  8 + *
  9 + * @author ruoyi
  10 + */
  11 +public class FileUploadException extends Exception
  12 +{
  13 +
  14 + private static final long serialVersionUID = 1L;
  15 +
  16 + private final Throwable cause;
  17 +
  18 + public FileUploadException()
  19 + {
  20 + this(null, null);
  21 + }
  22 +
  23 + public FileUploadException(final String msg)
  24 + {
  25 + this(msg, null);
  26 + }
  27 +
  28 + public FileUploadException(String msg, Throwable cause)
  29 + {
  30 + super(msg);
  31 + this.cause = cause;
  32 + }
  33 +
  34 + @Override
  35 + public void printStackTrace(PrintStream stream)
  36 + {
  37 + super.printStackTrace(stream);
  38 + if (cause != null)
  39 + {
  40 + stream.println("Caused by:");
  41 + cause.printStackTrace(stream);
  42 + }
  43 + }
  44 +
  45 + @Override
  46 + public void printStackTrace(PrintWriter writer)
  47 + {
  48 + super.printStackTrace(writer);
  49 + if (cause != null)
  50 + {
  51 + writer.println("Caused by:");
  52 + cause.printStackTrace(writer);
  53 + }
  54 + }
  55 +
  56 + @Override
  57 + public Throwable getCause()
  58 + {
  59 + return cause;
  60 + }
  61 +}
1 package com.ruoyi.common.exception.file; 1 package com.ruoyi.common.exception.file;
2 2
3 -import org.apache.tomcat.util.http.fileupload.FileUploadException;  
4 3
5 import java.util.Arrays; 4 import java.util.Arrays;
6 5
@@ -100,8 +100,8 @@ public class FileUploadUtils @@ -100,8 +100,8 @@ public class FileUploadUtils
100 * @throws InvalidExtensionException 文件校验异常 100 * @throws InvalidExtensionException 文件校验异常
101 */ 101 */
102 public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) 102 public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
103 - throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,  
104 - InvalidExtensionException 103 + throws Exception
  104 +
105 { 105 {
106 int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); 106 int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
107 if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) 107 if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
@@ -158,7 +158,7 @@ public class FileUploadUtils @@ -158,7 +158,7 @@ public class FileUploadUtils
158 * @throws InvalidExtensionException 158 * @throws InvalidExtensionException
159 */ 159 */
160 public static final void assertAllowed(MultipartFile file, String[] allowedExtension) 160 public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
161 - throws FileSizeLimitExceededException, InvalidExtensionException 161 + throws Exception
162 { 162 {
163 long size = file.getSize(); 163 long size = file.getSize();
164 if (size > DEFAULT_MAX_SIZE) 164 if (size > DEFAULT_MAX_SIZE)
@@ -87,7 +87,7 @@ public interface IWfProcessService { @@ -87,7 +87,7 @@ public interface IWfProcessService {
87 * @param procDefId 流程定义ID 87 * @param procDefId 流程定义ID
88 * @param variables 扩展参数 88 * @param variables 扩展参数
89 */ 89 */
90 - ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables); 90 + org.flowable.engine.runtime.ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables);
91 91
92 /** 92 /**
93 * 通过DefinitionKey启动流程 93 * 通过DefinitionKey启动流程
@@ -583,11 +583,11 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce @@ -583,11 +583,11 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
583 */ 583 */
584 @Override 584 @Override
585 @Transactional(rollbackFor = Exception.class) 585 @Transactional(rollbackFor = Exception.class)
586 - public ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables) { 586 + public org.flowable.engine.runtime.ProcessInstance startProcessByDefId(String procDefId, Map<String, Object> variables) {
587 try { 587 try {
588 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() 588 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
589 .processDefinitionId(procDefId).singleResult(); 589 .processDefinitionId(procDefId).singleResult();
590 - ProcessInstance processInstance= startProcess(processDefinition, variables); 590 + org.flowable.engine.runtime.ProcessInstance processInstance= startProcess(processDefinition, variables);
591 return processInstance; 591 return processInstance;
592 } catch (Exception e) { 592 } catch (Exception e) {
593 e.printStackTrace(); 593 e.printStackTrace();
@@ -705,7 +705,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce @@ -705,7 +705,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
705 /** 705 /**
706 * 启动流程实例 706 * 启动流程实例
707 */ 707 */
708 - private ProcessInstance startProcess(ProcessDefinition procDef, Map<String, Object> variables) { 708 + private org.flowable.engine.runtime.ProcessInstance startProcess(ProcessDefinition procDef, Map<String, Object> variables) {
709 if (ObjectUtil.isNotNull(procDef) && procDef.isSuspended()) { 709 if (ObjectUtil.isNotNull(procDef) && procDef.isSuspended()) {
710 throw new ServiceException("流程已被挂起,请先激活流程"); 710 throw new ServiceException("流程已被挂起,请先激活流程");
711 } 711 }
@@ -716,7 +716,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce @@ -716,7 +716,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
716 // 设置流程状态为进行中 716 // 设置流程状态为进行中
717 variables.put(ProcessConstants.PROCESS_STATUS_KEY, ProcessStatus.RUNNING.getStatus()); 717 variables.put(ProcessConstants.PROCESS_STATUS_KEY, ProcessStatus.RUNNING.getStatus());
718 // 发起流程实例 718 // 发起流程实例
719 - ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDef.getId(), variables); 719 + org.flowable.engine.runtime.ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDef.getId(), variables);
720 // 第一个用户任务为发起人,则自动完成任务 720 // 第一个用户任务为发起人,则自动完成任务
721 wfTaskService.startFirstTask(processInstance, variables); 721 wfTaskService.startFirstTask(processInstance, variables);
722 722