|
@@ -19,6 +19,7 @@ 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 javafx.scene.control.Tab;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -29,6 +30,8 @@ import javax.annotation.Resource;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -181,17 +184,19 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
String attendanceTableOffWorkPm = jsonObject.get("attendance_table_offwork_pm").toString();
|
|
|
map.put("attendanceTableWork", "未打卡");
|
|
|
map.put("attendanceTableOffWork", "未打卡");
|
|
|
+ map.put("attendanceTableWorkPm", "未打卡");
|
|
|
+ map.put("attendanceTableOffWorkPm", "未打卡");
|
|
|
if (isNotEmpty(attendanceTableWork)) {
|
|
|
- map.put("attendanceTableWork", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableWork)) + " 已打卡");
|
|
|
+ map.put("attendanceTableWork", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableWork.substring(0,attendanceTableWork.length()-2))) + " 已打卡");
|
|
|
}
|
|
|
if (isNotEmpty(attendanceTableOffWork)) {
|
|
|
- map.put("attendanceTableOffWork", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableOffWork)) + " 已打卡");
|
|
|
+ map.put("attendanceTableOffWork", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableOffWork.substring(0,attendanceTableOffWork.length()-2))) + " 已打卡");
|
|
|
}
|
|
|
if (isNotEmpty(attendanceTableWorkPm)) {
|
|
|
- map.put("attendanceTableWorkPm", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableWorkPm)) + " 已打卡");
|
|
|
+ map.put("attendanceTableWorkPm", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableWorkPm.substring(0,attendanceTableWorkPm.length()-2))) + " 已打卡");
|
|
|
}
|
|
|
if (isNotEmpty(attendanceTableOffWorkPm)) {
|
|
|
- map.put("attendanceTableOffWorkPm", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableOffWorkPm)) + " 已打卡");
|
|
|
+ map.put("attendanceTableOffWorkPm", DateUtils.dateToMMdd(DateUtils.parseDate(attendanceTableOffWorkPm.substring(0,attendanceTableOffWorkPm.length()-2))) + " 已打卡");
|
|
|
}
|
|
|
|
|
|
map.put("dateTime", jsonObject.get("attendance_table_week") + " " + jsonObject.get("attendance_table_todaytime"));
|
|
@@ -218,7 +223,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
int result = ca.get(GregorianCalendar.AM_PM);
|
|
|
if (0 == result) {
|
|
|
//上午上班打卡
|
|
|
- return MapUtils.isEmpty(attendanceTableUsername) ? GO_TO_WORK : GO_OFF_WORK;
|
|
|
+ return (MapUtils.isEmpty(attendanceTableUsername) || isEmpty(attendanceTableUsername.getString(ATTENDANCE_TABLE_WORK)))? GO_TO_WORK : GO_OFF_WORK;
|
|
|
} else {
|
|
|
if (MapUtils.isEmpty(attendanceTableUsername) || isEmpty(attendanceTableUsername.getString(ATTENDANCE_TABLE_WORK_PM))) {
|
|
|
return GO_TO_WORK_PM;
|
|
@@ -478,45 +483,80 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
return AjaxResult.success(jsonObjectList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 请假通过后,修改考勤表对应时间的是否请假
|
|
|
+ * @param dto
|
|
|
+ * {
|
|
|
+ * "table": "attendance_table",
|
|
|
+ * "fixedData": {
|
|
|
+ * "condition": {
|
|
|
+ * "user_id": 133,
|
|
|
+ * "user_name": 姓名,
|
|
|
+ * "dept_id": 133,
|
|
|
+ * "leavefrom_start_time": "2021-08-03 13:14:23",
|
|
|
+ * "leavefrom_end_time": "2021-08-06 13:14:23"
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public AjaxResult updateAttendance(FormDataDto dto) {
|
|
|
JSONObject condition = ifNullSetEmpty(dto.getFixedData().getJSONObject(CONDITION));
|
|
|
- String tableName = "attendance_table";
|
|
|
- GenTable genTable = cmdService.getTableFromRedisByTableName(RedisKey.TABLE_INFO, tableName);
|
|
|
- List<GenTableColumn> columns = genTable.getColumns();
|
|
|
- JSONObject packCondition = ifNullSetEmpty(selectService.packColCondition(columns, condition));
|
|
|
- JSONObject result = new JSONObject();
|
|
|
- List<JSONObject> rows = attendanceMapper.selectByCondition(tableName);
|
|
|
-
|
|
|
- List<Map<String, Object>> detailedRecordList = new ArrayList<>();
|
|
|
- if (isEmpty(rows)) {
|
|
|
- result.put(FormDataConstant.PAGE_ROWS, rows);
|
|
|
- return AjaxResult.success(result);
|
|
|
+ //表名
|
|
|
+ String tableName = dto.getTableName();
|
|
|
+ //请假开始时间
|
|
|
+ String leaveFromStartTime = condition.get("leavefrom_start_time").toString();
|
|
|
+ //请假结束时间
|
|
|
+ String leaveFromEndTime = condition.get("leavefrom_end_time").toString();
|
|
|
+ DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate startDate = LocalDate.parse(leaveFromStartTime, ftf);
|
|
|
+ LocalDate endDate = LocalDate.parse(leaveFromEndTime, ftf);
|
|
|
+ List<LocalDate> datesBetween = DateUtils.getDatesBetween(startDate, endDate);
|
|
|
+ List<String> dateTime = new ArrayList<>();
|
|
|
+ for (LocalDate localDate : datesBetween) {
|
|
|
+ dateTime.add(localDate.toString());
|
|
|
}
|
|
|
-
|
|
|
- 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");
|
|
|
- map.put("attendanceTableWork", "未打卡");
|
|
|
- map.put("attendanceTableOffWork", "未打卡");
|
|
|
- if (isNotEmpty(attendanceTableWork)) {
|
|
|
- map.put("attendanceTableWork", attendanceTableWork + "已打卡");
|
|
|
+ JSONObject conditionSelect = new JSONObject();
|
|
|
+ //需要ATTENDANCE_TABLE_TODAYTIME字段是查询可见
|
|
|
+ condition.put(ATTENDANCE_TABLE_TODAYTIME,dateTime);
|
|
|
+ condition.put(IS_DEL,"N");
|
|
|
+ //查询考勤表中是否有对应日期的数据
|
|
|
+ List<JSONObject> byMap = commonService.getByMap(tableName, conditionSelect);
|
|
|
+ List<String> dateTimeUser = new ArrayList<>();
|
|
|
+ if(isNotEmpty(byMap)){
|
|
|
+ //如果不为空说明当前日期有考勤记录,直接修改状态后更新
|
|
|
+ for (JSONObject jsonObject : byMap) {
|
|
|
+ Long id = Long.parseLong(jsonObject.get("id").toString());
|
|
|
+ UpdateDto uto = new UpdateDto();
|
|
|
+ uto.setTableName(tableName);
|
|
|
+ uto.setCondition(JSONObjectUtils.putValue("id",id,ATTENDANCE_TABLE_LEAVE_OR,"Y"));
|
|
|
+ commonService.update(uto);
|
|
|
+ dateTimeUser.add(jsonObject.get(ATTENDANCE_TABLE_TODAYTIME).toString());
|
|
|
}
|
|
|
- if (isNotEmpty(attendanceTableOffWork)) {
|
|
|
- map.put("attendanceTableWork", attendanceTableOffWork + "已打卡");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("dateTime", jsonObject.get("attendance_table_week") + " " + jsonObject.get("attendance_table_todaytime"));
|
|
|
- detailedRecordList.add(map);
|
|
|
+ }
|
|
|
+ if (isNotEmpty(dateTimeUser)){
|
|
|
+ dateTime.removeAll(dateTimeUser);
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
+ for (String date : dateTime) {
|
|
|
+ JSONObject commitData = new JSONObject();
|
|
|
+ commitData.put(ATTENDANCE_USER_NAME,condition.get("user_name"));
|
|
|
+ commitData.put(ATTENDANCE_USER_ID, condition.get("user_id"));
|
|
|
+ commitData.put(ATTENDANCE_DEPT_ID,condition.get("dept_id"));
|
|
|
+ commitData.put(ATTENDANCE_TABLE_TODAYTIME,date);
|
|
|
+ commitData.put(ATTENDANCE_TABLE_CREATE_TIME,DateUtils.getNowDate());
|
|
|
+ commitData.put(ATTENDANCE_TABLE_CREATE_BY,"admin");
|
|
|
+ commitData.put(ATTENDANCE_TABLE_LEAVE_OR,"Y");
|
|
|
+ FormDataDto fto = new FormDataDto();
|
|
|
+ fto.setObjId(-1L);
|
|
|
+ fto.setTable(tableName);
|
|
|
+ fto.setFixedData(commitData);
|
|
|
+ cmdService.objectSave(fto);
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 功能描述: 保存打卡信息
|
|
|
*
|