|
@@ -0,0 +1,204 @@
|
|
|
|
|
+package nckd.jxccl.hr.hspm.plugin.form.tsapp.validator;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
|
|
+import kd.bos.util.CollectionUtils;
|
|
|
|
|
+import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
|
|
|
|
|
+import kd.hr.hbp.common.util.HRStringUtils;
|
|
|
|
|
+import kd.hr.impt.common.dto.ImportLog;
|
|
|
|
|
+import kd.hr.impt.common.dto.ImportRowErrorLog;
|
|
|
|
|
+import kd.hr.impt.common.enu.ValidatorOrderEnum;
|
|
|
|
|
+import kd.hrmp.hies.multientry.common.dto.EntryImptBillData;
|
|
|
|
|
+import kd.hrmp.hies.multientry.core.validate.AbstractEntryValidateHandler;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.QueryFieldBuilder;
|
|
|
|
|
+import nckd.jxccl.hr.hspm.common.TitleSkillAppointConstant;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @entity:
|
|
|
|
|
+ * @author: jtd
|
|
|
|
|
+ * @date: 2026/1/14 22:20
|
|
|
|
|
+ */
|
|
|
|
|
+public class TitleSkillAppointEntryImportValidator extends AbstractEntryValidateHandler {
|
|
|
|
|
+ /** 员工职称信息基础服务 */
|
|
|
|
|
+ private static final HRBaseServiceHelper empNtitleHelper = new HRBaseServiceHelper(TitleSkillAppointConstant.NCKD_HRPI_NTITLE_ENTITY);
|
|
|
|
|
+ /** 员工技能信息-基础服务 */
|
|
|
|
|
+ private static final HRBaseServiceHelper empSkillHelper = new HRBaseServiceHelper(TitleSkillAppointConstant.NCKD_HRPI_EMPSKILL_ENTITY);
|
|
|
|
|
+ /** 职称资格级别技能等级-基础服务 */
|
|
|
|
|
+ private static final HRBaseServiceHelper titleSkillLevelHelper = new HRBaseServiceHelper(TitleSkillAppointConstant.NCKD_HBSS_TITLESKLRK_ENTITY);
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ValidatorOrderEnum setValidatorRole() {
|
|
|
|
|
+ return ValidatorOrderEnum.AFTER;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void validate(List<EntryImptBillData> list, ImportLog importLog) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取错误信息
|
|
|
|
|
+ ConcurrentHashMap<String, ConcurrentHashMap<Integer, ImportRowErrorLog>> rowErrors = importLog.getRowErrors();
|
|
|
|
|
+ List<EntryImptBillData> billDataList = list.stream().filter(billData -> {
|
|
|
|
|
+ ConcurrentHashMap<Integer, ImportRowErrorLog> rowError = rowErrors.getOrDefault(billData.getSheetName(), null);
|
|
|
|
|
+ if (Objects.isNull(rowError) || rowError.isEmpty()) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return !rowError.containsKey(billData.getStartIndex());
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ if (billDataList.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> typeItemMap = (Map<String, String>) getCustomParams().get(TitleSkillAppointConstant.NCKD_TYPE_KEY);
|
|
|
|
|
+ Set<Long> employeeIds = billDataList.stream().map(billData -> billData.getData().getJSONObject(billData.getEntryKey()).getJSONObject(TitleSkillAppointConstant.NCKD_EMPLOYEE).getLongValue(TitleSkillAppointConstant.ID_KEY)).collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取职称技能等级
|
|
|
|
|
+ Map<String, Long> titleSkillLevelMap = titleSkillLevelHelper.queryOriginalCollection(String.join(",", TitleSkillAppointConstant.ID_KEY, TitleSkillAppointConstant.NAME_KEY), null, TitleSkillAppointConstant.MODIFY_TIME_KEY)
|
|
|
|
|
+ .stream().collect(Collectors.toMap(
|
|
|
|
|
+ dyo -> dyo.getString(TitleSkillAppointConstant.NAME_KEY),
|
|
|
|
|
+ dyo -> dyo.getLong(TitleSkillAppointConstant.ID_KEY),
|
|
|
|
|
+ (oldValue, newValue) -> newValue)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ String selectFields = QueryFieldBuilder.create()
|
|
|
|
|
+ .add(TitleSkillAppointConstant.ID_KEY)
|
|
|
|
|
+ .add(TitleSkillAppointConstant.EMPLOYEE_KEY, TitleSkillAppointConstant.ID_KEY)
|
|
|
|
|
+ .add(TitleSkillAppointConstant.NCKD_TITLE_KEY)
|
|
|
|
|
+ .add(TitleSkillAppointConstant.NCKD_QUALLEVEL_KEY, TitleSkillAppointConstant.NAME_KEY)
|
|
|
|
|
+ .buildSelect();
|
|
|
|
|
+ QFilter[] filters = new QFilter[]{new QFilter(TitleSkillAppointConstant.EMPLOYEE_KEY, QCP.in, employeeIds)};
|
|
|
|
|
+ // 查询员工职称信息
|
|
|
|
|
+ DynamicObject[] empNtitleDyos = empNtitleHelper.queryOriginalArray(selectFields, filters, TitleSkillAppointConstant.MODIFY_TIME_KEY);
|
|
|
|
|
+ Map<String, Long> empNtitleMap = Arrays.stream(empNtitleDyos).collect(Collectors.toMap(
|
|
|
|
|
+ ntitleDyo -> String.join("##",
|
|
|
|
|
+ ntitleDyo.getString(String.join(".", TitleSkillAppointConstant.EMPLOYEE_KEY, TitleSkillAppointConstant.ID_KEY)),
|
|
|
|
|
+ ntitleDyo.getString(TitleSkillAppointConstant.NCKD_TITLE_KEY),
|
|
|
|
|
+ ntitleDyo.getString(String.join(".", TitleSkillAppointConstant.NCKD_QUALLEVEL_KEY, TitleSkillAppointConstant.NAME_KEY))
|
|
|
|
|
+ ),
|
|
|
|
|
+ ntitleDyo -> ntitleDyo.getLong(TitleSkillAppointConstant.ID_KEY),
|
|
|
|
|
+ (oldValue, newValue) -> newValue
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // 查询员工技能信息
|
|
|
|
|
+ selectFields = QueryFieldBuilder.create()
|
|
|
|
|
+ .add(TitleSkillAppointConstant.ID_KEY)
|
|
|
|
|
+ .add(TitleSkillAppointConstant.EMPLOYEE_KEY, TitleSkillAppointConstant.ID_KEY)
|
|
|
|
|
+ .add(TitleSkillAppointConstant.NCKD_QUALINAME_KEY)
|
|
|
|
|
+ .add(TitleSkillAppointConstant.NCKD_SKILLLEVEL_KEY, TitleSkillAppointConstant.NAME_KEY)
|
|
|
|
|
+ .buildSelect();
|
|
|
|
|
+ DynamicObject[] empSkillDyos = empSkillHelper.queryOriginalArray(selectFields, filters, TitleSkillAppointConstant.MODIFY_TIME_KEY);
|
|
|
|
|
+ Map<String, Long> empSkillMap = Arrays.stream(empSkillDyos).collect(Collectors.toMap(
|
|
|
|
|
+ skillDyo -> String.join("##",
|
|
|
|
|
+ skillDyo.getString(String.join(".", TitleSkillAppointConstant.EMPLOYEE_KEY, TitleSkillAppointConstant.ID_KEY)),
|
|
|
|
|
+ skillDyo.getString(TitleSkillAppointConstant.NCKD_QUALINAME_KEY),
|
|
|
|
|
+ skillDyo.getString(String.join(".", TitleSkillAppointConstant.NCKD_SKILLLEVEL_KEY, TitleSkillAppointConstant.NAME_KEY))
|
|
|
|
|
+ ),
|
|
|
|
|
+ skillDyo -> skillDyo.getLong(TitleSkillAppointConstant.ID_KEY),
|
|
|
|
|
+ (oldValue, newValue) -> newValue
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // 获取字段名称
|
|
|
|
|
+ Map<String, String> entryFieldNameMap = (Map<String, String>) getCustomParams().get("entryFieldNameMap");
|
|
|
|
|
+ // 员工职称信息属性名称
|
|
|
|
|
+ Map<String, String> empNtitleFieldNameMap = (Map<String, String>) getCustomParams().get("empNtitleFieldNameMap");
|
|
|
|
|
+ // 员工技能信息属性名称
|
|
|
|
|
+ Map<String, String> empSkillFieldNameMap = (Map<String, String>) getCustomParams().get("empSkillFieldNameMap");
|
|
|
|
|
+ for (EntryImptBillData billData : billDataList) {
|
|
|
|
|
+ JSONObject entryData = billData.getData().getJSONObject(billData.getEntryKey());
|
|
|
|
|
+ String employeeId = entryData.getJSONObject(TitleSkillAppointConstant.NCKD_EMPLOYEE).getString(TitleSkillAppointConstant.ID_KEY);
|
|
|
|
|
+
|
|
|
|
|
+ // 判断聘任类型是否正确
|
|
|
|
|
+ String typeItemName = entryData.getString(TitleSkillAppointConstant.NCKD_TYPE_KEY);
|
|
|
|
|
+ String typeItemValue = null;
|
|
|
|
|
+ for (Map.Entry<String, String> item : typeItemMap.entrySet()) {
|
|
|
|
|
+ if (item.getValue().equals(typeItemName)) {
|
|
|
|
|
+ typeItemValue = item.getKey();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (HRStringUtils.isBlank(typeItemValue)) {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("“{}”录入有误,请重新录入。", entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_TYPE_KEY, "")));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String[] temp = new String[0];
|
|
|
|
|
+ // 根据聘任类型判断对应列是否有值
|
|
|
|
|
+ if ("1".equals(typeItemValue)) {
|
|
|
|
|
+ String ntitleTemp = entryData.getString(String.join("_", TitleSkillAppointConstant.NCKD_NTITLE_KEY, "temp"));
|
|
|
|
|
+ if (HRStringUtils.isBlank(ntitleTemp)) {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("“{}”为[{}]时,必须录入“{}”。", new Object[]{entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_TYPE_KEY, ""), typeItemName, entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_NTITLE_KEY, "")}));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ temp = ntitleTemp.split("##");
|
|
|
|
|
+ if (temp.length != 2) {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("“{}”录入有误,请重新录入。", entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_NTITLE_KEY, "")));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Long empNtitleId = empNtitleMap.get(String.join("##", employeeId, ntitleTemp));
|
|
|
|
|
+ if (empNtitleId == null || !(empNtitleId > 0)) {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("该员工的“{}”中不存在“{}”为[{}],“{}”为[{}]的记录,请重新录入。", new Object[]{EntityMetadataCache.getDataEntityType(empNtitleHelper.getEntityName()).getDisplayName().getLocaleValue(), empNtitleFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_TITLE_KEY, ""), temp[0], empNtitleFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_QUALLEVEL_KEY, ""), temp[1]}));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject title = new JSONObject(){{put(TitleSkillAppointConstant.ID_KEY, empNtitleId);}};
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_NTITLE_KEY, title);
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject level = new JSONObject();
|
|
|
|
|
+ level.put(TitleSkillAppointConstant.ID_KEY, titleSkillLevelMap.getOrDefault(temp[1], 0L));
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_A_TITLESKLRK_KEY, level);
|
|
|
|
|
+
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_POSTNM_KEY, temp[0]);
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_EMPSKILL_KEY, null);
|
|
|
|
|
+ } else if ("2".equals(typeItemValue)) {
|
|
|
|
|
+ String skillTemp = entryData.getString(String.join("_", TitleSkillAppointConstant.NCKD_EMPSKILL_KEY, "temp"));
|
|
|
|
|
+ if (HRStringUtils.isBlank(skillTemp)) {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("“{}”为[{}]时,必须录入“{}”。", new Object[]{entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_TYPE_KEY, ""), typeItemName, entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_EMPSKILL_KEY, "")}));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ temp = skillTemp.split("##");
|
|
|
|
|
+ if (temp.length != 2) {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("“{}”录入有误,请重新录入。", entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_EMPSKILL_KEY, "")));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Long empSkillId = empSkillMap.get(String.join("##", employeeId, skillTemp));
|
|
|
|
|
+ if (empSkillId == null || !(empSkillId > 0)) {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("该员工的“{}”中不存在“{}”为[{}],“{}”为[{}]的记录,请重新录入。", new Object[]{EntityMetadataCache.getDataEntityType(empSkillHelper.getEntityName()).getDisplayName().getLocaleValue(), empSkillFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_QUALINAME_KEY, ""), temp[0], empSkillFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_SKILLLEVEL_KEY, ""), temp[1]}));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject skill = new JSONObject(){{put(TitleSkillAppointConstant.ID_KEY, empSkillId);}};
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_EMPSKILL_KEY, skill);
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject level = new JSONObject();
|
|
|
|
|
+ level.put(TitleSkillAppointConstant.ID_KEY, titleSkillLevelMap.getOrDefault(temp[1], 0L));
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_A_TITLESKLRK_KEY, level);
|
|
|
|
|
+
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_POSTNM_KEY, temp[0]);
|
|
|
|
|
+ entryData.put(TitleSkillAppointConstant.NCKD_NTITLE_KEY, null);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ importLog.writeRowLog(billData.getSheetName(), billData.getStartIndex(), billData.getEndIndex(), HRStringUtils.format("“{}”录入有误,请联系管理员处理。", new Object[]{entryFieldNameMap.getOrDefault(TitleSkillAppointConstant.NCKD_TYPE_KEY, "")}));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|