|
|
|
@ -1,32 +1,26 @@
|
|
|
|
|
package com.supervision.knowsub.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
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.entity.vo.knowledge.*;
|
|
|
|
|
import com.supervision.knowsub.enums.FlowTypeEnum;
|
|
|
|
|
import com.supervision.knowsub.enums.StatusEnum;
|
|
|
|
|
import com.supervision.knowsub.exception.BusinessException;
|
|
|
|
|
import com.supervision.knowsub.model.*;
|
|
|
|
|
import com.supervision.knowsub.service.*;
|
|
|
|
|
import com.supervision.knowsub.util.UserUtil;
|
|
|
|
|
import com.supervision.knowsub.vo.knowledge.KnowledgePageResVO;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
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;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
@ -49,9 +43,13 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
|
|
|
|
|
private final KnowledgeFlowService knowledgeFlowService;
|
|
|
|
|
|
|
|
|
|
private final SystemDeptService systemDeptService;
|
|
|
|
|
|
|
|
|
|
private final SystemBaseService systemBaseService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<Knowledge> queryKnowledgePage(Integer status,
|
|
|
|
|
public IPage<KnowledgePageResVO> queryKnowledgePage(Integer status,
|
|
|
|
|
String title,
|
|
|
|
|
String publishDeptId,
|
|
|
|
|
String baseId,
|
|
|
|
@ -59,7 +57,28 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
|
|
|
|
|
LocalDateTime publishDateBegin,
|
|
|
|
|
LocalDateTime publishDateEnd, Integer pageNum, Integer pageSize) {
|
|
|
|
|
String userId = UserUtil.getUser().getId();
|
|
|
|
|
return knowledgeService.queryKnowledgePage(status, title, publishDeptId, baseId, submittedDeptId, publishDateBegin, publishDateEnd, userId, pageNum, pageSize);
|
|
|
|
|
IPage<KnowledgePageResVO> knowledgeIPage = knowledgeService.queryKnowledgePage(status, title, publishDeptId, baseId, submittedDeptId, publishDateBegin, publishDateEnd, userId, pageNum, pageSize);
|
|
|
|
|
List<KnowledgePageResVO> records = knowledgeIPage.getRecords();
|
|
|
|
|
if (CollUtil.isEmpty(records)){
|
|
|
|
|
return knowledgeIPage;
|
|
|
|
|
}
|
|
|
|
|
// 获取所有部门
|
|
|
|
|
Set<String> submitDeptSet = records.stream().map(Knowledge::getSubmittedDeptId).collect(Collectors.toSet());
|
|
|
|
|
Set<String> publishDeptSet = records.stream().map(Knowledge::getPublishDeptId).collect(Collectors.toSet());
|
|
|
|
|
Collection<String> deptIdSet = CollUtil.union(submitDeptSet, publishDeptSet);
|
|
|
|
|
Map<String, String> deptMap = systemDeptService.listByIds(deptIdSet).stream().collect(Collectors.toMap(SystemDept::getId, SystemDept::getDeptName));
|
|
|
|
|
// 获取所有子库
|
|
|
|
|
Set<String> baseIdSet = records.stream().map(Knowledge::getBaseId).collect(Collectors.toSet());
|
|
|
|
|
Map<String, String> baseMap = systemBaseService.listByIds(baseIdSet).stream().collect(Collectors.toMap(SystemBase::getId, SystemBase::getBaseName));
|
|
|
|
|
List<KnowledgePageResVO> list = records.stream().map(knowledge -> {
|
|
|
|
|
KnowledgePageResVO node = BeanUtil.copyProperties(knowledge, KnowledgePageResVO.class);
|
|
|
|
|
node.setBaseName(baseMap.getOrDefault(knowledge.getBaseId(), "全部"));
|
|
|
|
|
node.setSubmitDeptName(deptMap.getOrDefault(knowledge.getSubmittedDeptId(), "未知部门"));
|
|
|
|
|
node.setPublishDeptName(deptMap.getOrDefault(knowledge.getPublishDeptId(), "未知部门"));
|
|
|
|
|
return node;
|
|
|
|
|
}).toList();
|
|
|
|
|
knowledgeIPage.setRecords(list);
|
|
|
|
|
return knowledgeIPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|