|
@@ -110,29 +110,60 @@ public class UnmeasureTemperatureAlarmTask {
|
|
|
DateTime attendanceTime = new DateTime(sdf.parse(date + " " + alarmConfig.getAttendanceTime()));
|
|
|
DateTime endTime = new DateTime(sdf.parse(date + " " + alarmConfig.getEndTime()));
|
|
|
|
|
|
- if (alarmConfig.getClassifier().equals(1)) {
|
|
|
- //todo 上班考勤
|
|
|
+ String companyCode = companyInfo.getCode();
|
|
|
+
|
|
|
+ if (alarmConfig.getSubordinate()!=null && alarmConfig.getSubordinate()){
|
|
|
+ companyCode += "%";
|
|
|
+ }
|
|
|
|
|
|
- //准时上班
|
|
|
- affectCount += recordAttendance(alarmConfig,startTime.toDate(),attendanceTime.toDate(),WorkAttendance.SUCCESS);
|
|
|
+ //todo 查询该单位当前时间段考勤人员列表
|
|
|
+ List<PersonInfo> attendanceList = personDeviceLogService.queryAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
|
|
|
|
|
|
- //迟到
|
|
|
- affectCount += recordAttendance(alarmConfig,attendanceTime.toDate(),endTime.toDate(),WorkAttendance.LATE);
|
|
|
+ for (PersonInfo personInfo: attendanceList) {
|
|
|
+ WorkAttendance workAttendance = new WorkAttendance();
|
|
|
+ workAttendance.setId(UUID.randomUUID().toString());
|
|
|
+ workAttendance.setPersonId(personInfo.getId());
|
|
|
+ workAttendance.setAlarmConfigId(alarmConfig.getId());
|
|
|
+ workAttendance.setCreateTime(new Date());
|
|
|
+ workAttendance.setDelFlag(false);
|
|
|
|
|
|
- //缺卡
|
|
|
- affectCount += recordUnAttendance(alarmConfig,startTime.toDate(),attendanceTime.toDate(),endTime.toDate(),WorkAttendance.MISSING);
|
|
|
- } else {
|
|
|
- //todo 下班考勤
|
|
|
+ List<PersonDeviceLog> logList = personDeviceLogService.findByPersonAndDate(personInfo.getId(),startTime.toDate(),endTime.toDate());
|
|
|
+
|
|
|
+ if (logList.size()>0) {
|
|
|
+ PersonDeviceLog personDeviceLog = null;
|
|
|
+
|
|
|
+ if (alarmConfig.getClassifier().equals(1)) {
|
|
|
+ //上班算最早一次考勤
|
|
|
+ personDeviceLog = logList.get(0);
|
|
|
+
|
|
|
+ if(personDeviceLog.getRecordTime().compareTo(startTime.toDate())>0 && personDeviceLog.getRecordTime().compareTo(attendanceTime.toDate())<=0){
|
|
|
+ workAttendance.setResult(WorkAttendance.SUCCESS);
|
|
|
+ }
|
|
|
+ else if(personDeviceLog.getRecordTime().compareTo(attendanceTime.toDate())>0 && personDeviceLog.getRecordTime().compareTo(endTime.toDate())<=0){
|
|
|
+ workAttendance.setResult(WorkAttendance.LATE);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //下班算最迟一次考勤
|
|
|
+ personDeviceLog = logList.get(logList.size()-1);
|
|
|
+
|
|
|
+ if(personDeviceLog.getRecordTime().compareTo(startTime.toDate())>0 && personDeviceLog.getRecordTime().compareTo(attendanceTime.toDate())<=0){
|
|
|
+ workAttendance.setResult(WorkAttendance.LEAVE_EARLY);
|
|
|
+ }
|
|
|
+ else if(personDeviceLog.getRecordTime().compareTo(attendanceTime.toDate())>0 && personDeviceLog.getRecordTime().compareTo(endTime.toDate())<=0){
|
|
|
+ workAttendance.setResult(WorkAttendance.SUCCESS);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //早退
|
|
|
- affectCount += recordAttendance(alarmConfig,startTime.toDate(),attendanceTime.toDate(),WorkAttendance.LEAVE_EARLY);
|
|
|
+ workAttendance.setRecordTime(personDeviceLog.getRecordTime());
|
|
|
|
|
|
- //准时下班
|
|
|
- affectCount += recordAttendance(alarmConfig,attendanceTime.toDate(),endTime.toDate(),WorkAttendance.SUCCESS);
|
|
|
+ workAttendance.setTemperature(personDeviceLog.getTemperature());
|
|
|
+ }
|
|
|
|
|
|
- //缺卡
|
|
|
- affectCount += recordUnAttendance(alarmConfig,startTime.toDate(),attendanceTime.toDate(),endTime.toDate(),WorkAttendance.MISSING);
|
|
|
+ affectCount += workAttendanceService.insert(workAttendance);
|
|
|
}
|
|
|
+
|
|
|
+ //统计缺卡
|
|
|
+ recordUnAttendance(alarmConfig,startTime.toDate(),attendanceTime.toDate(),endTime.toDate(),WorkAttendance.MISSING);
|
|
|
}
|
|
|
}
|
|
|
|