Browse Source

feat(hr): 优化职位档案保存逻辑并增强日志记录

- 引入OperateOption和OperationResult以增强保存操作的控制与结果处理
- 添加详细的日志记录,覆盖数据提取、积分计算、职级确定等关键步骤
- 在保存失败时抛出自定义ValidationException并聚合错误信息
- 移除旧的保存方式注释,统一使用saveOperate方法进行实体保存
- 增强异常处理机制,确保操作失败时能够准确反馈错误原因
- 补充对空值情况的日志输出,提升调试与问题追踪能力
wyc 1 hour ago
parent
commit
f751b270a1

File diff suppressed because it is too large
+ 342 - 49
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/business/JobLevelCalculatorService.java


+ 16 - 1
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/adjust/NewDynamicAdjustmentOperationPlugIn.java

@@ -2,11 +2,15 @@ package nckd.jxccl.hr.psms.plugin.operate.adjust;
 
 import kd.bos.common.enums.EnableEnum;
 import kd.bos.context.RequestContext;
+import kd.bos.dataentity.OperateOption;
 import kd.bos.dataentity.entity.CloneUtils;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.utils.ObjectUtils;
 import kd.bos.entity.ExtendedDataEntity;
 import kd.bos.entity.constant.StatusEnum;
+import kd.bos.entity.operate.result.IOperateInfo;
+import kd.bos.entity.operate.result.OperationResult;
 import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 import kd.bos.entity.plugin.AddValidatorsEventArgs;
 import kd.bos.entity.plugin.args.BeforeOperationArgs;
@@ -175,7 +179,18 @@ public class NewDynamicAdjustmentOperationPlugIn extends AbstractOperationServic
 
         }
 
-        SaveServiceHelper.save(newPersonPosFiles.toArray(new DynamicObject[0]));
+//        SaveServiceHelper.save(newPersonPosFiles.toArray(new DynamicObject[0]));
+        OperationResult operationResult = SaveServiceHelper.saveOperate(PositionStructureConstant.PERSONPOSFILE_ENTITYID, newPersonPosFiles.toArray(new DynamicObject[0]), OperateOption.create());
+        if (!operationResult.isSuccess()) {
+            StringJoiner errorMsg = new StringJoiner("\n");
+            for (IOperateInfo error : operationResult.getAllErrorOrValidateInfo()) {
+                errorMsg.add(error.getMessage());
+            }
+            if (!ObjectUtils.isEmpty(operationResult.getMessage())) {
+                errorMsg.add(operationResult.getMessage());
+            }
+            throw new ValidationException("保存职位档案失败,原因:" + errorMsg.toString());
+        }
         PositionFileHelper.markAsNotCurrentNewest(personIds.toArray(new Long[0]));
         PositionFileHelper.markAsCurrentNewest(null,personIds.toArray(new Long[0]));
 

+ 18 - 1
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/annualadjust/AnnualAdjustmentOperationPlugin.java

@@ -1,9 +1,13 @@
 package nckd.jxccl.hr.psms.plugin.operate.annualadjust;
 
 import kd.bos.common.enums.EnableEnum;
+import kd.bos.dataentity.OperateOption;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.utils.ObjectUtils;
 import kd.bos.entity.ExtendedDataEntity;
+import kd.bos.entity.operate.result.IOperateInfo;
+import kd.bos.entity.operate.result.OperationResult;
 import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 import kd.bos.entity.plugin.AddValidatorsEventArgs;
 import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
@@ -16,6 +20,7 @@ import kd.bos.servicehelper.operation.SaveServiceHelper;
 import kd.sdk.plugin.Plugin;
 import nckd.jxccl.base.common.constant.FormConstant;
 import nckd.jxccl.base.common.enums.psms.AdjustTypeEnum;
+import nckd.jxccl.base.common.exception.ValidationException;
 import nckd.jxccl.base.common.utils.DateUtil;
 import nckd.jxccl.base.common.utils.StrFormatter;
 import nckd.jxccl.base.pm.helper.PerformanceManagerHelper;
@@ -33,6 +38,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.StringJoiner;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -176,7 +182,18 @@ public class AnnualAdjustmentOperationPlugin extends AbstractOperationServicePlu
             }
         }
 
-        SaveServiceHelper.save(newPersonPosFiles.toArray(new DynamicObject[0]));
+//        SaveServiceHelper.save(newPersonPosFiles.toArray(new DynamicObject[0]));
+        OperationResult operationResult = SaveServiceHelper.saveOperate(PositionStructureConstant.PERSONPOSFILE_ENTITYID, newPersonPosFiles.toArray(new DynamicObject[0]), OperateOption.create());
+        if (!operationResult.isSuccess()) {
+            StringJoiner errorMsg = new StringJoiner("\n");
+            for (IOperateInfo error : operationResult.getAllErrorOrValidateInfo()) {
+                errorMsg.add(error.getMessage());
+            }
+            if (!ObjectUtils.isEmpty(operationResult.getMessage())) {
+                errorMsg.add(operationResult.getMessage());
+            }
+            throw new ValidationException("保存职位档案失败,原因:" + errorMsg.toString());
+        }
         PositionFileHelper.markAsNotCurrentNewest(personIds.toArray(new Long[0]));
         PositionFileHelper.markAsCurrentNewest(null,personIds.toArray(new Long[0]));
         for (DynamicObject newPersonPosFile : newPersonPosFiles) {

+ 1 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/annualadjust/AnnualLockOrUnLockedOpPlugin.java

@@ -149,6 +149,7 @@ public class AnnualLockOrUnLockedOpPlugin extends AbstractOperationServicePlugIn
                 for (DynamicObject dynamicObject : load) {
                     DynamicObject entryObj = new DynamicObject(entryType);
                     entryObj.set(PositionStructureConstant.NCKD_PERSONPOSFILE, dynamicObject);
+                    entryObj.set(PositionStructureConstant.NCKD_ORG, dynamicObject.getDynamicObject(FormConstant.NCKD_DEP).getDynamicObject(FormConstant.BELONGCOMPANY_KEY));
                     entryColl.add(entryObj);
                 }
                 //提交单据

+ 85 - 10
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/initial/BaseInitialOperationPlugIn.java

@@ -3,9 +3,13 @@ package nckd.jxccl.hr.psms.plugin.operate.initial;
 import com.google.common.collect.Lists;
 import kd.bos.common.enums.EnableEnum;
 import kd.bos.context.RequestContext;
+import kd.bos.dataentity.OperateOption;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.utils.ObjectUtils;
 import kd.bos.entity.constant.StatusEnum;
+import kd.bos.entity.operate.result.IOperateInfo;
+import kd.bos.entity.operate.result.OperationResult;
 import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 import kd.bos.logging.Log;
 import kd.bos.logging.LogFactory;
@@ -15,6 +19,7 @@ import kd.bos.servicehelper.operation.SaveServiceHelper;
 import nckd.jxccl.base.common.constant.FormConstant;
 import nckd.jxccl.base.common.enums.AppraisalResultEnum;
 import nckd.jxccl.base.common.enums.psms.JobSeqEnum;
+import nckd.jxccl.base.common.exception.ValidationException;
 import nckd.jxccl.base.common.utils.DateUtil;
 import nckd.jxccl.base.common.utils.QueryFieldBuilder;
 import nckd.jxccl.base.common.utils.StrFormatter;
@@ -32,6 +37,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.StringJoiner;
 
 /**
  * 人员初定操作插件基类
@@ -118,75 +124,101 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
      * @date: 2025/10/12 14:20
      */
     protected List<BaseInitialData> extractBasicInfo(DynamicObject initialData) {
+        logger.info("【职位体系】-开始提取基本信息");
         List<BaseInitialData> dataList = new ArrayList<>();
         if(initialData.containsProperty(FormConstant.NCKD_ENTRYENTITY)){
             DynamicObjectCollection dynamicObjectCollection = initialData.getDynamicObjectCollection(FormConstant.NCKD_ENTRYENTITY);
-            for (DynamicObject dynamicObject : dynamicObjectCollection) {
+            logger.info("【职位体系】-检测到批量初定数据,条数: {}", dynamicObjectCollection.size());
+            for (int i = 0; i < dynamicObjectCollection.size(); i++) {
+                DynamicObject dynamicObject = dynamicObjectCollection.get(i);
+                logger.info("【职位体系】-处理第 {} 条数据", i+1);
                 //批量初定
                 BaseInitialData data = getBaseInitialData(dynamicObject);
                 dataList.add(data);
                 baseInitialData.add(data);
             }
         }else{
+            logger.info("【职位体系】-处理单条初定数据");
             BaseInitialData data = getBaseInitialData(initialData);
             dataList.add(data);
             baseInitialData.add(data);
         }
+        logger.info("【职位体系】-基本信息提取完成,共提取 {} 条数据", dataList.size());
         return dataList;
     }
 
     @NotNull
     private BaseInitialData getBaseInitialData(DynamicObject initialData) {
         BaseInitialData data = new BaseInitialData();
+        logger.info("【职位体系】-开始获取基础数据");
 
         data.beginDate = initialData.getDate(PositionStructureConstant.NCKD_BEGINDATE);
         data.causeRemark = initialData.getString(PositionStructureConstant.KEY_NCKD_CAUSEREMARK);
         data.person = initialData.getDynamicObject(PositionStructureConstant.NCKD_PERSON);
 
         PositionAppointmentBO positionAppointment = PositionFileHelper.positionAppointmentQuery(data.person.getLong(FormConstant.ID_KEY), data.beginDate);
+        logger.info("【职位体系】-获取人员任职信息完成,personId={}", data.person.getLong(FormConstant.ID_KEY));
+        
         // 学历
         DynamicObject perEduExp = positionAppointment.getPerEduExp();
         if (perEduExp != null) {
             // 学历
             long diplomaId = perEduExp.getLong(String.join(".", FormConstant.EDUCATION_KEY, FormConstant.ID_KEY));
+            logger.info("【职位体系】-获取学历信息,diplomaId={}", diplomaId);
             if(diplomaId > 0) {
                 DynamicObject diploma = BusinessDataServiceHelper.newDynamicObject(PositionStructureConstant.HBSS_DIPLOMA);
                 diploma.set(FormConstant.ID_KEY, diplomaId);
                 data.diploma = diploma;
             }
+        } else {
+            logger.info("【职位体系】-无学历信息");
         }
+        
         // 职称信息
         DynamicObject perProTitle = positionAppointment.getPerProTitle();
         if (perProTitle != null) {
             data.rankName = perProTitle.getString(String.join(".", FormConstant.PROFESSIONAL_KEY, FormConstant.NAME_KEY));
+            logger.info("【职位体系】-获取职称信息,rankName={}", data.rankName);
+            
             // 职称等级
             long perProTitleId = perProTitle.getLong(String.join(".", FormConstant.PROLEVEL_KEY, FormConstant.ID_KEY));
+            logger.info("【职位体系】-获取职称等级,perProTitleId={}", perProTitleId);
             if(perProTitleId > 0) {
                 DynamicObject proTitleLevel = BusinessDataServiceHelper.newDynamicObject(PositionStructureConstant.HBSS_PROTITLELEVEL);
                 proTitleLevel.set(FormConstant.ID_KEY, perProTitleId);
                 data.proTitleLevel = proTitleLevel;
             }
+        } else {
+            logger.info("【职位体系】-无职称信息");
         }
 
         // 技能信息
         DynamicObject perOcpQual = positionAppointment.getPerOcpQual();
         if (perOcpQual != null) {
             data.jobStatusName = perOcpQual.getString(String.join(".", FormConstant.QUALIFICATION_KEY, FormConstant.NAME_KEY));
+            logger.info("【职位体系】-获取技能信息,jobStatusName={}", data.jobStatusName);
+            
             // 技能等级
             long quaLevelId = perOcpQual.getLong(String.join(".", FormConstant.QUALEVEL_KEY, FormConstant.ID_KEY));
+            logger.info("【职位体系】-获取技能等级,quaLevelId={}", quaLevelId);
             if(quaLevelId > 0) {
                 DynamicObject ocpQualLevel = BusinessDataServiceHelper.newDynamicObject(PositionStructureConstant.HBSS_OCPQUALLEVEL);
                 ocpQualLevel.set(FormConstant.ID_KEY, quaLevelId);
                 data.ocpQualLevel = ocpQualLevel;
             }
-
+        } else {
+            logger.info("【职位体系】-无技能信息");
         }
+        
         // 任职信息
         DynamicObject empPosOrgRel = positionAppointment.getEmpPosOrgRel();
         if (empPosOrgRel != null) {
             data.empPosOrgRel = empPosOrgRel;
+            logger.info("【职位体系】-获取任职信息完成");
+            
             //岗位
             long positionId = empPosOrgRel.getLong(String.join(".", FormConstant.POSITION_KEY, FormConstant.ID_KEY));
+            logger.info("【职位体系】-获取岗位信息,positionId={}", positionId);
             if(positionId > 0) {
                 DynamicObject position = BusinessDataServiceHelper.newDynamicObject(FormConstant.HBPM_POSITIONHR);
                 position.set(FormConstant.ID_KEY, positionId);
@@ -195,12 +227,15 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
             }
 
             long companyId = empPosOrgRel.getLong(String.join(".", FormConstant.COMPANY_KEY, FormConstant.ID_KEY));
+            logger.info("【职位体系】-获取公司信息,companyId={}", companyId);
             if(companyId > 0) {
                 DynamicObject company = BusinessDataServiceHelper.newDynamicObject(FormConstant.ADMINORG_ENTITYID);
                 company.set(FormConstant.ID_KEY, companyId);
                 data.company = company;
             }
+            
             long adminOrgId = empPosOrgRel.getLong(String.join(".", FormConstant.ADMINORG, FormConstant.ID_KEY));
+            logger.info("【职位体系】-获取部门信息,adminOrgId={}", adminOrgId);
             if(adminOrgId > 0) {
                 DynamicObject dep = BusinessDataServiceHelper.newDynamicObject(FormConstant.ADMINORG_ENTITYID);
                 dep.set(FormConstant.ID_KEY, adminOrgId);
@@ -209,6 +244,7 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
 
             // 职位序列
             Long jobSeqId = empPosOrgRel.getLong(String.join(".", FormConstant.HBPM_POSITIONHR, FormConstant.NCKD_JOBSEQ, FormConstant.ID_KEY));
+            logger.info("【职位体系】-获取职位序列信息,jobSeqId={}", jobSeqId);
             if(jobSeqId > 0) {
                 String jobSeqNumber = empPosOrgRel.getString(String.join(".", FormConstant.HBPM_POSITIONHR, FormConstant.NCKD_JOBSEQ, FormConstant.NUMBER_KEY));
                 String jobSeqName = empPosOrgRel.getString(String.join(".", FormConstant.HBPM_POSITIONHR, FormConstant.NCKD_JOBSEQ, FormConstant.NAME_KEY));
@@ -220,20 +256,25 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
                 data.jobSeqNumber = jobSeqNumber;
                 data.jobSeqName = jobSeqName;
                 data.jobSeqEnum = JobSeqEnum.getByCode(data.jobSeqNumber);
+                logger.info("【职位体系】-职位序列编号={},名称={}", jobSeqNumber, jobSeqName);
             }
 
-
-
             //本次加入集团时间
             data.joinComDate = empPosOrgRel.getDate(String.join(".", FormConstant.HRPI_PERSERLEN, FormConstant.JOINCOMDATE_KEY));
+            logger.info("【职位体系】-本次加入集团时间={}", data.joinComDate);
+        } else {
+            logger.info("【职位体系】-无任职信息");
         }
 
         data.isExcellent = Boolean.FALSE;
         if(positionAppointment.getExcellent() != null && positionAppointment.getExcellent()){
             data.isExcellent = Boolean.TRUE;
+            logger.info("【职位体系】-该员工为优秀生");
         }
+        
         // 特定字段由子类处理
         extractSpecificFields(data, initialData);
+        logger.info("【职位体系】-基础数据获取完成");
         return data;
     }
 
@@ -275,6 +316,7 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
      * 获取积分数据
      */
     protected ScoreData getScoreData(BaseInitialData data, String logPrefix) {
+        logger.info("{}-开始获取积分数据", logPrefix);
         ScoreData scoreData = new ScoreData();
 
         QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create().addIdNumberNameWithExtras(FormConstant.NCKD_SCORE);
@@ -282,6 +324,7 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
         // 学历积分
         scoreData.educationScore = BigDecimal.ZERO;
         if (data.diploma != null) {
+            logger.info("{}-开始获取学历积分,diplomaId={}", logPrefix, data.diploma.getLong(FormConstant.ID_KEY));
             DynamicObject education = BusinessDataServiceHelper.loadSingle(FormConstant.HBSS_DIPLOMA,
                     queryFieldBuilder.buildSelect(),
                     new QFilter[]{QFilterCommonHelper.getIdEqFilter(data.diploma.getLong(FormConstant.ID_KEY))});
@@ -302,30 +345,41 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
         scoreData.dbProTitleLevel = null;
         scoreData.dbOcpQualLevel = null;
 
-
+        logger.info("{}-职位序列类型={}, proTitleLevel={}, ocpQualLevel={}", 
+                   logPrefix, data.jobSeqEnum, data.proTitleLevel, data.ocpQualLevel);
 
         if (data.jobSeqEnum != JobSeqEnum.SKILL && data.proTitleLevel != null) {
             // 非技能序列获取职称积分
+            logger.info("{}-开始获取职称积分", logPrefix);
             scoreData.dbProTitleLevel = BusinessDataServiceHelper.loadSingle(FormConstant.HBSS_PROTITLELEVEL,
                     queryFieldBuilder.buildSelect(),
                     new QFilter[]{QFilterCommonHelper.getIdEqFilter(data.proTitleLevel.getLong(FormConstant.ID_KEY))});
             if (scoreData.dbProTitleLevel != null) {
                 scoreData.proTitleScore = scoreData.dbProTitleLevel.getBigDecimal(FormConstant.NCKD_SCORE);
                 data.jobStatusName = null;
+                logger.info("{}-职称积分获取完成,积分为{}", logPrefix, scoreData.proTitleScore);
+            } else {
+                logger.warn("{}-未找到职称等级信息", logPrefix);
             }
         } else if (data.jobSeqEnum == JobSeqEnum.SKILL && data.ocpQualLevel != null) {
             // 技能序列获取技能积分
+            logger.info("{}-开始获取技能积分", logPrefix);
             scoreData.dbOcpQualLevel = BusinessDataServiceHelper.loadSingle(FormConstant.HBSS_OCPQUALLEVEL,
                     queryFieldBuilder.buildSelect(),
                     new QFilter[]{QFilterCommonHelper.getIdEqFilter(data.ocpQualLevel.getLong(FormConstant.ID_KEY))});
             if (scoreData.dbOcpQualLevel != null) {
                 scoreData.perOcpQualScore = scoreData.dbOcpQualLevel.getBigDecimal(FormConstant.NCKD_SCORE);
                 data.rankName = null;
+                logger.info("{}-技能积分获取完成,积分为{}", logPrefix, scoreData.perOcpQualScore);
+            } else {
+                logger.warn("{}-未找到技能等级信息", logPrefix);
             }
+        } else {
+            logger.info("{}-无需获取职称或技能积分", logPrefix);
         }
 
-        logger.info("{}-初定职位序列【{}】-职称积分【{}】-技能积分【{}】",
-                logPrefix, data.jobSeqName, scoreData.proTitleScore, scoreData.perOcpQualScore);
+        logger.info("{}-初定职位序列【{}】-学历积分【{}】-职称积分【{}】-技能积分【{}】",
+                logPrefix, data.jobSeqName, scoreData.educationScore, scoreData.proTitleScore, scoreData.perOcpQualScore);
 
         return scoreData;
     }
@@ -355,12 +409,15 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
     protected DynamicObject createAndSavePersonPosFile(BaseInitialData data, ScoreData scoreData,
                                              BigDecimal allSumScore, BigDecimal sumScore, 
                                              DynamicObject jobLeve, String logPrefix, String typeState) {
+        logger.info("{}-开始创建并保存职位档案", logPrefix);
         // 优秀生得2分
         BigDecimal excellentScore = data.isExcellent ? new BigDecimal(2) : BigDecimal.ZERO;
+        logger.info("{}-优秀生分数: {}", logPrefix, excellentScore);
 
         // 构建职位档案并存入数据库
         DynamicObject personPosFile = BusinessDataServiceHelper.newDynamicObject(
                 PositionStructureConstant.PERSONPOSFILE_ENTITYID);
+        logger.info("{}-创建职位档案对象完成", logPrefix);
 
         personPosFile.set(PositionStructureConstant.NCKD_PERSON, data.person);
         personPosFile.set(PositionStructureConstant.NCKD_FIRSTRANK, EnableEnum.YES.getCode());
@@ -380,18 +437,24 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
         personPosFile.set(PositionStructureConstant.NCKD_DEP, data.dep);
         personPosFile.set(PositionStructureConstant.NCKD_ALLSUMSCORE, allSumScore);
         personPosFile.set(PositionStructureConstant.NCKD_SUMSCORE, sumScore);
+        logger.info("{}-设置基本字段完成,总积分={}, 累计积分={}", logPrefix, allSumScore, sumScore);
 
         DynamicObject convertJobSeq = data.convertJobSeq;
         JobSeqEnum jobSeqEnum = JobSeqEnum.getByCode(convertJobSeq.getString(FormConstant.NUMBER_KEY));
+        logger.info("{}-转换后的职位序列类型={}", logPrefix, jobSeqEnum);
+        
         if(JobSeqEnum.SKILL == jobSeqEnum){
             personPosFile.set(PositionStructureConstant.NCKD_JOBSTATUSNAME, data.jobStatusName);
             personPosFile.set(PositionStructureConstant.NCKD_OCPQUALLEVEL, scoreData.dbOcpQualLevel);
             personPosFile.set(PositionStructureConstant.NCKD_JOBSTATUSSCORE, scoreData.perOcpQualScore);
+            logger.info("{}-设置技能序列相关信息完成", logPrefix);
         }else{
             personPosFile.set(PositionStructureConstant.NCKD_RANKNAME, data.rankName);
             personPosFile.set(PositionStructureConstant.NCKD_PROTITLELEVEL, scoreData.dbProTitleLevel);
             personPosFile.set(PositionStructureConstant.NCKD_RANKSCORE, scoreData.proTitleScore);
+            logger.info("{}-设置非技能序列相关信息完成", logPrefix);
         }
+        
         personPosFile.set(PositionStructureConstant.NCKD_JOBLEVELHR, jobLeve);
         personPosFile.set(PositionStructureConstant.NCKD_DIPLOMA, data.diploma);
         personPosFile.set(PositionStructureConstant.NCKD_TYPESTATE, typeState);
@@ -405,9 +468,21 @@ public abstract class BaseInitialOperationPlugIn extends AbstractOperationServic
         personPosFile.set(PositionStructureConstant.STATUS, StatusEnum.C.toString());
         personPosFile.set(PositionStructureConstant.ENABLE, EnableEnum.YES.getCode());
         personPosFile.set(PositionStructureConstant.CREATOR_KEY, RequestContext.get().getCurrUserId());
-
-
-        SaveServiceHelper.save(new DynamicObject[]{personPosFile});
+        logger.info("{}-设置所有字段完成", logPrefix);
+
+//        SaveServiceHelper.save(new DynamicObject[]{personPosFile});
+        OperationResult operationResult = SaveServiceHelper.saveOperate(PositionStructureConstant.PERSONPOSFILE_ENTITYID, new DynamicObject[]{personPosFile}, OperateOption.create());
+        if (!operationResult.isSuccess()) {
+            StringJoiner errorMsg = new StringJoiner("\n");
+            for (IOperateInfo error : operationResult.getAllErrorOrValidateInfo()) {
+                errorMsg.add(error.getMessage());
+            }
+            if (!ObjectUtils.isEmpty(operationResult.getMessage())) {
+                errorMsg.add(operationResult.getMessage());
+            }
+            throw new ValidationException("保存职位档案失败,原因:" + errorMsg.toString());
+        }
+        logger.info("{}-职位档案保存完成,ID={}", logPrefix, personPosFile.getLong(FormConstant.ID_KEY));
         return personPosFile;
     }
 

+ 21 - 1
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/initial/NewHireInitialOperationPlugIn.java

@@ -139,9 +139,12 @@ public class NewHireInitialOperationPlugIn extends BaseInitialOperationPlugIn {
      * 处理单个在职人员初定
      */
     private void processNewHireInitialData() {
+        logger.info("【职位体系】-开始处理新入职人员初定");
 
         List<DynamicObject> savePersonPosFileList = Lists.newArrayList();
-        for (BaseInitialData data : baseInitialData) {
+        for (int i = 0; i < baseInitialData.size(); i++) {
+            BaseInitialData data = baseInitialData.get(i);
+            logger.info("【职位体系】-处理第{}个新入职人员初定", i+1);
 
             String logPrefix = StrFormatter.format("【职位体系】-新入职人员初定-人员【{}({})】",
                     data.person.getString(FormConstant.NAME_KEY),
@@ -153,9 +156,11 @@ public class NewHireInitialOperationPlugIn extends BaseInitialOperationPlugIn {
                     data.positionHr.getString(FormConstant.NAME_KEY));
 
             // 获取上年度绩效结果
+            logger.info("{}-开始获取上年度绩效结果", logPrefix);
             getPreviousYearPerformance(data, logPrefix);
 
             // 获取学历、职称、技能对应的积分
+            logger.info("{}-开始获取积分数据", logPrefix);
             ScoreData scoreData = getScoreData(data, logPrefix);
 
             // 优秀生得2分
@@ -165,34 +170,49 @@ public class NewHireInitialOperationPlugIn extends BaseInitialOperationPlugIn {
             BigDecimal allSumScore = scoreData.educationScore.add(scoreData.proTitleScore).add(scoreData.perOcpQualScore).add(excellentScore);
             logger.info("{}-学历分 + 职称/技能分 + 优秀生分 = {}", logPrefix, allSumScore);
             // 计算累计积分池(生涯积分)
+            logger.info("{}-开始计算累计积分池", logPrefix);
             BigDecimal sumScore = calculateSumScore(allSumScore, scoreData, logPrefix);
 
             // 计算职级
             //当考核结果为无时,职级定为最低级
             boolean useMinLevel = data.lastYearAppraisalResultEnum == nckd.jxccl.base.common.enums.AppraisalResultEnum.NONE;
             // 如果是管理序列,则按职能序列进行初定
+            logger.info("{}-开始处理职位序列转换", logPrefix);
             data.convertJobSeq = JobLevelCalculatorService.handleJobSeq(data.jobSeq);
+            logger.info("{}-职位序列转换完成,convertJobSeq={}", logPrefix, data.convertJobSeq);
+            
             //【三期需求】-不满足三要素(聘任职称/技能、考核结果、积分)按"无职级"初定
             String perProTitleNumber = scoreData.dbProTitleLevel != null ? scoreData.dbProTitleLevel.getString(FormConstant.NUMBER_KEY) : null;
             String quaLevelNumber = scoreData.dbOcpQualLevel != null ? scoreData.dbOcpQualLevel.getString(FormConstant.NUMBER_KEY) : null;
             boolean threeElementMeet = JobLevelCalculatorService.checkThreeElementsRequirement(data.convertJobSeq, allSumScore, scoreData.dbProTitleLevel,
                     scoreData.dbOcpQualLevel, data.lastYearAppraisalResultEnum);
+                    
+            logger.info("{}-计算职级参数: convertJobSeq={}, allSumScore={}, perProTitleNumber={}, quaLevelNumber={}, downgradeNum={}, useMinLevel={}, !threeElementMeet={}",
+                       logPrefix, data.convertJobSeq, allSumScore, perProTitleNumber, quaLevelNumber, data.downgradeNum, useMinLevel, !threeElementMeet);
 
             DynamicObject jobLeve = JobLevelCalculatorService.getJobLevel(
                     data.convertJobSeq, allSumScore, perProTitleNumber,
                     quaLevelNumber,data.downgradeNum,useMinLevel,!threeElementMeet);
+            logger.info("{}-职级计算完成,jobLeve={}", logPrefix, jobLeve);
+            
             if(jobLeve != null) {
                 // 构建职位档案并存入数据库
+                logger.info("{}-开始创建并保存职位档案", logPrefix);
                 DynamicObject savePersonPosFile = createAndSavePersonPosFile(data, scoreData, allSumScore, sumScore, jobLeve, logPrefix, "1");
                 savePersonPosFileList.add(savePersonPosFile);
                 //返回定级后的职级
                 setJobLevelResult(data.person, jobLeve);
+                logger.info("{}-职位档案创建并保存完成", logPrefix);
 
                 //TODO 【待修改】-职位体系-这里可能有协同,初定完成后需要将待办任务置为已完成
+            } else {
+                logger.warn("{}-未能计算出有效职级,跳过创建职位档案", logPrefix);
             }
         }
         //职位津贴
+        logger.info("【职位体系】-开始生成职位津贴,处理数量: {}", savePersonPosFileList.size());
         ManagerAllowanceService.generateMgrPostAllow(savePersonPosFileList);
+        logger.info("【职位体系】-新入职人员初定处理完成");
 
     }
 

+ 20 - 2
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/initial/ServingInitialOperationPlugIn.java

@@ -147,9 +147,13 @@ public class ServingInitialOperationPlugIn extends BaseInitialOperationPlugIn {
      * 处理单个在职人员初定
      */
     private void processServingInitial() {
+        logger.info("【职位体系】-开始处理在职人员初定");
         List<DynamicObject> savePersonPosFileList = Lists.newArrayList();
         // 提取基本信息
-        for (BaseInitialData data : baseInitialData) {
+        for (int i = 0; i < baseInitialData.size(); i++) {
+            BaseInitialData data = baseInitialData.get(i);
+            logger.info("【职位体系】-处理第{}个在职人员初定", i+1);
+            
             String logPrefix = StrFormatter.format("【职位体系】-在职人员初定-人员【{}({})】",
                     data.person.getString(FormConstant.NAME_KEY),
                     data.person.getString(FormConstant.EMP_NUMBER_KEY));
@@ -161,17 +165,21 @@ public class ServingInitialOperationPlugIn extends BaseInitialOperationPlugIn {
                     data.allSumScore.toString());
 
             // 获取上年度绩效结果
+            logger.info("{}-开始获取上年度绩效结果", logPrefix);
             getPreviousYearPerformance(data, logPrefix);
 
             // 获取学历、职称、技能对应的积分
+            logger.info("{}-开始获取积分数据", logPrefix);
             ScoreData scoreData = getScoreData(data, logPrefix);
 
             // 计算累计积分池(生涯积分)
+            logger.info("{}-开始计算累计积分池", logPrefix);
             BigDecimal sumScore = calculateSumScore(data.allSumScore, scoreData, logPrefix);
 
             // 如果是管理序列,则按职能序列进行初定
+            logger.info("{}-开始处理职位序列转换", logPrefix);
             data.convertJobSeq = JobLevelCalculatorService.handleJobSeq(data.jobSeq);
-
+            logger.info("{}-职位序列转换完成,convertJobSeq={}", logPrefix, data.convertJobSeq);
 
             // 计算职级
             //当考核结果为无时,职级定为最低级
@@ -180,20 +188,30 @@ public class ServingInitialOperationPlugIn extends BaseInitialOperationPlugIn {
             String quaLevelNumber = scoreData.dbOcpQualLevel != null ? scoreData.dbOcpQualLevel.getString(FormConstant.NUMBER_KEY) : null;
             boolean threeElementMeet = JobLevelCalculatorService.checkThreeElementsRequirement(data.convertJobSeq, data.allSumScore, scoreData.dbProTitleLevel,
                     scoreData.dbOcpQualLevel, data.lastYearAppraisalResultEnum);
+            logger.info("{}-计算职级参数: convertJobSeq={}, allSumScore={}, perProTitleNumber={}, quaLevelNumber={}, downgradeNum={}, useMinLevel={}, !threeElementMeet={}",
+                       logPrefix, data.convertJobSeq, data.allSumScore, perProTitleNumber, quaLevelNumber, data.downgradeNum, useMinLevel, !threeElementMeet);
+                       
             DynamicObject jobLeve = JobLevelCalculatorService.getJobLevel(
                     data.convertJobSeq, data.allSumScore, perProTitleNumber,
                     quaLevelNumber,  data.downgradeNum,useMinLevel,!threeElementMeet);
+            logger.info("{}-职级计算完成,jobLeve={}", logPrefix, jobLeve);
 
             if(jobLeve != null) {
                 // 构建职位档案并存入数据库
+                logger.info("{}-开始创建并保存职位档案", logPrefix);
                 DynamicObject savePersonPosFile = createAndSavePersonPosFile(data, scoreData, data.allSumScore, sumScore, jobLeve, logPrefix, "2");
                 savePersonPosFileList.add(savePersonPosFile);
                 //返回定级后的职级。张三:职位级为"初级(1)"
                 setJobLevelResult(data.person, jobLeve);
+                logger.info("{}-职位档案创建并保存完成", logPrefix);
+            } else {
+                logger.warn("{}-未能计算出有效职级,跳过创建职位档案", logPrefix);
             }
         }
         //职位津贴
+        logger.info("【职位体系】-开始生成职位津贴,处理数量: {}", savePersonPosFileList.size());
         ManagerAllowanceService.generateMgrPostAllow(savePersonPosFileList);
+        logger.info("【职位体系】-在职人员初定处理完成");
     }
 
     @Override

+ 1 - 9
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/other/NewAppointMentOpPlugin.java

@@ -161,11 +161,7 @@ public class NewAppointMentOpPlugin extends AbstractOperationServicePlugIn imple
                 ));
         List<DynamicObject> newEntityList = new ArrayList<>();
 
-        DynamicObject org = OrgHelper.getCreateOrg(PositionStructureConstant.PERSONPOSFILE_ENTITYID);
-        String bdCtrlStrgy = null;
-        if(org != null) {
-            bdCtrlStrgy = OrgHelper.getBdCtrlStrgy(PositionStructureConstant.PERSONPOSFILE_ENTITYID, org.getLong(FormConstant.ID_KEY));
-        }
+
         for (DynamicObject entry : e.getDataEntities()) {
             DynamicObject newEntity = EntityHelper.newEntity(PositionStructureConstant.NCKD_PERSONPOSFILE);
             DynamicObject person = entry.getDynamicObject(PositionStructureConstant.NCKD_PERSON);
@@ -182,10 +178,6 @@ public class NewAppointMentOpPlugin extends AbstractOperationServicePlugIn imple
             newEntity.set(PositionStructureConstant.NCKD_POSITIONHR, empPosOrgRel.get(PositionStructureConstant.POSITION_KEY));
             newEntity.set(PositionStructureConstant.NCKD_EXECUTEYEAR, beginDateDateTime.getYear());
             newEntity.set(PositionStructureConstant.NCKD_APPOINTSTATUS, "1");
-            newEntity.set(FormConstant.CREATEORG_KEY, org);
-            newEntity.set(FormConstant.ORG_KEY, org);
-            newEntity.set(FormConstant.USEORG_KEY, org);
-            newEntity.set(FormConstant.CTRLSTRATEGY_KEY, bdCtrlStrgy);
             newEntity.set(FormConstant.CREATOR_KEY, UserServiceHelper.getCurrentUserId());
             newEntity.set(FormConstant.DESCRIPTION_KEY, entry.get(FormConstant.DESCRIPTION_KEY));
             newEntityList.add(newEntity);

Some files were not shown because too many files changed in this diff