Commit 3a0b2b7c by 张富康

refactor(perfSalary): 优化自动绩效计算逻辑和提交流程

- 调整自动绩效规则判断逻辑,支持未开启自动绩效情况下的数据处理
- 优化绩效工资、基本工资计算,区分自动和未开启自动绩效情况
- PerfAppraisalDetailDTO adoptType字段注释更新,明确未开启自动带绩效状态
- 删除PerformanceEvaluation中的废弃字段totalGrossSalary,调整字段注释说明
- PerformanceEvaluationMapper新增submitOne接口,支持绩效单条提交更新
- PerformanceEvaluationService新增单个绩效提交方法,增加考核时间校验和逻辑校验
- 提交时校验绩效修改次数限制和绩效金额合理性,确保奖励额度不超限
- 通过绩效等级映射获取对应系数,实现手动评分和自动评分金额计算
- PerformanceTimeCycleCodeEnum调整成员变量为final,增强代码规范性
1 parent e5df5fa9
...@@ -222,9 +222,9 @@ public class PerfAppraisalDetailDTO implements Serializable { ...@@ -222,9 +222,9 @@ public class PerfAppraisalDetailDTO implements Serializable {
private Integer handleStatus; private Integer handleStatus;
/** /**
* 采用类型 1-采用自动绩效 2-采用手动绩效 * 采用类型 1-采用自动绩效 2-采用手动绩效 (null-未开启自动带绩效)
*/ */
@ApiModelProperty(notes = "采用类型 1-采用自动绩效 2-采用手动绩效") @ApiModelProperty(notes = "采用类型 1-采用自动绩效 2-采用手动绩效 (null-未开启自动带绩效)")
private Integer adoptType; private Integer adoptType;
/** /**
......
...@@ -46,7 +46,7 @@ public enum PerformanceTimeCycleCodeEnum { ...@@ -46,7 +46,7 @@ public enum PerformanceTimeCycleCodeEnum {
*/ */
T7("T7", "10. 发放最终工资,定稿工资数据"), T7("T7", "10. 发放最终工资,定稿工资数据"),
; ;
;
private String code; private final String code;
private String desc; private final String desc;
} }
...@@ -145,7 +145,7 @@ public class PerformanceEvaluation implements Serializable { ...@@ -145,7 +145,7 @@ public class PerformanceEvaluation implements Serializable {
/** /**
* 考勤计算后-合计工资 * 考勤计算后-考勤工资
*/ */
@ApiModelProperty(notes = "考勤计算后-合计工资") @ApiModelProperty(notes = "考勤计算后-合计工资")
@Column(name = "after_attendance_total_basic_salary") @Column(name = "after_attendance_total_basic_salary")
...@@ -172,12 +172,6 @@ public class PerformanceEvaluation implements Serializable { ...@@ -172,12 +172,6 @@ public class PerformanceEvaluation implements Serializable {
@Column(name = "basic_salary") @Column(name = "basic_salary")
private BigDecimal basicSalary; private BigDecimal basicSalary;
/**
* 合计应发工资
*/
@ApiModelProperty(notes = "合计应发工资")
@Column(name = "total_gross_salary")
private BigDecimal totalGrossSalary;
/** /**
* 该月产值 * 该月产值
......
...@@ -27,4 +27,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua ...@@ -27,4 +27,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua
List<AppraisalInfoDTO> perfStaffList(PerfRuleReqDTO perfRuleReqDTO); List<AppraisalInfoDTO> perfStaffList(PerfRuleReqDTO perfRuleReqDTO);
BigDecimal getTotalExtraAmount(PerfRuleReqDTO perfRuleReqDTO); BigDecimal getTotalExtraAmount(PerfRuleReqDTO perfRuleReqDTO);
int submitOne(PerformanceEvaluation updatePerfAppraisalDetailDTO);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.service.perfSalary; package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.*; import cn.com.glsx.dj.staff.dto.perfSalary.*;
import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO;
import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum;
import cn.com.glsx.dj.staff.mapper.PerformanceTimeCycleMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceEvaluationMapper; import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceEvaluationMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceLevelMapper;
import cn.com.glsx.dj.staff.model.perfSalary.PerformanceEvaluation;
import cn.com.glsx.dj.staff.model.perfSalary.PerformanceLevel;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j @Slf4j
...@@ -22,6 +34,11 @@ public class PerformanceEvaluationService { ...@@ -22,6 +34,11 @@ public class PerformanceEvaluationService {
@Resource @Resource
private PerformanceEvaluationMapper performanceEvaluationMapper; private PerformanceEvaluationMapper performanceEvaluationMapper;
@Resource
private PerformanceLevelMapper performanceLevelMapper;
@Resource
private PerformanceTimeCycleMapper performanceTimeCycleMapper;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void test(String test) { public void test(String test) {
...@@ -69,7 +86,7 @@ public class PerformanceEvaluationService { ...@@ -69,7 +86,7 @@ public class PerformanceEvaluationService {
} }
/** /**
* 员工列表(过滤提交过2次的员工)-(按照评分月份,区域经理手机号筛选) * 员工列表(过滤提交过2次的员工)-(按照评分月份,区域经理手机号筛选)
*/ */
public List<AppraisalInfoDTO> perfStaffList(PerfRuleReqDTO perfRuleReqDTO) { public List<AppraisalInfoDTO> perfStaffList(PerfRuleReqDTO perfRuleReqDTO) {
return performanceEvaluationMapper.perfStaffList(perfRuleReqDTO); return performanceEvaluationMapper.perfStaffList(perfRuleReqDTO);
...@@ -78,8 +95,19 @@ public class PerformanceEvaluationService { ...@@ -78,8 +95,19 @@ public class PerformanceEvaluationService {
/** /**
* 绩效考核-提交-单个处理 * 绩效考核-提交-单个处理
*/ */
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public Boolean perfAppraisalSingleSubmit(PerfAppraisalSubmitReqDTO perfAppraisalSubmitReqDTO) { public Boolean perfAppraisalSingleSubmit(PerfAppraisalSubmitReqDTO perfAppraisalSubmitReqDTO) {
// 校验 // 校验
// 校验是否在修改的时间
PerformanceTimeCycleDTO performanceTimeCycleDTO = performanceTimeCycleMapper.selectByCode(PerformanceTimeCycleCodeEnum.T1.getCode());
Date startDate = performanceTimeCycleDTO.getStartDate();
Date endDate = performanceTimeCycleDTO.getEndDate();
Date now = DateUtil.date();
// 判断当前时间是否在考核时间范围内 当前时间需要大于等于开始时间,小于等于结束时间
boolean judgeTime = now.compareTo(startDate) < 0 || now.compareTo(endDate) > 0;
if (judgeTime) {
throw new RpcServiceException("亲,当前时间不能再提交数据");
}
PerfRuleReqDTO perfRuleReqDTO = new PerfRuleReqDTO(); PerfRuleReqDTO perfRuleReqDTO = new PerfRuleReqDTO();
perfRuleReqDTO.setMobilePhone(perfAppraisalSubmitReqDTO.getMobilePhone()); perfRuleReqDTO.setMobilePhone(perfAppraisalSubmitReqDTO.getMobilePhone());
perfRuleReqDTO.setQueryMonth(perfAppraisalSubmitReqDTO.getEvaluationMonth()); perfRuleReqDTO.setQueryMonth(perfAppraisalSubmitReqDTO.getEvaluationMonth());
...@@ -88,22 +116,75 @@ public class PerformanceEvaluationService { ...@@ -88,22 +116,75 @@ public class PerformanceEvaluationService {
throw new RpcServiceException("该员工该月绩效评分数据不存在"); throw new RpcServiceException("该员工该月绩效评分数据不存在");
} }
if (perfAppraisalDetailDTO.getSubmitCount() >= 2) { if (perfAppraisalDetailDTO.getSubmitCount() >= 2) {
throw new RpcServiceException("该员工该月绩效评分数据已处理2次"); throw new RpcServiceException("亲,每月只有修改2次绩效次数,如有问题请联系总部运营,统一增加扣减金额");
}
// 判断该月未开启自动绩效 且选择自动绩效 则抛异常
if (ObjectUtil.notEqual(perfAppraisalDetailDTO.getIsAutoPerformance(), 1)
&& ObjectUtil.equal(perfAppraisalSubmitReqDTO.getAdoptType(), 1)
&& ObjectUtil.isEmpty(perfAppraisalSubmitReqDTO.getManualFinalPerformanceAmount())) {
throw new RpcServiceException("亲,该月未开启自动打绩效,请选择手动绩效或填写手动维护最终绩效金额");
} }
// 查询该月该经理下员工可分配绩效金额额度 当前totalExtraAmount大于0则不能提交 小于0时需要计算是否符合 // 查询该月该经理下员工可分配绩效金额额度 当前totalExtraAmount大于0则不能提交 小于0时需要计算是否符合
BigDecimal totalExtraAmount = performanceEvaluationMapper.getTotalExtraAmount(perfRuleReqDTO); BigDecimal totalExtraAmount = performanceEvaluationMapper.getTotalExtraAmount(perfRuleReqDTO);
Integer adoptType = perfAppraisalSubmitReqDTO.getAdoptType(); Integer adoptType = perfAppraisalSubmitReqDTO.getAdoptType();
if (adoptType == 1) { // 通过uuid获取对应的系数
// 自动绩效判断 考勤计算后-合计工资 x (1 - basic_salary_ratio) x 评分系数' todz 检查一下 Example performanceLevelExample = new Example(PerformanceLevel.class);
BigDecimal multiply = perfAppraisalDetailDTO.getAfterAttendanceTotalBasicSalary() performanceLevelExample.createCriteria().andEqualTo("uuid", perfAppraisalDetailDTO.getPerformanceGradeUuid());
.multiply((BigDecimal.ONE.divide(perfAppraisalDetailDTO.getBasicSalaryRatio())) performanceLevelMapper.selectByExample(performanceLevelExample);
.multiply(perfAppraisalDetailDTO.getAutoRewardCoefficient())); List<PerformanceLevel> performanceLevels = performanceLevelMapper.selectByExample(performanceLevelExample);
// perfAppraisalDetailDTO.getAutoRewardCoefficient() * perfAppraisalDetailDTO.get() // 按绩效等级获取对应的系数分组 Map<绩效等级, 实体类>
Map<String, PerformanceLevel> performanceLevelMap = performanceLevels.stream().collect(Collectors.toMap(PerformanceLevel::getLevelCode, v -> v));
// 初始绩效 = 考勤计算后-合计工资 * (1 - basic_salary_ratio)
BigDecimal initPerfAmt = NumberUtil.mul(perfAppraisalDetailDTO.getAfterAttendanceTotalBasicSalary(),
NumberUtil.sub(BigDecimal.ONE, perfAppraisalDetailDTO.getBasicSalaryRatio()));
BigDecimal subInit;
// 绩效工资
BigDecimal performanceSalary;
// 判断手动绩效金额是否为空
if (ObjectUtil.isNotEmpty(perfAppraisalSubmitReqDTO.getManualFinalPerformanceAmount())) {
// 手动绩效金额 - 初始绩效
subInit = NumberUtil.sub(perfAppraisalSubmitReqDTO.getManualFinalPerformanceAmount(), initPerfAmt);
performanceSalary = perfAppraisalSubmitReqDTO.getManualFinalPerformanceAmount();
} else { } else {
// 手动绩效判断 if (adoptType == 1) {
// 自动绩效金额(进行系数计算) = 初始绩效 * 系数
performanceSalary = NumberUtil.mul(initPerfAmt, perfAppraisalDetailDTO.getAutoRewardCoefficient());
// 自动绩效金额 - 初始绩效
subInit = NumberUtil.sub(performanceSalary, initPerfAmt);
} else {
// 手动评分绩效判断
// 获取等级对应的系数
BigDecimal rewardCoefficient = performanceLevelMap.get(perfAppraisalSubmitReqDTO.getManualGradeCode()).getRewardCoefficient();
// 手动评分绩效金额 = 初始绩效 * 系数
performanceSalary = NumberUtil.mul(initPerfAmt, rewardCoefficient);
// 手动绩效金额 - 初始绩效
subInit = NumberUtil.sub(performanceSalary, initPerfAmt);
}
} }
// 判断该金额加上totalExtraAmount是否大于0 如果结果大于0则抛异常说明 当前你名下的驻店销售组员,奖励金额已超出当前扣罚金额,请及时调整整体绩效等级
return null; if (NumberUtil.add(subInit, totalExtraAmount).compareTo(BigDecimal.ZERO) > 0) {
throw new RpcServiceException("亲,当前你名下的驻店销售组员,奖励金额已超出当前扣罚金额,请及时调整整体绩效等级");
}
// 更新绩效
boolean isAuto = ObjectUtil.equals(adoptType, 1);
PerformanceEvaluation updatePerfAppraisal = new PerformanceEvaluation();
updatePerfAppraisal.setId(perfAppraisalDetailDTO.getId());
updatePerfAppraisal.setAdoptType(adoptType);
updatePerfAppraisal.setHandleStatus(1);
updatePerfAppraisal.setManualFinalPerformanceAmount(perfAppraisalSubmitReqDTO.getManualFinalPerformanceAmount());
updatePerfAppraisal.setManualGradeCode(isAuto ? null : perfAppraisalSubmitReqDTO.getManualGradeCode());
updatePerfAppraisal.setManualRewardCoefficient(isAuto ? null : performanceLevelMap.get(perfAppraisalSubmitReqDTO.getManualGradeCode()).getRewardCoefficient());
updatePerfAppraisal.setManualScoreSymbolValue(isAuto ? null : performanceLevelMap.get(perfAppraisalSubmitReqDTO.getManualGradeCode()).getScoreSymbolValue());
// 绩效工资
updatePerfAppraisal.setPerformanceSalary(performanceSalary);
// 基本工资
updatePerfAppraisal.setBasicSalary(NumberUtil.add(perfAppraisalDetailDTO.getBaseSalary(), performanceSalary));
updatePerfAppraisal.setSubmitCount(perfAppraisalDetailDTO.getSubmitCount() + 1);
int updateCount = performanceEvaluationMapper.submitOne(updatePerfAppraisal);
if (updateCount < 1) {
throw new RpcServiceException("亲,每月只有修改2次绩效次数,如有问题请联系总部运营,统一增加扣减金额");
}
return true;
} }
/** /**
......
...@@ -258,6 +258,7 @@ ...@@ -258,6 +258,7 @@
updated_date = current_timestamp updated_date = current_timestamp
</insert> </insert>
<select id="perfAppraisalStatisticsCard" resultType="cn.com.glsx.dj.staff.dto.perfSalary.PerfAppraisalStatisticsCardDTO"> <select id="perfAppraisalStatisticsCard" resultType="cn.com.glsx.dj.staff.dto.perfSalary.PerfAppraisalStatisticsCardDTO">
SELECT SELECT
COALESCE(SUM(CASE WHEN grade = 'S' THEN 1 ELSE 0 END), 0) AS sCount, COALESCE(SUM(CASE WHEN grade = 'S' THEN 1 ELSE 0 END), 0) AS sCount,
...@@ -460,4 +461,20 @@ ...@@ -460,4 +461,20 @@
and superior_leader_mobile_phone = #{regionManagerMobilePhone} and superior_leader_mobile_phone = #{regionManagerMobilePhone}
</select> </select>
<update id="submitOne">
update sal_performance_evaluation
set adopt_type = #{adoptType},
handle_status = #{handleStatus},
manual_final_performance_amount = #{manualFinalPerformanceAmount},
manual_grade_code = #{manualGradeCode},
manual_reward_coefficient = #{manualRewardCoefficient},
manual_score_symbol_value = #{manualScoreSymbolValue},
performance_salary = #{performanceSalary},
basic_salary = #{basicSalary},
submit_count = #{submitCount}
where id = #{id}
and deleted_flag = 'N'
and <![CDATA[ submit_count < 2]]>
</update>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!