Browse Source

事务列表

test
smallchill 6 years ago
parent
commit
8027b55334
  1. 29
      blade-service-api/blade-flow-api/src/main/java/org/springblade/flowable/core/entity/BladeFlow.java
  2. 6
      blade-service/blade-desk/src/main/java/org/springblade/desk/service/impl/LeaveServiceImpl.java
  3. 99
      blade-service/blade-flow/src/main/java/org/springblade/flowable/business/controller/WorkController.java
  4. 7
      blade-service/blade-flow/src/main/java/org/springblade/flowable/business/feign/FlowClient.java
  5. 64
      blade-service/blade-flow/src/main/java/org/springblade/flowable/business/service/FlowBusinessService.java
  6. 235
      blade-service/blade-flow/src/main/java/org/springblade/flowable/business/service/impl/FlowBusinessServiceImpl.java
  7. 14
      blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/constant/FlowableConstant.java
  8. 4
      blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowManagerController.java
  9. 3
      blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/FlowProcess.java
  10. 2
      blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/FlowService.java
  11. 4
      blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java
  12. 73
      blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/utils/FlowCache.java
  13. 16
      doc/sql/bladex-update-RC9.sql

29
blade-service-api/blade-flow-api/src/main/java/org/springblade/flowable/core/entity/BladeFlow.java

@ -20,6 +20,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
* 工作流通用实体类
@ -50,7 +51,26 @@ public class BladeFlow implements Serializable {
* 任务执行人名称
*/
private String assigneeName;
/**
* 流程分类
*/
private String category;
/**
* 流程分类名
*/
private String categoryName;
/**
* 创建时间
*/
private Date createTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 签收时间
*/
private Date claimTime;
/**
* 历史任务结束时间
*/
@ -70,7 +90,6 @@ public class BladeFlow implements Serializable {
private String processDefinitionDesc;
private String processDefinitionDiagramResName;
private String processDefinitionResName;
/**
* 已办任务流程实例ID 查看流程图会用到
*/
@ -79,7 +98,6 @@ public class BladeFlow implements Serializable {
* 流程实例是否结束(true:结束false:未结束)
*/
private String processIsFinished;
/**
* 历史活动流程
*/
@ -88,7 +106,6 @@ public class BladeFlow implements Serializable {
* 历史活动耗时
*/
private String hisActInsDuTime;
/**
* 业务绑定Table
*/
@ -117,4 +134,8 @@ public class BladeFlow implements Serializable {
* 结束查询日期
*/
private Date endDate;
/**
* 流程参数
*/
private Map<String, Object> variables;
}

6
blade-service/blade-desk/src/main/java/org/springblade/desk/service/impl/LeaveServiceImpl.java

@ -56,10 +56,12 @@ public class LeaveServiceImpl extends BaseServiceImpl<LeaveMapper, ProcessLeave>
leave.setApplyTime(LocalDateTime.now());
save(leave);
// 启动流程
variables.put("taskUser", SecureUtil.getUser().getUserId());
variables.put("days", Duration.between(leave.getEndTime(), leave.getStartTime()).toDays());
variables.put("businessId", leave.getId());
variables.put("taskUser", SecureUtil.getUserAccount());
variables.put("days", Duration.between(leave.getStartTime(), leave.getEndTime()).toDays());
BladeFlow bladeFlow = flowClient.startProcessInstanceById(leave.getProcessId(), FlowUtil.getBusinessKey(businessTable, String.valueOf(leave.getId())), variables);
log.debug("流程已启动,流程ID:" + bladeFlow.getProcessInstanceId());
// 返回流程id写入leave
leave.setInstanceId(bladeFlow.getProcessInstanceId());
updateById(leave);
} else {

99
blade-service/blade-flow/src/main/java/org/springblade/flowable/business/controller/WorkController.java

@ -0,0 +1,99 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.flowable.business.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.flowable.business.service.FlowBusinessService;
import org.springblade.flowable.core.entity.BladeFlow;
import org.springblade.flowable.engine.entity.FlowProcess;
import org.springblade.flowable.engine.service.FlowService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 流程事务通用接口
*
* @author Chill
*/
@RestController
@AllArgsConstructor
@RequestMapping("work")
@Api(value = "流程事务通用接口", tags = "流程事务通用接口")
public class WorkController {
private FlowService flowService;
private FlowBusinessService flowBusinessService;
/**
* 发起事务列表页
*/
@GetMapping("start-list")
@ApiOperation(value = "发起事务列表页", notes = "传入流程类型", position = 1)
public R<IPage<FlowProcess>> startList(@ApiParam("流程类型") String category, Query query) {
IPage<FlowProcess> pages = flowService.selectProcessPage(Condition.getPage(query), category);
return R.data(pages);
}
/**
* 待签事务列表页
*/
@GetMapping("claim-list")
@ApiOperation(value = "待签事务列表页", notes = "传入流程信息", position = 2)
public R<IPage<BladeFlow>> claimList(@ApiParam("流程信息") BladeFlow bladeFlow, Query query) {
IPage<BladeFlow> pages = flowBusinessService.selectClaimPage(Condition.getPage(query), bladeFlow);
return R.data(pages);
}
/**
* 待办事务列表页
*/
@GetMapping("todo-list")
@ApiOperation(value = "待办事务列表页", notes = "传入流程信息", position = 3)
public R<IPage<BladeFlow>> todoList(@ApiParam("流程信息") BladeFlow bladeFlow, Query query) {
IPage<BladeFlow> pages = flowBusinessService.selectTodoPage(Condition.getPage(query), bladeFlow);
return R.data(pages);
}
/**
* 已发事务列表页
*/
@GetMapping("send-list")
@ApiOperation(value = "已发事务列表页", notes = "传入流程信息", position = 4)
public R<IPage<BladeFlow>> sendList(@ApiParam("流程信息") BladeFlow bladeFlow, Query query) {
IPage<BladeFlow> pages = flowBusinessService.selectSendPage(Condition.getPage(query), bladeFlow);
return R.data(pages);
}
/**
* 办结事务列表页
*/
@GetMapping("done-list")
@ApiOperation(value = "办结事务列表页", notes = "传入流程信息", position = 5)
public R<IPage<BladeFlow>> doneList(@ApiParam("流程信息") BladeFlow bladeFlow, Query query) {
IPage<BladeFlow> pages = flowBusinessService.selectDonePage(Condition.getPage(query), bladeFlow);
return R.data(pages);
}
}

7
blade-service/blade-flow/src/main/java/org/springblade/flowable/business/feign/FlowClient.java

@ -17,9 +17,10 @@
package org.springblade.flowable.business.feign;
import lombok.AllArgsConstructor;
import org.flowable.engine.IdentityService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.flowable.core.entity.BladeFlow;
import org.springblade.flowable.core.feign.IFlowClient;
import org.springframework.web.bind.annotation.PostMapping;
@ -38,12 +39,12 @@ import java.util.Map;
public class FlowClient implements IFlowClient {
private RuntimeService runtimeService;
private TaskService taskService;
private IdentityService identityService;
@Override
@PostMapping(START_PROCESS_INSTANCE_BY_Id)
public BladeFlow startProcessInstanceById(String processDefinitionId, String businessKey, @RequestBody Map<String, Object> variables) {
identityService.setAuthenticatedUserId(SecureUtil.getUserAccount());
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinitionId, businessKey, variables);
BladeFlow flow = new BladeFlow();
flow.setProcessInstanceId(processInstance.getId());

64
blade-service/blade-flow/src/main/java/org/springblade/flowable/business/service/FlowBusinessService.java

@ -0,0 +1,64 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.flowable.business.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.flowable.core.entity.BladeFlow;
/**
* 流程业务类
*
* @author Chill
*/
public interface FlowBusinessService {
/**
* 流程待签列表
*
* @param page 分页工具
* @param bladeFlow 流程类
* @return
*/
IPage<BladeFlow> selectClaimPage(IPage<BladeFlow> page, BladeFlow bladeFlow);
/**
* 流程待办列表
*
* @param page 分页工具
* @param bladeFlow 流程类
* @return
*/
IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, BladeFlow bladeFlow);
/**
* 流程已发列表
*
* @param page 分页工具
* @param bladeFlow 流程类
* @return
*/
IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page, BladeFlow bladeFlow);
/**
* 流程办结列表
*
* @param page 分页工具
* @param bladeFlow 流程类
* @return
*/
IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page, BladeFlow bladeFlow);
}

235
blade-service/blade-flow/src/main/java/org/springblade/flowable/business/service/impl/FlowBusinessServiceImpl.java

@ -0,0 +1,235 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.flowable.business.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.flowable.business.service.FlowBusinessService;
import org.springblade.flowable.core.entity.BladeFlow;
import org.springblade.flowable.engine.constant.FlowableConstant;
import org.springblade.flowable.engine.utils.FlowCache;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 流程业务实现类
*
* @author Chill
*/
@Service
@AllArgsConstructor
public class FlowBusinessServiceImpl implements FlowBusinessService {
private RepositoryService repositoryService;
private TaskService taskService;
private HistoryService historyService;
@Override
public IPage<BladeFlow> selectClaimPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
String taskUser = SecureUtil.getUserAccount();
List<BladeFlow> flowList = new LinkedList<>();
// 等待签收的任务
TaskQuery claimQuery = taskService.createTaskQuery().taskCandidateUser(taskUser)
.includeProcessVariables().active().orderByTaskCreateTime().desc();
// 构建列表数据
buildFlowTaskList(bladeFlow, flowList, claimQuery, FlowableConstant.STATUS_CLAIM);
// 计算总数
long count = claimQuery.count();
// 设置页数
page.setSize(count);
// 设置总数
page.setTotal(count);
// 设置数据
page.setRecords(flowList);
return null;
}
@Override
public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
String taskUser = SecureUtil.getUserAccount();
List<BladeFlow> flowList = new LinkedList<>();
// 已签收的任务
TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
.includeProcessVariables().orderByTaskCreateTime().desc();
// 构建列表数据
buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowableConstant.STATUS_TODO);
// 计算总数
long count = todoQuery.count();
// 设置页数
page.setSize(count);
// 设置总数
page.setTotal(count);
// 设置数据
page.setRecords(flowList);
return page;
}
@Override
public IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
String taskUser = SecureUtil.getUserAccount();
List<BladeFlow> flowList = new LinkedList<>();
HistoricProcessInstanceQuery historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser).orderByProcessInstanceStartTime().desc();
// 查询列表
List<HistoricProcessInstance> historyList = historyQuery.listPage(Func.toInt(page.getCurrent() - 1), Func.toInt(page.getSize()));
historyList.forEach(historicProcessInstance -> {
BladeFlow bf = new BladeFlow();
// historicProcessInstance
bf.setCreateTime(historicProcessInstance.getStartTime());
bf.setEndTime(historicProcessInstance.getEndTime());
bf.setVariables(historicProcessInstance.getProcessVariables());
bf.setBusinessId(historicProcessInstance.getBusinessKey());
bf.setHisActInsActName(historicProcessInstance.getName());
bf.setProcessInstanceId(historicProcessInstance.getId());
bf.setHistoryProcessInstanceId(historicProcessInstance.getId());
// ProcessDefinition
ProcessDefinition pd = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
bf.setProcessDefinitionId(pd.getId());
bf.setProcessDefinitionName(pd.getName());
bf.setProcessDefinitionKey(pd.getKey());
bf.setProcessDefinitionVersion(pd.getVersion());
bf.setProcessInstanceId(historicProcessInstance.getId());
// HistoricTaskInstance
HistoricTaskInstance historyTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().list().get(0);
bf.setTaskId(historyTask.getId());
bf.setTaskName(historyTask.getName());
bf.setTaskDefinitionKey(historyTask.getTaskDefinitionKey());
// Status
if (historicProcessInstance.getEndActivityId() != null) {
bf.setProcessIsFinished(FlowableConstant.STATUS_FINISHED);
} else {
bf.setProcessIsFinished(FlowableConstant.STATUS_UNFINISHED);
}
bf.setStatus(FlowableConstant.STATUS_FINISH);
flowList.add(bf);
});
// 计算总数
long count = historyQuery.count();
// 设置总数
page.setTotal(count);
page.setRecords(flowList);
return page;
}
@Override
public IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
String taskUser = SecureUtil.getUserAccount();
List<BladeFlow> flowList = new LinkedList<>();
HistoricTaskInstanceQuery doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
.includeProcessVariables().orderByHistoricTaskInstanceEndTime().desc();
if (bladeFlow.getBeginDate() != null) {
doneQuery.taskCompletedAfter(bladeFlow.getBeginDate());
}
if (bladeFlow.getEndDate() != null) {
doneQuery.taskCompletedBefore(bladeFlow.getEndDate());
}
// 查询列表
List<HistoricTaskInstance> doneList = doneQuery.listPage(Func.toInt(page.getCurrent() - 1), Func.toInt(page.getSize()));
doneList.forEach(historicTaskInstance -> {
BladeFlow bf = new BladeFlow();
bf.setTaskId(historicTaskInstance.getId());
bf.setTaskDefinitionKey(historicTaskInstance.getTaskDefinitionKey());
bf.setTaskName(historicTaskInstance.getName());
bf.setAssignee(historicTaskInstance.getAssignee());
bf.setCreateTime(historicTaskInstance.getCreateTime());
bf.setExecutionId(historicTaskInstance.getExecutionId());
bf.setHistoryTaskEndTime(historicTaskInstance.getEndTime());
bf.setVariables(historicTaskInstance.getProcessVariables());
ProcessDefinition pd = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
bf.setProcessDefinitionId(pd.getId());
bf.setProcessDefinitionName(pd.getName());
bf.setProcessDefinitionKey(pd.getKey());
bf.setProcessDefinitionVersion(pd.getVersion());
bf.setProcessInstanceId(historicTaskInstance.getProcessInstanceId());
bf.setHistoryProcessInstanceId(historicTaskInstance.getProcessInstanceId());
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(historicTaskInstance.getProcessInstanceId()).singleResult();
if (historicProcessInstance.getEndActivityId() != null) {
bf.setProcessIsFinished(FlowableConstant.STATUS_FINISHED);
} else {
bf.setProcessIsFinished(FlowableConstant.STATUS_UNFINISHED);
}
bf.setStatus(FlowableConstant.STATUS_FINISH);
flowList.add(bf);
});
// 计算总数
long count = doneQuery.count();
// 设置总数
page.setTotal(count);
page.setRecords(flowList);
return page;
}
private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status) {
if (bladeFlow.getBeginDate() != null) {
taskQuery.taskCreatedAfter(bladeFlow.getBeginDate());
}
if (bladeFlow.getEndDate() != null) {
taskQuery.taskCreatedBefore(bladeFlow.getEndDate());
}
taskQuery.list().forEach(task -> {
BladeFlow bf = new BladeFlow();
bf.setTaskId(task.getId());
bf.setTaskDefinitionKey(task.getTaskDefinitionKey());
bf.setTaskName(task.getName());
bf.setAssignee(task.getAssignee());
bf.setCreateTime(task.getCreateTime());
bf.setClaimTime(task.getClaimTime());
bf.setExecutionId(task.getExecutionId());
bf.setVariables(task.getProcessVariables());
bf.setCategory(task.getCategory());
bf.setCategoryName(FlowCache.getCategoryName(task.getCategory()));
ProcessDefinition pd = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
bf.setProcessDefinitionId(pd.getId());
bf.setProcessDefinitionName(pd.getName());
bf.setProcessDefinitionKey(pd.getKey());
bf.setProcessDefinitionVersion(pd.getVersion());
bf.setProcessInstanceId(task.getProcessInstanceId());
bf.setStatus(status);
flowList.add(bf);
});
}
}

14
blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/constant/FlowableConstant.java

@ -31,4 +31,18 @@ public interface FlowableConstant {
String SUSPEND = "suspend";
String STATUS_TODO = "todo";
String STATUS_CLAIM = "claim";
String STATUS_SEND = "send";
String STATUS_DONE = "done";
String STATUS_FINISHED = "finished";
String STATUS_UNFINISHED = "unfinished";
String STATUS_FINISH = "finish";
}

4
blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowManagerController.java

@ -17,6 +17,7 @@
package org.springblade.flowable.engine.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
@ -41,6 +42,7 @@ import java.util.List;
@RestController
@RequestMapping("manager")
@AllArgsConstructor
@Api(value = "流程管理接口", tags = "流程管理接口")
public class FlowManagerController {
private FlowService flowService;
@ -51,7 +53,7 @@ public class FlowManagerController {
@GetMapping("list")
@ApiOperation(value = "分页", notes = "传入流程类型", position = 1)
public R<IPage<FlowProcess>> list(@ApiParam("流程类型") String category, Query query) {
IPage<FlowProcess> pages = flowService.selectManagerPage(Condition.getPage(query), category);
IPage<FlowProcess> pages = flowService.selectProcessPage(Condition.getPage(query), category);
return R.data(pages);
}

3
blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/FlowProcess.java

@ -20,6 +20,7 @@ import lombok.Data;
import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.flowable.engine.utils.FlowCache;
import org.springblade.system.utils.DictUtil;
import java.io.Serializable;
@ -50,7 +51,7 @@ public class FlowProcess implements Serializable {
this.name = entity.getName();
this.key = entity.getKey();
this.category = entity.getCategory();
this.categoryName = DictUtil.getValue(entity.getCategory().split(StringPool.UNDERSCORE)[0], Func.toInt(entity.getCategory().split(StringPool.UNDERSCORE)[1]));
this.categoryName = FlowCache.getCategoryName(entity.getCategory());
this.version = entity.getVersion();
this.deploymentId = entity.getDeploymentId();
this.resourceName = entity.getResourceName();

2
blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/FlowService.java

@ -48,7 +48,7 @@ public interface FlowService extends IService<FlowModel> {
* @param category 分类
* @return
*/
IPage<FlowProcess> selectManagerPage(IPage<FlowProcess> page, String category);
IPage<FlowProcess> selectProcessPage(IPage<FlowProcess> page, String category);
/**
* 变更流程状态

4
blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java

@ -76,12 +76,11 @@ public class FlowServiceImpl extends ServiceImpl<FlowMapper, FlowModel> implemen
}
@Override
public IPage<FlowProcess> selectManagerPage(IPage<FlowProcess> page, String category) {
public IPage<FlowProcess> selectProcessPage(IPage<FlowProcess> page, String category) {
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().latestVersion().orderByProcessDefinitionKey().asc();
if (StringUtils.isNotEmpty(category)) {
processDefinitionQuery.processDefinitionCategory(category);
}
page.setTotal(processDefinitionQuery.count());
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(Func.toInt(page.getCurrent() - 1), Func.toInt(page.getSize()));
List<FlowProcess> flowProcessList = new ArrayList<>();
for (ProcessDefinition processDefinition : processDefinitionList) {
@ -91,6 +90,7 @@ public class FlowServiceImpl extends ServiceImpl<FlowMapper, FlowModel> implemen
flowProcess.setDeploymentTime(deployment.getDeploymentTime());
flowProcessList.add(flowProcess);
}
page.setTotal(processDefinitionQuery.count());
page.setRecords(flowProcessList);
return page;
}

73
blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/utils/FlowCache.java

@ -0,0 +1,73 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.flowable.engine.utils;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.repository.ProcessDefinition;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.system.utils.DictUtil;
/**
* 流程缓存
*
* @author Chill
*/
public class FlowCache {
private static final String FLOW_CACHE = "flow:process";
private static final String FLOW_CACHE_PD_ID_ = "definition_id_";
private static RepositoryService repositoryService;
static {
repositoryService = SpringUtil.getBean(RepositoryService.class);
}
/**
* 获得流程定义对象
*
* @param procDefId 流程对象id
* @return
*/
public static ProcessDefinition getProcessDefinition(String procDefId) {
ProcessDefinition pd = CacheUtil.get(FLOW_CACHE, FLOW_CACHE_PD_ID_ + procDefId, ProcessDefinition.class);
if (Func.isEmpty(pd)) {
pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
if (Func.isNotEmpty(pd)) {
CacheUtil.put(FLOW_CACHE, FLOW_CACHE_PD_ID_ + procDefId, pd);
}
}
return pd;
}
/**
* 获取流程类型名
*
* @param category 流程类型
* @return
*/
public static String getCategoryName(String category) {
if (Func.isEmpty(category)) {
return StringPool.EMPTY;
}
return DictUtil.getValue(category.split(StringPool.UNDERSCORE)[0], Func.toInt(category.split(StringPool.UNDERSCORE)[1]));
}
}

16
doc/sql/bladex-update-RC9.sql

@ -50,12 +50,24 @@ INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`,
VALUES (@startid, 'work_start_image', '流程图', 'image', '', 'image', 2, 2, 2, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@workid, 'work_todo', '代办事务', 'menu', '/work/todo', NULL, 2, 1, 0, 1, NULL, 0);
VALUES (@workid, 'work_claim', '待签事务', 'menu', '/work/claim', NULL, 2, 1, 0, 1, NULL, 0);
set @claimid = (SELECT LAST_INSERT_ID());
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@claimid, 'work_claim_sign', '签收', 'sign', '', 'sign', 1, 2, 2, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@claimid, 'work_claim_detail', '详情', 'detail', '', 'detail', 2, 2, 2, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@claimid, 'work_claim_follow', '跟踪', 'follow', '', 'follow', 3, 2, 2, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@workid, 'work_todo', '待办事务', 'menu', '/work/todo', NULL, 2, 1, 0, 1, NULL, 0);
set @todoid = (SELECT LAST_INSERT_ID());
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@todoid, 'work_todo_handle', '办理', 'handle', '', 'handle', 1, 2, 2, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@todoid, 'work_todo_follow', '跟踪', 'follow', '', 'follow', 2, 2, 2, 1, NULL, 0);
VALUES (@todoid, 'work_todo_detail', '详情', 'detail', '', 'detail', 2, 2, 2, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@todoid, 'work_todo_follow', '跟踪', 'follow', '', 'follow', 3, 2, 2, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)

Loading…
Cancel
Save