Browse Source

fix(hr): 修正管理人员任命终止逻辑与数据迁移判断

- 修改了字段属性加载方式,使用 getAllFields 替代手动添加
- 修复终止状态判断条件,从 typeState 改为 appointStatus
- 在终止操作中增加结束日期字段设置
- 优化数据迁移标识判断逻辑,支持多来源参数识别
- 引入 ObjectUtils 工具类进行空值安全判断
- 统一各插件中的数据迁移校验处理方式
wyc 1 tuần trước cách đây
mục cha
commit
c3b726a4db

+ 11 - 10
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/other/EndAppointMentOpPlugin.java

@@ -16,20 +16,20 @@ import nckd.jxccl.base.common.exception.ValidationException;
 import nckd.jxccl.base.common.utils.StrFormatter;
 import nckd.jxccl.hr.psms.common.PositionStructureConstant;
 
+import java.util.Date;
+
 /**
-* 终止管理人员任命
-* 实体标识:nckd_mgrappointmgmt
-* @author W.Y.C
-* @date 2025/12/4 21:25
-* @version 1.0
-*/
+ * 终止管理人员任命
+ * 实体标识:nckd_mgrappointmgmt
+ * @author W.Y.C
+ * @date 2025/12/4 21:25
+ * @version 1.0
+ */
 public class EndAppointMentOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
 
     @Override
     public void onPreparePropertys(PreparePropertysEventArgs e) {
-        e.getFieldKeys().add(PositionStructureConstant.NCKD_TYPESTATE);
-        e.getFieldKeys().add(PositionStructureConstant.NCKD_APPOINTSTATUS);
-        e.getFieldKeys().add(PositionStructureConstant.NCKD_PERSON);
+        e.getFieldKeys().addAll(this.billEntityType.getAllFields().keySet());
     }
 
     @Override
@@ -43,7 +43,7 @@ public class EndAppointMentOpPlugin extends AbstractOperationServicePlugIn imple
                     String name = person.getString(PositionStructureConstant.NAME_KEY);
                     String typeState = data.getString(PositionStructureConstant.NCKD_TYPESTATE);
                     String appointStatus = data.getString(PositionStructureConstant.NCKD_APPOINTSTATUS);
-                    if(!"1".equalsIgnoreCase(typeState)){
+                    if(!"1".equalsIgnoreCase(appointStatus)){
                         this.addErrorMessage(rowDataEntity, StrFormatter.format("【{}】状态为【已终止】,忽略此条处理!",name));
                     }
                 }
@@ -55,6 +55,7 @@ public class EndAppointMentOpPlugin extends AbstractOperationServicePlugIn imple
     public void beginOperationTransaction(BeginOperationTransactionArgs e) {
         for (DynamicObject dataEntity : e.getDataEntities()) {
             dataEntity.set(PositionStructureConstant.NCKD_APPOINTSTATUS, "0");
+            dataEntity.set(PositionStructureConstant.NCKD_ENDDATE, new Date());
         }
         OperationResult operationResult = SaveServiceHelper.saveOperate(PositionStructureConstant.PERSONPOSFILE_ENTITYID, e.getDataEntities(), OperateOption.create());
         if (!operationResult.isSuccess()) {

+ 12 - 2
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/performance/PerfRankMgmtSaveOpPlugin.java

@@ -37,6 +37,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
+import kd.bos.dataentity.utils.ObjectUtils;
 
 /**
 * 年度绩效排名管理-保存插件
@@ -60,8 +61,17 @@ public class PerfRankMgmtSaveOpPlugin extends AbstractOperationServicePlugIn imp
 
     @Override
     public void beginOperationTransaction(BeginOperationTransactionArgs e) {
-        String invoker = (String)this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
-        boolean dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker);
+        boolean dataMigration = false;
+        Object invoker = this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
+        if(ObjectUtils.isEmpty(invoker)){
+            Object invoker1 = this.getOption().getVariables().get("hr_hrdmvalidatetag_of_datasource");
+            Object invoker2 = this.getOption().getVariables().get("hr_hrdmsynctag_of_datasource");
+            if(!ObjectUtils.isEmpty(invoker1) || !ObjectUtils.isEmpty(invoker2)){
+                dataMigration = true;
+            }
+        } else{
+            dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker.toString());
+        }
         for (DynamicObject dataEntity : e.getDataEntities()) {
 
             //事务开始前先查询数据库中的排名名单,找出哪些是此次被删除的人员

+ 23 - 4
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/performance/validate/PerfRankMgmtSaveValidate.java

@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.StringJoiner;
 import java.util.stream.Collectors;
+import kd.bos.dataentity.utils.ObjectUtils;
 
 /**
 * 绩效排名管理保存验证插件
@@ -39,8 +40,17 @@ public class PerfRankMgmtSaveValidate extends AbstractValidator {
     private final Map<String, BigDecimal> appraisalResultRatioMap = new HashMap<>();
     @Override
     public void validate() {
-        String invoker = (String)this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
-        boolean dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker);
+        boolean dataMigration = false;
+        Object invoker = this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
+        if(ObjectUtils.isEmpty(invoker)){
+            Object invoker1 = this.getOption().getVariables().get("hr_hrdmvalidatetag_of_datasource");
+            Object invoker2 = this.getOption().getVariables().get("hr_hrdmsynctag_of_datasource");
+            if(!ObjectUtils.isEmpty(invoker1) || !ObjectUtils.isEmpty(invoker2)){
+                dataMigration = true;
+            }
+        } else{
+            dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker.toString());
+        }
         if(!dataMigration) {
             QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
                     .addGroup(new String[]{FormConstant.NCKD_ENTRYENTITY}, PerfRankMgmtConstant.NCKD_RATIO)
@@ -262,8 +272,17 @@ public class PerfRankMgmtSaveValidate extends AbstractValidator {
      */
     private void validateEntry(DynamicObject entry, ExtendedDataEntity rowDataEntity,
                                int rowIndex, Set<Long> personIds, ValidationContext context) {
-        String invoker = (String)this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
-        boolean dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker);
+        boolean dataMigration = false;
+        Object invoker = this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
+        if(ObjectUtils.isEmpty(invoker)){
+            Object invoker1 = this.getOption().getVariables().get("hr_hrdmvalidatetag_of_datasource");
+            Object invoker2 = this.getOption().getVariables().get("hr_hrdmsynctag_of_datasource");
+            if(!ObjectUtils.isEmpty(invoker1) || !ObjectUtils.isEmpty(invoker2)){
+                dataMigration = true;
+            }
+        } else{
+            dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker.toString());
+        }
         DynamicObject empPosOrgRel = entry.getDynamicObject(PerfRankMgmtConstant.NCKD_EMPPOSORGREL);
         DynamicObject person = entry.getDynamicObject(PerfRankMgmtConstant.NCKD_PERSON);
         if(!dataMigration && empPosOrgRel == null){

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

@@ -45,6 +45,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.StringJoiner;
 import java.util.stream.Collectors;
+import kd.bos.dataentity.utils.ObjectUtils;
 
 /**
  * 考核周期保存OP
@@ -67,8 +68,19 @@ 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);
+        boolean dataMigration;
+        Object invoker = this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
+        if(ObjectUtils.isEmpty(invoker)){
+            Object invoker1 = this.getOption().getVariables().get("hr_hrdmvalidatetag_of_datasource");
+            Object invoker2 = this.getOption().getVariables().get("hr_hrdmsynctag_of_datasource");
+            if(!ObjectUtils.isEmpty(invoker1) || !ObjectUtils.isEmpty(invoker2)){
+                dataMigration = true;
+            } else {
+                dataMigration = false;
+            }
+        } else{
+            dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker.toString());
+        }
         boolean isUpdate = ConvertUtil.toBoolean(this.getOption().getVariableValue("isUpdate",StringUtils.EMPTY),Boolean.FALSE);
         e.addValidator(new AbstractValidator() {
             @Override