流程管理新增

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

@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
* @author hongawen
*/
@FeignClient(value = ServerInfo.BPM,path = "/bpm/processDefinition",fallbackFactory = BpmProcessFeignClientFallbackFactory.class)
public interface BpmProcessFeignClient {

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
/**
* 流程实例/任务的删除原因枚举
*
* @author 芋道源码
* @author hongawen
*/
@Getter
@AllArgsConstructor

View File

@@ -8,7 +8,7 @@ import java.util.Arrays;
/**
* BPM 模型的表单类型的枚举
*
* @author 芋道源码
* @author hongawen
*/
@Getter
@AllArgsConstructor

View File

@@ -8,7 +8,7 @@ import java.util.Arrays;
/**
* 流程实例 ProcessInstance 的状态
*
* @author 芋道源码
* @author hongawen
*/
@Getter
@AllArgsConstructor

View File

@@ -44,19 +44,25 @@ public enum BpmResponseEnum {
REPEAT_CATEGORY_NAME_FORM("A00568", "流程类型名称重复"),
PROCESS_INSTANCE_NOT_EXISTS ("A00568", "流程实例不存在"),
REPEAT_CATEGORY_CODE_FORM("A00568", "流程类型编码重复"),
TASK_IS_PENDING ("A00568", "当前任务处于挂起状态,不能操作"),
REPEAT_SIGN_NAME_FORM("A00568", "流程标识名称重复"),
TASK_TARGET_NODE_NOT_EXISTS ("A00568", " 目标节点不存在"),
REPEAT_SIGN_KEY_FORM("A00568", "流程标识key重复"),
TASK_RETURN_FAIL_SOURCE_TARGET_ERROR ("A00568", "回退任务失败,目标节点是在并行网关上或非同一路线上,不可跳转"),
PROCESS_INSTANCE_NOT_EXISTS("A00568", "流程实例不存在"),
TASK_IS_PENDING("A00568", "当前任务处于挂起状态,不能操作"),
TASK_TARGET_NODE_NOT_EXISTS("A00568", " 目标节点不存在"),
TASK_RETURN_FAIL_SOURCE_TARGET_ERROR("A00568", "回退任务失败,目标节点是在并行网关上或非同一路线上,不可跳转"),
PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS("A00568", "流程取消失败,流程不处于运行中"),
TASK_DELEGATE_FAIL_USER_REPEAT("A00568", "任务委派失败,委派人和当前审批人为同一人"),
TASK_DELEGATE_FAIL_USER_REPEAT("A00568", "任务委派失败,委派人和当前审批人为同一人"),
TASK_DELEGATE_FAIL_USER_NOT_EXISTS("A00568", "任务委派失败,被委派人不存在"),
TASK_DELEGATE_FAIL_USER_NOT_EXISTS("A00568", "任务委派失败,被委派人不存在"),
TASK_TRANSFER_FAIL_USER_REPEAT("A00568", "任务转办失败,转办人和当前审批人为同一人"),

View File

@@ -9,7 +9,7 @@ import lombok.Getter;
*
* 例如说:分配给指定人审批
*
* @author 芋道源码
* @author hongawen
*/
@Getter
@AllArgsConstructor

View File

@@ -3,7 +3,7 @@ package com.njcn.bpm.enums;
/**
* BPMN XML 常量信息
*
* @author 芋道源码
* @author hongawen
*/
public interface BpmnModelConstants {

View File

@@ -9,7 +9,7 @@ package com.njcn.bpm.enums;
* 虽然说HTTP 响应状态码作为业务使用表达能力偏弱,但是使用在系统层面还是非常不错的
* 比较特殊的是,因为之前一直使用 0 作为成功,就不使用 200 啦。
*
* @author 芋道源码
* @author hongawen
*/
public interface GlobalErrorCodeConstants {

View File

@@ -3,7 +3,7 @@ package com.njcn.bpm.enums;
/**
* 可生成 Int 数组的接口
*
* @author 芋道源码
* @author hongawen
*/
public interface IntArrayValuable {

View File

@@ -5,7 +5,7 @@ package com.njcn.bpm.enums;
*
* 考虑到每个 starter 都需要用到该工具类,所以放到 common 模块下的 enums 包下
*
* @author 芋道源码
* @author hongawen
*/
public interface WebFilterOrderEnum {

View File

@@ -7,7 +7,7 @@ import lombok.Data;
* 主要用于 { Model#setMetaInfo(String)} 的存储
*
*
* @author 芋道源码
* @author hongawen
*/
@Data
public class BpmModelMetaInfoRespDTO {

View File

@@ -14,7 +14,7 @@ import java.io.Serializable;
/**
* BPM 流程分类
*
* @author 芋道源码
* @author hongawen
*/
@Data
public class BpmCategoryParam implements Serializable {

View File

@@ -0,0 +1,92 @@
package com.njcn.bpm.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.db.bo.BaseEntity;
import com.njcn.web.constant.ValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
* <p>
* BPM 流程标识
* </p>
*
* @author hongawen
* @since 2024-05-13
*/
@Data
public class BpmSignParam extends BaseEntity implements Serializable {
/**
* 流程名称
*/
@ApiModelProperty("流程名称")
@NotBlank(message = "流程名称不能为空")
private String name;
/**
* 流程标识key
*/
@ApiModelProperty("流程标识key")
@NotBlank(message = "流程标识key不能为空")
private String signKey;
/**
* 流程查看表单路径
*/
@ApiModelProperty("流程查看表单路径")
@NotBlank(message = "流程查看表单路径不能为空")
private String viewPath;
/**
* 流程创建表单路径
*/
@ApiModelProperty("流程创建表单路径")
private String createPath;
/**
* 更新操作实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class BpmSignUpdateParam extends BpmSignParam {
/**
* 表Id
*/
@ApiModelProperty("id")
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
private String id;
}
/**
* 分页查询实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class BpmSignQueryParam extends BaseParam {
@ApiModelProperty("标识名称")
private String name;
@ApiModelProperty("标识key")
private String key;
}
}

View File

@@ -14,7 +14,7 @@ import java.io.Serializable;
/**
* BPM 流程分类 DO
*
* @author 芋道源码
* @author hongawen
*/
@TableName("bpm_category")
@Data

View File

@@ -17,7 +17,7 @@ import java.util.List;
* BPM 工作流的表单定义
* 用于工作流的申请表单,需要动态配置的场景
*
* @author 芋道源码
* @author hongawen
*/
@TableName(value = "bpm_form", autoResultMap = true)
@Data

View File

@@ -0,0 +1,57 @@
package com.njcn.bpm.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* BPM 流程标识
* </p>
*
* @author hongawen
* @since 2024-05-13
*/
@Getter
@Setter
@TableName("bpm_sign")
public class BpmSign extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 流程标识索引
*/
private String id;
/**
* 流程名称
*/
private String name;
/**
* 流程标识key
*/
private String signKey;
/**
* 流程查看表单路径
*/
private String viewPath;
/**
* 流程创建表单路径
*/
private String createPath;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -1,13 +1,15 @@
package com.njcn.bpm.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* BPM 流程分类 DO
*
* @author 芋道源码
* @author hongawen
*/
@Data
public class BpmCategoryVO implements Serializable {
@@ -37,5 +39,10 @@ public class BpmCategoryVO implements Serializable {
*/
private Integer sort;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,61 @@
package com.njcn.bpm.pojo.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* BPM 流程标识
* </p>
*
* @author hongawen
* @since 2024-05-13
*/
@Data
public class BpmSignVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 流程标识索引
*/
private String id;
/**
* 流程名称
*/
private String name;
/**
* 流程标识key
*/
private String signKey;
/**
* 流程查看表单路径
*/
private String viewPath;
/**
* 流程创建表单路径
*/
private String createPath;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
}

View File

@@ -13,7 +13,7 @@ import java.util.function.Consumer;
* 1. 默认使用 {@link BeanUtil} 作为实现类,虽然不同 bean 工具的性能有差别,但是对绝大多数同学的项目,不用在意这点性能
* 2. 针对复杂的对象转换,可以搜参考 AuthConvert 实现,通过 mapstruct + default 配合实现
*
* @author 芋道源码
* @author hongawen
*/
public class BeanUtils {

View File

@@ -9,7 +9,7 @@ import java.util.Date;
/**
* 时间工具类
*
* @author 芋道源码
* @author hongawen
*/
public class DateUtils {

View File

@@ -9,7 +9,7 @@ import java.io.Serializable;
/**
* Key Value 的键值对
*
* @author 芋道源码
* @author hongawen
*/
@Data
@NoArgsConstructor

View File

@@ -15,7 +15,7 @@ import java.util.function.Consumer;
/**
* Map 工具类
*
* @author 芋道源码
* @author hongawen
*/
public class MapUtils {

View File

@@ -8,7 +8,7 @@ import java.math.BigDecimal;
/**
* 数字的工具类,补全 {@link NumberUtil} 的功能
*
* @author 芋道源码
* @author hongawen
*/
public class NumberUtils {

View File

@@ -10,7 +10,7 @@ import java.util.function.Consumer;
/**
* Object 工具类
*
* @author 芋道源码
* @author hongawen
*/
public class ObjectUtils {

View File

@@ -14,7 +14,7 @@ import java.util.regex.Pattern;
/**
* 校验工具类
*
* @author 芋道源码
* @author hongawen
*/
public class ValidationUtils {

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 {

View File

@@ -21,7 +21,7 @@ public class GenerateCode {
private static final String TARGET_DIR = "D://code";
private static final String DB_URL = "jdbc:mysql://192.168.1.24:13306/pqsinfo_jb";
private static final String DB_URL = "jdbc:mysql://192.168.1.24:13306/bpm";
// private static final String DB_URL = "jdbc:oracle:thin:@192.168.1.170:1521:pqsbase";
private static final String USERNAME = "root";
@@ -30,9 +30,9 @@ public class GenerateCode {
public static void main(String[] args) {
List<Module> modules = Stream.of(
new Module("hongawen", "com.njcn.supervision", "device", Stream.of(
"supervision_quit_running_device"
).collect(Collectors.toList()), "supervision_")
new Module("hongawen", "com.njcn.bpm", "", Stream.of(
"bpm_sign"
).collect(Collectors.toList()), "")
).collect(Collectors.toList());
generateJavaFile(modules);
}

View File

@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
* @author hongawen
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/userReport", fallbackFactory = UserReportFeignClientFallbackFactory.class)
public interface UserReportFeignClient {