初始代码
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-workflow-engine</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-workflow-engine-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-workflow-engine-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,806 @@
|
||||
package com.yunzhupaas.engine.controller;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.engine.entity.*;
|
||||
import com.yunzhupaas.engine.enums.FlowNodeEnum;
|
||||
import com.yunzhupaas.engine.enums.FlowRecordEnum;
|
||||
import com.yunzhupaas.engine.enums.FlowTaskStatusEnum;
|
||||
import com.yunzhupaas.engine.model.flowbefore.*;
|
||||
import com.yunzhupaas.engine.model.flowcandidate.FlowCandidateUserModel;
|
||||
import com.yunzhupaas.engine.model.flowcandidate.FlowCandidateVO;
|
||||
import com.yunzhupaas.engine.model.flowcandidate.FlowRejectVO;
|
||||
import com.yunzhupaas.engine.model.flowengine.FlowModel;
|
||||
import com.yunzhupaas.engine.model.flowengine.shuntjson.childnode.ChildNode;
|
||||
import com.yunzhupaas.engine.model.flowengine.shuntjson.nodejson.ChildNodeList;
|
||||
import com.yunzhupaas.engine.model.flowengine.shuntjson.nodejson.ConditionList;
|
||||
import com.yunzhupaas.engine.model.flowtask.FlowTaskListModel;
|
||||
import com.yunzhupaas.engine.model.flowtask.PaginationFlowTask;
|
||||
import com.yunzhupaas.engine.model.flowtask.TaskNodeModel;
|
||||
import com.yunzhupaas.engine.model.flowtasknode.TaskNodeListModel;
|
||||
import com.yunzhupaas.engine.service.*;
|
||||
import com.yunzhupaas.engine.util.FlowJsonUtil;
|
||||
import com.yunzhupaas.engine.util.FlowNature;
|
||||
import com.yunzhupaas.engine.util.FlowTaskUtil;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.permission.model.user.UserIdListVo;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.ServiceAllUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import com.yunzhupaas.util.visiual.YunzhupaasKeyConsts;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 待我审核
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "待我审核", description = "FlowBefore")
|
||||
@RestController
|
||||
@RequestMapping("/api/workflow1/Engine/FlowBefore")
|
||||
public class FlowBeforeController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ServiceAllUtil serviceUtil;
|
||||
|
||||
@Autowired
|
||||
private FlowTaskUtil flowTaskUtil;
|
||||
@Autowired
|
||||
private FlowTaskService flowTaskService;
|
||||
@Autowired
|
||||
private FlowTemplateJsonService flowTemplateJsonService;
|
||||
@Autowired
|
||||
private FlowTaskOperatorService flowTaskOperatorService;
|
||||
@Autowired
|
||||
private FlowTaskOperatorRecordService flowTaskOperatorRecordService;
|
||||
@Autowired
|
||||
private FlowTaskNodeService flowTaskNodeService;
|
||||
@Autowired
|
||||
private FlowTaskNewService flowTaskNewService;
|
||||
@Autowired
|
||||
private FlowOperatorUserService flowOperatorUserService;
|
||||
@Autowired
|
||||
private FlowTaskCirculateService flowTaskCirculateService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 获取待我审核列表
|
||||
*
|
||||
* @param category 分类
|
||||
* @param paginationFlowTask 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取待我审核列表(有带分页),1-待办事宜,2-已办事宜,3-抄送事宜,4-批量审批")
|
||||
@GetMapping("/List/{category}")
|
||||
@Parameters({
|
||||
@Parameter(name = "category", description = "分类", required = true),
|
||||
})
|
||||
public ActionResult<PageListVO<FlowBeforeListVO>> list(@PathVariable("category") String category, PaginationFlowTask paginationFlowTask) {
|
||||
List<FlowTaskListModel> data = new ArrayList<>();
|
||||
paginationFlowTask.setDelegateType(true);
|
||||
if (FlowNature.WAIT.equals(category)) {
|
||||
data.addAll(flowTaskService.getWaitList(paginationFlowTask));
|
||||
} else if (FlowNature.TRIAL.equals(category)) {
|
||||
data.addAll(flowTaskService.getTrialList(paginationFlowTask));
|
||||
} else if (FlowNature.CIRCULATE.equals(category)) {
|
||||
data.addAll(flowTaskService.getCirculateList(paginationFlowTask));
|
||||
} else if (FlowNature.BATCH.equals(category)) {
|
||||
paginationFlowTask.setIsBatch(1);
|
||||
data.addAll(flowTaskService.getWaitList(paginationFlowTask));
|
||||
}
|
||||
List<FlowBeforeListVO> listVO = new LinkedList<>();
|
||||
List<UserEntity> userList = serviceUtil.getUserName(data.stream().map(FlowTaskListModel::getCreatorUserId).collect(Collectors.toList()));
|
||||
boolean isBatch = FlowNature.BATCH.equals(category);
|
||||
List<FlowTaskNodeEntity> taskNodeList = new ArrayList<>();
|
||||
List<String> taskNodeIdList = data.stream().map(FlowTaskListModel::getThisStepId).collect(Collectors.toList());
|
||||
if (isBatch) {
|
||||
taskNodeList.addAll(flowTaskNodeService.getList(taskNodeIdList, FlowTaskNodeEntity::getId, FlowTaskNodeEntity::getNodePropertyJson));
|
||||
}
|
||||
for (FlowTaskListModel task : data) {
|
||||
FlowBeforeListVO vo = JsonUtil.getJsonToBean(task, FlowBeforeListVO.class);
|
||||
//用户名称赋值
|
||||
UserEntity user = userList.stream().filter(t -> t.getId().equals(vo.getCreatorUserId())).findFirst().orElse(null);
|
||||
vo.setUserName(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
FlowTaskNodeEntity taskNode = taskNodeList.stream().filter(t -> t.getId().equals(task.getThisStepId())).findFirst().orElse(null);
|
||||
if (isBatch && taskNode != null) {
|
||||
ChildNodeList childNode = JsonUtil.getJsonToBean(taskNode.getNodePropertyJson(), ChildNodeList.class);
|
||||
vo.setApproversProperties(JsonUtil.getObjectToString(childNode.getProperties()));
|
||||
}
|
||||
vo.setFlowVersion(StringUtil.isEmpty(vo.getFlowVersion()) ? "" : vo.getFlowVersion());
|
||||
listVO.add(vo);
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationFlowTask, PaginationVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待我审批信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取待我审批信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<FlowBeforeInfoVO> info(@PathVariable("id") String id, FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setId(id);
|
||||
FlowBeforeInfoVO vo = flowTaskNewService.getBeforeInfo(flowModel);
|
||||
//处理当前默认值
|
||||
if (vo != null && vo.getFlowFormInfo() != null && StringUtil.isNotEmpty(vo.getFlowFormInfo().getPropertyJson()) && vo.getFlowFormInfo().getFormType() == 2) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
Map<String, Integer> havaDefaultCurrentValue = new HashMap<>();
|
||||
vo.getFlowFormInfo().setPropertyJson(setDefaultCurrentValue(vo.getFlowFormInfo().getPropertyJson(), havaDefaultCurrentValue, userInfo));
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 待我审核审核
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "待我审核审核")
|
||||
@PostMapping("/Audit/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult audit(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setId(id);
|
||||
flowTaskNewService.audit(flowModel);
|
||||
return ActionResult.success(MsgCode.WF001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存草稿
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "保存草稿")
|
||||
@PostMapping("/SaveAudit/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult saveAudit(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
FlowTaskOperatorEntity flowTaskOperatorEntity = flowTaskOperatorService.getInfo(id);
|
||||
if (flowTaskOperatorEntity != null) {
|
||||
Map<String, Object> formDataAll = flowModel.getFormData();
|
||||
flowTaskOperatorEntity.setDraftData(JsonUtil.getObjectToString(formDataAll));
|
||||
flowTaskOperatorService.update(flowTaskOperatorEntity);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批汇总
|
||||
*
|
||||
* @param id 主键
|
||||
* @param category 类型
|
||||
* @param type 类型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "审批汇总")
|
||||
@GetMapping("/RecordList/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<List<FlowSummary>> recordList(@PathVariable("id") String id, String category, String type) {
|
||||
List<FlowSummary> flowSummaries = flowTaskNewService.recordList(id, category, type);
|
||||
return ActionResult.success(flowSummaries);
|
||||
}
|
||||
|
||||
/**
|
||||
* 待我审核驳回
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "待我审核驳回")
|
||||
@PostMapping("/Reject/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult reject(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setId(id);
|
||||
flowTaskNewService.reject(flowModel);
|
||||
return ActionResult.success(MsgCode.WF002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 待我审核转办
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "待我审核转办")
|
||||
@PostMapping("/Transfer/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult transfer(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setId(id);
|
||||
flowTaskNewService.transfer(flowModel);
|
||||
return ActionResult.success(MsgCode.WF003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 待我审核转办
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "待我审核加签")
|
||||
@PostMapping("/freeApprover/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult freeApprover(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setId(id);
|
||||
flowTaskNewService.audit(flowModel);
|
||||
return ActionResult.success(MsgCode.WF004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 待我审核撤回审核
|
||||
* 注意:在撤销流程时要保证你的下一节点没有处理这条记录;如已处理则无法撤销流程。
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "待我审核撤回审核")
|
||||
@PostMapping("/Recall/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult recall(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
FlowTaskOperatorRecordEntity operatorRecord = flowTaskOperatorRecordService.getInfo(id);
|
||||
FlowTaskNodeEntity taskNode = flowTaskNodeService.getInfo(operatorRecord.getTaskNodeId(), FlowTaskNodeEntity::getId);
|
||||
//拒绝不撤回
|
||||
if (FlowNature.ProcessCompletion.equals(operatorRecord.getHandleStatus())) {
|
||||
throw new WorkFlowException(MsgCode.WF005.get());
|
||||
}
|
||||
if (taskNode == null) {
|
||||
return ActionResult.fail(MsgCode.WF006.get());
|
||||
}
|
||||
if (FlowRecordEnum.swerve.getCode().equals(operatorRecord.getHandleStatus())) {
|
||||
return ActionResult.fail(MsgCode.WF007.get());
|
||||
}
|
||||
if (FlowRecordEnum.revoke.getCode().equals(operatorRecord.getStatus())) {
|
||||
return ActionResult.fail(MsgCode.WF006.get());
|
||||
}
|
||||
if (taskNode != null && !FlowRecordEnum.revoke.getCode().equals(operatorRecord.getStatus())) {
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowTaskNewService.recall(id, operatorRecord, flowModel);
|
||||
}
|
||||
return ActionResult.success(MsgCode.WF008.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 待我审核终止审核
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "待我审核终止审核")
|
||||
@PostMapping("/Cancel/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult cancel(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
FlowTaskEntity entity = flowTaskService.getInfo(id, FlowTaskEntity::getFlowType);
|
||||
if (entity != null) {
|
||||
if (Objects.equals(entity.getFlowType(), 1)) {
|
||||
return ActionResult.fail(MsgCode.WF009.get());
|
||||
}
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
List<String> idList = ImmutableList.of(id);
|
||||
flowTaskNewService.cancel(idList, flowModel);
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA009.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 指派人
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "指派人")
|
||||
@PostMapping("/Assign/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult assign(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowTaskNewService.assign(id, flowModel);
|
||||
return ActionResult.success(MsgCode.WF010.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取候选人
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取候选人节点")
|
||||
@PostMapping("/Candidates/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult<FlowCandidateVO> candidates(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
FlowCandidateVO candidate = flowTaskNewService.candidates(id, flowModel, false);
|
||||
return ActionResult.success(candidate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取候选人
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取候选人")
|
||||
@PostMapping("/CandidateUser/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult<PageListVO<FlowCandidateUserModel>> candidateUser(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
List<FlowCandidateUserModel> candidate = flowTaskNewService.candidateUser(id, flowModel);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(flowModel, PaginationVO.class);
|
||||
return ActionResult.page(candidate, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量审批引擎
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "批量审批引擎")
|
||||
@GetMapping("/BatchFlowSelector")
|
||||
public ActionResult<List<FlowBatchModel>> batchFlowSelector() {
|
||||
List<FlowBatchModel> batchFlowList = flowTaskService.batchFlowSelector();
|
||||
return ActionResult.success(batchFlowList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝下拉框
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "拒绝下拉框")
|
||||
@GetMapping("/RejectList/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<FlowRejectVO> rejectList(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowRejectVO vo = flowTaskNewService.rejectList(id, false);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 引擎节点
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
@Operation(summary = "引擎节点")
|
||||
@GetMapping("/NodeSelector/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<List<FlowBatchModel>> nodeSelector(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateAllModel template = flowTaskUtil.templateJson(id);
|
||||
String templateJson = template.getTemplateJson().getFlowTemplateJson();
|
||||
List<FlowBatchModel> batchList = new ArrayList<>();
|
||||
ChildNode childNodeAll = JsonUtil.getJsonToBean(templateJson, ChildNode.class);
|
||||
//获取流程节点
|
||||
List<ChildNodeList> nodeListAll = new ArrayList<>();
|
||||
List<ConditionList> conditionListAll = new ArrayList<>();
|
||||
//递归获取条件数据和节点数据
|
||||
FlowJsonUtil.getTemplateAll(childNodeAll, nodeListAll, conditionListAll);
|
||||
List<String> type = ImmutableList.of(FlowNature.NodeSubFlow, FlowNature.NodeStart);
|
||||
for (ChildNodeList childNodeList : nodeListAll) {
|
||||
if (!type.contains(childNodeList.getCustom().getType())) {
|
||||
FlowBatchModel batchModel = new FlowBatchModel();
|
||||
batchModel.setFullName(childNodeList.getProperties().getTitle());
|
||||
batchModel.setId(childNodeList.getCustom().getNodeId());
|
||||
batchList.add(batchModel);
|
||||
}
|
||||
}
|
||||
return ActionResult.success(batchList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程批量类型下拉
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
@Operation(summary = "流程批量类型下拉")
|
||||
@GetMapping("/BatchFlowJsonList/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<List<FlowBatchModel>> batchFlowJsonList(@PathVariable("id") String id) {
|
||||
List<String> taskIdList = flowTaskOperatorService.getBatchList().stream().map(FlowTaskOperatorEntity::getTaskId).collect(Collectors.toList());
|
||||
List<FlowTaskEntity> taskListAll = flowTaskService.getOrderStaList(taskIdList);
|
||||
List<String> flowIdList = taskListAll.stream().filter(t -> t.getTemplateId().equals(id)).map(FlowTaskEntity::getFlowId).collect(Collectors.toList());
|
||||
List<FlowTemplateJsonEntity> templateJsonList = flowTemplateJsonService.getTemplateJsonList(flowIdList);
|
||||
List<FlowBatchModel> listVO = new ArrayList<>();
|
||||
for (FlowTemplateJsonEntity entity : templateJsonList) {
|
||||
FlowBatchModel vo = JsonUtil.getJsonToBean(entity, FlowBatchModel.class);
|
||||
vo.setFullName(vo.getFullName() + "(v" + entity.getVersion() + ")");
|
||||
listVO.add(vo);
|
||||
}
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量审批
|
||||
*
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "批量审批")
|
||||
@PostMapping("/BatchOperation")
|
||||
@Parameters({
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult batchOperation(@RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowTaskNewService.batch(flowModel);
|
||||
return ActionResult.success(MsgCode.WF011.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取候选人
|
||||
*
|
||||
* @param flowId 流程主键
|
||||
* @param taskOperatorId 代办主键
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
@Operation(summary = "批量获取候选人")
|
||||
@GetMapping("/BatchCandidate")
|
||||
public ActionResult<FlowCandidateVO> batchCandidate(String flowId, String taskOperatorId) throws WorkFlowException {
|
||||
FlowModel flowModel = new FlowModel();
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowModel.setFlowId(flowId);
|
||||
FlowCandidateVO candidate = flowTaskNewService.batchCandidates(flowId, taskOperatorId, flowModel);
|
||||
return ActionResult.success(candidate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息跳转工作流
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "消息跳转工作流")
|
||||
@GetMapping("/{id}/Info")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult taskOperatorId(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTaskOperatorEntity operator = flowTaskOperatorService.getInfo(id);
|
||||
FlowTaskEntity flowTask = flowTaskService.getInfo(operator.getTaskId());
|
||||
FlowModel flowModel = new FlowModel();
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowTaskNewService.permissions(operator.getHandleId(), flowTask, operator, "", flowModel);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (!FlowNature.ProcessCompletion.equals(operator.getCompletion())) {
|
||||
map.put("isCheck", true);
|
||||
} else {
|
||||
map.put("isCheck", false);
|
||||
}
|
||||
return ActionResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点下拉框
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "节点下拉框")
|
||||
@GetMapping("/Selector/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<List<TaskNodeModel>> selector(@PathVariable("id") String id) {
|
||||
List<String> nodetype = ImmutableList.of(FlowNature.NodeStart, FlowNature.NodeSubFlow, FlowNature.EndRound);
|
||||
TaskNodeListModel nodeListModel = TaskNodeListModel.builder().id(id).state(FlowNodeEnum.Process.getCode()).build();
|
||||
List<FlowTaskNodeEntity> list = flowTaskNodeService.getList(nodeListModel,
|
||||
FlowTaskNodeEntity::getId, FlowTaskNodeEntity::getCandidates,
|
||||
FlowTaskNodeEntity::getCompletion, FlowTaskNodeEntity::getNodeType,
|
||||
FlowTaskNodeEntity::getNodeNext, FlowTaskNodeEntity::getNodeName,
|
||||
FlowTaskNodeEntity::getNodeCode, FlowTaskNodeEntity::getNodePropertyJson
|
||||
);
|
||||
flowTaskUtil.nodeList(list);
|
||||
list = list.stream().filter(t -> !nodetype.contains(t.getNodeType())).collect(Collectors.toList());
|
||||
List<TaskNodeModel> nodeList = JsonUtil.getJsonToList(list, TaskNodeModel.class);
|
||||
return ActionResult.success(nodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更或者复活
|
||||
*
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "变更或者复活")
|
||||
@PostMapping("/Change")
|
||||
@Parameters({
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult change(@RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
FlowTaskEntity info = flowTaskService.getInfo(flowModel.getTaskId());
|
||||
if (FlowTaskStatusEnum.Revoke.getCode().equals(info.getStatus()) || FlowTaskStatusEnum.Cancel.getCode().equals(info.getStatus()) || FlowTaskStatusEnum.Draft.getCode().equals(info.getStatus())) {
|
||||
throw new WorkFlowException(MsgCode.WF012.get());
|
||||
}
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowTaskNewService.change(flowModel);
|
||||
String msg = flowModel.getResurgence() ? MsgCode.WF013.get() : MsgCode.WF014.get();
|
||||
return ActionResult.success(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 子流程数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "子流程数据")
|
||||
@GetMapping("/SubFlowInfo/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<List<FlowBeforeInfoVO>> subFlowInfo(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTaskNodeEntity taskNode = flowTaskNodeService.getInfo(id, FlowTaskNodeEntity::getNodePropertyJson);
|
||||
List<FlowBeforeInfoVO> listVO = new ArrayList<>();
|
||||
if (taskNode != null) {
|
||||
ChildNodeList childNodeList = JsonUtil.getJsonToBean(taskNode.getNodePropertyJson(), ChildNodeList.class);
|
||||
List<String> flowTaskIdList = new ArrayList<>();
|
||||
flowTaskIdList.addAll(childNodeList.getCustom().getAsyncTaskList());
|
||||
flowTaskIdList.addAll(childNodeList.getCustom().getTaskId());
|
||||
for (String taskId : flowTaskIdList) {
|
||||
FlowModel flowModel = new FlowModel();
|
||||
flowModel.setId(taskId);
|
||||
FlowBeforeInfoVO vo = flowTaskNewService.getBeforeInfo(flowModel);
|
||||
listVO.add(vo);
|
||||
}
|
||||
}
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程类型下拉
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "流程类型下拉")
|
||||
@GetMapping("/Suspend/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult suspend(@PathVariable("id") String id) {
|
||||
List<FlowTaskEntity> childList = flowTaskService.getChildList(id, FlowTaskEntity::getId, FlowTaskEntity::getIsAsync);
|
||||
boolean isAsync = childList.stream().filter(t -> FlowNature.ChildAsync.equals(t.getIsAsync())).count() > 0;
|
||||
return ActionResult.success(isAsync);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程挂起
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "流程挂起")
|
||||
@PostMapping("/Suspend/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult suspend(@PathVariable("id") String id, @RequestBody FlowModel flowModel) {
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowTaskNewService.suspend(id, flowModel, true);
|
||||
return ActionResult.success(MsgCode.WF015.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程恢复
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "流程恢复")
|
||||
@PostMapping("/Restore/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult restore(@PathVariable("id") String id, @RequestBody FlowModel flowModel) {
|
||||
flowModel.setUserInfo(UserProvider.getUser());
|
||||
flowModel.setSuspend(false);
|
||||
flowTaskNewService.suspend(id, flowModel, false);
|
||||
return ActionResult.success(MsgCode.WF016.get());
|
||||
}
|
||||
|
||||
//递归处理默认当前配置
|
||||
private String setDefaultCurrentValue(String configJson, Map<String, Integer> havaDefaultCurrentValue, UserInfo userInfo) {
|
||||
if (StringUtil.isEmpty(configJson)) {
|
||||
return configJson;
|
||||
}
|
||||
Map<String, Object> configJsonMap = JsonUtil.stringToMap(configJson.trim());
|
||||
if (configJsonMap == null && configJsonMap.isEmpty()) {
|
||||
return configJson;
|
||||
}
|
||||
List<UserRelationEntity> userRelationList = serviceUtil.getListByUserIdAll(ImmutableList.of(userInfo.getUserId()));
|
||||
|
||||
int isChange = 0;
|
||||
//处理字段
|
||||
Object fieldsObj = configJsonMap.get("fields");
|
||||
List<Map<String, Object>> fieldsList = null;
|
||||
if (fieldsObj != null) {
|
||||
fieldsList = (List<Map<String, Object>>) fieldsObj;
|
||||
if (fieldsList != null && !fieldsList.isEmpty()) {
|
||||
setDefaultCurrentValue(userRelationList, fieldsList, userInfo, "add");
|
||||
configJsonMap.put("fields", fieldsList);
|
||||
isChange = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isChange == 1) {
|
||||
return JsonUtil.getObjectToString(configJsonMap);
|
||||
} else {
|
||||
return configJson;
|
||||
}
|
||||
}
|
||||
|
||||
private void setDefaultCurrentValue(List<UserRelationEntity> userRelationList, List<Map<String, Object>> itemList, UserInfo userInfo, String parseFlag) {
|
||||
for (int i = 0, len = itemList.size(); i < len; i++) {
|
||||
Map<String, Object> itemMap = itemList.get(i);
|
||||
if (itemMap == null || itemMap.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> configMap = (Map<String, Object>) itemMap.get("__config__");
|
||||
if (configMap == null || configMap.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
List<Map<String, Object>> childrenList = (List<Map<String, Object>>) configMap.get("children");
|
||||
if (childrenList != null && !childrenList.isEmpty()) {
|
||||
setDefaultCurrentValue(userRelationList, childrenList, userInfo, parseFlag);
|
||||
configMap = (Map<String, Object>) itemMap.get("__config__");
|
||||
}
|
||||
String yunzhupaasKey = (String) configMap.get("yunzhupaasKey");
|
||||
String defaultCurrent = String.valueOf(configMap.get("defaultCurrent"));
|
||||
if ("true".equals(defaultCurrent)) {
|
||||
Map<String, List<UserRelationEntity>> relationMap = userRelationList.stream().collect(Collectors.groupingBy(UserRelationEntity::getObjectType));
|
||||
Object data = "";
|
||||
switch (yunzhupaasKey) {
|
||||
case YunzhupaasKeyConsts.COMSELECT:
|
||||
data = new ArrayList() {{
|
||||
add(userInfo.getOrganizeId());
|
||||
}};
|
||||
break;
|
||||
case YunzhupaasKeyConsts.DEPSELECT:
|
||||
data = userInfo.getDepartmentId();
|
||||
break;
|
||||
case YunzhupaasKeyConsts.POSSELECT:
|
||||
data = userInfo.getPositionIds().length > 0 ? userInfo.getPositionIds()[0] : "";
|
||||
break;
|
||||
case YunzhupaasKeyConsts.USERSELECT:
|
||||
case YunzhupaasKeyConsts.CUSTOMUSERSELECT:
|
||||
data = YunzhupaasKeyConsts.CUSTOMUSERSELECT.equals(yunzhupaasKey) ? userInfo.getUserId() + "--" + PermissionConst.USER : userInfo.getUserId();
|
||||
break;
|
||||
case YunzhupaasKeyConsts.ROLESELECT:
|
||||
List<UserRelationEntity> roleList = relationMap.get(PermissionConst.ROLE) != null ? relationMap.get(PermissionConst.ROLE) : new ArrayList<>();
|
||||
data = roleList.size() > 0 ? roleList.get(0).getObjectId() : "";
|
||||
break;
|
||||
case YunzhupaasKeyConsts.GROUPSELECT:
|
||||
List<UserRelationEntity> groupList = relationMap.get(PermissionConst.GROUP) != null ? relationMap.get(PermissionConst.GROUP) : new ArrayList<>();
|
||||
data = groupList.size() > 0 ? groupList.get(0).getObjectId() : "";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(data);
|
||||
if ("search".equals(parseFlag)) {
|
||||
String searchMultiple = String.valueOf(itemMap.get("searchMultiple"));
|
||||
if ("true".equals(searchMultiple)) {
|
||||
configMap.put("defaultValue", list);
|
||||
} else {
|
||||
configMap.put("defaultValue", data);
|
||||
}
|
||||
} else {
|
||||
String multiple = String.valueOf(itemMap.get("multiple"));
|
||||
if ("true".equals(multiple)) {
|
||||
configMap.put("defaultValue", list);
|
||||
} else {
|
||||
configMap.put("defaultValue", data);
|
||||
}
|
||||
}
|
||||
itemMap.put("__config__", configMap);
|
||||
itemList.set(i, itemMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程所关联的用户信息
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @param flowTaskUserListModel 查询模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程所关联的用户信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "taskId", description = "任务ID", required = true),
|
||||
@Parameter(name = "flowTaskUserListModel", description = "查询模型", required = true)
|
||||
})
|
||||
@GetMapping("/TaskUserList/{taskId}")
|
||||
public ActionResult getTaskUserList(@PathVariable("taskId") String taskId, FlowTaskUserListModel flowTaskUserListModel) throws WorkFlowException {
|
||||
FlowUserListModel flowUserListModel = flowTaskUtil.getTaskUserList(taskId);
|
||||
List<UserIdListVo> jsonToList = userService.getObjList(flowUserListModel.getAllUserIdList(), flowTaskUserListModel, null);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(flowTaskUserListModel, PaginationVO.class);
|
||||
return ActionResult.page(jsonToList, paginationVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,396 @@
|
||||
package com.yunzhupaas.engine.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.engine.entity.*;
|
||||
import com.yunzhupaas.engine.model.flowbefore.FlowUserListModel;
|
||||
import com.yunzhupaas.engine.model.flowcomment.FlowCommentForm;
|
||||
import com.yunzhupaas.engine.model.flowcomment.FlowCommentInfoVO;
|
||||
import com.yunzhupaas.engine.model.flowcomment.FlowCommentListVO;
|
||||
import com.yunzhupaas.engine.model.flowcomment.FlowCommentPagination;
|
||||
import com.yunzhupaas.engine.model.flowengine.FlowModel;
|
||||
import com.yunzhupaas.engine.model.flowengine.shuntjson.childnode.MsgConfig;
|
||||
import com.yunzhupaas.engine.model.flowengine.shuntjson.nodejson.ChildNodeList;
|
||||
import com.yunzhupaas.engine.model.flowmessage.FlowMsgModel;
|
||||
import com.yunzhupaas.engine.service.FlowCommentService;
|
||||
import com.yunzhupaas.engine.service.FlowTaskNodeService;
|
||||
import com.yunzhupaas.engine.util.FlowMsgUtil;
|
||||
import com.yunzhupaas.engine.util.FlowNature;
|
||||
import com.yunzhupaas.engine.util.FlowTaskUtil;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 流程评论
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
*/
|
||||
@Tag(name = "流程评论", description = "Comment")
|
||||
@RestController
|
||||
@RequestMapping("/api/workflow1/Engine/FlowComment")
|
||||
public class FlowCommentController extends SuperController<FlowCommentService, FlowCommentEntity> {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ServiceAllUtil serviceUtil;
|
||||
|
||||
@Autowired
|
||||
private FlowCommentService flowCommentService;
|
||||
@Autowired
|
||||
private FlowTaskNodeService flowTaskNodeService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private FlowTaskUtil flowTaskUtil;
|
||||
@Autowired
|
||||
private FlowMsgUtil flowMsgUtil;
|
||||
|
||||
/**
|
||||
* 获取流程评论列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程评论列表")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<FlowCommentListVO>> list(FlowCommentPagination pagination) {
|
||||
List<FlowCommentEntity> list = flowCommentService.getlist(pagination);
|
||||
List<FlowCommentListVO> listVO = new ArrayList<>();
|
||||
List<String> userId = list.stream().map(t -> t.getCreatorUserId()).collect(Collectors.toList());
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<UserEntity> userName = serviceUtil.getUserName(userId);
|
||||
for (FlowCommentEntity flowCommentEntity : list) {
|
||||
FlowCommentListVO vo = JsonUtil.getJsonToBean(flowCommentEntity, FlowCommentListVO.class);
|
||||
UserEntity userEntity = userName.stream().filter(t -> t.getId().equals(flowCommentEntity.getCreatorUserId())).findFirst().orElse(null);
|
||||
if(flowCommentEntity.getCreatorUserId().equals(userInfo.getUserId()) && !"1".equals(String.valueOf(flowCommentEntity.getDeleteShow()))) {
|
||||
vo.setIsDel(1); //1-删除按钮显示
|
||||
}else if("1".equals(String.valueOf(flowCommentEntity.getDeleteShow()))) {
|
||||
vo.setIsDel(2); //1-删除按钮显示
|
||||
vo.setText("该评论已被删除");
|
||||
}else{
|
||||
vo.setIsDel(0);
|
||||
}
|
||||
vo.setCreatorUser(userEntity != null ? userEntity.getRealName() + "/" + userEntity.getAccount() : "");
|
||||
vo.setCreatorUserHeadIcon(userEntity != null ? UploaderUtil.uploaderImg(userEntity.getHeadIcon()) : vo.getCreatorUserHeadIcon());
|
||||
if(StringUtil.isNotEmpty(flowCommentEntity.getReplyId())) {
|
||||
FlowCommentEntity replyEntity = list.stream().filter(t-> t.getId().equals(flowCommentEntity.getReplyId())).findFirst().orElse(null);
|
||||
if(replyEntity == null) {
|
||||
replyEntity = flowCommentService.getInfo(flowCommentEntity.getReplyId());
|
||||
}
|
||||
if(replyEntity != null) {
|
||||
FlowCommentEntity finalReplyEntity = replyEntity;
|
||||
UserEntity replyUserEntity = userName.stream().filter(t -> t.getId().equals(finalReplyEntity.getCreatorUserId())).findFirst().orElse(null);
|
||||
vo.setReplyUser(userEntity != null ? replyUserEntity.getRealName() + "/" + replyUserEntity.getAccount() : "");
|
||||
vo.setReplyText(("1".equals(String.valueOf(replyEntity.getDeleteShow())) || "1".equals(String.valueOf(replyEntity.getDeleteMark()))) ? "该评论已被删除": replyEntity.getText());
|
||||
}
|
||||
}
|
||||
listVO.add(vo);
|
||||
}
|
||||
PaginationVO vo = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(listVO, vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程评论信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程评论信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<FlowCommentInfoVO> info(@PathVariable("id") String id) {
|
||||
FlowCommentEntity entity = flowCommentService.getInfo(id);
|
||||
FlowCommentInfoVO vo = JsonUtil.getJsonToBean(entity, FlowCommentInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建流程评论
|
||||
*
|
||||
* @param commentForm 流程评论模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建流程评论")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "commentForm", description = "流程评论模型", required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody @Valid FlowCommentForm commentForm) throws DataException, WorkFlowException {
|
||||
FlowCommentEntity entity = JsonUtil.getJsonToBean(commentForm, FlowCommentEntity.class);
|
||||
flowCommentService.create(entity);
|
||||
|
||||
//发送提醒消息
|
||||
this.sendCommentMsg(entity);
|
||||
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新流程评论
|
||||
*
|
||||
* @param id 主键
|
||||
* @param commentForm 流程评论模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新流程评论")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "commentForm", description = "流程评论模型", required = true),
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid FlowCommentForm commentForm) throws DataException {
|
||||
FlowCommentEntity info = flowCommentService.getInfo(id);
|
||||
if (info != null) {
|
||||
FlowCommentEntity entity = JsonUtil.getJsonToBean(commentForm, FlowCommentEntity.class);
|
||||
entity.setDeleteShow(info.getDeleteShow());
|
||||
flowCommentService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程评论
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除流程评论")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@Transactional
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
FlowCommentEntity entity = flowCommentService.getInfo(id);
|
||||
if (entity.getCreatorUserId().equals(UserProvider.getUser().getUserId())) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
boolean isDeleteShow = false;
|
||||
ChildNodeList childNodeList = this.getCommentChildNodeList(entity.getTaskId());
|
||||
if(childNodeList != null && childNodeList.getProperties().getIsShowDelComment() != null && childNodeList.getProperties().getIsShowDelComment()) {
|
||||
isDeleteShow = true;
|
||||
}
|
||||
if(isDeleteShow) {
|
||||
entity.setDeleteShow(1);
|
||||
entity.setDeleteTime(new Date());
|
||||
entity.setDeleteUserId(userInfo.getUserId());
|
||||
flowCommentService.updateById(entity);
|
||||
}else{
|
||||
entity.setDeleteMark(1);
|
||||
entity.setDeleteTime(new Date());
|
||||
entity.setDeleteUserId(userInfo.getUserId());
|
||||
flowCommentService.updateById(entity);
|
||||
// List<FlowCommentEntity> deleteList = new ArrayList<>();
|
||||
// deleteList.add(entity);
|
||||
// List<String> deleteIdList = deleteList.stream().map(t-> t.getId()).collect(Collectors.toList());
|
||||
// this.getDeleteList(deleteList, deleteIdList);
|
||||
// for(FlowCommentEntity each : deleteList) {
|
||||
// flowCommentService.delete(each);
|
||||
// }
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
//递归查询下级
|
||||
private void getDeleteList(List<FlowCommentEntity> allDeleteList, List<String> parentIdList) {
|
||||
if(parentIdList == null || parentIdList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QueryWrapper<FlowCommentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(FlowCommentEntity::getReplyId, parentIdList);
|
||||
List<FlowCommentEntity> childrenList = flowCommentService.list(queryWrapper);
|
||||
if(childrenList == null || childrenList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
parentIdList = childrenList.stream().map(t-> t.getId()).collect(Collectors.toList());
|
||||
allDeleteList.addAll(childrenList);
|
||||
this.getDeleteList(allDeleteList, parentIdList);
|
||||
}
|
||||
|
||||
|
||||
private ChildNodeList getCommentChildNodeList(String taskId) {
|
||||
if(StringUtil.isEmpty(taskId)) {
|
||||
return null;
|
||||
}
|
||||
QueryWrapper<FlowTaskNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTaskNodeEntity::getTaskId, taskId);
|
||||
queryWrapper.lambda().eq(FlowTaskNodeEntity::getNodeType, FlowNature.NodeStart);
|
||||
queryWrapper.lambda().orderByDesc(FlowTaskNodeEntity::getCreatorTime);
|
||||
queryWrapper.lambda().select(FlowTaskNodeEntity::getNodePropertyJson);
|
||||
List<FlowTaskNodeEntity> startNodeList = flowTaskNodeService.list(queryWrapper);
|
||||
if(startNodeList != null && !startNodeList.isEmpty()) {
|
||||
FlowTaskNodeEntity flowNode = startNodeList.get(0);
|
||||
ChildNodeList childNodeList = JsonUtil.getJsonToBean(flowNode.getNodePropertyJson(), ChildNodeList.class);
|
||||
return childNodeList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//发送提醒消息
|
||||
private void sendCommentMsg(FlowCommentEntity flowCommentEntity) throws WorkFlowException {
|
||||
//发消息
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
//不包含@{ 且 回复ID为空 (不发消息)
|
||||
if((StringUtil.isEmpty(flowCommentEntity.getText()) || !flowCommentEntity.getText().contains("@{")) && StringUtil.isEmpty(flowCommentEntity.getReplyId())) {
|
||||
return;
|
||||
}
|
||||
ChildNodeList startChildNodeList = this.getCommentChildNodeList(flowCommentEntity.getTaskId());
|
||||
if(startChildNodeList == null || startChildNodeList.getProperties() == null || startChildNodeList.getProperties().getCommentMsgConfig() == null || startChildNodeList.getProperties().getCommentMsgConfig().getOn() == null) {
|
||||
return;
|
||||
}
|
||||
MsgConfig commentMsgConfig = startChildNodeList.getProperties().getCommentMsgConfig();
|
||||
if(commentMsgConfig.getOn() != 1 && commentMsgConfig.getOn() != 3) {
|
||||
return;
|
||||
}
|
||||
Set<String> userIdSet = new HashSet<>();
|
||||
//回复
|
||||
if(StringUtil.isNotEmpty(flowCommentEntity.getReplyId())) {
|
||||
FlowCommentEntity replyEntity = flowCommentService.getInfo(flowCommentEntity.getReplyId());
|
||||
if(replyEntity != null && StringUtil.isNotEmpty(replyEntity.getCreatorUserId())) {
|
||||
userIdSet.add(replyEntity.getCreatorUserId());
|
||||
}
|
||||
}
|
||||
//@
|
||||
if(StringUtil.isNotEmpty(flowCommentEntity.getText()) && flowCommentEntity.getText().contains("@{")) {
|
||||
String[] textArray = flowCommentEntity.getText().split("@\\{");
|
||||
List<String> accountList = new ArrayList<>();
|
||||
for(int i = 0; i<textArray.length; i ++) {
|
||||
if(i == 0) {
|
||||
continue;
|
||||
}
|
||||
if(!textArray[i].trim().contains("}")) {
|
||||
continue;
|
||||
}
|
||||
String nameAndAccount = textArray[i].substring(0, textArray[i].indexOf("}"));
|
||||
if(nameAndAccount.contains("/") && !nameAndAccount.trim().startsWith("/") && !nameAndAccount.trim().endsWith("/")) {
|
||||
String[] nameAndAccountArray = nameAndAccount.split("/");
|
||||
if(nameAndAccountArray.length != 2) {
|
||||
continue;
|
||||
}
|
||||
accountList.add(nameAndAccountArray[1].trim());
|
||||
}
|
||||
}
|
||||
if(accountList != null && !accountList.isEmpty()) {
|
||||
QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(UserEntity::getAccount, accountList);
|
||||
queryWrapper.lambda().select(UserEntity::getId);
|
||||
List<UserEntity> list = userService.list(queryWrapper);
|
||||
userIdSet.addAll(list.stream().map(t-> t.getId()).collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
//过滤自己
|
||||
Set<String> finalUserIdSet = userIdSet;
|
||||
userIdSet = userIdSet.stream().filter(t-> !finalUserIdSet.contains(userInfo.getUserId())).collect(Collectors.toSet());
|
||||
|
||||
if(userIdSet.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
FlowUserListModel flowUserListModel = flowTaskUtil.getTaskUserList(flowCommentEntity.getTaskId());
|
||||
userIdSet.retainAll(flowUserListModel.getAllUserIdList()); //取交集
|
||||
if(userIdSet.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> noAddUserIdList = new HashSet<>(userIdSet);
|
||||
//审批人
|
||||
List<FlowTaskOperatorEntity> operatorList = new ArrayList<>(); //审批人
|
||||
// List<FlowOperatorUserEntity> operatorUserList = new ArrayList<>(); //依次审批人
|
||||
List<FlowTaskCirculateEntity> circulateList = new ArrayList<>(); //抄送人
|
||||
List<FlowTaskOperatorRecordEntity> operatorRecordList = new ArrayList<>(); //已办数据
|
||||
String startHandId = null; //发起人
|
||||
|
||||
//审批人
|
||||
if(!noAddUserIdList.isEmpty()) {
|
||||
for(FlowTaskOperatorEntity each : flowUserListModel.getOperatorList()) {
|
||||
if(noAddUserIdList.contains(each.getHandleId())) {
|
||||
operatorList.add(each);
|
||||
noAddUserIdList.remove(each.getHandleId());
|
||||
}
|
||||
}
|
||||
}
|
||||
//依次审批人
|
||||
// if(!noAddUserIdList.isEmpty()) {
|
||||
// for (FlowOperatorUserEntity each : flowUserListModel.getOperatorUserList()) {
|
||||
// if (noAddUserIdList.contains(each.getHandleId())) {
|
||||
// operatorUserList.add(each);
|
||||
// noAddUserIdList.remove(each.getHandleId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//抄送人
|
||||
if(!noAddUserIdList.isEmpty()) {
|
||||
for (FlowTaskCirculateEntity each : flowUserListModel.getCirculateList()) {
|
||||
if (noAddUserIdList.contains(each.getObjectId())) {
|
||||
circulateList.add(each);
|
||||
noAddUserIdList.remove(each.getObjectId());
|
||||
}
|
||||
}
|
||||
}
|
||||
//发起人
|
||||
if(!noAddUserIdList.isEmpty()) {
|
||||
if(noAddUserIdList.contains(flowUserListModel.getFlowTask().getCreatorUserId())) {
|
||||
startHandId = flowUserListModel.getFlowTask().getCreatorUserId();
|
||||
}
|
||||
}
|
||||
|
||||
//已办记录
|
||||
if(!noAddUserIdList.isEmpty()) {
|
||||
for (FlowTaskOperatorRecordEntity each : flowUserListModel.getOperatorRecordList()) {
|
||||
if(noAddUserIdList.contains(each.getHandleId())) {
|
||||
operatorRecordList.add(each);
|
||||
noAddUserIdList.remove(each.getHandleId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//节点集合
|
||||
QueryWrapper<FlowTaskNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTaskNodeEntity::getTaskId, flowCommentEntity.getTaskId());
|
||||
queryWrapper.lambda().eq(FlowTaskNodeEntity::getState, 0);
|
||||
queryWrapper.lambda().orderByDesc(FlowTaskNodeEntity::getCreatorTime);
|
||||
List<FlowTaskNodeEntity> nodeList = flowTaskNodeService.list(queryWrapper);
|
||||
//构造消息
|
||||
FlowMsgModel flowMsgModel = new FlowMsgModel();
|
||||
flowMsgModel.setTaskEntity(flowUserListModel.getFlowTask());
|
||||
flowMsgModel.setNodeList(nodeList);
|
||||
flowMsgModel.setOperatorList(operatorList);
|
||||
flowMsgModel.setCirculateList(circulateList);
|
||||
flowMsgModel.setOperatorRecordList(operatorRecordList);
|
||||
flowMsgModel.setStartHandId(startHandId);
|
||||
FlowModel flowModel = new FlowModel();
|
||||
flowModel.setUserInfo(userInfo);
|
||||
flowMsgModel.setFlowModel(flowModel);
|
||||
flowMsgModel.setWait(false);
|
||||
flowMsgModel.setComment(true);
|
||||
//发送消息
|
||||
flowMsgUtil.message(flowMsgModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
package com.yunzhupaas.engine.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.engine.entity.FlowDelegateEntity;
|
||||
import com.yunzhupaas.engine.model.flowcandidate.FlowCandidateUserModel;
|
||||
import com.yunzhupaas.engine.model.flowdelegate.*;
|
||||
import com.yunzhupaas.engine.model.flowengine.FlowPagination;
|
||||
import com.yunzhupaas.engine.model.flowtemplate.FlowPageListVO;
|
||||
import com.yunzhupaas.engine.service.FlowDelegateService;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.JsonUtilEx;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程委托
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "流程委托", description = "FlowDelegate")
|
||||
@RestController
|
||||
@RequestMapping("/api/workflow1/Engine/FlowDelegate")
|
||||
public class FlowDelegateController extends SuperController<FlowDelegateService, FlowDelegateEntity> {
|
||||
|
||||
@Autowired
|
||||
private FlowDelegateService flowDelegateService;
|
||||
|
||||
/**
|
||||
* 获取流程委托列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程委托列表")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<FlowDelegatListVO>> list(FlowDelegatePagination pagination) {
|
||||
List<FlowDelegateEntity> list = flowDelegateService.getList(pagination);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
List<FlowDelegatListVO> listVO = JsonUtil.getJsonToList(list, FlowDelegatListVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程委托信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程委托信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<FlowDelegateInfoVO> info(@PathVariable("id") String id) throws DataException {
|
||||
FlowDelegateEntity entity = flowDelegateService.getInfo(id);
|
||||
FlowDelegateInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity, FlowDelegateInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建流程委托
|
||||
*
|
||||
* @param flowDelegateCrForm 委托模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建流程委托")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "flowDelegateCrForm", description = "委托模型", required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody @Valid FlowDelegateCrForm flowDelegateCrForm) {
|
||||
FlowDelegateEntity entity = JsonUtil.getJsonToBean(flowDelegateCrForm, FlowDelegateEntity.class);
|
||||
if (entity.getUserId().equals(entity.getToUserId())) {
|
||||
return ActionResult.fail(MsgCode.WF017.get());
|
||||
}
|
||||
if (alreadyDelegate(flowDelegateCrForm, null)) {
|
||||
return ActionResult.fail(MsgCode.WF018.get());
|
||||
}
|
||||
FlowDelegateCrForm flowReverse = new FlowDelegateCrForm();
|
||||
BeanUtils.copyProperties(flowDelegateCrForm, flowReverse);
|
||||
flowReverse.setUserId(flowDelegateCrForm.getToUserId());
|
||||
flowReverse.setToUserId(flowDelegateCrForm.getUserId());
|
||||
if (alreadyDelegate(flowReverse, null)) {
|
||||
return ActionResult.fail(MsgCode.WF019.get());
|
||||
}
|
||||
flowDelegateService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否已有委托
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/10/28
|
||||
*/
|
||||
private boolean alreadyDelegate(FlowDelegateCrForm flowDelegateCrForm, String id) {
|
||||
List<FlowDelegateEntity> flowDelegateEntities = flowDelegateService.selectSameParamAboutDelaget(flowDelegateCrForm);
|
||||
for (FlowDelegateEntity delegate : flowDelegateEntities) {
|
||||
if (delegate.getId().equals(id)) {
|
||||
continue;
|
||||
}
|
||||
//时间交叉
|
||||
if ((flowDelegateCrForm.getStartTime() <= delegate.getStartTime().getTime() && flowDelegateCrForm.getEndTime() >= delegate.getStartTime().getTime()) ||
|
||||
(flowDelegateCrForm.getStartTime() >= delegate.getStartTime().getTime() && flowDelegateCrForm.getStartTime() <= delegate.getEndTime().getTime())) {
|
||||
if (StringUtil.isEmpty(flowDelegateCrForm.getFlowId())) {
|
||||
return true;
|
||||
} else {
|
||||
if (StringUtil.isEmpty(delegate.getFlowId())) {
|
||||
return true;
|
||||
} else {
|
||||
List<String> split = Arrays.asList(delegate.getFlowId().split(","));
|
||||
List<String> split1 = Arrays.asList(flowDelegateCrForm.getFlowId().split(","));
|
||||
for (String srt : split) {
|
||||
if (split1.contains(srt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新流程委托
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param flowDelegateUpForm 委托模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新流程委托")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowDelegateUpForm", description = "委托模型", required = true),
|
||||
})
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid FlowDelegateUpForm flowDelegateUpForm) {
|
||||
FlowDelegateEntity entity = JsonUtil.getJsonToBean(flowDelegateUpForm, FlowDelegateEntity.class);
|
||||
if (entity.getUserId().equals(entity.getToUserId())) {
|
||||
return ActionResult.fail(MsgCode.WF017.get());
|
||||
}
|
||||
|
||||
if (alreadyDelegate(flowDelegateUpForm, id)) {
|
||||
return ActionResult.fail(MsgCode.WF018.get());
|
||||
}
|
||||
FlowDelegateCrForm flowReverse = new FlowDelegateCrForm();
|
||||
BeanUtils.copyProperties(flowDelegateUpForm, flowReverse);
|
||||
flowReverse.setUserId(flowDelegateUpForm.getToUserId());
|
||||
flowReverse.setToUserId(flowDelegateUpForm.getUserId());
|
||||
if (alreadyDelegate(flowReverse, id)) {
|
||||
return ActionResult.fail(MsgCode.WF019.get());
|
||||
}
|
||||
boolean flag = flowDelegateService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.success(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止流程引擎
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "结束委托")
|
||||
@PutMapping("/Stop/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult stop(@PathVariable("id") String id) {
|
||||
FlowDelegateEntity entity = flowDelegateService.getInfo(id);
|
||||
if (entity != null) {
|
||||
Date date = new Date();
|
||||
entity.setStartTime(date);
|
||||
entity.setEndTime(date);
|
||||
flowDelegateService.updateStop(id, entity);
|
||||
return ActionResult.success(MsgCode.SU008.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程委托
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除流程委托")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
FlowDelegateEntity entity = flowDelegateService.getInfo(id);
|
||||
if (entity != null) {
|
||||
flowDelegateService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 被委托审核
|
||||
* 根据流程id和委托人id=查询被委托人
|
||||
*
|
||||
* @param flowId 流程主键
|
||||
* @param userId 用户主键
|
||||
* @param touserId 用户主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "被委托审核")
|
||||
@GetMapping("/getuser")
|
||||
@Parameters({
|
||||
@Parameter(name = "flowId", description = "流程主键", required = true),
|
||||
@Parameter(name = "userId", description = "用户主键"),
|
||||
@Parameter(name = "touserId", description = "用户主键"),
|
||||
})
|
||||
public ActionResult getuser(@RequestParam("flowId") String flowId, @RequestParam("userId") String userId, @RequestParam("touserId") String touserId) {
|
||||
flowDelegateService.getUser(userId, flowId, touserId);
|
||||
return ActionResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 被委托发起
|
||||
* 根据被委托人查询可发起的流程列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "被委托发起")
|
||||
@GetMapping("/getflow")
|
||||
public ActionResult<PageListVO<FlowPageListVO>> getflow(FlowPagination pagination) {
|
||||
List<FlowPageListVO> getflow = flowDelegateService.getflow(pagination);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
List<FlowPageListVO> listVO = JsonUtil.getJsonToList(getflow, FlowPageListVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取委托人
|
||||
* 根据被委托人查询可发起的流程列表
|
||||
*
|
||||
* @Param flowId 流程主键
|
||||
*/
|
||||
@Operation(summary = "获取委托人")
|
||||
@GetMapping("/userList")
|
||||
@Parameters({
|
||||
@Parameter(name = "flowId", description = "流程主键", required = true),
|
||||
})
|
||||
public ActionResult<ListVO<FlowCandidateUserModel>> getUserListByFlowId(@RequestParam("flowId") String flowId) throws WorkFlowException {
|
||||
ListVO<FlowCandidateUserModel> userListByFlowId = flowDelegateService.getUserListByFlowId(flowId);
|
||||
return ActionResult.success(userListByFlowId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.yunzhupaas.engine.controller;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.engine.entity.FlowTaskEntity;
|
||||
import com.yunzhupaas.engine.model.flowengine.FlowModel;
|
||||
import com.yunzhupaas.engine.model.flowlaunch.FlowLaunchListVO;
|
||||
import com.yunzhupaas.engine.model.flowtask.PaginationFlowTask;
|
||||
import com.yunzhupaas.engine.service.FlowTaskNewService;
|
||||
import com.yunzhupaas.engine.service.FlowTaskService;
|
||||
import com.yunzhupaas.engine.util.FlowNature;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 流程发起
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "流程发起", description = "FlowLaunch")
|
||||
@RestController
|
||||
@RequestMapping("/api/workflow1/Engine/FlowLaunch")
|
||||
public class FlowLaunchController {
|
||||
|
||||
@Autowired
|
||||
private FlowTaskService flowTaskService;
|
||||
|
||||
@Autowired
|
||||
private FlowTaskNewService flowTaskNewService;
|
||||
|
||||
/**
|
||||
* 获取流程发起列表
|
||||
*
|
||||
* @param paginationFlowTask 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程发起列表(带分页)")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<FlowLaunchListVO>> list(PaginationFlowTask paginationFlowTask) {
|
||||
List<FlowTaskEntity> list = flowTaskService.getLaunchList(paginationFlowTask);
|
||||
List<FlowLaunchListVO> listVO = JsonUtil.getJsonToList(list, FlowLaunchListVO.class);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationFlowTask, PaginationVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程发起
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除流程发起")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTaskEntity entity = flowTaskService.getInfo(id, FlowTaskEntity::getId,
|
||||
FlowTaskEntity::getParentId, FlowTaskEntity::getFlowType, FlowTaskEntity::getFullName,
|
||||
FlowTaskEntity::getStatus
|
||||
);
|
||||
if (entity != null) {
|
||||
if (Objects.equals(entity.getFlowType(), 1)) {
|
||||
return ActionResult.fail(MsgCode.WF020.get());
|
||||
}
|
||||
if (!FlowNature.ParentId.equals(entity.getParentId()) && StringUtil.isNotEmpty(entity.getParentId())) {
|
||||
return ActionResult.fail(entity.getFullName() + MsgCode.WF021.get());
|
||||
}
|
||||
if(!Objects.equals(entity.getCreatorUserId(), UserProvider.getLoginUserId())){
|
||||
return ActionResult.fail(MsgCode.FA021.get());
|
||||
}
|
||||
flowTaskService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 待我审核催办
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "发起催办")
|
||||
@PostMapping("/Press/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult press(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowModel flowModel = new FlowModel();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
flowModel.setUserInfo(userInfo);
|
||||
boolean flag = flowTaskNewService.press(id, flowModel);
|
||||
if (flag) {
|
||||
return ActionResult.success(MsgCode.WF022.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.WF023.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回流程发起
|
||||
* 注意:在撤销流程时要保证你的下一节点没有处理这条记录;如已处理则无法撤销流程。
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "撤回流程发起")
|
||||
@PutMapping("/{id}/Actions/Withdraw")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult revoke(@PathVariable("id") String id, @RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
flowModel.setUserInfo(userInfo);
|
||||
flowTaskNewService.revoke(ImmutableList.of(id), flowModel, true);
|
||||
return ActionResult.success(MsgCode.WF008.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.yunzhupaas.engine.controller;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.entity.DataInterfaceEntity;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.engine.entity.FlowEventLogEntity;
|
||||
import com.yunzhupaas.engine.entity.FlowTaskEntity;
|
||||
import com.yunzhupaas.engine.model.flowmonitor.FlowEventLogListVO;
|
||||
import com.yunzhupaas.engine.model.flowmonitor.FlowMonitorListVO;
|
||||
import com.yunzhupaas.engine.model.flowtask.FlowAssistModel;
|
||||
import com.yunzhupaas.engine.model.flowtask.PaginationFlowTask;
|
||||
import com.yunzhupaas.engine.service.FlowEventLogService;
|
||||
import com.yunzhupaas.engine.service.FlowTaskService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.ServiceAllUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 流程监控
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "流程监控", description = "FlowMonitor")
|
||||
@RestController
|
||||
@RequestMapping("/api/workflow1/Engine/FlowMonitor")
|
||||
public class FlowMonitorController {
|
||||
|
||||
@Autowired
|
||||
private FlowTaskService flowTaskService;
|
||||
@Autowired
|
||||
private ServiceAllUtil serviceUtil;
|
||||
@Autowired
|
||||
private FlowEventLogService flowEventLogService;
|
||||
|
||||
/**
|
||||
* 获取流程监控列表
|
||||
*
|
||||
* @param paginationFlowTask 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程监控列表")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<FlowMonitorListVO>> list(PaginationFlowTask paginationFlowTask) {
|
||||
List<FlowTaskEntity> list = flowTaskService.getMonitorList(paginationFlowTask);
|
||||
List<UserEntity> userList = serviceUtil.getUserName(list.stream().map(t -> t.getCreatorUserId()).collect(Collectors.toList()));
|
||||
List<FlowMonitorListVO> listVO = new LinkedList<>();
|
||||
for (FlowTaskEntity taskEntity : list) {
|
||||
//用户名称赋值
|
||||
FlowMonitorListVO vo = JsonUtil.getJsonToBean(taskEntity, FlowMonitorListVO.class);
|
||||
UserEntity user = userList.stream().filter(t -> t.getId().equals(taskEntity.getCreatorUserId())).findFirst().orElse(null);
|
||||
vo.setUserName(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
listVO.add(vo);
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationFlowTask, PaginationVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除流程监控
|
||||
*
|
||||
* @param assistModel 流程删除模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "批量删除流程监控")
|
||||
@DeleteMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "assistModel", description = "流程删除模型", required = true),
|
||||
})
|
||||
public ActionResult delete(@RequestBody FlowAssistModel assistModel) throws WorkFlowException {
|
||||
String[] taskId = assistModel.getIds().split(",");
|
||||
flowTaskService.delete(taskId);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取事件日志列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取事件日志列表")
|
||||
@GetMapping("/{id}/EventLog")
|
||||
public ActionResult getEventLog(@PathVariable("id") String id) {
|
||||
List<FlowEventLogEntity> logList = flowEventLogService.getList(ImmutableList.of(id));
|
||||
List<String> interfaceIdList = logList.stream().map(FlowEventLogEntity::getInterfaceId).collect(Collectors.toList());
|
||||
List<DataInterfaceEntity> interfaceList = serviceUtil.getInterfaceList(interfaceIdList);
|
||||
List<FlowEventLogListVO> list = new ArrayList<>();
|
||||
for (FlowEventLogEntity logEntity : logList) {
|
||||
FlowEventLogListVO listVO = JsonUtil.getJsonToBean(logEntity, FlowEventLogListVO.class);
|
||||
DataInterfaceEntity dataInterface = interfaceList.stream().filter(t -> t.getId().equals(listVO.getInterfaceId())).findFirst().orElse(null);
|
||||
if (dataInterface != null) {
|
||||
listVO.setInterfaceCode(dataInterface.getEnCode());
|
||||
listVO.setInterfaceName(dataInterface.getFullName());
|
||||
}
|
||||
list.add(listVO);
|
||||
}
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.yunzhupaas.engine.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.engine.entity.FlowTaskEntity;
|
||||
import com.yunzhupaas.engine.enums.FlowStatusEnum;
|
||||
import com.yunzhupaas.engine.model.flowengine.FlowModel;
|
||||
import com.yunzhupaas.engine.service.FlowDynamicService;
|
||||
import com.yunzhupaas.engine.service.FlowTaskService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import com.yunzhupaas.util.context.RequestContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 流程引擎
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "流程引擎", description = "FlowTask")
|
||||
@RestController
|
||||
@RequestMapping("/api/workflow1/Engine/FlowTask")
|
||||
public class FlowTaskController extends SuperController<FlowTaskService, FlowTaskEntity> {
|
||||
|
||||
|
||||
@Autowired
|
||||
private FlowTaskService flowTaskService;
|
||||
@Autowired
|
||||
private FlowDynamicService flowDynamicService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "保存")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult save(@RequestBody FlowModel flowModel) throws WorkFlowException {
|
||||
boolean isApp = !RequestContext.isOrignPc();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
flowModel.setUserInfo(userInfo);
|
||||
flowModel.setSystemId(isApp ? userInfo.getSystemId() : userInfo.getAppSystemId());
|
||||
flowDynamicService.batchCreateOrUpdate(flowModel);
|
||||
String msg = FlowStatusEnum.save.getMessage().equals(flowModel.getStatus()) ? MsgCode.SU002.get() : MsgCode.SU006.get();
|
||||
return ActionResult.success(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "提交")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "flowModel", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult submit(@RequestBody FlowModel flowModel, @PathVariable("id") String id) throws WorkFlowException {
|
||||
boolean isApp = !RequestContext.isOrignPc();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
flowModel.setId(id);
|
||||
flowModel.setUserInfo(userInfo);
|
||||
flowModel.setSystemId(isApp ? userInfo.getSystemId() : userInfo.getAppSystemId());
|
||||
FlowTaskEntity infoSubmit = flowTaskService.getInfoSubmit(id,FlowTaskEntity::getCreatorUserId);
|
||||
if (infoSubmit != null && !Objects.equals(infoSubmit.getCreatorUserId(), userInfo.getUserId())) {
|
||||
return ActionResult.fail(MsgCode.FA021.get());
|
||||
}
|
||||
flowDynamicService.batchCreateOrUpdate(flowModel);
|
||||
String msg = FlowStatusEnum.save.getMessage().equals(flowModel.getStatus()) ? MsgCode.SU002.get() : MsgCode.SU006.get();
|
||||
return ActionResult.success(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,583 @@
|
||||
package com.yunzhupaas.engine.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.emnus.ModuleTypeEnum;
|
||||
import com.yunzhupaas.engine.entity.FlowEngineVisibleEntity;
|
||||
import com.yunzhupaas.engine.entity.FlowTaskEntity;
|
||||
import com.yunzhupaas.engine.entity.FlowTemplateEntity;
|
||||
import com.yunzhupaas.engine.entity.FlowTemplateJsonEntity;
|
||||
import com.yunzhupaas.engine.model.flowbefore.FlowFormVo;
|
||||
import com.yunzhupaas.engine.model.flowengine.FlowPagination;
|
||||
import com.yunzhupaas.engine.model.flowengine.shuntjson.childnode.ChildNode;
|
||||
import com.yunzhupaas.engine.model.flowtask.FlowAssistModel;
|
||||
import com.yunzhupaas.engine.model.flowtemplate.*;
|
||||
import com.yunzhupaas.engine.model.flowtemplatejson.FlowTemplateJsonListVO;
|
||||
import com.yunzhupaas.engine.model.flowtemplatejson.FlowTemplateJsonPage;
|
||||
import com.yunzhupaas.engine.service.FlowEngineVisibleService;
|
||||
import com.yunzhupaas.engine.service.FlowTaskService;
|
||||
import com.yunzhupaas.engine.service.FlowTemplateJsonService;
|
||||
import com.yunzhupaas.engine.service.FlowTemplateService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.visual.service.VisualdevApi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "流程模板", description = "template")
|
||||
@RestController
|
||||
@RequestMapping("/api/workflow1/Engine/flowTemplate")
|
||||
public class FlowTemplateController extends SuperController<FlowTemplateService, FlowTemplateEntity> {
|
||||
|
||||
@Autowired
|
||||
private FlowTemplateService flowTemplateService;
|
||||
@Autowired
|
||||
private FlowTemplateJsonService flowTemplateJsonService;
|
||||
@Autowired
|
||||
private FlowEngineVisibleService flowEngineVisibleService;
|
||||
@Autowired
|
||||
private ServiceAllUtil serviceUtil;
|
||||
@Autowired
|
||||
private FlowTaskService flowTaskService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取流程引擎列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程引擎列表")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<FlowPageListVO>> list(FlowPagination pagination) {
|
||||
List<FlowTemplateEntity> list = flowTemplateService.getPageList(pagination);
|
||||
List<DictionaryDataEntity> dictionList = serviceUtil.getDictionName(list.stream().map(FlowTemplateEntity::getCategory).collect(Collectors.toList()));
|
||||
List<UserEntity> userList = serviceUtil.getUserName(list.stream().map(FlowTemplateEntity::getCreatorUserId).collect(Collectors.toList()));
|
||||
List<FlowPageListVO> listVO = new ArrayList<>();
|
||||
for (FlowTemplateEntity entity : list) {
|
||||
FlowPageListVO vo = JsonUtil.getJsonToBean(entity, FlowPageListVO.class);
|
||||
DictionaryDataEntity dataEntity = dictionList.stream().filter(t -> t.getId().equals(entity.getCategory())).findFirst().orElse(null);
|
||||
vo.setCategory(dataEntity != null ? dataEntity.getFullName() : "");
|
||||
UserEntity userEntity = userList.stream().filter(t -> t.getId().equals(entity.getCreatorUserId())).findFirst().orElse(null);
|
||||
vo.setCreatorUser(userEntity != null ? userEntity.getRealName() + "/" + userEntity.getAccount() : "");
|
||||
listVO.add(vo);
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程设计列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "流程引擎下拉框")
|
||||
@GetMapping("/Selector")
|
||||
public ActionResult<ListVO<FlowTemplateListVO>> listSelect() {
|
||||
List<FlowTemplateListVO> treeList = flowTemplateService.getSelectList();
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(treeList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可见引擎下拉框
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "可见引擎下拉框")
|
||||
@GetMapping("/ListAll")
|
||||
public ActionResult<ListVO<FlowTemplateListVO>> listAll() {
|
||||
List<FlowTemplateListVO> treeList = flowTemplateService.getSelectList();
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(treeList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可见的流程引擎列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "可见的流程引擎列表")
|
||||
@GetMapping("/PageListAll")
|
||||
public ActionResult<PageListVO<FlowPageListVO>> listAll(FlowPagination pagination) {
|
||||
List<FlowTemplateEntity> list = flowTemplateService.getListAll(pagination, true);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
List<FlowPageListVO> listVO = JsonUtil.getJsonToList(list, FlowPageListVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 所属流程树形接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "所属流程树形接口")
|
||||
@GetMapping("/TreeList")
|
||||
public ActionResult<ListVO<FlowTemplateListVO>> treeList() {
|
||||
List<FlowTemplateListVO> treeList = flowTemplateService.getTreeList();
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(treeList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可见的流程引擎列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "可见的子流程流程引擎列表")
|
||||
@GetMapping("/PageChildListAll")
|
||||
public ActionResult<PageListVO<FlowSelectVO>> childListAll(FlowPagination pagination) {
|
||||
List<FlowSelectVO> list = flowTemplateJsonService.getChildListPage(pagination);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程引擎信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取流程引擎信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<FlowTemplateInfoVO> info(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateInfoVO vo = flowTemplateService.info(id);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建流程设计
|
||||
*
|
||||
* @param form 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建流程引擎")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "form", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody @Valid FlowTemplateCrForm form) throws WorkFlowException {
|
||||
FlowTemplateEntity entity = JsonUtil.getJsonToBean(form, FlowTemplateEntity.class);
|
||||
String json = StringUtil.isNotEmpty(form.getFlowTemplateJson()) ? form.getFlowTemplateJson() : "[]";
|
||||
List<FlowTemplateJsonEntity> templatejson = JsonUtil.getJsonToList(json, FlowTemplateJsonEntity.class);
|
||||
flowTemplateService.create(entity, templatejson);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新流程设计
|
||||
*
|
||||
* @param id 主键
|
||||
* @param form 流程模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新流程引擎")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "form", description = "流程模型", required = true),
|
||||
})
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid FlowTemplatUprForm form) throws WorkFlowException {
|
||||
FlowTemplateEntity entity = JsonUtil.getJsonToBean(form, FlowTemplateEntity.class);
|
||||
String json = StringUtil.isNotEmpty(form.getFlowTemplateJson()) ? form.getFlowTemplateJson() : "[]";
|
||||
List<FlowTemplateJsonEntity> templateJsonList = JsonUtil.getJsonToList(json, FlowTemplateJsonEntity.class);
|
||||
FlowTemplateVO vo = flowTemplateService.updateVisible(id, entity, templateJsonList);
|
||||
return ActionResult.success(MsgCode.SU004.get(), vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程设计
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除流程引擎")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateEntity entity = flowTemplateService.getInfo(id);
|
||||
flowTemplateService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制流程表单
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "复制流程表单")
|
||||
@PostMapping("/{id}/Actions/Copy")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult copy(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateEntity flowtemplate = flowTemplateService.getInfo(id);
|
||||
if (flowtemplate != null) {
|
||||
if (flowtemplate.getType() == 1) {
|
||||
throw new WorkFlowException(MsgCode.WF024.get());
|
||||
}
|
||||
List<FlowTemplateJsonEntity> templateJson = flowTemplateJsonService.getMainList(ImmutableList.of(id));
|
||||
flowTemplateService.copy(flowtemplate, templateJson);
|
||||
return ActionResult.success(MsgCode.SU007.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程表单状态
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新流程表单状态")
|
||||
@PutMapping("/{id}/Actions/State")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult state(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateEntity entity = flowTemplateService.getInfo(id);
|
||||
if (entity != null) {
|
||||
entity.setEnabledMark("1".equals(String.valueOf(entity.getEnabledMark())) ? 0 : 1);
|
||||
flowTemplateService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布流程引擎
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "发布流程设计")
|
||||
@PostMapping("/Release/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult release(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateEntity entity = flowTemplateService.getInfo(id);
|
||||
if (entity != null) {
|
||||
entity.setEnabledMark(1);
|
||||
List<FlowTemplateJsonEntity> templateJson = flowTemplateJsonService.getMainList(ImmutableList.of(id));
|
||||
if (templateJson.size() == 0) {
|
||||
return ActionResult.fail(MsgCode.WF025.get());
|
||||
}
|
||||
flowTemplateService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.WF026.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA011.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止流程引擎
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "停止流程设计")
|
||||
@PostMapping("/Stop/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult stop(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateEntity entity = flowTemplateService.getInfo(id);
|
||||
if (entity != null) {
|
||||
entity.setEnabledMark(0);
|
||||
flowTemplateService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.WF027.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA008.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作流导出
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
@Operation(summary = "工作流导出")
|
||||
@GetMapping("/{id}/Actions/Export")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<DownloadVO> exportData(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowExportModel model = flowTemplateService.exportData(id);
|
||||
DownloadVO downloadVO = serviceUtil.exportData(model);
|
||||
return ActionResult.success(downloadVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作流导入
|
||||
*
|
||||
* @param multipartFile 文件
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
@Operation(summary = "工作流导入")
|
||||
@PostMapping(value = "/Actions/Import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ActionResult ImportData(@RequestPart("file") MultipartFile multipartFile, @RequestPart("type") String type) throws WorkFlowException {
|
||||
//判断是否为.json结尾
|
||||
if (FileUtil.existsSuffix(multipartFile, ModuleTypeEnum.FLOW_FLOWENGINE.getTableName())) {
|
||||
return ActionResult.fail(MsgCode.IMP002.get());
|
||||
}
|
||||
//获取文件内容
|
||||
String fileContent = FileUtil.getFileContent(multipartFile);
|
||||
FlowExportModel flowExportModel = JsonUtil.getJsonToBean(fileContent, FlowExportModel.class);
|
||||
if (ObjectUtil.isEmpty(flowExportModel.getFlowTemplate())) {
|
||||
return ActionResult.fail(MsgCode.IMP004.get());
|
||||
}
|
||||
flowTemplateService.ImportData(flowExportModel, type);
|
||||
return ActionResult.success(MsgCode.IMP001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程版本列表
|
||||
*
|
||||
* @param templateId 主键
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "流程版本列表")
|
||||
@GetMapping("{templateId}/FlowJsonList")
|
||||
@Parameters({
|
||||
@Parameter(name = "templateId", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<PageListVO<FlowTemplateJsonListVO>> list(@PathVariable("templateId") String templateId, FlowTemplateJsonPage pagination) {
|
||||
List<FlowTemplateJsonEntity> list = flowTemplateJsonService.getListPage(pagination, true);
|
||||
List<String> createId = list.stream().map(FlowTemplateJsonEntity::getCreatorUserId).collect(Collectors.toList());
|
||||
List<UserEntity> userName = serviceUtil.getUserName(createId);
|
||||
List<FlowTemplateJsonListVO> listVO = JsonUtil.getJsonToList(list, FlowTemplateJsonListVO.class);
|
||||
for (FlowTemplateJsonListVO templateJson : listVO) {
|
||||
UserEntity entity = userName.stream().filter(t -> t.getId().equals(templateJson.getCreatorUserId())).findFirst().orElse(null);
|
||||
templateJson.setCreatorUser(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置主版本
|
||||
*
|
||||
* @param ids 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设置主版本")
|
||||
@PostMapping("{ids}/MainVersion")
|
||||
@Parameters({
|
||||
@Parameter(name = "ids", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult mainVersion(@PathVariable("ids") String ids) throws WorkFlowException {
|
||||
flowTemplateJsonService.templateJsonMajor(ids);
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除版本
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除版本")
|
||||
@DeleteMapping("{id}/FlowJson")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult flowJson(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateJsonEntity entity = flowTemplateJsonService.getInfo(id);
|
||||
List<FlowTaskEntity> flowTaskList = flowTaskService.getFlowList(entity.getId());
|
||||
if (flowTaskList.size() > 0) {
|
||||
throw new WorkFlowException(MsgCode.WF028.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程类型下拉
|
||||
*
|
||||
* @param id 主键
|
||||
* @param type 类型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "流程类型下拉")
|
||||
@GetMapping("/FlowJsonList/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<List<FlowSelectVO>> flowJsonList(@PathVariable("id") String id, String type) throws WorkFlowException {
|
||||
FlowTemplateEntity info = flowTemplateService.getInfo(id);
|
||||
if (!ObjectUtil.equal(info.getEnabledMark(), 1)) {
|
||||
return ActionResult.fail(MsgCode.WF053.get());
|
||||
}
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<FlowTemplateJsonEntity> list = flowTemplateJsonService.getMainList(ImmutableList.of(id));
|
||||
List<FlowSelectVO> listVO = new ArrayList<>();
|
||||
if (StringUtil.isNotEmpty(type) && !userInfo.getIsAdministrator()) {
|
||||
List<FlowEngineVisibleEntity> visibleFlowList = flowEngineVisibleService.getVisibleFlowList(userInfo.getUserId());
|
||||
for (FlowTemplateJsonEntity entity : list) {
|
||||
boolean count = visibleFlowList.stream().filter(t -> t.getFlowId().equals(entity.getId())).count() > 0;
|
||||
if ((entity.getVisibleType() == 1 && count) || entity.getVisibleType() == 0) {
|
||||
FlowSelectVO vo = JsonUtil.getJsonToBean(entity, FlowSelectVO.class);
|
||||
listVO.add(vo);
|
||||
}
|
||||
}
|
||||
if (listVO.size() == 0) {
|
||||
return ActionResult.fail(MsgCode.WF029.get());
|
||||
}
|
||||
} else {
|
||||
listVO.addAll(JsonUtil.getJsonToList(list, FlowSelectVO.class));
|
||||
}
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 子流程表单信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "子流程表单信息")
|
||||
@GetMapping("/{id}/FormInfo")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<FlowFormVo> formInfo(@PathVariable("id") String id) throws WorkFlowException {
|
||||
FlowTemplateJsonEntity info = flowTemplateJsonService.getInfo(id);
|
||||
ChildNode childNode = JsonUtil.getJsonToBean(info.getFlowTemplateJson(), ChildNode.class);
|
||||
String formId = childNode.getProperties().getFormId();
|
||||
//todo 添加表单配置
|
||||
FlowFormVo vo = JsonUtil.getJsonToBean("", FlowFormVo.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程协管
|
||||
*
|
||||
* @param assistModel 协管模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "流程协管")
|
||||
@PostMapping("/assist")
|
||||
@Parameters({
|
||||
@Parameter(name = "assistModel", description = "协管模型", required = true),
|
||||
})
|
||||
public ActionResult assist(@RequestBody FlowAssistModel assistModel) {
|
||||
flowEngineVisibleService.assistList(assistModel);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 委托可选全部流程
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "委托可选全部流程")
|
||||
@GetMapping("/getflowAll")
|
||||
public ActionResult<PageListVO<FlowPageListVO>> getflowAll(FlowPagination pagination) {
|
||||
List<FlowTemplateEntity> listByFlowIds = flowTemplateService.getListAll(pagination, true);
|
||||
List<FlowPageListVO> listVO = JsonUtil.getJsonToList(listByFlowIds, FlowPageListVO.class);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 委托流程选择展示
|
||||
*
|
||||
* @param templateIds 委托流程
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "委托流程选择展示")
|
||||
@PostMapping("/getflowList")
|
||||
@Parameters({
|
||||
@Parameter(name = "templateIds", description = "委托流程", required = true),
|
||||
})
|
||||
public ActionResult<List<FlowPageListVO>> getflowList(@RequestBody List<String> templateIds) {
|
||||
FlowPagination pagination = new FlowPagination();
|
||||
pagination.setTemplateIdList(templateIds);
|
||||
List<FlowTemplateEntity> listByFlowIds = flowTemplateService.getListAll(pagination, false);
|
||||
List<FlowPageListVO> listVO = JsonUtil.getJsonToList(listByFlowIds, FlowPageListVO.class);
|
||||
return ActionResult.success(MsgCode.SU002.get(), listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 委托流程选择展示
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取协管")
|
||||
@GetMapping("/{id}/assistList")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<ListVO<String>> getAssistList(@PathVariable("id") String id) {
|
||||
List<FlowEngineVisibleEntity> assistListAll = flowEngineVisibleService.getList(ImmutableList.of(id));
|
||||
List<String> assistList = new ArrayList<>();
|
||||
for (FlowEngineVisibleEntity entity : assistListAll) {
|
||||
assistList.add(entity.getOperatorId() + "--" + entity.getOperatorType());
|
||||
}
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(assistList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取引擎id
|
||||
*
|
||||
* @param code 编码
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取引擎id")
|
||||
@GetMapping("/getFlowIdByCode/{code}")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "编码", required = true),
|
||||
})
|
||||
public ActionResult getFlowIdByCode(@PathVariable("code") String code) throws WorkFlowException {
|
||||
FlowTemplateEntity entity = flowTemplateService.getFlowIdByCode(code);
|
||||
return ActionResult.success(MsgCode.SU002.get(), entity.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user