|
@@ -3,6 +3,7 @@ package com.boman.web.core.service.attendance;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.boman.common.core.utils.DateUtils;
|
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
|
+import com.boman.common.core.utils.StringUtils;
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
import com.boman.common.redis.RedisKey;
|
|
|
import com.boman.domain.GenTable;
|
|
@@ -17,7 +18,9 @@ import com.boman.web.core.service.attendance.rules.AttendanceRulesService;
|
|
|
import com.boman.web.core.service.common.ICommonService;
|
|
|
import com.boman.web.core.service.select.IBaseSelectService;
|
|
|
import com.boman.web.core.utils.AuthUtils;
|
|
|
+import com.boman.web.core.utils.JSONObjectUtils;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -31,11 +34,11 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.boman.common.core.utils.DateUtils.YYYY_MM_DD_HH_MM;
|
|
|
+import static com.boman.common.core.utils.DateUtils.dateTimeNow;
|
|
|
import static com.boman.common.core.utils.number.NumberUtils.gtZero;
|
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
|
import static com.boman.domain.constant.AttendanceConst.*;
|
|
|
-import static com.boman.domain.constant.AttendanceRulesConst.ATTENDANCE_RULES_END_TIME;
|
|
|
-import static com.boman.domain.constant.AttendanceRulesConst.ATTENDANCE_RULES_START_TIME;
|
|
|
+import static com.boman.domain.constant.AttendanceRulesConst.*;
|
|
|
import static com.boman.domain.constant.FormDataConstant.CONDITION;
|
|
|
import static com.boman.domain.constant.FormDataConstant.PAGE_ROWS;
|
|
|
import static com.boman.web.core.utils.ColumnUtils.withoutHrReturnColumnNames;
|
|
@@ -195,16 +198,19 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
public String showAttendanceType(String tableName, String userName) {
|
|
|
requireNonNull(tableName, "tableName is empty");
|
|
|
requireNonNull(userName, "userName is empty");
|
|
|
-
|
|
|
- FormDataDto dto = new FormDataDto();
|
|
|
- dto.setTable(tableName);
|
|
|
- JSONObject condition = new JSONObject();
|
|
|
- condition.put("attendance_table_username", userName);
|
|
|
- // in
|
|
|
- condition.put(ATTENDANCE_TABLE_TODAYTIME, Lists.newArrayList(DateUtils.getDate()));
|
|
|
- dto.setFixedData(condition);
|
|
|
- int count = commonService.count(dto);
|
|
|
- return count > 0 ? GO_OFF_WORK : GO_TO_WORK;
|
|
|
+ JSONObject attendanceTableUsername = commonService.getOneByMap(tableName, JSONObjectUtils.putValue("attendance_table_username", userName, ATTENDANCE_TABLE_TODAYTIME, Lists.newArrayList(DateUtils.getDate())));
|
|
|
+ GregorianCalendar ca = new GregorianCalendar();
|
|
|
+ int result = ca.get(GregorianCalendar.AM_PM);
|
|
|
+ if (0 == result){
|
|
|
+ //上午上班打卡
|
|
|
+ return MapUtils.isEmpty(attendanceTableUsername)?GO_TO_WORK:GO_OFF_WORK;
|
|
|
+ }else {
|
|
|
+ if (MapUtils.isEmpty(attendanceTableUsername) || isEmpty(attendanceTableUsername.getString(ATTENDANCE_TABLE_WORK_PM))){
|
|
|
+ return GO_TO_WORK_PM;
|
|
|
+ }else {
|
|
|
+ return GO_OFF_WORK_PM;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -280,23 +286,25 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
commitData.put(ATTENDANCE_TABLE_TODAYTIME, Lists.newArrayList(DateUtils.getDate()));
|
|
|
commitData.put(ATTENDANCE_TABLE_LONGITUDE, dto.getLongitude());
|
|
|
commitData.put(ATTENDANCE_TABLE_LATITUDE, dto.getLatitude());
|
|
|
+ commitData.put(ATTENDANCE_USER_ID, SecurityUtils.getUserId());
|
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
|
// 是否请假
|
|
|
if (checkIsLeave()) {
|
|
|
//
|
|
|
}
|
|
|
-
|
|
|
+ if (checkIsLate(currentTime,type)) {
|
|
|
+ commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
|
+ commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
|
+ }
|
|
|
if (GO_TO_WORK_TYPE == type) {
|
|
|
commitData.put(ATTENDANCE_TABLE_WORK, currentTime);
|
|
|
- if (checkIsLate(currentTime)) {
|
|
|
- commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
|
- commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
|
- }
|
|
|
-
|
|
|
} else if (GO_OFF_WORK_TYPE == type) {
|
|
|
commitData.put(ATTENDANCE_TABLE_OFFWORK, currentTime);
|
|
|
+ }else if(GO_TO_WORK_TYPE_PM == type){
|
|
|
+ commitData.put(ATTENDANCE_TABLE_WORK_PM, currentTime);
|
|
|
+ }else if(GO_OFF_WORK_TYPE_PM == type){
|
|
|
+ commitData.put(ATTENDANCE_TABLE_OFFWORK_PM, currentTime);
|
|
|
}
|
|
|
-
|
|
|
saveClockOn(tableName, commitData);
|
|
|
return commitData;
|
|
|
}
|
|
@@ -455,9 +463,15 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
* @param arrivalTime 上班打卡时间
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- private boolean checkIsLate(Timestamp arrivalTime) {
|
|
|
+ private boolean checkIsLate(Timestamp arrivalTime,int type) {
|
|
|
JSONObject rule = rulesService.listByDeptId(AuthUtils.getLoginUser().getSysUser().getDeptId());
|
|
|
- String hourMi = rule.getString(ATTENDANCE_RULES_START_TIME);
|
|
|
+ String hourMi = "";
|
|
|
+ if (GO_TO_WORK_TYPE == type){
|
|
|
+ hourMi = rule.getString(ATTENDANCE_RULES_START_TIME);
|
|
|
+ }
|
|
|
+ if (GO_TO_WORK_TYPE_PM == type){
|
|
|
+ hourMi = rule.getString(ATTENDANCE_RULES_START_TIME_PM);
|
|
|
+ }
|
|
|
String year_month = DateUtils.getDate();
|
|
|
String ruleStartTime = year_month + " " + hourMi;
|
|
|
Date date = DateUtils.strToDate(ruleStartTime, YYYY_MM_DD_HH_MM);
|