|
|
@@ -105,46 +105,57 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
Long id = param.getId();
|
|
|
List<CompanyDeptUserInfo> searchUserInfo = statisticManageMapper.getSearchUserInfo(id);
|
|
|
List result = Lists.newArrayList();
|
|
|
- List<Date> dates = MyDateUtils.generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
- for (Date date : dates) {
|
|
|
- param.setStartTime(date);
|
|
|
- param.setEndTime(date);
|
|
|
- for (CompanyDeptUserInfo companyDeptUserInfo : searchUserInfo) {
|
|
|
- Long parentId = companyDeptUserInfo.getParentId();
|
|
|
- Long deptId = companyDeptUserInfo.getDeptId();
|
|
|
- if (parentId != BigDecimal.ZERO.longValue()) {
|
|
|
- Optional<CompanyDeptUserInfo> first = searchUserInfo.stream().filter(dept -> dept.getDeptId().equals(parentId)).findFirst();
|
|
|
- if (first.isPresent()){
|
|
|
- CompanyDeptUserInfo findParentDept = first.get();
|
|
|
- String parentDeptName = findParentDept.getDeptName();
|
|
|
- String deptName = companyDeptUserInfo.getDeptName();
|
|
|
- companyDeptUserInfo.setDeptName(parentDeptName + "/" + deptName);
|
|
|
- }
|
|
|
- }
|
|
|
- String companyName = companyDeptUserInfo.getCompanyName();
|
|
|
- Long companyId = companyDeptUserInfo.getCompanyId();
|
|
|
- param.setUserId(companyDeptUserInfo.getUserId());
|
|
|
- ComprehensiveStatisticsDTO statisticDataByDeptId =
|
|
|
- statisticManageMapper.getStatisticDataByDeptId(param);
|
|
|
- if(ObjectUtils.isEmpty(statisticDataByDeptId)){
|
|
|
- statisticDataByDeptId = new ComprehensiveStatisticsDTO();
|
|
|
- statisticDataByDeptId.setAnswerNum(BigDecimal.ZERO.intValue());
|
|
|
- statisticDataByDeptId.setRedPacketNum(BigDecimal.ZERO.intValue());
|
|
|
- statisticDataByDeptId.setSendCount(BigDecimal.ZERO.intValue());
|
|
|
- statisticDataByDeptId.setRedPacketAmount(BigDecimal.ZERO);
|
|
|
- statisticDataByDeptId.setCompleteNum(BigDecimal.ZERO.intValue());
|
|
|
+
|
|
|
+ if(param.getTimeGroupFlag()){
|
|
|
+ List<Date> dates = MyDateUtils.generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
+ for (Date date : dates) {
|
|
|
+ param.setStartTime(date);
|
|
|
+ param.setEndTime(date);
|
|
|
+ personalDimension(param, date, searchUserInfo, result);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ personalDimension(param, null, searchUserInfo, result);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void personalDimension(ComprehensiveStatisticsParam param, Date date, List<CompanyDeptUserInfo> searchUserInfo, List result) {
|
|
|
+ for (CompanyDeptUserInfo companyDeptUserInfo : searchUserInfo) {
|
|
|
+ Long parentId = companyDeptUserInfo.getParentId();
|
|
|
+ Long deptId = companyDeptUserInfo.getDeptId();
|
|
|
+ if (parentId != BigDecimal.ZERO.longValue()) {
|
|
|
+ Optional<CompanyDeptUserInfo> first = searchUserInfo.stream().filter(dept -> dept.getDeptId().equals(parentId)).findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ CompanyDeptUserInfo findParentDept = first.get();
|
|
|
+ String parentDeptName = findParentDept.getDeptName();
|
|
|
+ String deptName = companyDeptUserInfo.getDeptName();
|
|
|
+ companyDeptUserInfo.setDeptName(parentDeptName + "/" + deptName);
|
|
|
}
|
|
|
- statisticDataByDeptId.setCompanyUserName(companyDeptUserInfo.getNickName());
|
|
|
- statisticDataByDeptId.setCompanyUserId(companyDeptUserInfo.getUserId());
|
|
|
- statisticDataByDeptId.setDeptName(companyDeptUserInfo.getDeptName());
|
|
|
- statisticDataByDeptId.setDeptId(deptId.intValue());
|
|
|
- statisticDataByDeptId.setCompanyName(companyName);
|
|
|
- statisticDataByDeptId.setCompanyId(companyId);
|
|
|
+ }
|
|
|
+ String companyName = companyDeptUserInfo.getCompanyName();
|
|
|
+ Long companyId = companyDeptUserInfo.getCompanyId();
|
|
|
+ param.setUserId(companyDeptUserInfo.getUserId());
|
|
|
+ ComprehensiveStatisticsDTO statisticDataByDeptId =
|
|
|
+ statisticManageMapper.getStatisticDataByDeptId(param);
|
|
|
+ if(ObjectUtils.isEmpty(statisticDataByDeptId)){
|
|
|
+ statisticDataByDeptId = new ComprehensiveStatisticsDTO();
|
|
|
+ statisticDataByDeptId.setAnswerNum(BigDecimal.ZERO.intValue());
|
|
|
+ statisticDataByDeptId.setRedPacketNum(BigDecimal.ZERO.intValue());
|
|
|
+ statisticDataByDeptId.setSendCount(BigDecimal.ZERO.intValue());
|
|
|
+ statisticDataByDeptId.setRedPacketAmount(BigDecimal.ZERO);
|
|
|
+ statisticDataByDeptId.setCompleteNum(BigDecimal.ZERO.intValue());
|
|
|
+ }
|
|
|
+ statisticDataByDeptId.setCompanyUserName(companyDeptUserInfo.getNickName());
|
|
|
+ statisticDataByDeptId.setCompanyUserId(companyDeptUserInfo.getUserId());
|
|
|
+ statisticDataByDeptId.setDeptName(companyDeptUserInfo.getDeptName());
|
|
|
+ statisticDataByDeptId.setDeptId(deptId.intValue());
|
|
|
+ statisticDataByDeptId.setCompanyName(companyName);
|
|
|
+ statisticDataByDeptId.setCompanyId(companyId);
|
|
|
+ if(date != null){
|
|
|
statisticDataByDeptId.setStatisticsTime(date);
|
|
|
- result.add(statisticDataByDeptId);
|
|
|
}
|
|
|
+ result.add(statisticDataByDeptId);
|
|
|
}
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -154,43 +165,53 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
//先从公司拿到公司和部门的信息
|
|
|
List<CompanyDeptUserInfo> searchDeptInfo = statisticManageMapper.getSearchDeptInfo(param.getId());;
|
|
|
List result = Lists.newArrayList();
|
|
|
- List<Date> dates = MyDateUtils.generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
- for (Date date : dates){
|
|
|
- param.setStartTime(date);
|
|
|
- param.setEndTime(date);
|
|
|
- for (CompanyDeptUserInfo companyDeptUserInfo : searchDeptInfo) {
|
|
|
- //判断当前部门的父级id不是0就组装名称
|
|
|
- Long parentId = companyDeptUserInfo.getParentId();
|
|
|
- if(parentId != BigDecimal.ZERO.longValue()){
|
|
|
- String parentDeptName = searchDeptInfo.stream().filter(dept -> dept.getDeptId().equals(parentId)).findFirst().get().getDeptName();
|
|
|
- String deptName = companyDeptUserInfo.getDeptName();
|
|
|
- companyDeptUserInfo.setDeptName(parentDeptName + "/" + deptName);
|
|
|
- }
|
|
|
- String companyName = companyDeptUserInfo.getCompanyName();
|
|
|
- Long deptId = companyDeptUserInfo.getDeptId();
|
|
|
- Long companyId = companyDeptUserInfo.getCompanyId();
|
|
|
- param.setDeptId(deptId);
|
|
|
- ComprehensiveStatisticsDTO statisticDataByDeptId =
|
|
|
- statisticManageMapper.getStatisticDataByDeptId(param);
|
|
|
- if(ObjectUtils.isEmpty(statisticDataByDeptId)){
|
|
|
- statisticDataByDeptId = new ComprehensiveStatisticsDTO();
|
|
|
- statisticDataByDeptId.setAnswerNum(BigDecimal.ZERO.intValue());
|
|
|
- statisticDataByDeptId.setRedPacketNum(BigDecimal.ZERO.intValue());
|
|
|
- statisticDataByDeptId.setSendCount(BigDecimal.ZERO.intValue());
|
|
|
- statisticDataByDeptId.setRedPacketAmount(BigDecimal.ZERO);
|
|
|
- statisticDataByDeptId.setCompleteNum(BigDecimal.ZERO.intValue());
|
|
|
- }
|
|
|
- statisticDataByDeptId.setDeptName(companyDeptUserInfo.getDeptName());
|
|
|
- statisticDataByDeptId.setDeptId(deptId.intValue());
|
|
|
- statisticDataByDeptId.setCompanyName(companyName);
|
|
|
- statisticDataByDeptId.setCompanyId(companyId);
|
|
|
- statisticDataByDeptId.setStatisticsTime(date);
|
|
|
- result.add(statisticDataByDeptId);
|
|
|
+ if(param.getTimeGroupFlag()){
|
|
|
+ List<Date> dates = MyDateUtils.generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
+ for (Date date : dates){
|
|
|
+ param.setStartTime(date);
|
|
|
+ param.setEndTime(date);
|
|
|
+ deptDimension(param, date, searchDeptInfo, result);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ deptDimension(param, null, searchDeptInfo, result);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private void deptDimension(ComprehensiveStatisticsParam param, Date date, List<CompanyDeptUserInfo> searchDeptInfo, List result) {
|
|
|
+ for (CompanyDeptUserInfo companyDeptUserInfo : searchDeptInfo) {
|
|
|
+ //判断当前部门的父级id不是0就组装名称
|
|
|
+ Long parentId = companyDeptUserInfo.getParentId();
|
|
|
+ if(parentId != BigDecimal.ZERO.longValue()){
|
|
|
+ String parentDeptName = searchDeptInfo.stream().filter(dept -> dept.getDeptId().equals(parentId)).findFirst().get().getDeptName();
|
|
|
+ String deptName = companyDeptUserInfo.getDeptName();
|
|
|
+ companyDeptUserInfo.setDeptName(parentDeptName + "/" + deptName);
|
|
|
+ }
|
|
|
+ String companyName = companyDeptUserInfo.getCompanyName();
|
|
|
+ Long deptId = companyDeptUserInfo.getDeptId();
|
|
|
+ Long companyId = companyDeptUserInfo.getCompanyId();
|
|
|
+ param.setDeptId(deptId);
|
|
|
+ ComprehensiveStatisticsDTO statisticDataByDeptId =
|
|
|
+ statisticManageMapper.getStatisticDataByDeptId(param);
|
|
|
+ if(ObjectUtils.isEmpty(statisticDataByDeptId)){
|
|
|
+ statisticDataByDeptId = new ComprehensiveStatisticsDTO();
|
|
|
+ statisticDataByDeptId.setAnswerNum(BigDecimal.ZERO.intValue());
|
|
|
+ statisticDataByDeptId.setRedPacketNum(BigDecimal.ZERO.intValue());
|
|
|
+ statisticDataByDeptId.setSendCount(BigDecimal.ZERO.intValue());
|
|
|
+ statisticDataByDeptId.setRedPacketAmount(BigDecimal.ZERO);
|
|
|
+ statisticDataByDeptId.setCompleteNum(BigDecimal.ZERO.intValue());
|
|
|
+ }
|
|
|
+ statisticDataByDeptId.setDeptName(companyDeptUserInfo.getDeptName());
|
|
|
+ statisticDataByDeptId.setDeptId(deptId.intValue());
|
|
|
+ statisticDataByDeptId.setCompanyName(companyName);
|
|
|
+ statisticDataByDeptId.setCompanyId(companyId);
|
|
|
+ if(date != null){
|
|
|
+ statisticDataByDeptId.setStatisticsTime(date);
|
|
|
+ }
|
|
|
+ result.add(statisticDataByDeptId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取搜索公司信息
|
|
|
*/
|