|
@@ -116,6 +116,8 @@ public class AttenDanceWarnNoticeTask {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ LocalDateTime attendanceTime = getAttendanceTime(ruleDetailsList, now);
|
|
|
|
+
|
|
//判断所有当前时间下,哪几条规则需要进行提醒
|
|
//判断所有当前时间下,哪几条规则需要进行提醒
|
|
Map<Long, Integer> ruleDetailsJudgeMap = judgeExecuteNotice(now, ruleDetailsList, recentlyTime);
|
|
Map<Long, Integer> ruleDetailsJudgeMap = judgeExecuteNotice(now, ruleDetailsList, recentlyTime);
|
|
|
|
|
|
@@ -139,7 +141,7 @@ public class AttenDanceWarnNoticeTask {
|
|
|
|
|
|
|
|
|
|
JSONObject time5 = new JSONObject();
|
|
JSONObject time5 = new JSONObject();
|
|
- time5.put("value", recentlyTime.format(formatter));
|
|
|
|
|
|
+ time5.put("value", attendanceTime.format(formatter));
|
|
paramJson.put("time5", time5);
|
|
paramJson.put("time5", time5);
|
|
|
|
|
|
JSONObject thing8 = new JSONObject();
|
|
JSONObject thing8 = new JSONObject();
|
|
@@ -190,36 +192,30 @@ public class AttenDanceWarnNoticeTask {
|
|
&& ruleDetails.getIsAttendance() != null && ruleDetails.getIsAttendance() == 1){
|
|
&& ruleDetails.getIsAttendance() != null && ruleDetails.getIsAttendance() == 1){
|
|
if(ruleDetails.getAmStartTime() != null){
|
|
if(ruleDetails.getAmStartTime() != null){
|
|
LocalDateTime amStartTime = judgeTime.with(ruleDetails.getAmStartTime().toLocalTime());
|
|
LocalDateTime amStartTime = judgeTime.with(ruleDetails.getAmStartTime().toLocalTime());
|
|
- if(recentlyTime.isEqual(amStartTime)){
|
|
|
|
- Long amBetween = ChronoUnit.MINUTES.between(judgeTime, amStartTime);
|
|
|
|
- if(judgeTime.isBefore(amStartTime) && amBetween >= ruleDetails.getAgoMinutes() - 1 && amBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
|
|
|
|
- result.put(ruleDetails.getId(), 1);
|
|
|
|
- }else if(judgeTime.isAfter(amStartTime) && amBetween >= ruleDetails.getOverMinutes() - 1 && amBetween <= ruleDetails.getOverMinutes() + 1){
|
|
|
|
- result.put(ruleDetails.getId(), 2);
|
|
|
|
- }
|
|
|
|
|
|
+ Long amBetween = Math.abs(ChronoUnit.MINUTES.between(judgeTime, amStartTime));
|
|
|
|
+ if(recentlyTime.isEqual(amStartTime.plusMinutes(- ruleDetails.getAgoMinutes())) && amBetween >= ruleDetails.getAgoMinutes() - 1 && amBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
|
|
|
|
+ result.put(ruleDetails.getId(), 1);
|
|
|
|
+ }else if(recentlyTime.isEqual(amStartTime.plusMinutes(ruleDetails.getOverMinutes())) && amBetween >= ruleDetails.getOverMinutes() - 1 && amBetween <= ruleDetails.getOverMinutes() + 1){
|
|
|
|
+ result.put(ruleDetails.getId(), 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(ruleDetails.getPmStartTime() != null){
|
|
if(ruleDetails.getPmStartTime() != null){
|
|
LocalDateTime pmStartTime = judgeTime.with(ruleDetails.getPmStartTime().toLocalTime());
|
|
LocalDateTime pmStartTime = judgeTime.with(ruleDetails.getPmStartTime().toLocalTime());
|
|
- if(recentlyTime.isEqual(pmStartTime)){
|
|
|
|
- Long pmBetween = ChronoUnit.MINUTES.between(judgeTime, pmStartTime);
|
|
|
|
- if(judgeTime.isBefore(pmStartTime) && pmBetween >= ruleDetails.getAgoMinutes() - 1 && pmBetween <= ruleDetails.getAgoMinutes() + 1){
|
|
|
|
- result.put(ruleDetails.getId(), 1);
|
|
|
|
- }else if(judgeTime.isAfter(pmStartTime) && pmBetween >= ruleDetails.getOverMinutes() - 1 && pmBetween <= ruleDetails.getOverMinutes() + 1){
|
|
|
|
- result.put(ruleDetails.getId(), 2);
|
|
|
|
- }
|
|
|
|
|
|
+ Long pmBetween = Math.abs(ChronoUnit.MINUTES.between(judgeTime, pmStartTime));
|
|
|
|
+ if(recentlyTime.isEqual(pmStartTime.plusMinutes(- ruleDetails.getAgoMinutes())) && pmBetween >= ruleDetails.getAgoMinutes() - 1 && pmBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
|
|
|
|
+ result.put(ruleDetails.getId(), 1);
|
|
|
|
+ }else if(recentlyTime.isEqual(pmStartTime.plusMinutes(ruleDetails.getOverMinutes())) && pmBetween >= ruleDetails.getOverMinutes() - 1 && pmBetween <= ruleDetails.getOverMinutes() + 1){
|
|
|
|
+ result.put(ruleDetails.getId(), 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if(ruleDetails.getEveningStartTime() != null){
|
|
if(ruleDetails.getEveningStartTime() != null){
|
|
LocalDateTime eveningStartTime = judgeTime.with(ruleDetails.getEveningStartTime().toLocalTime());
|
|
LocalDateTime eveningStartTime = judgeTime.with(ruleDetails.getEveningStartTime().toLocalTime());
|
|
- if(recentlyTime.isEqual(eveningStartTime)){
|
|
|
|
- Long eveningBetween = ChronoUnit.MINUTES.between(judgeTime, eveningStartTime);
|
|
|
|
- if(judgeTime.isBefore(eveningStartTime) && eveningBetween >= ruleDetails.getAgoMinutes() - 1 && eveningBetween <= ruleDetails.getAgoMinutes() + 1){
|
|
|
|
- result.put(ruleDetails.getId(), 1);
|
|
|
|
- }else if(judgeTime.isAfter(eveningStartTime) && eveningBetween >= ruleDetails.getOverMinutes() - 1 && eveningBetween <= ruleDetails.getOverMinutes() + 1){
|
|
|
|
- result.put(ruleDetails.getId(), 2);
|
|
|
|
- }
|
|
|
|
|
|
+ Long eveningBetween = Math.abs(ChronoUnit.MINUTES.between(judgeTime, eveningStartTime));
|
|
|
|
+ if(recentlyTime.isEqual(eveningStartTime.plusMinutes(- ruleDetails.getAgoMinutes())) && eveningBetween >= ruleDetails.getAgoMinutes() - 1 && eveningBetween <= ruleDetails.getAgoMinutes() + 1){//相差分钟数小于0
|
|
|
|
+ result.put(ruleDetails.getId(), 1);
|
|
|
|
+ }else if(recentlyTime.isEqual(eveningStartTime.plusMinutes(ruleDetails.getOverMinutes())) && eveningBetween >= ruleDetails.getOverMinutes() - 1 && eveningBetween <= ruleDetails.getOverMinutes() + 1){
|
|
|
|
+ result.put(ruleDetails.getId(), 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -283,4 +279,38 @@ public class AttenDanceWarnNoticeTask {
|
|
return timeMap.get(collect.get(0));
|
|
return timeMap.get(collect.get(0));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ LocalDateTime getAttendanceTime(List<AttendanceRuleDetails> ruleDetails, LocalDateTime now){
|
|
|
|
+ List<LocalDateTime> result = new ArrayList<>();
|
|
|
|
+ for (AttendanceRuleDetails ruleDetail : ruleDetails) {
|
|
|
|
+ if(ruleDetail.getIsAllowInOutSchool() != null && ruleDetail.getIsAllowInOutSchool() == 1
|
|
|
|
+ && ruleDetail.getIsAttendance() != null && ruleDetail.getIsAttendance() == 1){
|
|
|
|
+ if(ruleDetail.getAmStartTime() != null){
|
|
|
|
+ LocalDateTime amStartTime = now.with(ruleDetail.getAmStartTime().toLocalTime());
|
|
|
|
+ result.add(amStartTime);
|
|
|
|
+ }
|
|
|
|
+ if(ruleDetail.getPmStartTime() != null){
|
|
|
|
+ LocalDateTime pmStartTime = now.with(ruleDetail.getPmStartTime().toLocalTime());
|
|
|
|
+ result.add(pmStartTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(ruleDetail.getEveningStartTime() != null){
|
|
|
|
+ LocalDateTime eveningStartTime = now.with(ruleDetail.getEveningStartTime().toLocalTime());
|
|
|
|
+ result.add(eveningStartTime);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(result.isEmpty()){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Map<Long, LocalDateTime> timeMap = new HashMap<>();
|
|
|
|
+ for (LocalDateTime localDateTime : result) {
|
|
|
|
+ long between = ChronoUnit.SECONDS.between(now, localDateTime);
|
|
|
|
+ timeMap.put(Math.abs(between), localDateTime);
|
|
|
|
+ }
|
|
|
|
+ List<Long> collect = timeMap.keySet().stream().collect(Collectors.toList());
|
|
|
|
+ Collections.sort(collect, Long::compare);
|
|
|
|
+
|
|
|
|
+ return timeMap.get(collect.get(0));
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|