|
|
@@ -369,30 +369,49 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
List<XmTechnicianEntity> list = xmTechnicianMapper.selectList(Wrappers.<XmTechnicianEntity>lambdaQuery().eq(XmTechnicianEntity::getYearAndMonth, yearAndMonth));
|
|
|
|
|
|
if(Func.isEmpty(list)){
|
|
|
- throw new ServiceException("本月没有研发人员");
|
|
|
+ throw new ServiceException("本月无参研人员");
|
|
|
}
|
|
|
+ List<String> unicodeList = list.stream().map(XmTechnicianEntity::getUnicode).distinct().toList();
|
|
|
|
|
|
+ List<AttendanceEntity> attendanceList = this.baseMapper.selectByYearAndMonth(yearAndMonth);
|
|
|
+ List<String> existsUnicodeList = attendanceList.stream().map(AttendanceEntity::getUnicode).distinct().toList();
|
|
|
+
|
|
|
+ List<String> insertUnicodeList = unicodeList.stream().filter(item -> !existsUnicodeList.contains(item)).toList();
|
|
|
+ if(Func.isEmpty(insertUnicodeList)){
|
|
|
+ throw new ServiceException("本月参研人员已全部引用");
|
|
|
+ }
|
|
|
List<AttendanceEntity> insertList = new ArrayList<>();
|
|
|
- for (XmTechnicianEntity xmTechnician : list) {
|
|
|
+ for (String unicode : insertUnicodeList) {
|
|
|
AttendanceEntity attendance = new AttendanceEntity();
|
|
|
- attendance.setUnicode(xmTechnician.getUnicode());
|
|
|
+ attendance.setUnicode(unicode);
|
|
|
attendance.setWorkDate(yearAndMonth + "01");
|
|
|
attendance.setWorkHours(0.0);
|
|
|
attendance.setTenantId(SecureUtil.getTenantId());
|
|
|
insertList.add(attendance);
|
|
|
}
|
|
|
+ return this.saveBatch(insertList);
|
|
|
+// if(Func.isEmpty(existsUnicodeList)){
|
|
|
+// return this.saveBatch(insertList);
|
|
|
+// }else {
|
|
|
+//// List<AttendanceEntity> deduplicationList = insertList.stream().filter(item -> !existsUnicodeList.contains(item.getUnicode())).toList();
|
|
|
+// List<String> insertUnicodeList = unicodeList.stream().filter(item -> !existsUnicodeList.contains(item)).toList();
|
|
|
+// if(Func.isEmpty(insertUnicodeList)){
|
|
|
+// throw new ServiceException("本月参研人员已全部引用");
|
|
|
+// }
|
|
|
+// return this.saveBatch(deduplicationList);
|
|
|
+// }
|
|
|
+// List<AttendanceEntity> insertList = new ArrayList<>();
|
|
|
+// for (XmTechnicianEntity xmTechnician : list) {
|
|
|
+// AttendanceEntity attendance = new AttendanceEntity();
|
|
|
+// attendance.setUnicode(xmTechnician.getUnicode());
|
|
|
+// attendance.setWorkDate(yearAndMonth + "01");
|
|
|
+// attendance.setWorkHours(0.0);
|
|
|
+// attendance.setTenantId(SecureUtil.getTenantId());
|
|
|
+// insertList.add(attendance);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- List<AttendanceEntity> attendanceList = this.baseMapper.selectByYearAndMonth(yearAndMonth);
|
|
|
- List<String> existsUnicodeList = attendanceList.stream().map(AttendanceEntity::getUnicode).distinct().toList();
|
|
|
- if(Func.isEmpty(existsUnicodeList)){
|
|
|
- return this.saveBatch(insertList);
|
|
|
- }else {
|
|
|
- List<AttendanceEntity> deduplicationList = insertList.stream().filter(item -> !existsUnicodeList.contains(item.getUnicode())).toList();
|
|
|
- if(Func.isEmpty(deduplicationList)){
|
|
|
- throw new ServiceException("本月研发人员已全部引用");
|
|
|
- }
|
|
|
- return this.saveBatch(deduplicationList);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|