|
@@ -2,12 +2,9 @@ package com.citu.module.bpm.controller.admin.definition;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import com.citu.framework.common.pojo.CommonResult;
|
|
import com.citu.framework.common.pojo.CommonResult;
|
|
-import com.citu.framework.common.pojo.PageResult;
|
|
|
|
-import com.citu.framework.common.util.collection.CollectionUtils;
|
|
|
|
-import com.citu.framework.common.util.io.IoUtils;
|
|
|
|
-import com.citu.framework.common.util.json.JsonUtils;
|
|
|
|
-import com.citu.framework.common.util.object.BeanUtils;
|
|
|
|
import com.citu.module.bpm.controller.admin.definition.vo.model.*;
|
|
import com.citu.module.bpm.controller.admin.definition.vo.model.*;
|
|
|
|
+import com.citu.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
|
|
|
+import com.citu.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelUpdateReqVO;
|
|
import com.citu.module.bpm.convert.definition.BpmModelConvert;
|
|
import com.citu.module.bpm.convert.definition.BpmModelConvert;
|
|
import com.citu.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
|
import com.citu.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
|
import com.citu.module.bpm.dal.dataobject.definition.BpmFormDO;
|
|
import com.citu.module.bpm.dal.dataobject.definition.BpmFormDO;
|
|
@@ -15,7 +12,8 @@ import com.citu.module.bpm.service.definition.BpmCategoryService;
|
|
import com.citu.module.bpm.service.definition.BpmFormService;
|
|
import com.citu.module.bpm.service.definition.BpmFormService;
|
|
import com.citu.module.bpm.service.definition.BpmModelService;
|
|
import com.citu.module.bpm.service.definition.BpmModelService;
|
|
import com.citu.module.bpm.service.definition.BpmProcessDefinitionService;
|
|
import com.citu.module.bpm.service.definition.BpmProcessDefinitionService;
|
|
-import com.citu.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
|
|
|
|
|
|
+import com.citu.module.system.api.user.AdminUserApi;
|
|
|
|
+import com.citu.module.system.api.user.dto.AdminUserRespDTO;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -28,15 +26,15 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
-import java.io.IOException;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
|
|
+import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import static com.citu.framework.common.pojo.CommonResult.success;
|
|
import static com.citu.framework.common.pojo.CommonResult.success;
|
|
-import static com.citu.framework.common.util.collection.CollectionUtils.convertMap;
|
|
|
|
-import static com.citu.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
|
+import static com.citu.framework.common.util.collection.CollectionUtils.*;
|
|
|
|
+import static com.citu.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
|
|
|
@Tag(name = "管理后台 - 流程模型")
|
|
@Tag(name = "管理后台 - 流程模型")
|
|
@RestController
|
|
@RestController
|
|
@@ -53,32 +51,42 @@ public class BpmModelController {
|
|
@Resource
|
|
@Resource
|
|
private BpmProcessDefinitionService processDefinitionService;
|
|
private BpmProcessDefinitionService processDefinitionService;
|
|
|
|
|
|
- @GetMapping("/page")
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
|
+
|
|
|
|
+ @GetMapping("/list")
|
|
@Operation(summary = "获得模型分页")
|
|
@Operation(summary = "获得模型分页")
|
|
- public CommonResult<PageResult<BpmModelRespVO>> getModelPage(BpmModelPageReqVO pageVO) {
|
|
|
|
- PageResult<Model> pageResult = modelService.getModelPage(pageVO);
|
|
|
|
- if (CollUtil.isEmpty(pageResult.getList())) {
|
|
|
|
- return success(PageResult.empty(pageResult.getTotal()));
|
|
|
|
|
|
+ @Parameter(name = "name", description = "模型名称", example = "芋艿")
|
|
|
|
+ public CommonResult<List<BpmModelRespVO>> getModelPage(@RequestParam(value = "name", required = false) String name) {
|
|
|
|
+ List<Model> list = modelService.getModelList(name);
|
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
|
+ return success(Collections.emptyList());
|
|
}
|
|
}
|
|
|
|
|
|
- // 拼接数据
|
|
|
|
// 获得 Form 表单
|
|
// 获得 Form 表单
|
|
- Set<Long> formIds = convertSet(pageResult.getList(), model -> {
|
|
|
|
- BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
|
|
|
|
|
|
+ Set<Long> formIds = convertSet(list, model -> {
|
|
|
|
+ BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model);
|
|
return metaInfo != null ? metaInfo.getFormId() : null;
|
|
return metaInfo != null ? metaInfo.getFormId() : null;
|
|
});
|
|
});
|
|
Map<Long, BpmFormDO> formMap = formService.getFormMap(formIds);
|
|
Map<Long, BpmFormDO> formMap = formService.getFormMap(formIds);
|
|
// 获得 Category Map
|
|
// 获得 Category Map
|
|
Map<String, BpmCategoryDO> categoryMap = categoryService.getCategoryMap(
|
|
Map<String, BpmCategoryDO> categoryMap = categoryService.getCategoryMap(
|
|
- convertSet(pageResult.getList(), Model::getCategory));
|
|
|
|
|
|
+ convertSet(list, Model::getCategory));
|
|
// 获得 Deployment Map
|
|
// 获得 Deployment Map
|
|
- Set<String> deploymentIds = new HashSet<>();
|
|
|
|
- pageResult.getList().forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId()));
|
|
|
|
- Map<String, Deployment> deploymentMap = processDefinitionService.getDeploymentMap(deploymentIds);
|
|
|
|
|
|
+ Map<String, Deployment> deploymentMap = processDefinitionService.getDeploymentMap(
|
|
|
|
+ convertSet(list, Model::getDeploymentId));
|
|
// 获得 ProcessDefinition Map
|
|
// 获得 ProcessDefinition Map
|
|
- List<ProcessDefinition> processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds);
|
|
|
|
|
|
+ List<ProcessDefinition> processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds(
|
|
|
|
+ deploymentMap.keySet());
|
|
Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId);
|
|
Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId);
|
|
- return success(BpmModelConvert.INSTANCE.buildModelPage(pageResult, formMap, categoryMap, deploymentMap, processDefinitionMap));
|
|
|
|
|
|
+ // 获得 User Map
|
|
|
|
+ Set<Long> userIds = convertSetByFlatMap(list, model -> {
|
|
|
|
+ BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model);
|
|
|
|
+ return metaInfo != null ? metaInfo.getStartUserIds().stream() : Stream.empty();
|
|
|
|
+ });
|
|
|
|
+ Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
|
|
|
|
+ return success(BpmModelConvert.INSTANCE.buildModelList(list,
|
|
|
|
+ formMap, categoryMap, deploymentMap, processDefinitionMap, userMap));
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/get")
|
|
@GetMapping("/get")
|
|
@@ -97,26 +105,25 @@ public class BpmModelController {
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
@Operation(summary = "新建模型")
|
|
@Operation(summary = "新建模型")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:create')")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:create')")
|
|
- public CommonResult<String> createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) {
|
|
|
|
- return success(modelService.createModel(createRetVO, null));
|
|
|
|
|
|
+ public CommonResult<String> createModel(@Valid @RequestBody BpmModelSaveReqVO createRetVO) {
|
|
|
|
+ return success(modelService.createModel(createRetVO));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@PutMapping("/update")
|
|
@PutMapping("/update")
|
|
@Operation(summary = "修改模型")
|
|
@Operation(summary = "修改模型")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
|
- public CommonResult<Boolean> updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) {
|
|
|
|
- modelService.updateModel(modelVO);
|
|
|
|
|
|
+ public CommonResult<Boolean> updateModel(@Valid @RequestBody BpmModelSaveReqVO modelVO) {
|
|
|
|
+ modelService.updateModel(getLoginUserId(), modelVO);
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
- @PostMapping("/import")
|
|
|
|
- @Operation(summary = "导入模型")
|
|
|
|
- @PreAuthorize("@ss.hasPermission('bpm:model:import')")
|
|
|
|
- public CommonResult<String> importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException {
|
|
|
|
- BpmModelCreateReqVO createReqVO = BeanUtils.toBean(importReqVO, BpmModelCreateReqVO.class);
|
|
|
|
- // 读取文件
|
|
|
|
- String bpmnXml = IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false);
|
|
|
|
- return success(modelService.createModel(createReqVO, bpmnXml));
|
|
|
|
|
|
+ @PutMapping("/update-sort-batch")
|
|
|
|
+ @Operation(summary = "批量修改模型排序")
|
|
|
|
+ @Parameter(name = "ids", description = "编号数组", required = true, example = "1,2,3")
|
|
|
|
+ public CommonResult<Boolean> updateModelSortBatch(@RequestParam("ids") List<String> ids) {
|
|
|
|
+ modelService.updateModelSortBatch(getLoginUserId(), ids);
|
|
|
|
+ return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
@PostMapping("/deploy")
|
|
@PostMapping("/deploy")
|
|
@@ -124,7 +131,7 @@ public class BpmModelController {
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:deploy')")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:deploy')")
|
|
public CommonResult<Boolean> deployModel(@RequestParam("id") String id) {
|
|
public CommonResult<Boolean> deployModel(@RequestParam("id") String id) {
|
|
- modelService.deployModel(id);
|
|
|
|
|
|
+ modelService.deployModel(getLoginUserId(), id);
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -132,7 +139,15 @@ public class BpmModelController {
|
|
@Operation(summary = "修改模型的状态", description = "实际更新的部署的流程定义的状态")
|
|
@Operation(summary = "修改模型的状态", description = "实际更新的部署的流程定义的状态")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
|
public CommonResult<Boolean> updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) {
|
|
public CommonResult<Boolean> updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) {
|
|
- modelService.updateModelState(reqVO.getId(), reqVO.getState());
|
|
|
|
|
|
+ modelService.updateModelState(getLoginUserId(), reqVO.getId(), reqVO.getState());
|
|
|
|
+ return success(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PutMapping("/update-bpmn")
|
|
|
|
+ @Operation(summary = "修改模型的 BPMN")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
|
|
|
+ public CommonResult<Boolean> updateModelBpmn(@Valid @RequestBody BpmModeUpdateBpmnReqVO reqVO) {
|
|
|
|
+ modelService.updateModelBpmnXml(reqVO.getId(), reqVO.getBpmnXml());
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -141,8 +156,25 @@ public class BpmModelController {
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:delete')")
|
|
@PreAuthorize("@ss.hasPermission('bpm:model:delete')")
|
|
public CommonResult<Boolean> deleteModel(@RequestParam("id") String id) {
|
|
public CommonResult<Boolean> deleteModel(@RequestParam("id") String id) {
|
|
- modelService.deleteModel(id);
|
|
|
|
|
|
+ modelService.deleteModel(getLoginUserId(), id);
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // ========== 仿钉钉/飞书的精简模型 =========
|
|
|
|
+
|
|
|
|
+ @GetMapping("/simple/get")
|
|
|
|
+ @Operation(summary = "获得仿钉钉流程设计模型")
|
|
|
|
+ @Parameter(name = "modelId", description = "流程模型编号", required = true, example = "a2c5eee0-eb6c-11ee-abf4-0c37967c420a")
|
|
|
|
+ public CommonResult<BpmSimpleModelNodeVO> getSimpleModel(@RequestParam("id") String modelId){
|
|
|
|
+ return success(modelService.getSimpleModel(modelId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/simple/update")
|
|
|
|
+ @Operation(summary = "保存仿钉钉流程设计模型")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
|
|
|
+ public CommonResult<Boolean> updateSimpleModel(@Valid @RequestBody BpmSimpleModelUpdateReqVO reqVO) {
|
|
|
|
+ modelService.updateSimpleModel(getLoginUserId(), reqVO);
|
|
|
|
+ return success(Boolean.TRUE);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|