|
|
|
@ -2,11 +2,14 @@ package com.supervision.knowsub.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.supervision.knowsub.domain.UserInfo;
|
|
|
|
|
import com.supervision.knowsub.entity.vo.knowledge.KnowledgeDetailResVO;
|
|
|
|
|
import com.supervision.knowsub.entity.vo.knowledge.KnowledgeLinkVO;
|
|
|
|
|
import com.supervision.knowsub.entity.vo.knowledge.ModifyKnowledgeReqVO;
|
|
|
|
|
import com.supervision.knowsub.entity.vo.knowledge.SaveKnowledgeReqVO;
|
|
|
|
|
import com.supervision.knowsub.enums.FlowTypeEnum;
|
|
|
|
|
import com.supervision.knowsub.enums.StatusEnum;
|
|
|
|
|
import com.supervision.knowsub.exception.BusinessException;
|
|
|
|
|
import com.supervision.knowsub.model.*;
|
|
|
|
@ -17,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
@ -41,6 +45,8 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
|
|
|
|
|
private final FileService fileService;
|
|
|
|
|
|
|
|
|
|
private final KnowledgeFlowService knowledgeFlowService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<Knowledge> queryKnowledgePage(Integer status,
|
|
|
|
@ -57,7 +63,7 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void saveKnowledge(SaveKnowledgeReqVO reqVO) {
|
|
|
|
|
Assert.notBlank(reqVO.getBaseId(),"应用子库不能为空");
|
|
|
|
|
Assert.notBlank(reqVO.getBaseId(), "应用子库不能为空");
|
|
|
|
|
var context = new KnowledgeContext();
|
|
|
|
|
context.setContext(reqVO.getContent());
|
|
|
|
|
knowledgeContextService.save(context);
|
|
|
|
@ -98,7 +104,9 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
}
|
|
|
|
|
// 这里需要进行判断,如果状态为2,说明要走流程
|
|
|
|
|
if (1 != reqVO.getOperate()) {
|
|
|
|
|
// TODO 这里需要走流程
|
|
|
|
|
// 这里需要走流程
|
|
|
|
|
UserInfo user = UserUtil.getUser();
|
|
|
|
|
knowledgeFlowService.submitFlowProcess(knowledge, FlowTypeEnum.SUBMIT, user.getId(), user.getDeptId(), reqVO.getRemark());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -109,7 +117,7 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void updateKnowledge(ModifyKnowledgeReqVO reqVO) {
|
|
|
|
|
Assert.notBlank(reqVO.getBaseId(),"应用子库不能为空");
|
|
|
|
|
Assert.notBlank(reqVO.getBaseId(), "应用子库不能为空");
|
|
|
|
|
Knowledge knowledge = knowledgeService.getOptById(reqVO.getKnowledgeId()).orElseThrow(() -> new BusinessException("未找到知识"));
|
|
|
|
|
// 首先校验状态,草稿/已撤回/已失效/驳回,才能修改(通过的,要先撤回才能修改)
|
|
|
|
|
Set<Integer> canModifyStatusSet = Set.of(StatusEnum.DRAFT.getStatus(), StatusEnum.RECALL.getStatus(), StatusEnum.INVALID.getStatus(), StatusEnum.REJECT.getStatus());
|
|
|
|
@ -153,7 +161,8 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
updateKnowledgeLink(reqVO, knowledge);
|
|
|
|
|
// 这里需要进行判断,如果状态为2,说明要走流程
|
|
|
|
|
if (1 != reqVO.getOperate()) {
|
|
|
|
|
// TODO 这里需要走流程
|
|
|
|
|
UserInfo user = UserUtil.getUser();
|
|
|
|
|
knowledgeFlowService.submitFlowProcess(knowledge, FlowTypeEnum.SUBMIT, user.getId(), user.getDeptId(), reqVO.getRemark());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -207,15 +216,16 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void recallKnowledge(String knowledgeId) {
|
|
|
|
|
public void recallKnowledge(String knowledgeId, String remark) {
|
|
|
|
|
Knowledge knowledge = knowledgeService.getOptById(knowledgeId).orElseThrow(() -> new BusinessException("未找到知识"));
|
|
|
|
|
// 只有通过状态或已失效状态才支持撤回
|
|
|
|
|
Set<Integer> canRecallStatusSet = Set.of(StatusEnum.PASS.getStatus(), StatusEnum.INVALID.getStatus());
|
|
|
|
|
if (!canRecallStatusSet.contains(knowledge.getStatus())) {
|
|
|
|
|
throw new BusinessException("该知识状态不能撤回");
|
|
|
|
|
}
|
|
|
|
|
// TODO 走撤回流程
|
|
|
|
|
|
|
|
|
|
// 走撤回流程
|
|
|
|
|
UserInfo user = UserUtil.getUser();
|
|
|
|
|
knowledgeFlowService.submitFlowProcess(knowledge, FlowTypeEnum.RECALL, user.getId(), user.getDeptId(), remark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -232,7 +242,7 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void deleteKnowledge(String knowledgeId) {
|
|
|
|
|
public void deleteKnowledge(String knowledgeId, String remark) {
|
|
|
|
|
// 删除是逻辑删除,如果当前状态是草稿,且没有走过审批流程,则可以直接删除
|
|
|
|
|
Knowledge knowledge = knowledgeService.getOptById(knowledgeId).orElseThrow(() -> new BusinessException("未找到知识"));
|
|
|
|
|
if (Objects.equals(StatusEnum.DRAFT.getStatus(), knowledge.getStatus())) {
|
|
|
|
@ -256,12 +266,15 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
// 如果非草稿,则校验是否是通过/驳回/已失效状态,如果是,则需要走审批流程进行删除
|
|
|
|
|
Set<Integer> canDeleteStatusSet = Set.of(StatusEnum.PASS.getStatus(), StatusEnum.REJECT.getStatus(), StatusEnum.INVALID.getStatus());
|
|
|
|
|
if (canDeleteStatusSet.contains(knowledge.getStatus())) {
|
|
|
|
|
// TODO 这时需要走审批流程进行删除
|
|
|
|
|
|
|
|
|
|
// 这时需要走审批流程进行删除
|
|
|
|
|
UserInfo user = UserUtil.getUser();
|
|
|
|
|
knowledgeFlowService.submitFlowProcess(knowledge, FlowTypeEnum.DELETE, user.getId(), user.getDeptId(), remark);
|
|
|
|
|
} else {
|
|
|
|
|
throw new BusinessException("审批中的知识不支持删除");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|