|
@@ -1,17 +1,22 @@
|
|
|
package com.fs.company.service.impl;
|
|
package com.fs.company.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import com.fs.common.enums.DimensionEnum;
|
|
|
import com.fs.company.domain.CompanyDeptUserInfo;
|
|
import com.fs.company.domain.CompanyDeptUserInfo;
|
|
|
import com.fs.company.dto.CompanyDeptUserInfoDTO;
|
|
import com.fs.company.dto.CompanyDeptUserInfoDTO;
|
|
|
import com.fs.company.mapper.StatisticManageMapper;
|
|
import com.fs.company.mapper.StatisticManageMapper;
|
|
|
import com.fs.company.service.IStatisticManageService;
|
|
import com.fs.company.service.IStatisticManageService;
|
|
|
|
|
+import com.fs.statis.param.ComprehensiveStatisticsParam;
|
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -28,15 +33,67 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private StatisticManageMapper statisticManageMapper;
|
|
private StatisticManageMapper statisticManageMapper;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 统计
|
|
* 统计
|
|
|
* 按照部门分组情况
|
|
* 按照部门分组情况
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public List<Map<String, Object>> statisticMain(ComprehensiveStatisticsParam param) {
|
|
|
|
|
+ if (param.getDimension() == DimensionEnum.PERSONAL.getValue()){
|
|
|
|
|
+ Assert.notNull(param.getId(), "按个人展示查询条件不能为空!");
|
|
|
|
|
+ getStatisticNumByPersonal( DimensionEnum.PERSONAL.getValue(), param.getStartTime(), param.getEndTime(), param.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(param.getDimension() == DimensionEnum.COMPANY.getValue()){
|
|
|
|
|
+ //按照公司统计,如果id为空就要展示全部公司,如果不为空就展示id查询的公司
|
|
|
|
|
+ if(ObjectUtil.isEmpty(param.getId())){
|
|
|
|
|
+ //得到所有公司信息
|
|
|
|
|
+ List<CompanyDeptUserInfo> companyInfo = statisticManageMapper.getCompanyInfo();
|
|
|
|
|
+ for (CompanyDeptUserInfo companyDeptUserInfo : companyInfo){
|
|
|
|
|
+ getStatisticNumByPersonal(DimensionEnum.COMPANY.getValue(), param.getStartTime(), param.getEndTime(),
|
|
|
|
|
+ companyDeptUserInfo.getCompanyId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //else{
|
|
|
|
|
+ // getStatisticNumByPersonal(DimensionEnum.COMPANY.getValue(), param.getStartTime(), param.getEndTime(),
|
|
|
|
|
+ // param.getId());
|
|
|
|
|
+ //}
|
|
|
|
|
+ }
|
|
|
|
|
+ if(param.getDimension() == DimensionEnum.DEPARTMENT.getValue()){
|
|
|
|
|
+ Assert.notNull(param.getId(), "按部门展示公司不能为空!");
|
|
|
|
|
+ List<CompanyDeptUserInfo> companyDeptdUserList = statisticManageMapper.getCompanyAndDeptAndDeptUserList(param.getId());
|
|
|
|
|
+ //按照部门分组
|
|
|
|
|
+ Map<Long, List<CompanyDeptUserInfo>> deptInfos = companyDeptdUserList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(CompanyDeptUserInfo::getDeptId));
|
|
|
|
|
+ deptInfos.forEach((deptId, companyDeptUserInfos) -> {
|
|
|
|
|
+ Long[] userIds = companyDeptUserInfos.stream().map(CompanyDeptUserInfo::getUserId).toArray(Long[]::new);
|
|
|
|
|
+ getStatisticNumByPersonal(DimensionEnum.PERSONAL.getValue(), param.getStartTime(), param.getEndTime(),userIds);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取统计数据
|
|
|
|
|
+ * @param dimension 维度
|
|
|
|
|
+ * @param startTime 开始时间
|
|
|
|
|
+ * @param endTime 结束时间
|
|
|
|
|
+ * @param userIds 用户id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public void getStatisticNumByPersonal(Integer dimension, Date startTime, Date endTime, Long... userIds) {
|
|
|
|
|
+ statisticManageMapper.getStatisticNumByPersonal(dimension,startTime, endTime, userIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 统计1.0
|
|
|
|
|
+ * 按照部门分组情况
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
public List<Map<String, Object>> statisticMain() {
|
|
public List<Map<String, Object>> statisticMain() {
|
|
|
- List<CompanyDeptUserInfo> companyDeptdUserList = statisticManageMapper.getCompanyAndDeptAndDeptUserList();
|
|
|
|
|
|
|
+ List<CompanyDeptUserInfo> companyDeptdUserList = statisticManageMapper.getCompanyAndDeptAndDeptUserList(null);
|
|
|
if(CollectionUtils.isEmpty(companyDeptdUserList)){return null;}
|
|
if(CollectionUtils.isEmpty(companyDeptdUserList)){return null;}
|
|
|
//按照部门分组
|
|
//按照部门分组
|
|
|
Map<Long, List<CompanyDeptUserInfo>> deptInfos = companyDeptdUserList.stream()
|
|
Map<Long, List<CompanyDeptUserInfo>> deptInfos = companyDeptdUserList.stream()
|
|
@@ -94,7 +151,7 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
|
|
|
|
|
private List<Map<String, Object>> groupByCompanyAndCompanyName(List<CompanyDeptUserInfoDTO> source){
|
|
private List<Map<String, Object>> groupByCompanyAndCompanyName(List<CompanyDeptUserInfoDTO> source){
|
|
|
//按照companyId和companyName分组
|
|
//按照companyId和companyName分组
|
|
|
- Map<Integer, List<CompanyDeptUserInfoDTO>> companyInfos = source.stream()
|
|
|
|
|
|
|
+ Map<Long, List<CompanyDeptUserInfoDTO>> companyInfos = source.stream()
|
|
|
.collect(Collectors.groupingBy(CompanyDeptUserInfoDTO::getCompanyId));
|
|
.collect(Collectors.groupingBy(CompanyDeptUserInfoDTO::getCompanyId));
|
|
|
List<Map<String, Object>> resultList = Lists.newArrayList();
|
|
List<Map<String, Object>> resultList = Lists.newArrayList();
|
|
|
companyInfos.forEach((companyId, companyDeptUserInfoDTOS) -> {
|
|
companyInfos.forEach((companyId, companyDeptUserInfoDTOS) -> {
|