|
|
@@ -252,19 +252,23 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
}
|
|
|
|
|
|
// 打卡日期是今天,且不存在打卡记录,则有两种情况:1.今天不用打卡;2.今天需要打卡但是还没打卡
|
|
|
- if (punchInDate.isEqual(today) && Objects.isNull(piTaskHistory)) {
|
|
|
+ if (punchInDate.isEqual(today)) {
|
|
|
// 判断是否需要打卡
|
|
|
boolean repeatResult = punchInCoreManager.judgeRepeat(piTask, today.toString());
|
|
|
- return repeatResult ? PunchInResultViewEnum.UNDONE : PunchInResultViewEnum.NOT_NEED;
|
|
|
- }
|
|
|
-
|
|
|
- // 打卡日期是今天,且存在打卡记录,则进一步判断打卡结果
|
|
|
- if (punchInDate.isEqual(today) && Objects.nonNull(piTaskHistory)) {
|
|
|
+ // 今天不用无须打卡
|
|
|
+ if (!repeatResult) {
|
|
|
+ return PunchInResultViewEnum.NOT_NEED;
|
|
|
+ }
|
|
|
+ // 今天还没有打卡记录无法判断打卡结果
|
|
|
+ if (Objects.isNull(piTaskHistory)) {
|
|
|
+ return PunchInResultViewEnum.TODAY_UNKNOWN;
|
|
|
+ }
|
|
|
+ // 今天有打卡记录,完成打卡则显示完成,未完成则显示未知
|
|
|
PunchInResultEnum punchInResult = punchInCoreManager.judgePunchInResultInTask(piTask, piTaskHistory);
|
|
|
- return PunchInResultEnum.DONE.equals(punchInResult) ? PunchInResultViewEnum.DONE : PunchInResultViewEnum.UNDONE;
|
|
|
+ return PunchInResultEnum.DONE.equals(punchInResult) ? PunchInResultViewEnum.DONE : PunchInResultViewEnum.TODAY_UNKNOWN;
|
|
|
}
|
|
|
|
|
|
- // 不符合任何情况则是未打卡
|
|
|
+ // 不符合任何情况则是无需打卡
|
|
|
return PunchInResultViewEnum.NOT_NEED;
|
|
|
}
|
|
|
|
|
|
@@ -400,6 +404,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
|
|
|
// 待更新/新增的打卡记录
|
|
|
PiTaskHistory tempPiTaskHistory = new PiTaskHistory();
|
|
|
+ tempPiTaskHistory.setSettlePiTaskId(piTask.getId());
|
|
|
// 不存在则新增,存在则更新
|
|
|
if (Objects.isNull(oldPiTaskHistory)) {
|
|
|
tempPiTaskHistory.setTaskUniqueId(piTask.getUniqueId());
|
|
|
@@ -434,6 +439,10 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
tempPiTaskHistory.setTimeTrack(request.getTimeTrack());
|
|
|
}
|
|
|
|
|
|
+ // 设置打卡结果
|
|
|
+ PunchInResultEnum punchInResult = punchInCoreManager.judgePunchInResultInTask(piTask, tempPiTaskHistory);
|
|
|
+ tempPiTaskHistory.setPunchInResult(punchInResult);
|
|
|
+
|
|
|
// 新增或更新
|
|
|
if (Objects.isNull(oldPiTaskHistory)) {
|
|
|
piTaskHistoryService.insert(tempPiTaskHistory);
|
|
|
@@ -477,6 +486,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
|
|
|
PiTaskHistory updatePiTaskHistory = new PiTaskHistory();
|
|
|
updatePiTaskHistory.setId(piTaskHistory.getId());
|
|
|
+ updatePiTaskHistory.setSettlePiTaskId(piTask.getId());
|
|
|
|
|
|
// 单次打卡,次数置为0
|
|
|
if (PunchInMethodEnum.SINGLE.equals(piTask.getPunchInMethod())) {
|
|
|
@@ -497,6 +507,10 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
updatePiTaskHistory.setCountTrack(countTrack - 1);
|
|
|
}
|
|
|
|
|
|
+ // 设置打卡结果
|
|
|
+ PunchInResultEnum punchInResult = punchInCoreManager.judgePunchInResultInTask(piTask, updatePiTaskHistory);
|
|
|
+ updatePiTaskHistory.setPunchInResult(punchInResult);
|
|
|
+
|
|
|
// 更新
|
|
|
piTaskHistoryService.update(updatePiTaskHistory);
|
|
|
|
|
|
@@ -640,7 +654,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Cacheable(cacheNames = CacheNameConstant.TASK_HISTORY_LIST_FOR_USER, key = "#userId+'_'+punchInDate", condition = "#userId != null && punchInDate != null && !punchInDate.isBlank()")
|
|
|
+ @Cacheable(cacheNames = CacheNameConstant.TASK_HISTORY_LIST_FOR_USER, key = "#userId+'_'+#punchInDate", condition = "#userId != null && #punchInDate != null && !#punchInDate.isBlank()")
|
|
|
public List<PiTaskHistory> getTaskHistoryListInCache(Long userId, String punchInDate) {
|
|
|
Assert.isNullInBusiness(userId, "用户ID不能为空");
|
|
|
Assert.isNullInBusiness(punchInDate, "打卡日期不能为空");
|