Commit 0099ed29 authored by shiyu's avatar shiyu

签到校验是否打卡时段

parent a8be5f1d
...@@ -24,7 +24,11 @@ import org.slf4j.Logger; ...@@ -24,7 +24,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -62,8 +66,24 @@ public class QdUserSignInServiceImpl implements QdUserSignInService { ...@@ -62,8 +66,24 @@ public class QdUserSignInServiceImpl implements QdUserSignInService {
//检查是否已签到过 //检查是否已签到过
String todayStr = DateUtils.DATE.format(LocalDate.now()); String todayStr = DateUtils.DATE.format(LocalDate.now());
if (qdUserSignInDao.isExisted(userId, todayStr, taskId)) { if (qdUserSignInDao.isExisted(userId, todayStr, taskId)) {
return Result.failed("您今天已签到过"); return Result.failed("今天已打过卡");
} }
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("H:mm");
SimpleDateFormat timeFormat = new SimpleDateFormat("H:mm");
if (signInTask.getSignInStartTime() != null && signInTask.getSignInEndTime() != null) {
String start = timeFormat.format(signInTask.getSignInStartTime());
String end = timeFormat.format(signInTask.getSignInEndTime());
LocalTime localTime = LocalTime.parse(start, dateTimeFormatter);
LocalDate today = LocalDate.now();
LocalDateTime todayStartTime = today.atTime(localTime);
LocalTime endlocalTime = LocalTime.parse(end, dateTimeFormatter);
LocalDateTime todayEndTime = today.atTime(endlocalTime);
LocalDateTime nowTime = LocalDateTime.now();
if (nowTime.isBefore(todayStartTime) || nowTime.isAfter(todayEndTime)) {
return Result.failed("非打卡时段");
}
}
//签到记录id //签到记录id
Long recordId = null; Long recordId = null;
//今天尚未签到,则进行记录,先查询昨天的打卡记录,有则再连续打卡天数上+1,没有则算签到第一天 //今天尚未签到,则进行记录,先查询昨天的打卡记录,有则再连续打卡天数上+1,没有则算签到第一天
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment