浏览代码

feat(coordination): 新增参保标准维度值自动填充功能

- 实现 propertyChanged 监听参保标准、险种及维度变化
- 添加从缓存获取参保标准信息逻辑
- 增加子单据体维度值设置方法
- 引入 SITCoordinationUtils 工具类处理标准结果
- 定义保险缴费基数常量映射关系
- 修复关键岗位 ID 获取方法命名错误
Tyx 1 周之前
父节点
当前提交
0330796b16

+ 15 - 2
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/common/constant/SitConstant.java

@@ -2,6 +2,9 @@ package nckd.jxccl.sit.hcsi.common.constant;
 
 import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class SitConstant {
     /*社保档案*/
     public static final HRBaseServiceHelper SINSURFILE_HELPER = new HRBaseServiceHelper("hcsi_sinsurfile");
@@ -27,8 +30,18 @@ public class SitConstant {
     public static final HRBaseServiceHelper SINSURPERIOD_HELPER = new HRBaseServiceHelper("sitbs_sinsurperiod");
     /*业务数据提报-外单位收入模板编码*/
     public static final String WDWSR_NUMBER = "JT001";
-
-
     public static final String SeparatorA = "_A";
     public static final String SeparatorB = "_B";
+    public static final Map<Long, String> INSURANCE_PAY_BASE_CONSTANTS = new HashMap<>();
+
+    static {
+        INSURANCE_PAY_BASE_CONSTANTS.put(1070L, "nckd_paybasetopofemployee");
+        INSURANCE_PAY_BASE_CONSTANTS.put(1080L, "nckd_paybasebottomofemplo");
+        INSURANCE_PAY_BASE_CONSTANTS.put(1130L, "nckd_paybasetopofcompany");
+        INSURANCE_PAY_BASE_CONSTANTS.put(1140L, "nckd_paybasebottomofcompa");
+        INSURANCE_PAY_BASE_CONSTANTS.put(1050L, "nckd_payfixedofemployee");
+        INSURANCE_PAY_BASE_CONSTANTS.put(1060L, "nckd_payfixedofcompany");
+        INSURANCE_PAY_BASE_CONSTANTS.put(1030L, "nckd_payproportionofemplo");
+        INSURANCE_PAY_BASE_CONSTANTS.put(1040L, "nckd_payproportionofcompa");
+    }
 }

+ 73 - 2
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/coordination/SinSurEmpChgCoordBatchEditPluginEx.java

@@ -3,10 +3,10 @@ package nckd.jxccl.sit.hcsi.formplugin.web.coordination;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.dataentity.serialization.SerializationUtils;
-import kd.bos.db.DB;
+import kd.bos.dataentity.utils.ObjectUtils;
 import kd.bos.entity.EntityMetadataCache;
 import kd.bos.entity.datamodel.IDataModel;
-import kd.bos.form.MessageBoxOptions;
+import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 import kd.bos.form.control.EntryGrid;
 import kd.bos.form.events.AfterDoOperationEventArgs;
 import kd.bos.form.events.BeforeDoOperationEventArgs;
@@ -16,9 +16,17 @@ import kd.bos.form.plugin.AbstractFormPlugin;
 import kd.bos.org.utils.DynamicObjectUtils;
 import kd.bos.orm.query.QFilter;
 import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
+import kd.hr.hbp.common.cache.HRPageCache;
 import kd.hr.hbp.common.util.HRStringUtils;
 import kd.sdk.plugin.Plugin;
+import kd.sdk.sit.sitbp.business.helper.SITBPServiceHelper;
+import kd.sdk.sit.sitbp.common.StdDimDTO;
+import kd.sdk.sit.sitbp.common.StdInsuranceItemDTO;
+import kd.sdk.sit.sitbp.common.StdResultInfoDTO;
+import nckd.jxccl.sit.hcsi.common.constant.SitConstant;
+import nckd.jxccl.sit.hcsi.utils.SITCoordinationUtils;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -71,7 +79,70 @@ public class SinSurEmpChgCoordBatchEditPluginEx extends AbstractFormPlugin imple
         this.getView().updateView("nckd_subentryentity");
     }
 
+    @Override
+    public void propertyChanged(PropertyChangedArgs e) {
+        super.propertyChanged(e);
+        IDataModel model = this.getModel();
+        String key = e.getProperty().getName();
+        // 如果是 参保标准 / 险种 / 险种维度发生变化,需要去取参保标准中的标准维度值
+        // 如果是 险种 / 险种维度发生变化,只需要修改当前子单据体的数据
+        if(HRStringUtils.equalsAny(key, "nckd_welfaretype", "nckd_sinsurdimension")) {
+            int rowIndex = model.getEntryCurrentRowIndex("entryentity");
+            DynamicObject sinSurStd = (DynamicObject) model.getValue("sinsurstd_r31", rowIndex);
+            getStdInfoAndStdDimfromCache(sinSurStd);
+            int subRowIndex = e.getChangeSet()[0].getRowIndex();
+            DynamicObject welfaretype = (DynamicObject) model.getValue("nckd_welfaretype", subRowIndex);
+            DynamicObject sinSurDimension = (DynamicObject) model.getValue("nckd_sinsurdimension", subRowIndex);
+            getDimensionValue(sinSurStd, welfaretype, sinSurDimension, rowIndex, subRowIndex);
+        }
+        // 如果是 参保标准发生变化,当前单据体下的子单据体都需要更新
+        else if (HRStringUtils.equals(key, "sinsurstd_r31")) {
+            Object newValue = e.getChangeSet()[0].getNewValue();
+            if(!ObjectUtils.isEmpty(newValue)) {
+                getStdInfoAndStdDimfromCache((DynamicObject) newValue);
+            }
+        }
+    }
+
+    /**
+     * 从缓存中获取参保标准的信息,如果没有缓存则生成缓存
+     * @param sinSurStd
+     * @return
+     */
+    public void getStdInfoAndStdDimfromCache (DynamicObject sinSurStd) {
+        HRPageCache pageCache = new HRPageCache(this.getView());
+        String cacheKey = String.valueOf(sinSurStd.getLong("id"));
+        StdResultInfoDTO stdResultInfoDTO = pageCache.get(cacheKey, StdResultInfoDTO.class);
+        if(stdResultInfoDTO == null) {
+            stdResultInfoDTO = SITBPServiceHelper.getStdInfoAndStdDim(Arrays.asList(sinSurStd.getLong("id"))).get(sinSurStd.getLong("id"));
+            pageCache.put(cacheKey, stdResultInfoDTO);
+        }
+    }
+
+    /**
+     * 子单据体获取并设置维度值
+     * @param sinSurStd
+     * @param welfaretype
+     * @param sinSurDimension
+     * @param subRowIndex
+     */
+    public void getDimensionValue(DynamicObject sinSurStd, DynamicObject welfaretype, DynamicObject sinSurDimension, int rowIndex, int subRowIndex) {
+        IDataModel model = this.getModel();
+        HRPageCache pageCache = new HRPageCache(this.getView());
+        String cacheKey = String.valueOf(sinSurStd.getLong("id"));
+        StdResultInfoDTO stdResultInfoDTO = pageCache.get(cacheKey, StdResultInfoDTO.class);
+
+        if(welfaretype == null || sinSurDimension == null)
+            return;
+
+        SITCoordinationUtils SITCoordinationUtils = new SITCoordinationUtils();
+        Map result = SITCoordinationUtils.dealStdResult(stdResultInfoDTO, sinSurStd, welfaretype, sinSurDimension);
 
+        Set<Long> keySet = SitConstant.INSURANCE_PAY_BASE_CONSTANTS.keySet();
+        for (Long key : keySet) {
+            model.setValue(SitConstant.INSURANCE_PAY_BASE_CONSTANTS.get(key), result.get(key), rowIndex, subRowIndex);
+        }
+    }
 
 
     @Override

+ 59 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/utils/SITCoordinationUtils.java

@@ -0,0 +1,59 @@
+package nckd.jxccl.sit.hcsi.utils;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.sdk.sit.sitbp.common.StdDimDTO;
+import kd.sdk.sit.sitbp.common.StdInsuranceItemDTO;
+import kd.sdk.sit.sitbp.common.StdResultInfoDTO;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SITCoordinationUtils {
+
+    /**
+     * 处理参保标准的结果
+     * @param stdResultInfoDTO
+     * @param sinSurStd
+     * @param welfaretype
+     * @param sinSurDimension Key = 险种属性ID, value = 参保标准中设置的值
+     * @return
+     */
+    public Map<Long, Object> dealStdResult (StdResultInfoDTO stdResultInfoDTO, DynamicObject sinSurStd, DynamicObject welfaretype, DynamicObject sinSurDimension) {
+        List<StdResultInfoDTO.StdInsurTypeResultInfoDTO> stdInsurTypeResultInfoDTOS = stdResultInfoDTO.getStdInsurTypeResultInfoDTOS();
+        // 根据 insurTypeId 和 baseDataId 查找目标数据
+        Long insurTypeId = welfaretype.getLong("id"); // 险种ID
+        Long baseDataId = sinSurDimension.getLong("id"); // 险种维度ID
+
+        Map<Long, Object> result = new HashMap<>();
+
+        for (StdResultInfoDTO.StdInsurTypeResultInfoDTO dto : stdInsurTypeResultInfoDTOS) {
+            // 匹配 insurTypeId
+            if (dto.getInsurTypeId() != null && dto.getInsurTypeId().equals(insurTypeId)) {
+                // 遍历 stdDimRlslnfos
+                List<StdResultInfoDTO.StdDimRsInfo> stdDimRlslnfos = dto.getStdDimRsInfos();
+                if (stdDimRlslnfos != null) {
+                    for (StdResultInfoDTO.StdDimRsInfo stdDimRlslnfo : stdDimRlslnfos) {
+                        List<StdDimDTO> stdDimDTOs = stdDimRlslnfo.getStdDimDTOs();
+                        if (stdDimDTOs != null) {
+                            for (StdDimDTO stdDimDTO : stdDimDTOs) {
+                                // 查找匹配的 baseDataId
+                                if(stdDimDTO.getBaseDataId().equals(baseDataId)) {
+                                    List<StdInsuranceItemDTO> list = stdDimRlslnfo.getStdInsuranceItemDTOs();
+                                    for (StdInsuranceItemDTO itemDTO : list) {
+                                        BigDecimal itemValue = itemDTO.getItemValue() == null ? BigDecimal.ZERO : itemDTO.getItemValue();
+                                        result.put(itemDTO.getInsurPropId(), itemValue);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return result; // 返回空 map 表示未找到
+    }
+
+}

+ 2 - 2
code/wtc/nckd-jxccl-wtc/src/main/java/nckd/jxccl/wtc/wtabm/web/validate/VaApplyCheckValidator.java

@@ -32,7 +32,7 @@ public class VaApplyCheckValidator extends AbstractValidator {
             Date startDate = bill.getDate("startdate");
             Date endDate = bill.getDate("enddate");
 
-            getKetPositionIds(operateKey, allOrgIds, positionIds, userId);
+            getKeyPositionIds(operateKey, allOrgIds, positionIds, userId);
 
             if(positionIds.size() > 0) {
                 // 根据关键岗位 + 日期范围 获取休假单信息
@@ -66,7 +66,7 @@ public class VaApplyCheckValidator extends AbstractValidator {
      * @param positionIds
      * @param userId
      */
-    public void getKetPositionIds (String operateKey, List<Long> allOrgIds, List<Long> positionIds, Long userId) {
+    public void getKeyPositionIds (String operateKey, List<Long> allOrgIds, List<Long> positionIds, Long userId) {
         // 根据工作流角色判断
         if("checkbyrole".equals(operateKey)) {
             // 获取工作流角色中的组织