Explorar o código

考勤统计调整

dzx hai 1 ano
pai
achega
ce5726368c

+ 42 - 36
src/main/java/com/xjrsoft/module/attendance/service/impl/AttendanceStatisticsServiceImpl.java

@@ -12,6 +12,7 @@ import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.attendance.dto.AddAttendanceStatisticsDto;
 import com.xjrsoft.module.attendance.dto.AttendanceStatisticsPageDto;
@@ -71,7 +72,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 /**
@@ -114,45 +114,15 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
             statistics.setStatus(0);
             statisticsMapper.insert(statistics);
 
-            CompletableFuture.runAsync(() -> {
-                List<LocalDate> dateList = getDatesBetween(dto.getStartDate(), dto.getEndDate());
-                LocalDateTime now = LocalDateTime.now();
-                if(dateList.contains(now.toLocalDate())){
-                    OutInRecordUtil outInRecordUtil = new OutInRecordUtil();
-                    LocalDateTime startDateTime = now.withHour(0).withMinute(0).withSecond(0).withNano(0);
-                    LocalDateTime endDateTime = startDateTime.plusDays(1).plusSeconds(-1);
-
-                    Map<Long, AttendanceRuleDetailsUserVo> teacherRules = ruleCategoryService.getAllTeacherTodyRule(now.getDayOfWeek().name());
-
-                    try {
-                        //教师
-                        outInRecordUtil.getTeacherRecords(faceImportMapper, startDateTime, endDateTime, teacherRules);
-                        //拉取车辆数据
-                        outInRecordUtil.GetVehicleRecord(faceImportMapper, startDateTime, endDateTime);
-                    } catch (ParseException e) {
-                        Log.error(e.getMessage(), e);
-                    }
-
-                    AttendanceRecordTask recordTask = new AttendanceRecordTask();
-                    recordTask.teacherAttendanceRecord(startDateTime, statistics.getTimePeriod(),
-                            userService,
-                            ruleCategoryService,
-                            holidayDateService,
-                            wfTeacherleaveService,
-                            outInRecordService,
-                            carOutInRecordService,
-                            recordService
-                    );
-                }
-                //1、同步出入记录的数据
-                //2、固化考勤数据
-                refreshRecord(statistics.getId());
-            });
-
+            //1、同步出入记录的数据
+            //2、固化考勤数据
+            refreshRecord(statistics.getId());
             return true;
         } catch (Exception e) {
             Log.error(e.getMessage(), e);
             throw new MyException("添加报错,请联系管理员");
+        }finally{
+
         }
     }
 
@@ -227,6 +197,42 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
             statistics.setModifyDate(new Date());
             this.updateById(statistics);
 
+            List<LocalDate> dateList2 = getDatesBetween(statistics.getStartDate(), statistics.getEndDate());
+            LocalDateTime now = LocalDateTime.now();
+            if(dateList2.contains(now.toLocalDate())){
+                DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                String sql = "DELETE FROM teacher_attendance_record WHERE attendance_date = '" + now.toLocalDate().format(dtf) + "'" +
+                        " AND time_interval = " + statistics.getTimePeriod();
+                SqlRunnerAdapter.db().delete(sql);
+
+                OutInRecordUtil outInRecordUtil = new OutInRecordUtil();
+                LocalDateTime startDateTime = now.withHour(0).withMinute(0).withSecond(0).withNano(0);
+                LocalDateTime endDateTime = startDateTime.plusDays(1).plusSeconds(-1);
+
+                Map<Long, AttendanceRuleDetailsUserVo> teacherRules = ruleCategoryService.getAllTeacherTodyRule(now.getDayOfWeek().name());
+
+                try {
+                    //教师
+                    outInRecordUtil.getTeacherRecords(faceImportMapper, startDateTime, endDateTime, teacherRules);
+                    //拉取车辆数据
+                    outInRecordUtil.GetVehicleRecord(faceImportMapper, startDateTime, endDateTime);
+                } catch (ParseException e) {
+                    Log.error(e.getMessage(), e);
+                }
+
+                AttendanceRecordTask recordTask = new AttendanceRecordTask();
+                recordTask.teacherAttendanceRecord(startDateTime, statistics.getTimePeriod(),
+                        userService,
+                        ruleCategoryService,
+                        holidayDateService,
+                        wfTeacherleaveService,
+                        outInRecordService,
+                        carOutInRecordService,
+                        recordService
+                );
+            }
+
+
             //2、删除以前的数据
             statisticsRecordService.remove(
                     new QueryWrapper<AttendanceStatisticsRecord>().lambda()

+ 1 - 1
src/main/resources/mapper/outin/TeacherOutInRecordMapper.xml

@@ -6,7 +6,7 @@
     <select id="getListByParam" parameterType="com.xjrsoft.module.outint.dto.TeacherOutInRecordDto" resultType="com.xjrsoft.module.outint.entity.TeacherOutInRecord">
         SELECT * FROM teacher_out_in_record
         WHERE delete_mark = 0
-        AND  #{dto.endTime} >= record_time
+        AND record_time between #{dto.startTime} and #{dto.endTime}
         AND status = #{dto.status}
         AND DATE_FORMAT(record_time, '%Y-%m-%d') = #{dto.queryDate}
         AND user_id = #{dto.userId}