BPM:code review 快搭的实现
This commit is contained in:
parent
b504d9841e
commit
1b708ccd55
@ -76,5 +76,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在");
|
ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在");
|
||||||
|
|
||||||
// ========== BPM 仿钉钉流程设计器 1-009-015-000 ==========
|
// ========== BPM 仿钉钉流程设计器 1-009-015-000 ==========
|
||||||
|
// TODO @芋艿:这个错误码,需要关注下
|
||||||
ErrorCode CONVERT_TO_SIMPLE_MODEL_NOT_SUPPORT = new ErrorCode(1_009_015_000, "该流程模型不支持仿钉钉设计流程");
|
ErrorCode CONVERT_TO_SIMPLE_MODEL_NOT_SUPPORT = new ErrorCode(1_009_015_000, "该流程模型不支持仿钉钉设计流程");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import java.util.Objects;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum BpmSimpleModelNodeType implements IntArrayValuable {
|
public enum BpmSimpleModelNodeType implements IntArrayValuable {
|
||||||
|
|
||||||
|
// TODO @jaosn:-1、0、1、4、-2 是前端已经定义好的么?感觉未来可以考虑搞成和 BPMN 尽量一致的单词哈;类似 usertask 用户审批;
|
||||||
START_NODE(-1, "开始节点"),
|
START_NODE(-1, "开始节点"),
|
||||||
START_USER_NODE(0, "发起人结点"),
|
START_USER_NODE(0, "发起人结点"),
|
||||||
APPROVE_USER_NODE (1, "审批人节点"),
|
APPROVE_USER_NODE (1, "审批人节点"),
|
||||||
@ -41,4 +42,5 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
|
|||||||
public int[] array() {
|
public int[] array() {
|
||||||
return ARRAYS;
|
return ARRAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
// TODO @芋艿:后续考虑下,怎么放这个 Controller
|
||||||
@Tag(name = "管理后台 - BPM 仿钉钉流程设计器")
|
@Tag(name = "管理后台 - BPM 仿钉钉流程设计器")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/bpm/simple")
|
@RequestMapping("/bpm/simple")
|
||||||
|
@ -16,7 +16,7 @@ public class BpmSimpleModelNodeVO {
|
|||||||
|
|
||||||
@Schema(description = "模型节点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent_1")
|
@Schema(description = "模型节点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent_1")
|
||||||
@NotEmpty(message = "模型节点编号不能为空")
|
@NotEmpty(message = "模型节点编号不能为空")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "模型节点类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "模型节点类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "模型节点类型不能为空")
|
@NotNull(message = "模型节点类型不能为空")
|
||||||
@ -33,5 +33,6 @@ public class BpmSimpleModelNodeVO {
|
|||||||
private List<BpmSimpleModelNodeVO> conditionNodes;
|
private List<BpmSimpleModelNodeVO> conditionNodes;
|
||||||
|
|
||||||
@Schema(description = "节点的属性")
|
@Schema(description = "节点的属性")
|
||||||
private Map<String, Object> attributes;
|
private Map<String, Object> attributes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotEmpty;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
// TODO @芋艿:或许挪到 model 里的 simple 包
|
||||||
@Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
|
@Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class BpmSimpleModelSaveReqVO {
|
public class BpmSimpleModelSaveReqVO {
|
||||||
@ -18,4 +19,5 @@ public class BpmSimpleModelSaveReqVO {
|
|||||||
@NotNull(message = "仿钉钉流程设计模型对象不能为空")
|
@NotNull(message = "仿钉钉流程设计模型对象不能为空")
|
||||||
@Valid
|
@Valid
|
||||||
private BpmSimpleModelNodeVO simpleModelBody;
|
private BpmSimpleModelNodeVO simpleModelBody;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public interface BpmnModelConstants {
|
|||||||
*/
|
*/
|
||||||
String USER_TASK_CANDIDATE_PARAM = "candidateParam";
|
String USER_TASK_CANDIDATE_PARAM = "candidateParam";
|
||||||
|
|
||||||
|
// TODO @芋艿:这里后面得关注下;
|
||||||
/**
|
/**
|
||||||
* BPMN End Event 节点 Id, 用于后端生成 End Event 节点
|
* BPMN End Event 节点 Id, 用于后端生成 End Event 节点
|
||||||
*/
|
*/
|
||||||
@ -36,6 +37,6 @@ public interface BpmnModelConstants {
|
|||||||
/**
|
/**
|
||||||
* 支持转仿钉钉设计模型的 Bpmn 节点
|
* 支持转仿钉钉设计模型的 Bpmn 节点
|
||||||
*/
|
*/
|
||||||
Set<Class<? extends FlowNode>> SUPPORT_CONVERT_SIMPLE_FlOW_NODES = ImmutableSet.of(UserTask.class, EndEvent.class);
|
Set<Class<? extends FlowNode>> SUPPORT_CONVERT_SIMPLE_FlOW_NODES = ImmutableSet.of(UserTask.class, EndEvent.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -335,6 +335,8 @@ public class BpmnModelUtils {
|
|||||||
return userTaskList;
|
return userTaskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========== TODO 芋艿:这里得捉摸下; ==========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仿钉钉流程设计模型数据结构(json) 转换成 Bpmn Model (待完善)
|
* 仿钉钉流程设计模型数据结构(json) 转换成 Bpmn Model (待完善)
|
||||||
*
|
*
|
||||||
@ -359,7 +361,6 @@ public class BpmnModelUtils {
|
|||||||
addBpmnSequenceFlow(mainProcess, simpleModelNode);
|
addBpmnSequenceFlow(mainProcess, simpleModelNode);
|
||||||
// 自动布局
|
// 自动布局
|
||||||
new BpmnAutoLayout(bpmnModel).execute();
|
new BpmnAutoLayout(bpmnModel).execute();
|
||||||
|
|
||||||
return bpmnModel;
|
return bpmnModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +397,6 @@ public class BpmnModelUtils {
|
|||||||
sequenceFlow.setConditionExpression(conditionExpression);
|
sequenceFlow.setConditionExpression(conditionExpression);
|
||||||
}
|
}
|
||||||
mainProcess.addFlowElement(sequenceFlow);
|
mainProcess.addFlowElement(sequenceFlow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addBpmnFlowNode(Process mainProcess, BpmSimpleModelNodeVO simpleModelNode) {
|
private static void addBpmnFlowNode(Process mainProcess, BpmSimpleModelNodeVO simpleModelNode) {
|
||||||
|
@ -53,6 +53,7 @@ public interface BpmModelService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @param bpmnXml BPMN XML
|
* @param bpmnXml BPMN XML
|
||||||
*/
|
*/
|
||||||
|
// TODO @芋艿:可能要关注下;
|
||||||
void saveModelBpmnXml(String id, String bpmnXml);
|
void saveModelBpmnXml(String id, String bpmnXml);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,14 +13,17 @@ public interface BpmSimpleModelService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存仿钉钉流程设计模型
|
* 保存仿钉钉流程设计模型
|
||||||
|
*
|
||||||
* @param reqVO 请求信息
|
* @param reqVO 请求信息
|
||||||
*/
|
*/
|
||||||
Boolean saveSimpleModel(@Valid BpmSimpleModelSaveReqVO reqVO);
|
Boolean saveSimpleModel(@Valid BpmSimpleModelSaveReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取仿钉钉流程设计模型结构
|
* 获取仿钉钉流程设计模型结构
|
||||||
|
*
|
||||||
* @param modelId 流程模型编号
|
* @param modelId 流程模型编号
|
||||||
* @return 仿钉钉流程设计模型结构
|
* @return 仿钉钉流程设计模型结构
|
||||||
*/
|
*/
|
||||||
BpmSimpleModelNodeVO getSimpleModel(String modelId);
|
BpmSimpleModelNodeVO getSimpleModel(String modelId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnMode
|
|||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
|
public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BpmModelService bpmModelService;
|
private BpmModelService bpmModelService;
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
|
|||||||
// bpmModelService.saveModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel));
|
// bpmModelService.saveModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel));
|
||||||
// return Boolean.TRUE;
|
// return Boolean.TRUE;
|
||||||
// } else {
|
// } else {
|
||||||
// // TODO BPMN XML 已经存在。如何修改 ??
|
// // TODO BPMN XML 已经存在。如何修改 ?? TODO add by 芋艿:感觉一个流程,只能二选一,要么 bpmn、要么 simple
|
||||||
// return Boolean.FALSE;
|
// return Boolean.FALSE;
|
||||||
// }
|
// }
|
||||||
// 暂时直接修改
|
// 暂时直接修改
|
||||||
@ -66,9 +67,9 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
|
|||||||
byte[] bpmnBytes = bpmModelService.getModelBpmnXML(modelId);
|
byte[] bpmnBytes = bpmModelService.getModelBpmnXML(modelId);
|
||||||
BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes);
|
BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes);
|
||||||
return convertBpmnModelToSimpleModel(bpmnModel);
|
return convertBpmnModelToSimpleModel(bpmnModel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @jason:一般要支持这个么?感觉 bpmn 转 json 支持会不会太复杂。可以优先级低一点,做下调研~
|
||||||
/**
|
/**
|
||||||
* Bpmn Model 转换成 仿钉钉流程设计模型数据结构(json) 待完善
|
* Bpmn Model 转换成 仿钉钉流程设计模型数据结构(json) 待完善
|
||||||
*
|
*
|
||||||
@ -89,7 +90,6 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
|
|||||||
rootNode.setName(startEvent.getName());
|
rootNode.setName(startEvent.getName());
|
||||||
recursiveBuildSimpleModelNode(startEvent, rootNode);
|
recursiveBuildSimpleModelNode(startEvent, rootNode);
|
||||||
return rootNode;
|
return rootNode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recursiveBuildSimpleModelNode(FlowNode currentFlowNode, BpmSimpleModelNodeVO currentSimpleModeNode) {
|
private void recursiveBuildSimpleModelNode(FlowNode currentFlowNode, BpmSimpleModelNodeVO currentSimpleModeNode) {
|
||||||
@ -113,7 +113,6 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
|
|||||||
// TODO 其它节点类型待实现
|
// TODO 其它节点类型待实现
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BpmSimpleModelNodeVO convertUserTaskToSimpleModelNode(UserTask userTask) {
|
private BpmSimpleModelNodeVO convertUserTaskToSimpleModelNode(UserTask userTask) {
|
||||||
BpmSimpleModelNodeVO simpleModelNodeVO = new BpmSimpleModelNodeVO();
|
BpmSimpleModelNodeVO simpleModelNodeVO = new BpmSimpleModelNodeVO();
|
||||||
simpleModelNodeVO.setType(BpmSimpleModelNodeType.APPROVE_USER_NODE.getType());
|
simpleModelNodeVO.setType(BpmSimpleModelNodeType.APPROVE_USER_NODE.getType());
|
||||||
|
Loading…
Reference in New Issue
Block a user