From d90db860b7ea15a6d6c58a3e77b649966f3ab6bf Mon Sep 17 00:00:00 2001
From: yubo <autumnal_wind@yeah.net>
Date: 星期三, 08 四月 2026 21:05:26 +0800
Subject: [PATCH] fix(hr): 修正合同信息查询条件中的员工状态过滤
---
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java | 104 +++++++++++++++++++---------------------------------
1 files changed, 38 insertions(+), 66 deletions(-)
diff --git a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java
index 7b3c90e..6656212 100644
--- a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java
+++ b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java
@@ -655,7 +655,6 @@
}
-
empBaseInfo.setDelFlag(2);
// 入职类型
dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "lztype") && StrUtil.equals(j.getDicItemName(), list.get(31).toString())).findFirst().orElse(null);
@@ -667,7 +666,7 @@
if (null != dicItem) {
empBaseInfo.setArchivesStatus(dicItem.getDicItemCode());
}
- //身份证有效期
+ // 身份证有效期
empBaseInfo.setCertificateValidity(DateUtil.parse(list.get(33).toString()));
empBaseInfo.setEmpStatus("0");
boolean saveResult = this.save(empBaseInfo);
@@ -1079,7 +1078,7 @@
if (count != null) {
stringObjectMap.put("insuranceCount", count);
}
- //QueryRequest request
+ // QueryRequest request
return stringObjectMap;
}
@@ -1488,7 +1487,7 @@
@Override
public void updateAnnualLeave(String userId) {
EmpBaseInfo empBaseInfo = this.getById(userId);
- int holiday = calculateHoliday(empBaseInfo.getEntryDate());
+ int holiday = calculateHoliday(empBaseInfo.getEntryDate(), empBaseInfo.getEmpStatus());
empBaseInfo.setAnnualLeave(holiday);
baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>()
.set(EmpBaseInfo::getAnnualLeave, holiday)
@@ -1499,7 +1498,7 @@
public void updateAnnualLeave() {
List<EmpBaseInfo> list = this.list();
list.parallelStream().forEach(p -> {
- int holiday = calculateHoliday(p.getEntryDate());
+ int holiday = calculateHoliday(p.getEntryDate(), p.getEmpStatus());
p.setAnnualLeave(holiday);
baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>()
.set(EmpBaseInfo::getAnnualLeave, holiday)
@@ -1511,7 +1510,7 @@
public void updateEmpBaseKeyInfo() {
List<EmpBaseInfo> list = this.list();
list.parallelStream().forEach(p -> {
- int holiday = calculateHoliday(p.getEntryDate());
+ int holiday = calculateHoliday(p.getEntryDate(), p.getEmpStatus());
int age = calculateAge(p.getBirthdate());
baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>()
@@ -1528,7 +1527,7 @@
SortUtil.handlePageSort(request, page, "insuranceType", FebsConstant.ORDER_DESC, true);
// 使用优化后的方法查询社保档位提醒员工
- List<EmpBaseInfo> alertList = findInsuranceAlertList(empBaseInfo,request);
+ List<EmpBaseInfo> alertList = findInsuranceAlertList(empBaseInfo, request);
// 手动分页
int total = alertList.size();
int start = (int) ((page.getCurrent() - 1) * page.getSize());
@@ -1572,8 +1571,9 @@
@Override
public Long countInsuranceAlert(EmpBaseInfo empBaseInfo, QueryRequest request) {
- return (long) findInsuranceAlertList(empBaseInfo,request).size();
+ return (long) findInsuranceAlertList(empBaseInfo, request).size();
}
+
/**
* 查询社保档位提醒员工列表
* 保险类型:6-(非深户) 四险二档 7-(非深户) 四险一档 10-外参 13-临时工意外险 14-甲方购买
@@ -1585,7 +1585,6 @@
private List<EmpBaseInfo> findInsuranceAlertList(EmpBaseInfo empBaseInfo, QueryRequest request) {
// 1. 计算时间范围
LocalDate[] dateRange = calculateDateRange(empBaseInfo.getTimeRange());
- LocalDate startDate = dateRange[0];
LocalDate endDate = dateRange[1];
// 2. 获取提醒年龄配置
@@ -1624,12 +1623,14 @@
}
int alertAge = "1".equals(emp.getSex()) ? alertManAge : alertWomanAge;
+ int maxAge = "1".equals(emp.getSex()) ? 50 : 40;
LocalDate birthDate = emp.getBirthdate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
LocalDate alertDate = birthDate.plusYears(alertAge);
+ LocalDate maxDate = birthDate.plusYears(maxAge);
- return !alertDate.isAfter(endDate);
+ return !alertDate.isAfter(endDate) && endDate.isBefore(maxDate);
})
.collect(Collectors.toList());
}
@@ -1642,14 +1643,14 @@
// 使用正向计算获取退休提醒列表
List<EmpBaseInfo> alertList = findRetirementAlertList(empBaseInfo);
-
+
// 手动分页
int total = alertList.size();
int start = (int) ((page.getCurrent() - 1) * page.getSize());
int end = Math.min(start + (int) page.getSize(), total);
-
+
List<EmpBaseInfo> pageList = start < total ? alertList.subList(start, end) : new ArrayList<>();
-
+
// 设置字典名称
List<DicItem> dicItems = CastUtil.castList(redisService.get("dicItems"), DicItem.class);
pageList.forEach(item -> {
@@ -1659,7 +1660,7 @@
.map(DicItem::getDicItemName)
.orElse("未知"));
});
-
+
// 构建分页结果
Page<EmpBaseInfo> resultPage = new Page<>(page.getCurrent(), page.getSize(), total);
resultPage.setRecords(pageList);
@@ -1720,58 +1721,35 @@
/**
* 根据设置的参数计算员工的年假
*
- * @param date 入职日期
+ * @param date 入职日期
+ * @param empStatus 人员状态(0-正常 1-离职 2-退休)只计算在职的
* @return 年假天数
*/
- private int calculateHoliday(Date date) {
- int holiday = 0;
- int joinYear = DateUtil.ageOfNow(date);
- String configValue = redisService.get("annual_leave").toString();
- String[] values = StrUtil.split(configValue, "|");
- String[] condition = StrUtil.split(values[0], ",");
- String[] days = StrUtil.split(values[1], ",");
- if (condition.length == 2) {
- int one = Integer.parseInt(condition[0]);
- int two = Integer.parseInt(condition[1]);
- if (joinYear >= one && joinYear < two) {
- holiday = Integer.parseInt(days[0]);
- } else if (joinYear >= two) {
- holiday = Integer.parseInt(days[1]);
+ private int calculateHoliday(Date date, String empStatus) {
+ if (!empStatus.equals("0")) {
+ int holiday = 0;
+ int joinYear = DateUtil.ageOfNow(date);
+ String configValue = redisService.get("annual_leave").toString();
+ String[] values = StrUtil.split(configValue, "|");
+ String[] condition = StrUtil.split(values[0], ",");
+ String[] days = StrUtil.split(values[1], ",");
+ if (condition.length == 2) {
+ int one = Integer.parseInt(condition[0]);
+ int two = Integer.parseInt(condition[1]);
+ if (joinYear >= one && joinYear < two) {
+ holiday = Integer.parseInt(days[0]);
+ } else if (joinYear >= two) {
+ holiday = Integer.parseInt(days[1]);
+ }
}
+ return holiday;
+ } else {
+ return 0;
}
- return holiday;
}
private int calculateAge(Date date) {
return DateUtil.ageOfNow(date);
- }
-
- private QueryWrapper<EmpBaseInfo> createInsuranceAlertQueryWrapper(EmpBaseInfo empBaseInfo) {
- String[] alertInsuranceTypes = {"6", "7", "10", "13", "14"};
-
- QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("a.DelFlag", "0");
- queryWrapper.eq("a.empStatus", "0");
- queryWrapper.in("a.insuranceType", (Object[]) alertInsuranceTypes);
-
- int alertWomanAge = getRedisConfigWithDefault("insurance_alert_woman", 39);
- int alertManAge = getRedisConfigWithDefault("insurance_alert_man", 48);
-
- queryWrapper.and(wrapper ->
- wrapper.and(inner -> inner.eq("a.sex", "1").ge("a.age", alertManAge))
- .or(inner -> inner.eq("a.sex", "2").ge("a.age", alertWomanAge))
- );
-
-
- return queryWrapper;
- }
-
- private void buildAgeCondition(QueryWrapper<EmpBaseInfo> wrapper, int manAge, int womanAge) {
- wrapper.nested(inner -> inner
- .gt("a.age", manAge).eq("a.sex", "1")
- ).or().nested(inner -> inner
- .gt("a.age", womanAge).eq("a.sex", "2")
- );
}
private int getRedisConfigWithDefault(String key, int defaultValue) {
@@ -1829,13 +1807,6 @@
}
/**
- * 统计退休提醒数量(正向计算)
- */
- public Long countRetirementAlert(EmpBaseInfo empBaseInfo) {
- return (long) findRetirementAlertList(empBaseInfo).size();
- }
-
- /**
* 计算员工的实际退休时间(正向计算)
* 方案A:法定退休时间早于2025-01时,按法定年龄退休,不延迟
*/
@@ -1864,13 +1835,14 @@
// 法定退休时间晚于等于2025-01,计算延迟
long monthsBetween = ChronoUnit.MONTHS.between(delayStart, legalRetirement);
- long delayMonths = monthsBetween / delayDivisor;
+ long delayMonths = (monthsBetween / delayDivisor) + 1;
return legalRetirement.plusMonths(delayMonths);
}
/**
* 根据时间范围类型计算开始和结束日期
+ *
* @param timeRange 0-当天 1-本周 2-本月 3-今年
* @return 包含开始日期和结束日期的数组 [startDate, endDate)
*/
--
Gitblit v1.8.0