|
@@ -0,0 +1,448 @@
|
|
|
|
|
+package nckd.jxccl.opmc.pm.plugin.operate.cycle;
|
|
|
|
|
+
|
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
|
+import kd.bos.algo.Algo;
|
|
|
|
|
+import kd.bos.algo.AlgoContext;
|
|
|
|
|
+import kd.bos.algo.DataSet;
|
|
|
|
|
+import kd.bos.algo.Row;
|
|
|
|
|
+import kd.bos.bd.pojo.CtrlStrategyEnum;
|
|
|
|
|
+import kd.bos.common.enums.EnableEnum;
|
|
|
|
|
+import kd.bos.consts.PermItemConst;
|
|
|
|
|
+import kd.bos.context.RequestContext;
|
|
|
|
|
+import kd.bos.dataentity.OperateOption;
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
|
|
+import kd.bos.entity.QueryEntityType;
|
|
|
|
|
+import kd.bos.entity.operate.OperateOptionConst;
|
|
|
|
|
+import kd.bos.entity.operate.result.IOperateInfo;
|
|
|
|
|
+import kd.bos.entity.operate.result.OperationResult;
|
|
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
|
|
+import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
|
|
|
+import kd.bos.entity.plugin.args.RollbackOperationArgs;
|
|
|
|
|
+import kd.bos.ext.hr.service.query.QueryEntityHelper;
|
|
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
|
+import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
|
|
+import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
|
+import kd.hr.hbp.common.model.AuthorizedOrgResultWithSub;
|
|
|
|
|
+import kd.hr.hbp.common.model.OrgSubInfo;
|
|
|
|
|
+import kd.sdk.hr.hbp.business.helper.permission.HRPermissionServiceHelper;
|
|
|
|
|
+import kd.sdk.plugin.Plugin;
|
|
|
|
|
+import nckd.jxccl.base.common.constant.FormConstant;
|
|
|
|
|
+import nckd.jxccl.base.common.constant.SystemQueryConstant;
|
|
|
|
|
+import nckd.jxccl.base.common.enums.AppraisalResultEnum;
|
|
|
|
|
+import nckd.jxccl.base.common.exception.ValidationException;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.DateUtil;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.QueryFieldBuilder;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.StrFormatter;
|
|
|
|
|
+import nckd.jxccl.base.entity.helper.EntityHelper;
|
|
|
|
|
+import nckd.jxccl.base.orm.helper.QFilterCommonHelper;
|
|
|
|
|
+import nckd.jxccl.opmc.pm.common.PerfManagerFormConstant;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.HashSet;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.StringJoiner;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+* 周期生成
|
|
|
|
|
+* 实体标识:nckd_cyclegenerate
|
|
|
|
|
+* @author W.Y.C
|
|
|
|
|
+* @date 2025/11/5 17:10
|
|
|
|
|
+* @version 1.0
|
|
|
|
|
+*/
|
|
|
|
|
+public class CycleGenerateOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
|
|
+ //获取待生成新周期人员
|
|
|
|
|
+ Map<Long, PerfManagerSaveOpPlugin.PersonPerfInfo> pendingCyclePersonnelMap = getPendingCyclePersonnel();
|
|
|
|
|
+ List<Long> perfManagerId = pendingCyclePersonnelMap.values().stream()
|
|
|
|
|
+ .map(PerfManagerSaveOpPlugin.PersonPerfInfo::getId)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //先结束当前周期
|
|
|
|
|
+ QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
|
|
|
|
|
+ .add(FormConstant.ID_KEY)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_WHYEND)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_WAGEEXPLAIN)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_THESTATUS)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_ACTENDYEAR)
|
|
|
|
|
+ .addIdNumberName(FormConstant.NCKD_PERSON);
|
|
|
|
|
+
|
|
|
|
|
+ QFilter filter = QFilterCommonHelper.getIdInFilter(perfManagerId);
|
|
|
|
|
+ DynamicObject[] dbPerfManagerArray = BusinessDataServiceHelper.load(PerfManagerFormConstant.PERFMANAGER_ENTITYID, queryFieldBuilder.buildSelect(), new QFilter[]{filter});
|
|
|
|
|
+ for (DynamicObject dbPerfManager : dbPerfManagerArray) {
|
|
|
|
|
+ long personId = dbPerfManager.getDynamicObject(FormConstant.NCKD_PERSON).getLong(FormConstant.ID_KEY);
|
|
|
|
|
+ PerfManagerSaveOpPlugin.PersonPerfInfo personPerfInfo = pendingCyclePersonnelMap.get(personId);
|
|
|
|
|
+ //结束原因
|
|
|
|
|
+ dbPerfManager.set(PerfManagerFormConstant.NCKD_WHYEND, personPerfInfo.getWhyEnd());
|
|
|
|
|
+ dbPerfManager.set(PerfManagerFormConstant.NCKD_THESTATUS, "3");
|
|
|
|
|
+ //实际结束时间(如果endYear大于当前时间(年)则使用endYear否则使用当前时间(年))
|
|
|
|
|
+ dbPerfManager.set(PerfManagerFormConstant.NCKD_ACTENDYEAR,DateUtil.toDate(personPerfInfo.getActEndYear()));
|
|
|
|
|
+ }
|
|
|
|
|
+ SaveServiceHelper.update(dbPerfManagerArray);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //调用save-op
|
|
|
|
|
+ List<DynamicObject> savePerfManager = new ArrayList<>();
|
|
|
|
|
+ for (PerfManagerSaveOpPlugin.PersonPerfInfo value : pendingCyclePersonnelMap.values()) {
|
|
|
|
|
+ DynamicObject newPerfManager = EntityHelper.newAvailableBasicEntity(PerfManagerFormConstant.PERFMANAGER_ENTITYID);
|
|
|
|
|
+ String personName = value.getPerson().getString(FormConstant.NAME_KEY);
|
|
|
|
|
+ newPerfManager.set(FormConstant.NCKD_PERSON, value.getPerson());
|
|
|
|
|
+ newPerfManager.set(PerfManagerFormConstant.NCKD_BEGINYEAR, DateUtil.toDate(value.getBeginYear()));
|
|
|
|
|
+ newPerfManager.set(PerfManagerFormConstant.NCKD_ENDYEAR, DateUtil.toDate(value.getEndYear()));
|
|
|
|
|
+ newPerfManager.set(PerfManagerFormConstant.DESCRIPTION_KEY, value.getDescription());
|
|
|
|
|
+ newPerfManager.set(PerfManagerFormConstant.CTRLSTRATEGY_KEY, CtrlStrategyEnum.GLOBAL_SHARE.getCtrlStrategy());
|
|
|
|
|
+ newPerfManager.set(FormConstant.NAME_KEY, StrFormatter.format("【{}】{}~{}的考核周期",personName,value.getBeginYear().getYear(),value.getEndYear().getYear()));
|
|
|
|
|
+ savePerfManager.add(newPerfManager);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(savePerfManager.isEmpty()){
|
|
|
|
|
+ this.operationResult.setShowMessage(true);
|
|
|
|
|
+ this.operationResult.setSuccess(false);
|
|
|
|
|
+ this.operationResult.setMessage("生成周期完成,本次没有需要生成周期的人员");
|
|
|
|
|
+ this.operationResult.setMessageType(1);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ OperateOption option = OperateOption.create();
|
|
|
|
|
+ option.setVariableValue(OperateOptionConst.IGNOREINTERACTION, Boolean.TRUE + "");
|
|
|
|
|
+ OperationResult operationResult = OperationServiceHelper.executeOperate(FormConstant.SAVE_OP, PerfManagerFormConstant.PERFMANAGER_ENTITYID, savePerfManager.toArray(new DynamicObject[0]), option);
|
|
|
|
|
+
|
|
|
|
|
+ if (!operationResult.isSuccess()) {
|
|
|
|
|
+ StringJoiner errorMsg = new StringJoiner(StrFormatter.LINE_SEPARATOR);
|
|
|
|
|
+ for (IOperateInfo error : operationResult.getAllErrorOrValidateInfo()) {
|
|
|
|
|
+ errorMsg.add(error.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new ValidationException(errorMsg.toString());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //周期生成成功,以下是本次周期生成的人员:
|
|
|
|
|
+ this.operationResult.setSuccess(true);
|
|
|
|
|
+ StringJoiner msg = new StringJoiner(StrFormatter.LINE_SEPARATOR);
|
|
|
|
|
+ msg.add(StrFormatter.format("周期生成成功,本次生成人数【{}】人,以下是本次周期生成的人员:",savePerfManager.size()));
|
|
|
|
|
+ AtomicInteger index = new AtomicInteger(1);
|
|
|
|
|
+ for (PerfManagerSaveOpPlugin.PersonPerfInfo value : pendingCyclePersonnelMap.values()) {
|
|
|
|
|
+ String personName = value.getPerson().getString(FormConstant.NAME_KEY);
|
|
|
|
|
+ String description = value.getDescription();
|
|
|
|
|
+ msg.add(StrFormatter.format("{}、【{}】{}",index.getAndIncrement(),personName,value.getWhyEnd()));
|
|
|
|
|
+ }
|
|
|
|
|
+ this.operationResult.setMessage(msg.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取待生成新周期人员
|
|
|
|
|
+ * 入职次年生成:新员工入职后的次年,系统自动生成一个三年考评周期。
|
|
|
|
|
+ * 上年度绩效结果不合格或基本合格:如果员工上年度绩效结果为"基本合格"或"不合格",系统会重算考核周期,生成新的三年考评周期。
|
|
|
|
|
+ * 三年考评周期结束:当一个三年考评周期结束后,次年会自动生成新的三年考评周期。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return: java.util.Map<java.lang.Long, nckd.jxccl.opmc.pm.plugin.operate.cycle.PerfManagerSaveOpPlugin.PersonPerfInfo>
|
|
|
|
|
+ * @author W.Y.C
|
|
|
|
|
+ * @date: 2025/11/06 14:19
|
|
|
|
|
+ */
|
|
|
|
|
+ public static Map<Long, PerfManagerSaveOpPlugin.PersonPerfInfo> getPendingCyclePersonnel() {
|
|
|
|
|
+ LocalDateTime now = DateUtil.beginOfYear(DateUtil.now());
|
|
|
|
|
+ LocalDateTime lastDate = now;
|
|
|
|
|
+ // LocalDateTime lastDate = DateUtil.minusYears(now, 1);
|
|
|
|
|
+ LocalDateTime lastBegin = DateUtil.beginOfYear(lastDate);
|
|
|
|
|
+ LocalDateTime lastEnd = DateUtil.endOfYear(lastDate);
|
|
|
|
|
+
|
|
|
|
|
+ Long currUserId = RequestContext.get().getCurrUserId();
|
|
|
|
|
+
|
|
|
|
|
+ // 在职并去年入职的人员
|
|
|
|
|
+ QFilter newHireFilter = buildNewHireFilter(lastBegin, lastEnd);
|
|
|
|
|
+
|
|
|
|
|
+ // 只处理权限范围内的人员
|
|
|
|
|
+ AuthorizedOrgResultWithSub userAdminOrgWithSub = HRPermissionServiceHelper.getUserAdminOrgsWithSub(
|
|
|
|
|
+ currUserId, "nckd_pm", PerfManagerFormConstant.PERFMANAGER_ENTITYID,
|
|
|
|
|
+ PermItemConst.ITEM_VIEW, "hrpi_empposorgrel.adminorg", new HashMap<>());
|
|
|
|
|
+
|
|
|
|
|
+ if (!userAdminOrgWithSub.isHasAllOrgPerm()) {
|
|
|
|
|
+ List<Long> orgIds = extractOrgIds(userAdminOrgWithSub.getHasPermOrgsWithSub());
|
|
|
|
|
+ newHireFilter.and(String.join(".", FormConstant.HRPI_EMPPOSORGREL, FormConstant.ADMINORG), QCP.in, orgIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, PerfManagerSaveOpPlugin.PersonPerfInfo> personPerfInfoMap = new HashMap<>();
|
|
|
|
|
+ DynamicObjectCollection newHirePersonList = queryNewHirePersons(newHireFilter);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建考核周期查询条件
|
|
|
|
|
+ QFilter perfManagerFilter = buildPerfManagerFilter(userAdminOrgWithSub);
|
|
|
|
|
+ QueryFieldBuilder perfManagerQueryFieldBuilder = buildPerfManagerQueryFieldBuilder();
|
|
|
|
|
+ QueryEntityType perfManagerQueryEntityType = (QueryEntityType) EntityMetadataCache.getDataEntityTypeNoCache("nckd_perfmanager_query");
|
|
|
|
|
+
|
|
|
|
|
+ Set<Long> personIds = new HashSet<>();
|
|
|
|
|
+ try (AlgoContext context = Algo.newContext()) {
|
|
|
|
|
+ // 查询权限范围内的考核周期
|
|
|
|
|
+ DataSet perfManagerQueryDataSet = QueryEntityHelper.getInstance().getQueryDataSet(
|
|
|
|
|
+ perfManagerQueryEntityType, perfManagerQueryFieldBuilder.buildSelectLowerCase(),
|
|
|
|
|
+ new QFilter[]{perfManagerFilter}, perfManagerQueryFieldBuilder.buildOrder());
|
|
|
|
|
+
|
|
|
|
|
+ // 收集所有人员ID
|
|
|
|
|
+ collectPersonIds(personIds, perfManagerQueryDataSet.copy());
|
|
|
|
|
+
|
|
|
|
|
+ // 1、去年入职人员生成周期
|
|
|
|
|
+ generateCycleForNewHires(personPerfInfoMap, newHirePersonList, personIds, now);
|
|
|
|
|
+
|
|
|
|
|
+ // 2、上年度绩效结果不合格或基本合格的人员,并且当前周期是最新的
|
|
|
|
|
+ handleUnqualifiedLastYearResults(personPerfInfoMap, perfManagerQueryDataSet.copy(),
|
|
|
|
|
+ perfManagerQueryFieldBuilder, lastBegin, now);
|
|
|
|
|
+
|
|
|
|
|
+ // 3、上年度无绩效结果(周期开始及结束年份含上年)
|
|
|
|
|
+ handleMissingLastYearResults(personPerfInfoMap, perfManagerQueryDataSet.copy(),
|
|
|
|
|
+ perfManagerQueryFieldBuilder, lastBegin, now);
|
|
|
|
|
+
|
|
|
|
|
+ // 4、三年考评周期结束(周期结束年份为去年,不管有没有结果)
|
|
|
|
|
+ handleEndedThreeYearCycles(personPerfInfoMap, perfManagerQueryDataSet.copy(),
|
|
|
|
|
+ perfManagerQueryFieldBuilder, lastBegin, now);
|
|
|
|
|
+ }
|
|
|
|
|
+ return personPerfInfoMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建新入职员工查询条件
|
|
|
|
|
+ */
|
|
|
|
|
+ private static QFilter buildNewHireFilter(LocalDateTime lastBegin, LocalDateTime lastEnd) {
|
|
|
|
|
+ return new QFilter(String.join(".", FormConstant.HRPI_EMPENTREL, FormConstant.ENTRYDATE), QCP.large_equals, lastBegin)
|
|
|
|
|
+ .and(String.join(".", FormConstant.HRPI_EMPENTREL, FormConstant.ENTRYDATE), QCP.less_equals, lastEnd)
|
|
|
|
|
+ .and(String.join(".", FormConstant.HRPI_EMPENTREL, FormConstant.LABOR_REL_STATUS, FormConstant.IS_HIRED),
|
|
|
|
|
+ QCP.equals, EnableEnum.YES.getCode());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提取组织ID列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private static List<Long> extractOrgIds(List<OrgSubInfo> orgSubInfos) {
|
|
|
|
|
+ return orgSubInfos.stream()
|
|
|
|
|
+ .map(OrgSubInfo::getOrgId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询新入职员工信息
|
|
|
|
|
+ */
|
|
|
|
|
+ private static DynamicObjectCollection queryNewHirePersons(QFilter filter) {
|
|
|
|
|
+ QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
|
|
|
|
|
+ .addIdNumberName(FormConstant.HRPI_EMPLOYEE);
|
|
|
|
|
+ QueryEntityType queryEntityType = (QueryEntityType) EntityMetadataCache.getDataEntityType(SystemQueryConstant.HSPM_ASSIGNMENTQUERY);
|
|
|
|
|
+ return QueryEntityHelper.getInstance().getQueryDyoColl(queryEntityType, queryFieldBuilder.buildSelect(), new QFilter[]{filter}, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建考核周期查询条件
|
|
|
|
|
+ */
|
|
|
|
|
+ private static QFilter buildPerfManagerFilter(AuthorizedOrgResultWithSub userAdminOrgWithSub) {
|
|
|
|
|
+ QFilter perfManagerFilter = QFilter.of("1=1");
|
|
|
|
|
+ if (!userAdminOrgWithSub.isHasAllOrgPerm()) {
|
|
|
|
|
+ List<Long> orgIds = extractOrgIds(userAdminOrgWithSub.getHasPermOrgsWithSub());
|
|
|
|
|
+ perfManagerFilter.and(String.join(".", FormConstant.HRPI_EMPPOSORGREL, FormConstant.ADMINORG), QCP.in, orgIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ return perfManagerFilter;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建考核周期查询字段
|
|
|
|
|
+ */
|
|
|
|
|
+ private static QueryFieldBuilder buildPerfManagerQueryFieldBuilder() {
|
|
|
|
|
+ return QueryFieldBuilder.create()
|
|
|
|
|
+ .add(FormConstant.ID_KEY)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_ISCURRENTNEWEST)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_BEGINYEAR)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_ENDYEAR)
|
|
|
|
|
+ .addIdNumberName(FormConstant.NCKD_PERSON)
|
|
|
|
|
+ .addGroup(new String[]{PerfManagerFormConstant.PERFMANAGERENTRY}, FormConstant.ID_KEY, PerfManagerFormConstant.NCKD_APPRAISALYEAR)
|
|
|
|
|
+ .addIdNumberName(PerfManagerFormConstant.PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALRESULT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 收集所有人员ID
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void collectPersonIds(Set<Long> personIds, DataSet dataSet) {
|
|
|
|
|
+ while (dataSet.hasNext()) {
|
|
|
|
|
+ Row next = dataSet.next();
|
|
|
|
|
+ Long personId = next.getLong(String.join(".", FormConstant.NCKD_PERSON, FormConstant.ID_KEY));
|
|
|
|
|
+ personIds.add(personId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 为新入职员工生成考核周期
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void generateCycleForNewHires(Map<Long, PerfManagerSaveOpPlugin.PersonPerfInfo> personPerfInfoMap,
|
|
|
|
|
+ DynamicObjectCollection newHirePersonList,
|
|
|
|
|
+ Set<Long> personIds,
|
|
|
|
|
+ LocalDateTime now) {
|
|
|
|
|
+ for (DynamicObject person : newHirePersonList) {
|
|
|
|
|
+ long personId = person.getLong(String.join(".", FormConstant.HRPI_EMPLOYEE, FormConstant.ID_KEY));
|
|
|
|
|
+ // 判断是否已有周期,如果有则不生成
|
|
|
|
|
+ if (!personIds.contains(personId)) {
|
|
|
|
|
+ String personName = person.getString(String.join(".", FormConstant.HRPI_EMPLOYEE, FormConstant.NAME_KEY));
|
|
|
|
|
+ DynamicObject cyclePerson = EntityHelper.newEntity(FormConstant.HRPI_EMPLOYEE);
|
|
|
|
|
+ cyclePerson.set(FormConstant.ID_KEY, personId);
|
|
|
|
|
+ cyclePerson.set(FormConstant.NAME_KEY, personName);
|
|
|
|
|
+ PerfManagerSaveOpPlugin.PersonPerfInfo personPerfInfo = new PerfManagerSaveOpPlugin.PersonPerfInfo(
|
|
|
|
|
+ cyclePerson, DateUtil.toDate(now), DateUtil.toDate(DateUtil.addYears(now, 2)), "周期生成(新入职)");
|
|
|
|
|
+ personPerfInfo.setWhyEnd("新入职员工");
|
|
|
|
|
+ personPerfInfoMap.put(personId, personPerfInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理上年度绩效不合格或基本合格的人员
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void handleUnqualifiedLastYearResults(Map<Long, PerfManagerSaveOpPlugin.PersonPerfInfo> personPerfInfoMap,
|
|
|
|
|
+ DataSet perfManagerQueryDataSet,
|
|
|
|
|
+ QueryFieldBuilder perfManagerQueryFieldBuilder,
|
|
|
|
|
+ LocalDateTime lastBegin,
|
|
|
|
|
+ LocalDateTime now) {
|
|
|
|
|
+ DataSet lastYearFailFilter = perfManagerQueryDataSet.copy().filter(
|
|
|
|
|
+ "perfmanagerentry.nckd_appraisalresult.number in ('" + AppraisalResultEnum.UN_QUALIFIED.getCode() + "','" +
|
|
|
|
|
+ AppraisalResultEnum.BASICALLY_QUALIFIED.getCode() + "') " +
|
|
|
|
|
+ "and YEAR(perfmanagerentry.nckd_appraisalyear) = " + lastBegin.getYear() +
|
|
|
|
|
+ " and nckd_iscurrentnewest = true")
|
|
|
|
|
+ .select(perfManagerQueryFieldBuilder.buildSelect());
|
|
|
|
|
+
|
|
|
|
|
+ while (lastYearFailFilter.hasNext()) {
|
|
|
|
|
+ Row next = lastYearFailFilter.next();
|
|
|
|
|
+ Long id = next.getLong(FormConstant.ID_KEY);
|
|
|
|
|
+ Long personId = next.getLong(String.join(".", FormConstant.NCKD_PERSON, FormConstant.ID_KEY));
|
|
|
|
|
+ String personName = next.getString(String.join(".", FormConstant.NCKD_PERSON, FormConstant.NAME_KEY));
|
|
|
|
|
+ String appraisalResult = next.getString(String.join(".", PerfManagerFormConstant.PERFMANAGERENTRY,
|
|
|
|
|
+ PerfManagerFormConstant.NCKD_APPRAISALRESULT, FormConstant.NUMBER_KEY));
|
|
|
|
|
+ Date endYear = next.getDate(PerfManagerFormConstant.NCKD_ENDYEAR);
|
|
|
|
|
+
|
|
|
|
|
+ DynamicObject person = EntityHelper.newEntity(FormConstant.HRPI_EMPLOYEE);
|
|
|
|
|
+ person.set(FormConstant.ID_KEY, personId);
|
|
|
|
|
+ person.set(FormConstant.NAME_KEY, personName);
|
|
|
|
|
+
|
|
|
|
|
+ PerfManagerSaveOpPlugin.PersonPerfInfo personPerfInfo = new PerfManagerSaveOpPlugin.PersonPerfInfo(
|
|
|
|
|
+ person, DateUtil.toDate(now), DateUtil.toDate(DateUtil.addYears(now, 2)), "周期重生成");
|
|
|
|
|
+ personPerfInfo.setId(id);
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime endYearLocalDateTime = DateUtil.toLocalDateTime(endYear);
|
|
|
|
|
+ LocalDateTime actualEndYear = endYearLocalDateTime.getYear() > now.getYear() ? now : endYearLocalDateTime;
|
|
|
|
|
+ personPerfInfo.setActEndYear(actualEndYear);
|
|
|
|
|
+
|
|
|
|
|
+ if (AppraisalResultEnum.UN_QUALIFIED.getCode().equalsIgnoreCase(appraisalResult)) {
|
|
|
|
|
+ personPerfInfo.setWhyEnd("上年度绩效【不合格】");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ personPerfInfo.setWhyEnd("上年度绩效【基本合格】");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ personPerfInfoMap.put(personId, personPerfInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理上年度无绩效结果的人员
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void handleMissingLastYearResults(Map<Long, PerfManagerSaveOpPlugin.PersonPerfInfo> personPerfInfoMap,
|
|
|
|
|
+ DataSet perfManagerQueryDataSet,
|
|
|
|
|
+ QueryFieldBuilder perfManagerQueryFieldBuilder,
|
|
|
|
|
+ LocalDateTime lastBegin,
|
|
|
|
|
+ LocalDateTime now) {
|
|
|
|
|
+ DataSet lastYearNoPerfFilter = perfManagerQueryDataSet.copy().filter(
|
|
|
|
|
+ "YEAR(NCKD_BEGINYEAR) <= " + lastBegin.getYear() +
|
|
|
|
|
+ " AND YEAR(NCKD_ENDYEAR) >= " + lastBegin.getYear() +
|
|
|
|
|
+ " and nckd_iscurrentnewest = true ")
|
|
|
|
|
+ .select(perfManagerQueryFieldBuilder.buildSelect());
|
|
|
|
|
+
|
|
|
|
|
+ // 临时存储人员对应的考核结果。key:personId,Value:考核结果编码
|
|
|
|
|
+ Map<Long, String> personIdAndAppraisalYearMap = new HashMap<>();
|
|
|
|
|
+ Map<Long, String> personIdAndPersonNameMap = new HashMap<>();
|
|
|
|
|
+ Map<Long, Long> personIdAndIdMap = new HashMap<>();
|
|
|
|
|
+ Map<Long, Date> personIdAndEndDateMap = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ while (lastYearNoPerfFilter.hasNext()) {
|
|
|
|
|
+ Row next = lastYearNoPerfFilter.next();
|
|
|
|
|
+ Long id = next.getLong(FormConstant.ID_KEY);
|
|
|
|
|
+ Long personId = next.getLong(String.join(".", FormConstant.NCKD_PERSON, FormConstant.ID_KEY));
|
|
|
|
|
+ String personName = next.getString(String.join(".", FormConstant.NCKD_PERSON, FormConstant.NAME_KEY));
|
|
|
|
|
+ String appraisalResultNumber = next.getString(String.join(".", PerfManagerFormConstant.PERFMANAGERENTRY,
|
|
|
|
|
+ PerfManagerFormConstant.NCKD_APPRAISALRESULT, FormConstant.NUMBER_KEY));
|
|
|
|
|
+ Date appraisalYear = next.getDate(String.join(".", PerfManagerFormConstant.PERFMANAGERENTRY,
|
|
|
|
|
+ PerfManagerFormConstant.NCKD_APPRAISALYEAR));
|
|
|
|
|
+ Date endYear = next.getDate(PerfManagerFormConstant.NCKD_ENDYEAR);
|
|
|
|
|
+
|
|
|
|
|
+ if (appraisalYear == null || lastBegin.getYear() == DateUtil.getYear(appraisalYear)) {
|
|
|
|
|
+ // 没有绩效记录或等于上年度则记录到临时变量
|
|
|
|
|
+ personIdAndAppraisalYearMap.put(personId, appraisalResultNumber);
|
|
|
|
|
+ personIdAndPersonNameMap.put(personId, personName);
|
|
|
|
|
+ personIdAndIdMap.put(personId, id);
|
|
|
|
|
+ personIdAndEndDateMap.put(personId, endYear);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 找出上年度绩效记录为空或等于"无"的人员
|
|
|
|
|
+ List<Long> filteredPersonIds = personIdAndAppraisalYearMap.entrySet().stream()
|
|
|
|
|
+ .filter(entry -> AppraisalResultEnum.NONE.getCode().equals(entry.getValue()) || entry.getValue() == null)
|
|
|
|
|
+ .map(Map.Entry::getKey)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ for (Long filteredPersonId : filteredPersonIds) {
|
|
|
|
|
+ String personName = personIdAndPersonNameMap.get(filteredPersonId);
|
|
|
|
|
+ DynamicObject person = EntityHelper.newEntity(FormConstant.HRPI_EMPLOYEE);
|
|
|
|
|
+ person.set(FormConstant.ID_KEY, filteredPersonId);
|
|
|
|
|
+ person.set(FormConstant.NAME_KEY, personName);
|
|
|
|
|
+
|
|
|
|
|
+ PerfManagerSaveOpPlugin.PersonPerfInfo personPerfInfo = new PerfManagerSaveOpPlugin.PersonPerfInfo(
|
|
|
|
|
+ person, DateUtil.toDate(now), DateUtil.toDate(DateUtil.addYears(now, 2)), "周期重生成");
|
|
|
|
|
+ personPerfInfo.setId(personIdAndIdMap.get(filteredPersonId));
|
|
|
|
|
+ personPerfInfo.setWhyEnd("上年度无绩效结果");
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime endYearLocalDateTime = DateUtil.toLocalDateTime(personIdAndEndDateMap.get(filteredPersonId));
|
|
|
|
|
+ LocalDateTime actualEndYear = endYearLocalDateTime.getYear() > now.getYear() ? now : endYearLocalDateTime;
|
|
|
|
|
+ personPerfInfo.setActEndYear(actualEndYear);
|
|
|
|
|
+
|
|
|
|
|
+ personPerfInfoMap.put(filteredPersonId, personPerfInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理三年考评周期结束的人员
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void handleEndedThreeYearCycles(Map<Long, PerfManagerSaveOpPlugin.PersonPerfInfo> personPerfInfoMap,
|
|
|
|
|
+ DataSet perfManagerQueryDataSet,
|
|
|
|
|
+ QueryFieldBuilder perfManagerQueryFieldBuilder,
|
|
|
|
|
+ LocalDateTime lastBegin,
|
|
|
|
|
+ LocalDateTime now) {
|
|
|
|
|
+ DataSet yearEvalEndFilter = perfManagerQueryDataSet.copy().filter(
|
|
|
|
|
+ "YEAR(nckd_endyear) = " + lastBegin.getYear() + " and nckd_iscurrentnewest = true ")
|
|
|
|
|
+ .select(perfManagerQueryFieldBuilder.buildSelect());
|
|
|
|
|
+
|
|
|
|
|
+ while (yearEvalEndFilter.hasNext()) {
|
|
|
|
|
+ Row next = yearEvalEndFilter.next();
|
|
|
|
|
+ Long id = next.getLong(FormConstant.ID_KEY);
|
|
|
|
|
+ Long personId = next.getLong(String.join(".", FormConstant.NCKD_PERSON, FormConstant.ID_KEY));
|
|
|
|
|
+ String personName = next.getString(String.join(".", FormConstant.NCKD_PERSON, FormConstant.NAME_KEY));
|
|
|
|
|
+ Date endYear = next.getDate(PerfManagerFormConstant.NCKD_ENDYEAR);
|
|
|
|
|
+
|
|
|
|
|
+ if (personPerfInfoMap.get(personId) == null) {
|
|
|
|
|
+ DynamicObject person = EntityHelper.newEntity(FormConstant.HRPI_EMPLOYEE);
|
|
|
|
|
+ person.set(FormConstant.ID_KEY, personId);
|
|
|
|
|
+ person.set(FormConstant.NAME_KEY, personName);
|
|
|
|
|
+
|
|
|
|
|
+ PerfManagerSaveOpPlugin.PersonPerfInfo personPerfInfo = new PerfManagerSaveOpPlugin.PersonPerfInfo(
|
|
|
|
|
+ person, DateUtil.toDate(now), DateUtil.toDate(DateUtil.addYears(now, 2)), "周期重生成");
|
|
|
|
|
+ personPerfInfo.setId(id);
|
|
|
|
|
+ personPerfInfo.setWhyEnd("三年考评周期结束(周期生成)");
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime endYearLocalDateTime = DateUtil.toLocalDateTime(endYear);
|
|
|
|
|
+ LocalDateTime actualEndYear = endYearLocalDateTime.getYear() > now.getYear() ? now : endYearLocalDateTime;
|
|
|
|
|
+ personPerfInfo.setActEndYear(actualEndYear);
|
|
|
|
|
+
|
|
|
|
|
+ personPerfInfoMap.put(personId, personPerfInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|