fix: 修复部门错误数据导致的异常

This commit is contained in:
liangcheng 2025-08-28 14:10:33 +08:00
parent 3d104ac67a
commit 4ee7f30197
1 changed files with 18 additions and 6 deletions

View File

@ -19,8 +19,10 @@ import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.TimeZone;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/**
* @Author liang.cheng
@ -29,6 +31,7 @@ import java.util.stream.Collectors;
* @Version 1.0
*/
@Component
@Slf4j
public class EbTableMonitorBO {
@Autowired
@ -45,18 +48,27 @@ public class EbTableMonitorBO {
EmployeePO employeePO = selectEmployee();
return hrKpiFlows.stream()
.filter(Objects::nonNull)
.map(hrKpiFlow -> {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
String formattedDate = hrKpiFlow.getRealPeriod() != null
? sdf.format(hrKpiFlow.getRealPeriod())
: null;
WeaDepartMent weaDepartMent = departMentService.getDepartMentById(hrKpiFlow.getDepartmentId());
String deptPath = departMentService.getDeptPath(hrKpiFlow.getDepartmentId(), WeaDeptPathLevel.DEPT_ALL_LEVEL, ">", employeePO.getTenantKey());
if (StringUtils.isNotBlank(deptPath)) {
deptPath = deptPath + ">" + weaDepartMent.getDepartMentName();
} else {
deptPath = weaDepartMent.getDepartMentName();
Long departmentId = hrKpiFlow.getDepartmentId();
WeaDepartMent weaDepartMent = departMentService.getDepartMentById(departmentId);
String deptPath = "";
try {
deptPath = departMentService.getDeptPath(departmentId, WeaDeptPathLevel.DEPT_ALL_LEVEL, ">", employeePO.getTenantKey());
if (StringUtils.isNotBlank(deptPath)) {
deptPath = deptPath + ">" + weaDepartMent.getDepartMentName();
} else {
deptPath = weaDepartMent.getDepartMentName();
}
}catch (Exception e) {
log.error("处理 hrKpiFlow ID: {} 时发生异常: {}",
hrKpiFlow.getId(), e.getMessage(), e);
return null;
}
return EbTableMonitorPO.builder()