Commit 99265350 by 张富康

refactor(perfSalary): 优化绩效模块时间字段类型及自动评绩效流程

- 将考勤月、评分月、查询月、生效月份等字段由Date改为格式为yyyy-MM的String类型
- 新增AppraisalInfoDTO的autoGradeCode字段,支持系统自动绩效等级设置
- AutoPerfEvaluationService自动评绩效接口支持传入年月参数,增强灵活性
- PerformanceEvaluationMapper新增perfAppraisalStatisticsCard方法,统计绩效等级及人数信息
- PerformanceEvaluationService新增绩效统计卡片接口封装mapper调用
- PerfRuleRemote及实现类新增自动评绩效及配置同步定时任务接口
- PerfRuleRemoteService的perfRuleSettingJob提供参数支持,实现传参控制执行月份
- Job层传递分片参数给自动评绩效及绩效配置设置任务,支持参数驱动执行
- 相关Mapper XML新增绩效统计SQL查询,支持月度绩效等级统计及入职人数统计
- 统一调整API注解及rpc相关类引用,增强代码一致性和可维护性
1 parent e2c59889
...@@ -53,6 +53,12 @@ public class AppraisalInfoDTO implements Serializable { ...@@ -53,6 +53,12 @@ public class AppraisalInfoDTO implements Serializable {
private String merchantName; private String merchantName;
/** /**
* 绩效等级-系统自动设置
*/
@ApiModelProperty(notes = "绩效等级-系统自动设置")
private String autoGradeCode;
/**
* 奖励系数-系统自动设置 * 奖励系数-系统自动设置
*/ */
@ApiModelProperty(notes = "奖励系数-系统自动设置") @ApiModelProperty(notes = "奖励系数-系统自动设置")
......
package cn.com.glsx.dj.staff.dto.perfSalary; package cn.com.glsx.dj.staff.dto.perfSalary;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* 自动评绩效规则配置表 * 自动评绩效规则配置表
...@@ -113,9 +111,8 @@ public class AutoPerformRuleUpdateDTO implements Serializable { ...@@ -113,9 +111,8 @@ public class AutoPerformRuleUpdateDTO implements Serializable {
/** /**
* 生效月份(yyyy-mm格式) * 生效月份(yyyy-mm格式)
*/ */
@ApiModelProperty(notes = "生效月份-传参格式:yyyy-MM-dd") @ApiModelProperty(notes = "生效月份-传参格式:yyyy-MM")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private String effectiveMonth;
private Date effectiveMonth;
/** /**
* 生效状态:1-生效中,2-待生效 * 生效状态:1-生效中,2-待生效
......
package cn.com.glsx.dj.staff.dto.perfSalary; package cn.com.glsx.dj.staff.dto.perfSalary;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -8,7 +7,6 @@ import lombok.NoArgsConstructor; ...@@ -8,7 +7,6 @@ import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
...@@ -20,9 +18,8 @@ public class PerfRuleReqDTO implements Serializable { ...@@ -20,9 +18,8 @@ public class PerfRuleReqDTO implements Serializable {
/** /**
* 查询月份 * 查询月份
*/ */
@ApiModelProperty(notes = "查询月份-传参格式:yyyy-MM-dd") @ApiModelProperty(notes = "查询月份-传参格式:yyyy-MM")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private String queryMonth;
private Date queryMonth;
/** /**
* 区域经理手机号 * 区域经理手机号
......
...@@ -63,4 +63,14 @@ public interface PerfRuleRemote { ...@@ -63,4 +63,14 @@ public interface PerfRuleRemote {
* 打卡数据 * 打卡数据
*/ */
RpcResponse<Boolean> clockInCompleteAnalysisStaff(); RpcResponse<Boolean> clockInCompleteAnalysisStaff();
/**
* 定时任务-绩效配置设置
*/
RpcResponse<Boolean> syncQwClockInDetailData(String clockInDateStr);
/**
* 每月自动评绩效
*/
RpcResponse<Boolean> autoPerfEvaluation();
} }
...@@ -20,7 +20,8 @@ public class AutoPerfEvaluationJob implements SimpleJob { ...@@ -20,7 +20,8 @@ public class AutoPerfEvaluationJob implements SimpleJob {
public void execute(ShardingContext shardingContext) { public void execute(ShardingContext shardingContext) {
log.info("----------------每月自动评绩效开始-----------------"); log.info("----------------每月自动评绩效开始-----------------");
try { try {
autoPerfEvaluationService.autoPerfEvaluation(); log.info("分片参数:{}", shardingContext.getJobParameter());
autoPerfEvaluationService.autoPerfEvaluation(shardingContext.getJobParameter());
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
......
...@@ -20,7 +20,7 @@ public class PerfRuleSettingJob implements SimpleJob { ...@@ -20,7 +20,7 @@ public class PerfRuleSettingJob implements SimpleJob {
public void execute(ShardingContext shardingContext) { public void execute(ShardingContext shardingContext) {
log.info("----------------绩效配置设置开始-----------------"); log.info("----------------绩效配置设置开始-----------------");
try { try {
perfRuleRemoteService.perfRuleSettingJob(); perfRuleRemoteService.perfRuleSettingJob(shardingContext.getJobParameter());
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
......
package cn.com.glsx.dj.staff.mapper.perfSalary; package cn.com.glsx.dj.staff.mapper.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.PerfAppraisalStatisticsCardDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.PerfRuleReqDTO;
import cn.com.glsx.dj.staff.model.perfSalary.PerformanceEvaluation; import cn.com.glsx.dj.staff.model.perfSalary.PerformanceEvaluation;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -13,4 +15,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua ...@@ -13,4 +15,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua
void insertOrUpdate(PerformanceEvaluation performanceEvaluation); void insertOrUpdate(PerformanceEvaluation performanceEvaluation);
void insertOrUpdateBatch(@Param("list") List<PerformanceEvaluation> performanceEvaluationList); void insertOrUpdateBatch(@Param("list") List<PerformanceEvaluation> performanceEvaluationList);
PerfAppraisalStatisticsCardDTO perfAppraisalStatisticsCard(PerfRuleReqDTO perfRuleReqDTO);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.remote.perfSalary; package cn.com.glsx.dj.staff.remote.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.*; import cn.com.glsx.dj.staff.dto.perfSalary.*;
import cn.com.glsx.dj.staff.service.perfSalary.AttendanceDataCleansingService; import cn.com.glsx.dj.staff.service.perfSalary.*;
import cn.com.glsx.dj.staff.service.perfSalary.ClockInCompleteAnalysisStaffService;
import cn.com.glsx.dj.staff.service.perfSalary.PerfRuleRemoteService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -22,6 +20,10 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote { ...@@ -22,6 +20,10 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote {
private AttendanceDataCleansingService attendanceDataCleansingService; private AttendanceDataCleansingService attendanceDataCleansingService;
@Resource @Resource
private ClockInCompleteAnalysisStaffService clockInCompleteAnalysisStaffService; private ClockInCompleteAnalysisStaffService clockInCompleteAnalysisStaffService;
@Resource
private AutoPerfEvaluationService autoPerfEvaluationService;
@Resource
private PerformanceEvaluationService performanceEvaluationService;
...@@ -69,7 +71,12 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote { ...@@ -69,7 +71,12 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote {
*/ */
@Override @Override
public RpcResponse<PerfAppraisalStatisticsCardDTO> perfAppraisalStatisticsCard(PerfRuleReqDTO perfRuleReqDTO) { public RpcResponse<PerfAppraisalStatisticsCardDTO> perfAppraisalStatisticsCard(PerfRuleReqDTO perfRuleReqDTO) {
return null; try {
return RpcResponse.success(performanceEvaluationService.perfAppraisalStatisticsCard(perfRuleReqDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
} }
/** /**
...@@ -130,5 +137,23 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote { ...@@ -130,5 +137,23 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote {
return RpcResponse.success(true); return RpcResponse.success(true);
} }
/**
* 定时任务-绩效配置设置
*/
@Override
public RpcResponse<Boolean> syncQwClockInDetailData(String clockInDateStr) {
perfRuleRemoteService.perfRuleSettingJob("");
return RpcResponse.success(true);
}
/**
* 每月自动评绩效
*/
@Override
public RpcResponse<Boolean> autoPerfEvaluation() {
autoPerfEvaluationService.autoPerfEvaluation("");
return RpcResponse.success(true);
}
} }
...@@ -64,7 +64,7 @@ public class AutoPerfEvaluationService { ...@@ -64,7 +64,7 @@ public class AutoPerfEvaluationService {
/** /**
* 每月自动评绩效 * 每月自动评绩效
*/ */
public void autoPerfEvaluation() { public void autoPerfEvaluation(String monthDate) {
// 查询生效中的自动绩效配置 // 查询生效中的自动绩效配置
Example autoPerformRuleExample = new Example(AutoPerformRule.class); Example autoPerformRuleExample = new Example(AutoPerformRule.class);
autoPerformRuleExample.createCriteria().andEqualTo("deletedFlag", 'N') autoPerformRuleExample.createCriteria().andEqualTo("deletedFlag", 'N')
...@@ -77,7 +77,7 @@ public class AutoPerfEvaluationService { ...@@ -77,7 +77,7 @@ public class AutoPerfEvaluationService {
// 查询北森同步表 获取该月在职或该月离职的员工 // 查询北森同步表 获取该月在职或该月离职的员工
Example staffBeisenBaseExample = new Example(StaffBeisenBaseInfo.class); Example staffBeisenBaseExample = new Example(StaffBeisenBaseInfo.class);
// 上个月 // 上个月
DateTime lastMonthDate = DateUtil.offsetMonth(new Date(), -1); DateTime lastMonthDate = StrUtil.isNotBlank(monthDate) ? DateUtil.parse(monthDate) : DateUtil.offsetMonth(new Date(), -1);
DateTime lastMonthFirstYMD = DateUtil.beginOfMonth(lastMonthDate); DateTime lastMonthFirstYMD = DateUtil.beginOfMonth(lastMonthDate);
DateTime lastMonthLastYMD = DateUtil.endOfMonth(lastMonthDate); DateTime lastMonthLastYMD = DateUtil.endOfMonth(lastMonthDate);
String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN); String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN);
......
...@@ -4,6 +4,7 @@ import cn.com.glsx.dj.staff.dto.perfSalary.*; ...@@ -4,6 +4,7 @@ import cn.com.glsx.dj.staff.dto.perfSalary.*;
import cn.com.glsx.dj.staff.enums.perfSalary.EffectiveStatusEnum; import cn.com.glsx.dj.staff.enums.perfSalary.EffectiveStatusEnum;
import cn.com.glsx.dj.staff.enums.perfSalary.PerfRuleConfigStarEnum; import cn.com.glsx.dj.staff.enums.perfSalary.PerfRuleConfigStarEnum;
import cn.com.glsx.dj.staff.mapper.perfSalary.AutoPerformRuleMapper; import cn.com.glsx.dj.staff.mapper.perfSalary.AutoPerformRuleMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceEvaluationMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceLevelMapper; import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceLevelMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceMonthlyMapper; import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceMonthlyMapper;
import cn.com.glsx.dj.staff.model.perfSalary.AutoPerformRule; import cn.com.glsx.dj.staff.model.perfSalary.AutoPerformRule;
...@@ -45,6 +46,9 @@ public class PerfRuleRemoteService { ...@@ -45,6 +46,9 @@ public class PerfRuleRemoteService {
@Resource @Resource
private PerformanceMonthlyMapper performanceMonthlyMapper; private PerformanceMonthlyMapper performanceMonthlyMapper;
@Resource
private PerformanceEvaluationMapper performanceEvaluationMapper;
// 当月入职新员工-规则外的默认等级编码 // 当月入职新员工-规则外的默认等级编码
String monthOnboardDefaultLevelCode = OrePropertyConfigurer.getProperty("month_onboard_default_level_code", String.class, "B"); String monthOnboardDefaultLevelCode = OrePropertyConfigurer.getProperty("month_onboard_default_level_code", String.class, "B");
...@@ -151,14 +155,15 @@ public class PerfRuleRemoteService { ...@@ -151,14 +155,15 @@ public class PerfRuleRemoteService {
return result; return result;
} }
/** /**
* 定时任务-绩效配置设置 * 定时任务-绩效配置设置
*/ */
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void perfRuleSettingJob() { public void perfRuleSettingJob(String monthDate) {
// 查询是否存在 待生效且生效时间等于上个月的配置 // 查询是否存在 待生效且生效时间等于上个月的配置
// 上个月 // 上个月
DateTime lastMonthDate = DateUtil.offsetMonth(new Date(), -1); DateTime lastMonthDate = StrUtil.isNotBlank(monthDate) ? DateUtil.parse(monthDate) : DateUtil.offsetMonth(new Date(), -1);
String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN); String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN);
String queryLastMonthPendingCondition = "(DATE_FORMAT(effective_month, '%Y-%m') = '{}')"; String queryLastMonthPendingCondition = "(DATE_FORMAT(effective_month, '%Y-%m') = '{}')";
queryLastMonthPendingCondition = StrUtil.format(queryLastMonthPendingCondition, lastMonth); queryLastMonthPendingCondition = StrUtil.format(queryLastMonthPendingCondition, lastMonth);
...@@ -229,4 +234,5 @@ public class PerfRuleRemoteService { ...@@ -229,4 +234,5 @@ public class PerfRuleRemoteService {
} }
} }
\ 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.PerfAppraisalStatisticsCardDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.PerfRuleReqDTO;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceEvaluationMapper; import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceEvaluationMapper;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -23,4 +25,11 @@ public class PerformanceEvaluationService { ...@@ -23,4 +25,11 @@ public class PerformanceEvaluationService {
} }
/**
* 绩效考核-统计卡片
*/
public PerfAppraisalStatisticsCardDTO perfAppraisalStatisticsCard(PerfRuleReqDTO perfRuleReqDTO) {
return performanceEvaluationMapper.perfAppraisalStatisticsCard(perfRuleReqDTO);
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -258,4 +258,37 @@ ...@@ -258,4 +258,37 @@
updated_date = current_timestamp updated_date = current_timestamp
</insert> </insert>
<select id="perfAppraisalStatisticsCard" resultType="cn.com.glsx.dj.staff.dto.perfSalary.PerfAppraisalStatisticsCardDTO">
SELECT
-- 绩效等级统计(7个固定等级)
SUM(CASE WHEN grade = 'S' THEN 1 ELSE 0 END) AS sCount,
SUM(CASE WHEN grade = 'A' THEN 1 ELSE 0 END) AS aCount,
SUM(CASE WHEN grade = 'B+' THEN 1 ELSE 0 END) AS bPlusCount,
SUM(CASE WHEN grade = 'B' THEN 1 ELSE 0 END) AS bCount,
SUM(CASE WHEN grade = 'B-' THEN 1 ELSE 0 END) AS bMinusCount,
SUM(CASE WHEN grade = 'C' THEN 1 ELSE 0 END) AS cCount,
SUM(CASE WHEN grade = 'D' THEN 1 ELSE 0 END) AS dCount,
-- 汇总数据(总人数/入职人数)
(SELECT COUNT(*) FROM sal_performance_evaluation
WHERE evaluation_month = #{queryMonth}
AND deleted_flag = 'N'
AND superior_leader_mobile_phone = #{regionManagerMobilePhone}) AS totalCount,
(SELECT COUNT(*) FROM sal_performance_evaluation
WHERE evaluation_month = #{queryMonth}
AND deleted_flag = 'N'
AND superior_leader_mobile_phone = #{regionManagerMobilePhone}
AND is_entry = 1) AS entryCount
FROM (
SELECT
-- 优先取manual_grade_code,为空则取auto_grade_code
COALESCE(manual_grade_code, auto_grade_code) AS grade
FROM sal_performance_evaluation
WHERE
evaluation_month = #{queryMonth}
AND deleted_flag = 'N'
AND superior_leader_mobile_phone = #{regionManagerMobilePhone}
AND (manual_grade_code IS NOT NULL OR auto_grade_code IS NOT NULL)
) t
</select>
</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!