|
@@ -1,15 +1,17 @@
|
|
|
package com.redxun.knowledge.analysis.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.redxun.common.base.entity.QueryData;
|
|
|
import com.redxun.common.tool.StringUtils;
|
|
|
import com.redxun.knowledge.analysis.entity.consts.PlatformConst;
|
|
|
+import com.redxun.knowledge.analysis.entity.dao.KnowledgeDao;
|
|
|
import com.redxun.knowledge.analysis.entity.vo.*;
|
|
|
import com.redxun.knowledge.analysis.mapper.AnalysisCommonMapper;
|
|
|
import com.redxun.knowledge.analysis.mapper.PvLogMapper;
|
|
|
-import com.redxun.knowledge.common.UserService;
|
|
|
-import com.redxun.knowledge.mapper.KnowledgeCategoryMapper;
|
|
|
import com.redxun.knowledge.utils.DateUtils;
|
|
|
|
|
|
+import com.redxun.knowledge.utils.PageListUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -37,12 +39,6 @@ public class AnalysisCommonServiceImpl {
|
|
|
@Autowired
|
|
|
private PvLogMapper pvLogMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private KnowledgeCategoryMapper knowledgeCategoryMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private UserService userService;
|
|
|
-
|
|
|
/**
|
|
|
* 各模块整体数量统计:知识仓库(知识总数量);知识地图(地图总数量);知识专辑(专辑总数量)
|
|
|
*
|
|
@@ -238,42 +234,48 @@ public class AnalysisCommonServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* 组织创建知识数量
|
|
|
- *
|
|
|
- * @param type
|
|
|
- * @param tops
|
|
|
- * @param sort
|
|
|
+ * @param queryData
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<KnowledgeCompanyVo> organizationKnowledges(String type, Integer tops, String sort) {
|
|
|
- //获取全部创建过知识的公司id
|
|
|
- List<String> knowledgeCompanyIdList = analysisCommonMapper.selectCompanyId();
|
|
|
+ public IPage organizationKnowledges(QueryData queryData) {
|
|
|
//获取当前年
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
int year = calendar.get(Calendar.YEAR);
|
|
|
- List<KnowledgeCompanyVo> result = knowledgeCompanyIdList.parallelStream().map(e -> {
|
|
|
+ List<KnowledgeDao> count = new ArrayList<>();
|
|
|
+ if (("total").equals(queryData.getParams().get("type"))) {
|
|
|
+ count = analysisCommonMapper.organizationKnowledges(null, null);
|
|
|
+ } else if ("year".equals(queryData.getParams().get("type"))) {
|
|
|
+ count = analysisCommonMapper.organizationKnowledges(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
+ DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
|
+ } else if ("month".equals(queryData.getParams().get("type"))) {
|
|
|
+ int month = calendar.get(Calendar.MONTH);
|
|
|
+ String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
|
|
|
+ String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
|
|
|
+ count = analysisCommonMapper.organizationKnowledges(firstOfMonth, lastOfMonth);
|
|
|
+ }
|
|
|
+ List<KnowledgeCompanyVo> result = count.parallelStream().map(e -> {
|
|
|
KnowledgeCompanyVo knowledgeCompanyVo = new KnowledgeCompanyVo();
|
|
|
- List<Integer> count = new ArrayList<>();
|
|
|
- if (("total").equals(type)) {
|
|
|
- count = analysisCommonMapper.organizationKnowledges(e, null, null);
|
|
|
- } else if ("year".equals(type)) {
|
|
|
- count = analysisCommonMapper.organizationKnowledges(e, DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
- DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
|
- } else if ("month".equals(type)) {
|
|
|
- int month = calendar.get(Calendar.MONTH);
|
|
|
- String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
|
|
|
- String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
|
|
|
- count = analysisCommonMapper.organizationKnowledges(e, firstOfMonth, lastOfMonth);
|
|
|
+ knowledgeCompanyVo.setCompany(e.getCompanyId());
|
|
|
+ e.getCounts().forEach(c -> {
|
|
|
+ if (c.containsKey("type") && c.get("type").intValue() == 1) {
|
|
|
+ knowledgeCompanyVo.setArchive(c.get("count").intValue());
|
|
|
+ }
|
|
|
+ if (c.containsKey("type") && c.get("type").intValue() == 2) {
|
|
|
+ knowledgeCompanyVo.setWiki(c.get("count").intValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (knowledgeCompanyVo.getArchive() == null){
|
|
|
+ knowledgeCompanyVo.setArchive(0);
|
|
|
}
|
|
|
- long archive = count.stream().filter(typeKnowledge -> typeKnowledge == 1).count();
|
|
|
- long wiki = count.stream().filter(typeKnowledge -> typeKnowledge == 2).count();
|
|
|
- knowledgeCompanyVo.setCompany(userService.findDeptByDeptId(e).getName());
|
|
|
- knowledgeCompanyVo.setTotal(count.size());
|
|
|
- knowledgeCompanyVo.setArchive((int) archive);
|
|
|
- knowledgeCompanyVo.setWiki((int) wiki);
|
|
|
+ if (knowledgeCompanyVo.getWiki() == null){
|
|
|
+ knowledgeCompanyVo.setWiki(0);
|
|
|
+ }
|
|
|
+ knowledgeCompanyVo.setTotal(knowledgeCompanyVo.getArchive() + knowledgeCompanyVo.getWiki());
|
|
|
return knowledgeCompanyVo;
|
|
|
}).collect(Collectors.toList());
|
|
|
//排序
|
|
|
- if (sort != null){
|
|
|
+ String sort = queryData.getParams().get("sort");
|
|
|
+ if (sort != null) {
|
|
|
switch (sort) {
|
|
|
case "totalDesc":
|
|
|
result = result.stream().sorted((t1, t2) -> t2.getTotal().compareTo(t1.getTotal())).collect(Collectors.toList());
|
|
@@ -297,8 +299,15 @@ public class AnalysisCommonServiceImpl {
|
|
|
} else {
|
|
|
result = result.stream().sorted((t1, t2) -> t2.getTotal().compareTo(t1.getTotal())).collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
//获取top10公司数据
|
|
|
- List<KnowledgeCompanyVo> resultTop = result.stream().limit(tops).collect(Collectors.toList());
|
|
|
- return resultTop;
|
|
|
+ String tops = queryData.getParams().get("tops");
|
|
|
+ List<KnowledgeCompanyVo> resultTop = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(tops)){
|
|
|
+ resultTop = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ resultTop = result.stream().limit(10).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),resultTop);
|
|
|
}
|
|
|
}
|