|
@@ -1,15 +1,14 @@
|
|
package com.redxun.knowledge.analysis.service;
|
|
package com.redxun.knowledge.analysis.service;
|
|
|
|
|
|
|
|
+import com.redxun.common.tool.StringUtils;
|
|
import com.redxun.knowledge.analysis.entity.consts.PlatformConst;
|
|
import com.redxun.knowledge.analysis.entity.consts.PlatformConst;
|
|
-import com.redxun.knowledge.analysis.entity.vo.LablesVo;
|
|
|
|
-import com.redxun.knowledge.analysis.entity.vo.SearchParticipleWordCloudVo;
|
|
|
|
-import com.redxun.knowledge.analysis.entity.vo.SearchVisitHistogramVo;
|
|
|
|
|
|
+import com.redxun.knowledge.analysis.entity.vo.*;
|
|
import com.redxun.knowledge.analysis.mapper.AnalysisCommonMapper;
|
|
import com.redxun.knowledge.analysis.mapper.AnalysisCommonMapper;
|
|
import com.redxun.knowledge.analysis.mapper.PvLogMapper;
|
|
import com.redxun.knowledge.analysis.mapper.PvLogMapper;
|
|
-import com.redxun.knowledge.analysis.mapper.SearchParticipleLogMapper;
|
|
|
|
|
|
+import com.redxun.knowledge.common.UserService;
|
|
|
|
+import com.redxun.knowledge.mapper.KnowledgeCategoryMapper;
|
|
import com.redxun.knowledge.utils.DateUtils;
|
|
import com.redxun.knowledge.utils.DateUtils;
|
|
import groovy.util.logging.Slf4j;
|
|
import groovy.util.logging.Slf4j;
|
|
-import io.swagger.models.auth.In;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -36,8 +35,15 @@ public class AnalysisCommonServiceImpl {
|
|
@Autowired
|
|
@Autowired
|
|
private PvLogMapper pvLogMapper;
|
|
private PvLogMapper pvLogMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private KnowledgeCategoryMapper knowledgeCategoryMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserService userService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 各模块整体数量统计:知识仓库(知识总数量);知识地图(地图总数量);知识专辑(专辑总数量)
|
|
* 各模块整体数量统计:知识仓库(知识总数量);知识地图(地图总数量);知识专辑(专辑总数量)
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Map<String, Object> totalAmount() {
|
|
public Map<String, Object> totalAmount() {
|
|
@@ -45,14 +51,15 @@ public class AnalysisCommonServiceImpl {
|
|
Integer knowledgeTotal = analysisCommonMapper.knowledgeTotalAmount();
|
|
Integer knowledgeTotal = analysisCommonMapper.knowledgeTotalAmount();
|
|
Integer mapTotal = analysisCommonMapper.mapTotalAmount();
|
|
Integer mapTotal = analysisCommonMapper.mapTotalAmount();
|
|
Integer albumTotal = analysisCommonMapper.albumTotalAmount();
|
|
Integer albumTotal = analysisCommonMapper.albumTotalAmount();
|
|
- result.put("knowledge",knowledgeTotal);
|
|
|
|
- result.put("map",mapTotal);
|
|
|
|
- result.put("album",albumTotal);
|
|
|
|
|
|
+ result.put("knowledge", knowledgeTotal);
|
|
|
|
+ result.put("map", mapTotal);
|
|
|
|
+ result.put("album", albumTotal);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询各类型(维基、文档)知识数量
|
|
* 查询各类型(维基、文档)知识数量
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Map<String, Object> knowledgeTypeAmount() {
|
|
public Map<String, Object> knowledgeTypeAmount() {
|
|
@@ -61,14 +68,15 @@ public class AnalysisCommonServiceImpl {
|
|
Integer archiveTotal = analysisCommonMapper.knowledgeTotalByType(1);
|
|
Integer archiveTotal = analysisCommonMapper.knowledgeTotalByType(1);
|
|
//类型为2(维基知识)
|
|
//类型为2(维基知识)
|
|
Integer wikiTotal = analysisCommonMapper.knowledgeTotalByType(2);
|
|
Integer wikiTotal = analysisCommonMapper.knowledgeTotalByType(2);
|
|
- result.put("archive",archiveTotal);
|
|
|
|
- result.put("wiki",wikiTotal);
|
|
|
|
- result.put("total",archiveTotal + wikiTotal);
|
|
|
|
|
|
+ result.put("archive", archiveTotal);
|
|
|
|
+ result.put("wiki", wikiTotal);
|
|
|
|
+ result.put("total", archiveTotal + wikiTotal);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取搜索服务分词的词云数据
|
|
* 获取搜索服务分词的词云数据
|
|
|
|
+ *
|
|
* @param tops
|
|
* @param tops
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -80,6 +88,7 @@ public class AnalysisCommonServiceImpl {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取搜索服务访问量分布柱状图数据,查看一次详情算一次PV
|
|
* 获取搜索服务访问量分布柱状图数据,查看一次详情算一次PV
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public SearchVisitHistogramVo searchVisitHistogram() {
|
|
public SearchVisitHistogramVo searchVisitHistogram() {
|
|
@@ -91,7 +100,7 @@ public class AnalysisCommonServiceImpl {
|
|
DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
//统计每月各个系统的搜索访问量
|
|
//统计每月各个系统的搜索访问量
|
|
List<LablesVo> lablesVoList = new ArrayList<>();
|
|
List<LablesVo> lablesVoList = new ArrayList<>();
|
|
- for (int i = 1; i <= 12 ; i++) {
|
|
|
|
|
|
+ for (int i = 1; i <= 12; i++) {
|
|
LablesVo lablesVo = new LablesVo();
|
|
LablesVo lablesVo = new LablesVo();
|
|
List<Map<String, Object>> values = new ArrayList<>();
|
|
List<Map<String, Object>> values = new ArrayList<>();
|
|
lablesVo.setName(i + "月");
|
|
lablesVo.setName(i + "月");
|
|
@@ -104,16 +113,16 @@ public class AnalysisCommonServiceImpl {
|
|
//根据月份查询各个业务系统访问量
|
|
//根据月份查询各个业务系统访问量
|
|
platformList.forEach(e -> {
|
|
platformList.forEach(e -> {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
- Integer count = pvLogMapper.selectSearchVisitHistogramByMonth(firstOfMonth,lastOfMonth,e);
|
|
|
|
- map.put("legend",e);
|
|
|
|
- map.put("value",count);
|
|
|
|
- if (sumByMonth == 0){
|
|
|
|
- map.put("percentage",0.0000);
|
|
|
|
|
|
+ Integer count = pvLogMapper.selectSearchVisitHistogramByMonth(firstOfMonth, lastOfMonth, e);
|
|
|
|
+ map.put("legend", e);
|
|
|
|
+ map.put("value", count);
|
|
|
|
+ if (sumByMonth == 0) {
|
|
|
|
+ map.put("percentage", 0.0000);
|
|
} else {
|
|
} else {
|
|
double sum = count / (sumByMonth.doubleValue());
|
|
double sum = count / (sumByMonth.doubleValue());
|
|
BigDecimal bd = new BigDecimal(sum);
|
|
BigDecimal bd = new BigDecimal(sum);
|
|
- double f1 = bd.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
|
- map.put("percentage",f1);
|
|
|
|
|
|
+ double f1 = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
|
+ map.put("percentage", f1);
|
|
}
|
|
}
|
|
values.add(map);
|
|
values.add(map);
|
|
});
|
|
});
|
|
@@ -125,4 +134,174 @@ public class AnalysisCommonServiceImpl {
|
|
searchVisitHistogramVo.setLables(lablesVoList);
|
|
searchVisitHistogramVo.setLables(lablesVoList);
|
|
return searchVisitHistogramVo;
|
|
return searchVisitHistogramVo;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 知识类型访问量分布
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<String, Object> knowledgeTypeVisitProportion(String type) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ //获取当前年
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
|
+ //查询出结果
|
|
|
|
+ List<Integer> count = null;
|
|
|
|
+ if (type.equals("total")) {
|
|
|
|
+ count = analysisCommonMapper.knowledgeTypeVisitProportion(null, null);
|
|
|
|
+ } else if (type.equals("year")) {
|
|
|
|
+ count = analysisCommonMapper.knowledgeTypeVisitProportion(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
|
+ DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
|
|
+ } else if (type.equals("month")) {
|
|
|
|
+ int month = calendar.get(Calendar.MONTH);
|
|
|
|
+ String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
|
|
|
|
+ String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
|
|
|
|
+ count = analysisCommonMapper.knowledgeTypeVisitProportion(firstOfMonth, lastOfMonth);
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ //文档知识和维基知识查看数量
|
|
|
|
+ int archive = (int) count.stream().filter(e -> e == 1).count();
|
|
|
|
+ int wiki = (int) count.stream().filter(e -> e == 2).count();
|
|
|
|
+ map.put("archive", archive);
|
|
|
|
+ map.put("wiki", wiki);
|
|
|
|
+ //计算百分比
|
|
|
|
+ if (count.size() == 0) {
|
|
|
|
+ map.put("archivePercentage", 0.00);
|
|
|
|
+ map.put("wikiPercentage", 0.00);
|
|
|
|
+ } else {
|
|
|
|
+ BigDecimal archivebg = new BigDecimal(archive / (double) count.size());
|
|
|
|
+ double archivedouble = archivebg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
|
+ map.put("archivePercentage", archivedouble);
|
|
|
|
+ BigDecimal wikibg = new BigDecimal(wiki / (double) count.size());
|
|
|
|
+ double wikidouble = wikibg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
|
+ map.put("wikiPercentage", wikidouble);
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 各一级分类知识创建数量(包含审核中和驳回的数据)
|
|
|
|
+ *
|
|
|
|
+ * @param type
|
|
|
|
+ * @param sort
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<KnowledgeCategoryVo> level1KnowledgeHistogram(String type, String sort) {
|
|
|
|
+ //查询全部一级分类
|
|
|
|
+ List<String> level1KnowledgeIdList = analysisCommonMapper.level1Knowledge();
|
|
|
|
+ List<KnowledgeCategoryVo> result = level1KnowledgeIdList.parallelStream().map(e -> {
|
|
|
|
+ //一级分类下知识数量(包含审核中的、驳回的)
|
|
|
|
+ List<Integer> count = new ArrayList<>();
|
|
|
|
+ //获取当前年
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
|
+ KnowledgeCategoryVo knowledgeCategoryVo = new KnowledgeCategoryVo();
|
|
|
|
+ knowledgeCategoryVo.setLabel(knowledgeCategoryMapper.selectById(e).getName());
|
|
|
|
+ //查询知识分类下创建的知识数量(纬度:年 最近1个月 全部)
|
|
|
|
+ if (type.equals("total")) {
|
|
|
|
+ count = analysisCommonMapper.level1KnowledgeHistogram(e, null, null);
|
|
|
|
+ } else if (type.equals("year")) {
|
|
|
|
+ count = analysisCommonMapper.level1KnowledgeHistogram(e, DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
|
+ DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
|
|
+ } else if (type.equals("month")) {
|
|
|
|
+ int month = calendar.get(Calendar.MONTH);
|
|
|
|
+ String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
|
|
|
|
+ String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
|
|
|
|
+ count = analysisCommonMapper.level1KnowledgeHistogram(e, firstOfMonth, lastOfMonth);
|
|
|
|
+ }
|
|
|
|
+ long archive = count.stream().filter(typeKnowledge -> typeKnowledge == 1).count();
|
|
|
|
+ long wiki = count.stream().filter(typeKnowledge -> typeKnowledge == 2).count();
|
|
|
|
+ knowledgeCategoryVo.setArchive((int) archive);
|
|
|
|
+ knowledgeCategoryVo.setWiki((int) wiki);
|
|
|
|
+ return knowledgeCategoryVo;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ //排序
|
|
|
|
+ if (StringUtils.isEmpty(sort)) {
|
|
|
|
+ result = result.stream().sorted((t1, t2) -> t2.getWiki().compareTo(t1.getWiki())).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ if ("wikiDesc".equals(sort)) {
|
|
|
|
+ result = result.stream().sorted((t1, t2) -> t2.getWiki().compareTo(t1.getWiki())).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ result = result.stream().sorted((t1, t2) -> t2.getArchive().compareTo(t1.getArchive())).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 组织创建知识数量
|
|
|
|
+ *
|
|
|
|
+ * @param type
|
|
|
|
+ * @param tops
|
|
|
|
+ * @param sort
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<KnowledgeCompanyVo> organizationKnowledges(String type, Integer tops, String sort) {
|
|
|
|
+ //获取全部创建过知识的公司id
|
|
|
|
+ List<String> knowledgeCompanyIdList = analysisCommonMapper.selectCompanyId();
|
|
|
|
+ //获取当前年
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
|
+ List<KnowledgeCompanyVo> result = knowledgeCompanyIdList.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);
|
|
|
|
+ }
|
|
|
|
+ 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);
|
|
|
|
+ return knowledgeCompanyVo;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ //排序
|
|
|
|
+ if (sort != null){
|
|
|
|
+ switch (sort) {
|
|
|
|
+ case "totalDesc":
|
|
|
|
+ result = result.stream().sorted((t1, t2) -> t2.getTotal().compareTo(t1.getTotal())).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case "totalAsc":
|
|
|
|
+ result = result.stream().sorted(Comparator.comparing(KnowledgeCompanyVo::getTotal)).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case "archiveDesc":
|
|
|
|
+ result = result.stream().sorted((t1, t2) -> t2.getArchive().compareTo(t1.getArchive())).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case "archiveAsc":
|
|
|
|
+ result = result.stream().sorted(Comparator.comparing(KnowledgeCompanyVo::getArchive)).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case "wikiDesc":
|
|
|
|
+ result = result.stream().sorted((t1, t2) -> t2.getWiki().compareTo(t1.getWiki())).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case "wikiAsc":
|
|
|
|
+ result = result.stream().sorted(Comparator.comparing(KnowledgeCompanyVo::getWiki)).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 专辑创建总量
|
|
|
|
+ *
|
|
|
|
+ * @param type
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<String, Object> albumAmount(String type) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|