|
@@ -145,11 +145,11 @@ public class AttendanceInfoServiceImpl implements AttendanceInfoService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
|
|
- public AttendanceInfoImportRespVO importAttendanceInfoList(List<AttendanceInfoImportExcelVO> importAttendanceInfos) {
|
|
|
+ public String importAttendanceInfoList(List<AttendanceInfoImportExcelVO> importAttendanceInfos) {
|
|
|
if (CollUtil.isEmpty(importAttendanceInfos)) {
|
|
|
throw exception(ATTENDANCE_INFO_IMPORT_LIST_IS_EMPTY);
|
|
|
}
|
|
|
-
|
|
|
+ StringBuilder returnMsg = new StringBuilder();
|
|
|
// 获取用户信息和租户ID
|
|
|
LoginUser user = SecurityFrameworkUtils.getLoginUser();
|
|
|
Long tenantId = user != null && user.getTenantId() != null ? user.getTenantId() : 0L;
|
|
@@ -191,25 +191,27 @@ public class AttendanceInfoServiceImpl implements AttendanceInfoService {
|
|
|
// 准备要插入的数据
|
|
|
AttendanceInfoDO attendanceInfoDO = BeanUtils.toBean(importAttendance, AttendanceInfoDO.class);
|
|
|
toInsert.add(attendanceInfoDO);
|
|
|
-
|
|
|
+ returnMsg.append("<br/>员工 " + attendanceInfoDO.getEmployeeName() + " 导入成功");
|
|
|
} catch (ServiceException ex) {
|
|
|
failedEmployeeNames.add(importAttendance.getEmployeeName());
|
|
|
respVO.getFailureEmployeeNames().put(importAttendance.getEmployeeName(), ex.getMessage());
|
|
|
+ returnMsg.append("<br/>员工 " + importAttendance.getEmployeeName() + " 导入失败,原因:" + ex.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 批量删除
|
|
|
if (!toDeleteIds.isEmpty()) {
|
|
|
infoMapper.deleteBatchIds(toDeleteIds);
|
|
|
- toDeleteIds.forEach(id -> respVO.getDeleteEmployeeNames().add(this.getInfo(id).getEmployeeName())); // 假设有一个findEmployeeNameById方法来获取员工名
|
|
|
+ toDeleteIds.forEach(id -> respVO.getDeleteEmployeeNames().add(this.getInfo(id).getEmployeeName()));
|
|
|
}
|
|
|
|
|
|
// 批量插入
|
|
|
if (!toInsert.isEmpty()) {
|
|
|
infoMapper.insertBatch(toInsert);
|
|
|
toInsert.forEach(info -> respVO.getCreateEmployeeNames().add(info.getEmployeeName()));
|
|
|
+ returnMsg.insert(0, "数据批量导入成功!共 " + toInsert.size() + " 条,数据如下:");
|
|
|
}
|
|
|
- return respVO;
|
|
|
+ return returnMsg.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|