Browse Source

feat(transfer): 新增调动基础单据功能

- 创建TransferApplyBillConstant常量类,定义调动相关的常量
- 创建AppflgConstant常量类,定义HR云init应用通用常量
- 实现TransferApplyBillFormPlugin表单插件,处理调动基础单据业务逻辑
- 添加近亲属关系验证功能,跨二级单位调动时检查员工近亲属关系
- 修改离职申请表单插件,支持员工确认退休日期自动设置合同结束日期
- 在离职申请常量中新增员工确认退休日期字段常量
jtd 1 tuần trước cách đây
mục cha
commit
625f43abc1

+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/business/.gitkeep


+ 22 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/common/AppflgConstant.java

@@ -0,0 +1,22 @@
+/**
+ * This is a kingdee cosmic template project that is automatically generated by the Kingdee cosmic development assistant plugin. 
+ * If there are any issues during the use process, you can provide feedback to the kingdee developer community website.
+ * Website: https://developer.kingdee.com/developer?productLineId=29
+ * Author: liebin.zheng
+ * Generate Date: 2025-05-26 16:28:10
+ */
+package nckd.jxccl.hr.hdm.common;
+
+/**
+ * hr云init应用-通用常量类<br>
+ * 代码中不能存在硬编码敏感信息,如账号、密码、http外链、ftp外链、邮箱等。<br>
+ * 标识或缓存的常量,需以"KEY_"、"FID_"、"ENTRY_"或"SUBENTRY_"作为变量的前缀。<br>
+ *
+ * @author nckd
+ * @date 2025-05-26 16:28:10
+ */
+public class AppflgConstant {
+	
+	public static final String KEY_APP_NAME = "hr-init";
+
+}

+ 40 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/common/transfer/TransferApplyBillConstant.java

@@ -0,0 +1,40 @@
+package nckd.jxccl.hr.hdm.common.transfer;
+
+import nckd.jxccl.base.common.constant.FormConstant;
+
+/**
+ * 调动基础单据常量类
+ * @author: jtd
+ * @date: 2026/1/4 15:37
+ */
+public class TransferApplyBillConstant extends FormConstant {
+    /** 获取员工近亲属关系查询实体标识 */
+    public static final String NCKD_HRPI_GETFAMILYRELATION_ENTITY = "nckd_hrpi_getfamilyrelation";
+
+    /** 调出公司 */
+    public static final String BCOMPANY_KEY = "bcompany";
+    /** 调入公司 */
+    public static final String ACOMPANY_KEY = "acompany";
+    /** 配偶、近亲属关系.员工 */
+    public static final String NCKD_EMPID_KEY = "nckd_empid";
+    /** 原合同是否解除 */
+    public static final String NCKD_ISTERMORIGCONT_KEY = "nckd_istermorigcont";
+
+    /** 员工.员工编码 */
+    public static final String EMPLOYEE_EMPNUMBER = "employee.empnumber";
+    /** 员工.员工姓名 */
+    public static final String EMPLOYEE_NAME = "employee.name";
+
+    /** 亲属关系.ID */
+    public static final String NCKD_RELATION_ID = "nckd_relation.id";
+    /** 亲属关系.编码 */
+    public static final String NCKD_RELATION_NUMBER = "nckd_relation.number";
+    /** 亲属关系.名称 */
+    public static final String NCKD_RELATION_NAME = "nckd_relation.name";
+
+    /** 近亲属关系确认页面缓存参数 */
+    public static final String FAMILY_RELATION_CONFIRM_PAGE_CACHE = "familyRelationConfirm";
+
+    /** 近亲属关系确认回调 */
+    public static final String FAMILY_RELATION_CONFIRM_CALLBACK = "familyRelationConfirm";
+}

+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/mservice/.gitkeep


+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/plugin/form/.gitkeep


+ 102 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/plugin/form/transfer/TransferApplyBillFormPlugin.java

@@ -0,0 +1,102 @@
+package nckd.jxccl.hr.hdm.plugin.form.transfer;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.entity.QueryEntityType;
+import kd.bos.form.ConfirmCallBackListener;
+import kd.bos.form.ConfirmTypes;
+import kd.bos.form.MessageBoxOptions;
+import kd.bos.form.MessageBoxResult;
+import kd.bos.form.events.BeforeDoOperationEventArgs;
+import kd.bos.form.events.MessageBoxClosedEvent;
+import kd.bos.form.operate.FormOperate;
+import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.MetadataServiceHelper;
+import kd.hr.hbp.business.servicehelper.HRQueryEntityHelper;
+import kd.hr.hbp.common.util.HRDynamicObjectUtils;
+import kd.hr.hbp.common.util.HRStringUtils;
+import nckd.jxccl.base.common.utils.QueryFieldBuilder;
+import nckd.jxccl.hr.hdm.common.transfer.TransferApplyBillConstant;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 调动基础单据表单插件
+ * @entity: nckd_hdm_transferbase_ext
+ * @author: jtd
+ * @date: 2026/1/4 15:34
+ */
+public class TransferApplyBillFormPlugin extends AbstractFormPlugin {
+
+    @Override
+    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
+        super.beforeDoOperation(args);
+
+        FormOperate formOperate = (FormOperate) args.getSource();
+        String operateKey = formOperate.getOperateKey();
+        switch (operateKey){
+            case TransferApplyBillConstant.SAVE_OP:
+                if (!HRStringUtils.equals(Boolean.TRUE.toString(), getView().getPageCache().get(TransferApplyBillConstant.FAMILY_RELATION_CONFIRM_PAGE_CACHE))) {
+                    validateFamilyRelation(args);
+                }
+        }
+    }
+
+    private void validateFamilyRelation(BeforeDoOperationEventArgs args) {
+        DynamicObject dataEntity = getModel().getDataEntity();
+        // 获取调出公司
+        DynamicObject bcompany = dataEntity.getDynamicObject(TransferApplyBillConstant.BCOMPANY_KEY);
+        // 获取调入公司
+        DynamicObject acompany = dataEntity.getDynamicObject(TransferApplyBillConstant.ACOMPANY_KEY);
+        // 判断是否跨二级单位调动
+        if (HRDynamicObjectUtils.compareValues(bcompany, acompany)) {
+            return;
+        }
+
+        // 获取调动员工
+        DynamicObject transferEmployee = dataEntity.getDynamicObject(TransferApplyBillConstant.BB_EM_TID);
+        // 获取调入公司内员工近亲属关系
+        QueryEntityType queryEntityType = (QueryEntityType) MetadataServiceHelper.getDataEntityType(TransferApplyBillConstant.NCKD_HRPI_GETFAMILYRELATION_ENTITY);
+        // 查询 员工编码、员工姓名、亲属关系ID、亲属关系编码、亲属关系名称
+        String queryFields = QueryFieldBuilder.create().add(TransferApplyBillConstant.EMPLOYEE_EMPNUMBER)
+                .add(TransferApplyBillConstant.EMPLOYEE_NAME)
+                .add(TransferApplyBillConstant.NCKD_RELATION_ID)
+                .add(TransferApplyBillConstant.NCKD_RELATION_NUMBER)
+                .add(TransferApplyBillConstant.NCKD_RELATION_NAME)
+                .buildSelect();
+        // 过滤 所属公司为调出公司 并且 近亲属员工为调动员工
+        QFilter qFilter = new QFilter(String.join(".", TransferApplyBillConstant.HRPI_EMPPOSORGREL, TransferApplyBillConstant.COMPANY_KEY, TransferApplyBillConstant.NUMBER_KEY), QCP.equals, acompany.getString(TransferApplyBillConstant.NUMBER_KEY))
+                .and(String.join(".", TransferApplyBillConstant.NCKD_EMPID_KEY, TransferApplyBillConstant.NUMBER_KEY), QCP.equals, transferEmployee.getString(TransferApplyBillConstant.NUMBER_KEY));
+        DynamicObjectCollection familyRelationDys = HRQueryEntityHelper.getInstance().getQueryDyoColl(queryEntityType, queryFields, new QFilter[]{qFilter}, TransferApplyBillConstant.EMPLOYEE_EMPNUMBER);
+        List<String> errorList = new ArrayList<String>();
+        for (DynamicObject familyRelationDy : familyRelationDys) {
+            // 获取近亲属员工姓名
+            String empName = familyRelationDy.getString(TransferApplyBillConstant.EMPLOYEE_NAME);
+            // 获取近亲属名称
+            String relationName = familyRelationDy.getString(TransferApplyBillConstant.NCKD_RELATION_NAME);
+            errorList.add(String.format("亲属姓名:%s,亲属关系:%s", empName, relationName));
+        }
+
+        if (!errorList.isEmpty()) {
+            getView().showConfirm("近亲属关系", String.join(System.lineSeparator(), errorList), MessageBoxOptions.OKCancel, ConfirmTypes.Default, new ConfirmCallBackListener(TransferApplyBillConstant.FAMILY_RELATION_CONFIRM_CALLBACK));
+            args.setCancel(true);
+        }
+    }
+
+    @Override
+    public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
+        super.confirmCallBack(messageBoxClosedEvent);
+
+        switch (messageBoxClosedEvent.getCallBackId()) {
+            case TransferApplyBillConstant.FAMILY_RELATION_CONFIRM_CALLBACK:
+                if (messageBoxClosedEvent.getResult() == MessageBoxResult.Yes) {
+                    getView().getPageCache().put(TransferApplyBillConstant.FAMILY_RELATION_CONFIRM_PAGE_CACHE, Boolean.TRUE.toString());
+                    getView().invokeOperation(TransferApplyBillConstant.SAVE_OP);
+                    getView().getPageCache().remove(TransferApplyBillConstant.FAMILY_RELATION_CONFIRM_PAGE_CACHE);
+                }
+        }
+    }
+}

+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/plugin/operate/.gitkeep


+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/plugin/other/.gitkeep


+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/plugin/report/.gitkeep


+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/plugin/workflow/.gitkeep


+ 0 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/hdm/webapi/.gitkeep


+ 3 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/htm/common/quitapply/QuitApplyConstant.java

@@ -78,4 +78,7 @@ public class QuitApplyConstant extends FormConstant {
     /** 合同状态 */
     public static final String CONTRACTSTATUS_KEY = "contractstatus";
 
+    /** 员工确认退休日期 */
+    public static final String NCKD_EMPCFMRETDT_KEY = "nckd_empcfmretdt";
+
 }

+ 22 - 10
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/htm/plugin/form/quitapply/QuitApplyFormPlugin.java

@@ -47,16 +47,28 @@ public class QuitApplyFormPlugin extends AbstractFormPlugin {
 
         String propertyName = e.getProperty().getName();
         Object newValue = e.getChangeSet()[0].getNewValue();
-        if (QuitApplyConstant.CONTRACTENDDATE_KEY.equals(propertyName)) {
-            DynamicObject quitPersonDy = (DynamicObject) getModel().getValue(QuitApplyConstant.BB_EM_TID_KEY);
-            Date contractEndDate = (Date) newValue;
-            if (quitPersonDy == null || contractEndDate == null) {
-                getModel().setValue(QuitApplyConstant.NCKD_UNUSEDANNUALLEAVE_KEY, 0);
-                return;
-            }
-            Long employeeId = quitPersonDy.getLong(QuitApplyConstant.ID_KEY);
-            setUnUsedAnnualLeave(employeeId, contractEndDate);
-            setTrainingAgmtStat(employeeId, contractEndDate);
+        switch (propertyName) {
+            case QuitApplyConstant.CONTRACTENDDATE_KEY:
+                DynamicObject quitPersonDy = (DynamicObject) getModel().getValue(QuitApplyConstant.BB_EM_TID_KEY);
+                Date contractEndDate = (Date) newValue;
+                if (quitPersonDy == null || contractEndDate == null) {
+                    getModel().setValue(QuitApplyConstant.NCKD_UNUSEDANNUALLEAVE_KEY, 0);
+                    return;
+                }
+                Long employeeId = quitPersonDy.getLong(QuitApplyConstant.ID_KEY);
+                setUnUsedAnnualLeave(employeeId, contractEndDate);
+                setTrainingAgmtStat(employeeId, contractEndDate);
+
+                break;
+            case QuitApplyConstant.BB_EM_TID_KEY:
+                // 获取员工确认退休日期
+                if (newValue != null) {
+                    DynamicObject newValueDy = (DynamicObject) newValue;
+                    Date empcfmretdt = newValueDy.getDate(QuitApplyConstant.NCKD_EMPCFMRETDT_KEY);
+                    if (empcfmretdt != null) {
+                        getModel().setValue(QuitApplyConstant.CONTRACTENDDATE_KEY, empcfmretdt);
+                    }
+                }
         }
     }