|
|
@@ -2,6 +2,7 @@ package com.sundot.airport.ledger.service.impl;
|
|
2
|
2
|
|
|
3
|
3
|
import com.sundot.airport.common.core.domain.entity.SysDept;
|
|
4
|
4
|
import com.sundot.airport.common.core.domain.entity.SysUser;
|
|
|
5
|
+import com.sundot.airport.common.enums.DeptTypeEnum;
|
|
5
|
6
|
import com.sundot.airport.common.enums.ScoreLevelEnum;
|
|
6
|
7
|
import com.sundot.airport.ledger.domain.LedgerExamScore;
|
|
7
|
8
|
import com.sundot.airport.ledger.domain.ScoreDimension;
|
|
|
@@ -206,6 +207,7 @@ public class EmployeePortraitServiceImpl implements IEmployeePortraitService {
|
|
206
|
207
|
vo.setSecurityInspectionPosition(user.getSecurityInspectionPosition());
|
|
207
|
208
|
vo.setUserTags(user.getTags());
|
|
208
|
209
|
|
|
|
210
|
+
|
|
209
|
211
|
// 司龄、工龄、开机年限
|
|
210
|
212
|
long nowMs = System.currentTimeMillis();
|
|
211
|
213
|
if (user.getStartWorkingDate() != null) {
|
|
|
@@ -251,15 +253,45 @@ public class EmployeePortraitServiceImpl implements IEmployeePortraitService {
|
|
251
|
253
|
// 部门路径
|
|
252
|
254
|
if (user.getDept() != null) {
|
|
253
|
255
|
String deptName = user.getDept().getDeptName();
|
|
254
|
|
- String parentDeptName = "";
|
|
255
|
|
- Long parentId = user.getDept().getParentId();
|
|
256
|
|
- if (parentId != null && parentId > 0) {
|
|
257
|
|
- SysDept parent = sysDeptMapper.selectDeptById(parentId);
|
|
258
|
|
- if (parent != null) parentDeptName = parent.getDeptName();
|
|
|
256
|
+ //根据名称查询部门
|
|
|
257
|
+ SysDept dept = sysDeptMapper.selectDeptById(user.getDept().getDeptId());
|
|
|
258
|
+ // 祖先ID批量查询
|
|
|
259
|
+ List<Long> ancestorIds = new ArrayList<>();
|
|
|
260
|
+ if (dept.getAncestors() != null) {
|
|
|
261
|
+ for (String id : dept.getAncestors().split(",")) {
|
|
|
262
|
+ Long deptId = Long.parseLong(id.trim());
|
|
|
263
|
+ if (deptId > 0) ancestorIds.add(deptId);
|
|
|
264
|
+ }
|
|
|
265
|
+ }
|
|
|
266
|
+
|
|
|
267
|
+ // 一次查询所有祖先部门
|
|
|
268
|
+ Map<Long, SysDept> deptMap = ancestorIds.isEmpty() ? new HashMap<>()
|
|
|
269
|
+ : sysDeptMapper.selectDeptByIdList(ancestorIds).stream()
|
|
|
270
|
+ .collect(Collectors.toMap(SysDept::getDeptId, d -> d));
|
|
|
271
|
+
|
|
|
272
|
+ // 构建路径(从BRIGADE到当前部门)
|
|
|
273
|
+ List<String> path = new ArrayList<>();
|
|
|
274
|
+ String currentDeptType = dept.getDeptType();
|
|
|
275
|
+ if (!DeptTypeEnum.MANAGER.getCode().equals(currentDeptType) && !DeptTypeEnum.TEAMS.getCode().equals(currentDeptType)) {
|
|
|
276
|
+ path.add(deptName);
|
|
|
277
|
+ } else {
|
|
|
278
|
+ // 从BRIGADE级别开始构建路径
|
|
|
279
|
+ for (Long id : ancestorIds) {
|
|
|
280
|
+ SysDept d = deptMap.get(id);
|
|
|
281
|
+ if (d != null) {
|
|
|
282
|
+ if (DeptTypeEnum.BRIGADE.getCode().equals(d.getDeptType())) path.clear();
|
|
|
283
|
+ path.add(d.getDeptName());
|
|
|
284
|
+ }
|
|
|
285
|
+ }
|
|
|
286
|
+ path.add(deptName);
|
|
259
|
287
|
}
|
|
|
288
|
+
|
|
260
|
289
|
vo.setDeptName(deptName);
|
|
261
|
|
- vo.setParentDeptName(parentDeptName);
|
|
262
|
|
- vo.setDeptPath(parentDeptName.isEmpty() ? deptName : parentDeptName + "/" + deptName);
|
|
|
290
|
+ vo.setParentDeptName(ancestorIds.isEmpty() ? "" :
|
|
|
291
|
+ Optional.ofNullable(deptMap.get(dept.getParentId()))
|
|
|
292
|
+ .orElseGet(() -> sysDeptMapper.selectDeptById(dept.getParentId()))
|
|
|
293
|
+ .getDeptName());
|
|
|
294
|
+ vo.setDeptPath(String.join("/", path));
|
|
263
|
295
|
}
|
|
264
|
296
|
}
|
|
265
|
297
|
|
|
|
@@ -507,4 +539,4 @@ public class EmployeePortraitServiceImpl implements IEmployeePortraitService {
|
|
507
|
539
|
});
|
|
508
|
540
|
return result;
|
|
509
|
541
|
}
|
|
510
|
|
-}
|
|
|
542
|
+}
|