|
|
@@ -56,10 +56,11 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
|
|
|
public void onAddValidators(AddValidatorsEventArgs e) {
|
|
|
String invoker = (String)this.getOption().getVariables().get(FormConstant.HR_INVOKER_PARAM_INVOKER);
|
|
|
boolean dataMigration = FormConstant.DATA_MIGRATION.equalsIgnoreCase(invoker);
|
|
|
+ boolean isUpdate = ConvertUtil.toBoolean(this.getOption().getVariableValue("isUpdate",StringUtils.EMPTY),Boolean.FALSE);
|
|
|
e.addValidator(new AbstractValidator() {
|
|
|
@Override
|
|
|
public void validate() {
|
|
|
- Boolean isCycleGenerate = ConvertUtil.toBoolean(this.getOption().getVariableValue("cyclegenerate",StringUtils.EMPTY),Boolean.FALSE);
|
|
|
+ Boolean isCycleGenerate = ConvertUtil.toBoolean(this.getOption().getVariableValue("cyclegenerate", StringUtils.EMPTY), Boolean.FALSE);
|
|
|
//第一个循环先获取表单数据,这里需要兼容单人和批量的数据包
|
|
|
Map<Long, List<PersonPerfInfo>> currentBatchData = new HashMap<>();
|
|
|
for (ExtendedDataEntity rowDataEntity : getDataEntities()) {
|
|
|
@@ -77,7 +78,7 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
|
|
|
if (beginYear != null) {
|
|
|
personBeginYearMap.put(personId, beginYear);
|
|
|
}
|
|
|
- if(id > 0) {
|
|
|
+ if (id > 0) {
|
|
|
ids.add(id);
|
|
|
}
|
|
|
|
|
|
@@ -89,34 +90,36 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
|
|
|
|
|
|
currentBatchData.computeIfAbsent(personId, k -> new ArrayList<>()).add(perfInfo);
|
|
|
}
|
|
|
- if(!dataMigration) {
|
|
|
- if (!isCycleGenerate) {
|
|
|
- //检查同一批次内同一人员的周期重叠
|
|
|
- for (Map.Entry<Long, List<PersonPerfInfo>> entry : currentBatchData.entrySet()) {
|
|
|
- List<PersonPerfInfo> personPerfList = entry.getValue();
|
|
|
- if (personPerfList.size() > 1) {
|
|
|
- // 对同一人员的多个周期进行相互比较
|
|
|
- for (int i = 0; i < personPerfList.size(); i++) {
|
|
|
- PersonPerfInfo info1 = personPerfList.get(i);
|
|
|
- for (int j = i + 1; j < personPerfList.size(); j++) {
|
|
|
- PersonPerfInfo info2 = personPerfList.get(j);
|
|
|
- String personName = info2.getPerson().getString(FormConstant.NAME_KEY);
|
|
|
-
|
|
|
- // 检查开始年份是否相同
|
|
|
- if (isSameYear(info1.getBeginYear(), info2.getBeginYear())) {
|
|
|
- addFatalErrorMessage(getDataEntities()[info1.getDataEntityIndex()],
|
|
|
- StrFormatter.format("同批次数据中,人员【{}】存在相同的周期开始年份:{}",
|
|
|
- personName, info1.getBeginYear().getYear()));
|
|
|
- } else {
|
|
|
- // 只有开始年份不相同时才检查重叠
|
|
|
- // 检查周期是否重叠
|
|
|
- String overlapInfo = getCycleOverlapInfo(
|
|
|
- info1.getBeginYear(), info1.getEndYear(), null,
|
|
|
- info2.getBeginYear(), info2.getEndYear(), null);
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(overlapInfo)) {
|
|
|
+ if(!isUpdate) {
|
|
|
+ if (!dataMigration) {
|
|
|
+ if (!isCycleGenerate) {
|
|
|
+ //检查同一批次内同一人员的周期重叠
|
|
|
+ for (Map.Entry<Long, List<PersonPerfInfo>> entry : currentBatchData.entrySet()) {
|
|
|
+ List<PersonPerfInfo> personPerfList = entry.getValue();
|
|
|
+ if (personPerfList.size() > 1) {
|
|
|
+ // 对同一人员的多个周期进行相互比较
|
|
|
+ for (int i = 0; i < personPerfList.size(); i++) {
|
|
|
+ PersonPerfInfo info1 = personPerfList.get(i);
|
|
|
+ for (int j = i + 1; j < personPerfList.size(); j++) {
|
|
|
+ PersonPerfInfo info2 = personPerfList.get(j);
|
|
|
+ String personName = info2.getPerson().getString(FormConstant.NAME_KEY);
|
|
|
+
|
|
|
+ // 检查开始年份是否相同
|
|
|
+ if (isSameYear(info1.getBeginYear(), info2.getBeginYear())) {
|
|
|
addFatalErrorMessage(getDataEntities()[info1.getDataEntityIndex()],
|
|
|
- StrFormatter.format("同批次数据中,人员【{}】存在重叠周期:{}", personName, overlapInfo));
|
|
|
+ StrFormatter.format("同批次数据中,人员【{}】存在相同的周期开始年份:{}",
|
|
|
+ personName, info1.getBeginYear().getYear()));
|
|
|
+ } else {
|
|
|
+ // 只有开始年份不相同时才检查重叠
|
|
|
+ // 检查周期是否重叠
|
|
|
+ String overlapInfo = getCycleOverlapInfo(
|
|
|
+ info1.getBeginYear(), info1.getEndYear(), null,
|
|
|
+ info2.getBeginYear(), info2.getEndYear(), null);
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(overlapInfo)) {
|
|
|
+ addFatalErrorMessage(getDataEntities()[info1.getDataEntityIndex()],
|
|
|
+ StrFormatter.format("同批次数据中,人员【{}】存在重叠周期:{}", personName, overlapInfo));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -169,25 +172,26 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
|
|
|
LocalDateTime dbEndYear = DateUtil.toLocalDateTime(dynamicObject.getDate(PerfManagerFormConstant.NCKD_ENDYEAR));
|
|
|
Date actEndYear = dynamicObject.getDate(PerfManagerFormConstant.NCKD_ACTENDYEAR);
|
|
|
LocalDateTime dbActEndYear = actEndYear != null ? DateUtil.toLocalDateTime(actEndYear) : null;
|
|
|
-
|
|
|
- if(!dataMigration) {
|
|
|
- if (!isCycleGenerate) {
|
|
|
- // 判断周期是否重叠并获取重叠信息,已结束周期使用实际结束时间
|
|
|
- String overlapInfo = getCycleOverlapInfo(beginYear, endYear, null, dbBeginYear, dbEndYear, dbActEndYear);
|
|
|
- if (StringUtils.isNotBlank(overlapInfo)) {
|
|
|
- addFatalErrorMessage(rowDataEntity,
|
|
|
- StrFormatter.format("人员【{}】的考核周期与已有周期在{}重叠,请检查!",
|
|
|
- personName, overlapInfo));
|
|
|
+ if(!isUpdate) {
|
|
|
+ if (!dataMigration) {
|
|
|
+ if (!isCycleGenerate) {
|
|
|
+ // 判断周期是否重叠并获取重叠信息,已结束周期使用实际结束时间
|
|
|
+ String overlapInfo = getCycleOverlapInfo(beginYear, endYear, null, dbBeginYear, dbEndYear, dbActEndYear);
|
|
|
+ if (StringUtils.isNotBlank(overlapInfo)) {
|
|
|
+ addFatalErrorMessage(rowDataEntity,
|
|
|
+ StrFormatter.format("人员【{}】的考核周期与已有周期在{}重叠,请检查!",
|
|
|
+ personName, overlapInfo));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //判断beginYear和dbBeginYear的年份是否相同
|
|
|
- if (isSameYear(beginYear, dbBeginYear)) {
|
|
|
- addFatalErrorMessage(rowDataEntity,
|
|
|
- StrFormatter.format("人员【{}】已经存在周期开始年份【{}】的周期,无需进行创建。",
|
|
|
- personName,
|
|
|
- beginYear.getYear()));
|
|
|
+ //判断beginYear和dbBeginYear的年份是否相同
|
|
|
+ if (isSameYear(beginYear, dbBeginYear)) {
|
|
|
+ addFatalErrorMessage(rowDataEntity,
|
|
|
+ StrFormatter.format("人员【{}】已经存在周期开始年份【{}】的周期,无需进行创建。",
|
|
|
+ personName,
|
|
|
+ beginYear.getYear()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//当前周期必须大于之前周期的开始时间
|