|
@@ -1,13 +1,17 @@
|
|
package com.xjrsoft.module.job;
|
|
package com.xjrsoft.module.job;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.xjrsoft.XjrSoftApplication;
|
|
import com.xjrsoft.XjrSoftApplication;
|
|
import com.xjrsoft.common.enums.OutInStatusEnum;
|
|
import com.xjrsoft.common.enums.OutInStatusEnum;
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
|
+import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
|
|
import com.xjrsoft.module.attendance.entity.TeacherAttendanceRecord;
|
|
import com.xjrsoft.module.attendance.entity.TeacherAttendanceRecord;
|
|
import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
|
|
import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
|
|
import com.xjrsoft.module.attendance.service.ITeacherAttendanceRecordService;
|
|
import com.xjrsoft.module.attendance.service.ITeacherAttendanceRecordService;
|
|
import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
|
|
import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
|
|
|
|
+import com.xjrsoft.module.holiday.entity.HolidayDate;
|
|
|
|
+import com.xjrsoft.module.holiday.service.IHolidayDateService;
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
import com.xjrsoft.module.outint.dto.TeacherOutInRecordDto;
|
|
import com.xjrsoft.module.outint.dto.TeacherOutInRecordDto;
|
|
@@ -30,7 +34,9 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -64,12 +70,13 @@ class AttendanceRecordTaskTest {
|
|
@Autowired
|
|
@Autowired
|
|
private ITeacherAttendanceRecordService recordService;
|
|
private ITeacherAttendanceRecordService recordService;
|
|
|
|
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHolidayDateService holidayDateService;
|
|
@Test
|
|
@Test
|
|
public void execute() {
|
|
public void execute() {
|
|
|
|
|
|
- LocalDateTime now = LocalDateTime.of(2024, 10, 14, 0, 0, 0);
|
|
|
|
- for (int i = 0; i < 7; i ++){
|
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.of(2024, 10, 20, 0, 0, 0);
|
|
|
|
+ for (int i = 0; i < 1; i ++){
|
|
LocalDateTime startDateTime = now.plusDays(i).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
LocalDateTime startDateTime = now.plusDays(i).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
LocalDateTime endDateTime = startDateTime.plusDays(i).withHour(23).withMinute(59).withSecond(59);
|
|
LocalDateTime endDateTime = startDateTime.plusDays(i).withHour(23).withMinute(59).withSecond(59);
|
|
|
|
|
|
@@ -95,61 +102,73 @@ class AttendanceRecordTaskTest {
|
|
List<Long> userIds = teacherList.stream().map(User::getId).collect(Collectors.toList());
|
|
List<Long> userIds = teacherList.stream().map(User::getId).collect(Collectors.toList());
|
|
Map<Long, AttendanceRuleDetailsUserVo> teacherTodyRuleByUserId = ruleCategoryService.getTeacherTodyRuleByUserId(userIds);
|
|
Map<Long, AttendanceRuleDetailsUserVo> teacherTodyRuleByUserId = ruleCategoryService.getTeacherTodyRuleByUserId(userIds);
|
|
|
|
|
|
|
|
+ List<Integer> holidayTypes = Arrays.asList(1, 3);
|
|
|
|
+ List<HolidayDate> holidayDates = holidayDateService.list(
|
|
|
|
+ new QueryWrapper<HolidayDate>().lambda()
|
|
|
|
+ .in(HolidayDate::getStatus, holidayTypes)
|
|
|
|
+ );
|
|
|
|
+ List<String> holidayDateList = holidayDates.stream().map(HolidayDate::getDate).collect(Collectors.toList());
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
LocalDate queryDate = startDateTime.toLocalDate();
|
|
LocalDate queryDate = startDateTime.toLocalDate();
|
|
List<TeacherAttendanceRecord> insertList = new ArrayList<>();
|
|
List<TeacherAttendanceRecord> insertList = new ArrayList<>();
|
|
|
|
+ List<String> weekList =Arrays.asList("SUNDAY", "SATURDAY");
|
|
for (User user : teacherList) {
|
|
for (User user : teacherList) {
|
|
-
|
|
|
|
- if(14954825256773L == user.getId()){
|
|
|
|
- System.out.println(user.getName());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
TeacherAttendanceRecord record = new TeacherAttendanceRecord();
|
|
TeacherAttendanceRecord record = new TeacherAttendanceRecord();
|
|
record.setCreateDate(LocalDateTime.now());
|
|
record.setCreateDate(LocalDateTime.now());
|
|
|
|
+ record.setAttendanceDate(queryDate);
|
|
record.setUserId(user.getId());
|
|
record.setUserId(user.getId());
|
|
record.setTimeInterval(timePeriod);
|
|
record.setTimeInterval(timePeriod);
|
|
- record.setAttendanceDate(queryDate);
|
|
|
|
AttendanceRuleDetailsUserVo detailsUserVo = teacherTodyRuleByUserId.get(user.getId());
|
|
AttendanceRuleDetailsUserVo detailsUserVo = teacherTodyRuleByUserId.get(user.getId());
|
|
|
|
+
|
|
if(detailsUserVo == null){
|
|
if(detailsUserVo == null){
|
|
record.setAttendanceStatus("不考勤");
|
|
record.setAttendanceStatus("不考勤");
|
|
insertList.add(record);
|
|
insertList.add(record);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ if(14954799823302L == user.getId()){
|
|
|
|
+ System.out.println(user.getName());
|
|
|
|
+ }
|
|
|
|
+ AttendanceRuleDetails holidayRule = ruleCategoryService.getHolidayRuleByParam(user.getId());
|
|
|
|
+ if((weekList.contains(queryDate.getDayOfWeek().name()) || holidayDateList.contains(queryDate.format(formatter))) && (holidayRule.getIsAttendance() == null || holidayRule.getIsAttendance() == 0)){
|
|
|
|
+ record.setAttendanceStatus("不考勤");
|
|
|
|
+ insertList.add(record);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
LocalDateTime startTime, endTime, amEndTime = null;
|
|
LocalDateTime startTime, endTime, amEndTime = null;
|
|
|
|
|
|
if(timePeriod == 1){
|
|
if(timePeriod == 1){
|
|
startTime = queryDate.atTime(5, 0, 0);
|
|
startTime = queryDate.atTime(5, 0, 0);
|
|
- if(detailsUserVo != null && detailsUserVo.getAmStartTime() != null){
|
|
|
|
|
|
+ if(detailsUserVo.getAmStartTime() != null){
|
|
startTime = queryDate.atTime(detailsUserVo.getAmStartTime());
|
|
startTime = queryDate.atTime(detailsUserVo.getAmStartTime());
|
|
}
|
|
}
|
|
endTime = queryDate.atTime(12, 0, 0);
|
|
endTime = queryDate.atTime(12, 0, 0);
|
|
- if(detailsUserVo != null && detailsUserVo.getAmEndTime() != null){
|
|
|
|
|
|
+ if(detailsUserVo.getAmEndTime() != null){
|
|
endTime = queryDate.atTime(detailsUserVo.getAmEndTime());
|
|
endTime = queryDate.atTime(detailsUserVo.getAmEndTime());
|
|
}
|
|
}
|
|
}else if(timePeriod == 2){
|
|
}else if(timePeriod == 2){
|
|
startTime = queryDate.atTime(12, 0, 0);
|
|
startTime = queryDate.atTime(12, 0, 0);
|
|
- if(detailsUserVo != null && detailsUserVo.getPmStartTime() != null){
|
|
|
|
|
|
+ if(detailsUserVo.getPmStartTime() != null){
|
|
startTime = queryDate.atTime(detailsUserVo.getPmStartTime());
|
|
startTime = queryDate.atTime(detailsUserVo.getPmStartTime());
|
|
}
|
|
}
|
|
endTime = queryDate.atTime(18, 0, 0);
|
|
endTime = queryDate.atTime(18, 0, 0);
|
|
- if(detailsUserVo != null && detailsUserVo.getPmEndTime() != null){
|
|
|
|
|
|
+ if(detailsUserVo.getPmEndTime() != null){
|
|
endTime = queryDate.atTime(detailsUserVo.getPmEndTime());
|
|
endTime = queryDate.atTime(detailsUserVo.getPmEndTime());
|
|
}
|
|
}
|
|
amEndTime = queryDate.atTime(12, 0, 0);
|
|
amEndTime = queryDate.atTime(12, 0, 0);
|
|
- if(detailsUserVo != null && detailsUserVo.getAmEndTime() != null){
|
|
|
|
|
|
+ if(detailsUserVo.getAmEndTime() != null){
|
|
amEndTime = queryDate.atTime(detailsUserVo.getAmEndTime());
|
|
amEndTime = queryDate.atTime(detailsUserVo.getAmEndTime());
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
startTime = queryDate.atTime(0, 0, 0);
|
|
startTime = queryDate.atTime(0, 0, 0);
|
|
- if(detailsUserVo != null && detailsUserVo.getEveningStartTime() != null){
|
|
|
|
|
|
+ if(detailsUserVo.getEveningStartTime() != null){
|
|
startTime = queryDate.atTime(detailsUserVo.getEveningStartTime());
|
|
startTime = queryDate.atTime(detailsUserVo.getEveningStartTime());
|
|
}
|
|
}
|
|
endTime = queryDate.atTime(23, 59, 59);
|
|
endTime = queryDate.atTime(23, 59, 59);
|
|
- if(detailsUserVo != null && detailsUserVo.getEveningEndTime() != null){
|
|
|
|
|
|
+ if(detailsUserVo.getEveningEndTime() != null){
|
|
endTime = queryDate.atTime(detailsUserVo.getEveningEndTime());
|
|
endTime = queryDate.atTime(detailsUserVo.getEveningEndTime());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
record.setStartTime(startTime);
|
|
record.setStartTime(startTime);
|
|
record.setEndTime(endTime);
|
|
record.setEndTime(endTime);
|
|
|
|
|