|
|
@@ -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();
|
|
|
}
|