activiti 7工作流

  • 一、用户体系与 activiti 整合
  • 1、取部门ID为103的部门经理,se 表示部门经理,取出来的结果可能多个
  • 2、流程定义指定部门经理
  • 3、代码中指定部门经理
  • 二、整合 vue与activiti


一、用户体系与 activiti 整合

1、取部门ID为103的部门经理,se 表示部门经理,取出来的结果可能多个

SELECT
	user_name 
FROM
	sys_post p
	LEFT JOIN sys_user_post up ON p.post_id = up.post_id
	LEFT JOIN sys_user u ON up.user_id = u.user_id 
WHERE
	p.post_code ="se"
	AND u.dept_id = 103;

sys_post 岗位表

activiti7去除spring security_activiti 7


sys_user 用户表

activiti7去除spring security_表单_02


sys_user_post 用户岗位表

activiti7去除spring security_spring cloud_03

2、流程定义指定部门经理

activiti7去除spring security_ci_04

3、代码中指定部门经理

@Override
    public int insertWorkflowLeave(WorkflowLeave workflowLeave) {

        String id = UUID.randomUUID().toString();
        workflowLeave.setId(id);
        workflowLeave.setCreateTime(DateUtils.getNowDate());
        String join = StringUtils.join(sysUserService.selectUserNameByPostCodeAndDeptId("se", SecurityUtils.getLoginUser().getUser().getDeptId()), ",");
        ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder
                .start()
                .withProcessDefinitionKey("leave")
                .withName(workflowLeave.getTitle())
                .withBusinessKey(id)
                .withVariable("deptLeader",join)
                .build());
        workflowLeave.setInstanceId(processInstance.getId());
        workflowLeave.setState("0");
        workflowLeave.setCreateName(SecurityUtils.getNickName());
        workflowLeave.setCreateBy(SecurityUtils.getUsername());
        workflowLeave.setCreateTime(DateUtils.getNowDate());
        return workflowLeaveMapper.insertWorkflowLeave(workflowLeave);
    }

二、整合 vue与activiti

整合ruoyi-vue-activiti到sx 的步聚

一、整合所有后端代码 包换两个项目activiti 、workflow
二、整合所有前端代码 public 、bpmn js、api、views

问题:
1、mybatis 版本冲突

<dependency>
            <groupId>com.sx</groupId>
            <artifactId>sx-activiti</artifactId>
            <version>2.4.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>mybatis</artifactId>
                    <groupId>org.mybatis</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>sx-common-core</artifactId>
                    <groupId>com.sx</groupId>
                </exclusion>
            </exclusions>


        </dependency>

2、activiti 不生成库表问题
解决不生成库表问题

3、
获取用户失败:[401] during [GET] to [http://sx-system/user/info/admin] [RemoteUserService#getUserInfo(String)]: [{“timestamp”:“2021-10-12T16:17:07.566+08:00”,“status”:401,“error”:“Unauthorized”,“message”:“”,“path”:“/user/info/admin”}]

问题原因:activiti 7 自动会配置spring security 权限控制导致的。
解决方案:

4、maven 多模块 报 Invalid bound statement

找到问题的原因了:

5、An Authentication object was not found in the SecurityContext问题

Http11Processor–>service— > this.getAdapter().service(this.request, this.response);

org.springframework.web.servlet.DispatcherServlet

system :

auth :

org.springframework.cloud.openfeign.ribbon.CachingSpringLoadBalancerFactory

public FeignLoadBalancer create(String clientName) {

feign-core包
feign.FeignException—>clientErrorStatus

activiti7去除spring security_表单_05

activiti7去除spring security_ci_06


activiti7去除spring security_表单_07

问题:
1、openfeign 的fallback 原理
2、debug时怎么让他不进入fallback

Activiti7相关问题汇总:

springboot activiti 配置项详解

配置:
spring:
activiti:
database-schema-update: true
history-level: full
db-history-used: true

三、脚本:

alter table ACT_RE_DEPLOYMENT add column PROJECT_RELEASE_VERSION_ varchar(255) DEFAULT NULL;
alter table ACT_RE_DEPLOYMENT add column VERSION_ varchar(255) DEFAULT NULL;

DROP TABLE IF EXISTS `act_workflow_formdata`;
CREATE TABLE `act_workflow_formdata`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '唯一标识符',
  `business_key` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事务key',
  `form_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单Key',
  `control_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单id',
  `control_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单名',
  `control_value` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单值',
  `task_node_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务节点名称',
  `create_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `create_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '动态表单' ROW_FORMAT = Dynamic;


INSERT INTO `sys_dict_data` VALUES (100, 1, '进行中', '0', 'activiti_flow_type', NULL, NULL, 'N', '0', 'admin', '2020-10-28 00:03:42', 'admin', '2020-10-28 22:40:58', NULL);
INSERT INTO `sys_dict_data` VALUES (101, 2, '成功', '1', 'activiti_flow_type', NULL, NULL, 'N', '0', 'admin', '2020-10-28 00:03:50', 'admin', '2020-10-28 22:41:09', NULL);
INSERT INTO `sys_dict_data` VALUES (102, 3, '失败', '2', 'activiti_flow_type', NULL, NULL, 'N', '0', 'admin', '2020-10-28 00:04:02', 'admin', '2020-10-28 22:41:17', NULL);
INSERT INTO `sys_dict_data` VALUES (103, 1, '年假', '年假', 'activiti_leave_type', NULL, NULL, 'N', '0', 'admin', '2020-10-28 00:07:14', 'admin', '2020-11-04 17:41:02', NULL);
INSERT INTO `sys_dict_data` VALUES (104, 2, '病假', '病假', 'activiti_leave_type', NULL, NULL, 'N', '0', 'admin', '2020-10-28 00:07:27', 'admin', '2020-11-04 17:41:07', NULL);
INSERT INTO `sys_dict_data` VALUES (105, 3, '事假', '事假', 'activiti_leave_type', NULL, NULL, 'N', '0', 'admin', '2020-10-28 00:07:48', 'admin', '2020-11-04 17:41:12', NULL);

INSERT INTO `sys_dict_type` VALUES (100, 'OA状态', 'activiti_flow_type', '0', 'admin', '2020-10-28 00:01:56', 'admin', '2020-10-28 00:02:43', 'OA流程状态');
INSERT INTO `sys_dict_type` VALUES (101, '请假类型', 'activiti_leave_type', '0', 'admin', '2020-10-28 00:06:10', 'admin', '2020-10-28 00:06:34', NULL);

INSERT INTO `sys_menu` VALUES (5, '流程菜单', 0, 4, 'activiti', NULL, 1, 0, 'M', '0', '0', 'activiti:modeler:list', 'cascader', 'admin', '2020-09-13 21:58:54', '', NULL, '');

INSERT INTO `sys_menu` VALUES (1901, '流程定义', 5, 1, 'definition', 'activiti/definition/index', 1, 0, 'C', '0', '0', 'activiti:modeler', '#', 'admin', '2020-09-14 23:09:31', '', NULL, '');
INSERT INTO `sys_menu` VALUES (3011, '请假', 2008, 1, 'leave', 'workflow/leave/index', 1, 0, 'C', '0', '0', 'workflow:leave:list', '#', 'admin', '2020-10-28 22:30:57', 'admin', '2020-11-10 22:15:13', '请假菜单');
INSERT INTO `sys_menu` VALUES (3001, '请假查询', 2000, 1, '#', '', 1, 0, 'F', '0', '0', 'workflow:leave:query', '#', 'admin', '2020-10-28 22:30:57', '', NULL, '');
INSERT INTO `sys_menu` VALUES (3002, '请假新增', 2000, 2, '#', '', 1, 0, 'F', '0', '0', 'workflow:leave:add', '#', 'admin', '2020-10-28 22:30:57', '', NULL, '');
INSERT INTO `sys_menu` VALUES (3003, '请假修改', 2000, 3, '#', '', 1, 0, 'F', '0', '0', 'workflow:leave:edit', '#', 'admin', '2020-10-28 22:30:57', '', NULL, '');
INSERT INTO `sys_menu` VALUES (3004, '请假删除', 2000, 4, '#', '', 1, 0, 'F', '0', '0', 'workflow:leave:remove', '#', 'admin', '2020-10-28 22:30:57', '', NULL, '');
INSERT INTO `sys_menu` VALUES (3005, '请假导出', 2000, 5, '#', '', 1, 0, 'F', '0', '0', 'workflow:leave:export', '#', 'admin', '2020-10-28 22:30:57', '', NULL, '');
INSERT INTO `sys_menu` VALUES (3006, '待办任务', 0, 6, 'task', NULL, 1, 0, 'M', '0', '0', '', 'excel', 'admin', '2020-11-04 10:53:24', 'admin', '2020-11-10 22:26:46', '');
INSERT INTO `sys_menu` VALUES (3007, '代办任务', 2006, 1, 'task', 'activiti/task', 1, 0, 'C', '0', '0', '', '#', 'admin', '2020-11-04 10:54:28', 'admin', '2020-11-04 10:55:06', '');
INSERT INTO `sys_menu` VALUES (3008, '我的OA', 0, 5, 'OA', NULL, 1, 0, 'M', '0', '0', '', 'guide', 'admin', '2020-11-10 22:13:34', 'admin', '2020-11-10 22:15:29', '');
INSERT INTO `sys_menu` VALUES (3009, '历史流程', 0, 7, 'open', NULL, 1, 0, 'M', '0', '0', NULL, 'eye-open', 'admin', '2020-11-10 22:17:36', '', NULL, '');
INSERT INTO `sys_menu` VALUES (3010, '请假历史', 2009, 1, 'leaveAll', 'workflow/leave/leaveAll', 1, 0, 'C', '0', '0', 'workflow:leave:list', '#', 'admin', '2020-10-28 22:30:57', 'admin', '2020-11-10 22:45:16', '请假菜单');

INSERT INTO `sys_role` VALUES (100, '部门历史OA', 'dept', 3, '4', 1, 1, '0', '0', 'admin', '2020-11-10 22:26:07', '', '2020-11-10 22:27:52', NULL);

INSERT INTO `sys_role_menu` VALUES (2, 3000);
INSERT INTO `sys_role_menu` VALUES (2, 3001);
INSERT INTO `sys_role_menu` VALUES (2, 3002);
INSERT INTO `sys_role_menu` VALUES (2, 3003);
INSERT INTO `sys_role_menu` VALUES (2, 3004);
INSERT INTO `sys_role_menu` VALUES (2, 3005);
INSERT INTO `sys_role_menu` VALUES (2, 3006);
INSERT INTO `sys_role_menu` VALUES (2, 3007);
INSERT INTO `sys_role_menu` VALUES (2, 3008);
INSERT INTO `sys_role_menu` VALUES (100, 3000);
INSERT INTO `sys_role_menu` VALUES (100, 3001);
INSERT INTO `sys_role_menu` VALUES (100, 3002);
INSERT INTO `sys_role_menu` VALUES (100, 3003);
INSERT INTO `sys_role_menu` VALUES (100, 3004);
INSERT INTO `sys_role_menu` VALUES (100, 3005);
INSERT INTO `sys_role_menu` VALUES (100, 3006);
INSERT INTO `sys_role_menu` VALUES (100, 3007);
INSERT INTO `sys_role_menu` VALUES (100, 3008);
INSERT INTO `sys_role_menu` VALUES (100, 3009);
INSERT INTO `sys_role_menu` VALUES (100, 3010);

INSERT INTO `sys_user` VALUES (200, 103, 'guanxing', '关兴', '00', '1@ry.com', '18600000001', '0', '', '$2a$10$ekiSpWpUVv8/WuUS1up8XuNah.FVbJ5ZC9XdvqWxBE5qc2qP6KF6W', '0', '0', '', NULL, 'admin', '2020-11-04 14:39:07', 'admin', '2020-11-10 22:29:48', NULL);
INSERT INTO `sys_user` VALUES (201, 103, 'guanyu', '关羽', '00', '2@ry.com', '18600000002', '0', '', '$2a$10$CT.xyhiTacc9V.X8YFfdDeaU68Li9C9MNpAssJ/W4v.1MC.AtiOsa', '0', '0', '', NULL, 'admin', '2020-11-04 14:40:43', 'admin', '2020-11-10 22:30:29', NULL);
INSERT INTO `sys_user` VALUES (202, 100, 'zhugeliang', '诸葛亮', '00', '3@ry.com', '18600000003', '0', '', '$2a$10$iOYs0XUxmyOF5PDxNGyNt.qf6.LpUzBPRBhbIAwlmrN7lgjjBd0KO', '0', '0', '', NULL, 'admin', '2020-11-04 14:41:37', 'admin', '2020-11-10 22:30:37', NULL);
INSERT INTO `sys_user` VALUES (203, 103, 'zhaoyun', '赵云', '00', '4@ry.com', '18600000004', '0', '', '$2a$10$JILiC3cILDSk0EgDprEr9OS1pNxp9fM8vuXBC.VRxds.bwHFE/gba', '0', '0', '', NULL, 'admin', '2020-11-08 15:52:30', 'admin', '2020-11-10 22:30:44', NULL);
INSERT INTO `sys_user` VALUES (204, 103, 'zhoucang', '周仓', '00', '5@ry.com', '18600000005', '0', '', '$2a$10$ekiSpWpUVv8/WuUS1up8XuNah.FVbJ5ZC9XdvqWxBE5qc2qP6KF6W', '0', '0', '', NULL, 'admin', '2020-11-04 14:39:07', 'admin', '2020-11-10 22:29:48', NULL);

INSERT INTO `sys_user_post` VALUES (200, 4);
INSERT INTO `sys_user_post` VALUES (201, 2);
INSERT INTO `sys_user_post` VALUES (202, 3);
INSERT INTO `sys_user_post` VALUES (203, 2);


INSERT INTO `sys_user_role` VALUES (200, 2);
INSERT INTO `sys_user_role` VALUES (201, 100);
INSERT INTO `sys_user_role` VALUES (202, 100);
INSERT INTO `sys_user_role` VALUES (203, 100);


DROP TABLE IF EXISTS `workflow_leave`;
CREATE TABLE `workflow_leave`  (
  `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键ID',
  `type` char(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请假类型',
  `title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标题',
  `reason` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '原因',
  `leave_start_time` date NULL DEFAULT NULL COMMENT '开始时间',
  `leave_end_time` date NULL DEFAULT NULL COMMENT '结束时间',
  `attachment_link` varchar(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件',
  `instance_id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `state` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态',
  `create_name` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建者名称',
  `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '请假' ROW_FORMAT = Dynamic;

四、在新加的API中增加前缀。/system

五、增加两条白名单

activiti7去除spring security_表单_08