Parcourir la source

feat(opmc): 新增多级组织加载插件并优化绩效管理校验逻辑

- 新增 LoadMultiOrgByEmpPosOrgRelListPlugin 插件,用于根据任职经历加载多级组织信息
- 优化 AnnualPerfDetailReportListDataPlugin 查询条件构造逻辑
- 在 PerfManagerSaveOpPlugin 中增加数据迁移标识判断,避免迁移数据触发校验
- 调整绩效周期重叠校验逻辑,排除数据迁移场景
- 完善列表数据查询时的组织信息缓存处理
- 优化包导入语句,统一使用通配符导入相关工具类
wyc il y a 1 semaine
Parent
commit
8580fde47a

+ 101 - 0
code/base/nckd-jxccl-base-common/src/main/java/nckd/jxccl/base/common/plugins/LoadMultiOrgByEmpPosOrgRelListPlugin.java

@@ -0,0 +1,101 @@
+package nckd.jxccl.base.common.plugins;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.entity.datamodel.events.PackageDataEvent;
+import kd.bos.form.IPageCache;
+import kd.bos.form.events.BeforeCreateListDataProviderArgs;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.bos.mvc.list.ListDataProvider;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.QueryServiceHelper;
+import kd.sdk.plugin.Plugin;
+import nckd.jxccl.base.common.constant.FormConstant;
+import nckd.jxccl.base.common.utils.QueryFieldBuilder;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * 根据任职经历加载多级组织通用插件
+ * 实体有任职经历需要在列表显示出1~6级组织
+ * 列表需要有动态字段:nckd_firstorg、nckd_secondorg、nckd_thirdorg、nckd_fourthorg、nckd_fifthorg、nckd_sixthorg
+ * @author W.Y.C
+ * @date 2025/11/4 13:07
+ * @version 1.0
+ */
+public class LoadMultiOrgByEmpPosOrgRelListPlugin extends AbstractListPlugin implements Plugin {
+
+    Map<Long, DynamicObject> map = null;
+    @Override
+    public void packageData(PackageDataEvent e) {
+        if(!adminOrgIds.isEmpty() && map == null) {
+            QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
+                    .add(FormConstant.ID_KEY)
+                    .addIdNumberName(FormConstant.NCKD_FIRSTORG)
+                    .addIdNumberName(FormConstant.NCKD_SECONDORG)
+                    .addIdNumberName(FormConstant.NCKD_THIRDORG)
+                    .addIdNumberName(FormConstant.NCKD_FOURTHORG)
+                    .addIdNumberName(FormConstant.NCKD_FIFTHORG)
+                    .addIdNumberName(FormConstant.NCKD_SIXTHORG);
+            QFilter qFilter = new QFilter(FormConstant.ID_KEY, QCP.in, adminOrgIds);
+            DynamicObjectCollection adminOrgColl = QueryServiceHelper.query(FormConstant.ADMINORGHR_ENTITYID, queryFieldBuilder.buildSelect(), new QFilter[]{qFilter});
+            map = adminOrgColl.stream()
+                    .collect(Collectors.toMap(
+                            obj -> obj.getLong(FormConstant.ID_KEY),
+                            obj -> obj
+                    ));
+        }
+        if(map != null) {
+            String colKey = e.getColKey();
+            if (e.getRowData().containsProperty(FormConstant.NCKD_EMPPOSORGREL)) {
+                DynamicObject adminOrg = e.getRowData().getDynamicObject(FormConstant.NCKD_EMPPOSORGREL).getDynamicObject(FormConstant.ADMINORG);
+                if (adminOrg != null) {
+                    DynamicObject org = map.get(adminOrg.getLong(FormConstant.ID_KEY));
+                    if (FormConstant.NCKD_FIRSTORG.equalsIgnoreCase(colKey)) {
+                        e.setFormatValue(org.getString(String.join(".", FormConstant.NCKD_FIRSTORG, FormConstant.NAME_KEY)));
+                    } else if (FormConstant.NCKD_SECONDORG.equalsIgnoreCase(colKey)) {
+                        e.setFormatValue(org.getString(String.join(".", FormConstant.NCKD_SECONDORG, FormConstant.NAME_KEY)));
+                    } else if (FormConstant.NCKD_THIRDORG.equalsIgnoreCase(colKey)) {
+                        e.setFormatValue(org.getString(String.join(".", FormConstant.NCKD_THIRDORG, FormConstant.NAME_KEY)));
+                    } else if (FormConstant.NCKD_FOURTHORG.equalsIgnoreCase(colKey)) {
+                        e.setFormatValue(org.getString(String.join(".", FormConstant.NCKD_FOURTHORG, FormConstant.NAME_KEY)));
+                    } else if (FormConstant.NCKD_FIFTHORG.equalsIgnoreCase(colKey)) {
+                        e.setFormatValue(org.getString(String.join(".", FormConstant.NCKD_FIFTHORG, FormConstant.NAME_KEY)));
+                    } else if (FormConstant.NCKD_SIXTHORG.equalsIgnoreCase(colKey)) {
+                        e.setFormatValue(org.getString(String.join(".", FormConstant.NCKD_SIXTHORG, FormConstant.NAME_KEY)));
+                    }
+                }
+            }
+        }
+
+
+    }
+
+    Set<Long> adminOrgIds = new HashSet<>();
+    @Override
+    public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
+        args.setListDataProvider(new ListDataProvider() {
+            @Override
+            public DynamicObjectCollection getData(int start, int size) {
+                DynamicObjectCollection rows = super.getData(start, size);
+                IPageCache pageCache = getView().getPageCache();
+                for (DynamicObject row : rows) {
+                    if(row.containsProperty(FormConstant.NCKD_EMPPOSORGREL)){
+                        DynamicObject empPosOrgRel = row.getDynamicObject(FormConstant.NCKD_EMPPOSORGREL);
+                        if(empPosOrgRel != null){
+                            DynamicObject adminOrg = empPosOrgRel.getDynamicObject(FormConstant.ADMINORG);
+                            if(adminOrg != null) {
+                                adminOrgIds.add(adminOrg.getLong(FormConstant.ID_KEY));
+                            }
+                        }
+                    }
+                }
+                return rows;
+            }
+        });
+    }
+}

+ 1 - 61
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/cycle/PerfManagerListPlugin.java

@@ -36,10 +36,7 @@ import nckd.jxccl.base.common.utils.QueryFieldBuilder;
 import nckd.jxccl.base.entity.helper.EntityHelper;
 import nckd.jxccl.opmc.pm.common.PerfManagerFormConstant;
 
-import java.util.EventObject;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -65,63 +62,6 @@ public class PerfManagerListPlugin extends AbstractListPlugin implements Plugin
         }
     }
 
-
-    @Override
-    public void packageData(PackageDataEvent e) {
-        if(!adminOrgIds.isEmpty()){
-            QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
-                    .addIdNumberName(FormConstant.NCKD_FIRSTORG)
-                    .addIdNumberName(FormConstant.NCKD_SECONDORG)
-                    .addIdNumberName(FormConstant.NCKD_THIRDORG)
-                    .addIdNumberName(FormConstant.NCKD_FOURTHORG)
-                    .addIdNumberName(FormConstant.NCKD_FIFTHORG)
-                    .addIdNumberName(FormConstant.NCKD_SIXTHORG);
-            QFilter qFilter = new QFilter(FormConstant.ID_KEY, QCP.in, adminOrgIds);
-            DynamicObject dynamicObject = QueryServiceHelper.queryOne(FormConstant.ADMINORGHR_ENTITYID, queryFieldBuilder.buildSelect(), new QFilter[]{qFilter});
-            String colKey = e.getColKey();
-            int year = DateUtil.now().getYear();
-
-            if (FormConstant.NCKD_FIRSTORG.equalsIgnoreCase(colKey)) {
-                e.setFormatValue(dynamicObject.getString(String.join(".", FormConstant.NCKD_FIRSTORG, FormConstant.NAME_KEY)));
-            } else if (FormConstant.NCKD_SECONDORG.equalsIgnoreCase(colKey)) {
-                e.setFormatValue(dynamicObject.getString(String.join(".", FormConstant.NCKD_SECONDORG, FormConstant.NAME_KEY)));
-            } else if (FormConstant.NCKD_THIRDORG.equalsIgnoreCase(colKey)) {
-                e.setFormatValue(dynamicObject.getString(String.join(".", FormConstant.NCKD_THIRDORG, FormConstant.NAME_KEY)));
-            } else if (FormConstant.NCKD_FOURTHORG.equalsIgnoreCase(colKey)) {
-                e.setFormatValue(dynamicObject.getString(String.join(".", FormConstant.NCKD_FOURTHORG, FormConstant.NAME_KEY)));
-            } else if (FormConstant.NCKD_FIFTHORG.equalsIgnoreCase(colKey)) {
-                e.setFormatValue(dynamicObject.getString(String.join(".", FormConstant.NCKD_FIFTHORG, FormConstant.NAME_KEY)));
-            } else if (FormConstant.NCKD_SIXTHORG.equalsIgnoreCase(colKey)) {
-                e.setFormatValue(dynamicObject.getString(String.join(".", FormConstant.NCKD_SIXTHORG, FormConstant.NAME_KEY)));
-            }
-        }
-
-    }
-
-    Set<Long> adminOrgIds = new HashSet<>();
-    @Override
-    public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
-        args.setListDataProvider(new ListDataProvider() {
-            @Override
-            public DynamicObjectCollection getData(int start, int size) {
-                DynamicObjectCollection rows = super.getData(start, size);
-                IPageCache pageCache = getView().getPageCache();
-                for (DynamicObject row : rows) {
-                    if(row.containsProperty(FormConstant.NCKD_EMPPOSORGREL)){
-                        DynamicObject empPosOrgRel = row.getDynamicObject(FormConstant.NCKD_EMPPOSORGREL);
-                        if(empPosOrgRel != null){
-                            DynamicObject adminOrg = empPosOrgRel.getDynamicObject(FormConstant.ADMINORG);
-                            if(adminOrg != null) {
-                                adminOrgIds.add(adminOrg.getLong(FormConstant.ID_KEY));
-                            }
-                        }
-                    }
-                }
-                return rows;
-            }
-        });
-    }
-
     @Override
     public void beforeDoOperation(BeforeDoOperationEventArgs args) {
         String operateKey = ((FormOperate) args.getSource()).getOperateKey();

+ 3 - 2
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/result/AnnualPerfDetailReportListDataPlugin.java

@@ -42,8 +42,8 @@ public class AnnualPerfDetailReportListDataPlugin extends AbstractReportListData
         int currentYear = LocalDate.now().getYear() - 1; // 不包含今年
         Date endDate = DateUtil.toDate(LocalDate.of(currentYear, 1, 1));
         //查询最近5年的数据
-        QFilter qFilter = new QFilter(String.join(".", PerfManagerFormConstant.PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALYEAR), QCP.large_equals, beginDate);
-        qFilter.and(String.join(".", PerfManagerFormConstant.PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALYEAR), QCP.less_equals, endDate);
+        QFilter qFilter = new QFilter(PerfManagerFormConstant.NCKD_BEGINYEAR, QCP.less_equals, endDate)
+                .and(new QFilter(PerfManagerFormConstant.NCKD_ENDYEAR, QCP.large_equals, beginDate));
 
         // 处理快速过滤条件
         processFastFilter(reportQueryParam, qFilter);
@@ -134,6 +134,7 @@ public class AnnualPerfDetailReportListDataPlugin extends AbstractReportListData
                 .addGroup(new String[]{PerfManagerFormConstant.PERFMANAGERENTRY},PerfManagerFormConstant.NCKD_APPRAISALRESULT)
                 .addIdNumberName(PerfManagerFormConstant.PERFMANAGERENTRY,PerfManagerFormConstant.NCKD_APPRAISALRESULT)
                 .addGroup(new String[]{PerfManagerFormConstant.PERFMANAGERENTRY},PerfManagerFormConstant.NCKD_APPRAISALYEAR)
+                .addGroup(new String[]{PerfManagerFormConstant.PERFMANAGERENTRY},PerfManagerFormConstant.ID_KEY)
                 .addGroup(new String[]{FormConstant.NCKD_EMPPOSORGREL,FormConstant.EMPLOYEE_KEY}, FormConstant.EMP_NUMBER_KEY, FormConstant.NAME_KEY)
                 .addIdNumberName(FormConstant.HRPI_EMPPOSORGREL,FormConstant.POS_STATUS)
                 .addIdNumberName(FormConstant.HRPI_EMPPOSORGREL,FormConstant.ADMINORG,FormConstant.NCKD_FIRSTORG)

+ 39 - 33
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/operate/cycle/PerfManagerSaveOpPlugin.java

@@ -54,6 +54,8 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
 
     @Override
     public void onAddValidators(AddValidatorsEventArgs e) {
+        String invoker = (String)this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
+        boolean dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker);
         e.addValidator(new AbstractValidator() {
             @Override
             public void validate() {
@@ -87,33 +89,35 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
 
                     currentBatchData.computeIfAbsent(personId, k -> new ArrayList<>()).add(perfInfo);
                 }
-                if(!isCycleGenerate) {
-                    //检查同一批次内同一人员的周期重叠
-                    for (Map.Entry<Long, List<PersonPerfInfo>> entry : currentBatchData.entrySet()) {
-                        List<PersonPerfInfo> personPerfList = entry.getValue();
-                        if (personPerfList.size() > 1) {
-                            // 对同一人员的多个周期进行相互比较
-                            for (int i = 0; i < personPerfList.size(); i++) {
-                                PersonPerfInfo info1 = personPerfList.get(i);
-                                for (int j = i + 1; j < personPerfList.size(); j++) {
-                                    PersonPerfInfo info2 = personPerfList.get(j);
-                                    String personName = info2.getPerson().getString(FormConstant.NAME_KEY);
-
-                                    // 检查开始年份是否相同
-                                    if (isSameYear(info1.getBeginYear(), info2.getBeginYear())) {
-                                        addFatalErrorMessage(getDataEntities()[info1.getDataEntityIndex()],
-                                                StrFormatter.format("同批次数据中,人员【{}】存在相同的周期开始年份:{}",
-                                                        personName, info1.getBeginYear().getYear()));
-                                    } else {
-                                        // 只有开始年份不相同时才检查重叠
-                                        // 检查周期是否重叠
-                                        String overlapInfo = getCycleOverlapInfo(
-                                                info1.getBeginYear(), info1.getEndYear(), null,
-                                                info2.getBeginYear(), info2.getEndYear(), null);
-
-                                        if (StringUtils.isNotBlank(overlapInfo)) {
+                if(!dataMigration) {
+                    if (!isCycleGenerate) {
+                        //检查同一批次内同一人员的周期重叠
+                        for (Map.Entry<Long, List<PersonPerfInfo>> entry : currentBatchData.entrySet()) {
+                            List<PersonPerfInfo> personPerfList = entry.getValue();
+                            if (personPerfList.size() > 1) {
+                                // 对同一人员的多个周期进行相互比较
+                                for (int i = 0; i < personPerfList.size(); i++) {
+                                    PersonPerfInfo info1 = personPerfList.get(i);
+                                    for (int j = i + 1; j < personPerfList.size(); j++) {
+                                        PersonPerfInfo info2 = personPerfList.get(j);
+                                        String personName = info2.getPerson().getString(FormConstant.NAME_KEY);
+
+                                        // 检查开始年份是否相同
+                                        if (isSameYear(info1.getBeginYear(), info2.getBeginYear())) {
                                             addFatalErrorMessage(getDataEntities()[info1.getDataEntityIndex()],
-                                                    StrFormatter.format("同批次数据中,人员【{}】存在重叠周期:{}", personName, overlapInfo));
+                                                    StrFormatter.format("同批次数据中,人员【{}】存在相同的周期开始年份:{}",
+                                                            personName, info1.getBeginYear().getYear()));
+                                        } else {
+                                            // 只有开始年份不相同时才检查重叠
+                                            // 检查周期是否重叠
+                                            String overlapInfo = getCycleOverlapInfo(
+                                                    info1.getBeginYear(), info1.getEndYear(), null,
+                                                    info2.getBeginYear(), info2.getEndYear(), null);
+
+                                            if (StringUtils.isNotBlank(overlapInfo)) {
+                                                addFatalErrorMessage(getDataEntities()[info1.getDataEntityIndex()],
+                                                        StrFormatter.format("同批次数据中,人员【{}】存在重叠周期:{}", personName, overlapInfo));
+                                            }
                                         }
                                     }
                                 }
@@ -166,13 +170,15 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
                         Date actEndYear = dynamicObject.getDate(PerfManagerFormConstant.NCKD_ACTENDYEAR);
                         LocalDateTime dbActEndYear = actEndYear != null ? DateUtil.toLocalDateTime(actEndYear) : null;
 
-                        if(!isCycleGenerate) {
-                            // 判断周期是否重叠并获取重叠信息,已结束周期使用实际结束时间
-                            String overlapInfo = getCycleOverlapInfo(beginYear, endYear, null, dbBeginYear, dbEndYear, dbActEndYear);
-                            if (StringUtils.isNotBlank(overlapInfo)) {
-                                addFatalErrorMessage(rowDataEntity,
-                                        StrFormatter.format("人员【{}】的考核周期与已有周期在{}重叠,请检查!",
-                                                personName, overlapInfo));
+                        if(!dataMigration) {
+                            if (!isCycleGenerate) {
+                                // 判断周期是否重叠并获取重叠信息,已结束周期使用实际结束时间
+                                String overlapInfo = getCycleOverlapInfo(beginYear, endYear, null, dbBeginYear, dbEndYear, dbActEndYear);
+                                if (StringUtils.isNotBlank(overlapInfo)) {
+                                    addFatalErrorMessage(rowDataEntity,
+                                            StrFormatter.format("人员【{}】的考核周期与已有周期在{}重叠,请检查!",
+                                                    personName, overlapInfo));
+                                }
                             }
                         }