Commit c84a9dd67e766ffd60b3685ed4c2a4af810897c1
1 parent
1294506a
优化流程 Model 的部署代码
Showing
21 changed files
with
266 additions
and
151 deletions
sql/ruoyi-vue-pro.sql
| @@ -2391,4 +2391,18 @@ INSERT INTO `tool_test_demo` VALUES (106, '老五1', 0, 1, 1, '牛逼哈2', '', | @@ -2391,4 +2391,18 @@ INSERT INTO `tool_test_demo` VALUES (106, '老五1', 0, 1, 1, '牛逼哈2', '', | ||
| 2391 | INSERT INTO `tool_test_demo` VALUES (107, '哈哈哈哈', 1, 0, 1, 'biubiubui', '', '2021-02-06 14:00:54', '', '2021-02-06 14:00:54', b'0'); | 2391 | INSERT INTO `tool_test_demo` VALUES (107, '哈哈哈哈', 1, 0, 1, 'biubiubui', '', '2021-02-06 14:00:54', '', '2021-02-06 14:00:54', b'0'); |
| 2392 | COMMIT; | 2392 | COMMIT; |
| 2393 | 2393 | ||
| 2394 | +CREATE TABLE `bpm_process_definition` ( | ||
| 2395 | + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | ||
| 2396 | + `process_definition_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程定义的编号', | ||
| 2397 | + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述', | ||
| 2398 | + `form_id` bigint DEFAULT NULL COMMENT '表单编号', | ||
| 2399 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者', | ||
| 2400 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 2401 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者', | ||
| 2402 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 2403 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | ||
| 2404 | + PRIMARY KEY (`id`) USING BTREE | ||
| 2405 | +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Bpm 流程定义的拓展表\n'; | ||
| 2406 | + | ||
| 2394 | SET FOREIGN_KEY_CHECKS = 1; | 2407 | SET FOREIGN_KEY_CHECKS = 1; |
| 2408 | + |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/BpmModelController.java
| @@ -25,10 +25,10 @@ public class BpmModelController { | @@ -25,10 +25,10 @@ public class BpmModelController { | ||
| 25 | 25 | ||
| 26 | // TODO @芋艿:权限 | 26 | // TODO @芋艿:权限 |
| 27 | 27 | ||
| 28 | - @GetMapping ("/page") | 28 | + @GetMapping("/page") |
| 29 | @ApiOperation(value = "获得模型分页") | 29 | @ApiOperation(value = "获得模型分页") |
| 30 | public CommonResult<PageResult<BpmModelPageItemRespVO>> getModelPage(ModelPageReqVO pageVO) { | 30 | public CommonResult<PageResult<BpmModelPageItemRespVO>> getModelPage(ModelPageReqVO pageVO) { |
| 31 | - return success(bpmModelService.getModelPage(pageVO)); | 31 | + return success(bpmModelService.getModelPage(pageVO)); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | @GetMapping("/get") | 34 | @GetMapping("/get") |
| @@ -43,7 +43,7 @@ public class BpmModelController { | @@ -43,7 +43,7 @@ public class BpmModelController { | ||
| 43 | @PostMapping("/create") | 43 | @PostMapping("/create") |
| 44 | @ApiOperation(value = "新建模型") | 44 | @ApiOperation(value = "新建模型") |
| 45 | public CommonResult<String> createModel(@RequestBody BpmModelCreateReqVO createRetVO) { | 45 | public CommonResult<String> createModel(@RequestBody BpmModelCreateReqVO createRetVO) { |
| 46 | - return success(bpmModelService.createModel(createRetVO)); | 46 | + return success(bpmModelService.createModel(createRetVO)); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | @PutMapping("/update") | 49 | @PutMapping("/update") |
| @@ -56,15 +56,17 @@ public class BpmModelController { | @@ -56,15 +56,17 @@ public class BpmModelController { | ||
| 56 | @DeleteMapping("/delete") | 56 | @DeleteMapping("/delete") |
| 57 | @ApiOperation("删除模型") | 57 | @ApiOperation("删除模型") |
| 58 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class) | 58 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class) |
| 59 | - public CommonResult<Boolean> deleteModel(@RequestParam("id") String id) { | 59 | + public CommonResult<Boolean> deleteModel(@RequestParam("id") String id) { |
| 60 | bpmModelService.deleteModel(id); | 60 | bpmModelService.deleteModel(id); |
| 61 | return success(true); | 61 | return success(true); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | @PostMapping("/deploy") | 64 | @PostMapping("/deploy") |
| 65 | @ApiOperation(value = "部署模型") | 65 | @ApiOperation(value = "部署模型") |
| 66 | - public CommonResult<String> deploy(@RequestParam String modelId) { | ||
| 67 | - return bpmModelService.deploy(modelId); | 66 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class) |
| 67 | + public CommonResult<Boolean> deployModel(@RequestParam("id") String id) { | ||
| 68 | + bpmModelService.deployModel(id); | ||
| 69 | + return success(true); | ||
| 68 | } | 70 | } |
| 69 | 71 | ||
| 70 | } | 72 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelBaseVO.java
| @@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty; | @@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty; | ||
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | import javax.validation.constraints.NotEmpty; | 6 | import javax.validation.constraints.NotEmpty; |
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | 7 | ||
| 9 | /** | 8 | /** |
| 10 | * 流程模型 Base VO,提供给添加、修改、详细的子 VO 使用 | 9 | * 流程模型 Base VO,提供给添加、修改、详细的子 VO 使用 |
| @@ -22,7 +21,6 @@ public class BpmModelBaseVO { | @@ -22,7 +21,6 @@ public class BpmModelBaseVO { | ||
| 22 | private String name; | 21 | private String name; |
| 23 | 22 | ||
| 24 | @ApiModelProperty(value = "流程描述", example = "我是描述") | 23 | @ApiModelProperty(value = "流程描述", example = "我是描述") |
| 25 | - @NotEmpty(message = "流程描述不能为空") | ||
| 26 | private String description; | 24 | private String description; |
| 27 | 25 | ||
| 28 | @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1") | 26 | @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1") |
| @@ -30,7 +28,6 @@ public class BpmModelBaseVO { | @@ -30,7 +28,6 @@ public class BpmModelBaseVO { | ||
| 30 | private String category; | 28 | private String category; |
| 31 | 29 | ||
| 32 | @ApiModelProperty(value = "表单编号", example = "1024") | 30 | @ApiModelProperty(value = "表单编号", example = "1024") |
| 33 | - @NotNull(message = "表单编号不能为空") | ||
| 34 | private Long formId; | 31 | private Long formId; |
| 35 | 32 | ||
| 36 | } | 33 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/TaskController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmTaskService; | 4 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | 7 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java
| @@ -5,6 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelPage | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelPage | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelUpdateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelUpdateReqVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; |
| 8 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; | 9 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; |
| 9 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 10 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 11 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| @@ -58,6 +59,19 @@ public interface ModelConvert { | @@ -58,6 +59,19 @@ public interface ModelConvert { | ||
| 58 | 59 | ||
| 59 | BpmModelRespVO convert(Model model); | 60 | BpmModelRespVO convert(Model model); |
| 60 | 61 | ||
| 62 | + default BpmDefinitionCreateReqDTO convert2(Model model) { | ||
| 63 | + BpmDefinitionCreateReqDTO createReqDTO = new BpmDefinitionCreateReqDTO(); | ||
| 64 | + createReqDTO.setName(model.getName()); | ||
| 65 | + createReqDTO.setKey(model.getKey()); | ||
| 66 | + createReqDTO.setCategory(model.getCategory()); | ||
| 67 | + BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | ||
| 68 | + if (metaInfo != null) { | ||
| 69 | + createReqDTO.setDescription(metaInfo.getDescription()); | ||
| 70 | + createReqDTO.setFormId(metaInfo.getFormId()); | ||
| 71 | + } | ||
| 72 | + return createReqDTO; | ||
| 73 | + } | ||
| 74 | + | ||
| 61 | default void copy(Model model, BpmModelCreateReqVO bean) { | 75 | default void copy(Model model, BpmModelCreateReqVO bean) { |
| 62 | model.setName(bean.getName()); | 76 | model.setName(bean.getName()); |
| 63 | model.setKey(bean.getKey()); | 77 | model.setKey(bean.getKey()); |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/workflow/ProcessDefinitionConvert.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/workflow/BpmDefinitionConvert.java
| 1 | package cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 4 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | ||
| 4 | import org.activiti.engine.repository.ProcessDefinition; | 6 | import org.activiti.engine.repository.ProcessDefinition; |
| 5 | import org.mapstruct.Mapper; | 7 | import org.mapstruct.Mapper; |
| 6 | import org.mapstruct.factory.Mappers; | 8 | import org.mapstruct.factory.Mappers; |
| 7 | 9 | ||
| 8 | /** | 10 | /** |
| 11 | + * Bpm 流程定义的 Convert | ||
| 12 | + * | ||
| 9 | * @author yunlong.li | 13 | * @author yunlong.li |
| 10 | */ | 14 | */ |
| 11 | @Mapper | 15 | @Mapper |
| 12 | -public interface ProcessDefinitionConvert { | ||
| 13 | - ProcessDefinitionConvert INSTANCE = Mappers.getMapper(ProcessDefinitionConvert.class); | 16 | +public interface BpmDefinitionConvert { |
| 17 | + | ||
| 18 | + BpmDefinitionConvert INSTANCE = Mappers.getMapper(BpmDefinitionConvert.class); | ||
| 14 | 19 | ||
| 15 | ProcessDefinitionRespVO convert(ProcessDefinition processDefinition); | 20 | ProcessDefinitionRespVO convert(ProcessDefinition processDefinition); |
| 16 | 21 | ||
| 22 | + BpmProcessDefinitionDO convert(BpmDefinitionCreateReqDTO bean); | ||
| 23 | + | ||
| 17 | } | 24 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmProcessDefinitionDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 8 | +import org.activiti.engine.repository.ProcessDefinition; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Bpm 流程定义的拓展表 | ||
| 12 | + * 主要解决 主要进行 Activiti {@link ProcessDefinition} 不支持拓展字段,所以新建拓展表 | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@TableName(value = "bpm_process_definition", autoResultMap = true) | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class BpmProcessDefinitionDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 编号 | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 流程定义的编号 | ||
| 32 | + * | ||
| 33 | + * 关联 {@link ProcessDefinition#getId()} | ||
| 34 | + */ | ||
| 35 | + private String processDefinitionId; | ||
| 36 | + /** | ||
| 37 | + * 描述 | ||
| 38 | + */ | ||
| 39 | + private String description; | ||
| 40 | + /** | ||
| 41 | + * 表单编号 | ||
| 42 | + * | ||
| 43 | + * 关联 {@link BpmFormDO#getId()} | ||
| 44 | + */ | ||
| 45 | + private Long formId; | ||
| 46 | + | ||
| 47 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/process/ProcessDefinitionDO.java deleted
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.process; | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * 流程模型实体类 映射 activiti ProcessDefinition接口 | ||
| 5 | - * | ||
| 6 | - * @author ZJQ | ||
| 7 | - * @date 2021/9/7 23:23 | ||
| 8 | - */ | ||
| 9 | -public class ProcessDefinitionDO { | ||
| 10 | - | ||
| 11 | - private String id; | ||
| 12 | - | ||
| 13 | - private String category; | ||
| 14 | - | ||
| 15 | - private String key; | ||
| 16 | - | ||
| 17 | - private String name; | ||
| 18 | - | ||
| 19 | - private String version; | ||
| 20 | - | ||
| 21 | - private String resourceName; | ||
| 22 | - | ||
| 23 | - private String deploymentId; | ||
| 24 | - | ||
| 25 | - private String diagramResourceName; | ||
| 26 | - | ||
| 27 | - private boolean suspended; | ||
| 28 | - | ||
| 29 | -} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/process/package-info.java deleted
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmProcessDefinitionMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO; | ||
| 4 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 5 | +import org.apache.ibatis.annotations.Mapper; | ||
| 6 | + | ||
| 7 | +@Mapper | ||
| 8 | +public interface BpmProcessDefinitionMapper extends BaseMapper<BpmProcessDefinitionDO> { | ||
| 9 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmDefinitionService.java
| @@ -3,9 +3,11 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; | @@ -3,9 +3,11 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | ||
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import org.activiti.engine.repository.ProcessDefinition; | 8 | import org.activiti.engine.repository.ProcessDefinition; |
| 8 | 9 | ||
| 10 | +import javax.validation.Valid; | ||
| 9 | import java.util.List; | 11 | import java.util.List; |
| 10 | import java.util.Set; | 12 | import java.util.Set; |
| 11 | 13 | ||
| @@ -31,11 +33,27 @@ public interface BpmDefinitionService { | @@ -31,11 +33,27 @@ public interface BpmDefinitionService { | ||
| 31 | FileResp export(String processDefinitionId); | 33 | FileResp export(String processDefinitionId); |
| 32 | 34 | ||
| 33 | /** | 35 | /** |
| 36 | + * 获得编号对应的 ProcessDefinition | ||
| 37 | + * | ||
| 38 | + * @param id 编号 | ||
| 39 | + * @return 流程定义 | ||
| 40 | + */ | ||
| 41 | + ProcessDefinition getDefinition(String id); | ||
| 42 | + | ||
| 43 | + /** | ||
| 34 | * 获得 deploymentId 对应的 ProcessDefinition 数组 | 44 | * 获得 deploymentId 对应的 ProcessDefinition 数组 |
| 35 | * | 45 | * |
| 36 | * @param deploymentId 部署编号 | 46 | * @param deploymentId 部署编号 |
| 37 | * @return 流程定义的数组 | 47 | * @return 流程定义的数组 |
| 38 | */ | 48 | */ |
| 39 | - List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentId); | 49 | + List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentId); |
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 创建流程定义 | ||
| 53 | + * | ||
| 54 | + * @param createReqDTO 创建信息 | ||
| 55 | + * @return 流程编号 | ||
| 56 | + */ | ||
| 57 | + String createDefinition(@Valid BpmDefinitionCreateReqDTO createReqDTO); | ||
| 40 | 58 | ||
| 41 | } | 59 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/process/ProcessService.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/ProcessService.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.process; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; |
| 2 | 2 | ||
| 3 | import org.springframework.web.multipart.MultipartFile; | 3 | import org.springframework.web.multipart.MultipartFile; |
| 4 | 4 | ||
| @@ -8,6 +8,7 @@ import org.springframework.web.multipart.MultipartFile; | @@ -8,6 +8,7 @@ import org.springframework.web.multipart.MultipartFile; | ||
| 8 | * @author ZJQ | 8 | * @author ZJQ |
| 9 | * @date 2021/9/5 21:00 | 9 | * @date 2021/9/5 21:00 |
| 10 | */ | 10 | */ |
| 11 | +@Deprecated | ||
| 11 | public interface ProcessService { | 12 | public interface ProcessService { |
| 12 | 13 | ||
| 13 | /** | 14 | /** |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/process/impl/ProcessServiceImpl.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/ProcessServiceImpl.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.process.impl; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.modules.bpm.service.process.ProcessService; | 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.ProcessService; |
| 4 | import lombok.extern.slf4j.Slf4j; | 4 | import lombok.extern.slf4j.Slf4j; |
| 5 | import org.activiti.engine.RepositoryService; | 5 | import org.activiti.engine.RepositoryService; |
| 6 | import org.activiti.engine.repository.Deployment; | 6 | import org.activiti.engine.repository.Deployment; |
| @@ -25,6 +25,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | @@ -25,6 +25,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | ||
| 25 | */ | 25 | */ |
| 26 | @Service | 26 | @Service |
| 27 | @Slf4j | 27 | @Slf4j |
| 28 | +@Deprecated | ||
| 28 | public class ProcessServiceImpl implements ProcessService { | 29 | public class ProcessServiceImpl implements ProcessService { |
| 29 | 30 | ||
| 30 | private static final String BPMN20_XML = "bpmn20.xml"; | 31 | private static final String BPMN20_XML = "bpmn20.xml"; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmDefinitionCreateReqDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +import javax.validation.constraints.NotEmpty; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 流程定义创建 Request DTO | ||
| 9 | + */ | ||
| 10 | +@Data | ||
| 11 | +public class BpmDefinitionCreateReqDTO { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 流程标识 | ||
| 15 | + */ | ||
| 16 | + @NotEmpty(message = "流程标识不能为空") | ||
| 17 | + private String key; | ||
| 18 | + /** | ||
| 19 | + * 流程名称 | ||
| 20 | + */ | ||
| 21 | + @NotEmpty(message = "流程名称不能为空") | ||
| 22 | + private String name; | ||
| 23 | + /** | ||
| 24 | + * 流程描述 | ||
| 25 | + */ | ||
| 26 | + private String description; | ||
| 27 | + /** | ||
| 28 | + * 流程分类 | ||
| 29 | + * 参见 bpm_model_category 数据字典 | ||
| 30 | + */ | ||
| 31 | + @NotEmpty(message = "流程分类不能为空") | ||
| 32 | + private String category; | ||
| 33 | + /** | ||
| 34 | + * BPMN XML | ||
| 35 | + */ | ||
| 36 | + @NotEmpty(message = "BPMN XML 不能为空") | ||
| 37 | + private String bpmnXml; | ||
| 38 | + /** | ||
| 39 | + * 动态表单编号,允许空 | ||
| 40 | + */ | ||
| 41 | + private Long formId; | ||
| 42 | + | ||
| 43 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmProcessDefinitionServiceImpl.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmDefinitionServiceImpl.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; |
| 7 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.ProcessDefinitionConvert; | 8 | +import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.BpmDefinitionConvert; |
| 9 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO; | ||
| 10 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessDefinitionMapper; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; | 11 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; |
| 12 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | ||
| 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 11 | -import lombok.RequiredArgsConstructor; | ||
| 12 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 13 | -import org.activiti.api.process.runtime.ProcessRuntime; | ||
| 14 | import org.activiti.bpmn.converter.BpmnXMLConverter; | 15 | import org.activiti.bpmn.converter.BpmnXMLConverter; |
| 15 | import org.activiti.bpmn.model.BpmnModel; | 16 | import org.activiti.bpmn.model.BpmnModel; |
| 16 | import org.activiti.engine.RepositoryService; | 17 | import org.activiti.engine.RepositoryService; |
| 18 | +import org.activiti.engine.repository.Deployment; | ||
| 17 | import org.activiti.engine.repository.ProcessDefinition; | 19 | import org.activiti.engine.repository.ProcessDefinition; |
| 18 | import org.activiti.engine.repository.ProcessDefinitionQuery; | 20 | import org.activiti.engine.repository.ProcessDefinitionQuery; |
| 19 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 22 | +import org.springframework.transaction.annotation.Transactional; | ||
| 23 | +import org.springframework.validation.annotation.Validated; | ||
| 20 | 24 | ||
| 25 | +import javax.annotation.Resource; | ||
| 21 | import java.util.Collections; | 26 | import java.util.Collections; |
| 22 | import java.util.List; | 27 | import java.util.List; |
| 23 | import java.util.Set; | 28 | import java.util.Set; |
| @@ -25,16 +30,22 @@ import java.util.stream.Collectors; | @@ -25,16 +30,22 @@ import java.util.stream.Collectors; | ||
| 25 | 30 | ||
| 26 | /** | 31 | /** |
| 27 | * 流程定义实现 | 32 | * 流程定义实现 |
| 33 | + * 主要进行 Activiti {@link ProcessDefinition} 和 {@link Deployment} 的维护 | ||
| 34 | + * | ||
| 28 | * @author yunlongn | 35 | * @author yunlongn |
| 29 | */ | 36 | */ |
| 30 | -@Slf4j | ||
| 31 | @Service | 37 | @Service |
| 32 | -@RequiredArgsConstructor | ||
| 33 | -public class BpmProcessDefinitionServiceImpl implements BpmDefinitionService { | 38 | +@Validated |
| 39 | +@Slf4j | ||
| 40 | +public class BpmDefinitionServiceImpl implements BpmDefinitionService { | ||
| 41 | + | ||
| 42 | + private static final String BPMN_FILE_SUFFIX = ".bpmn"; | ||
| 34 | 43 | ||
| 35 | - private final RepositoryService repositoryService; | 44 | + @Resource |
| 45 | + private RepositoryService repositoryService; | ||
| 36 | 46 | ||
| 37 | - private final ProcessRuntime processRuntime; | 47 | + @Resource |
| 48 | + private BpmProcessDefinitionMapper processDefinitionMapper; | ||
| 38 | 49 | ||
| 39 | @Override | 50 | @Override |
| 40 | public PageResult<ProcessDefinitionRespVO> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) { | 51 | public PageResult<ProcessDefinitionRespVO> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) { |
| @@ -47,7 +58,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmDefinitionService { | @@ -47,7 +58,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmDefinitionService { | ||
| 47 | .listPage((processDefinitionPageReqVo.getPageNo() - 1) * processDefinitionPageReqVo.getPageSize(), | 58 | .listPage((processDefinitionPageReqVo.getPageNo() - 1) * processDefinitionPageReqVo.getPageSize(), |
| 48 | processDefinitionPageReqVo.getPageSize()); | 59 | processDefinitionPageReqVo.getPageSize()); |
| 49 | final List<ProcessDefinitionRespVO> respVOList = processDefinitions.stream() | 60 | final List<ProcessDefinitionRespVO> respVOList = processDefinitions.stream() |
| 50 | - .map(ProcessDefinitionConvert.INSTANCE::convert).collect(Collectors.toList()); | 61 | + .map(BpmDefinitionConvert.INSTANCE::convert).collect(Collectors.toList()); |
| 51 | return new PageResult<>(respVOList, processDefinitionQuery.count()); | 62 | return new PageResult<>(respVOList, processDefinitionQuery.count()); |
| 52 | } | 63 | } |
| 53 | 64 | ||
| @@ -62,11 +73,36 @@ public class BpmProcessDefinitionServiceImpl implements BpmDefinitionService { | @@ -62,11 +73,36 @@ public class BpmProcessDefinitionServiceImpl implements BpmDefinitionService { | ||
| 62 | } | 73 | } |
| 63 | 74 | ||
| 64 | @Override | 75 | @Override |
| 65 | - public List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentIds) { | 76 | + public ProcessDefinition getDefinition(String id) { |
| 77 | + return repositoryService.getProcessDefinition(id); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentIds) { | ||
| 66 | if (CollUtil.isEmpty(deploymentIds)) { | 82 | if (CollUtil.isEmpty(deploymentIds)) { |
| 67 | return Collections.emptyList(); | 83 | return Collections.emptyList(); |
| 68 | } | 84 | } |
| 69 | return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); | 85 | return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); |
| 70 | } | 86 | } |
| 71 | 87 | ||
| 88 | + @Override | ||
| 89 | + @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | ||
| 90 | + public String createDefinition(BpmDefinitionCreateReqDTO createReqDTO) { | ||
| 91 | + // 创建 Deployment 部署 | ||
| 92 | + Deployment deploy = repositoryService.createDeployment() | ||
| 93 | + .key(createReqDTO.getKey()).name(createReqDTO.getName()).category(createReqDTO.getCategory()) | ||
| 94 | + .addString(createReqDTO.getName() + BPMN_FILE_SUFFIX, createReqDTO.getBpmnXml()) | ||
| 95 | + .deploy(); | ||
| 96 | + | ||
| 97 | + // 设置 ProcessDefinition 的 category 分类 | ||
| 98 | + ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); | ||
| 99 | + repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory()); | ||
| 100 | + | ||
| 101 | + // 插入拓展表 | ||
| 102 | + BpmProcessDefinitionDO definitionDO = BpmDefinitionConvert.INSTANCE.convert(createReqDTO) | ||
| 103 | + .setProcessDefinitionId(definition.getId()); | ||
| 104 | + processDefinitionMapper.insert(definitionDO); | ||
| 105 | + return definition.getId(); | ||
| 106 | + } | ||
| 107 | + | ||
| 72 | } | 108 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/BpmModelService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.model; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.model; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 5 | ||
| 7 | import javax.validation.Valid; | 6 | import javax.validation.Valid; |
| @@ -45,11 +44,11 @@ public interface BpmModelService { | @@ -45,11 +44,11 @@ public interface BpmModelService { | ||
| 45 | void updateModel(@Valid BpmModelUpdateReqVO updateReqVO); | 44 | void updateModel(@Valid BpmModelUpdateReqVO updateReqVO); |
| 46 | 45 | ||
| 47 | /** | 46 | /** |
| 48 | - * 部署模型 使模型成为一个 process | ||
| 49 | - * @param modelId 模型Id | ||
| 50 | - * @return 返回成功 | 47 | + * 将流程模型,部署成一个流程定义 |
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 51 | */ | 50 | */ |
| 52 | - CommonResult<String> deploy(String modelId); | 51 | + void deployModel(String id); |
| 53 | 52 | ||
| 54 | /** | 53 | /** |
| 55 | * 删除模型 | 54 | * 删除模型 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/impl/BpmModelServiceImpl.java
| 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.model.impl; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.model.impl; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.util.ArrayUtil; | ||
| 4 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert; |
| 7 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; |
| 8 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | ||
| 10 | import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService; | 9 | import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService; |
| 11 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService; | 10 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService; |
| 12 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; | 11 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; |
| 13 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 14 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 12 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 15 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 13 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 16 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 14 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 17 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; | 15 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; |
| 18 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
| 19 | -import org.activiti.bpmn.converter.BpmnXMLConverter; | ||
| 20 | -import org.activiti.bpmn.model.BpmnModel; | ||
| 21 | import org.activiti.engine.RepositoryService; | 17 | import org.activiti.engine.RepositoryService; |
| 22 | -import org.activiti.engine.repository.Deployment; | ||
| 23 | import org.activiti.engine.repository.Model; | 18 | import org.activiti.engine.repository.Model; |
| 24 | import org.activiti.engine.repository.ModelQuery; | 19 | import org.activiti.engine.repository.ModelQuery; |
| 25 | import org.activiti.engine.repository.ProcessDefinition; | 20 | import org.activiti.engine.repository.ProcessDefinition; |
| 26 | -import org.apache.commons.lang3.exception.ExceptionUtils; | ||
| 27 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 28 | import org.springframework.transaction.annotation.Transactional; | 22 | import org.springframework.transaction.annotation.Transactional; |
| 29 | import org.springframework.util.ObjectUtils; | 23 | import org.springframework.util.ObjectUtils; |
| 30 | import org.springframework.validation.annotation.Validated; | 24 | import org.springframework.validation.annotation.Validated; |
| 31 | 25 | ||
| 32 | import javax.annotation.Resource; | 26 | import javax.annotation.Resource; |
| 33 | -import javax.xml.stream.XMLInputFactory; | ||
| 34 | -import javax.xml.stream.XMLStreamReader; | ||
| 35 | -import java.io.ByteArrayInputStream; | ||
| 36 | -import java.io.InputStreamReader; | ||
| 37 | -import java.nio.charset.StandardCharsets; | ||
| 38 | import java.util.HashSet; | 27 | import java.util.HashSet; |
| 39 | import java.util.List; | 28 | import java.util.List; |
| 40 | import java.util.Map; | 29 | import java.util.Map; |
| 41 | import java.util.Set; | 30 | import java.util.Set; |
| 42 | 31 | ||
| 32 | +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS; | ||
| 43 | import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS; | 33 | import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS; |
| 44 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 34 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 45 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | 35 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| @@ -55,8 +45,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. | @@ -55,8 +45,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. | ||
| 55 | @Slf4j | 45 | @Slf4j |
| 56 | public class BpmModelServiceImpl implements BpmModelService { | 46 | public class BpmModelServiceImpl implements BpmModelService { |
| 57 | 47 | ||
| 58 | - private static final String BPMN_FILE_SUFFIX = ".bpmn"; | ||
| 59 | - | ||
| 60 | @Resource | 48 | @Resource |
| 61 | private RepositoryService repositoryService; | 49 | private RepositoryService repositoryService; |
| 62 | @Resource | 50 | @Resource |
| @@ -83,8 +71,8 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -83,8 +71,8 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 83 | 71 | ||
| 84 | // 获得 ProcessDefinition Map | 72 | // 获得 ProcessDefinition Map |
| 85 | Set<String> deploymentIds = new HashSet<>(); | 73 | Set<String> deploymentIds = new HashSet<>(); |
| 86 | - models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getId())); | ||
| 87 | - List<ProcessDefinition> processDefinitions = bpmDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds); | 74 | + models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); |
| 75 | + List<ProcessDefinition> processDefinitions = bpmDefinitionService.getDefinitionListByDeploymentIds(deploymentIds); | ||
| 88 | Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); | 76 | Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); |
| 89 | 77 | ||
| 90 | // 拼接结果 | 78 | // 拼接结果 |
| @@ -98,9 +86,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -98,9 +86,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 98 | BpmModelRespVO modelRespVO = ModelConvert.INSTANCE.convert(model); | 86 | BpmModelRespVO modelRespVO = ModelConvert.INSTANCE.convert(model); |
| 99 | // 拼接 bpmn XML | 87 | // 拼接 bpmn XML |
| 100 | byte[] bpmnBytes = repositoryService.getModelEditorSource(id); | 88 | byte[] bpmnBytes = repositoryService.getModelEditorSource(id); |
| 101 | - if (ArrayUtil.isNotEmpty(bpmnBytes)) { | ||
| 102 | - modelRespVO.setBpmnXml(StrUtil.utf8Str(bpmnBytes)); | ||
| 103 | - } | 89 | + modelRespVO.setBpmnXml(StrUtil.utf8Str(bpmnBytes)); |
| 104 | return modelRespVO; | 90 | return modelRespVO; |
| 105 | } | 91 | } |
| 106 | 92 | ||
| @@ -124,26 +110,13 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -124,26 +110,13 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 124 | return model.getId(); | 110 | return model.getId(); |
| 125 | } | 111 | } |
| 126 | 112 | ||
| 127 | -// @Override | ||
| 128 | -// @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | ||
| 129 | -// public String createModel(BpmModelCreateReqVO createReqVO) { | ||
| 130 | -// Deployment deploy = repositoryService.createDeployment() | ||
| 131 | -// .key(createReqVO.getKey()).name(createReqVO.getName()).category(createReqVO.getCategory()) | ||
| 132 | -// .addString(createReqVO.getName() + BPMN_FILE_SUFFIX, createReqVO.getBpmnXml()) | ||
| 133 | -// .deploy(); | ||
| 134 | -// // 设置 ProcessDefinition 的 category 分类 | ||
| 135 | -// ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); | ||
| 136 | -// repositoryService.setProcessDefinitionCategory(definition.getId(), createReqVO.getCategory()); | ||
| 137 | -// return definition.getId(); | ||
| 138 | -// } | ||
| 139 | - | ||
| 140 | @Override | 113 | @Override |
| 141 | @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | 114 | @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 |
| 142 | public void updateModel(BpmModelUpdateReqVO updateReqVO) { | 115 | public void updateModel(BpmModelUpdateReqVO updateReqVO) { |
| 143 | // 校验流程模型存在 | 116 | // 校验流程模型存在 |
| 144 | Model model = repositoryService.getModel(updateReqVO.getId()); | 117 | Model model = repositoryService.getModel(updateReqVO.getId()); |
| 145 | if (model == null) { | 118 | if (model == null) { |
| 146 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | 119 | + throw exception(BPMN_MODEL_NOT_EXISTS); |
| 147 | } | 120 | } |
| 148 | // TODO @芋艿:需要校验下 key 的格式 | 121 | // TODO @芋艿:需要校验下 key 的格式 |
| 149 | 122 | ||
| @@ -156,40 +129,27 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -156,40 +129,27 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 156 | } | 129 | } |
| 157 | 130 | ||
| 158 | @Override | 131 | @Override |
| 159 | - public CommonResult<String> deploy(String modelId) { | ||
| 160 | - try { | ||
| 161 | - Model modelData = repositoryService.getModel(modelId); | ||
| 162 | - if (ObjectUtils.isEmpty(modelData)) { | ||
| 163 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | ||
| 164 | - } | ||
| 165 | - byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); | ||
| 166 | - if (bytes == null) { | ||
| 167 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | ||
| 168 | - } | ||
| 169 | - // 将xml转换为流 | ||
| 170 | - // TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个 | ||
| 171 | - ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); | ||
| 172 | - XMLInputFactory xif = XMLInputFactory.newInstance(); | ||
| 173 | - InputStreamReader in = new InputStreamReader(inputStream, StandardCharsets.UTF_8); | ||
| 174 | - XMLStreamReader xtr = xif.createXMLStreamReader(in); | ||
| 175 | - // 流数据转化为 model | ||
| 176 | - BpmnModel model = new BpmnXMLConverter().convertToBpmnModel(xtr); | ||
| 177 | - if(ObjectUtils.isEmpty(model.getProcesses())){ | ||
| 178 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_PROCESS_NOT_EXISTS); | ||
| 179 | - } | ||
| 180 | - byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model); | ||
| 181 | - // 部署发布模型流程 | ||
| 182 | - String processName = modelData.getName() + ".bpmn20.xml"; | ||
| 183 | - Deployment deployment = repositoryService.createDeployment() | ||
| 184 | - .name(modelData.getName()) | ||
| 185 | - .addString(processName, new String(bpmnBytes, StandardCharsets.UTF_8)) | ||
| 186 | - .deploy(); | ||
| 187 | - // 部署成功 | ||
| 188 | - return CommonResult.success(deployment.getId()); | ||
| 189 | - } catch (Exception e) { | ||
| 190 | - log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e)); | ||
| 191 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); | 132 | + @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 |
| 133 | + public void deployModel(String id) { | ||
| 134 | + // 校验流程模型存在 | ||
| 135 | + Model model = repositoryService.getModel(id); | ||
| 136 | + if (ObjectUtils.isEmpty(model)) { | ||
| 137 | + throw exception(BPMN_MODEL_NOT_EXISTS); | ||
| 192 | } | 138 | } |
| 139 | + byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId()); | ||
| 140 | + if (bpmnBytes == null) { | ||
| 141 | + throw exception(BPMN_MODEL_NOT_EXISTS); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + // 创建流程定义 | ||
| 145 | + BpmDefinitionCreateReqDTO definitionCreateReqDTO = ModelConvert.INSTANCE.convert2(model) | ||
| 146 | + .setBpmnXml(StrUtil.utf8Str(bpmnBytes)); | ||
| 147 | + String definitionId = bpmDefinitionService.createDefinition(definitionCreateReqDTO); | ||
| 148 | + | ||
| 149 | + // 更新 model 的 deploymentId,进行关联 | ||
| 150 | + ProcessDefinition definition = bpmDefinitionService.getDefinition(definitionId); | ||
| 151 | + model.setDeploymentId(definition.getDeploymentId()); | ||
| 152 | + repositoryService.saveModel(model); | ||
| 193 | } | 153 | } |
| 194 | 154 | ||
| 195 | @Override | 155 | @Override |
| @@ -197,7 +157,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -197,7 +157,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 197 | // 校验流程模型存在 | 157 | // 校验流程模型存在 |
| 198 | Model model = repositoryService.getModel(id); | 158 | Model model = repositoryService.getModel(id); |
| 199 | if (model == null) { | 159 | if (model == null) { |
| 200 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | 160 | + throw exception(BPMN_MODEL_NOT_EXISTS); |
| 201 | } | 161 | } |
| 202 | // 执行删除 | 162 | // 执行删除 |
| 203 | repositoryService.deleteModel(id); | 163 | repositoryService.deleteModel(id); |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmTaskService.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.task; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmTaskServiceImpl.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.io.IoUtil; | 4 | import cn.hutool.core.io.IoUtil; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.TaskConvert; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.TaskConvert; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmTaskService; | 7 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService; |
| 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 9 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 10 | import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; | 10 | import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; |
| @@ -28,7 +28,6 @@ import org.activiti.engine.repository.ProcessDefinition; | @@ -28,7 +28,6 @@ import org.activiti.engine.repository.ProcessDefinition; | ||
| 28 | import org.activiti.engine.runtime.ProcessInstance; | 28 | import org.activiti.engine.runtime.ProcessInstance; |
| 29 | import org.activiti.engine.task.Comment; | 29 | import org.activiti.engine.task.Comment; |
| 30 | import org.activiti.image.ProcessDiagramGenerator; | 30 | import org.activiti.image.ProcessDiagramGenerator; |
| 31 | -import org.apache.commons.lang3.exception.ExceptionUtils; | ||
| 32 | import org.springframework.stereotype.Service; | 31 | import org.springframework.stereotype.Service; |
| 33 | import org.springframework.transaction.annotation.Transactional; | 32 | import org.springframework.transaction.annotation.Transactional; |
| 34 | import org.springframework.util.ObjectUtils; | 33 | import org.springframework.util.ObjectUtils; |
yudao-admin-ui/src/api/bpm/model.js
| @@ -38,10 +38,9 @@ export function deleteModel(id) { | @@ -38,10 +38,9 @@ export function deleteModel(id) { | ||
| 38 | }) | 38 | }) |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | -export function deployModel(data) { | 41 | +export function deployModel(id) { |
| 42 | return request({ | 42 | return request({ |
| 43 | - url: '/bpm/model/deploy?modelId='+ data.modelId, | ||
| 44 | - method: 'POST', | ||
| 45 | - data: data | 43 | + url: '/bpm/model/deploy?id=' + id, |
| 44 | + method: 'POST' | ||
| 46 | }) | 45 | }) |
| 47 | } | 46 | } |
yudao-admin-ui/src/views/bpm/model/index.vue
| @@ -27,10 +27,9 @@ | @@ -27,10 +27,9 @@ | ||
| 27 | <el-table-column label="流程编号" align="center" prop="id" :show-overflow-tooltip="true" /> | 27 | <el-table-column label="流程编号" align="center" prop="id" :show-overflow-tooltip="true" /> |
| 28 | <el-table-column label="流程标识" align="center" prop="key" /> | 28 | <el-table-column label="流程标识" align="center" prop="key" /> |
| 29 | <el-table-column label="流程名称" align="center" prop="name" /> | 29 | <el-table-column label="流程名称" align="center" prop="name" /> |
| 30 | - <el-table-column label="流程分类" align="center" prop="category" /> | ||
| 31 | - <el-table-column label="表单信息" align="center" prop="formName" /> | ||
| 32 | - <el-table-column label="流程版本" align="center" prop="revision" /> | ||
| 33 | - <el-table-column label="状态" align="center" prop="rversion" /> | 30 | + <el-table-column label="流程分类" align="center" prop="category" /> <!-- TODO 芋艿:数据字典的格式化 --> |
| 31 | + <el-table-column label="表单信息" align="center" prop="formId" /> <!-- TODO 芋艿:需要支持表单的点击 --> | ||
| 32 | + <el-table-column label="流程版本" align="center" prop="processDefinition.version" /> | ||
| 34 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 33 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 35 | <template slot-scope="scope"> | 34 | <template slot-scope="scope"> |
| 36 | <span>{{ parseTime(scope.row.createTime) }}</span> | 35 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| @@ -39,8 +38,9 @@ | @@ -39,8 +38,9 @@ | ||
| 39 | <el-table-column label="操作" align="center" width="240"> | 38 | <el-table-column label="操作" align="center" width="240"> |
| 40 | <template slot-scope="scope"> | 39 | <template slot-scope="scope"> |
| 41 | <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button> | 40 | <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button> |
| 42 | - <el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button> | ||
| 43 | - <el-button size="mini" type="text" icon="el-icon-thumb" @click="modelDeploy(scope.row)">发布</el-button> | 41 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button> |
| 42 | + <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)">发布</el-button> | ||
| 43 | + <!-- TODO 芋艿:流程定义 --> | ||
| 44 | </template> | 44 | </template> |
| 45 | </el-table-column> | 45 | </el-table-column> |
| 46 | </el-table> | 46 | </el-table> |
| @@ -115,6 +115,10 @@ export default { | @@ -115,6 +115,10 @@ export default { | ||
| 115 | this.handleQuery(); | 115 | this.handleQuery(); |
| 116 | }, | 116 | }, |
| 117 | processSave(data) { | 117 | processSave(data) { |
| 118 | + // TODO 芋艿:临时写死的参数 | ||
| 119 | + data.category = '1' | ||
| 120 | + data.formId = 11 | ||
| 121 | + | ||
| 118 | // 修改的提交 | 122 | // 修改的提交 |
| 119 | if (data.id) { | 123 | if (data.id) { |
| 120 | updateModel(data).then(response => { | 124 | updateModel(data).then(response => { |
| @@ -159,7 +163,7 @@ export default { | @@ -159,7 +163,7 @@ export default { | ||
| 159 | this.showBpmnOpen = true | 163 | this.showBpmnOpen = true |
| 160 | }) | 164 | }) |
| 161 | }, | 165 | }, |
| 162 | - modelDelete(row) { | 166 | + handleDelete(row) { |
| 163 | const that = this; | 167 | const that = this; |
| 164 | this.$confirm('是否删除该流程!!', "警告", { | 168 | this.$confirm('是否删除该流程!!', "警告", { |
| 165 | confirmButtonText: "确定", | 169 | confirmButtonText: "确定", |
| @@ -172,16 +176,14 @@ export default { | @@ -172,16 +176,14 @@ export default { | ||
| 172 | }) | 176 | }) |
| 173 | }) | 177 | }) |
| 174 | }, | 178 | }, |
| 175 | - modelDeploy(row) { | 179 | + handleDeploy(row) { |
| 176 | const that = this; | 180 | const that = this; |
| 177 | this.$confirm('是否部署该流程!!', "提示", { | 181 | this.$confirm('是否部署该流程!!', "提示", { |
| 178 | confirmButtonText: "确定", | 182 | confirmButtonText: "确定", |
| 179 | cancelButtonText: "取消", | 183 | cancelButtonText: "取消", |
| 180 | type: "success" | 184 | type: "success" |
| 181 | }).then(function() { | 185 | }).then(function() { |
| 182 | - deployModel({ | ||
| 183 | - modelId: row.id | ||
| 184 | - }).then(response => { | 186 | + deployModel(row.id).then(response => { |
| 185 | that.getList(); | 187 | that.getList(); |
| 186 | that.msgSuccess("部署成功"); | 188 | that.msgSuccess("部署成功"); |
| 187 | }) | 189 | }) |