fix -- 格式化代码风格

This commit is contained in:
hewenqiang
2022-02-11 14:56:18 +08:00
parent e6bfd5bf0a
commit b47bcba0a4
8 changed files with 42 additions and 44 deletions

View File

@@ -42,7 +42,7 @@ import java.util.List;
@RequestMapping("/workflow/category") @RequestMapping("/workflow/category")
public class FlowCategoryController extends BaseController { public class FlowCategoryController extends BaseController {
private final IFlowCategoryService iFlowCategoryService; private final IFlowCategoryService flowCategoryService;
/** /**
* 查询流程分类列表 * 查询流程分类列表
@@ -51,7 +51,7 @@ public class FlowCategoryController extends BaseController {
@SaCheckPermission("workflow:category:list") @SaCheckPermission("workflow:category:list")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo<FlowCategoryVo> list(@Validated(QueryGroup.class) FlowCategoryBo bo, PageQuery pageQuery) { public TableDataInfo<FlowCategoryVo> list(@Validated(QueryGroup.class) FlowCategoryBo bo, PageQuery pageQuery) {
return iFlowCategoryService.queryPageList(bo, pageQuery); return flowCategoryService.queryPageList(bo, pageQuery);
} }
/** /**
@@ -62,7 +62,7 @@ public class FlowCategoryController extends BaseController {
@Log(title = "流程分类", businessType = BusinessType.EXPORT) @Log(title = "流程分类", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(@Validated FlowCategoryBo bo, HttpServletResponse response) { public void export(@Validated FlowCategoryBo bo, HttpServletResponse response) {
List<FlowCategoryVo> list = iFlowCategoryService.queryList(bo); List<FlowCategoryVo> list = flowCategoryService.queryList(bo);
ExcelUtil.exportExcel(list, "流程分类", FlowCategoryVo.class, response); ExcelUtil.exportExcel(list, "流程分类", FlowCategoryVo.class, response);
} }
@@ -75,7 +75,7 @@ public class FlowCategoryController extends BaseController {
public R<FlowCategoryVo> getInfo(@ApiParam("主键") public R<FlowCategoryVo> getInfo(@ApiParam("主键")
@NotNull(message = "主键不能为空") @NotNull(message = "主键不能为空")
@PathVariable("categoryId") Long categoryId) { @PathVariable("categoryId") Long categoryId) {
return R.ok(iFlowCategoryService.queryById(categoryId)); return R.ok(flowCategoryService.queryById(categoryId));
} }
/** /**
@@ -87,7 +87,7 @@ public class FlowCategoryController extends BaseController {
@RepeatSubmit() @RepeatSubmit()
@PostMapping() @PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody FlowCategoryBo bo) { public R<Void> add(@Validated(AddGroup.class) @RequestBody FlowCategoryBo bo) {
return toAjax(iFlowCategoryService.insertByBo(bo) ? 1 : 0); return toAjax(flowCategoryService.insertByBo(bo) ? 1 : 0);
} }
/** /**
@@ -99,7 +99,7 @@ public class FlowCategoryController extends BaseController {
@RepeatSubmit() @RepeatSubmit()
@PutMapping() @PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FlowCategoryBo bo) { public R<Void> edit(@Validated(EditGroup.class) @RequestBody FlowCategoryBo bo) {
return toAjax(iFlowCategoryService.updateByBo(bo) ? 1 : 0); return toAjax(flowCategoryService.updateByBo(bo) ? 1 : 0);
} }
/** /**
@@ -109,9 +109,7 @@ public class FlowCategoryController extends BaseController {
@SaCheckPermission("workflow:category:remove") @SaCheckPermission("workflow:category:remove")
@Log(title = "流程分类" , businessType = BusinessType.DELETE) @Log(title = "流程分类" , businessType = BusinessType.DELETE)
@DeleteMapping("/{categoryIds}") @DeleteMapping("/{categoryIds}")
public R<Void> remove(@ApiParam("主键串") public R<Void> remove(@ApiParam("主键串") @NotEmpty(message = "主键不能为空") @PathVariable Long[] categoryIds) {
@NotEmpty(message = "主键不能为空") return toAjax(flowCategoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true) ? 1 : 0);
@PathVariable Long[] categoryIds) {
return toAjax(iFlowCategoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true) ? 1 : 0);
} }
} }

View File

@@ -62,6 +62,7 @@ public class FlowDefinitionController extends BaseController {
/** /**
* 列出指定流程的发布版本列表 * 列出指定流程的发布版本列表
*
* @param processKey 流程定义Key * @param processKey 流程定义Key
* @return * @return
*/ */
@@ -76,8 +77,8 @@ public class FlowDefinitionController extends BaseController {
@ApiOperation(value = "导入流程文件", notes = "上传bpmn20的xml文件") @ApiOperation(value = "导入流程文件", notes = "上传bpmn20的xml文件")
@PostMapping("/import") @PostMapping("/import")
public R<Void> importFile(@RequestParam(required = false) String name, public R<Void> importFile(@RequestParam(required = false) String name,
@RequestParam(required = false) String category, @RequestParam(required = false) String category,
MultipartFile file) { MultipartFile file) {
try (InputStream in = file.getInputStream()) { try (InputStream in = file.getInputStream()) {
flowDefinitionService.importFile(name, category, in); flowDefinitionService.importFile(name, category, in);
} catch (Exception e) { } catch (Exception e) {
@@ -133,7 +134,7 @@ public class FlowDefinitionController extends BaseController {
@ApiOperation(value = "根据流程定义id启动流程实例") @ApiOperation(value = "根据流程定义id启动流程实例")
@PostMapping("/start/{procDefId}") @PostMapping("/start/{procDefId}")
public R<Void> start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, public R<Void> start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) { @ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
flowDefinitionService.startProcessInstanceById(procDefId, variables); flowDefinitionService.startProcessInstanceById(procDefId, variables);
return success("流程启动成功"); return success("流程启动成功");
@@ -142,7 +143,7 @@ public class FlowDefinitionController extends BaseController {
@ApiOperation(value = "激活或挂起流程定义") @ApiOperation(value = "激活或挂起流程定义")
@PutMapping(value = "/updateState") @PutMapping(value = "/updateState")
public R<Void> updateState(@ApiParam(value = "ture:挂起,false:激活", required = true) @RequestParam Boolean suspended, public R<Void> updateState(@ApiParam(value = "ture:挂起,false:激活", required = true) @RequestParam Boolean suspended,
@ApiParam(value = "流程定义ID", required = true) @RequestParam String definitionId) { @ApiParam(value = "流程定义ID", required = true) @RequestParam String definitionId) {
flowDefinitionService.updateState(suspended, definitionId); flowDefinitionService.updateState(suspended, definitionId);
return success(); return success();
} }

View File

@@ -31,16 +31,17 @@ public class FlowInstanceController {
@ApiOperation(value = "根据流程定义id启动流程实例") @ApiOperation(value = "根据流程定义id启动流程实例")
@PostMapping("/startBy/{procDefId}") @PostMapping("/startBy/{procDefId}")
public R startById(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, public R startById(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) { @ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
return flowInstanceService.startProcessInstanceById(procDefId, variables); flowInstanceService.startProcessInstanceById(procDefId, variables);
return R.ok("流程启动成功");
} }
@ApiOperation(value = "激活或挂起流程实例") @ApiOperation(value = "激活或挂起流程实例")
@PostMapping(value = "/updateState") @PostMapping(value = "/updateState")
public R updateState(@ApiParam(value = "1:激活,2:挂起", required = true) @RequestParam Integer state, public R updateState(@ApiParam(value = "1:激活,2:挂起", required = true) @RequestParam Integer state,
@ApiParam(value = "流程实例ID", required = true) @RequestParam String instanceId) { @ApiParam(value = "流程实例ID", required = true) @RequestParam String instanceId) {
flowInstanceService.updateState(state,instanceId); flowInstanceService.updateState(state, instanceId);
return R.ok(); return R.ok();
} }
@@ -54,8 +55,8 @@ public class FlowInstanceController {
@ApiOperation(value = "删除流程实例") @ApiOperation(value = "删除流程实例")
@DeleteMapping(value = "/delete") @DeleteMapping(value = "/delete")
public R delete(@ApiParam(value = "流程实例ID", required = true) @RequestParam String instanceId, public R delete(@ApiParam(value = "流程实例ID", required = true) @RequestParam String instanceId,
@ApiParam(value = "删除原因") @RequestParam(required = false) String deleteReason) { @ApiParam(value = "删除原因") @RequestParam(required = false) String deleteReason) {
flowInstanceService.delete(instanceId,deleteReason); flowInstanceService.delete(instanceId, deleteReason);
return R.ok(); return R.ok();
} }
} }

View File

@@ -76,7 +76,7 @@ public class FlowTaskController {
@ApiOperation(value = "获取流程变量", response = FlowTaskDto.class) @ApiOperation(value = "获取流程变量", response = FlowTaskDto.class)
@GetMapping(value = "/processVariables/{taskId}") @GetMapping(value = "/processVariables/{taskId}")
public R processVariables(@ApiParam(value = "流程任务Id") @PathVariable(value = "taskId") String taskId) { public R processVariables(@ApiParam(value = "流程任务Id") @PathVariable(value = "taskId") String taskId) {
return flowTaskService.processVariables(taskId); return flowTaskService.processVariables(taskId);
} }
@@ -157,7 +157,7 @@ public class FlowTaskController {
@RequestMapping("/diagram/{processId}") @RequestMapping("/diagram/{processId}")
public void genProcessDiagram(HttpServletResponse response, public void genProcessDiagram(HttpServletResponse response,
@PathVariable("processId") String processId) { @PathVariable("processId") String processId) {
InputStream inputStream = flowTaskService.diagram(processId); InputStream inputStream = flowTaskService.diagram(processId);
OutputStream os = null; OutputStream os = null;
BufferedImage image = null; BufferedImage image = null;
try { try {
@@ -167,9 +167,9 @@ public class FlowTaskController {
if (image != null) { if (image != null) {
ImageIO.write(image, "png", os); ImageIO.write(image, "png", os);
} }
}catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
if (os != null) { if (os != null) {
os.flush(); os.flush();

View File

@@ -1,6 +1,5 @@
package com.ruoyi.workflow.service; package com.ruoyi.workflow.service;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.workflow.domain.vo.FlowTaskVo; import com.ruoyi.workflow.domain.vo.FlowTaskVo;
import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
@@ -54,5 +53,5 @@ public interface IFlowInstanceService {
* @param variables 流程变量 * @param variables 流程变量
* @return * @return
*/ */
R startProcessInstanceById(String procDefId, Map<String, Object> variables); void startProcessInstanceById(String procDefId, Map<String, Object> variables);
} }

View File

@@ -205,26 +205,26 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void startProcessInstanceById(String procDefId, Map<String, Object> variables) { public void startProcessInstanceById(String procDefId, Map<String, Object> variables) {
try { try {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId) ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.latestVersion().singleResult(); .processDefinitionId(procDefId).singleResult();
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
throw new ServiceException("流程已被挂起,请先激活流程"); throw new ServiceException("流程已被挂起,请先激活流程");
} }
// variables.put("skip", true); // variables.put("skip", true);
// variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true); // variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
// 设置流程发起人Id到流程中 // 设置流程发起人Id到流程中
String UserIdStr = LoginHelper.getUserId().toString(); String userIdStr = LoginHelper.getUserId().toString();
identityService.setAuthenticatedUserId(UserIdStr); identityService.setAuthenticatedUserId(userIdStr);
variables.put(ProcessConstants.PROCESS_INITIATOR, UserIdStr); variables.put(ProcessConstants.PROCESS_INITIATOR, userIdStr);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
// 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题? // 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题?
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
if (Objects.nonNull(task)) { if (Objects.nonNull(task)) {
if (!StrUtil.equalsAny(task.getAssignee(), UserIdStr)) { if (!StrUtil.equalsAny(task.getAssignee(), userIdStr)) {
throw new ServiceException("数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!"); throw new ServiceException("数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!");
} }
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), LoginHelper.getNickName() + "发起流程申请"); taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), LoginHelper.getNickName() + "发起流程申请");
// taskService.setAssignee(task.getId(), UserIdStr); // taskService.setAssignee(task.getId(), userIdStr);
taskService.complete(task.getId(), variables); taskService.complete(task.getId(), variables);
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -1,8 +1,9 @@
package com.ruoyi.workflow.service.impl; package com.ruoyi.workflow.service.impl;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.flowable.common.constant.ProcessConstants;
import com.ruoyi.flowable.factory.FlowServiceFactory; import com.ruoyi.flowable.factory.FlowServiceFactory;
import com.ruoyi.workflow.domain.vo.FlowTaskVo; import com.ruoyi.workflow.domain.vo.FlowTaskVo;
import com.ruoyi.workflow.service.IFlowInstanceService; import com.ruoyi.workflow.service.IFlowInstanceService;
@@ -109,19 +110,17 @@ public class FlowInstanceServiceImpl extends FlowServiceFactory implements IFlow
* @return * @return
*/ */
@Override @Override
public R startProcessInstanceById(String procDefId, Map<String, Object> variables) { public void startProcessInstanceById(String procDefId, Map<String, Object> variables) {
try { try {
// 设置流程发起人Id到流程中 // 设置流程发起人Id到流程中
Long userId = LoginHelper.getUserId(); String userIdStr = LoginHelper.getUserId().toString();
// identityService.setAuthenticatedUserId(userId.toString()); // identityService.setAuthenticatedUserId(userId.toString());
variables.put("initiator", userId); variables.put(ProcessConstants.PROCESS_INITIATOR, userIdStr);
variables.put("_FLOWABLE_SKIP_EXPRESSION_ENABLED", true); variables.put("_FLOWABLE_SKIP_EXPRESSION_ENABLED", true);
runtimeService.startProcessInstanceById(procDefId, variables); runtimeService.startProcessInstanceById(procDefId, variables);
return R.ok("流程启动成功");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return R.fail("流程启动错误"); throw new ServiceException("流程启动错误");
} }
} }
} }

View File

@@ -781,7 +781,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
} }
// 获得活动的节点 // 获得活动的节点
List<HistoricActivityInstance> highLightedFlowList = historyService.createHistoricActivityInstanceQuery().processInstanceId(processId).orderByHistoricActivityInstanceStartTime().asc().list(); List<HistoricActivityInstance> highLightedFlowList = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processId).orderByHistoricActivityInstanceStartTime().asc().list();
List<String> highLightedFlows = new ArrayList<>(); List<String> highLightedFlows = new ArrayList<>();
List<String> highLightedNodes = new ArrayList<>(); List<String> highLightedNodes = new ArrayList<>();
@@ -801,9 +802,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
ProcessEngineConfiguration configuration = processEngine.getProcessEngineConfiguration(); ProcessEngineConfiguration configuration = processEngine.getProcessEngineConfiguration();
//获取自定义图片生成器 //获取自定义图片生成器
ProcessDiagramGenerator diagramGenerator = new CustomProcessDiagramGenerator(); ProcessDiagramGenerator diagramGenerator = new CustomProcessDiagramGenerator();
InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", highLightedNodes, highLightedFlows, configuration.getActivityFontName(), return diagramGenerator.generateDiagram(bpmnModel, "png", highLightedNodes, highLightedFlows, configuration.getActivityFontName(),
configuration.getLabelFontName(), configuration.getAnnotationFontName(), configuration.getClassLoader(), 1.0, true); configuration.getLabelFontName(), configuration.getAnnotationFontName(), configuration.getClassLoader(), 1.0, true);
return in;
} }