赞
踩
flowbale工作流各个表和字段的介绍:https://www.cnblogs.com/phyger/p/14067201.html
运行官方demo:https://blog.csdn.net/u013972652/article/details/109990809
flowable使用流程:
1.首先画流程图,给流程图绑定流程变量;
2.部署流程图,产生流程定义.
3.开启流程实例
流程部署之后:act_re_deployment记录数+1;act_re_procdef记录数+1;
act_ru_actinst:运行中的节点信息表,开启流程实例后,生成流程实例id,把模型的各个节点往里边插入值.
ac_ru_identitylink开启流程实例后,该流程实例的所有的参与人放到此表中.
act_ru_variable 开启一个流程实例后,往里边插入运行中变量的id,根据流程实例查询出开启流程实例put进去的变量,随着流程的递进增加或减少,流程完毕,流程实例下变量清空,进入到了历史表中.
act_ru_execution 每一个用户节点都是一个执行的实例.但是数据根流程实例.随着流程的递进,流程完毕,进入到历史表中
act_ru_task 开启流程实例后,当前要处理的人物存储在这个表中.随着节点的递进,流程实例下的记录不断改变
act_hi_varinst存放所有的历史变量
act_hi_taskinst存放所有的用户任务
act_hi_procinst存放单个流程实例
act_hi_comment存放用户操作的信息,包括审批信息,附言信息等.
act_hi_actinst存放所有的节点信息
流程图绑定变量#{deptManager} 跳过表达式${deptManager==''}
下边是配置代码:flowable的maven子模块
- 若依后台框架整合flowable的配置
- flowable的maven包下的config配置
-
- @Configuration
- @ComponentScan(value={"org.flowable.ui.modeler.rest.app"},excludeFilters={
- @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,value=DatabaseConfiguration.class),
- @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,value=StencilSetResource.class),
- @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,value=EditorUsersResource.class),
- @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,value=EditorGroupsResource.class),
- })
- @EnableAsync
- public class AppDispatcherServletConfiguration implements WebMvcRegistrations{
- private static final LOGGER = LoggerFactory.getLogger(AppDispatcherServletConfiguration.class);
- @Bean
- public SessionLocaleResolver localeResolver(){
- return new SessionLocaleResolver();
- }
- @Bean
- public LocaleChangeInterceptor LocaleChangeInterceptor(){
- LOGGER.debug("Configution localeChangeInterceptor");
- LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
- localeChangeInterceptor.setParamName("language");
- return localeChangeInterceptor;
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public RequestMappingHandlerMapping getRequestMappingHandlerMapping(){
- RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
- requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
- requestMappingHandlerMapping.setRemoveSemicolonContext(false);
- Object [] interceptors = {localeChangeInterceptor()};
- requestMappingHandlerMapping.setInterceptros(interceptors);
- return requestMappingHandlerMapping;
- }
- }
-
- @Configuration
- @EnableConfigurationProperities({FlowableModelerAppProperties.class})
- @ComponentScan(basePackages={
- "org.flowable.ui.modeler.repository",
- "org.flowable.ui.modeler.service",
- "org.flowable.ui.common.service",
- "org.flowable.ui.common.repository",
- "org.flowable.ui.comon.tenant"
- },execludeFilters={
- @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,value=RemoteIdmService.class)
- })
- public class ApplicationConfiguration{
- @SuppressWarnings({"rawtypes","unchecked"})
- @Bean
- public ServletRegistrationBean apiServlet(ApplicationContext applicationContext){
- AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
- AnnotationConfigWebApplicationContext.setParent(applicationContext);
- AnnotationConfigWebApplicationContext.register(ApiDispatcherServletConfiguration.class);
- DispatcherServlet servlet = new DispatcherServlet(dispatcherServletConfiguration)
- ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet,"/api/*");
- registrationBean.setName("Flowable IDM App API Servlet");
- registrationBean.setLoadOnStartup(1);
- registrationBean.setAsyncSupoorted(true);
- return registrationBean;
- }
-
- @Bean
- public HttpFirewall allowUrlEncodedSlashHttpFirewall(){
- StricHttpFirewall firewall = new StrictHttpFirewall();
- firewall.setAllowUrlEncodeSlash(true);
- return firewall;
- }
- }
-
-
- @Configutation
- public class DatabaseLiquiAutoConfiguration{
- private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseLiquiAutoConfigutation.class);
-
- protect static fianl String LIQUIBASE_CHANGELOG_PREFIX = "ACT_DE_";
-
- @Bean
- public Liquibase liquibase(DataSource dataSource){
- LOGGER.info("configuring Liquibase");
- Liquibase liquibase = null;
- try{
- DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());
- Databse database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
- database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogTableName());
- database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX=database.getDatabaseChangeLogLockTableName());
- liquibase = new Liquibase("META_INF/liquibase/flowable0modeler-app-db-changelog.xml",new ClassLoaderResourceAccessor(),database);
- liquibase.updata("flowable");
- return liquibase;
- }catch(Exception e){
- throw new InternalServerErrorException("Error creating liquibase database",e)
- }finally{
- closeDatabase(liquibase);
- }
- }
-
- public void closeDatabase(Liquibase liquibase){
- if(liquibase!=null){
- Database database = liquibase.getDatabase();
- if(database!=null){
- try{
- database.close();
- }catch(DatabaseException e){
- LOGGER.warn("Error closing database",e);
- }
- }
- }
- }
- }
-
-
-
-
- @Api
- @RestController
- @RequestMapping("/app")
- public class FlowableStencilSetResource{
- private static final Logger LOGGER = LoggerFactory.getLogger(FlowableStencilSetResource.class);
-
- @Autowired
- protected ObjectMapper objectMapper;
-
- @ApiOperation("获取bpmn sets文件")
- @RequestMapping(value="rest/stencli-sets/editor",method=RequestMethod.GET,produces="application/json")
- public JsonNode getStencilSetForEditor(){
- try{
- InputStream is = this.getClass().getClassLoader().getReourceAsStream("stencilset/stencilset_bpmn.json");
- JsonNode stencilNode = objectMapper.readTree(is);
- return stencilNode;
- }catch(Exception e){
- LOGGER.error("Error reading bpmn stencil set json",e);
- throw new InternalServerErrorException("Error reading bpmn stencli set json");
- }
- }
-
- @ApiOperation(value="获取cmmn sets文件")
- @RequestMapping(value="/rest/stencil-sets/cmmneditor",method=RequestMethod.GET,produces="application/json")
- public JsonNode getCmmnStencilSetForEditor(){
- try{
- JsonNode stencilNode = objectMapper.readTree(this.getClass.getClassLoader().getResourceAsStream("stencilset/stencilset_cmmn.json"));
- return stencilNode;
- }catch(Exception e){
- LOGGER.error("Error reading bpmn stencli set json",e);
- throw new InternalSeverErrorException("Error reading bpmn stencil set json")
- }
- }
- }
-
-
- //流程引擎配置文件
- @Configuration
- public class ProcessEngineConfig{
- private Logger logger = LoggerFactory.getLogger(ProcessEngineConfig.class);
-
- @Bean
- public SpringProcessEngineConfiguration springProcessEngineConfiuration(DataSourceTransactionManager datasourceTransactionManager,DataSource dataSource){
- SpringProcessEngineConfiguration.springProcessEngineConfiguration = new SpringProcessEngineConfiguration();
- springProcessEngineConfiguration.setDataSource(dataSource);
- springProcessEngineConfiguration.setTransactionManager(datasourceTransactionManager);
- springProcessEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEME_UPDATE_TRUE);
- springProcessEngineConfiguration.setAsyncExcutorActivate(true);
- springProcessEngineConfiguration.setActivityFontName();
- springProcessEngineConfiguration.setLabelFontName();
- springProcessEngineConfiguration.setAnnotationFontName();
-
- return springProcessEngineConfiguration;
- }
- }
-
- FlowableController.java
- @Api(tags="flowable测试接口")
- @RestController
- @RequestMapping("/flowable")
- public class FlowableController{
- @Autowired
- private IdentityService identityService;
-
- @Autowired
- private RepositoryService repositoryService;
-
- @Autowired
- private RuntimeService runtimeService;
-
- @Autowired
- private TaskService taskService;
-
- @Autowired
- private ProcessEngine processEngine;
-
- @ApiOperation("新建用户")
- @GetMaping("/user/createUser",produces={"application/json"})
- public User createUser(String name,String firstName,String lastName){
- User user = identityService.newUser(name);
- user.setFirstName(firstName);
- user.setLastName(lastName);
- user.setEmail("123@qq.com");
- user.setPassword("123456");
- identityService.saveUser(user);
- return user; //org.flowable.idm.api.User;
-
- }
-
- @ApiOperation("获取用户的任务")
- @GetMapping("value=/getTasks/{userId}",produces={"application/json"})
- public List<Title> getTasks(@PathVariable String userId){
- return taskService.createTaskQuery().taskAssignee(userId).orderByTaskCreateTime().desc().list();
- }
-
- @ApiOperation("审批不通过")
- @PostMapping("value=/faile/{taskId}")
- public String faile(@PathVariable String taskId){
- Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
- if(task == null){
- return "流程不存在";
- }
- HashMap<String,Object> map = new HashMap<>();
- map.put("approved",false);
- taskService.complete(taskId,map);
- return "审批不通过";
- }
-
- @ApiOperation("获取流程图")
- @PostMapping(value="processDiagram")
- public void getProcessDiagram(HttpServletResponse response,String processId) throws IOException{
- ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
- //流程走完的不显示图
- if(pi==null){
- return;
- }
- Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
- String instanceId = task.getProcessInstanceId();
- List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(instanceId).list();
-
- List<String> activityIds = new ArrayList<>();
- List<String> flows = new ArrayList<>();
- for(Execution exe:executions){
- List<String> ids = runtimeService.getActiveActivityIds(exe.getId());
- activityIds.addAll(ids);
- }
- //获取流程图
- BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId());
- ProcessEngineConfiguration engconf = processEngine.getprocessEngineConfiguration();
- ProcesDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator();
- InputStream in = diagramGeneratro.generateDiagram(bpmnMode,"png",activityIds,flows,engconf.getActivityFontName(),engconf.getLabelFontName(),engconf.getAnnotaionFontName(),
- engconf.getClassLoader(),1.0,true);
- OutputStream out = null;
- byte[] buf = new byte[1024];
- int length = 0;
- try{
- out = response.getOutputStream();
- while((length=in.read(buf))!=-1){
- out.write(buf,0,length);
- }
- }finally{
- if(in!=null){
- in.close();
- }
- if(out!=null){
- out.close();
- }
- }
- }
- }
-
-
- ModelController.java
- @Api(tags="流程管理模块")
- @RestController
- @RequestMapping("/modelmanager")
- public class ModelController{
- private static final Logger LOGGER = LoggerFactory.getLogger(ModelController.class);
-
- @Autowired
- private IFlowableModelService flowableModelService;
- @Autowired
- private ModelService modelService;
- @Autowired
- private ProcessEngine processEngine;
- @Autowired
- private AddFlwProcessModelService addFlwProcessModelService;
- @Autowired
- private TokenService tokenService;
-
- @ApiOperation("获取模型列表")
- @GetMapping("/list-model")
- public ReturnVo<List<ChildModel>> listModel(){
- ReturnVo<List<ChildModel>> returnVo = new ReturnVo<>(ReturnCode.SUCCESS,"OK");
- List<AbstractModel> datas = modelService.getModelByModelType(Abstract.MODEL_TYPE_BPMN);
- ..........
- .........
- ........
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。