|
@@ -304,39 +304,71 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
String tableName = requireNonNull(dto.getTableName(), "clockOn tableName is empty");
|
|
String tableName = requireNonNull(dto.getTableName(), "clockOn tableName is empty");
|
|
|
|
|
|
JSONObject commitData = new JSONObject();
|
|
JSONObject commitData = new JSONObject();
|
|
|
|
+ Long deptId = AuthUtils.getLoginUser().getSysUser().getDeptId();
|
|
commitData.put(ATTENDANCE_USER_NAME, SecurityUtils.getUsername());
|
|
commitData.put(ATTENDANCE_USER_NAME, SecurityUtils.getUsername());
|
|
commitData.put(ATTENDANCE_TABLE_TODAYTIME, DateUtils.getDate());
|
|
commitData.put(ATTENDANCE_TABLE_TODAYTIME, DateUtils.getDate());
|
|
commitData.put(ATTENDANCE_TABLE_LONGITUDE, dto.getLongitude());
|
|
commitData.put(ATTENDANCE_TABLE_LONGITUDE, dto.getLongitude());
|
|
commitData.put(ATTENDANCE_TABLE_LATITUDE, dto.getLatitude());
|
|
commitData.put(ATTENDANCE_TABLE_LATITUDE, dto.getLatitude());
|
|
commitData.put(ATTENDANCE_USER_ID, SecurityUtils.getUserId());
|
|
commitData.put(ATTENDANCE_USER_ID, SecurityUtils.getUserId());
|
|
- commitData.put(ATTENDANCE_DEPT_ID, AuthUtils.getLoginUser().getSysUser().getDeptId());
|
|
|
|
|
|
+ commitData.put(ATTENDANCE_DEPT_ID, deptId);
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
// 是否请假
|
|
// 是否请假
|
|
if (checkIsLeave()) {
|
|
if (checkIsLeave()) {
|
|
//
|
|
//
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //获取考勤规定时间
|
|
|
|
+ JSONObject rules = rulesService.listByDeptId(deptId);
|
|
|
|
+ //规定上午上班时间
|
|
|
|
+ String attendanceRulesStartTime = rules.get("attendance_rules_start_time").toString();
|
|
|
|
+ //规定下午上班时间
|
|
|
|
+ String attendanceRulesEndTime = rules.get("attendance_rules_end_time").toString();
|
|
|
|
+ //规定的下午上班时间
|
|
|
|
+ String attendanceRulesStartTimePm = rules.get("attendance_rules_start_time_pm").toString();
|
|
|
|
+ //规定的下午下班时间
|
|
|
|
+ String attendanceRulesEndTimePm = rules.get("attendance_rules_end_time_pm").toString();
|
|
UpdateDto updateDto = new UpdateDto();
|
|
UpdateDto updateDto = new UpdateDto();
|
|
//如果是更新
|
|
//如果是更新
|
|
JSONObject commitDataUpdate = new JSONObject();
|
|
JSONObject commitDataUpdate = new JSONObject();
|
|
if (GO_TO_WORK_TYPE == type) {
|
|
if (GO_TO_WORK_TYPE == type) {
|
|
if (checkIsLate(currentTime, type)) {
|
|
if (checkIsLate(currentTime, type)) {
|
|
|
|
+ //判断迟到多久
|
|
|
|
+ Date date = DateUtils.strToDate(attendanceRulesStartTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String datePoor = DateUtils.getDatePoor(currentTime, date);
|
|
|
|
+ commitData.put(LATE_TIME, datePoor);
|
|
commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
}
|
|
}
|
|
commitData.put(ATTENDANCE_TABLE_WORK, currentTime);
|
|
commitData.put(ATTENDANCE_TABLE_WORK, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_WORK, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_WORK, currentTime);
|
|
} else if (GO_OFF_WORK_TYPE == type) {
|
|
} else if (GO_OFF_WORK_TYPE == type) {
|
|
|
|
+ if (checkIsLeaveEarly(currentTime, type)){
|
|
|
|
+ Date date = DateUtils.strToDate(attendanceRulesEndTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String datePoor = DateUtils.getDatePoor(currentTime, date);
|
|
|
|
+ commitData.put(LEAVE_EARLY_TIME, datePoor);
|
|
|
|
+ commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
|
|
+ commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
|
|
+ }
|
|
commitData.put(ATTENDANCE_TABLE_OFFWORK, currentTime);
|
|
commitData.put(ATTENDANCE_TABLE_OFFWORK, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_OFFWORK, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_OFFWORK, currentTime);
|
|
} else if (GO_TO_WORK_TYPE_PM == type) {
|
|
} else if (GO_TO_WORK_TYPE_PM == type) {
|
|
if (checkIsLate(currentTime, type)) {
|
|
if (checkIsLate(currentTime, type)) {
|
|
|
|
+ Date date = DateUtils.strToDate(attendanceRulesStartTimePm, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String datePoor = DateUtils.getDatePoor(currentTime, date);
|
|
|
|
+ commitData.put(LATE_TIME_PM, datePoor);
|
|
commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
}
|
|
}
|
|
commitData.put(ATTENDANCE_TABLE_WORK_PM, currentTime);
|
|
commitData.put(ATTENDANCE_TABLE_WORK_PM, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_WORK_PM, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_WORK_PM, currentTime);
|
|
} else if (GO_OFF_WORK_TYPE_PM == type) {
|
|
} else if (GO_OFF_WORK_TYPE_PM == type) {
|
|
|
|
+ if (checkIsLeaveEarly(currentTime, type)){
|
|
|
|
+ Date date = DateUtils.strToDate(attendanceRulesEndTimePm, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String datePoor = DateUtils.getDatePoor(currentTime, date);
|
|
|
|
+ commitData.put(LEAVE_EARLY_TIME_PM, datePoor);
|
|
|
|
+ commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
|
|
+ commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
|
|
+ }
|
|
commitData.put(ATTENDANCE_TABLE_OFFWORK_PM, currentTime);
|
|
commitData.put(ATTENDANCE_TABLE_OFFWORK_PM, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_OFFWORK_PM, currentTime);
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_OFFWORK_PM, currentTime);
|
|
}
|
|
}
|
|
@@ -389,7 +421,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
//根据日期 年-月和用户id查询用户当月打卡记录
|
|
//根据日期 年-月和用户id查询用户当月打卡记录
|
|
List<JSONObject> jsonObjects = standardlyMapper.findDate(date, userId);
|
|
List<JSONObject> jsonObjects = standardlyMapper.findDate(date, userId);
|
|
//获取某月的所有日期
|
|
//获取某月的所有日期
|
|
- List<String> monthEveryDays = getMonthEveryDays(date);
|
|
|
|
|
|
+ List<String> monthEveryDays = DateUtils.getMonthEveryDays(date);
|
|
String workDaKa = " 上午上班打卡";
|
|
String workDaKa = " 上午上班打卡";
|
|
String workDaKaPm = " 下午上班打卡";
|
|
String workDaKaPm = " 下午上班打卡";
|
|
String offDaKa = " 上午下班打卡";
|
|
String offDaKa = " 上午下班打卡";
|
|
@@ -447,51 +479,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取某年某月每一天日期
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public static List<String> getMonthEveryDays(String date) {
|
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
|
- List<String> arr = new ArrayList<>();
|
|
|
|
- try {
|
|
|
|
- Date parse = simpleDateFormat.parse(date);
|
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
|
- c.setTime(parse);
|
|
|
|
- int year = c.get(Calendar.YEAR);
|
|
|
|
- int monthInt = c.get(Calendar.MONTH) + 1;
|
|
|
|
- int num = getDaysByYearMonth(year, monthInt);
|
|
|
|
- for (int i = 1; i <= num; i++) {
|
|
|
|
- String day = String.valueOf(i);
|
|
|
|
- if (i < 10) {
|
|
|
|
- day = "0" + i;
|
|
|
|
- }
|
|
|
|
- String month = String.valueOf(monthInt);
|
|
|
|
- if (monthInt < 10) {
|
|
|
|
- month = "0" + monthInt;
|
|
|
|
- }
|
|
|
|
- arr.add(year + "-" + month + "-" + day);
|
|
|
|
- }
|
|
|
|
- return arr;
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 根据年 月 获取对应的月份 天数
|
|
|
|
- */
|
|
|
|
- public static int getDaysByYearMonth(int year, int month) {
|
|
|
|
- Calendar a = Calendar.getInstance();
|
|
|
|
- a.set(Calendar.YEAR, year);
|
|
|
|
- a.set(Calendar.MONTH, month - 1);
|
|
|
|
- a.set(Calendar.DATE, 1);
|
|
|
|
- a.roll(Calendar.DATE, -1);
|
|
|
|
- int maxDate = a.get(Calendar.DATE);
|
|
|
|
- return maxDate;
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 功能描述: 保存打卡信息
|
|
* 功能描述: 保存打卡信息
|
|
@@ -536,10 +524,18 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
* @param leaveTime 下班打卡时间
|
|
* @param leaveTime 下班打卡时间
|
|
* @return boolean
|
|
* @return boolean
|
|
*/
|
|
*/
|
|
- private boolean checkIsLeaveEarly(Timestamp leaveTime) {
|
|
|
|
|
|
+ private boolean checkIsLeaveEarly(Timestamp leaveTime,int type) {
|
|
JSONObject rule = rulesService.listByDeptId(AuthUtils.getLoginUser().getSysUser().getDeptId());
|
|
JSONObject rule = rulesService.listByDeptId(AuthUtils.getLoginUser().getSysUser().getDeptId());
|
|
- Timestamp ruleEndTime = rule.getTimestamp(ATTENDANCE_RULES_END_TIME);
|
|
|
|
- return leaveTime.before(ruleEndTime);
|
|
|
|
|
|
+ //判断上午下班时间
|
|
|
|
+ if (GO_OFF_WORK_TYPE == type) {
|
|
|
|
+ Timestamp ruleEndTime = rule.getTimestamp(ATTENDANCE_RULES_END_TIME);
|
|
|
|
+ return leaveTime.before(ruleEndTime);
|
|
|
|
+ }else if (GO_OFF_WORK_TYPE_PM == type) {
|
|
|
|
+ //判断下午下班时间
|
|
|
|
+ Timestamp ruleEndTimePm = rule.getTimestamp(ATTENDANCE_RULES_END_TIME_PM);
|
|
|
|
+ return leaveTime.before(ruleEndTimePm);
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|