|
@@ -48,12 +48,16 @@ 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();
|
|
|
}
|
|
|
- resultMap.put("timeDistribution", timeArray);
|
|
|
+ for(int i = 0; i <= 9; i++){
|
|
|
+ stringArray[i] = convertSecond(timeArray[i]);
|
|
|
+ }
|
|
|
+ resultMap.put("timeDistribution", stringArray);
|
|
|
httpRespMsg.data = resultMap;
|
|
|
return httpRespMsg;
|
|
|
}
|
|
@@ -92,15 +96,15 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
map.put("name", userMap.get("name"));
|
|
|
map.put("phone", userMap.get("phone"));
|
|
|
//然后根据日期和用户id获取到所有的记录 然后手动累加在一起
|
|
|
- Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
+ Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
|
|
|
for (Map<String, Object> dataMap : timeCalculationMapper
|
|
|
.getTodayStatistics((String) userMap.get("id"), date, companyId)) {
|
|
|
- timeArray[(int) dataMap.get("type")] += (int) dataMap.get("duration");
|
|
|
+ timeArray[(int) dataMap.get("type")] += (Long) dataMap.get("duration");
|
|
|
}
|
|
|
map.put("statistics", timeArray);
|
|
|
//最后是数组的和
|
|
|
- Integer sum = 0;
|
|
|
- for (Integer singleNumber : timeArray) {
|
|
|
+ Long sum = 0L;
|
|
|
+ for (Long singleNumber : timeArray) {
|
|
|
sum += singleNumber;
|
|
|
}
|
|
|
map.put("sum", sum);
|
|
@@ -151,8 +155,8 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
}
|
|
|
dataMap.put("time", list);
|
|
|
//这里检查如果只有一天记录的话那就再多计算一个当天总工作时间
|
|
|
- if (resultList.size() == 1) {
|
|
|
- dataMap.put("total", convertSecond(total));
|
|
|
+ if (dateList.size() == 1) {
|
|
|
+ dataMap.put("total", total);
|
|
|
}
|
|
|
resultList.add(dataMap);
|
|
|
}
|
|
@@ -172,6 +176,15 @@ 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) {
|
|
|
+ Long hour = 0L, minute = 0L, second = 0L;
|
|
|
+ hour = time / 3600;
|
|
|
+ time = time % 3600;
|
|
|
+ minute = time / 60;
|
|
|
+ second = minute % 60;
|
|
|
+ return hour + "时" + minute + "分" + second + "秒";
|
|
|
}
|
|
|
}
|