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")
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")
@GetMapping("/list")
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)
@PostMapping("/export")
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);
}
@@ -75,7 +75,7 @@ public class FlowCategoryController extends BaseController {
public R<FlowCategoryVo> getInfo(@ApiParam("主键")
@NotNull(message = "主键不能为空")
@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()
@PostMapping()
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()
@PutMapping()
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")
@Log(title = "流程分类" , businessType = BusinessType.DELETE)
@DeleteMapping("/{categoryIds}")
public R<Void> remove(@ApiParam("主键串")
@NotEmpty(message = "主键不能为空")
@PathVariable Long[] categoryIds) {
return toAjax(iFlowCategoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true) ? 1 : 0);
public R<Void> remove(@ApiParam("主键串") @NotEmpty(message = "主键不能为空") @PathVariable Long[] categoryIds) {
return toAjax(flowCategoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true) ? 1 : 0);
}
}

View File

@@ -62,6 +62,7 @@ public class FlowDefinitionController extends BaseController {
/**
* 列出指定流程的发布版本列表
*
* @param processKey 流程定义Key
* @return
*/
@@ -76,8 +77,8 @@ public class FlowDefinitionController extends BaseController {
@ApiOperation(value = "导入流程文件", notes = "上传bpmn20的xml文件")
@PostMapping("/import")
public R<Void> importFile(@RequestParam(required = false) String name,
@RequestParam(required = false) String category,
MultipartFile file) {
@RequestParam(required = false) String category,
MultipartFile file) {
try (InputStream in = file.getInputStream()) {
flowDefinitionService.importFile(name, category, in);
} catch (Exception e) {
@@ -133,7 +134,7 @@ public class FlowDefinitionController extends BaseController {
@ApiOperation(value = "根据流程定义id启动流程实例")
@PostMapping("/start/{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);
return success("流程启动成功");
@@ -142,7 +143,7 @@ public class FlowDefinitionController extends BaseController {
@ApiOperation(value = "激活或挂起流程定义")
@PutMapping(value = "/updateState")
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);
return success();
}

View File

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

View File

@@ -76,7 +76,7 @@ public class FlowTaskController {
@ApiOperation(value = "获取流程变量", response = FlowTaskDto.class)
@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);
}
@@ -157,7 +157,7 @@ public class FlowTaskController {
@RequestMapping("/diagram/{processId}")
public void genProcessDiagram(HttpServletResponse response,
@PathVariable("processId") String processId) {
InputStream inputStream = flowTaskService.diagram(processId);
InputStream inputStream = flowTaskService.diagram(processId);
OutputStream os = null;
BufferedImage image = null;
try {
@@ -167,9 +167,9 @@ public class FlowTaskController {
if (image != null) {
ImageIO.write(image, "png", os);
}
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
try {
if (os != null) {
os.flush();

View File

@@ -1,6 +1,5 @@
package com.ruoyi.workflow.service;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.task.api.Task;
@@ -54,5 +53,5 @@ public interface IFlowInstanceService {
* @param variables 流程变量
* @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)
public void startProcessInstanceById(String procDefId, Map<String, Object> variables) {
try {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
.latestVersion().singleResult();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(procDefId).singleResult();
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
throw new ServiceException("流程已被挂起,请先激活流程");
}
// variables.put("skip", true);
// variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
// 设置流程发起人Id到流程中
String UserIdStr = LoginHelper.getUserId().toString();
identityService.setAuthenticatedUserId(UserIdStr);
variables.put(ProcessConstants.PROCESS_INITIATOR, UserIdStr);
String userIdStr = LoginHelper.getUserId().toString();
identityService.setAuthenticatedUserId(userIdStr);
variables.put(ProcessConstants.PROCESS_INITIATOR, userIdStr);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
// 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题?
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
if (Objects.nonNull(task)) {
if (!StrUtil.equalsAny(task.getAssignee(), UserIdStr)) {
if (!StrUtil.equalsAny(task.getAssignee(), userIdStr)) {
throw new ServiceException("数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!");
}
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);
}
} catch (Exception e) {

View File

@@ -1,8 +1,9 @@
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.flowable.common.constant.ProcessConstants;
import com.ruoyi.flowable.factory.FlowServiceFactory;
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
import com.ruoyi.workflow.service.IFlowInstanceService;
@@ -109,19 +110,17 @@ public class FlowInstanceServiceImpl extends FlowServiceFactory implements IFlow
* @return
*/
@Override
public R startProcessInstanceById(String procDefId, Map<String, Object> variables) {
public void startProcessInstanceById(String procDefId, Map<String, Object> variables) {
try {
// 设置流程发起人Id到流程中
Long userId = LoginHelper.getUserId();
// identityService.setAuthenticatedUserId(userId.toString());
variables.put("initiator", userId);
String userIdStr = LoginHelper.getUserId().toString();
// identityService.setAuthenticatedUserId(userId.toString());
variables.put(ProcessConstants.PROCESS_INITIATOR, userIdStr);
variables.put("_FLOWABLE_SKIP_EXPRESSION_ENABLED", true);
runtimeService.startProcessInstanceById(procDefId, variables);
return R.ok("流程启动成功");
} catch (Exception e) {
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> highLightedNodes = new ArrayList<>();
@@ -801,9 +802,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
ProcessEngineConfiguration configuration = processEngine.getProcessEngineConfiguration();
//获取自定义图片生成器
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);
return in;
}