|
@@ -1,14 +1,21 @@
|
|
package com.redxun.knowledge.analysis.service;
|
|
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.AlbumDetailVisitsVo;
|
|
import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
|
|
import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
|
|
|
|
+import com.redxun.knowledge.analysis.entity.vo.SynthesizeCompanyVo;
|
|
import com.redxun.knowledge.analysis.mapper.AnalysisSynthesizeMapper;
|
|
import com.redxun.knowledge.analysis.mapper.AnalysisSynthesizeMapper;
|
|
|
|
+import com.redxun.knowledge.common.UserService;
|
|
import com.redxun.knowledge.utils.DateUtils;
|
|
import com.redxun.knowledge.utils.DateUtils;
|
|
|
|
+import com.redxun.knowledge.utils.PageListUtils;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 文件名: AnalysisSynthesizeServiceImpl
|
|
* 文件名: AnalysisSynthesizeServiceImpl
|
|
@@ -26,6 +33,9 @@ public class AnalysisSynthesizeServiceImpl {
|
|
@Autowired
|
|
@Autowired
|
|
private AnalysisSynthesizeMapper analysisSynthesizeMapper;
|
|
private AnalysisSynthesizeMapper analysisSynthesizeMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserService userService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 各板块访问量分布
|
|
* 各板块访问量分布
|
|
* @param type
|
|
* @param type
|
|
@@ -64,4 +74,40 @@ public class AnalysisSynthesizeServiceImpl {
|
|
});
|
|
});
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 组织访问量
|
|
|
|
+ * @param queryData
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public IPage organizationVisits(QueryData queryData) {
|
|
|
|
+ //获取排序规则
|
|
|
|
+ String sort = queryData.getSortField();
|
|
|
|
+ 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);
|
|
|
|
+ } else if ("year".equals(queryData.getParams().get("type"))) {
|
|
|
|
+ result = analysisSynthesizeMapper.organizationVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ String tops = queryData.getParams().get("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);
|
|
|
|
+ }
|
|
}
|
|
}
|