Explorar el Código

获取上一条记录的时间条件修改为id

Reiskuchen hace 5 años
padre
commit
7618e5f47e

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -89,7 +89,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             TimeCalculation latestRecord = timeCalculationMapper.selectOne(new QueryWrapper<TimeCalculation>()
                     .eq("user_id", screenshot.getUid())
                     .eq("date", screenshot.getIndate().toLocalDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
-                    .orderByDesc("end_time")
+                    .orderByDesc("id")
                     .last("LIMIT 1"));
             //截图时间
             LocalTime currentTime = screenshot.getIndate().toLocalTime();

+ 4 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java

@@ -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端界面那个地方 那就再多计算一个当天总工作时间