Commit 25e699ae by 章家宝

Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0

2 parents 990272c1 3a0b2b7c
......@@ -222,9 +222,9 @@ public class PerfAppraisalDetailDTO implements Serializable {
private Integer handleStatus;
/**
* 采用类型 1-采用自动绩效 2-采用手动绩效
* 采用类型 1-采用自动绩效 2-采用手动绩效 (null-未开启自动带绩效)
*/
@ApiModelProperty(notes = "采用类型 1-采用自动绩效 2-采用手动绩效")
@ApiModelProperty(notes = "采用类型 1-采用自动绩效 2-采用手动绩效 (null-未开启自动带绩效)")
private Integer adoptType;
/**
......
......@@ -46,7 +46,7 @@ public enum PerformanceTimeCycleCodeEnum {
*/
T7("T7", "10. 发放最终工资,定稿工资数据"),
;
;
private String code;
private String desc;
private final String code;
private final String desc;
}
......@@ -145,7 +145,7 @@ public class PerformanceEvaluation implements Serializable {
/**
* 考勤计算后-合计工资
* 考勤计算后-考勤工资
*/
@ApiModelProperty(notes = "考勤计算后-合计工资")
@Column(name = "after_attendance_total_basic_salary")
......@@ -172,12 +172,6 @@ public class PerformanceEvaluation implements Serializable {
@Column(name = "basic_salary")
private BigDecimal basicSalary;
/**
* 合计应发工资
*/
@ApiModelProperty(notes = "合计应发工资")
@Column(name = "total_gross_salary")
private BigDecimal totalGrossSalary;
/**
* 该月产值
......
......@@ -27,4 +27,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua
List<AppraisalInfoDTO> perfStaffList(PerfRuleReqDTO perfRuleReqDTO);
BigDecimal getTotalExtraAmount(PerfRuleReqDTO perfRuleReqDTO);
int submitOne(PerformanceEvaluation updatePerfAppraisalDetailDTO);
}
\ No newline at end of file
package cn.com.glsx.dj.staff.service.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.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.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
......@@ -22,6 +34,11 @@ public class PerformanceEvaluationService {
@Resource
private PerformanceEvaluationMapper performanceEvaluationMapper;
@Resource
private PerformanceLevelMapper performanceLevelMapper;
@Resource
private PerformanceTimeCycleMapper performanceTimeCycleMapper;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void test(String test) {
......@@ -69,7 +86,7 @@ public class PerformanceEvaluationService {
}
/**
* 员工列表(过滤提交过2次的员工)-(按照评分月份,区域经理手机号筛选)
* 员工列表(过滤提交过2次的员工)-(按照评分月份,区域经理手机号筛选)
*/
public List<AppraisalInfoDTO> perfStaffList(PerfRuleReqDTO perfRuleReqDTO) {
return performanceEvaluationMapper.perfStaffList(perfRuleReqDTO);
......@@ -78,8 +95,19 @@ public class PerformanceEvaluationService {
/**
* 绩效考核-提交-单个处理
*/
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
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.setMobilePhone(perfAppraisalSubmitReqDTO.getMobilePhone());
perfRuleReqDTO.setQueryMonth(perfAppraisalSubmitReqDTO.getEvaluationMonth());
......@@ -88,22 +116,75 @@ public class PerformanceEvaluationService {
throw new RpcServiceException("该员工该月绩效评分数据不存在");
}
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时需要计算是否符合
BigDecimal totalExtraAmount = performanceEvaluationMapper.getTotalExtraAmount(perfRuleReqDTO);
Integer adoptType = perfAppraisalSubmitReqDTO.getAdoptType();
if (adoptType == 1) {
// 自动绩效判断 考勤计算后-合计工资 x (1 - basic_salary_ratio) x 评分系数' todz 检查一下
BigDecimal multiply = perfAppraisalDetailDTO.getAfterAttendanceTotalBasicSalary()
.multiply((BigDecimal.ONE.divide(perfAppraisalDetailDTO.getBasicSalaryRatio()))
.multiply(perfAppraisalDetailDTO.getAutoRewardCoefficient()));
// perfAppraisalDetailDTO.getAutoRewardCoefficient() * perfAppraisalDetailDTO.get()
// 通过uuid获取对应的系数
Example performanceLevelExample = new Example(PerformanceLevel.class);
performanceLevelExample.createCriteria().andEqualTo("uuid", perfAppraisalDetailDTO.getPerformanceGradeUuid());
performanceLevelMapper.selectByExample(performanceLevelExample);
List<PerformanceLevel> performanceLevels = performanceLevelMapper.selectByExample(performanceLevelExample);
// 按绩效等级获取对应的系数分组 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 {
// 手动绩效判断
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);
}
}
return null;
// 判断该金额加上totalExtraAmount是否大于0 如果结果大于0则抛异常说明 当前你名下的驻店销售组员,奖励金额已超出当前扣罚金额,请及时调整整体绩效等级
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 @@
updated_date = current_timestamp
</insert>
<select id="perfAppraisalStatisticsCard" resultType="cn.com.glsx.dj.staff.dto.perfSalary.PerfAppraisalStatisticsCardDTO">
SELECT
COALESCE(SUM(CASE WHEN grade = 'S' THEN 1 ELSE 0 END), 0) AS sCount,
......@@ -460,4 +461,20 @@
and superior_leader_mobile_phone = #{regionManagerMobilePhone}
</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>
\ 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!