|
@@ -42,6 +42,7 @@ import static com.boman.domain.constant.AttendanceConst.*;
|
|
|
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.domain.constant.LeaveConst.TABLE_NAME;
|
|
|
import static com.boman.web.core.utils.ColumnUtils.withoutHrReturnColumnNames;
|
|
|
import static com.boman.web.core.utils.HandlerFormDataUtils.handleNullColumnValue;
|
|
|
|
|
@@ -69,16 +70,15 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
* 功能描述: 根据tableName和userId查找当月考勤
|
|
|
*
|
|
|
* @param tableName tableName
|
|
|
- * @param userName userName
|
|
|
+ * @param userId userId
|
|
|
* @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
|
*/
|
|
|
- private List<JSONObject> listByUserName(String tableName, String userName) {
|
|
|
+ private List<JSONObject> listByUserId(String tableName, Long userId) {
|
|
|
requireNonNull(tableName, "tableName is empty");
|
|
|
- requireNonNull(userName, "userName is empty");
|
|
|
-
|
|
|
+ requireNonNull(userId, "userId is empty");
|
|
|
List<String> days = DateUtils.getMonthDays();
|
|
|
JSONObject map = new JSONObject(2);
|
|
|
- map.put(ATTENDANCE_USER_NAME, userName);
|
|
|
+ map.put(ATTENDANCE_USER_ID, userId);
|
|
|
map.put(ATTENDANCE_TABLE_TODAYTIME, days);
|
|
|
return commonService.getByMap(tableName, map);
|
|
|
}
|
|
@@ -88,24 +88,27 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
* 功能描述: 根据tableName和userId查找当月考勤
|
|
|
*
|
|
|
* @param tableName tableName
|
|
|
- * @param userName userName
|
|
|
+ * @param userId userId
|
|
|
* @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
|
*/
|
|
|
@Override
|
|
|
- public AjaxResult attendanceRecord(String tableName, String userName) {
|
|
|
+ public AjaxResult attendanceRecord(String tableName, Long userId) {
|
|
|
Map<String, Object> mapObj = new HashMap<>(4);
|
|
|
- List<JSONObject> byMap = listByUserName(tableName, userName);
|
|
|
+ List<JSONObject> byMap = listByUserId(tableName, userId);
|
|
|
+ //异常的时间
|
|
|
+ List<String> dateListErr = new ArrayList<>(byMap.size());
|
|
|
+ List<String> dateList = new ArrayList<>(byMap.size());
|
|
|
if (isEmpty(byMap)) {
|
|
|
- mapObj.put("leave", 0);
|
|
|
- mapObj.put("late", 0);
|
|
|
- mapObj.put("leaveOr", 0);
|
|
|
- mapObj.put("dateList", new ArrayList<>(0));
|
|
|
+ mapObj.put("leave", 1);
|
|
|
+ mapObj.put("late", 2);
|
|
|
+ mapObj.put("leaveOr", 3);
|
|
|
+ mapObj.put("abnormal", 10);
|
|
|
+ mapObj.put("dateList", dateList);
|
|
|
+ mapObj.put("dateListErr", dateListErr);
|
|
|
return AjaxResult.success(mapObj);
|
|
|
}
|
|
|
-
|
|
|
- List<String> dateList = new ArrayList<>(byMap.size());
|
|
|
- // 早退 迟到 请假
|
|
|
- int leave = 0, late = 0, leaveOr = 0;
|
|
|
+ // 早退 迟到 请假 异常
|
|
|
+ int leave = 0, late = 0, leaveOr = 0, abnormal = 0;
|
|
|
for (JSONObject jsonObject : byMap) {
|
|
|
if (ObjectUtils.isNotEmpty(jsonObject.get("attendance_table_leave")) && "Y".equals(String.valueOf(jsonObject.get("attendance_table_leave")))) {
|
|
|
leave++;
|
|
@@ -118,19 +121,22 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
if (ObjectUtils.isNotEmpty(jsonObject.get("attendance_table_leave_or")) && "Y".equals(String.valueOf(jsonObject.get("attendance_table_leave_or")))) {
|
|
|
leaveOr++;
|
|
|
}
|
|
|
-
|
|
|
- if (ObjectUtils.isNotEmpty(jsonObject.get("attendance_table_todaytime"))) {
|
|
|
- // 只需要异常的
|
|
|
- if (gtZero(leave) || gtZero(late) || gtZero(leaveOr)) {
|
|
|
- dateList.add(jsonObject.getString("attendance_table_todaytime"));
|
|
|
+ //异常
|
|
|
+ if (ObjectUtils.isNotEmpty(jsonObject.get("attendance_table_judge")) && "Y".equals(String.valueOf(jsonObject.get("attendance_table_judge")))) {
|
|
|
+ abnormal++;
|
|
|
+ if (ObjectUtils.isNotEmpty(jsonObject.get("attendance_table_todaytime"))) {
|
|
|
+ dateListErr.add(jsonObject.getString("attendance_table_todaytime"));
|
|
|
}
|
|
|
+ }else {
|
|
|
+ dateList.add(jsonObject.getString("attendance_table_todaytime"));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
mapObj.put("leave", leave);
|
|
|
mapObj.put("late", late);
|
|
|
mapObj.put("leaveOr", leaveOr);
|
|
|
+ mapObj.put("abnormal", abnormal);
|
|
|
mapObj.put("dateList", dateList);
|
|
|
+ mapObj.put("dateListErr", dateListErr);
|
|
|
return AjaxResult.success(mapObj);
|
|
|
}
|
|
|
|
|
@@ -169,23 +175,23 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
|
|
|
for (JSONObject jsonObject : rows) {
|
|
|
Map<String, Object> map = new HashMap<>(5);
|
|
|
- Object attendanceTableWork = jsonObject.get("attendance_table_work");
|
|
|
- Object attendanceTableOffWork = jsonObject.get("attendance_table_offwork");
|
|
|
- Object attendanceTableWorkPm = jsonObject.get("attendance_table_work_pm");
|
|
|
- Object attendanceTableOffWorkPm = jsonObject.get("attendance_table_offwork_pm");
|
|
|
+ String attendanceTableWork = jsonObject.get("attendance_table_work").toString();
|
|
|
+ String attendanceTableOffWork = jsonObject.get("attendance_table_offwork").toString();
|
|
|
+ String attendanceTableWorkPm = jsonObject.get("attendance_table_work_pm").toString();
|
|
|
+ String attendanceTableOffWorkPm = jsonObject.get("attendance_table_offwork_pm").toString();
|
|
|
map.put("attendanceTableWork", "未打卡");
|
|
|
map.put("attendanceTableOffWork", "未打卡");
|
|
|
if (isNotEmpty(attendanceTableWork)) {
|
|
|
- map.put("attendanceTableWork", attendanceTableWork + " 已打卡");
|
|
|
+ map.put("attendanceTableWork", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableWork)) + " 已打卡");
|
|
|
}
|
|
|
if (isNotEmpty(attendanceTableOffWork)) {
|
|
|
- map.put("attendanceTableWork", attendanceTableOffWork + " 已打卡");
|
|
|
+ map.put("attendanceTableOffWork", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableOffWork)) + " 已打卡");
|
|
|
}
|
|
|
if (isNotEmpty(attendanceTableWorkPm)) {
|
|
|
- map.put("attendanceTableWorkPm", attendanceTableWorkPm + " 已打卡");
|
|
|
+ map.put("attendanceTableWorkPm", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableWorkPm)) + " 已打卡");
|
|
|
}
|
|
|
if (isNotEmpty(attendanceTableOffWorkPm)) {
|
|
|
- map.put("attendanceTableOffWorkPm", attendanceTableOffWorkPm + " 已打卡");
|
|
|
+ map.put("attendanceTableOffWorkPm", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableOffWorkPm)) + " 已打卡");
|
|
|
}
|
|
|
|
|
|
map.put("dateTime", jsonObject.get("attendance_table_week") + " " + jsonObject.get("attendance_table_todaytime"));
|
|
@@ -210,13 +216,13 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
JSONObject attendanceTableUsername = commonService.getOneByMap(tableName, JSONObjectUtils.putValue("attendance_table_username", userName, ATTENDANCE_TABLE_TODAYTIME, DateUtils.getDate()));
|
|
|
GregorianCalendar ca = new GregorianCalendar();
|
|
|
int result = ca.get(GregorianCalendar.AM_PM);
|
|
|
- if (0 == result){
|
|
|
+ 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 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 {
|
|
|
+ } else {
|
|
|
return GO_OFF_WORK_PM;
|
|
|
}
|
|
|
}
|
|
@@ -314,7 +320,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
//如果是更新
|
|
|
JSONObject commitDataUpdate = new JSONObject();
|
|
|
if (GO_TO_WORK_TYPE == type) {
|
|
|
- if (checkIsLate(currentTime,type)) {
|
|
|
+ if (checkIsLate(currentTime, type)) {
|
|
|
commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
|
commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
|
}
|
|
@@ -323,22 +329,22 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
} else if (GO_OFF_WORK_TYPE == type) {
|
|
|
commitData.put(ATTENDANCE_TABLE_OFFWORK, currentTime);
|
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_OFFWORK, currentTime);
|
|
|
- }else if(GO_TO_WORK_TYPE_PM == type){
|
|
|
- if (checkIsLate(currentTime,type)) {
|
|
|
+ } else if (GO_TO_WORK_TYPE_PM == type) {
|
|
|
+ if (checkIsLate(currentTime, type)) {
|
|
|
commitData.put(ATTENDANCE_ABNORMAL, Y);
|
|
|
commitData.put(ATTENDANCE_TABLE_LATE, Y);
|
|
|
}
|
|
|
commitData.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) {
|
|
|
commitData.put(ATTENDANCE_TABLE_OFFWORK_PM, currentTime);
|
|
|
commitDataUpdate.put(ATTENDANCE_TABLE_OFFWORK_PM, currentTime);
|
|
|
}
|
|
|
JSONObject jsonObject = JSONObjectUtils.putValue(ATTENDANCE_USER_NAME, SecurityUtils.getUsername(), ATTENDANCE_TABLE_TODAYTIME, DateUtils.getDate());
|
|
|
JSONObject oneByMap = commonService.getOneByMap(tableName, jsonObject);
|
|
|
- if (MapUtils.isEmpty(oneByMap)){
|
|
|
+ if (MapUtils.isEmpty(oneByMap)) {
|
|
|
saveClockOn(tableName, commitData);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
Long id = oneByMap.getLong("id");
|
|
|
updateDto.setCommitData(commitDataUpdate);
|
|
|
JSONObject condition = JSONObjectUtils.putValue("id", id);
|
|
@@ -362,7 +368,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
int page = ((Integer) map.get("page"));
|
|
|
int pageSize = ((Integer) map.get("pageSize"));
|
|
|
int pageNo = (page - 1) * pageSize;
|
|
|
- if("null".equals(name)){
|
|
|
+ if ("null".equals(name)) {
|
|
|
name = "";
|
|
|
}
|
|
|
List<JSONObject> jsonObjects = standardlyMapper.statisticsByMonth(date, name, pageNo, pageSize);
|
|
@@ -384,8 +390,10 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
List<JSONObject> jsonObjects = standardlyMapper.findDate(date, userId);
|
|
|
//获取某月的所有日期
|
|
|
List<String> monthEveryDays = getMonthEveryDays(date);
|
|
|
- String workDaKa = " 上班打卡";
|
|
|
- String offDaKa = " 下班打卡";
|
|
|
+ String workDaKa = " 上午上班打卡";
|
|
|
+ String workDaKaPm = " 下午上班打卡";
|
|
|
+ String offDaKa = " 上午下班打卡";
|
|
|
+ String offDaKaPm = " 下午下班打卡";
|
|
|
String onDaKa = " 未打卡";
|
|
|
//给返回值中添加所有日期数据
|
|
|
if (monthEveryDays != null && monthEveryDays.size() > 0) {
|
|
@@ -420,14 +428,14 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
if (ObjectUtils.isNotEmpty(attendanceTableWorkPm)) {
|
|
|
String[] s = String.valueOf(attendanceTableWorkPm).split(" ");
|
|
|
if (s[0].equals(dateDay)) {
|
|
|
- jsonObjectDay.put("attendanceTableWorkPm", s[1] + workDaKa);
|
|
|
+ jsonObjectDay.put("attendanceTableWorkPm", s[1] + workDaKaPm);
|
|
|
}
|
|
|
}
|
|
|
Object attendanceTableOffWorkPm = jsonObject.get("attendanceTableOffWorkPm");
|
|
|
if (ObjectUtils.isNotEmpty(attendanceTableOffWorkPm)) {
|
|
|
String[] s = String.valueOf(attendanceTableOffWorkPm).split(" ");
|
|
|
if (s[0].equals(dateDay)) {
|
|
|
- jsonObjectDay.put("attendanceTableOffWorkPm", s[1] + offDaKa);
|
|
|
+ jsonObjectDay.put("attendanceTableOffWorkPm", s[1] + offDaKaPm);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -507,17 +515,17 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
* @param arrivalTime 上班打卡时间
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- private boolean checkIsLate(Timestamp arrivalTime,int type) {
|
|
|
+ private boolean checkIsLate(Timestamp arrivalTime, int type) {
|
|
|
JSONObject rule = rulesService.listByDeptId(AuthUtils.getLoginUser().getSysUser().getDeptId());
|
|
|
String hourMi = "";
|
|
|
- if (GO_TO_WORK_TYPE == type){
|
|
|
+ if (GO_TO_WORK_TYPE == type) {
|
|
|
hourMi = rule.getString(ATTENDANCE_RULES_START_TIME);
|
|
|
}
|
|
|
- if (GO_TO_WORK_TYPE_PM == type){
|
|
|
+ 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;
|
|
|
+ String yearMonth = DateUtils.getDate();
|
|
|
+ String ruleStartTime = yearMonth + " " + hourMi;
|
|
|
Date date = DateUtils.strToDate(ruleStartTime, YYYY_MM_DD_HH_MM);
|
|
|
return arrivalTime.after(date);
|
|
|
}
|