|
@@ -68,6 +68,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.YearMonth;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -593,10 +594,14 @@ public class ReportServiceImpl implements ReportService {
|
|
|
List<String> userIds = userList.stream().map(AdminUserRespDTO::getId).collect(Collectors.toList());
|
|
|
List<StaffRecordSDO> starfList = recordsService.getUserList(userIds);
|
|
|
Map<String, StaffRecordSDO> userMap = starfList.stream()
|
|
|
- .collect(Collectors.toMap(StaffRecordSDO::getUserId,
|
|
|
- staffRecordSDO -> staffRecordSDO,
|
|
|
- (existing, replacement) -> existing));
|
|
|
+ .collect(Collectors.toMap(StaffRecordSDO::getUserId, Function.identity()));
|
|
|
|
|
|
+ //过滤尚未入职的用户
|
|
|
+ userList = filterUsersNotYetEntry(userList, userMap, year, month);
|
|
|
+
|
|
|
+ if (CollectionUtil.isEmpty(userList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
|
|
|
//获取当月的工作日列表及工作日/周数量
|
|
|
List<WorkdayDO> monthWorkDay = new ArrayList<>();
|
|
@@ -665,6 +670,38 @@ public class ReportServiceImpl implements ReportService {
|
|
|
return respList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 过滤掉在指定年月时尚未入职的用户
|
|
|
+ *
|
|
|
+ * @param userList 用户列表
|
|
|
+ * @param userMap 用户档案信息(包含入职时间)
|
|
|
+ * @param year 统计年份
|
|
|
+ * @param month 统计月份
|
|
|
+ * @return 过滤后的用户列表
|
|
|
+ */
|
|
|
+ private List<AdminUserRespDTO> filterUsersNotYetEntry(
|
|
|
+ List<AdminUserRespDTO> userList, Map<String, StaffRecordSDO> userMap,
|
|
|
+ Short year, Short month) {
|
|
|
+
|
|
|
+ YearMonth statYm = YearMonth.of(year, month);
|
|
|
+
|
|
|
+ return userList.stream()
|
|
|
+ .filter(user -> {
|
|
|
+ StaffRecordSDO staffRecord = userMap.get(user.getId());
|
|
|
+ if (staffRecord == null || staffRecord.getRgssj() == null) {
|
|
|
+ // 没有入职记录,默认不过滤(可根据业务需要改为 false)
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDateTime entryDate = staffRecord.getRgssj();
|
|
|
+ YearMonth entryYm = YearMonth.from(entryDate.toLocalDate());
|
|
|
+
|
|
|
+ return !entryYm.isAfter(statYm); // 入职时间不晚于统计月份才保留
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
public String sendFillRemind(Short year, Short month) {
|
|
|
ReportStatisticReqDTO reportStatisticReqDTO = new ReportStatisticReqDTO();
|
|
|
reportStatisticReqDTO.setYear(year);
|