|
@@ -11,10 +11,12 @@ import com.fs.company.service.IStatisticManageService;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
import com.fs.statis.dto.ComprehensiveStatisticsDTO;
|
|
import com.fs.statis.dto.ComprehensiveStatisticsDTO;
|
|
|
import com.fs.statis.param.ComprehensiveStatisticsParam;
|
|
import com.fs.statis.param.ComprehensiveStatisticsParam;
|
|
|
|
|
+import com.fs.utils.MyDateUtils;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
|
@@ -28,6 +30,7 @@ import java.util.stream.Collectors;
|
|
|
* @author: Guos
|
|
* @author: Guos
|
|
|
* @time: 2025/10/30 上午9:21
|
|
* @time: 2025/10/30 上午9:21
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Lazy
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
@@ -44,7 +47,7 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public Object statisticMain(ComprehensiveStatisticsParam param) {
|
|
|
|
|
|
|
+ public List<ComprehensiveStatisticsDTO> statisticMain(ComprehensiveStatisticsParam param) {
|
|
|
if(param.getDimension() == DimensionEnum.COMPANY.getValue()){
|
|
if(param.getDimension() == DimensionEnum.COMPANY.getValue()){
|
|
|
return getStatisticNumByCompany(param);
|
|
return getStatisticNumByCompany(param);
|
|
|
}
|
|
}
|
|
@@ -62,10 +65,10 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
/**
|
|
/**
|
|
|
* 按照公司维度统计数据
|
|
* 按照公司维度统计数据
|
|
|
*/
|
|
*/
|
|
|
- public List getStatisticNumByCompany(ComprehensiveStatisticsParam param) {
|
|
|
|
|
|
|
+ public List<ComprehensiveStatisticsDTO> getStatisticNumByCompany(ComprehensiveStatisticsParam param) {
|
|
|
List<CompanyDeptUserInfo> companyInfo = statisticManageMapper.getCompanyInfo();
|
|
List<CompanyDeptUserInfo> companyInfo = statisticManageMapper.getCompanyInfo();
|
|
|
List result = Lists.newArrayList();
|
|
List result = Lists.newArrayList();
|
|
|
- List<Date> dates = generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
|
|
|
|
+ List<Date> dates = MyDateUtils.generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
for (Date date : dates){
|
|
for (Date date : dates){
|
|
|
param.setStartTime(date);
|
|
param.setStartTime(date);
|
|
|
param.setEndTime(date);
|
|
param.setEndTime(date);
|
|
@@ -97,12 +100,12 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
/**
|
|
/**
|
|
|
* 根据部门id获取个人统计数据
|
|
* 根据部门id获取个人统计数据
|
|
|
*/
|
|
*/
|
|
|
- public List getStatisticNumByDeptId(ComprehensiveStatisticsParam param){
|
|
|
|
|
|
|
+ public List<ComprehensiveStatisticsDTO> getStatisticNumByDeptId(ComprehensiveStatisticsParam param){
|
|
|
//先获取部门下的用户的信息
|
|
//先获取部门下的用户的信息
|
|
|
Long id = param.getId();
|
|
Long id = param.getId();
|
|
|
List<CompanyDeptUserInfo> searchUserInfo = statisticManageMapper.getSearchUserInfo(id);
|
|
List<CompanyDeptUserInfo> searchUserInfo = statisticManageMapper.getSearchUserInfo(id);
|
|
|
List result = Lists.newArrayList();
|
|
List result = Lists.newArrayList();
|
|
|
- List<Date> dates = generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
|
|
|
|
+ List<Date> dates = MyDateUtils.generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
for (Date date : dates) {
|
|
for (Date date : dates) {
|
|
|
param.setStartTime(date);
|
|
param.setStartTime(date);
|
|
|
param.setEndTime(date);
|
|
param.setEndTime(date);
|
|
@@ -147,11 +150,11 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
/**
|
|
/**
|
|
|
* 根据公司获取统部门的计数据
|
|
* 根据公司获取统部门的计数据
|
|
|
*/
|
|
*/
|
|
|
- public List getStatisticNumByCompanyId(ComprehensiveStatisticsParam param){
|
|
|
|
|
|
|
+ public List<ComprehensiveStatisticsDTO> getStatisticNumByCompanyId(ComprehensiveStatisticsParam param){
|
|
|
//先从公司拿到公司和部门的信息
|
|
//先从公司拿到公司和部门的信息
|
|
|
List<CompanyDeptUserInfo> searchDeptInfo = statisticManageMapper.getSearchDeptInfo(param.getId());;
|
|
List<CompanyDeptUserInfo> searchDeptInfo = statisticManageMapper.getSearchDeptInfo(param.getId());;
|
|
|
List result = Lists.newArrayList();
|
|
List result = Lists.newArrayList();
|
|
|
- List<Date> dates = generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
|
|
|
|
+ List<Date> dates = MyDateUtils.generateDateList(param.getStartTime(), param.getEndTime());
|
|
|
for (Date date : dates){
|
|
for (Date date : dates){
|
|
|
param.setStartTime(date);
|
|
param.setStartTime(date);
|
|
|
param.setEndTime(date);
|
|
param.setEndTime(date);
|
|
@@ -188,54 +191,6 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 生成开始时间到结束时间之间的每日时间数组
|
|
|
|
|
- * @param startTime 开始时间
|
|
|
|
|
- * @param endTime 结束时间
|
|
|
|
|
- * @return 时间数组列表
|
|
|
|
|
- */
|
|
|
|
|
- public List<Date> generateDateList(Date startTime, Date endTime) {
|
|
|
|
|
- List<Date> dateList = new ArrayList<>();
|
|
|
|
|
- if (startTime == null || endTime == null) {
|
|
|
|
|
- return dateList;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
|
|
- calendar.setTime(startTime);
|
|
|
|
|
-
|
|
|
|
|
- // 设置时间为当天00:00:00,确保按天计算
|
|
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
-
|
|
|
|
|
- Date currentDate = calendar.getTime();
|
|
|
|
|
- Date finalEndTime = getStartOfDay(endTime);
|
|
|
|
|
-
|
|
|
|
|
- while (!currentDate.after(finalEndTime)) {
|
|
|
|
|
- dateList.add(currentDate);
|
|
|
|
|
- calendar.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
- currentDate = calendar.getTime();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return dateList;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取指定日期的开始时间(00:00:00)
|
|
|
|
|
- * @param date 指定日期
|
|
|
|
|
- * @return 当天开始时间
|
|
|
|
|
- */
|
|
|
|
|
- private Date getStartOfDay(Date date) {
|
|
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
|
|
- calendar.setTime(date);
|
|
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
- return calendar.getTime();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取搜索公司信息
|
|
* 获取搜索公司信息
|
|
|
*/
|
|
*/
|
|
@@ -436,73 +391,6 @@ public class StatisticManageServiceImpl implements IStatisticManageService {
|
|
|
return build;
|
|
return build;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-// /**
|
|
|
|
|
-// * 执行定时任务
|
|
|
|
|
-// * 还需要考虑在统计部门数据时,部门下面没有用户,某个时候这个部门下面又加入新的用户了,这个时候就会出现数据偏差
|
|
|
|
|
-// */
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void executeTask() {
|
|
|
|
|
-// StopWatch stopWatch = new StopWatch();
|
|
|
|
|
-// stopWatch.start("gs-执行数据统计任务");
|
|
|
|
|
-// List<CompanyDeptUserInfo> companyDeptdUserList = statisticManageMapper.getCompanyAndDeptAndDeptUserList(null);
|
|
|
|
|
-// log.info("统计人数列表:{}", companyDeptdUserList.size());
|
|
|
|
|
-// companyDeptdUserList.forEach(companyDeptUserInfo -> {
|
|
|
|
|
-// CompanyDeptUserInfoDTO statisticNum = new CompanyDeptUserInfoDTO();
|
|
|
|
|
-// boolean empty = null == companyDeptUserInfo.getUserId(); //用户id为空返回true
|
|
|
|
|
-// if(!empty){
|
|
|
|
|
-// statisticNum = statisticManageMapper.getStatisticNum(companyDeptUserInfo.getUserId());
|
|
|
|
|
-// }
|
|
|
|
|
-// ComprehensiveDailyStats comprehensiveDailyStats = component(companyDeptUserInfo, statisticNum);
|
|
|
|
|
-// ComprehensiveDailyStats selectResult = null;
|
|
|
|
|
-// if(!empty){
|
|
|
|
|
-// //用户id不为空,我们就用用户id去查询这个日期是否有数据
|
|
|
|
|
-// selectResult = statisticManageMapper.selectByUserAndDate(comprehensiveDailyStats.getUserId(), comprehensiveDailyStats.getStatisticsTime());
|
|
|
|
|
-// }else{
|
|
|
|
|
-// //如果用户id为空,说明部门下面没有人(没人情况下,部门id只会在当天的日期中存在一条),先按照部门去查询后删除(或者直接按照id更新就可以了)
|
|
|
|
|
-// selectResult = statisticManageMapper.selectByDeptAndDate(companyDeptUserInfo.getDeptId(), comprehensiveDailyStats.getStatisticsTime());
|
|
|
|
|
-// }
|
|
|
|
|
-// if(!ObjectUtils.isEmpty(selectResult)){
|
|
|
|
|
-// comprehensiveDailyStats.setId(selectResult.getId());
|
|
|
|
|
-// statisticManageMapper.updateById(comprehensiveDailyStats);
|
|
|
|
|
-// }else{
|
|
|
|
|
-// statisticManageMapper.insert(comprehensiveDailyStats);
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-// stopWatch.stop();
|
|
|
|
|
-// log.info("gs-执行数据统计任务完成,耗时:{}", stopWatch.getTotalTimeSeconds());
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// private ComprehensiveDailyStats component(CompanyDeptUserInfo source, CompanyDeptUserInfoDTO statisticNum){
|
|
|
|
|
-// ComprehensiveDailyStats target = new ComprehensiveDailyStats();
|
|
|
|
|
-// target.setCompanyId(source.getCompanyId());
|
|
|
|
|
-// target.setCompanyName(source.getCompanyName());
|
|
|
|
|
-// target.setDeptId(source.getDeptId());
|
|
|
|
|
-// target.setDeptName(source.getDeptName());
|
|
|
|
|
-// target.setStatisticsTime(new Date());
|
|
|
|
|
-// target.setCreateTime(new Date());
|
|
|
|
|
-// target.setUpdateTime(new Date());
|
|
|
|
|
-// if(null != source.getUserId()){
|
|
|
|
|
-// target.setUserId(source.getUserId());
|
|
|
|
|
-// target.setUserName(source.getUserName());
|
|
|
|
|
-// target.setNickName(source.getNickName());
|
|
|
|
|
-// target.setAnswerNum(statisticNum.getAnswerNum());
|
|
|
|
|
-// target.setCompleteNum(statisticNum.getCompleteNum());
|
|
|
|
|
-// target.setLineNum(statisticNum.getLineNum());
|
|
|
|
|
-// target.setActiveNum(statisticNum.getActiveNum());
|
|
|
|
|
-// target.setRedPacketNum(statisticNum.getRedPacketNum());
|
|
|
|
|
-// target.setRedPacketAmount(new BigDecimal(0.00));
|
|
|
|
|
-// }else{
|
|
|
|
|
-// target.setAnswerNum(0);
|
|
|
|
|
-// target.setCompleteNum(0);
|
|
|
|
|
-// target.setLineNum(0);
|
|
|
|
|
-// target.setActiveNum(0);
|
|
|
|
|
-// target.setRedPacketNum(0);
|
|
|
|
|
-// target.setRedPacketAmount(new BigDecimal(0.00));
|
|
|
|
|
-// }
|
|
|
|
|
-// return target;
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|