时点花名册查询逻辑优化

This commit is contained in:
Administrator 2025-06-10 14:00:05 +08:00
parent 24baccf2ae
commit f5b7b162ad
1 changed files with 52 additions and 25 deletions

View File

@ -848,15 +848,10 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
/**
* 查询离职记录表是否为空
*/
boolean b = checkIsNotEmpty(ebTableName, stratDate, endDate);
if(b){
//boolean b = checkIsNotEmpty(ebTableName, stratDate, endDate);
//不存在
List<Map<String, Object>> employeeInformation = queryEmployeeInformationInfo(employee_informationName, stratDate, endDate,subCompany,department);
log.error("getRosterInfoByDateRange.employeeInformation:{}", employeeInformation);
if(employeeInformation.size()>0){
resultList.addAll(employeeInformation);
}
}else {
//存在
//先按日期关联查询出员工信息
List<Map<String, Object>> resignationInfo = queryResignationInfo(employee_informationName, ebTableName, stratDate, endDate,subCompany,department);
@ -873,10 +868,25 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
.map(Optional::get)
.collect(Collectors.toList());
log.error("getRosterInfoByDateRange.resignationInfoNew:{}", resignationInfoNew);
if(employeeInformation.size()>0){
if(resignationInfoNew.size()>0){
resultList.addAll(resignationInfoNew);
/**
* 先处理一下退休记录
*/
// 1. 收集 listB 中的所有 ID
Set<Object> idsInB = resignationInfoNew.stream()
.map(map -> map.get("id")) // 假设 ID 的键是 "id"
.collect(Collectors.toSet());
log.error("getRosterInfoByDateRange.idsInB:{}", idsInB);
// 2. listA 中移除所有 ID 存在于 listB 中的元素
employeeInformation.removeIf(map -> idsInB.contains(map.get("id")));
// 3. listB 中的所有元素添加到 listA
employeeInformation.addAll(resignationInfoNew);
log.error("getRosterInfoByDateRange.employeeInformation:{}", employeeInformation);
}
resultList.addAll(employeeInformation);
}
//}
/**
* 多租户查询主表名称
*/
@ -886,15 +896,10 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
/**
* 查询退休记录表是否为空
*/
boolean b1 = checkIsNotEmpty(ebTableTxName, stratDate, endDate);
if(b1){
//boolean b1 = checkIsNotEmpty(ebTableTxName, stratDate, endDate);
//不存在
List<Map<String, Object>> employeeInformationTx = queryEmployeeInformationInfo(employee_informationName, stratDate, endDate,subCompany,department);
log.error("getRosterInfoByDateRange.employeeInformationTx:{}", employeeInformationTx);
if(employeeInformationTx.size()>0){
resultList.addAll(employeeInformationTx);
}
}else {
//存在
//先按日期关联查询出员工信息
List<Map<String, Object>> retirementInfo = queryResignationInfo(employee_informationName, ebTableTxName, stratDate, endDate,subCompany,department);
@ -910,11 +915,24 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
.map(Optional::get)
.collect(Collectors.toList());
log.error("getRosterInfoByDateRange.retirementInfoNew:{}", retirementInfoNew);
if(employeeInformationTx.size()>0){
if(retirementInfoNew.size()>0){
resultList.addAll(retirementInfoNew);
/**
* 先处理一下退休记录
*/
// 1. 收集 listB 中的所有 ID
Set<Object> idsInB = retirementInfoNew.stream()
.map(map -> map.get("id")) // 假设 ID 的键是 "id"
.collect(Collectors.toSet());
log.error("getRosterInfoByDateRange2222.idsInB:{}", idsInB);
// 2. listA 中移除所有 ID 存在于 listB 中的元素
employeeInformationTx.removeIf(map -> idsInB.contains(map.get("id")));
// 3. listB 中的所有元素添加到 listA
employeeInformationTx.addAll(retirementInfoNew);
log.error("getRosterInfoByDateRange2222.employeeInformationTx:{}", employeeInformationTx);
}
resultList.addAll(employeeInformationTx);
}
/**
* 多租户查询主表名称
*/
@ -924,15 +942,10 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
/**
* 查询调动记录表是否为空
*/
boolean b2 = checkIsNotEmptyForDd(ebTableDdName, endDate);
if(b2){
//boolean b2 = checkIsNotEmptyForDd(ebTableDdName, endDate);
//不存在
List<Map<String, Object>> employeeInformationDd = queryEmployeeInformationInfo(employee_informationName, stratDate, endDate,subCompany,department);
log.error("getRosterInfoByDateRange.employeeInformationDd:{}", employeeInformationDd);
if(employeeInformationDd.size()>0){
resultList.addAll(employeeInformationDd);
}
}else {
//存在
//先按日期关联查询出员工信息
List<Map<String, Object>> transferInfo = queryTransferInfo(employee_informationName, ebTableDdName, endDate,subCompany,department);
@ -949,10 +962,24 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
.map(Optional::get)
.collect(Collectors.toList());
log.error("getRosterInfoByDateRange.transferInfoNew:{}", transferInfoNew);
if(transferInfoNew.size()>0){
resultList.addAll(transferInfoNew);
if(employeeInformationDd.size()>0){
if(transferInfoNew.size()>0){
/**
* 先处理一下调动记录
*/
// 1. 收集 listB 中的所有 ID
Set<Object> idsInB = transferInfoNew.stream()
.map(map -> map.get("id")) // 假设 ID 的键是 "id"
.collect(Collectors.toSet());
log.error("getRosterInfoByDateRange3333.idsInB:{}", idsInB);
// 2. listA 中移除所有 ID 存在于 listB 中的元素
employeeInformationDd.removeIf(map -> idsInB.contains(map.get("id")));
// 3. listB 中的所有元素添加到 listA
employeeInformationDd.addAll(transferInfoNew);
log.error("getRosterInfoByDateRange3333.employeeInformationDd:{}", employeeInformationDd);
}
resultList.addAll(employeeInformationDd);
}
}
convertHireDatesRobust(resultList);
/**
* 相关id转化为名称
@ -995,7 +1022,7 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
" b.yglxmc,c.name subcompanyName,d.name departmentName,e.name positionName,f.username superiorName from " + tableName+ "" +
" a left join uf_jcl_yglx b on a.yglx = b.id left join eteams.department c on a.subcompany = c.id " +
" left join eteams.department d on a.department = d.id left join eteams.position e on a.position = e.id " +
" left join eteams.employee f on a.id = f.id where a.zhgzr is null and a.hiredate <= '" + endDate + "' and a.delete_type = 0 " ;
" left join eteams.employee f on a.superior = f.id where a.zhgzr is null and a.hiredate <= '" + endDate + "' and a.delete_type = 0 " ;
String str = " union all select a.id,a.username,a.hiredate,a.mobile,a.email,a.job_num,a.yglx,a.subcompany,a.department,a.position,a.superior," +
" b.yglxmc,c.name subcompanyName,d.name departmentName,e.name positionName,f.username superiorName from " + tableName+ "" +