Эх сурвалжийг харах

fix(perf): 修复绩效排名管理中的数据查询和验证问题

- 修正入职日期常量注释错误
- 添加全职任职类型和工作性质相关常量
- 修复职级计算服务中积分验证逻辑,处理空值情况
- 移除未使用的导入包和枚举
- 添加
wyc 7 цаг өмнө
parent
commit
d7e9ed093f

+ 11 - 1
code/base/nckd-jxccl-base-common/src/main/java/nckd/jxccl/base/common/constant/FormConstant.java

@@ -310,7 +310,7 @@ public class FormConstant {
     public static final String EMPLOYEE_KEY = "employee";
     /**职级序列*/
     public static final String JOBLEVELSEQ = "joblevelseq";
-    /**职级序列*/
+    /**入职日期*/
     public static final String ENTRYDATE = "entrydate";
     /**当前数据*/
     public static final String ISCURRENTDATA = "iscurrentdata";
@@ -440,4 +440,14 @@ public class FormConstant {
     /** 岗位工资标准(jt002)*/
     public static final Long STANDARDITEM_ID_KEY = 2321899710350111744L;
 
+    /** 全职任职类型编码 */
+    public static final String FULLSERVICE_NUMBER = "1010_S";
+
+    /** 工作性质 */
+    public static final String NCKD_HBSS_WORKNATURE = "nckd_hbss_worknature";
+    /** 工作性质大类 */
+    public static final String NCKD_JOBTJOBTYPMAIN = "nckd_jobtjobtypmain";
+    /** 工作性质大类离岗编码 */
+    public static final String NCKD_JOBTJOBTYPMAIN_LEAVE_NUMBER = "05";
+
 }

+ 2 - 3
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/business/JobLevelCalculatorService.java

@@ -1984,9 +1984,8 @@ public class JobLevelCalculatorService {
             logger.warn("无考核结果");
             isEligibleForJobLevel = Boolean.FALSE;
         }
-        if(score.compareTo(new BigDecimal(18)) < 0) {
-            //积分数小于18
-            logger.warn("积分数小于18: {}", score);
+        if(score == null || score.compareTo(BigDecimal.ZERO) <= 0) {
+            logger.warn("积分为空或小于0");
             isEligibleForJobLevel = Boolean.FALSE;
         }
 

+ 70 - 19
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/form/performance/PerfRankMgmtFormPlugin.java

@@ -10,9 +10,6 @@ import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.dataentity.metadata.IDataEntityProperty;
 import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
-import kd.bos.dataentity.serialization.DataEntitySerializer;
-import kd.bos.dataentity.serialization.DataEntitySerializerOption;
-import kd.bos.dtx.util.DynamicObjectSerializeUtil;
 import kd.bos.entity.EntityMetadataCache;
 import kd.bos.entity.MainEntityType;
 import kd.bos.entity.QueryEntityType;
@@ -28,7 +25,6 @@ import kd.bos.entity.filter.CompareTypeEnum;
 import kd.bos.entity.filter.FilterValue;
 import kd.bos.entity.filter.SimpleFilterRow;
 import kd.bos.entity.operate.result.OperationResult;
-import kd.bos.entity.property.entryfilter.EntryQueryParam;
 import kd.bos.form.ConfirmCallBackListener;
 import kd.bos.form.ConfirmTypes;
 import kd.bos.form.IClientViewProxy;
@@ -36,7 +32,6 @@ import kd.bos.form.IPageCache;
 import kd.bos.form.MessageBoxOptions;
 import kd.bos.form.MessageBoxResult;
 import kd.bos.form.container.Wizard;
-import kd.bos.form.control.Control;
 import kd.bos.form.control.EntryGrid;
 import kd.bos.form.control.Steps;
 import kd.bos.form.control.events.StepEvent;
@@ -52,17 +47,14 @@ import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
 import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.QueryServiceHelper;
-import kd.hdtc.hrcc.common.enums.FileImportSubTaskDealStatusEnum;
 import kd.hr.hbp.business.servicehelper.HRQueryEntityHelper;
 import nckd.jxccl.base.common.constant.FormConstant;
-import nckd.jxccl.base.common.constant.QueryConstant;
 import nckd.jxccl.base.common.enums.AppraisalResultEnum;
 import nckd.jxccl.base.common.enums.psms.JobSeqEnum;
 import nckd.jxccl.base.common.utils.ConvertUtil;
 import nckd.jxccl.base.common.utils.DateUtil;
 import nckd.jxccl.base.common.utils.QueryFieldBuilder;
 import nckd.jxccl.base.common.utils.StrFormatter;
-import nckd.jxccl.base.hrpi.helper.EmpPosOrgRelHelper;
 import nckd.jxccl.base.orm.helper.QFilterCommonHelper;
 import nckd.jxccl.hr.psms.common.PerfRankMgmtConstant;
 import nckd.jxccl.hr.psms.common.PositionStructureConstant;
@@ -288,6 +280,13 @@ public class PerfRankMgmtFormPlugin extends AbstractFormPlugin implements Wizard
                 args.setCancel(true);
                 return;
             }
+            int theYear = ConvertUtil.toInt(this.getModel().getValue(PerfRankMgmtConstant.NCKD_THEYEAR));
+            if(theYear <= 0){
+                this.getView().showTipNotification("请先填写“年份”");
+                args.setCancel(true);
+                return;
+            }
+
             RefObject<String> afterConfirm = new RefObject<>();
             if (!operate.getOption().tryGetVariableValue("afterConfirm", afterConfirm)) {
                 //判断是否已获取过名单,如获取过再获取提示用户数据会丢失
@@ -471,26 +470,36 @@ public class PerfRankMgmtFormPlugin extends AbstractFormPlugin implements Wizard
             }else{*/
                 IDataModel model = this.getModel();
                 DynamicObject adminOrg = ConvertUtil.toDynamicObjectOrNull(model.getValue(FormConstant.NCKD_ADMINORG));
+                int theYear = ConvertUtil.toInt(model.getValue(PerfRankMgmtConstant.NCKD_THEYEAR));
                 if(adminOrg != null) {
+                    Date targetDate = DateUtil.toDate(LocalDateTime.of(theYear, 12, 31, 23, 59, 59));
                     String structLongNumber = adminOrg.getString(FormConstant.STRUCTLONGNUMBER);
                     //查询所选组织下的人员
-                    QFilter qFilter = new QFilter(String.join(".", FormConstant.HRPI_EMPPOSORGREL, FormConstant.ADMINORG, FormConstant.STRUCTLONGNUMBER), QCP.like, structLongNumber + "%");
+                    //任职状态为在岗,且任职经历的任职类型为全职任职的人员((不含工作性质大类为离岗))
+                    QFilter qFilter = new QFilter(String.join(".",FormConstant.ADMINORG, FormConstant.STRUCTLONGNUMBER), QCP.like, structLongNumber + "%")
+                            .and(FormConstant.STARTDATE, QCP.less_equals, targetDate)
+                            .and(FormConstant.ENDDATE, QCP.large_equals, targetDate);
+
                     //在职人员
                     qFilter.and(String.join(".", FormConstant.HRPI_EMPENTREL, FormConstant.LABOR_REL_STATUS, FormConstant.IS_HIRED), QCP.equals, EnableEnum.YES.getCode());
                     QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
-                            .addGroup(new String[]{FormConstant.HRPI_EMPPOSORGREL}, FormConstant.ID_KEY)
+                            .add(FormConstant.ID_KEY)
+                            .add(FormConstant.STARTDATE)
                             //用工关系状态.编码(1005_S	在职-试用中、1010_S	在职、1020_S	离职、1030_S	已退休),istrial:是否试用,ishired:是否在职
                             .addGroup(new String[]{FormConstant.HRPI_EMPENTREL, FormConstant.LABOR_REL_STATUS}, FormConstant.NUMBER_KEY, FormConstant.NAME_KEY, FormConstant.IS_TRIAL, FormConstant.IS_HIRED)
                             //任职状态分类(1010_S:在岗,1030_S:不在岗)
-                            .addGroup(new String[]{FormConstant.HRPI_EMPPOSORGREL, FormConstant.POS_STATUS, FormConstant.POST_STATE_CLS}, FormConstant.NUMBER_KEY)
+                            .addIdNumberName(FormConstant.POS_STATUS, FormConstant.POST_STATE_CLS)
                             //入职日期
                             .addGroup(new String[]{FormConstant.HRPI_EMPENTREL}, FormConstant.ENTRYDATE)
                             //职务级别
                             .addGroup(new String[]{FormConstant.NCKD_HRPI_PARTYPOSH, FormConstant.NCKD_POSGRADE}, FormConstant.NAME_KEY, FormConstant.NUMBER_KEY, FormConstant.NCKD_SORTNUM)
-                            .addGroup(new String[]{FormConstant.EMPLOYEE_KEY}, FormConstant.ID_KEY, FormConstant.NAME_KEY, FormConstant.EMP_NUMBER_KEY);
+                            .addGroup(new String[]{FormConstant.EMPLOYEE_KEY}, FormConstant.ID_KEY, FormConstant.NAME_KEY, FormConstant.EMP_NUMBER_KEY)
+                            //工作性质大类
+                            .addIdNumberName(FormConstant.NCKD_HBSS_WORKNATURE,FormConstant.NCKD_JOBTJOBTYPMAIN)
+                            .orderDesc(FormConstant.STARTDATE);
 
                     // -------------------------------- 1、查询组织下的在职人员 --------------------------------
-                    QueryEntityType queryEntityType = (QueryEntityType) EntityMetadataCache.getDataEntityType(QueryConstant.PERSON_QUERY);
+                    QueryEntityType queryEntityType = (QueryEntityType) EntityMetadataCache.getDataEntityType("personfilequery");
                     DynamicObjectCollection personList = HRQueryEntityHelper.getInstance().getQueryDyoColl(queryEntityType, queryFieldBuilder.buildSelect(), new QFilter[]{qFilter}, queryFieldBuilder.buildOrder());
                     //添加分录
                     DynamicObjectCollection entryEntityCols = this.getModel().getDataEntity(true).getDynamicObjectCollection(PerfRankMgmtConstant.NCKD_PERFRANKMGMTENTRY);
@@ -503,6 +512,22 @@ public class PerfRankMgmtFormPlugin extends AbstractFormPlugin implements Wizard
                     List<Long> personIds = personList.stream()
                             .map(person -> person.getLong(String.join(".", FormConstant.EMPLOYEE_KEY, FormConstant.ID_KEY)))
                             .collect(Collectors.toList());
+                    //按员工ID分组,并只取开始日期最新的任职记录
+                    Map<Long, DynamicObject> groupedByEmployee = personList.stream()
+                            .collect(Collectors.groupingBy(
+                                    person -> person.getLong(String.join(".", FormConstant.EMPLOYEE_KEY, FormConstant.ID_KEY)),
+                                    Collectors.collectingAndThen(
+                                            Collectors.maxBy((p1, p2) -> {
+                                                Date date1 = p1.getDate(FormConstant.STARTDATE);
+                                                Date date2 = p2.getDate(FormConstant.STARTDATE);
+                                                if (date1 == null && date2 == null) return 0;
+                                                if (date1 == null) return -1;
+                                                if (date2 == null) return 1;
+                                                return date2.compareTo(date1); // 降序,取最新的
+                                            }),
+                                            optional -> optional.orElse(null)
+                                    )
+                            ));
                     if (!personIds.isEmpty()) {
                         Date now = new Date();
                         // -------------------------------- 3、获取人员是否享受职位津贴 --------------------------------
@@ -511,22 +536,35 @@ public class PerfRankMgmtFormPlugin extends AbstractFormPlugin implements Wizard
                         // -------------------------------- 4、加载数据到分录 --------------------------------
                         //预加载任职经历
                         List<Long> ids = personList.stream()
-                                .map(person -> person.getLong(String.join(".", FormConstant.HRPI_EMPPOSORGREL, FormConstant.ID_KEY)))
+                                .map(person -> person.getLong(FormConstant.ID_KEY))
                                 .collect(Collectors.toList());
-                        Map<Long, DynamicObject> empPosOrgRelByEmployeesMap = EmpPosOrgRelHelper.queryEmpPosOrgRelByEmployeesMap(personIds);
+                        MainEntityType empOrgRelEntityType = EntityMetadataCache.getDataEntityType(FormConstant.HRPI_EMPPOSORGREL);
+                        DynamicObject[] empOrgRelArray = BusinessDataServiceHelper.load(ids.toArray(), empOrgRelEntityType);
+                        Map<Long, DynamicObject> empOrgRelMap = Arrays.stream(empOrgRelArray)
+                                .collect(Collectors.toMap(
+                                        obj -> obj.getLong(FormConstant.ID_KEY),
+                                        obj -> obj,
+                                        (existing, replacement) -> existing
+                                ));
                         Set<Long> addedPersonIds = new HashSet<>();
-                        for (DynamicObject person : personList) {
+                        for (Map.Entry<Long, DynamicObject> personEntry : groupedByEmployee.entrySet()) {
+                            DynamicObject person = personEntry.getValue();
+                            long id = person.getLong(FormConstant.ID_KEY);
                             long personId = person.getLong(String.join(".", FormConstant.EMPLOYEE_KEY, FormConstant.ID_KEY));
                             // 检查人员是否已经添加过,如果已存在则跳过
                             if (addedPersonIds.contains(personId)) {
                                 continue;
                             }
+                            DynamicObject empPosOrgRel = empOrgRelMap.get(id);
+                            if(empPosOrgRel == null){
+                                continue;
+                            }
                             DynamicObject entryCol = entryEntityCols.addNew();
                             addedPersonIds.add(personId); // 记录已添加的人员ID
                             String personName = person.getString(String.join(".", FormConstant.EMPLOYEE_KEY, FormConstant.NAME_KEY));
                             String personNumber = person.getString(String.join(".", FormConstant.EMPLOYEE_KEY, FormConstant.EMP_NUMBER_KEY));
 
-                            DynamicObject empPosOrgRel = empPosOrgRelByEmployeesMap.get(personId);
+
                             entryCol.set(FormConstant.NCKD_DEP, empPosOrgRel.get(FormConstant.ADMINORG));
                             entryCol.set(PositionStructureConstant.NCKD_POSITIONHR, empPosOrgRel.get(FormConstant.POSITION_KEY));
 
@@ -559,10 +597,23 @@ public class PerfRankMgmtFormPlugin extends AbstractFormPlugin implements Wizard
                             //判断是否有职位津贴
                             boolean hasAllowance = entitledToAllowance.get(personId);
                             entryCol.set(PerfRankMgmtConstant.NCKD_POSTALLOWANCE, hasAllowance);
-
                         }
-//                        this.getModel().updateEntryCache(entryEntityCols);
+
+                        this.getModel().updateEntryCache(entryEntityCols);
                         this.getView().updateView(PerfRankMgmtConstant.NCKD_PERFRANKMGMTENTRY);
+
+                        /*for (int i = 0; i < entryEntityCols.size(); i++) {
+                            Boolean isRanking = ConvertUtil.toBoolean(this.getModel().getValue(PerfRankMgmtConstant.NCKD_ISRANKING, i));
+                            if(isRanking){
+                                this.getModel().setValue(PerfRankMgmtConstant.NCKD_ISRANKING, Boolean.FALSE,i);
+                            }else{
+                                this.getModel().setValue(PerfRankMgmtConstant.NCKD_ISRANKING, Boolean.TRUE,i);
+                            }
+                            this.getModel().setValue(PerfRankMgmtConstant.NCKD_ISRANKING, isRanking,i);
+                            this.getView().updateView(PerfRankMgmtConstant.NCKD_ISRANKING,i);
+
+                        }*/
+
                         this.getView().showSuccessNotification("名单获取完成");
                     } else {
                         this.getView().showTipNotification("未获取到人员");