Преглед изворни кода

feat(wtc): 优化关键岗位休假校验逻辑

- 修复序号递增问题,确保消息列表正确显示
- 调整组织范围关键岗位获取逻辑,提升准确性
- 新增获取岗位直接下级关键岗位方法
- 优化员工主职与兼职岗位查询逻辑
- 移除冗余的组织层级查询操作
Tyx пре 6 дана
родитељ
комит
a707257f06

+ 13 - 1
code/base/nckd-jxccl-base-helper/src/main/java/nckd/jxccl/base/wtc/helper/WTCHelper.java

@@ -191,11 +191,23 @@ public class WTCHelper {
         QFilter filter = new QFilter("iscurrentdata", QCP.equals, "1"); // 启用
         filter.and(new QFilter("employee.id", QCP.in, employeeId));
 
-        String selectFields1 = "adminorg.id";
+        String selectFields1 = "adminorg.id, position.id";
         DynamicObjectCollection empposorgreDyns = QueryServiceHelper.query("hrpi_empposorgrel", selectFields1, filter.toArray());
 
         return empposorgreDyns;
     }
 
+    /**
+     * 获取岗位直接下级的关键岗位
+     * @param positionIds
+     * @return
+     */
+    public static List<Long> getSubKeyPositions(List<Long> positionIds) {
+        QFilter filter = new QFilter ("parent.id", QCP.in, positionIds);
+        filter.and("nckd_iskeypos", QCP.equals, "1");
+        DynamicObjectCollection subPositionDyns = QueryServiceHelper.query("hbpm_positionhr", "id", filter.toArray());
+        return subPositionDyns.stream().map(dyn -> dyn.getLong("id")).collect(Collectors.toList());
+    }
+
 
 }

+ 8 - 11
code/wtc/nckd-jxccl-wtc/src/main/java/nckd/jxccl/wtc/wtabm/web/validate/VaApplyCheckValidator.java

@@ -50,6 +50,7 @@ public class VaApplyCheckValidator extends AbstractValidator {
                         String endDateStr = WtcUtils.dateToStr(applyBill.getDate("enddate"), "yyyy-MM-dd");
                         String msg = String.format(i + "、【%s】-【%s】-【%s】-【%s】-【%s】-【%s】", billNo, empName, orgName, posName, startDateStr, endDateStr);
                         msgList.add(msg);
+                        i++;
                     }
                     String titleMsg = "以下单据存在其他关键岗位人员正在休假:\n ";
                     String errorMsg = titleMsg + String.join("\n ", msgList);
@@ -85,23 +86,19 @@ public class VaApplyCheckValidator extends AbstractValidator {
                     allOrgIds.add(role.getLong("roleentry.org.id"));
                 }
             }
+            // 获取组织范围内的关键岗位
+            positionIds.addAll(WTCHelper.getKeyPositionByOrg(allOrgIds));
         }
         // 根据直接上级判断
+        // 2025-12-12 查找当前用户的主职和兼职下的所有关键岗位
         else if ("checkbypar".equals(operateKey)) {
             // 获取当前用户对应的employeeId
             Long employeeId = WTCHelper.queryEmployeeIdByUserId(userId);
-            // 获取员工当前的行政组织
+            // 获取员工当前的主职/兼职岗位
             DynamicObjectCollection empPosOrgRelDyns = WTCHelper.queryEmpPosOrgRelDyns(Arrays.asList(employeeId));
-            List<Long> orgIds = new ArrayList<Long>();
-            orgIds.addAll(empPosOrgRelDyns.stream().map(i -> i.getLong("adminorg.id")).collect(Collectors.toList()));
-            List<Map<String, Object>> subOrgMap = HAOSServiceHelper.querySubOrgToList(orgIds, new Date(), null);
-            allOrgIds.addAll(subOrgMap.stream().map(i -> Long.valueOf(i.get("orgId").toString())).collect(Collectors.toList()));
+            List<Long> empPositionIds = empPosOrgRelDyns.stream().map(i -> i.getLong("position.id")).collect(Collectors.toList());
+            // 添加下级岗级关键岗位
+            positionIds.addAll(WTCHelper.getSubKeyPositions(empPositionIds));
         }
-
-        // 获取组织范围内的关键岗位
-        positionIds.addAll(WTCHelper.getKeyPositionByOrg(allOrgIds));
-
     }
-
-
 }