|
@@ -48,16 +48,12 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
resultMap.put("date", todayDate);
|
|
|
//时间占比 预先定义好长度为9的数组再向里面添加
|
|
|
Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
- String[] stringArray = new String[9];
|
|
|
for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
|
.eq("user_id", userId)
|
|
|
.eq("date", todayDate))) {
|
|
|
timeArray[timeCalculation.getActionType()] += timeCalculation.getDuration();
|
|
|
}
|
|
|
- for(int i = 0; i <= 9; i++){
|
|
|
- stringArray[i] = convertSecond(timeArray[i]);
|
|
|
- }
|
|
|
- resultMap.put("timeDistribution", stringArray);
|
|
|
+ resultMap.put("timeDistribution", timeArray);
|
|
|
httpRespMsg.data = resultMap;
|
|
|
return httpRespMsg;
|
|
|
}
|
|
@@ -97,17 +93,21 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
map.put("phone", userMap.get("phone"));
|
|
|
//然后根据日期和用户id获取到所有的记录 然后手动累加在一起
|
|
|
Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
|
|
|
+ String[] stringArray = new String[9];
|
|
|
for (Map<String, Object> dataMap : timeCalculationMapper
|
|
|
.getTodayStatistics((String) userMap.get("id"), date, companyId)) {
|
|
|
timeArray[(int) dataMap.get("type")] += (Long) dataMap.get("duration");
|
|
|
}
|
|
|
- map.put("statistics", timeArray);
|
|
|
+ for (int i = 0; i < 9; i++) {
|
|
|
+ stringArray[i] = convertSecond(timeArray[i]);
|
|
|
+ }
|
|
|
+ map.put("statistics", stringArray);
|
|
|
//最后是数组的和
|
|
|
Long sum = 0L;
|
|
|
for (Long singleNumber : timeArray) {
|
|
|
sum += singleNumber;
|
|
|
}
|
|
|
- map.put("sum", sum);
|
|
|
+ map.put("sum", convertSecond(sum));
|
|
|
resultList.add(map);
|
|
|
}
|
|
|
httpRespMsg.data = resultList;
|
|
@@ -176,7 +176,7 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
time = time % 3600;
|
|
|
minute = time / 60;
|
|
|
second = minute % 60;
|
|
|
- return hour + "时" + minute + "分" + second + "秒";
|
|
|
+ return hour + "小时" + minute + "分" + second + "秒";
|
|
|
}
|
|
|
|
|
|
private String convertSecond(Long time) {
|
|
@@ -185,6 +185,6 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
time = time % 3600;
|
|
|
minute = time / 60;
|
|
|
second = minute % 60;
|
|
|
- return hour + "时" + minute + "分" + second + "秒";
|
|
|
+ return hour + "小时" + minute + "分" + second + "秒";
|
|
|
}
|
|
|
}
|