|
@@ -45,13 +45,13 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
//日期
|
|
//日期
|
|
LocalDate todayDate = LocalDate.now(ZoneOffset.of("+8"));
|
|
LocalDate todayDate = LocalDate.now(ZoneOffset.of("+8"));
|
|
resultMap.put("date", todayDate);
|
|
resultMap.put("date", todayDate);
|
|
- //时间占比 预先定义好长度为9的数组再向里面添加
|
|
|
|
- Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
|
|
+ //时间占比 预先定义好长度为10的数组再向里面添加
|
|
|
|
+ Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
//把当天所有行为分别加在一起装进数组
|
|
//把当天所有行为分别加在一起装进数组
|
|
for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
.eq("user_id", userId)
|
|
.eq("user_id", userId)
|
|
.eq("date", todayDate))) {
|
|
.eq("date", todayDate))) {
|
|
- timeArray[timeCalculation.getActionType()] += timeCalculation.getDuration();
|
|
|
|
|
|
+ timeArray[timeCalculation.getActionType() + 1] += timeCalculation.getDuration();
|
|
}
|
|
}
|
|
resultMap.put("timeDistribution", timeArray);
|
|
resultMap.put("timeDistribution", timeArray);
|
|
httpRespMsg.data = resultMap;
|
|
httpRespMsg.data = resultMap;
|
|
@@ -93,22 +93,24 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
map.put("name", userMap.get("name"));
|
|
map.put("name", userMap.get("name"));
|
|
map.put("phone", userMap.get("phone"));
|
|
map.put("phone", userMap.get("phone"));
|
|
//然后根据日期和用户id获取到所有的记录 然后手动累加在一起
|
|
//然后根据日期和用户id获取到所有的记录 然后手动累加在一起
|
|
- Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
|
|
|
|
- //编程 资料 文档 设计 美工 运营 小说 游戏 音乐
|
|
|
|
|
|
+ Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
|
|
|
|
+ //其他 编程 上网 文档 设计 美工 运营 看小说 影视娱乐 听音乐
|
|
for (Map<String, Object> dataMap : timeCalculationMapper
|
|
for (Map<String, Object> dataMap : timeCalculationMapper
|
|
.getTodayStatistics((String) userMap.get("id"), date, companyId)) {
|
|
.getTodayStatistics((String) userMap.get("id"), date, companyId)) {
|
|
- timeArray[(int) dataMap.get("type")] += (Long) dataMap.get("duration");
|
|
|
|
|
|
+ timeArray[(int) dataMap.get("type") + 1] += (Long) dataMap.get("duration");
|
|
}
|
|
}
|
|
- Long[] resultArray = new Long[5];
|
|
|
|
- //编程 浏览 设计 办公 娱乐
|
|
|
|
- resultArray[0] = timeArray[0];
|
|
|
|
- resultArray[1] = timeArray[1] + timeArray[2];
|
|
|
|
- resultArray[2] = timeArray[3] + timeArray[4];
|
|
|
|
- resultArray[3] = timeArray[5];
|
|
|
|
- resultArray[4] = timeArray[6] + timeArray[7] + timeArray[8];
|
|
|
|
|
|
+ Long[] resultArray = new Long[7];
|
|
|
|
+ //编程 上网 文档 设计 运营 娱乐 其他
|
|
|
|
+ resultArray[0] = timeArray[1];
|
|
|
|
+ resultArray[1] = timeArray[2];
|
|
|
|
+ resultArray[2] = timeArray[3];
|
|
|
|
+ resultArray[3] = timeArray[4] + timeArray[5];
|
|
|
|
+ resultArray[4] = timeArray[6];
|
|
|
|
+ resultArray[5] = timeArray[7] + timeArray[8] + timeArray[9];
|
|
|
|
+ resultArray[6] = timeArray[0];
|
|
//将后端的9中行为类型分门别类转换为前端的5种并转换为字符串格式
|
|
//将后端的9中行为类型分门别类转换为前端的5种并转换为字符串格式
|
|
- String[] stringArray = new String[5];
|
|
|
|
- for (int i = 0; i < 5; i++) {
|
|
|
|
|
|
+ String[] stringArray = new String[7];
|
|
|
|
+ for (int i = 0; i < 7; i++) {
|
|
stringArray[i] = convertSecond(resultArray[i]);
|
|
stringArray[i] = convertSecond(resultArray[i]);
|
|
}
|
|
}
|
|
map.put("statistics", stringArray);
|
|
map.put("statistics", stringArray);
|