|
@@ -55,9 +55,10 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
//时间占比 预先定义好长度为10的数组再向里面添加
|
|
|
Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
//把当天所有行为分别加在一起装进数组
|
|
|
- for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
|
+ List<TimeCalculation> list = timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
|
.eq("user_id", userId)
|
|
|
- .eq("date", todayDate))) {
|
|
|
+ .eq("date", todayDate));
|
|
|
+ for (TimeCalculation timeCalculation : list) {
|
|
|
timeArray[timeCalculation.getActionType() + 1] += timeCalculation.getDuration();
|
|
|
}
|
|
|
resultMap.put("timeDistribution", timeArray);
|
|
@@ -180,7 +181,7 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
total += todayTime;
|
|
|
list.add(map);
|
|
|
}
|
|
|
- /*这个时间复杂度巨几把高的for循环可以用某种算法优化 至少计算过的应该排除才对*/
|
|
|
+ /*后续可以用迭代器把重复数据删掉*/
|
|
|
}
|
|
|
dataMap.put("time", list);
|
|
|
//这里检查如果只需要一天记录的话 说明是pc端界面那个地方 那就再多计算一个当天总工作时间
|