From 42d1da6ad4334479e44b9029ed0646879e24361f Mon Sep 17 00:00:00 2001
From: yubo <autumnal_wind@yeah.net>
Date: 星期六, 11 四月 2026 08:16:53 +0800
Subject: [PATCH] feat(hr): 添加人员基本信息模块实现
---
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java | 905 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 660 insertions(+), 245 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 1373f36..a00d17f 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
@@ -43,7 +43,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.time.DayOfWeek;
import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@@ -490,183 +494,439 @@
@Override
@Transactional(rollbackFor = Exception.class)
public void importEmpBaseInfo(List<List<Object>> listObject, List<String> returnList, List<DicItem> dicItems) {
+ // ========== 优化1:批量预加载员工数据 ==========
+ Set<String> empNumbs = new HashSet<>();
for (List<Object> list : listObject) {
- if (list.size() == 0) {
+ if (list.isEmpty()) continue;
+ String empNumb = getImportCellValue(list, 1);
+ if (StringUtils.isNotBlank(empNumb)) {
+ empNumbs.add(empNumb);
+ }
+ }
+
+ // 批量查询已存在的员工,构建Map
+ Map<String, EmpBaseInfo> empMap = new HashMap<>();
+ if (CollUtil.isNotEmpty(empNumbs)) {
+ List<EmpBaseInfo> existEmps = this.list(
+ new LambdaQueryWrapper<EmpBaseInfo>()
+ .in(EmpBaseInfo::getEmpNumb, empNumbs)
+ );
+ empMap = existEmps.stream()
+ .collect(Collectors.toMap(EmpBaseInfo::getEmpNumb, e -> e));
+ }
+
+ // 批量查询身份证号重复情况
+ Map<String, Long> certCountMap = new HashMap<>();
+ if (CollUtil.isNotEmpty(empNumbs)) {
+ List<EmpBaseInfo> certCheckList = this.list(
+ new LambdaQueryWrapper<EmpBaseInfo>()
+ .select(EmpBaseInfo::getCertificateNumb)
+ .in(EmpBaseInfo::getCertificateNumb, empNumbs)
+ .ne(EmpBaseInfo::getDelFlag, 1)
+ );
+ certCountMap = certCheckList.stream()
+ .filter(e -> StringUtils.isNotBlank(e.getCertificateNumb()))
+ .collect(Collectors.groupingBy(
+ EmpBaseInfo::getCertificateNumb,
+ Collectors.counting()
+ ));
+ }
+
+ // ========== 优化2:部门/岗位数据提前转Map ==========
+ List<Dept> depts = CastUtil.castList(redisService.get("depts"), Dept.class);
+ if (CollUtil.isEmpty(depts)) {
+ depts = remoteDeptService.setDeptRedis();
+ }
+ Map<String, Dept> deptMap = new HashMap<>();
+ if (CollUtil.isNotEmpty(depts)) {
+ deptMap = depts.stream()
+ .collect(Collectors.toMap(Dept::getDeptName, d -> d, (v1, v2) -> v1));
+ }
+
+ List<Position> positionList = CastUtil.castList(redisService.get("position"), Position.class);
+ if (CollUtil.isEmpty(positionList)) {
+ positionList = remotePositionService.setPositionRedis();
+ }
+ Map<String, Position> positionMap = new HashMap<>();
+ if (CollUtil.isNotEmpty(positionList)) {
+ positionMap = positionList.stream()
+ .collect(Collectors.toMap(Position::getPositionName, p -> p, (v1, v2) -> v1));
+ }
+
+ // ========== 优化3:字典数据转Map ==========
+ Map<String, Map<String, DicItem>> dicMap = new HashMap<>();
+ if (CollUtil.isNotEmpty(dicItems)) {
+ dicMap = dicItems.stream()
+ .collect(Collectors.groupingBy(
+ DicItem::getDicCode,
+ Collectors.toMap(DicItem::getDicItemName, d -> d, (v1, v2) -> v1)
+ ));
+ }
+
+ String operatorId = FebsUtil.getUserId();
+
+ // 分离新增和更新的数据
+ List<EmpBaseInfo> newEmpList = new ArrayList<>();
+ List<EmpBaseInfo> updateEmpList = new ArrayList<>();
+
+ // ========== 循环处理(保留原有逻辑)==========
+ for (int i = 0; i < listObject.size(); i++) {
+ List<Object> list = listObject.get(i);
+ if (list.isEmpty()) {
continue;
}
- if (this.count(new LambdaQueryWrapper<EmpBaseInfo>().eq(EmpBaseInfo::getEmpNumb, list.get(1).toString()).ne(EmpBaseInfo::getDelFlag, 1)) > 0) {
- returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}员工编号重复", listObject.indexOf(list) + 1, list.get(1).toString()));
+
+ String empNumb = getImportCellValue(list, 1);
+
+ // ⚡ 从Map获取,不再查询数据库
+ EmpBaseInfo dbData = empMap.get(empNumb);
+ boolean isNew = dbData == null;
+
+ // ⚡ 从Map检查身份证重复
+ if (isNew && certCountMap.getOrDefault(empNumb, 0L) > 0) {
+ returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}身份证号重复", i + 1, empNumb));
continue;
}
- if (this.count(new LambdaQueryWrapper<EmpBaseInfo>().eq(EmpBaseInfo::getCertificateNumb, list.get(1).toString()).ne(EmpBaseInfo::getDelFlag, 1)) > 0) {
- returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}身份证号重复", listObject.indexOf(list) + 1, list.get(1).toString()));
- continue;
- }
- EmpBaseInfo empBaseInfo = new EmpBaseInfo();
- empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE));
- empBaseInfo.setArchivesNumb(list.get(0).toString());
- empBaseInfo.setEmpNumb(list.get(1).toString());
-
- List<Dept> depts = CastUtil.castList(redisService.get("depts"), Dept.class);
- if (null == depts) {
- depts = remoteDeptService.setDeptRedis();
- }
- if (null == depts) {
- depts = remoteDeptService.setDeptRedis();
- }
- empBaseInfo.setDeptName(list.get(2).toString());
- Dept dept = depts.stream().filter(d -> d.getDeptName().equals(list.get(2).toString())).findFirst().orElse(null);
- if (null == dept) {
- returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}部门不存在", listObject.indexOf(list) + 1, list.get(2).toString()));
- continue;
+
+ EmpBaseInfo empBaseInfo = isNew ? new EmpBaseInfo() : dbData;
+ if (isNew) {
+ empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE));
}
- empBaseInfo.setAllDeptName(dept.getAllDeptName());
+ String archivesNumb = getImportCellValue(list, 0);
+ if (isNew || StringUtils.isNotBlank(archivesNumb)) {
+ empBaseInfo.setArchivesNumb(archivesNumb);
+ }
+ if (isNew || StringUtils.isNotBlank(empNumb)) {
+ empBaseInfo.setEmpNumb(empNumb);
+ }
- empBaseInfo.setDeptId(dept.getDeptId());
- List<Position> positionList = CastUtil.castList(redisService.get("position"), Position.class);
- if (null == positionList) {
- positionList = remotePositionService.setPositionRedis();
- if (null == positionList) {
- returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}获取岗位为空,请设置岗位", listObject.indexOf(list) + 1, list.get(3).toString()));
+ String deptName = getImportCellValue(list, 2);
+ if (isNew || StringUtils.isNotBlank(deptName)) {
+ // ⚡ 使用Map查找
+ Dept dept = deptMap.get(deptName);
+ if (null == dept) {
+ returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}部门不存在", i + 1, deptName));
continue;
}
+
+ empBaseInfo.setDeptName(deptName);
+ empBaseInfo.setAllDeptName(dept.getAllDeptName());
+ empBaseInfo.setDeptId(dept.getDeptId());
}
- Position position = positionList.stream().filter(d -> d.getPositionName().equals(list.get(3).toString())).findFirst().orElse(null);
- if (null == position) {
- returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}获取岗位为空", listObject.indexOf(list) + 1, list.get(3).toString()));
- continue;
+
+ String jobName = getImportCellValue(list, 3);
+ if (isNew || StringUtils.isNotBlank(jobName)) {
+ // ⚡ 使用Map查找
+ Position position = positionMap.get(jobName);
+ if (null == position) {
+ returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}获取岗位为空", i + 1, jobName));
+ continue;
+ }
+ empBaseInfo.setJobId(position.getPositionId());
+ empBaseInfo.setJobName(jobName);
}
- empBaseInfo.setJobId(position.getPositionId());
- empBaseInfo.setJobName(list.get(3).toString());
- empBaseInfo.setEmpName(list.get(4).toString());
+
+ String empName = getImportCellValue(list, 4);
+ if (isNew || StringUtils.isNotBlank(empName)) {
+ empBaseInfo.setEmpName(empName);
+ }
+
+ String certificateNumb = getImportCellValue(list, 5);
try {
- if (StrUtil.isNotBlank(list.get(5).toString())) {
- empBaseInfo.setCertificateNumb(list.get(5).toString());
- if (IdcardUtil.isValidCard(list.get(5).toString())) {
- empBaseInfo.setAge(IdcardUtil.getAgeByIdCard(list.get(5).toString()));
- empBaseInfo.setBirthdate(IdcardUtil.getBirthDate(list.get(5).toString()));
+ if (isNew || StrUtil.isNotBlank(certificateNumb)) {
+ empBaseInfo.setCertificateNumb(certificateNumb);
+ if (IdcardUtil.isValidCard(certificateNumb)) {
+ empBaseInfo.setAge(IdcardUtil.getAgeByIdCard(certificateNumb));
+ empBaseInfo.setBirthdate(IdcardUtil.getBirthDate(certificateNumb));
}
}
-
} catch (Exception e) {
log.error("导入人员身份证异常:{}", e);
- returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}检查身份证是否正确", listObject.indexOf(list) + 1, list.get(5).toString()));
+ returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}检查身份证是否正确", i + 1, certificateNumb));
continue;
}
-
- empBaseInfo.setSex("男".equals(list.get(6).toString()) ? "1" : "2");
-
- // 民族
- DicItem dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "nation") && StrUtil.equals(j.getDicItemName(), list.get(7).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setNation(dicItem.getDicItemCode());
+ String sex = getImportCellValue(list, 6);
+ if (isNew || StringUtils.isNotBlank(sex)) {
+ empBaseInfo.setSex("男".equals(sex) ? "1" : "2");
}
- // 婚姻状况
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "marriage") && StrUtil.equals(j.getDicItemName(), list.get(8).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setMarriage(dicItem.getDicItemCode());
- }
-
- if (StringUtils.isNotBlank(list.get(9).toString())) {
- empBaseInfo.setStature(Integer.valueOf(list.get(9).toString()));
- }
- // 政治面貌
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "plitical") && StrUtil.equals(j.getDicItemName(), list.get(10).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setPolitics(dicItem.getDicItemCode());
- }
-
- if (StringUtils.isNotBlank(list.get(11).toString())) {
- empBaseInfo.setEntryDate(DateUtil.parse(list.get(11).toString()));
- }
-
- // 最高学历
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "education") && StrUtil.equals(j.getDicItemName(), list.get(12).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setEducation(dicItem.getDicItemCode());
- }
-
- if (StringUtils.isNotBlank(list.get(13).toString())) {
- empBaseInfo.setSeniority(list.get(13).toString());
- }
-
- // 籍贯
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "nativePlace") && StrUtil.equals(j.getDicItemName(), list.get(14).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setNativePlace(dicItem.getDicItemCode());
- }
-
- empBaseInfo.setCensusAddress(list.get(15).toString());
- empBaseInfo.setCurrentAddress(list.get(16).toString());
- // 员工类型
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "empType") && StrUtil.equals(j.getDicItemName(), list.get(17).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setEmpType(dicItem.getDicItemCode());
- }
-
- empBaseInfo.setGuardNumb(list.get(18).toString());
- empBaseInfo.setReturnReceipt(list.get(19).toString());
- empBaseInfo.setTelePhone(list.get(20).toString());
- empBaseInfo.setIntroducer(list.get(21).toString());
- empBaseInfo.setBankName(list.get(22).toString());
- empBaseInfo.setBankNumb(list.get(23).toString());
- // 保险类型
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "insuranceType") && StrUtil.equals(j.getDicItemName(), list.get(24).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setInsuranceType(dicItem.getDicItemCode());
- }
-
- empBaseInfo.setSocialNumb(list.get(25).toString());
- empBaseInfo.setFamily(list.get(26).toString());
- empBaseInfo.setUrgencyPhone(list.get(27).toString());
- // 员工手册
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "handbookStatus") && StrUtil.equals(j.getDicItemName(), list.get(28).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setHandbookStatus(dicItem.getDicItemCode());
- }
-
- // 工作证
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "empCardStatus") && StrUtil.equals(j.getDicItemName(), list.get(29).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setEmpCardStatus(dicItem.getDicItemCode());
- }
-
- // 相关证件
- List<DicItem> dicItemList = new ArrayList<>();
- String[] certificateList = list.get(30).toString().split(StringConstant.COMMA);
- if (null != certificateList) {
- for (String s : certificateList) {
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "certificateList") && StrUtil.equals(j.getDicItemName(), s)).findFirst().orElse(null);
+ // 民族 - 使用字典Map查找
+ String nationName = getImportCellValue(list, 7);
+ if (StringUtils.isNotBlank(nationName)) {
+ Map<String, DicItem> nationDic = dicMap.get("nation");
+ if (nationDic != null) {
+ DicItem dicItem = nationDic.get(nationName);
if (null != dicItem) {
- dicItemList.add(dicItem);
+ empBaseInfo.setNation(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ // 婚姻状况 - 使用字典Map查找
+ String marriageName = getImportCellValue(list, 8);
+ if (StringUtils.isNotBlank(marriageName)) {
+ Map<String, DicItem> marriageDic = dicMap.get("marriage");
+ if (marriageDic != null) {
+ DicItem dicItem = marriageDic.get(marriageName);
+ if (null != dicItem) {
+ empBaseInfo.setMarriage(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ String stature = getImportCellValue(list, 9);
+ if (StringUtils.isNotBlank(stature)) {
+ empBaseInfo.setStature(Integer.valueOf(stature));
+ }
+ // 政治面貌 - 使用字典Map查找
+ String politicsName = getImportCellValue(list, 10);
+ if (StringUtils.isNotBlank(politicsName)) {
+ Map<String, DicItem> politicsDic = dicMap.get("plitical");
+ if (politicsDic != null) {
+ DicItem dicItem = politicsDic.get(politicsName);
+ if (null != dicItem) {
+ empBaseInfo.setPolitics(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ String entryDate = getImportCellValue(list, 11);
+ if (StringUtils.isNotBlank(entryDate)) {
+ empBaseInfo.setEntryDate(DateUtil.parse(entryDate));
+ }
+
+ // 最高学历 - 使用字典Map查找
+ String educationName = getImportCellValue(list, 12);
+ if (StringUtils.isNotBlank(educationName)) {
+ Map<String, DicItem> educationDic = dicMap.get("education");
+ if (educationDic != null) {
+ DicItem dicItem = educationDic.get(educationName);
+ if (null != dicItem) {
+ empBaseInfo.setEducation(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ String seniority = getImportCellValue(list, 13);
+ if (StringUtils.isNotBlank(seniority)) {
+ empBaseInfo.setSeniority(seniority);
+ }
+
+ // 籍贯 - 使用字典Map查找
+ String nativePlaceName = getImportCellValue(list, 14);
+ if (StringUtils.isNotBlank(nativePlaceName)) {
+ Map<String, DicItem> nativePlaceDic = dicMap.get("nativePlace");
+ if (nativePlaceDic != null) {
+ DicItem dicItem = nativePlaceDic.get(nativePlaceName);
+ if (null != dicItem) {
+ empBaseInfo.setNativePlace(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ String censusAddress = getImportCellValue(list, 15);
+ if (isNew || StringUtils.isNotBlank(censusAddress)) {
+ empBaseInfo.setCensusAddress(censusAddress);
+ }
+ String currentAddress = getImportCellValue(list, 16);
+ if (isNew || StringUtils.isNotBlank(currentAddress)) {
+ empBaseInfo.setCurrentAddress(currentAddress);
+ }
+ // 员工类型 - 使用字典Map查找
+ String empTypeName = getImportCellValue(list, 17);
+ if (StringUtils.isNotBlank(empTypeName)) {
+ Map<String, DicItem> empTypeDic = dicMap.get("empType");
+ if (empTypeDic != null) {
+ DicItem dicItem = empTypeDic.get(empTypeName);
+ if (null != dicItem) {
+ empBaseInfo.setEmpType(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ String guardNumb = getImportCellValue(list, 18);
+ if (isNew || StringUtils.isNotBlank(guardNumb)) {
+ empBaseInfo.setGuardNumb(guardNumb);
+ }
+ String returnReceipt = getImportCellValue(list, 19);
+ if (isNew || StringUtils.isNotBlank(returnReceipt)) {
+ empBaseInfo.setReturnReceipt(returnReceipt);
+ }
+ String telePhone = getImportCellValue(list, 20);
+ if (isNew || StringUtils.isNotBlank(telePhone)) {
+ empBaseInfo.setTelePhone(telePhone);
+ }
+ String introducer = getImportCellValue(list, 21);
+ if (isNew || StringUtils.isNotBlank(introducer)) {
+ empBaseInfo.setIntroducer(introducer);
+ }
+ String bankName = getImportCellValue(list, 22);
+ if (isNew || StringUtils.isNotBlank(bankName)) {
+ empBaseInfo.setBankName(bankName);
+ }
+ String bankNumb = getImportCellValue(list, 23);
+ if (isNew || StringUtils.isNotBlank(bankNumb)) {
+ empBaseInfo.setBankNumb(bankNumb);
+ }
+ // 保险类型 - 使用字典Map查找
+ String insuranceTypeName = getImportCellValue(list, 24);
+ if (StringUtils.isNotBlank(insuranceTypeName)) {
+ Map<String, DicItem> insuranceTypeDic = dicMap.get("insuranceType");
+ if (insuranceTypeDic != null) {
+ DicItem dicItem = insuranceTypeDic.get(insuranceTypeName);
+ if (null != dicItem) {
+ empBaseInfo.setInsuranceType(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ String socialNumb = getImportCellValue(list, 25);
+ if (isNew || StringUtils.isNotBlank(socialNumb)) {
+ empBaseInfo.setSocialNumb(socialNumb);
+ }
+ String family = getImportCellValue(list, 26);
+ if (isNew || StringUtils.isNotBlank(family)) {
+ empBaseInfo.setFamily(family);
+ }
+ String urgencyPhone = getImportCellValue(list, 27);
+ if (isNew || StringUtils.isNotBlank(urgencyPhone)) {
+ empBaseInfo.setUrgencyPhone(urgencyPhone);
+ }
+ // 员工手册 - 使用字典Map查找
+ String handbookStatusName = getImportCellValue(list, 28);
+ if (StringUtils.isNotBlank(handbookStatusName)) {
+ Map<String, DicItem> handbookStatusDic = dicMap.get("handbookStatus");
+ if (handbookStatusDic != null) {
+ DicItem dicItem = handbookStatusDic.get(handbookStatusName);
+ if (null != dicItem) {
+ empBaseInfo.setHandbookStatus(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ // 工作证 - 使用字典Map查找
+ String empCardStatusName = getImportCellValue(list, 29);
+ if (StringUtils.isNotBlank(empCardStatusName)) {
+ Map<String, DicItem> empCardStatusDic = dicMap.get("empCardStatus");
+ if (empCardStatusDic != null) {
+ DicItem dicItem = empCardStatusDic.get(empCardStatusName);
+ if (null != dicItem) {
+ empBaseInfo.setEmpCardStatus(dicItem.getDicItemCode());
+ }
+ }
+ }
+
+ // 相关证件 - 使用字典Map查找
+ List<DicItem> dicItemList = new ArrayList<>();
+ String certificateListValue = getImportCellValue(list, 30);
+ String[] certificateList = certificateListValue.split(StringConstant.COMMA);
+ if (isNew || StringUtils.isNotBlank(certificateListValue)) {
+ Map<String, DicItem> certificateListDic = dicMap.get("certificateList");
+ for (String s : certificateList) {
+ if (certificateListDic != null) {
+ DicItem dicItem = certificateListDic.get(s);
+ if (null != dicItem) {
+ dicItemList.add(dicItem);
+ }
}
}
}
if (CollUtil.isNotEmpty(dicItemList)) {
- empBaseInfo.setCertificateList(dicItemList.stream().map(i -> i.getDicItemCode()).collect(Collectors.joining(StringConstant.COMMA)));
+ empBaseInfo.setCertificateList(dicItemList.stream()
+ .map(DicItem::getDicItemCode)
+ .collect(Collectors.joining(StringConstant.COMMA)));
}
- empBaseInfo.setDelFlag(2);
- // 入职类型
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "lztype") && StrUtil.equals(j.getDicItemName(), list.get(31).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setEntryType(dicItem.getDicItemCode());
+ if (isNew) {
+ empBaseInfo.setDelFlag(2);
}
- // 档案情况
- dicItem = dicItems.parallelStream().filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), "archivesStatus") && StrUtil.equals(j.getDicItemName(), list.get(32).toString())).findFirst().orElse(null);
- if (null != dicItem) {
- empBaseInfo.setArchivesStatus(dicItem.getDicItemCode());
+ // 入职类型 - 使用字典Map查找
+ String lztypeName = getImportCellValue(list, 31);
+ if (StringUtils.isNotBlank(lztypeName)) {
+ Map<String, DicItem> lztypeDic = dicMap.get("lztype");
+ if (lztypeDic != null) {
+ DicItem dicItem = lztypeDic.get(lztypeName);
+ if (null != dicItem) {
+ empBaseInfo.setEntryType(dicItem.getDicItemCode());
+ }
+ }
}
- empBaseInfo.setEmpStatus("0");
- boolean saveResult = this.save(empBaseInfo);
- // 新入职员工需要增加一条入职记录
- this.addEmpDimissLog(empBaseInfo, "2", empBaseInfo.getEmpId());
+ // 档案情况 - 使用字典Map查找
+ String archivesStatusName = getImportCellValue(list, 32);
+ if (StringUtils.isNotBlank(archivesStatusName)) {
+ Map<String, DicItem> archivesStatusDic = dicMap.get("archivesStatus");
+ if (archivesStatusDic != null) {
+ DicItem dicItem = archivesStatusDic.get(archivesStatusName);
+ if (null != dicItem) {
+ empBaseInfo.setArchivesStatus(dicItem.getDicItemCode());
+ }
+ }
+ }
+ // 身份证有效期
+ String certificateValidity = getImportCellValue(list, 33);
+ if (isNew || StringUtils.isNotBlank(certificateValidity)) {
+ empBaseInfo.setCertificateValidity(DateUtil.parse(certificateValidity));
+ }
+ if (isNew) {
+ empBaseInfo.setEmpStatus("0");
+ newEmpList.add(empBaseInfo);
+ } else {
+ empBaseInfo.setModifyTime(new Date());
+ empBaseInfo.setModifier(operatorId);
+ updateEmpList.add(empBaseInfo);
+ }
}
+
+ // ========== 优化4:批量保存/更新 ==========
+ if (CollUtil.isNotEmpty(newEmpList)) {
+ this.saveBatch(newEmpList, 100);
+ // 批量添加入职记录
+ for (EmpBaseInfo emp : newEmpList) {
+ this.addEmpDimissLog(emp, "2", emp.getEmpId());
+ }
+ }
+
+ if (CollUtil.isNotEmpty(updateEmpList)) {
+ this.updateBatchById(updateEmpList, 100);
+ }
+ }
+
+ private String getImportCellValue(List<Object> list, int index) {
+ if (index >= list.size() || list.get(index) == null) {
+ return StringUtils.EMPTY;
+ }
+ return list.get(index).toString();
+ }
+
+ private List<Dept> getImportDepts(List<Dept> depts) {
+ if (null == depts) {
+ depts = remoteDeptService.setDeptRedis();
+ }
+ if (null == depts) {
+ depts = remoteDeptService.setDeptRedis();
+ }
+ return depts;
+ }
+
+ private List<Position> getImportPositions(List<Position> positionList) {
+ if (null == positionList) {
+ positionList = remotePositionService.setPositionRedis();
+ }
+ return positionList;
+ }
+
+ private DicItem getImportDicItem(List<DicItem> dicItems, String dicCode, String dicItemName) {
+ if (StrUtil.isBlank(dicItemName)) {
+ return null;
+ }
+ return dicItems.parallelStream()
+ .filter(j -> StrUtil.equalsIgnoreCase(j.getDicCode(), dicCode) && StrUtil.equals(j.getDicItemName(), dicItemName))
+ .findFirst()
+ .orElse(null);
}
// @Override
@@ -1054,6 +1314,25 @@
if (bljlObjectMap != null) {
stringObjectMap.put("bljl", bljlObjectMap);
}
+ // 试用提醒 判断条件试用期结束时间
+ EmpBaseInfo empBaseInfo = new EmpBaseInfo();
+ empBaseInfo.setTimeRange(Integer.valueOf(index));
+ Long count = empBaseInfoMapper.selectAlertCount(
+ createProbationAlertQueryWrapper(empBaseInfo)
+ );
+ if (count != null) {
+ stringObjectMap.put("probationCount", count);
+ }
+
+ // 四险提醒 判断条件试用期结束时间
+ empBaseInfo = new EmpBaseInfo();
+ empBaseInfo.setTimeRange(Integer.valueOf(index));
+ QueryRequest queryRequest = new QueryRequest();
+ count = this.countInsuranceAlert(empBaseInfo, queryRequest);
+ if (count != null) {
+ stringObjectMap.put("insuranceCount", count);
+ }
+ // QueryRequest request
return stringObjectMap;
}
@@ -1462,7 +1741,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)
@@ -1473,7 +1752,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)
@@ -1485,7 +1764,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>()
@@ -1495,19 +1774,28 @@
});
}
+ // region 员工社保档位提醒
@Override
public IPage<EmpBaseInfo> findInsuranceEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) {
Page<EmpBaseInfo> page = new Page<>(request.getPageNum(), request.getPageSize());
- SortUtil.handlePageSort(request, page, "entryDate", FebsConstant.ORDER_ASC, true);
- IPage<EmpBaseInfo> iPage = empBaseInfoMapper.selectPageVo(page, createInsuranceAlertQueryWrapper(empBaseInfo));
- List<EmpBaseInfo> list = iPage.getRecords();
+ SortUtil.handlePageSort(request, page, "insuranceType", FebsConstant.ORDER_DESC, true);
+
+ // 使用优化后的方法查询社保档位提醒员工
+ List<EmpBaseInfo> alertList = findInsuranceAlertList(empBaseInfo, request);
+ // 手动分页
+ 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);
- list.forEach(item -> {
+ pageList.forEach(item -> {
item.setInsuranceTypeName(dicItems.stream()
.filter(k -> DicCode.INSURANCETYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(item.getInsuranceType()))
.findFirst()
.map(DicItem::getDicItemName)
- .orElse("未购保险"));
+ .orElse("未知"));
item.setSexName(dicItems.stream()
.filter(k -> DicCode.SEX.equals(k.getDicCode()) && k.getDicItemCode().equals(item.getSex()))
.findFirst()
@@ -1529,27 +1817,108 @@
.map(DicItem::getDicItemName)
.orElse("未知"));
});
- iPage.setRecords(list);
- return iPage;
+ // 构建分页结果
+ Page<EmpBaseInfo> resultPage = new Page<>(page.getCurrent(), page.getSize(), total);
+ resultPage.setRecords(pageList);
+ return resultPage;
}
+
+ @Override
+ public Long countInsuranceAlert(EmpBaseInfo empBaseInfo, QueryRequest request) {
+ return (long) findInsuranceAlertList(empBaseInfo, request).size();
+ }
+
+ /**
+ * 查询社保档位提醒员工列表
+ * 保险类型:6-(非深户) 四险二档 7-(非深户) 四险一档 10-外参 13-临时工意外险 14-甲方购买
+ * 提醒年龄:男 48 岁,女 39 岁
+ *
+ * @param empBaseInfo 查询条件,timeRange 字段控制时间范围(0-当天 1-本周 2-本月 3-今年)
+ * @return 符合条件的员工列表
+ */
+ private List<EmpBaseInfo> findInsuranceAlertList(EmpBaseInfo empBaseInfo, QueryRequest request) {
+ // 1. 计算时间范围
+ LocalDate[] dateRange = calculateDateRange(empBaseInfo.getTimeRange());
+ LocalDate endDate = dateRange[1];
+
+ // 2. 获取提醒年龄配置
+ int alertWomanAge = getRedisConfigWithDefault("insurance_alert_woman", 39);
+ int alertManAge = getRedisConfigWithDefault("insurance_alert_man", 48);
+
+ // 3. 获取排序参数
+ String sortField = StringUtils.isNotBlank(request.getField()) ? request.getField() : "insuranceType";
+ boolean isAsc = FebsConstant.ORDER_ASC.equals(request.getOrder());
+
+ // 4. 查询符合条件的员工(仅做初步筛选)
+ QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("a.DelFlag", "0")
+ .eq("a.empStatus", "0")
+ .in("a.insuranceType", "6", "7", "10", "13", "14")
+ .isNotNull("a.birthdate")
+ .isNotNull("a.sex");
+ // 如果传入了性别条件,则添加性别筛选
+ if (StringUtils.isNotBlank(empBaseInfo.getSex())) {
+ queryWrapper.eq("a.sex", empBaseInfo.getSex());
+ }
+
+ // 如果传入了社保档位条件,则添加社保档位筛选
+ if (StringUtils.isNotBlank(empBaseInfo.getInsuranceType())) {
+ queryWrapper.eq("a.insuranceType", empBaseInfo.getInsuranceType());
+ }
+ // 添加排序条件
+ queryWrapper.orderBy(true, isAsc, sortField);
+ List<EmpBaseInfo> allList = this.baseMapper.listAll(queryWrapper);
+
+ // 5. 精确筛选:计算每个员工的"生日 + 提醒年龄"日期,判断是否在时间范围内
+ return allList.stream()
+ .filter(emp -> {
+ if (emp.getBirthdate() == null || emp.getSex() == null) {
+ return false;
+ }
+
+ 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) && endDate.isBefore(maxDate);
+ })
+ .collect(Collectors.toList());
+ }
+ //#endregion
@Override
public IPage<EmpBaseInfo> findRetirementEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) {
Page<EmpBaseInfo> page = new Page<>(request.getPageNum(), request.getPageSize());
SortUtil.handlePageSort(request, page, "birthDate", FebsConstant.ORDER_ASC, true);
- IPage<EmpBaseInfo> iPage = empBaseInfoMapper.selectPageVo(page, createRetirementAlertQueryWrapper(empBaseInfo));
- List<EmpBaseInfo> list = iPage.getRecords();
+ // 使用正向计算获取退休提醒列表
+ 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);
- list.forEach(item -> {
+ pageList.forEach(item -> {
item.setSexName(dicItems.stream()
.filter(k -> DicCode.SEX.equals(k.getDicCode()) && k.getDicItemCode().equals(item.getSex()))
.findFirst()
.map(DicItem::getDicItemName)
.orElse("未知"));
});
- iPage.setRecords(list);
- return iPage;
+
+ // 构建分页结果
+ Page<EmpBaseInfo> resultPage = new Page<>(page.getCurrent(), page.getSize(), total);
+ resultPage.setRecords(pageList);
+ return resultPage;
}
@Override
@@ -1606,69 +1975,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 INSURANCE_TYPE_FOUR_ONE = "7";
- String INSURANCE_TYPE_FOUR_TWO = "6";
-
- QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("a.DelFlag", "0");
- queryWrapper.eq("a.empStatus", "0");
-
- int fourOneWoman = getRedisConfigWithDefault("four_one_woman", 39);
- int fourOneMan = getRedisConfigWithDefault("four_one_man", 45);
- int fourTwoWoman = getRedisConfigWithDefault("four_two_woman", 46);
- int fourTwoMan = getRedisConfigWithDefault("four_two_man", 55);
-
- queryWrapper.and(wrapper -> wrapper
- .nested(inner -> inner
- .eq("a.insuranceType", INSURANCE_TYPE_FOUR_TWO)
- .and(ageWrapper -> buildAgeCondition(ageWrapper, fourTwoMan, fourTwoWoman))
- ).or().nested(inner -> inner
- .eq("a.insuranceType", INSURANCE_TYPE_FOUR_ONE)
- .and(ageWrapper -> buildAgeCondition(ageWrapper, fourOneMan, fourOneWoman))
- ).or().nested(inner -> inner
- .and(noInsuranceWrapper -> noInsuranceWrapper
- .isNull("a.insuranceType")
- .or().eq("a.insuranceType", "")
- )
- )
- );
-
- 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) {
@@ -1685,36 +2020,118 @@
}
}
- private QueryWrapper<EmpBaseInfo> createRetirementAlertQueryWrapper(EmpBaseInfo empBaseInfo) {
- QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("a.DelFlag", 0);
- // 人员的状态,0-在职 1-离职 2-退休
- queryWrapper.eq("a.empStatus", "0");
- // 未提醒
- queryWrapper.eq("a.retirementReminded", 0);
+ /**
+ * 查询退休提醒列表(正向计算)
+ * 使用延迟退休计算逻辑:2025年1月起,男性每4个月延迟1个月,女性每2个月延迟1个月
+ */
+ public List<EmpBaseInfo> findRetirementAlertList(EmpBaseInfo empBaseInfo) {
+ // 1. 计算目标时间范围
+ LocalDate[] dateRange = calculateDateRange(empBaseInfo.getTimeRange());
+ LocalDate startDate = dateRange[0];
+ LocalDate endDate = dateRange[1];
- if (StringUtils.isNotBlank(empBaseInfo.getSex())) {
- queryWrapper.in("a.sex", empBaseInfo.getSex());
+ // 2. 动态计算粗略出生日期范围
+ // 最早出生:男性60岁+最大延迟3年+余量 = startDate - 63年 - 6个月
+ LocalDate roughBirthStart = startDate.minusYears(63).minusMonths(6);
+
+ // 最晚出生:女性50岁退休(最早退休)- 余量 = endDate - 50年 + 6个月
+ // 解释:如果出生日期是 1975-01-01,女性法定退休是 2025-01-01,可能延迟几个月
+ // 所以最晚出生日期应该比 endDate 早约 50年,再留点余量
+ LocalDate roughBirthEnd = endDate.minusYears(50).plusYears(3); // 50岁+可能延迟3年
+
+ // 3. 查询所有在职、未提醒的员工(动态粗略筛选)
+ QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("DelFlag", 0)
+ .eq("empStatus", "0")
+ .eq("retirementReminded", 0)
+ .ge("birthdate", roughBirthStart)
+ .le("birthdate", roughBirthEnd);
+
+ List<EmpBaseInfo> allList = this.baseMapper.selectList(queryWrapper);
+
+ // 3. 逐个计算实际退休时间,筛选在范围内的
+ return allList.stream()
+ .filter(emp -> {
+ LocalDate actualRetirement = calculateActualRetirement(emp);
+ return actualRetirement != null
+ && !actualRetirement.isBefore(startDate)
+ && actualRetirement.isBefore(endDate);
+ })
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * 计算员工的实际退休时间(正向计算)
+ * 方案A:法定退休时间早于2025-01时,按法定年龄退休,不延迟
+ */
+ private LocalDate calculateActualRetirement(EmpBaseInfo emp) {
+ if (emp.getBirthdate() == null || emp.getSex() == null) {
+ return null;
}
- String targetYearMonthForMan = DateUtil.format(DateUtil.offsetMonth(new Date(), -60 * 12), "yyyy-MM");
- String targetYearMonthForWoman = DateUtil.format(DateUtil.offsetMonth(new Date(), -50 * 12), "yyyy-MM");
+ LocalDate birthDate = emp.getBirthdate().toInstant()
+ .atZone(java.time.ZoneId.systemDefault())
+ .toLocalDate();
- // 查询条件:
- // 1. 男性:出生年月 <= 60 年前的本月(即当月或之前满 60 岁)
- // 2. 女性:出生年月 <= 50 年前的本月(即当月或之前满 50 岁)
- // 3. 未处理退休提醒
- queryWrapper.and(wrapper -> wrapper
- .nested(inner -> inner
- .eq("a.sex", "1") // sex = '1' (男)
- .le("DATE_FORMAT(a.birthdate, '%Y-%m')", targetYearMonthForMan) // 生日在当前月份
- ).or().nested(inner -> inner
- .eq("a.sex", "2") // sex = '2' (女)
- .le("DATE_FORMAT(a.birthdate, '%Y-%m')", targetYearMonthForWoman) // 生日在当前月份
- )
- );
+ // 法定退休年龄
+ int legalAge = "1".equals(emp.getSex()) ? 60 : 50;
+ // 延迟除数
+ int delayDivisor = "1".equals(emp.getSex()) ? 4 : 2;
- return queryWrapper;
+ // 法定退休时间
+ LocalDate legalRetirement = birthDate.plusYears(legalAge);
+
+ // 方案A:法定退休时间早于2025-01,按法定年龄退休
+ LocalDate delayStart = LocalDate.of(2025, 1, 1);
+ if (legalRetirement.isBefore(delayStart)) {
+ return legalRetirement;
+ }
+
+ // 法定退休时间晚于等于2025-01,计算延迟
+ long monthsBetween = ChronoUnit.MONTHS.between(delayStart, legalRetirement);
+ long delayMonths = (monthsBetween / delayDivisor) + 1;
+
+ return legalRetirement.plusMonths(delayMonths);
+ }
+
+ /**
+ * 根据时间范围类型计算开始和结束日期
+ *
+ * @param timeRange 0-当天 1-本周 2-本月 3-今年
+ * @return 包含开始日期和结束日期的数组 [startDate, endDate)
+ */
+ private LocalDate[] calculateDateRange(Integer timeRange) {
+ if (timeRange == null) {
+ timeRange = 2;
+ }
+
+ LocalDate now = LocalDate.now();
+ LocalDate startDate;
+ LocalDate endDate;
+
+ switch (timeRange) {
+ case 0: // 当天
+ startDate = now;
+ endDate = now.plusDays(1);
+ break;
+ case 1: // 本周(周一为开始)
+ startDate = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+ endDate = startDate.plusWeeks(1);
+ break;
+ case 2: // 本月
+ startDate = now.withDayOfMonth(1);
+ endDate = startDate.plusMonths(1);
+ break;
+ case 3: // 今年
+ startDate = now.withDayOfYear(1);
+ endDate = startDate.plusYears(1);
+ break;
+ default:
+ startDate = now.withDayOfMonth(1);
+ endDate = startDate.plusMonths(1);
+ }
+
+ return new LocalDate[]{startDate, endDate};
}
private QueryWrapper<EmpBaseInfo> createProbationAlertQueryWrapper(EmpBaseInfo empBaseInfo) {
@@ -1722,14 +2139,12 @@
queryWrapper.eq("a.DelFlag", 0)
.eq("a.empStatus", "0");
- // 获取当前月份第一天和下月第一天
- LocalDate now = LocalDate.now();
- LocalDate startOfMonth = now.withDayOfMonth(1);
- LocalDate startOfNextMonth = startOfMonth.plusMonths(1);
+ // 计算时间范围
+ LocalDate[] dateRange = calculateDateRange(empBaseInfo.getTimeRange());
- // 转正日期在当月范围内:[当月第一天, 下月第一天)
- queryWrapper.ge("a.probationDate", startOfMonth)
- .lt("a.probationDate", startOfNextMonth);
+ // 转正日期范围条件
+ queryWrapper.ge("a.probationDate", dateRange[0])
+ .lt("a.probationDate", dateRange[1]);
// 转正状态条件:查询状态为 0 或 3 的员工
queryWrapper.in("a.probationStatus", "0", "3");
--
Gitblit v1.8.0