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

Merge remote-tracking branch 'origin/master'

彭佳杰 4 өдөр өмнө
parent
commit
aac4ec5eb1

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

@@ -5,13 +5,15 @@ import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.serialization.SerializationUtils;
 import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
-import kd.bos.servicehelper.DispatchServiceHelper;
 import kd.bos.servicehelper.QueryServiceHelper;
+import kd.hr.hbp.business.servicehelper.HRMServiceHelper;
 import nckd.jxccl.hr.htm.common.quitapply.QuitApplyConstant;
 
-import java.time.ZoneId;
+import java.math.BigDecimal;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
@@ -25,6 +27,7 @@ import java.util.Map;
  * @date: 2025/11/18 22:53
  */
 public class QuitApplyFormPlugin extends AbstractFormPlugin {
+    private static final Log log = LogFactory.getLog(QuitApplyFormPlugin.class);
 
     /** 培养协议合同类型编码 */
     private static final String CONTRACTTYPE_NUMBER = "JT01";
@@ -79,18 +82,26 @@ public class QuitApplyFormPlugin extends AbstractFormPlugin {
      * @param contractEndDate 离职日期
      */
     private void setUnUsedAnnualLeave(Long employeeId, Date contractEndDate) {
+        log.info("设置应休未休剩余年假>>>nckd.jxccl.hr.htm.plugin.form.quitapply.QuitApplyFormPlugin.setUnUsedAnnualLeave");
         // 获取人员考勤档案
-        String attFileSerializedString = DispatchServiceHelper.invokeService("nckd.jxccl.wtc.wtp.servicehelper", QuitApplyConstant.WTP_APP, "IWTPCustomerService", "getAttFile", new Object[]{contractEndDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), employeeId});
-        if (attFileSerializedString == null) {
+        //String attFileSerializedString = DispatchServiceHelper.invokeService("nckd.jxccl.wtc.wtp.servicehelper", QuitApplyConstant.WTP_APP, "IWTPCustomerService", "getAttFile", new Object[]{contractEndDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), employeeId});
+        Object attFileObj = HRMServiceHelper.invokeBizService(QuitApplyConstant.WTC_CLOUD, QuitApplyConstant.WTBS_APP, "IAttFileQueryService", "attFileQuery", new Object[]{contractEndDate, employeeId});
+        log.info("设置应休未休剩余年假>>>attFileObj:::"+attFileObj);
+        if (attFileObj == null) {
             getView().showTipNotification("未获取到应休未休剩余年假,请检查离职人员是否存在离职时间内有效的考勤档案");
             return;
         }
-        Map<String, Object> attFile = SerializationUtils.fromJsonString(attFileSerializedString, HashMap.class);
+        Map<String, Object> attFile = SerializationUtils.fromJsonString(SerializationUtils.toJsonString(attFileObj), HashMap.class);
 
-        List<DynamicObject> quotaList = DispatchServiceHelper.invokeService("nckd.jxccl.wtc.wtp.servicehelper", QuitApplyConstant.WTP_APP, "IWTPCustomerService", "queryQuota", new Object[]{attFile.get("boId"), Collections.singletonList(1666695290893207552L), 0, contractEndDate, contractEndDate});
+        List<DynamicObject> quotaList = HRMServiceHelper.invokeBizService(QuitApplyConstant.WTC_CLOUD, QuitApplyConstant.WTP_APP, "IQTService", "queryQuota", new Object[]{attFile.get("boId"), Collections.singletonList(1666695290893207552L), 0, contractEndDate, contractEndDate});
+        //List<DynamicObject> quotaList = DispatchServiceHelper.invokeService("nckd.jxccl.wtc.wtp.servicehelper", QuitApplyConstant.WTP_APP, "IWTPCustomerService", "queryQuota", new Object[]{attFile.get("boId"), Collections.singletonList(1666695290893207552L), 0, contractEndDate, contractEndDate});
+        log.info("设置应休未休剩余年假>>>quotaList.size:::"+(quotaList.isEmpty() ? 0 : quotaList.size()));
         if (quotaList != null && !quotaList.isEmpty()) {
-            DynamicObject quotaDy = quotaList.get(0);
-            getModel().setValue(QuitApplyConstant.NCKD_UNUSEDANNUALLEAVE_KEY, quotaDy.getBigDecimal(QuitApplyConstant.USABLEVALUE_KEY));
+            BigDecimal quota = BigDecimal.ZERO;
+            for (DynamicObject quotaDy : quotaList) {
+                quota = quota.add(quotaDy.getBigDecimal(QuitApplyConstant.USABLEVALUE_KEY) == null ? BigDecimal.ZERO : quotaDy.getBigDecimal(QuitApplyConstant.USABLEVALUE_KEY));
+            }
+            getModel().setValue(QuitApplyConstant.NCKD_UNUSEDANNUALLEAVE_KEY, quota);
         } else {
             getModel().setValue(QuitApplyConstant.NCKD_UNUSEDANNUALLEAVE_KEY, 0);
         }

+ 10 - 5
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/psms/plugin/operate/contribution/ContribBillOpPlugin.java

@@ -21,6 +21,7 @@ import nckd.jxccl.base.common.utils.ConvertUtil;
 import nckd.jxccl.base.common.utils.StrFormatter;
 import nckd.jxccl.hr.psms.common.ContributionConstant;
 import nckd.jxccl.hr.psms.helper.ContributionHelper;
+import org.apache.commons.lang3.StringUtils;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -131,11 +132,15 @@ public class ContribBillOpPlugin extends AbstractOperationServicePlugIn implemen
 
     @Override
     public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
-        for (DynamicObject data : e.getDataEntities()) {
-            int participants = data.getInt(ContributionConstant.NCKD_PARTICIPANTS);
-            DynamicObjectCollection dynamicObjectCollection = data.getDynamicObjectCollection(FormConstant.NCKD_ENTRYENTITY);
-            if(participants != dynamicObjectCollection.size()){
-                e.cancel = !this.showInteractionMessage(participants,dynamicObjectCollection.size());
+        //来源导入
+        String variableValue = this.getOption().getVariableValue("importtype", StringUtils.EMPTY);
+        if(StringUtils.isBlank(variableValue)) {
+            for (DynamicObject data : e.getDataEntities()) {
+                int participants = data.getInt(ContributionConstant.NCKD_PARTICIPANTS);
+                DynamicObjectCollection dynamicObjectCollection = data.getDynamicObjectCollection(FormConstant.NCKD_ENTRYENTITY);
+                if (participants != dynamicObjectCollection.size()) {
+                    e.cancel = !this.showInteractionMessage(participants, dynamicObjectCollection.size());
+                }
             }
         }
     }

+ 5 - 0
code/hrmp/nckd-jxccl-hrmp/src/main/java/nckd/jxccl/hrmp/hbpm/business/hr/service/impl/PositionBillServiceHelper.java

@@ -53,6 +53,7 @@ import org.apache.commons.lang3.time.DateUtils;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -199,6 +200,10 @@ public class PositionBillServiceHelper {
         return EntityMetadataCache.getDataEntityType(PositionBillConstant.HBPM_POSITIONHR).getProperties().stream().map(IDataEntityProperty::getName).collect(Collectors.toSet());
     }
 
+    public static Set<String> getPositionAllFields() {
+        return new HashSet<String>(EntityMetadataCache.getDataEntityType(PositionBillConstant.HBPM_POSITIONHR).getAllFields().keySet());
+    }
+
     /**
      * 获取分录序号
      * @param iDataModel

+ 59 - 12
code/hrmp/nckd-jxccl-hrmp/src/main/java/nckd/jxccl/hrmp/hbpm/plugin/form/hr/PositionAssignFormPlugin.java

@@ -3,6 +3,7 @@ package nckd.jxccl.hrmp.hbpm.plugin.form.hr;
 import kd.bos.dataentity.OperateOption;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.entity.EntityType;
 import kd.bos.entity.operate.OperateOptionConst;
 import kd.bos.entity.operate.result.IOperateInfo;
 import kd.bos.entity.operate.result.OperationResult;
@@ -15,8 +16,10 @@ import kd.bos.servicehelper.operation.OperationServiceHelper;
 import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
 import kd.hr.hbp.common.util.HRDateTimeUtils;
 import kd.hr.hbp.common.util.HRDynamicObjectUtils;
+import kd.hr.hbp.common.util.HRObjectUtils;
 import kd.hr.hbp.common.util.HRStringUtils;
 import nckd.jxccl.base.common.utils.QueryFieldBuilder;
+import nckd.jxccl.hrmp.hbpm.business.hr.service.impl.PositionBillServiceHelper;
 import nckd.jxccl.hrmp.hbpm.common.hr.PositionBillConstant;
 import nckd.jxccl.hrmp.hbpm.common.hr.PositionHRConstant;
 
@@ -26,6 +29,7 @@ import java.util.EventObject;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -133,25 +137,49 @@ public class PositionAssignFormPlugin extends AbstractFormPlugin {
 
     private void confirm(Map<Long, DynamicObject> positionDyMap) {
         DynamicObjectCollection entryEntityDyoColl = getModel().getDataEntity(true).getDynamicObjectCollection(PositionHRConstant.NCKD_ENTRYENTITY);
+        // 获取所有单据体 属性
+        Set<String> entryFields = ((EntityType) entryEntityDyoColl.getDynamicObjectType()).getFields().keySet();
+        // 获取所有岗位属性
+        Set<String> positionFields = PositionBillServiceHelper.getPositionAllFields();
+        // 获取岗位要转换的键值,页面字段: 岗位字段
+        Map<String, String> posAssignReverseTransKeyMap = getPosAssignTransKeyMap().entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey, (oldValue, newValue) -> newValue));
         List<DynamicObject> dataEntities = new ArrayList<DynamicObject>();
         HRBaseServiceHelper positionServiceHelper = HRBaseServiceHelper.create(PositionHRConstant.HBPM_POSITIONHR);
         String orgId = "";
         for (DynamicObject entryEntityDy : entryEntityDyoColl) {
             DynamicObject newDyo = positionServiceHelper.generateEmptyDynamicObject();
-            HRDynamicObjectUtils.copy(positionDyMap.get(entryEntityDy.getLong(PositionHRConstant.ID_KEY)), newDyo);
+            DynamicObject dbPositionDy = positionDyMap.get(entryEntityDy.getLong(PositionHRConstant.ID_KEY));
+            HRDynamicObjectUtils.copy(dbPositionDy, newDyo);
+
+            // 设置 变更值到要新增的岗位数据中
+            for (String entryField : entryFields) {
+                String positionField = posAssignReverseTransKeyMap.getOrDefault(entryField, entryField);
+                // 如果岗位中不存在该属性则忽略
+                if (!positionFields.contains(positionField)) {
+                    continue;
+                }
+
+                Object oldValue = dbPositionDy.get(positionField);
+                Object newValue = entryEntityDy.get(entryField);
+                boolean isChange;
+                if (HRObjectUtils.isEmpty(oldValue) && HRObjectUtils.isEmpty(newValue)) {
+                    isChange = false;
+                } else if ((!HRObjectUtils.isEmpty(oldValue) && HRObjectUtils.isEmpty(newValue)) || (HRObjectUtils.isEmpty(oldValue) && !HRObjectUtils.isEmpty(newValue))) {
+                    isChange = true;
+                } else {
+                    isChange = !HRDynamicObjectUtils.compareValues(newValue, oldValue);
+                }
+
+                if (isChange) {
+                    newDyo.set(positionField, newValue);
+                }
+            }
+
             // 重置ID
             newDyo.set(PositionHRConstant.ID_KEY, null);
             newDyo.set(PositionHRConstant.BOID_KEY, null);
-            // 设置 行政组织
-            newDyo.set(PositionHRConstant.ADMINORG, entryEntityDy.get(PositionHRConstant.NCKD_ADMINORG));
-            // 设置 上级岗位
-            newDyo.set(PositionHRConstant.PARENT_KEY, entryEntityDy.get(PositionHRConstant.NCKD_PARENT_KEY));
-            // 设置 岗级
-            newDyo.set(PositionHRConstant.NCKD_POSTGRADE_KEY, entryEntityDy.get(PositionHRConstant.NCKD_POSTGRADE_KEY));
-            // 设置 管理层级细项
-            newDyo.set(PositionHRConstant.NCKD_MGTLVLDTL_KEY, entryEntityDy.get(PositionHRConstant.NCKD_MGTLVLDTL_KEY));
-            // 设置 法人岗位层级
-            newDyo.set(PositionHRConstant.NCKD_LEGPOSTLV_KEY, entryEntityDy.get(PositionHRConstant.NCKD_LEGPOSTLV_KEY));
+            // 设置 生效日期为设立日期
+            newDyo.set(PositionHRConstant.BSED_KEY, newDyo.get(PositionHRConstant.NCKD_ESTABLISHMENTDATE_KEY));
             // 设置编码
             orgId = newDyo.getString(String.join(".", PositionHRConstant.ORG_KEY, PositionHRConstant.ID_KEY));
             String positionNumber = CodeRuleServiceHelper.getNumber(PositionHRConstant.HBPM_POSITIONHR, newDyo, orgId);
@@ -184,7 +212,26 @@ public class PositionAssignFormPlugin extends AbstractFormPlugin {
             return;
         }
 
-        OperationServiceHelper.executeOperate(PositionHRConstant.SAVE_OP, PositionBillConstant.HBPM_POSITIONHR, dataEntities.toArray(new DynamicObject[0]));
+        operationResult = OperationServiceHelper.executeOperate(PositionHRConstant.SAVE_OP, PositionBillConstant.HBPM_POSITIONHR, dataEntities.toArray(new DynamicObject[0]));
+        if (!operationResult.isSuccess()) {
+            for(IOperateInfo operateInfo : operationResult.getAllErrorOrValidateInfo()) {
+                errorMsgList.add(operateInfo.getMessage());
+            }
+
+            if (HRStringUtils.isNotBlank(operationResult.getMessage())) {
+                errorMsgList.add(operationResult.getMessage());
+            }
+
+            // 回收编码
+            String[] numbers = dataEntities.stream().map(data -> data.getString(PositionHRConstant.NUMBER_KEY)).toArray(String[]::new);
+            CodeRuleServiceHelper.recycleBatchNumber(PositionHRConstant.HBPM_POSITIONHR, dataEntities.toArray(new DynamicObject[0]), orgId, numbers);
+        }
+
+        if (!errorMsgList.isEmpty()) {
+            getView().showMessage(null ,String.join(System.lineSeparator(), errorMsgList), MessageTypes.Default);
+            return;
+        }
+
         getView().returnDataToParent("true");
         getView().close();
     }

+ 0 - 1
code/hrmp/nckd-jxccl-hrmp/src/main/java/nckd/jxccl/hrmp/hbpm/plugin/operate/hr/PositionBillEffectOpPlugin.java

@@ -66,7 +66,6 @@ public class PositionBillEffectOpPlugin extends AbstractOperationServicePlugIn {
 
         DynamicObject[] bills = e.getDataEntities();
         Set<Long> billIds = Sets.newHashSetWithExpectedSize(bills.length);
-        billIds = null;
 
         for(DynamicObject bill : bills) {
             billIds.add(bill.getLong(PositionBillConstant.ID_KEY));

+ 4 - 2
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/mas/plugin/form/structappr/EntleaderAnlSalStdFormPlugin.java

@@ -39,8 +39,10 @@ public class EntleaderAnlSalStdFormPlugin extends AbstractStructApprFormPlugin i
         DynamicObjectCollection entryCollection = this.getModel().getEntryEntity(FormConstant.NCKD_ENTRYENTITY);
         for (int rowIndex = 0; rowIndex < entryCollection.size(); rowIndex++) {
             DynamicObject entry = entryCollection.get(rowIndex);
-            int installmentYears = entry.getInt(MasConstant.NCKD_INSTALLMENTYEARS);
-            initOperateOption(installmentYears,rowIndex);
+            if(entry.get(MasConstant.NCKD_INSTALLMENTYEARS) != null) {
+                int installmentYears = entry.getInt(MasConstant.NCKD_INSTALLMENTYEARS);
+                initOperateOption(installmentYears, rowIndex);
+            }
         }
     }