|
|
@@ -84,6 +84,7 @@ public class ScheduleController {
|
|
|
//0 0 22 * * ?
|
|
|
@Async
|
|
|
@Scheduled(cron = "0 0 */1 * * ?")//一个小时
|
|
|
+ //@Scheduled(cron = "0 */1 * * * ?")//1分钟
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public void autoDispatch() throws Exception {
|
|
|
|
|
|
@@ -91,6 +92,7 @@ public class ScheduleController {
|
|
|
if (scheduleConfig.getIsOpen().equals("1")) {
|
|
|
|
|
|
List<SmartAttendance> attendances = new ArrayList<>();
|
|
|
+ List<Integer> deleteAttendances = new ArrayList<>();
|
|
|
List<SmartUser> students = smartUserService.queryStudentDatas();
|
|
|
|
|
|
// SmartUser studentData = smartUserService.getSmartById(1088);
|
|
|
@@ -149,9 +151,9 @@ public class ScheduleController {
|
|
|
for (AttendanceRuleListEventByClazzResult.DataItem eventId : eventItems) {
|
|
|
|
|
|
//判断考勤是否开始 用考勤事件的开始时间和当前时间判断 考勤规则开始生效了才拉取
|
|
|
- Date eventStartTime =TimeExchange.StringToDate((TimeExchange.getDate() + " " + eventId.getAttendStartTime() + ":00"), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date eventStartTime = TimeExchange.StringToDate((TimeExchange.getDate() + " " + eventId.getAttendStartTime() + ":00"), "yyyy-MM-dd HH:mm:ss");
|
|
|
Date nowDate = new Date();
|
|
|
- if(nowDate.compareTo(eventStartTime) < 0){
|
|
|
+ if (nowDate.compareTo(eventStartTime) < 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
@@ -199,10 +201,10 @@ public class ScheduleController {
|
|
|
if (newAttends != null && newAttends.size() > 0) {
|
|
|
int i = 0;
|
|
|
for (AttendanceServiceListAttendClassRecordsResult.RecordsItem newAttend : newAttends) {
|
|
|
- if (newAttend.getStatus().intValue() != 6) {//请假数据不通过考勤接口拿 因为考勤给的请假数据没有请假原因和请假时长
|
|
|
- if (oldAttends.size() > i) {
|
|
|
- SmartAttendance oldData = new SmartAttendance();
|
|
|
- oldData = oldAttends.get(i);
|
|
|
+ if (oldAttends.size() > i) {
|
|
|
+ SmartAttendance oldData = new SmartAttendance();
|
|
|
+ oldData = oldAttends.get(i);
|
|
|
+ if (newAttend.getStatus().intValue() != 6) {
|
|
|
boolean isUpdate = false;
|
|
|
Date AttendTime = StringUtils.hasText(newAttend.getAttendTime()) ? TimeExchange.StringToDate((TimeExchange.getDate() + " " + newAttend.getAttendTime()), "yyyy-MM-dd HH:mm:ss") : TimeExchange.StringToDate((TimeExchange.getDate() + " " + eventId.getAttendEndTime() + ":00"), "yyyy-MM-dd HH:mm:ss");
|
|
|
if (oldData.getAttendTime().compareTo(AttendTime) != 0) {
|
|
|
@@ -220,8 +222,11 @@ public class ScheduleController {
|
|
|
if (isUpdate) {
|
|
|
attendances.add(oldData);
|
|
|
}
|
|
|
-
|
|
|
- } else {
|
|
|
+ }else{
|
|
|
+ deleteAttendances.add(oldData.getId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (newAttend.getStatus().intValue() != 6) {//请假数据不通过考勤接口拿 因为考勤给的请假数据没有请假原因和请假时长
|
|
|
SmartAttendance attendance = new SmartAttendance();
|
|
|
attendance.setUserId(student.get().getId());
|
|
|
attendance.setUserUid(newAttend.getUserUid());
|
|
|
@@ -235,6 +240,8 @@ public class ScheduleController {
|
|
|
attendances.add(attendance);
|
|
|
}
|
|
|
}
|
|
|
+ i++;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -247,6 +254,9 @@ public class ScheduleController {
|
|
|
if (attendances.size() > 0) {
|
|
|
smartAttendanceService.saveOrUpdateBatch(attendances);
|
|
|
}
|
|
|
+ if(deleteAttendances.size() > 0){
|
|
|
+ smartAttendanceService.deleteDatasByids(deleteAttendances);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (
|
|
|
Exception e) {
|