|
@@ -0,0 +1,436 @@
|
|
|
|
|
+package nckd.jxccl.opmc.pm.plugin.operate.salary;
|
|
|
|
|
+
|
|
|
|
|
+import kd.bos.algo.Algo;
|
|
|
|
|
+import kd.bos.algo.AlgoContext;
|
|
|
|
|
+import kd.bos.algo.DataSet;
|
|
|
|
|
+import kd.bos.algo.Row;
|
|
|
|
|
+import kd.bos.common.enums.EnableEnum;
|
|
|
|
|
+import kd.bos.consts.PermItemConst;
|
|
|
|
|
+import kd.bos.context.RequestContext;
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
|
|
+import kd.bos.entity.QueryEntityType;
|
|
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
|
|
+import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
|
|
|
+import kd.bos.entity.validate.BillStatus;
|
|
|
|
|
+import kd.bos.ext.hr.service.query.QueryEntityHelper;
|
|
|
|
|
+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.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 kd.sdk.swc.hcdm.business.helper.HCDMAdjFileServiceHelper;
|
|
|
|
|
+import nckd.jxccl.base.common.constant.FormConstant;
|
|
|
|
|
+import nckd.jxccl.base.common.enums.AppraisalResultEnum;
|
|
|
|
|
+import nckd.jxccl.base.common.exception.ValidationException;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.ConvertUtil;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.DateUtil;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.QueryFieldBuilder;
|
|
|
|
|
+import nckd.jxccl.base.entity.helper.EntityHelper;
|
|
|
|
|
+import nckd.jxccl.opmc.pm.common.PerfManagerFormConstant;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.Calendar;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.HashSet;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+* 生成调薪
|
|
|
|
|
+* 实体标识:nckd_saladjtracker
|
|
|
|
|
+* @author W.Y.C
|
|
|
|
|
+* @date 2025/11/24 13:14
|
|
|
|
|
+* @version 1.0
|
|
|
|
|
+*/
|
|
|
|
|
+public class SalaryAdjOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
|
|
|
|
|
+
|
|
|
|
|
+ private static final Log logger = LogFactory.getLog(SalaryAdjOpPlugin.class);
|
|
|
|
|
+
|
|
|
|
|
+ // 调薪类型常量
|
|
|
|
|
+ /**不及格降档*/
|
|
|
|
|
+ private static final int TYPE_DEMOTE_FOR_FAIL = -1;
|
|
|
|
|
+ /**及格升档*/
|
|
|
|
|
+ private static final int TYPE_NO_CHANGE = 0; // 不升不降档
|
|
|
|
|
+ /**双优升档*/
|
|
|
|
|
+ private static final int TYPE_PROMOTE_FOR_TWO_EXCELLENT = 1; // 双优升档
|
|
|
|
|
+ /**三及格升档*/
|
|
|
|
|
+ private static final int TYPE_PROMOTE_FOR_THREE_PASS = 2; // 三及格升档
|
|
|
|
|
+ /**双优以及三及格升档*/
|
|
|
|
|
+ private static final int TYPE_PROMOTE_FOR_TWO_EXCELLENT_AND_THREE_PASS = 3; // 双优以及三及格
|
|
|
|
|
+ /**连续两年考核结果为优秀且另一年考核结果为合格及以上*/
|
|
|
|
|
+ private static final int TYPE_PROMOTE_FOR_TWO_EXCELLENT_AND_THREE_PASS_FOR_TWO_YEARS = 4;
|
|
|
|
|
+ /** 岗位工资标准(jt002)*/
|
|
|
|
|
+ private static final Long standardItemId = 2321899710350111744L;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ int passYear = 2018;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Long currUserId = RequestContext.get().getCurrUserId();
|
|
|
|
|
+ // 只处理权限范围内的人员
|
|
|
|
|
+ AuthorizedOrgResultWithSub userAdminOrgWithSub = HRPermissionServiceHelper.getUserAdminOrgsWithSub(
|
|
|
|
|
+ currUserId, "nckd_pm", PerfManagerFormConstant.PERFMANAGER_ENTITYID,
|
|
|
|
|
+ PermItemConst.ITEM_VIEW, "hrpi_empposorgrel.adminorg", new HashMap<>());
|
|
|
|
|
+ // 构建考核周期查询条件
|
|
|
|
|
+ QFilter perfManagerFilter = buildPerfManagerFilter(userAdminOrgWithSub);
|
|
|
|
|
+ QueryFieldBuilder perfManagerQueryFieldBuilder = buildPerfManagerQueryFieldBuilder();
|
|
|
|
|
+ QueryEntityType perfManagerQueryEntityType = (QueryEntityType) EntityMetadataCache.getDataEntityType("nckd_perfmanager_query");
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long,SalaryAdjustmentResult> salaryAdjustmentResultMap = new HashMap<>();
|
|
|
|
|
+ try (AlgoContext context = Algo.newContext()) {
|
|
|
|
|
+ // 查询权限范围内的考核周期
|
|
|
|
|
+ DataSet queryDataSet = QueryEntityHelper.getInstance().getQueryDataSet(
|
|
|
|
|
+ perfManagerQueryEntityType, perfManagerQueryFieldBuilder.buildSelectLowerCase(),
|
|
|
|
|
+ new QFilter[]{perfManagerFilter}, perfManagerQueryFieldBuilder.buildOrder());
|
|
|
|
|
+ queryDataSet.print(true);
|
|
|
|
|
+ while (queryDataSet.hasNext()) {
|
|
|
|
|
+ Row next = queryDataSet.next();
|
|
|
|
|
+ //对应:Personappraisaladminid
|
|
|
|
|
+ long id = next.getLong(FormConstant.ID_KEY);
|
|
|
|
|
+ long personId = next.getLong(String.join(".", FormConstant.NCKD_PERSON, FormConstant.ID_KEY));
|
|
|
|
|
+ LocalDateTime beginDate = DateUtil.toLocalDateTime(next.getDate(PerfManagerFormConstant.NCKD_BEGINYEAR));
|
|
|
|
|
+ int beginYear = beginDate.getYear();
|
|
|
|
|
+ LocalDateTime endDate = DateUtil.toLocalDateTime(next.getDate(PerfManagerFormConstant.NCKD_ENDYEAR));
|
|
|
|
|
+ int endYear = endDate.getYear();
|
|
|
|
|
+ Date actEndDate = next.getDate(PerfManagerFormConstant.NCKD_ACTENDYEAR);
|
|
|
|
|
+ LocalDateTime actEndLocalDateTime = actEndDate != null ? DateUtil.toLocalDateTime(actEndDate) : endDate;
|
|
|
|
|
+ int actEndYear = actEndLocalDateTime.getYear();
|
|
|
|
|
+ String theStatus = next.getString(PerfManagerFormConstant.NCKD_THESTATUS);
|
|
|
|
|
+ if (actEndYear <= passYear) {
|
|
|
|
|
+ logger.info(">>>周期开始时间在上线前!PASS!!");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (theStatus != null && !"1".equals(theStatus)) {
|
|
|
|
|
+ logger.info(">>>周期状态非正常!PASS!!");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ int nowYear = Calendar.getInstance().get(Calendar.YEAR);
|
|
|
|
|
+ if (nowYear < beginYear) {
|
|
|
|
|
+ logger.info(">>>还未到周期开始时间!PASS!!");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //第一年考核结果
|
|
|
|
|
+ String firstYearResultNumber = next.getString(String.join(".", PerfManagerFormConstant.NCKD_FIRSTYEARRESULT, FormConstant.NUMBER_KEY));
|
|
|
|
|
+ AppraisalResultEnum firstYearResult = AppraisalResultEnum.getByCode(firstYearResultNumber);
|
|
|
|
|
+ //第二年考核结果
|
|
|
|
|
+ String secondYearResultNumber = next.getString(String.join(".", PerfManagerFormConstant.NCKD_SECONDYEARRESULT, FormConstant.NUMBER_KEY));
|
|
|
|
|
+ AppraisalResultEnum secondYearResult = AppraisalResultEnum.getByCode(secondYearResultNumber);
|
|
|
|
|
+ //第三年考核结果
|
|
|
|
|
+ String thirdYearResultNumber = next.getString(String.join(".", PerfManagerFormConstant.NCKD_THIRDYEARRESULT, FormConstant.NUMBER_KEY));
|
|
|
|
|
+ AppraisalResultEnum thirdYearResult = AppraisalResultEnum.getByCode(thirdYearResultNumber);
|
|
|
|
|
+
|
|
|
|
|
+ // 计算调薪档次
|
|
|
|
|
+ SalaryAdjustmentResult result = calculateSalaryAdjustmentLevel(firstYearResult, secondYearResult, thirdYearResult, beginYear, endYear);
|
|
|
|
|
+ logger.info("人员ID: {} 的调薪档次为: {},调薪类型: {},调薪说明: {}", personId, result.level, result.type, result.reason);
|
|
|
|
|
+ if(result.level > 0){
|
|
|
|
|
+ salaryAdjustmentResultMap.put(personId, result);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// if(!salaryAdjustmentResultMap.isEmpty()){
|
|
|
|
|
+ DynamicObject standardItem = EntityHelper.newEntity(FormConstant.HSBS_STANDARDITEM);
|
|
|
|
|
+ standardItem.set(FormConstant.ID_KEY, standardItemId);
|
|
|
|
|
+ List<Long> personIds = new ArrayList<>();
|
|
|
|
|
+ personIds.add(2311775636290546688L);
|
|
|
|
|
+ personIds.add(2313784485549715456L);
|
|
|
|
|
+ personIds.add(2313784485549715456L);
|
|
|
|
|
+ personIds.add(2313986306029400064L);
|
|
|
|
|
+ personIds.add(2313986306029400064L);
|
|
|
|
|
+ personIds.add(2313985716754853888L);
|
|
|
|
|
+ personIds.add(2313985716754853888L);
|
|
|
|
|
+ personIds.add(2324801894234460160L);
|
|
|
|
|
+ personIds.add(2321890608861426688L);
|
|
|
|
|
+ personIds.add(2321890608861426688L);
|
|
|
|
|
+ personIds.add(2324801894234460160L);
|
|
|
|
|
+ personIds.add(2311773642125487104L);
|
|
|
|
|
+ personIds.add(2311773642125487104L);
|
|
|
|
|
+ personIds.add(2311775067064774656L);
|
|
|
|
|
+ personIds.add(2311775636290546688L);
|
|
|
|
|
+ personIds.add(2311775067064774656L);
|
|
|
|
|
+ personIds.add(2329770917598607370L);
|
|
|
|
|
+ personIds.add(2330584474036731904L);
|
|
|
|
|
+ personIds.add(2329770917598607370L);
|
|
|
|
|
+ personIds.add(2329770917598607370L);
|
|
|
|
|
+ personIds.add(2330584474036731904L);
|
|
|
|
|
+ personIds.add(2330584474036731904L);
|
|
|
|
|
+ personIds.add(2313985716754853888L);
|
|
|
|
|
+ personIds.add(2313985716754853888L);
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+ params.put("employees", personIds);
|
|
|
|
|
+ List<String> status = new ArrayList<>();
|
|
|
|
|
+ status.add(BillStatus.C.toString());
|
|
|
|
|
+ params.put("status", status);
|
|
|
|
|
+ //获取人员定薪档案
|
|
|
|
|
+ Map<String, Object> result = DispatchServiceHelper.invokeBizService("swc", "hcdm", "IAdjFileInfoService", "queryAdjFileBoByEmp", params);
|
|
|
|
|
+ if(ConvertUtil.toBoolean(result.get("success"))){
|
|
|
|
|
+ List<Map> list = ConvertUtil.toList(result.get("data"), ArrayList::new);
|
|
|
|
|
+ List<Long> adjFileIds = new ArrayList<>();
|
|
|
|
|
+ for (Map map : list) {
|
|
|
|
|
+ Long id = ConvertUtil.toLong(map.get(FormConstant.ID_KEY));
|
|
|
|
|
+ adjFileIds.add(id);
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println();
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
|
|
+ for (Long adjFileId : adjFileIds) {
|
|
|
|
|
+ Map<String, Object> dataItem = new HashMap<>();
|
|
|
|
|
+ // 调薪档案ID
|
|
|
|
|
+ dataItem.put("adjfile", adjFileId);
|
|
|
|
|
+ // 调薪项目ID
|
|
|
|
|
+ dataItem.put("standarditem", standardItemId);
|
|
|
|
|
+ // 查询基准日期
|
|
|
|
|
+ dataItem.put("startdate", new Date());
|
|
|
|
|
+ // 唯一标识
|
|
|
|
|
+ dataItem.put("_uniquecode", "unique"+adjFileId);
|
|
|
|
|
+ dataList.add(dataItem);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ param.put("data", dataList);
|
|
|
|
|
+ //查询定调薪记录
|
|
|
|
|
+ Map<String, Object> lastDecAdjRecords = HCDMAdjFileServiceHelper.getLastDecAdjRecords(param);
|
|
|
|
|
+ if(ConvertUtil.toBoolean(lastDecAdjRecords.get("success"))){
|
|
|
|
|
+ List<Map> datas = ConvertUtil.toList(lastDecAdjRecords.get("data"), ArrayList::new);
|
|
|
|
|
+ for (Map data : datas) {
|
|
|
|
|
+ if(ConvertUtil.toBoolean(data.get("success"))){
|
|
|
|
|
+ List<DynamicObject> adjRecordList = ConvertUtil.toList(data.get("data"), ArrayList::new);
|
|
|
|
|
+ for (DynamicObject dynamicObject : adjRecordList) {
|
|
|
|
|
+ //薪等(01岗、02岗)
|
|
|
|
|
+ DynamicObject salaryGrade = dynamicObject.getDynamicObject("salarygrade");
|
|
|
|
|
+ //薪档(1档、2档)
|
|
|
|
|
+ DynamicObject salaryRank = dynamicObject.getDynamicObject("salaryrank");
|
|
|
|
|
+ // 人员
|
|
|
|
|
+ DynamicObject employee = dynamicObject.getDynamicObject("adjfile").getDynamicObject("employee");
|
|
|
|
|
+ //金额
|
|
|
|
|
+ BigDecimal amount = dynamicObject.getBigDecimal("amount");
|
|
|
|
|
+ SalaryAdjustmentResult salaryAdjustmentResult = salaryAdjustmentResultMap.get(employee.getLong(FormConstant.ID_KEY));
|
|
|
|
|
+ salaryAdjustmentResult.oldStandardItem = standardItem;
|
|
|
|
|
+ salaryAdjustmentResult.oldSalaryGrade = salaryGrade;
|
|
|
|
|
+ salaryAdjustmentResult.oldSalaryRank = salaryRank;
|
|
|
|
|
+ salaryAdjustmentResult.oldAmount = amount;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ logger.error("查询定调薪记录失败");
|
|
|
|
|
+ throw new ValidationException("查询定调薪记录失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ logger.error("获取人员定薪档案失败");
|
|
|
|
|
+ throw new ValidationException("获取人员定薪档案失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据三年的考核结果计算调薪档次
|
|
|
|
|
+ * 1. 考核结果三年合格及以上-上调一档;
|
|
|
|
|
+ * 2. 考核结果连续两年优秀-上调一档;
|
|
|
|
|
+ * 3. 考核结果为不合格-下降一档;
|
|
|
|
|
+ * 4. 连续两年考核结果为优秀且另一年考核结果为合格及以上-上调两档;
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param firstYear 第一年考核结果
|
|
|
|
|
+ * @param secondYear 第二年考核结果
|
|
|
|
|
+ * @param thirdYear 第三年考核结果
|
|
|
|
|
+ * @param beginYear 考核周期开始年份
|
|
|
|
|
+ * @param endYear 考核周期结束年份
|
|
|
|
|
+ * @return 调薪结果对象,包含调薪档次和说明
|
|
|
|
|
+ */
|
|
|
|
|
+ private SalaryAdjustmentResult calculateSalaryAdjustmentLevel(AppraisalResultEnum firstYear, AppraisalResultEnum secondYear, AppraisalResultEnum thirdYear, int beginYear, int endYear) {
|
|
|
|
|
+ // 定义考核等级常量组
|
|
|
|
|
+ final Set<AppraisalResultEnum> EXCELLENT_LEVELS = new HashSet<>(Arrays.asList(AppraisalResultEnum.EXCELLENT, AppraisalResultEnum.DEEMED_EXCELLENT));
|
|
|
|
|
+ final Set<AppraisalResultEnum> QUALIFIED_LEVELS = new HashSet<>(Arrays.asList(AppraisalResultEnum.EXCELLENT, AppraisalResultEnum.DEEMED_EXCELLENT,
|
|
|
|
|
+ AppraisalResultEnum.QUALIFIED, AppraisalResultEnum.DEEMED_QUALIFIED, AppraisalResultEnum.NONE));
|
|
|
|
|
+ final Set<AppraisalResultEnum> UNQUALIFIED_LEVELS = new HashSet<>(Arrays.asList(AppraisalResultEnum.UN_QUALIFIED, AppraisalResultEnum.DEEMED_UNQUALIFIED));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 判断各年份是否存在并获取相应值
|
|
|
|
|
+ boolean isFirstYearPresent = isFirstYearPresent(firstYear);
|
|
|
|
|
+ boolean isSecondYearPresent = isSecondYearPresent(secondYear);
|
|
|
|
|
+ boolean isThirdYearPresent = isThirdYearPresent(thirdYear);
|
|
|
|
|
+
|
|
|
|
|
+ // 判断是否为优秀(包括视同优秀)
|
|
|
|
|
+ boolean isFirstYearExcellent = isFirstYearPresent && EXCELLENT_LEVELS.contains(firstYear);
|
|
|
|
|
+ boolean isSecondYearExcellent = isSecondYearPresent && EXCELLENT_LEVELS.contains(secondYear);
|
|
|
|
|
+ boolean isThirdYearExcellent = isThirdYearPresent && EXCELLENT_LEVELS.contains(thirdYear);
|
|
|
|
|
+
|
|
|
|
|
+ // 判断是否为合格及以上(包括合格、视同合格、无、优秀、视同优秀)
|
|
|
|
|
+ boolean isFirstYearQualifiedOrAbove = isFirstYearPresent && QUALIFIED_LEVELS.contains(firstYear);
|
|
|
|
|
+ boolean isSecondYearQualifiedOrAbove = isSecondYearPresent && QUALIFIED_LEVELS.contains(secondYear);
|
|
|
|
|
+ boolean isThirdYearQualifiedOrAbove = isThirdYearPresent && QUALIFIED_LEVELS.contains(thirdYear);
|
|
|
|
|
+
|
|
|
|
|
+ // 判断是否为不合格(包括视同不合格)
|
|
|
|
|
+ boolean isFirstYearUnqualified = isFirstYearPresent && UNQUALIFIED_LEVELS.contains(firstYear);
|
|
|
|
|
+ boolean isSecondYearUnqualified = isSecondYearPresent && UNQUALIFIED_LEVELS.contains(secondYear);
|
|
|
|
|
+ boolean isThirdYearUnqualified = isThirdYearPresent && UNQUALIFIED_LEVELS.contains(thirdYear);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取每年的具体考核结果名称
|
|
|
|
|
+ String firstYearResultName = isFirstYearPresent ? firstYear.getName() : "无";
|
|
|
|
|
+ String secondYearResultName = isSecondYearPresent ? secondYear.getName() : "无";
|
|
|
|
|
+ String thirdYearResultName = isThirdYearPresent ? thirdYear.getName() : "无";
|
|
|
|
|
+
|
|
|
|
|
+ // 计算具体的年份
|
|
|
|
|
+ int firstYearValue = beginYear;
|
|
|
|
|
+ int secondYearValue = beginYear + 1;
|
|
|
|
|
+ int thirdYearValue = beginYear + 2;
|
|
|
|
|
+
|
|
|
|
|
+ int type = TYPE_NO_CHANGE; // 调薪类型
|
|
|
|
|
+ int level = 0; // 调薪档次
|
|
|
|
|
+ String reason = String.format("未满足调薪条件(%d年:%s,%d年:%s,%d年:%s)",
|
|
|
|
|
+ firstYearValue, firstYearResultName, secondYearValue, secondYearResultName, thirdYearValue, thirdYearResultName); // 调薪原因
|
|
|
|
|
+
|
|
|
|
|
+ // 规则3: 考核结果为不合格-下降一档(最高优先级)
|
|
|
|
|
+ if (isFirstYearUnqualified || isSecondYearUnqualified || isThirdYearUnqualified) {
|
|
|
|
|
+ reason = String.format("考核结果【不合格】【降一档】(%d年:%s,%d年:%s,%d年:%s)",
|
|
|
|
|
+ firstYearValue, firstYearResultName, secondYearValue, secondYearResultName, thirdYearValue, thirdYearResultName);
|
|
|
|
|
+ type = TYPE_DEMOTE_FOR_FAIL;
|
|
|
|
|
+ level = -1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 规则4: 连续两年考核结果为优秀且另一年考核结果为合格及以上-上调两档(次高优先级)
|
|
|
|
|
+ // 检查所有可能的连续两年优秀的情况
|
|
|
|
|
+ if ((isFirstYearExcellent && isSecondYearExcellent && isThirdYearQualifiedOrAbove) ||
|
|
|
|
|
+ (isFirstYearQualifiedOrAbove && isSecondYearExcellent && isThirdYearExcellent)) {
|
|
|
|
|
+ reason = String.format("连续两年考核结果为【优秀】且另一年考核结果为【合格及以上】【升两档】(%d年:%s,%d年:%s,%d年:%s)",
|
|
|
|
|
+ firstYearValue, firstYearResultName, secondYearValue, secondYearResultName, thirdYearValue, thirdYearResultName);
|
|
|
|
|
+ type = TYPE_PROMOTE_FOR_TWO_EXCELLENT_AND_THREE_PASS_FOR_TWO_YEARS;
|
|
|
|
|
+ level = 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 规则2: 考核结果连续两年优秀-上调一档(只要连续两年优秀就可以上调,不需要三年都存在)
|
|
|
|
|
+ if ((isFirstYearExcellent && isSecondYearExcellent) ||
|
|
|
|
|
+ (isSecondYearExcellent && isThirdYearExcellent)) {
|
|
|
|
|
+ reason = String.format("连续两年考核结果为【优秀】【升一档】(%d年:%s,%d年:%s,%d年:%s)",
|
|
|
|
|
+ firstYearValue, firstYearResultName, secondYearValue, secondYearResultName, thirdYearValue, thirdYearResultName);
|
|
|
|
|
+ type = TYPE_PROMOTE_FOR_TWO_EXCELLENT;
|
|
|
|
|
+ level = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 规则1: 考核结果三年合格及以上-上调一档(较低优先级)
|
|
|
|
|
+ if (isFirstYearQualifiedOrAbove && isSecondYearQualifiedOrAbove && isThirdYearQualifiedOrAbove) {
|
|
|
|
|
+ reason = String.format("三年考核结果均为【合格】【升一档】(%d年:%s,%d年:%s,%d年:%s)",
|
|
|
|
|
+ firstYearValue, firstYearResultName, secondYearValue, secondYearResultName, thirdYearValue, thirdYearResultName);
|
|
|
|
|
+ // 特殊处理:如果是因为连续两年优秀上调一档,并且同时满足三年合格及以上,则更新类型
|
|
|
|
|
+ if(type == TYPE_PROMOTE_FOR_TWO_EXCELLENT){
|
|
|
|
|
+ reason = String.format("连续两年考核结果【优秀】且三年【合格及以上】【升一档】(%d年:%s,%d年:%s,%d年:%s)",
|
|
|
|
|
+ firstYearValue, firstYearResultName, secondYearValue, secondYearResultName, thirdYearValue, thirdYearResultName);
|
|
|
|
|
+ type = TYPE_PROMOTE_FOR_TWO_EXCELLENT_AND_THREE_PASS;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ type = TYPE_PROMOTE_FOR_THREE_PASS;
|
|
|
|
|
+ }
|
|
|
|
|
+ level = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return new SalaryAdjustmentResult(type, level, reason);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查第一年考核结果是否存在
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean isFirstYearPresent(AppraisalResultEnum firstYear) {
|
|
|
|
|
+ return firstYear != null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查第二年考核结果是否存在
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean isSecondYearPresent(AppraisalResultEnum secondYear) {
|
|
|
|
|
+ return secondYear != null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查第三年考核结果是否存在
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean isThirdYearPresent(AppraisalResultEnum thirdYear) {
|
|
|
|
|
+ return thirdYear != 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ perfManagerFilter.and(String.join(".", FormConstant.HRPI_EMPPOSORGREL, FormConstant.IS_SEQLATESTRECORD), QCP.equals, EnableEnum.YES.getCode());
|
|
|
|
|
+ perfManagerFilter.and(PerfManagerFormConstant.NCKD_THESTATUS, QCP.equals, EnableEnum.YES.getCode());
|
|
|
|
|
+ perfManagerFilter.and(PerfManagerFormConstant.NCKD_PERSON, QCP.equals, "2348152690355230726");
|
|
|
|
|
+ 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)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_ACTENDYEAR)
|
|
|
|
|
+ .add(PerfManagerFormConstant.NCKD_THESTATUS)
|
|
|
|
|
+ .addIdNumberName(FormConstant.NCKD_PERSON)
|
|
|
|
|
+ .addIdNumberName(PerfManagerFormConstant.NCKD_FIRSTYEARRESULT)
|
|
|
|
|
+ .addIdNumberName(PerfManagerFormConstant.NCKD_SECONDYEARRESULT)
|
|
|
|
|
+ .addIdNumberName(PerfManagerFormConstant.NCKD_THIRDYEARRESULT);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提取组织ID列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private static List<Long> extractOrgIds(List<OrgSubInfo> orgSubInfos) {
|
|
|
|
|
+ return orgSubInfos.stream()
|
|
|
|
|
+ .map(OrgSubInfo::getOrgId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 调薪结果类
|
|
|
|
|
+ class SalaryAdjustmentResult {
|
|
|
|
|
+ /** 调薪类型*/
|
|
|
|
|
+ int type;
|
|
|
|
|
+ /** 调薪档次*/
|
|
|
|
|
+ int level;
|
|
|
|
|
+ /** 调薪原因*/
|
|
|
|
|
+ String reason;
|
|
|
|
|
+ /** 原定调薪项目 */
|
|
|
|
|
+ DynamicObject oldStandardItem;
|
|
|
|
|
+ /** 原薪等(01岗、02岗)*/
|
|
|
|
|
+ DynamicObject oldSalaryGrade;
|
|
|
|
|
+ /** 原薪档(1档、2档)*/
|
|
|
|
|
+ DynamicObject oldSalaryRank;
|
|
|
|
|
+ //金额
|
|
|
|
|
+ BigDecimal oldAmount;
|
|
|
|
|
+ /** 定调薪项目 */
|
|
|
|
|
+ DynamicObject standardItem;
|
|
|
|
|
+ /** 薪等(01岗、02岗)*/
|
|
|
|
|
+ DynamicObject salaryGrade;
|
|
|
|
|
+ /** 薪档(1档、2档)*/
|
|
|
|
|
+ DynamicObject salaryRank;
|
|
|
|
|
+ //金额
|
|
|
|
|
+ BigDecimal amount;
|
|
|
|
|
+
|
|
|
|
|
+ SalaryAdjustmentResult(int type, int level, String reason) {
|
|
|
|
|
+ this.type = type;
|
|
|
|
|
+ this.level = level;
|
|
|
|
|
+ this.reason = reason;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|