Commit 5e3d4f07 authored by 赵啸非's avatar 赵啸非

修改假期重复提交的问题

parent e376254a
package com.mortals.xhx.module.attendance.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.service.IUser;
......@@ -82,6 +83,10 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
List<AttendanceRecordHikEntity> collect = hikEntityList.stream().sorted(Comparator.comparing(AttendanceRecordHikEntity::getAttendanceDate)).collect(Collectors.toList());
//另一种实现
Map<Long, List<AttendanceRecordHikEntity>> listMap = collect.stream().collect(Collectors.groupingBy(AttendanceRecordHikEntity::getStaffId));
List<AttendanceRecordEntity> saveList = new ArrayList<>();
List<AttendanceRecordEntity> updateList = new ArrayList<>();
for (Map.Entry<Long, List<AttendanceRecordHikEntity>> itemEntry : listMap.entrySet()) {
//按人员
Long staffId = itemEntry.getKey();
......@@ -198,9 +203,13 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
attendanceRecordEntity.setId(recordEntity.getId());
attendanceRecordEntity.setUpdateTime(new Date());
attendanceRecordEntity.setUpdateUserId(this.getContextUserId(context));
attendanceRecordService.update(attendanceRecordEntity, context);
updateList.add(attendanceRecordEntity);
// attendanceRecordService.update(attendanceRecordEntity, context);
} else {
attendanceRecordService.save(attendanceRecordEntity, context);
saveList.add(attendanceRecordEntity);
// attendanceRecordService.save(attendanceRecordEntity, context);
}
}
......@@ -208,6 +217,16 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
}
if (!ObjectUtils.isEmpty(saveList)) {
attendanceRecordService.save(saveList, context);
}
if (!ObjectUtils.isEmpty(updateList)) {
List<List<AttendanceRecordEntity>> partition = ListUtil.partition(updateList, 30);
for (List<AttendanceRecordEntity> attendanceRecordEntities : partition) {
attendanceRecordService.update(attendanceRecordEntities, context);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment