提交部分代码
parent
fb8b39b876
commit
5463942117
@ -0,0 +1,49 @@
|
||||
package com.supervision.knowsub.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.supervision.knowsub.vo.flow.BaseResVo;
|
||||
import com.supervision.knowsub.vo.flow.FlowInfoReqVo;
|
||||
import com.supervision.knowsub.vo.flow.FlowInfoResVo;
|
||||
import com.supervision.knowsub.vo.sublibrary.SubLibraryResVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FlowManageService {
|
||||
String saveFlow(FlowInfoReqVo flowInfoReqVo);
|
||||
|
||||
/**
|
||||
* 根据typeIds查询已经被使用的子库ids
|
||||
* @param typeIds
|
||||
* @return
|
||||
*/
|
||||
List<String> listUsedBaseIds(List<Integer> typeIds);
|
||||
|
||||
/**
|
||||
* 修改流程
|
||||
* @param flowInfoReqVo
|
||||
*/
|
||||
void updateFlow(FlowInfoReqVo flowInfoReqVo);
|
||||
|
||||
/**
|
||||
* 删除流程
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteFlow(String id);
|
||||
|
||||
/**
|
||||
* 分页查询流程列表
|
||||
* @param flowName 流程名称
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* @return
|
||||
*/
|
||||
IPage<FlowInfoResVo> pageListFlow(String flowName, Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 查询可选择的子库信息列表
|
||||
* @param flowType 流程类型
|
||||
* @return
|
||||
*/
|
||||
List<BaseResVo> optionalBaseList(List<Integer> flowType);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.supervision.knowsub.service;
|
||||
|
||||
public interface FlowRuleManageService {
|
||||
|
||||
boolean saveFlowRule(String flowId, String ruleId, String userId);
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
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;
|
||||
import com.supervision.knowsub.model.SystemFlowBaseRelation;
|
||||
import com.supervision.knowsub.model.SystemFlowTypeRelation;
|
||||
import com.supervision.knowsub.service.*;
|
||||
import com.supervision.knowsub.vo.flow.BaseResVo;
|
||||
import com.supervision.knowsub.vo.flow.FlowInfoReqVo;
|
||||
import com.supervision.knowsub.vo.flow.FlowInfoResVo;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class FlowManageServiceImpl implements FlowManageService {
|
||||
|
||||
private final SystemFlowService systemFlowService;
|
||||
|
||||
private final SystemFlowBaseRelationService systemFlowBaseRelationService;
|
||||
|
||||
private final SystemFlowTypeRelationService systemFlowTypeRelationService;
|
||||
|
||||
private final SystemFlowRuleService systemFlowRuleService;
|
||||
|
||||
|
||||
private final ApplicationSubLibraryService applicationSubLibraryService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String saveFlow(FlowInfoReqVo flowInfoReqVo) {
|
||||
|
||||
assertBase(flowInfoReqVo);
|
||||
|
||||
// 一个子库最多对应一种流程类型
|
||||
List<String> baseIdList = flowInfoReqVo.getBaseIdList();
|
||||
if (CollUtil.isNotEmpty(baseIdList)){
|
||||
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()), "该子库已存在流程类型"));
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
return doSaveFlow(flowInfoReqVo);
|
||||
}
|
||||
|
||||
private String doSaveFlow(FlowInfoReqVo flowInfoReqVo) {
|
||||
// 保存主表数据
|
||||
SystemFlow systemFlow = new SystemFlow();
|
||||
systemFlow.setFlowName(flowInfoReqVo.getFlowName());
|
||||
systemFlow.setRemark(flowInfoReqVo.getRemark());
|
||||
systemFlowService.save(systemFlow);
|
||||
|
||||
// 保存关联表数据
|
||||
List<String> baseIdList = flowInfoReqVo.getBaseIdList();
|
||||
List<SystemFlowBaseRelation> flowBaseRelationList = flowInfoReqVo.getBaseIdList().stream().map(baseId -> {
|
||||
SystemFlowBaseRelation flowBaseRelation = new SystemFlowBaseRelation();
|
||||
flowBaseRelation.setFlowId(systemFlow.getId());
|
||||
flowBaseRelation.setBaseId(baseId);
|
||||
return flowBaseRelation;
|
||||
}).toList();
|
||||
systemFlowBaseRelationService.saveBatch(flowBaseRelationList);
|
||||
|
||||
List<SystemFlowTypeRelation> flowTypeRelationList = flowInfoReqVo.getFlowTypeList().stream().map(flowType -> baseIdList.stream().map(baseId -> {
|
||||
SystemFlowTypeRelation flowTypeRelation = new SystemFlowTypeRelation();
|
||||
flowTypeRelation.setFlowType(flowType);
|
||||
flowTypeRelation.setBaseId(baseId);
|
||||
flowTypeRelation.setFlowId(systemFlow.getId());
|
||||
return flowTypeRelation;
|
||||
}).toList()).flatMap(Collection::stream).toList();
|
||||
systemFlowTypeRelationService.saveBatch(flowTypeRelationList);
|
||||
|
||||
return systemFlow.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listUsedBaseIds(List<Integer> typeIds){
|
||||
if (CollUtil.isEmpty(typeIds)){
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
|
||||
return systemFlowTypeRelationService.lambdaQuery().in(SystemFlowTypeRelation::getFlowId, typeIds).list()
|
||||
.stream().map(SystemFlowTypeRelation::getBaseId).distinct().toList();
|
||||
}
|
||||
|
||||
private void assertBase(FlowInfoReqVo flowInfoReqVo){
|
||||
Assert.notEmpty(flowInfoReqVo.getFlowName());
|
||||
Assert.notEmpty(flowInfoReqVo.getFlowTypeList());
|
||||
Assert.notEmpty(flowInfoReqVo.getBaseIdList());
|
||||
Assert.notEmpty(flowInfoReqVo.getNodeInfoList());
|
||||
}
|
||||
@Override
|
||||
public void updateFlow(FlowInfoReqVo flowInfoReqVo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteFlow(String id) {
|
||||
throw new BusinessException("暂不支持删除流程");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<FlowInfoResVo> pageListFlow(String flowName, Integer pageNum, Integer pageSize) {
|
||||
|
||||
return systemFlowService.pageListFlow(flowName, pageNum, pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseResVo> optionalBaseList(List<Integer> flowType) {
|
||||
List<SystemBase> allSubLibrary = applicationSubLibraryService.listAllSubLibrary();
|
||||
|
||||
final List<SystemFlowTypeRelation> flowTypeRelationList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(flowType)){
|
||||
flowTypeRelationList.addAll(
|
||||
systemFlowTypeRelationService.lambdaQuery()
|
||||
.in(SystemFlowTypeRelation::getFlowType, flowType).list()) ;
|
||||
}
|
||||
|
||||
return allSubLibrary.stream().filter(systemBase ->
|
||||
flowTypeRelationList.stream().noneMatch(flowTypeRelation ->
|
||||
flowTypeRelation.getBaseId().equals(systemBase.getId()))).map(systemBase -> {
|
||||
BaseResVo baseResVo = new BaseResVo();
|
||||
baseResVo.setBaseId(systemBase.getId());
|
||||
baseResVo.setBaseName(systemBase.getBaseName());
|
||||
return baseResVo;
|
||||
}).toList();
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.supervision.knowsub.service.impl;
|
||||
|
||||
import com.supervision.knowsub.service.FileInfoService;
|
||||
import com.supervision.knowsub.service.FlowRuleManageService;
|
||||
import com.supervision.knowsub.service.SystemFlowRuleService;
|
||||
import com.supervision.knowsub.service.SystemFlowRuleUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class FlowRuleManageServiceImpl implements FlowRuleManageService {
|
||||
|
||||
private final SystemFlowRuleService systemFlowRuleService;
|
||||
|
||||
private final SystemFlowRuleUserService systemFlowRuleUserService;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.supervision.knowsub.dto.flow;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 子库关联流程类型
|
||||
*/
|
||||
@Data
|
||||
public class FlowBaseRelationTypeDTO {
|
||||
|
||||
private String id;
|
||||
|
||||
private String flowId;
|
||||
|
||||
private String baseId;
|
||||
|
||||
private List<Integer> flowTypeList;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.supervision.knowsub.dto.flow;
|
||||
|
||||
public class FlowRoleInfo {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.supervision.knowsub.vo.flow;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BaseResVo {
|
||||
|
||||
private String baseId;
|
||||
|
||||
private String baseName;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.supervision.knowsub.vo.flow;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 流程详情返回对象
|
||||
*/
|
||||
@Data
|
||||
public class FlowDetailResVo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String flowName;
|
||||
|
||||
private String remark;
|
||||
|
||||
// private
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.supervision.knowsub.vo.flow;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FlowInfoReqVo {
|
||||
|
||||
@Schema(description = "流程名称")
|
||||
private String flowName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "数据类型集合 1知识报送 2:知识撤回 3 知识删除")
|
||||
private List<Integer> flowTypeList;
|
||||
|
||||
@Schema(description = "应用库id集合")
|
||||
private List<String> baseIdList;
|
||||
|
||||
|
||||
@Schema(description = "流程id,集合需要与页面顺序保持一致")
|
||||
private List<NodeInfo> nodeInfoList;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.supervision.knowsub.vo.flow;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class FlowInfoResVo {
|
||||
|
||||
@Schema(description = "流程id")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "流程名称")
|
||||
private String flowName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建人id")
|
||||
private String createUserId;
|
||||
|
||||
@Schema(description = "创建人姓名")
|
||||
private String createUserName;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.supervision.knowsub.vo.flow;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NodeInfo {
|
||||
|
||||
@Schema(description = "节点id")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "节点名称")
|
||||
private String NodeName;
|
||||
|
||||
@Schema(description = "节点用户id列表")
|
||||
private List<String> userIdList;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.supervision.knowsub.vo.flow;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 子库信息
|
||||
*/
|
||||
@Data
|
||||
public class SubLibraryInfo {
|
||||
|
||||
@Schema(description = "关联数据id")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "子库id")
|
||||
private String baseId;
|
||||
|
||||
@Schema(description = "子库名称")
|
||||
private String baseName;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue