Commit de763fda by 张富康

refactor(perfSalary): 重构绩效相关Mapper和服务逻辑,优化性能规则查询

- 删除多个Mapper XML中的BaseResultMap,简化映射文件减少冗余
- 在AutoPerformRuleMapper接口新增查询最新绩效规则配置和绩效等级配置方法
- 在AutoPerformRuleMapper XML中添加对应SQL查询语句支持最新规则及绩效等级联查
- 新增PerfRuleRemoteService,封装获取最新绩效规则详情及关联等级的业务逻辑
- 实现PerfRuleRemoteImpl的perfRuleConfigDetail方法,调用服务层并处理异常
- PerformanceLevelMapper接口及其XML更新,移除不必要字段
- 新增PerfRuleRemoteService单元测试,验证绩效规则配置详情获取功能
- 整体清理并优化相关代码文件及注释,提升代码结构清晰度和可维护性
1 parent f9585c95
package cn.com.glsx.dj.staff.mapper.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.AutoPerformRuleDetailDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.PerformanceLevelDetailDTO;
import cn.com.glsx.dj.staff.model.perfSalary.AutoPerformRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper
public interface AutoPerformRuleMapper extends OreMapper<AutoPerformRule> {
AutoPerformRuleDetailDTO getLatestRuleConfig();
List<PerformanceLevelDetailDTO> getPerformanceLevels(@Param("uuid") String uuid);
}
\ No newline at end of file
......@@ -7,4 +7,5 @@ import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface PerformanceLevelMapper extends OreMapper<PerformanceLevel> {
}
\ No newline at end of file
package cn.com.glsx.dj.staff.remote.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.*;
import cn.com.glsx.dj.staff.service.perfSalary.PerfRuleRemoteService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@DubboService(version = "1.0.0", validation = "true")
public class PerfRuleRemoteImpl implements PerfRuleRemote {
@Resource
private PerfRuleRemoteService perfRuleRemoteService;
/**
* 绩效规则配置详情
*/
@Override
public RpcResponse<PerfRuleConfigDetailDTO> perfRuleConfigDetail() {
return null;
try {
return RpcResponse.success(perfRuleRemoteService.perfRuleConfigDetail());
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
/**
......
package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.AutoPerformRuleDetailDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.PerfRuleConfigDetailDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.PerformanceLevelDetailDTO;
import cn.com.glsx.dj.staff.mapper.perfSalary.AutoPerformRuleMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceLevelMapper;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class PerfRuleRemoteService {
@Resource
private AutoPerformRuleMapper autoPerformRuleMapper;
@Resource
private PerformanceLevelMapper performanceLevelMapper;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void test(String test) {
}
/**
* 绩效规则配置详情
*/
public PerfRuleConfigDetailDTO perfRuleConfigDetail() {
// 查询当前最新的绩效配置
AutoPerformRuleDetailDTO latestRuleConfig = autoPerformRuleMapper.getLatestRuleConfig();
List<PerformanceLevelDetailDTO> performanceLevels = autoPerformRuleMapper.getPerformanceLevels(latestRuleConfig.getPerformanceLevelUuid());
return new PerfRuleConfigDetailDTO(performanceLevels, latestRuleConfig);
}
}
\ No newline at end of file
......@@ -4,28 +4,5 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.AttendanceSummaryMapper">
<!-- ========== BaseResultMap ========== -->
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.staff.model.perfSalary.AttendanceSummary">
<!-- WARNING - @mbg.generated -->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="mobile_phone" property="mobilePhone" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="merchant_id" property="merchantId" jdbcType="INTEGER"/>
<result column="merchant_attendance_list_id" property="merchantAttendanceListId" jdbcType="INTEGER"/>
<result column="attendance_month" property="attendanceMonth" jdbcType="TIMESTAMP"/>
<result column="expected_attendance_days" property="expectedAttendanceDays" jdbcType="INTEGER"/>
<result column="actual_attendance_days" property="actualAttendanceDays" jdbcType="DECIMAL"/>
<result column="appeal_attendance_days" property="appealAttendanceDays" jdbcType="DECIMAL"/>
<result column="total_work_hours" property="totalWorkHours" jdbcType="DECIMAL"/>
<result column="late_early_hours" property="lateEarlyHours" jdbcType="DECIMAL"/>
<result column="missing_punch_count" property="missingPunchCount" jdbcType="INTEGER"/>
<result column="superior_leader_mobile_phone" property="superiorLeaderMobilePhone" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -3,32 +3,44 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.AutoPerformRuleMapper">
<select id="getLatestRuleConfig" resultType="cn.com.glsx.dj.staff.dto.perfSalary.AutoPerformRuleDetailDTO">
SELECT id,
month_onboard_attendance_days AS monthOnboardAttendanceDays,
month_onboard_output_threshold AS monthOnboardOutputThreshold,
month_onboard_trigger_level_code AS monthOnboardTriggerLevelCode,
month_onboard_trigger_score AS monthOnboardTriggerScore,
month_onboard_trigger_reward_coefficient AS monthOnboardTriggerRewardCoefficient,
month_onboard_default_level_code AS monthOnboardDefaultLevelCode,
month_onboard_default_score AS monthOnboardDefaultScore,
month_onboard_default_reward_coefficient AS monthOnboardDefaultRewardCoefficient,
no_month_onboard_output_threshold AS noMonthOnboardOutputThreshold,
no_month_onboard_trigger_level_code AS noMonthOnboardTriggerLevelCode,
no_month_onboard_trigger_score AS noMonthOnboardTriggerScore,
no_month_onboard_trigger_reward_coefficient AS noMonthOnboardTriggerRewardCoefficient,
no_month_onboard_default_level_code AS noMonthOnboardDefaultLevelCode,
no_month_onboard_default_score AS noMonthOnboardDefaultScore,
no_month_onboard_default_reward_coefficient AS noMonthOnboardDefaultRewardCoefficient,
effective_month AS effectiveMonth,
effective_status AS effectiveStatus,
status AS status,
performance_level_uuid AS performanceLevelUuid
FROM sal_auto_perform_rule
WHERE deleted_flag = 'N'
ORDER BY created_date
DESC
LIMIT 1
</select>
<!-- ========== BaseResultMap ========== -->
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.staff.model.perfSalary.AutoPerformRule">
<!-- WARNING - @mbg.generated -->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="month_onboard_attendance_days" property="monthOnboardAttendanceDays" jdbcType="INTEGER"/>
<result column="month_onboard_output_threshold" property="monthOnboardOutputThreshold" jdbcType="INTEGER"/>
<result column="month_onboard_trigger_level_code" property="monthOnboardTriggerLevelCode" jdbcType="VARCHAR"/>
<result column="month_onboard_default_level_code" property="monthOnboardDefaultLevelCode" jdbcType="VARCHAR"/>
<result column="no_month_onboard_output_threshold" property="noMonthOnboardOutputThreshold" jdbcType="INTEGER"/>
<result column="no_month_onboard_trigger_level_code" property="noMonthOnboardTriggerLevelCode"
jdbcType="VARCHAR"/>
<result column="no_month_onboard_default_level_code" property="noMonthOnboardDefaultLevelCode"
jdbcType="VARCHAR"/>
<result column="effective_month" property="effectiveMonth" jdbcType="TIMESTAMP"/>
<result column="effective_status" property="effectiveStatus" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="performance_level_uuid" property="performanceLevelUuid" jdbcType="VARCHAR"/>
<result column="performance_level_json" property="performanceLevelJson" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="VARCHAR"/>
</resultMap>
<!-- 2. 查询绩效等级配置(关联表) -->
<select id="getPerformanceLevels" resultType="cn.com.glsx.dj.staff.dto.perfSalary.PerformanceLevelDetailDTO">
SELECT
level_code AS levelCode,
uuid AS uuid,
score_symbol_value AS scoreSymbolValue,
reward_coefficient AS rewardCoefficient
FROM sal_performance_level
WHERE uuid = #{uuid} <!-- 通过外部参数传入 -->
</select>
</mapper>
\ No newline at end of file
......@@ -4,36 +4,5 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.EffectiveReferralReviewMapper">
<!-- ========== BaseResultMap ========== -->
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview">
<!-- WARNING - @mbg.generated -->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="merchant_id" property="merchantId" jdbcType="INTEGER"/>
<result column="total_delivery_count" property="totalDeliveryCount" jdbcType="INTEGER"/>
<result column="area_effective_count" property="areaEffectiveCount" jdbcType="INTEGER"/>
<result column="reviewed_effective_count" property="reviewedEffectiveCount" jdbcType="INTEGER"/>
<result column="review_month" property="reviewMonth" jdbcType="TIMESTAMP"/>
<result column="image_urls" property="imageUrls" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="brand_id" property="brandId" jdbcType="INTEGER"/>
<result column="brand_name" property="brandName" jdbcType="VARCHAR"/>
<result column="scene_type" property="sceneType" jdbcType="INTEGER"/>
<result column="is_need_reviewed" property="isNeedReviewed" jdbcType="INTEGER"/>
<result column="is_reviewed" property="isReviewed" jdbcType="INTEGER"/>
<result column="manager_id" property="managerId" jdbcType="VARCHAR"/>
<result column="manager_name" property="managerName" jdbcType="VARCHAR"/>
<result column="manager_phone" property="managerPhone" jdbcType="VARCHAR"/>
<result column="manager_commit_time" property="managerCommitTime" jdbcType="TIMESTAMP"/>
<result column="reviewed_by" property="reviewedBy" jdbcType="VARCHAR"/>
<result column="reviewed_name" property="reviewedName" jdbcType="VARCHAR"/>
<result column="reviewed_time" property="reviewedTime" jdbcType="TIMESTAMP"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -4,23 +4,5 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.MerchantAttendanceListMapper">
<!-- ========== BaseResultMap ========== -->
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.staff.model.perfSalary.MerchantAttendanceList">
<!-- WARNING - @mbg.generated -->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="merchant_id" property="merchantId" jdbcType="INTEGER"/>
<result column="merchant_name" property="merchantName" jdbcType="VARCHAR"/>
<result column="attendance_address" property="attendanceAddress" jdbcType="VARCHAR"/>
<result column="address_lng" property="addressLng" jdbcType="VARCHAR"/>
<result column="address_lat" property="addressLat" jdbcType="VARCHAR"/>
<result column="work_start_time" property="workStartTime" jdbcType="VARCHAR"/>
<result column="work_end_time" property="workEndTime" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -4,38 +4,5 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceEvaluationMapper">
<!-- ========== BaseResultMap ========== -->
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.staff.model.perfSalary.PerformanceEvaluation">
<!-- WARNING - @mbg.generated -->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="mobile_phone" property="mobilePhone" jdbcType="VARCHAR"/>
<result column="evaluation_month" property="evaluationMonth" jdbcType="TIMESTAMP"/>
<result column="auto_grade_code" property="autoGradeCode" jdbcType="VARCHAR"/>
<result column="manual_grade_code" property="manualGradeCode" jdbcType="VARCHAR"/>
<result column="manual_final_performance_amount" property="manualFinalPerformanceAmount" jdbcType="DECIMAL"/>
<result column="performance_salary" property="performanceSalary" jdbcType="DECIMAL"/>
<result column="before_correction_basic_salary" property="beforeCorrectionBasicSalary" jdbcType="DECIMAL"/>
<result column="after_correction_basic_salary" property="afterCorrectionBasicSalary" jdbcType="DECIMAL"/>
<result column="after_attendance_basic_salary" property="afterAttendanceBasicSalary" jdbcType="DECIMAL"/>
<result column="basic_salary" property="basicSalary" jdbcType="DECIMAL"/>
<result column="total_gross_salary" property="totalGrossSalary" jdbcType="DECIMAL"/>
<result column="is_probation" property="isProbation" jdbcType="INTEGER"/>
<result column="entry_date" property="entryDate" jdbcType="TIMESTAMP"/>
<result column="correction_date" property="correctionDate" jdbcType="TIMESTAMP"/>
<result column="is_correction" property="isCorrection" jdbcType="INTEGER"/>
<result column="is_working" property="isWorking" jdbcType="INTEGER"/>
<result column="merchant_id" property="merchantId" jdbcType="INTEGER"/>
<result column="auto_performance_config_id" property="autoPerformanceConfigId" jdbcType="INTEGER"/>
<result column="performance_grade_uuid" property="performanceGradeUuid" jdbcType="VARCHAR"/>
<result column="submit_count" property="submitCount" jdbcType="INTEGER"/>
<result column="handle_status" property="handleStatus" jdbcType="INTEGER"/>
<result column="superior_leader_mobile_phone" property="superiorLeaderMobilePhone" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -12,7 +12,6 @@
<result column="uuid" property="uuid" jdbcType="VARCHAR"/>
<result column="score_symbol_value" property="scoreSymbolValue" jdbcType="VARCHAR"/>
<result column="reward_coefficient" property="rewardCoefficient" jdbcType="DECIMAL"/>
<result column="star_count" property="starCount" jdbcType="INTEGER"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
......
......@@ -4,20 +4,4 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceMonthlyMapper">
<!-- ========== BaseResultMap ========== -->
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.staff.model.perfSalary.PerformanceMonthly">
<!-- WARNING - @mbg.generated -->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="month_date" property="monthDate" jdbcType="TIMESTAMP"/>
<result column="is_auto_perform" property="isAutoPerform" jdbcType="INTEGER"/>
<result column="auto_perform_rule_id" property="autoPerformRuleId" jdbcType="INTEGER"/>
<result column="performance_level_uuid" property="performanceLevelUuid" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -4,39 +4,5 @@
<mapper namespace="cn.com.glsx.dj.staff.mapper.perfSalary.StaffQwClockInInfoMapper">
<!-- ========== BaseResultMap ========== -->
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.staff.model.perfSalary.StaffQwClockInInfo">
<!-- WARNING - @mbg.generated -->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="staff_phone" property="staffPhone" jdbcType="VARCHAR"/>
<result column="clock_in_date" property="clockInDate" jdbcType="VARCHAR"/>
<result column="clock_in_first_time" property="clockInFirstTime" jdbcType="TIMESTAMP"/>
<result column="clock_in_last_time" property="clockInLastTime" jdbcType="TIMESTAMP"/>
<result column="clock_in_location" property="clockInLocation" jdbcType="VARCHAR"/>
<result column="clock_in_photo_url" property="clockInPhotoUrl" jdbcType="VARCHAR"/>
<result column="clock_out_photo_url" property="clockOutPhotoUrl" jdbcType="VARCHAR"/>
<result column="clock_in_addr_lng" property="clockInAddrLng" jdbcType="VARCHAR"/>
<result column="clock_in_addr_lat" property="clockInAddrLat" jdbcType="VARCHAR"/>
<result column="clock_out_addr_lng" property="clockOutAddrLng" jdbcType="VARCHAR"/>
<result column="clock_out_addr_lat" property="clockOutAddrLat" jdbcType="VARCHAR"/>
<result column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="clock_in_abnormal_attire" property="clockInAbnormalAttire" jdbcType="VARCHAR"/>
<result column="clock_out_abnormal_attire" property="clockOutAbnormalAttire" jdbcType="VARCHAR"/>
<result column="clock_in_abnormal_task_id" property="clockInAbnormalTaskId" jdbcType="VARCHAR"/>
<result column="clock_out_abnormal_task_id" property="clockOutAbnormalTaskId" jdbcType="VARCHAR"/>
<result column="clock_in_state" property="clockInState" jdbcType="INTEGER"/>
<result column="clock_out_state" property="clockOutState" jdbcType="INTEGER"/>
<result column="qw_exception_type" property="qwExceptionType" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="VARCHAR"/>
<result column="qw_late_duration" property="qwLateDuration" jdbcType="INTEGER"/>
<result column="qw_leave_early_duration" property="qwLeaveEarlyDuration" jdbcType="INTEGER"/>
<result column="qw_absentee_duration" property="qwAbsenteeDuration" jdbcType="INTEGER"/>
</resultMap>
</mapper>
\ No newline at end of file
package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.sale.service.BaseServiceTest;
import cn.com.glsx.dj.staff.dto.perfSalary.PerfRuleConfigDetailDTO;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import javax.annotation.Resource;
@Slf4j
public class PerfRuleRemoteServiceTest extends BaseServiceTest {
@Resource
private PerfRuleRemoteService perfRuleRemoteService;
@Test
public void testPerfRuleConfigDetail() {
PerfRuleConfigDetailDTO perfRuleConfigDetail = perfRuleRemoteService.perfRuleConfigDetail();
log.info("结果:{}", JSONUtil.toJsonStr(perfRuleConfigDetail));
}
}
\ 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!