|
@@ -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);
|
|
@@ -105,8 +106,9 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
//然后根据日期和用户id获取到所有的记录 然后手动累加在一起
|
|
|
Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
|
|
|
//其他 编程 上网 文档 设计 美工 运营 看小说 影视娱乐 听音乐
|
|
|
- for (Map<String, Object> dataMap : timeCalculationMapper
|
|
|
- .getTodayStatistics((String) userMap.get("id"), date, companyId)) {
|
|
|
+ List<Map<String, Object>> tatistics = timeCalculationMapper
|
|
|
+ .getTodayStatistics((String) userMap.get("id"), date, companyId);
|
|
|
+ for (Map<String, Object> dataMap : tatistics) {
|
|
|
timeArray[(int) dataMap.get("type") + 1] += (Long) dataMap.get("duration");
|
|
|
}
|
|
|
Long[] resultArray = new Long[6];
|
|
@@ -180,7 +182,7 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
total += todayTime;
|
|
|
list.add(map);
|
|
|
}
|
|
|
- /*这个时间复杂度巨几把高的for循环可以用某种算法优化 至少计算过的应该排除才对*/
|
|
|
+ /*后续可以用迭代器把重复数据删掉*/
|
|
|
}
|
|
|
dataMap.put("time", list);
|
|
|
//这里检查如果只需要一天记录的话 说明是pc端界面那个地方 那就再多计算一个当天总工作时间
|