|
@@ -3,9 +3,7 @@ package com.redxun.knowledge.analysis.service;
|
|
|
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.vo.AlbumDetailVisitsVo;
|
|
|
-import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
|
|
|
-import com.redxun.knowledge.analysis.entity.vo.SynthesizeCompanyVo;
|
|
|
+import com.redxun.knowledge.analysis.entity.vo.*;
|
|
|
import com.redxun.knowledge.analysis.mapper.AnalysisSynthesizeMapper;
|
|
|
import com.redxun.knowledge.common.UserService;
|
|
|
import com.redxun.knowledge.utils.DateUtils;
|
|
@@ -38,15 +36,16 @@ public class AnalysisSynthesizeServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* 各板块访问量分布
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> moduleUserVisits(String type) {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
int year = calendar.get(Calendar.YEAR);
|
|
|
- List<AlbumDetailVisitsVo> moduleUserVisitsVo = new ArrayList<>();
|
|
|
- if ("total".equals(type)){
|
|
|
- moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserVisits(null,null);
|
|
|
+ List<AlbumDetailVisitsVo> moduleUserVisitsVo = new ArrayList<>();
|
|
|
+ if ("total".equals(type)) {
|
|
|
+ moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserVisits(null, null);
|
|
|
} else if ("year".equals(type)) {
|
|
|
moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
@@ -58,18 +57,18 @@ public class AnalysisSynthesizeServiceImpl {
|
|
|
}
|
|
|
Map<String, Object> result = new LinkedHashMap<>();
|
|
|
moduleUserVisitsVo.forEach(e -> {
|
|
|
- if (e.getName().equals("搜索服务")){
|
|
|
- result.put("search",e.getValue());
|
|
|
- result.put("searchPercentage",e.getPercentage());
|
|
|
- } else if (e.getName().equals("知识仓库")){
|
|
|
- result.put("knowledge",e.getValue());
|
|
|
- result.put("knowledgePercentage",e.getPercentage());
|
|
|
- } else if (e.getName().equals("知识地图")){
|
|
|
- result.put("map",e.getValue());
|
|
|
- result.put("mapPercentage",e.getPercentage());
|
|
|
- } else if (e.getName().equals("知识专辑")){
|
|
|
- result.put("album",e.getValue());
|
|
|
- result.put("albumPercentage",e.getPercentage());
|
|
|
+ if (e.getName().equals("搜索服务")) {
|
|
|
+ result.put("search", e.getValue());
|
|
|
+ result.put("searchPercentage", e.getPercentage());
|
|
|
+ } else if (e.getName().equals("知识仓库")) {
|
|
|
+ result.put("knowledge", e.getValue());
|
|
|
+ result.put("knowledgePercentage", e.getPercentage());
|
|
|
+ } else if (e.getName().equals("知识地图")) {
|
|
|
+ result.put("map", e.getValue());
|
|
|
+ result.put("mapPercentage", e.getPercentage());
|
|
|
+ } else if (e.getName().equals("知识专辑")) {
|
|
|
+ result.put("album", e.getValue());
|
|
|
+ result.put("albumPercentage", e.getPercentage());
|
|
|
}
|
|
|
});
|
|
|
return result;
|
|
@@ -77,51 +76,53 @@ public class AnalysisSynthesizeServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* 组织访问量
|
|
|
+ *
|
|
|
* @param queryData
|
|
|
* @return
|
|
|
*/
|
|
|
public IPage organizationVisits(QueryData queryData) {
|
|
|
//获取排序规则
|
|
|
String sort = queryData.getSortField();
|
|
|
- if (sort != null){
|
|
|
+ if (sort != null) {
|
|
|
sort = sort + queryData.getSortOrder();
|
|
|
}
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
int year = calendar.get(Calendar.YEAR);
|
|
|
- List<SynthesizeCompanyVo> result = new ArrayList<>();
|
|
|
- if ("total".equals(queryData.getParams().get("type"))){
|
|
|
- result = analysisSynthesizeMapper.organizationVisits(null,null,sort);
|
|
|
+ List<SynthesizeCompanyVo> result = new ArrayList<>();
|
|
|
+ if ("total".equals(queryData.getParams().get("type"))) {
|
|
|
+ result = analysisSynthesizeMapper.organizationVisits(null, null, sort);
|
|
|
} else if ("year".equals(queryData.getParams().get("type"))) {
|
|
|
result = analysisSynthesizeMapper.organizationVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
- DateUtils.format(DateUtils.getLastOfYear(year)),sort);
|
|
|
+ DateUtils.format(DateUtils.getLastOfYear(year)), sort);
|
|
|
} 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);
|
|
|
- result = analysisSynthesizeMapper.organizationVisits(firstOfMonth, lastOfMonth,sort);
|
|
|
+ result = analysisSynthesizeMapper.organizationVisits(firstOfMonth, lastOfMonth, sort);
|
|
|
}
|
|
|
String tops = queryData.getParams().get("tops");
|
|
|
- if(StringUtils.isNotEmpty(tops)){
|
|
|
+ if (StringUtils.isNotEmpty(tops)) {
|
|
|
result = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
|
|
|
} else {
|
|
|
result = result.stream().limit(10).collect(Collectors.toList());
|
|
|
}
|
|
|
//公司名称赋值
|
|
|
result.forEach(e -> e.setCompany(userService.findDeptByDeptId(e.getCompany()).getName()));
|
|
|
- return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),result);
|
|
|
+ return PageListUtils.getPages(queryData.getPageNo(), queryData.getPageSize(), result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 各板块访问量分布(UV)
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> moduleUserUniqueVisits(String type) {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
int year = calendar.get(Calendar.YEAR);
|
|
|
- List<AlbumDetailVisitsVo> moduleUserVisitsVo = new ArrayList<>();
|
|
|
- if ("total".equals(type)){
|
|
|
- moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserUniqueVisits(null,null);
|
|
|
+ List<AlbumDetailVisitsVo> moduleUserVisitsVo = new ArrayList<>();
|
|
|
+ if ("total".equals(type)) {
|
|
|
+ moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserUniqueVisits(null, null);
|
|
|
} else if ("year".equals(type)) {
|
|
|
moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserUniqueVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
DateUtils.format(DateUtils.getLastOfYear(year)));
|
|
@@ -133,20 +134,60 @@ public class AnalysisSynthesizeServiceImpl {
|
|
|
}
|
|
|
Map<String, Object> result = new LinkedHashMap<>();
|
|
|
moduleUserVisitsVo.forEach(e -> {
|
|
|
- if (e.getName().equals("搜索服务")){
|
|
|
- result.put("search",e.getValue());
|
|
|
- result.put("searchPercentage",e.getPercentage());
|
|
|
- } else if (e.getName().equals("知识仓库")){
|
|
|
- result.put("knowledge",e.getValue());
|
|
|
- result.put("knowledgePercentage",e.getPercentage());
|
|
|
- } else if (e.getName().equals("知识地图")){
|
|
|
- result.put("map",e.getValue());
|
|
|
- result.put("mapPercentage",e.getPercentage());
|
|
|
- } else if (e.getName().equals("知识专辑")){
|
|
|
- result.put("album",e.getValue());
|
|
|
- result.put("albumPercentage",e.getPercentage());
|
|
|
+ if (e.getName().equals("搜索服务")) {
|
|
|
+ result.put("search", e.getValue());
|
|
|
+ result.put("searchPercentage", e.getPercentage());
|
|
|
+ } else if (e.getName().equals("知识仓库")) {
|
|
|
+ result.put("knowledge", e.getValue());
|
|
|
+ result.put("knowledgePercentage", e.getPercentage());
|
|
|
+ } else if (e.getName().equals("知识地图")) {
|
|
|
+ result.put("map", e.getValue());
|
|
|
+ result.put("mapPercentage", e.getPercentage());
|
|
|
+ } else if (e.getName().equals("知识专辑")) {
|
|
|
+ result.put("album", e.getValue());
|
|
|
+ result.put("albumPercentage", e.getPercentage());
|
|
|
}
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户访问总量
|
|
|
+ *
|
|
|
+ * @param module
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public CreateUserView totalUserVisits(String module, String type) {
|
|
|
+ if ("total".equals(module)){
|
|
|
+ module = null;
|
|
|
+ } else if ("knowledge".equals(module)){
|
|
|
+ module = "知识仓库";
|
|
|
+ } else if ("album".equals(module)){
|
|
|
+ module = "知识专辑";
|
|
|
+ } else if ("map".equals(module)){
|
|
|
+ module = "知识地图";
|
|
|
+ } else if ("search".equals(module)){
|
|
|
+ module = "搜索服务";
|
|
|
+ }
|
|
|
+ CreateUserView createUserView = new CreateUserView();
|
|
|
+ List<CreateUserViewLabel> createUserViewLabel = new ArrayList<>();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ if (("total").equals(type)) {
|
|
|
+ createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(null, null, module);
|
|
|
+ } else if ("year".equals(type)) {
|
|
|
+ createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
+ DateUtils.format(DateUtils.getLastOfYear(year)), module);
|
|
|
+ } 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);
|
|
|
+ createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(firstOfMonth, lastOfMonth, module);
|
|
|
+ }
|
|
|
+ int sum = createUserViewLabel.stream().mapToInt(e -> e.getPv() + e.getUv()).sum();
|
|
|
+ createUserView.setTotal(sum);
|
|
|
+ createUserView.setLables(createUserViewLabel);
|
|
|
+ return createUserView;
|
|
|
+ }
|
|
|
}
|