流程管理新增

This commit is contained in:
2024-05-13 21:12:32 +08:00
parent fb6ce3fc11
commit fc2f2d767a
62 changed files with 596 additions and 64 deletions

View File

@@ -14,7 +14,7 @@ import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFacto
* 自定义的 ActivityBehaviorFactory 实现类,目的如下:
* 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配
*
* @author 芋道源码
* @author hongawen
*/
@Setter
public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory {

View File

@@ -18,7 +18,7 @@ import java.util.Set;
*
* 本质上,实现和 {@link BpmParallelMultiInstanceBehavior} 一样,只是继承的类不一样
*
* @author 芋道源码
* @author hongawen
*/
@Setter
public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceBehavior {

View File

@@ -23,7 +23,7 @@ import java.util.Set;
* 第一步,基于分配规则,计算出分配任务的【单个】候选人。如果找不到,则直接报业务异常,不继续执行后续的流程;
* 第二步,随机选择一个候选人,则选择作为 assignee 负责人。
*
* @author 芋道源码
* @author hongawen
*/
@Slf4j
public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior {

View File

@@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
/**
* bpm 模块的 web 组件的 Configuration
*
* @author 芋道源码
* @author hongawen
*/
@Configuration(proxyBeanMethods = false)
public class BpmWebConfiguration {

View File

@@ -5,7 +5,7 @@ import org.flowable.engine.runtime.ProcessInstance;
/**
* BPM 通用常量
*
* @author 芋道源码
* @author hongawen
*/
public class BpmConstants {

View File

@@ -0,0 +1,113 @@
package com.njcn.bpm.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.bpm.pojo.param.BpmSignParam;
import com.njcn.bpm.pojo.param.BpmSignParam;
import com.njcn.bpm.pojo.po.BpmCategory;
import com.njcn.bpm.pojo.po.BpmSign;
import com.njcn.bpm.pojo.vo.BpmSignVO;
import com.njcn.bpm.service.IBpmSignService;
import com.njcn.bpm.service.IBpmSignService;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.njcn.web.controller.BaseController;
import javax.validation.Valid;
import java.util.List;
/**
* <p>
* BPM 流程标识 前端控制器
* </p>
*
* @author hongawen
* @since 2024-05-13
*/
@RestController
@RequestMapping("/bpmSign")
@Validated
@Slf4j
@Api(tags = "流程标识控制器")
@RequiredArgsConstructor
public class BpmSignController extends BaseController {
private final IBpmSignService bpmSignService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("创建流程标识")
@ApiImplicitParam(name = "bpmSignParam", value = "流程标识数据", required = true)
public HttpResult<String> add(@Valid @RequestBody BpmSignParam bpmSignParam) {
String methodDescribe = getMethodDescribe("add");
String categoryId = bpmSignService.createSign(bpmSignParam);
if (StrUtil.isNotBlank(categoryId)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, categoryId, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("更新流程标识")
@ApiImplicitParam(name = "updateParam", value = "流程标识数据", required = true)
public HttpResult<Object> update(@RequestBody @Validated BpmSignParam.BpmSignUpdateParam updateParam) {
String methodDescribe = getMethodDescribe("update");
bpmSignService.updateSign(updateParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/delete")
@ApiOperation("删除流程标识")
@ApiImplicitParam(name = "ids", value = "流程标识索引", required = true, dataTypeClass = List.class)
public HttpResult<Object> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{}流程标识ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids));
bpmSignService.deleteSign(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/list")
@ApiOperation("查询流程标识数据")
@ApiImplicitParam(name = "bpmSignQueryParam", value = "查询参数", required = true)
public HttpResult<Page<BpmSignVO>> list(@RequestBody BpmSignParam.BpmSignQueryParam bpmSignQueryParam) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询流程标识数据为:{}", methodDescribe, bpmSignQueryParam);
Page<BpmSignVO> result = bpmSignService.getSignPage(bpmSignQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@GetMapping("/simpleList")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@Operation(summary = "获得动态表单的精简列表", description = "用于表单下拉框")
public HttpResult<List<BpmSign>> getSignSimpleList() {
String methodDescribe = getMethodDescribe("getCategorySimpleList");
List<BpmSign> list = bpmSignService.getSignSimpleList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -9,7 +9,7 @@ import javax.validation.Valid;
/**
*
* @author 芋道源码
* @author hongawen
*/
@AllArgsConstructor
@Validated

View File

@@ -8,7 +8,7 @@ import javax.validation.constraints.NotNull;
/**
* 流程实例的状态(结果)发生变化的 Event
*
* @author 芋道源码
* @author hongawen
*/
@SuppressWarnings("ALL")
@Data

View File

@@ -6,7 +6,7 @@ import org.springframework.context.ApplicationListener;
/**
* {@link BpmProcessInstanceStatusEvent} 的监听器
*
* @author 芋道源码
* @author hongawen
*/
public abstract class BpmProcessInstanceStatusEventListener
implements ApplicationListener<BpmProcessInstanceStatusEvent> {

View File

@@ -12,7 +12,6 @@ import org.apache.ibatis.annotations.Param;
/**
* BPM 流程分类 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface BpmCategoryMapper extends BaseMapper<BpmCategory> {

View File

@@ -0,0 +1,21 @@
package com.njcn.bpm.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.bpm.pojo.po.BpmSign;
import com.njcn.bpm.pojo.vo.BpmSignVO;
import org.apache.ibatis.annotations.Param;
/**
* <p>
* BPM 流程标识 Mapper 接口
* </p>
*
* @author hongawen
* @since 2024-05-13
*/
public interface BpmSignMapper extends BaseMapper<BpmSign> {
Page<BpmSignVO> page(@Param("page")Page<Object> objectPage, @Param("ew") QueryWrapper<BpmSignVO> bpmSignVOQueryWrapper);
}

View File

@@ -10,7 +10,7 @@
bpm_category.code,
bpm_category.status,
bpm_category.create_time,
bpm_category.remark
bpm_category.description
FROM bpm_category bpm_category
WHERE ${ew.sqlSegment}
</select>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.bpm.mapper.BpmSignMapper">
<!--获取流程标识分页列表-->
<select id="page" resultType="BpmSignVO">
SELECT
bpm_sign.id,
bpm_sign.name,
bpm_sign.sign_key,
bpm_sign.view_path,
bpm_sign.create_time
FROM bpm_sign bpm_sign
WHERE ${ew.sqlSegment}
</select>
</mapper>

View File

@@ -17,7 +17,6 @@ import static com.njcn.bpm.utils.CollectionUtils.convertMap;
/**
* BPM 流程分类 Service 接口
*
* @author 芋道源码
*/
public interface IBpmCategoryService extends IService<BpmCategory> {

View File

@@ -24,7 +24,7 @@ import static com.njcn.bpm.utils.CollectionUtils.convertMap;
*
* @author yunlong.li
* @author ZJQ
* @author 芋道源码
* @author hongawen
*/
public interface IBpmProcessDefinitionService extends IService<BpmProcessDefinitionInfo> {

View File

@@ -0,0 +1,30 @@
package com.njcn.bpm.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.bpm.pojo.param.BpmSignParam;
import com.njcn.bpm.pojo.po.BpmSign;
import com.njcn.bpm.pojo.vo.BpmSignVO;
import java.util.List;
/**
* <p>
* BPM 流程标识 服务类
* </p>
*
* @author hongawen
* @since 2024-05-13
*/
public interface IBpmSignService extends IService<BpmSign> {
String createSign(BpmSignParam bpmSignParam);
void updateSign(BpmSignParam.BpmSignUpdateParam updateParam);
void deleteSign(List<String> ids);
Page<BpmSignVO> getSignPage(BpmSignParam.BpmSignQueryParam bpmSignQueryParam);
List<BpmSign> getSignSimpleList();
}

View File

@@ -29,7 +29,6 @@ import java.util.List;
/**
* BPM 流程分类 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
@@ -43,6 +42,7 @@ public class BpmCategoryServiceImpl extends ServiceImpl<BpmCategoryMapper, BpmCa
checkCategoryCode(bpmCategoryParam, false);
// 插入
BpmCategory category = BeanUtils.toBean(bpmCategoryParam, BpmCategory.class);
category.setState(DataStateEnum.ENABLE.getCode());
this.baseMapper.insert(category);
return category.getId();
}
@@ -74,7 +74,7 @@ public class BpmCategoryServiceImpl extends ServiceImpl<BpmCategoryMapper, BpmCa
}
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getCode())) {
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getCode());
categoryVOQueryWrapper.like("bpm_category.code", bpmCategoryQueryParam.getCode());
}
categoryVOQueryWrapper.eq("bpm_category.state", DataStateEnum.ENABLE.getCode());
categoryVOQueryWrapper.orderByDesc("bpm_category.update_time");
@@ -135,7 +135,7 @@ public class BpmCategoryServiceImpl extends ServiceImpl<BpmCategoryMapper, BpmCa
int nameCountByAccount = this.count(categoryLambdaQueryWrapper);
//大于等于1个则表示重复
if (nameCountByAccount >= 1) {
throw new BusinessException(BpmResponseEnum.REPEAT_CATEGORY_NAME_FORM);
throw new BusinessException(BpmResponseEnum.REPEAT_CATEGORY_CODE_FORM);
}
}

View File

@@ -40,7 +40,7 @@ import java.util.Objects;
* 主要进行 Flowable {@link Model} 的维护
*
* @author yunlongn
* @author 芋道源码
* @author hongawen
* @author jason
*/
@Service

View File

@@ -41,7 +41,7 @@ import static java.util.Collections.emptyList;
*
* @author yunlongn
* @author ZJQ
* @author 芋道源码
* @author hongawen
*/
@Service
@Validated

View File

@@ -0,0 +1,128 @@
package com.njcn.bpm.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.bpm.enums.BpmResponseEnum;
import com.njcn.bpm.mapper.BpmSignMapper;
import com.njcn.bpm.pojo.param.BpmCategoryParam;
import com.njcn.bpm.pojo.param.BpmSignParam;
import com.njcn.bpm.pojo.po.BpmCategory;
import com.njcn.bpm.pojo.po.BpmSign;
import com.njcn.bpm.pojo.vo.BpmCategoryVO;
import com.njcn.bpm.pojo.vo.BpmSignVO;
import com.njcn.bpm.service.IBpmSignService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.bpm.utils.BeanUtils;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.web.factory.PageFactory;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* BPM 流程标识 服务实现类
* </p>
*
* @author hongawen
* @since 2024-05-13
*/
@Service
public class BpmSignServiceImpl extends ServiceImpl<BpmSignMapper, BpmSign> implements IBpmSignService {
@Override
public String createSign(BpmSignParam bpmSignParam) {
//判断名称和key是否重复
checkSignName(bpmSignParam, false);
checkSignKey(bpmSignParam, false);
BpmSign sign = BeanUtils.toBean(bpmSignParam, BpmSign.class);
sign.setState(DataStateEnum.ENABLE.getCode());
this.baseMapper.insert(sign);
return sign.getId();
}
private void checkSignName(BpmSignParam bpmSignParam, boolean isExcludeSelf) {
LambdaQueryWrapper<BpmSign> signLambdaQueryWrapper = new LambdaQueryWrapper<>();
//判断流程表单的名称
signLambdaQueryWrapper
.eq(BpmSign::getName, bpmSignParam.getName())
.eq(BpmSign::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (bpmSignParam instanceof BpmSignParam.BpmSignUpdateParam) {
signLambdaQueryWrapper.ne(BpmSign::getId, ((BpmSignParam.BpmSignUpdateParam) bpmSignParam).getId());
}
}
int nameCountByAccount = this.count(signLambdaQueryWrapper);
//大于等于1个则表示重复
if (nameCountByAccount >= 1) {
throw new BusinessException(BpmResponseEnum.REPEAT_SIGN_NAME_FORM);
}
}
private void checkSignKey(BpmSignParam bpmSignParam, boolean isExcludeSelf) {
LambdaQueryWrapper<BpmSign> signLambdaQueryWrapper = new LambdaQueryWrapper<>();
//判断流程表单的名称
signLambdaQueryWrapper
.eq(BpmSign::getSignKey, bpmSignParam.getSignKey())
.eq(BpmSign::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (bpmSignParam instanceof BpmSignParam.BpmSignUpdateParam) {
signLambdaQueryWrapper.ne(BpmSign::getId, ((BpmSignParam.BpmSignUpdateParam) bpmSignParam).getId());
}
}
int nameCountByAccount = this.count(signLambdaQueryWrapper);
//大于等于1个则表示重复
if (nameCountByAccount >= 1) {
throw new BusinessException(BpmResponseEnum.REPEAT_SIGN_KEY_FORM);
}
}
@Override
public void updateSign(BpmSignParam.BpmSignUpdateParam updateParam) {
//判断名称和key是否重复
checkSignName(updateParam, true);
checkSignKey(updateParam, true);
// 更新
BpmSign bpmSign = BeanUtils.toBean(updateParam, BpmSign.class);
this.baseMapper.updateById(bpmSign);
}
@Override
public void deleteSign(List<String> ids) {
this.lambdaUpdate().set(BpmSign::getState, DataStateEnum.DELETED.getCode())
.in(BpmSign::getId, ids)
.update();
}
@Override
public Page<BpmSignVO> getSignPage(BpmSignParam.BpmSignQueryParam bpmSignQueryParam) {
QueryWrapper<BpmSignVO> bpmSignVOQueryWrapper = new QueryWrapper<>();
if (StrUtil.isNotBlank(bpmSignQueryParam.getName())) {
bpmSignVOQueryWrapper.like("bpm_sign.name", bpmSignQueryParam.getName());
}
if (StrUtil.isNotBlank(bpmSignQueryParam.getKey())) {
bpmSignVOQueryWrapper.like("bpm_sign.signKey", bpmSignQueryParam.getKey());
}
bpmSignVOQueryWrapper.eq("bpm_sign.state", DataStateEnum.ENABLE.getCode());
bpmSignVOQueryWrapper.orderByDesc("bpm_sign.update_time");
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(bpmSignQueryParam), PageFactory.getPageSize(bpmSignQueryParam)), bpmSignVOQueryWrapper);
}
@Override
public List<BpmSign> getSignSimpleList() {
LambdaQueryWrapper<BpmSign> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(BpmSign::getId,BpmSign::getName,BpmSign::getViewPath,BpmSign::getSignKey)
.eq(BpmSign::getState,DataStateEnum.ENABLE.getCode());
return this.baseMapper.selectList(lambdaQueryWrapper);
}
}

View File

@@ -8,7 +8,7 @@ import java.util.List;
/**
* BPM 活动实例 Service 接口
*
* @author 芋道源码
* @author hongawen
*/
public interface IBpmActivityService {

View File

@@ -19,7 +19,7 @@ import static com.njcn.bpm.utils.CollectionUtils.convertMap;
/**
* 流程实例 Service 接口
*
* @author 芋道源码
* @author hongawen
*/
public interface IBpmProcessInstanceService {

View File

@@ -14,7 +14,7 @@ import java.util.Map;
* 流程任务实例 Service 接口
*
* @author jason
* @author 芋道源码
* @author hongawen
*/
public interface IBpmTaskService {

View File

@@ -16,7 +16,7 @@ import java.util.List;
/**
* BPM 活动实例 Service 实现类
*
* @author 芋道源码
* @author hongawen
*/
@Service
@Slf4j

View File

@@ -56,7 +56,7 @@ import java.util.*;
* <p>
* 简单来说,前者 = 历史 + 运行中的流程实例,后者仅是运行中的流程实例
*
* @author 芋道源码
* @author hongawen
*/
@Service
@Validated

View File

@@ -60,7 +60,7 @@ import static com.njcn.bpm.utils.CollectionUtils.convertListByFlatMap;
/**
* 流程任务实例 Service 实现类
*
* @author 芋道源码
* @author hongawen
* @author jason
*/
@Slf4j

View File

@@ -22,7 +22,7 @@ import java.util.*;
/**
* @author 芋道源码
* @author hongawen
*/
@Slf4j
public class BpmTaskCandidateInvoker {

View File

@@ -18,7 +18,7 @@ import java.util.*;
/**
*
* @author 芋道源码
* @author hongawen
*/
@Component
public class BpmTaskCandidateStartUserSelectStrategy implements IBpmTaskCandidateStrategy {

View File

@@ -11,7 +11,7 @@ import java.util.Set;
*
* 例如说:分配审批人
*
* @author 芋道源码
* @author hongawen
*/
public interface IBpmTaskCandidateStrategy {

View File

@@ -12,7 +12,7 @@ import java.util.List;
/**
* BPM 活动 Convert
*
* @author 芋道源码
* @author hongawen
*/
@Mapper(uses = DateUtils.class)
public interface BpmActivityConvert {

View File

@@ -25,7 +25,7 @@ import java.util.Map;
/**
* 流程实例 Convert
*
* @author 芋道源码
* @author hongawen
*/
@Mapper
public interface BpmProcessInstanceConvert {

View File

@@ -27,7 +27,7 @@ import static com.njcn.bpm.utils.MapUtils.findAndThen;
/**
* Bpm 任务 Convert
*
* @author 芋道源码
* @author hongawen
*/
@Mapper
public interface BpmTaskConvert {

View File

@@ -19,7 +19,7 @@ import java.util.Map;
/**
* Flowable 相关的工具方法
*
* @author 芋道源码
* @author hongawen
*/
public class FlowableUtils {

View File

@@ -21,7 +21,7 @@ import java.util.List;
/**
* JSON 工具类
*
* @author 芋道源码
* @author hongawen
*/
@Slf4j
public class JsonUtils {

View File

@@ -13,7 +13,7 @@ import java.util.stream.Collectors;
/**
* 字符串工具类
*
* @author 芋道源码
* @author hongawen
*/
public class StrUtils {