|
|
|
@ -3,7 +3,6 @@ package com.supervision.knowsub.service.impl;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.supervision.knowsub.dto.flow.FlowBaseRelationTypeDTO;
|
|
|
|
|
import com.supervision.knowsub.exception.BusinessException;
|
|
|
|
|
import com.supervision.knowsub.model.SystemBase;
|
|
|
|
|
import com.supervision.knowsub.model.SystemFlow;
|
|
|
|
@ -11,17 +10,15 @@ import com.supervision.knowsub.model.SystemFlowBaseRelation;
|
|
|
|
|
import com.supervision.knowsub.model.SystemFlowTypeRelation;
|
|
|
|
|
import com.supervision.knowsub.service.*;
|
|
|
|
|
import com.supervision.knowsub.vo.flow.*;
|
|
|
|
|
import com.supervision.knowsub.vo.sublibrary.SubLibraryResVo;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.imageio.metadata.IIOMetadataFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
@ -46,11 +43,11 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
|
|
|
|
|
// 一个子库最多对应一种流程类型
|
|
|
|
|
List<String> baseIdList = flowInfoReqVo.getBaseIdList();
|
|
|
|
|
if (CollUtil.isNotEmpty(baseIdList)){
|
|
|
|
|
List<Integer> flowTypeList = flowInfoReqVo.getFlowTypeList();
|
|
|
|
|
if (CollUtil.isNotEmpty(baseIdList) & CollUtil.isNotEmpty(flowTypeList)){
|
|
|
|
|
List<SystemFlowTypeRelation> flowTypeRelationList = systemFlowTypeRelationService.lambdaQuery().in(SystemFlowTypeRelation::getBaseId, baseIdList).list();
|
|
|
|
|
List<String> usedBaseIds = listUsedBaseIds(flowInfoReqVo.getFlowTypeList());
|
|
|
|
|
flowTypeRelationList.forEach(flowTypeRelation ->
|
|
|
|
|
Assert.isTrue(!usedBaseIds.contains(flowTypeRelation.getBaseId()), "该子库已存在流程类型"));
|
|
|
|
|
Assert.isTrue(!flowTypeList.contains(flowTypeRelation.getFlowType()), "该子库已存在流程类型"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保存数据
|
|
|
|
@ -108,7 +105,7 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
return CollUtil.newArrayList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return systemFlowTypeRelationService.lambdaQuery().in(SystemFlowTypeRelation::getFlowId, typeIds).list()
|
|
|
|
|
return systemFlowTypeRelationService.lambdaQuery().in(SystemFlowTypeRelation::getFlowType, typeIds).list()
|
|
|
|
|
.stream().map(SystemFlowTypeRelation::getBaseId).distinct().toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -119,6 +116,7 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
Assert.notEmpty(flowInfoReqVo.getNodeInfoList());
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void updateFlow(FlowInfoReqVo flowInfoReqVo) {
|
|
|
|
|
|
|
|
|
|
Assert.notEmpty(flowInfoReqVo.getId(), "流程id不能为空");
|
|
|
|
@ -129,12 +127,12 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
|
|
|
|
|
// 一个子库最多对应一种流程类型
|
|
|
|
|
List<String> baseIdList = flowInfoReqVo.getBaseIdList();
|
|
|
|
|
if (CollUtil.isNotEmpty(baseIdList)){
|
|
|
|
|
List<Integer> flowTypeList = flowInfoReqVo.getFlowTypeList();
|
|
|
|
|
if (CollUtil.isNotEmpty(baseIdList) && CollUtil.isNotEmpty(flowTypeList)){
|
|
|
|
|
List<SystemFlowTypeRelation> flowTypeRelationList = systemFlowTypeRelationService.lambdaQuery()
|
|
|
|
|
.in(SystemFlowTypeRelation::getBaseId, baseIdList).notIn(SystemFlowTypeRelation::getFlowId, flowInfoReqVo.getId()).list();
|
|
|
|
|
List<String> usedBaseIds = listUsedBaseIds(flowInfoReqVo.getFlowTypeList());
|
|
|
|
|
flowTypeRelationList.forEach(flowTypeRelation ->
|
|
|
|
|
Assert.isTrue(!usedBaseIds.contains(flowTypeRelation.getBaseId()), "该子库已存在流程类型"));
|
|
|
|
|
Assert.isTrue(!flowTypeList.contains(flowTypeRelation.getFlowType()), "该子库已存在流程类型"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新主表数据
|
|
|
|
@ -159,6 +157,9 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
// 更新流程类型关联表数据
|
|
|
|
|
updateFlowTypeRelation(flowInfoReqVo.getId(), flowInfoReqVo.getFlowTypeList(), flowInfoReqVo.getBaseIdList());
|
|
|
|
|
|
|
|
|
|
// 更新流程规则表数据
|
|
|
|
|
flowRuleManageService.updateFlowRule(flowInfoReqVo.getId(), flowInfoReqVo.getNodeInfoList());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -212,7 +213,7 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
List<Integer> needInsert = flowTypeList.stream().filter(flowType -> !dbFlowTypeList.contains(flowType)).toList();
|
|
|
|
|
|
|
|
|
|
// 数据库中存在,入参中不存在,删除
|
|
|
|
|
List<Integer> needDelete = dbFlowTypeList.stream().filter(flowType -> !flowTypeList.contains(flowType)).toList();
|
|
|
|
|
List<Integer> needDelete = dbFlowTypeList.stream().filter(flowType -> !flowTypeList.contains(flowType)).distinct().toList();
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(needInsert)){
|
|
|
|
|
doBatchSaveFlowTypeRelation(flowId, needInsert, baseIdList);
|
|
|
|
@ -263,10 +264,11 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
SystemFlow systemFlow = systemFlowService.getById(flowId);
|
|
|
|
|
Assert.notNull(systemFlow, "流程不存在");
|
|
|
|
|
|
|
|
|
|
FlowDetailResVo flowDetail = FlowDetailResVo.builder().id(systemFlow.getId()).flowName(systemFlow.getFlowName()).build();
|
|
|
|
|
FlowDetailResVo flowDetail = FlowDetailResVo.builder().id(systemFlow.getId())
|
|
|
|
|
.flowName(systemFlow.getFlowName()).remark(systemFlow.getRemark()).build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SystemFlowBaseRelation> flowBaseRelationList = systemFlowBaseRelationService.lambdaQuery().eq(SystemFlowBaseRelation::getId, flowId).list();
|
|
|
|
|
List<SystemFlowBaseRelation> flowBaseRelationList = systemFlowBaseRelationService.lambdaQuery().eq(SystemFlowBaseRelation::getFlowId, flowId).list();
|
|
|
|
|
if (CollUtil.isNotEmpty(flowBaseRelationList)){
|
|
|
|
|
flowDetail.setSubLibraryIdList(flowBaseRelationList.stream().map(SystemFlowBaseRelation::getBaseId).toList());
|
|
|
|
|
}
|
|
|
|
@ -278,6 +280,7 @@ public class FlowManageServiceImpl implements FlowManageService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<NodeInfo> nodeInfos = flowRuleManageService.listFlowRule(flowId);
|
|
|
|
|
nodeInfos.sort(Comparator.comparing(NodeInfo::getOrder));
|
|
|
|
|
flowDetail.setNodeInfoList(nodeInfos);
|
|
|
|
|
return flowDetail;
|
|
|
|
|
}
|
|
|
|
|