提交部分代码

release_1.0.0
xueqingkun 8 months ago
parent fb8b39b876
commit 5463942117

@ -0,0 +1,66 @@
package com.supervision.knowsub.controller.system;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.knowsub.service.ApplicationSubLibraryService;
import com.supervision.knowsub.service.FlowManageService;
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.SubLibraryReqVo;
import com.supervision.knowsub.vo.sublibrary.SubLibraryResVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "流程管理")
@RestController
@RequestMapping("/flow")
@RequiredArgsConstructor
public class FlowManageController {
private final FlowManageService flowManageService;
@Operation(summary = "新建流程")
@PostMapping("/save")
public String saveFlow(@RequestBody FlowInfoReqVo flowInfoReqVo) {
return flowManageService.saveFlow(flowInfoReqVo);
}
@Operation(summary = "修改流程")
@PostMapping("/update")
public void updateFlow(@RequestBody FlowInfoReqVo flowInfoReqVo) {
flowManageService.updateFlow(flowInfoReqVo);
}
@Operation(summary = "删除流程")
@DeleteMapping("/delete")
public Boolean deleteFlow(@Parameter(name = "id") @RequestParam(name="id") String id) {
return flowManageService.deleteFlow(id);
}
@Operation(summary = "分页查询流程列表")
@GetMapping("/list")
public IPage<FlowInfoResVo> listFlow(@Parameter(name = "flowName",description = "流程名称") @RequestParam(required = false) String flowName,
@Parameter(name = "pageNum",description = "页码") @RequestParam(defaultValue = "1") Integer pageNum,
@Parameter(name = "pageSize",description = "每页大小") @RequestParam(defaultValue = "10") Integer pageSize) {
return flowManageService.pageListFlow(flowName,pageNum,pageSize);
}
@Operation(summary = "查询可选择的子库信息列表")
@GetMapping("/optionalBaseList")
public List<BaseResVo> optionalBaseList(@Parameter(name = "flowType",description = "数据类型id多个id用英文逗号拼接")
@RequestParam(name = "flowType",required = false) List<Integer> flowType) {
return flowManageService.optionalBaseList(flowType);
}
}

@ -1,9 +1,12 @@
package com.supervision.knowsub.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.knowsub.model.SystemBase;
import com.supervision.knowsub.vo.sublibrary.SubLibraryReqVo;
import com.supervision.knowsub.vo.sublibrary.SubLibraryResVo;
import java.util.List;
public interface ApplicationSubLibraryService {
String saveSubLibrary(SubLibraryReqVo subLibraryReqVo);
@ -13,4 +16,6 @@ public interface ApplicationSubLibraryService {
Boolean deleteSubLibrary(String id);
IPage<SubLibraryResVo> listSubLibrary(SubLibraryReqVo subLibraryReqVo,Integer pageNum,Integer pageSize);
List<SystemBase> listAllSubLibrary();
}

@ -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);
}

@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
@Service
@ -106,4 +107,10 @@ public class ApplicationSubLibraryServiceImpl implements ApplicationSubLibrarySe
// todo: 部门名称 待补充
return systemBaseService.listSubLibrary(subLibraryReqVo, pageNum, pageSize);
}
@Override
public List<SystemBase> listAllSubLibrary() {
return systemBaseService.list();
}
}

@ -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 {
}

@ -1,7 +1,10 @@
package com.supervision.knowsub.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.supervision.knowsub.model.SystemFlow;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.supervision.knowsub.vo.flow.FlowInfoResVo;
/**
* @author Administrator
@ -11,6 +14,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface SystemFlowMapper extends BaseMapper<SystemFlow> {
IPage<FlowInfoResVo> pageListFlow(String flowName, Page<Object> objectPage);
}

@ -29,6 +29,12 @@ public class SystemFlowTypeRelation implements Serializable {
*/
private Integer flowType;
/**
* id ks_system_baseid
*/
private String baseId;
/**
* ID
*/

@ -1,7 +1,9 @@
package com.supervision.knowsub.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.knowsub.model.SystemFlow;
import com.baomidou.mybatisplus.extension.service.IService;
import com.supervision.knowsub.vo.flow.FlowInfoResVo;
/**
* @author Administrator
@ -10,4 +12,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface SystemFlowService extends IService<SystemFlow> {
IPage<FlowInfoResVo> pageListFlow(String flowName, Integer pageNum, Integer pageSize);
}

@ -1,9 +1,12 @@
package com.supervision.knowsub.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.knowsub.model.SystemFlow;
import com.supervision.knowsub.service.SystemFlowService;
import com.supervision.knowsub.mapper.SystemFlowMapper;
import com.supervision.knowsub.vo.flow.FlowInfoResVo;
import org.springframework.stereotype.Service;
/**
@ -15,6 +18,11 @@ import org.springframework.stereotype.Service;
public class SystemFlowServiceImpl extends ServiceImpl<SystemFlowMapper, SystemFlow>
implements SystemFlowService{
@Override
public IPage<FlowInfoResVo> pageListFlow(String flowName, Integer pageNum, Integer pageSize) {
return super.getBaseMapper().pageListFlow(flowName,new Page<>(pageNum,pageSize));
}
}

@ -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;
}

@ -19,4 +19,18 @@
remark,create_user_id,create_time,
update_user_id,update_time
</sql>
<select id="pageListFlow" resultType="com.supervision.knowsub.vo.flow.FlowInfoResVo">
select f.id as id,
f.flow_name as flowName,
f.remark as remark,
f.create_user_id as createUserId,
u.username as createUserName,
f.create_time as createTime
from ks_system_flow f
left join ks_system_user u on f.create_user_id = u.id
where
<if test="flowName != null and flowName != ''">
f.flow_name like concat('%', #{flowName}, '%')
</if>
</select>
</mapper>

@ -8,6 +8,7 @@
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="flowId" column="flow_id" jdbcType="VARCHAR"/>
<result property="flowType" column="flow_type" jdbcType="INTEGER"/>
<result property="baseId" column="base_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
@ -15,7 +16,7 @@
</resultMap>
<sql id="Base_Column_List">
id,flow_id,flow_type,
id,flow_id,flow_type,base_id,
create_user_id,create_time,update_user_id,
update_time
</sql>

Loading…
Cancel
Save