refactor(examine): 优化考核评分逻辑
- 移除 ExamineDetailServiceImpl 中的系统核算单独处理逻辑 - 在 ExamineUserServiceImpl 中新增系统核算处理方法- 更新 ExamineDto 和 ExamineUser 类,添加 selfScore 字段 - 修改数据库 mapper,增加 self_score 相关的 SQL 语句 - 优化工作日志查询 SQL,提高查询效率dev_1.1.0
parent
db51747dc7
commit
30c63b8c10
|
@ -106,6 +106,12 @@ public class ExamineDetailController extends BaseController {
|
|||
if (examineDto.getManageScore().compareTo(bigDecimal) != 0) {
|
||||
return AjaxResult.error("总分与明细分数不一致");
|
||||
}
|
||||
} else {
|
||||
//非主管需要计算个人分数
|
||||
Map<Integer, BigDecimal> scoreMap = examineDetailService.calculateScoreByDetail(examineDto.getTaskId()
|
||||
, examineDto.getExamineDetailList(), ReviewTypeEnum.SELF);
|
||||
BigDecimal bigDecimal = scoreMap.get(examineDto.getExamineId());
|
||||
examineDto.setSelfScore(bigDecimal);
|
||||
}
|
||||
|
||||
//保存detail详情
|
||||
|
|
|
@ -25,6 +25,7 @@ public class ExamineDto {
|
|||
private Integer examineId;
|
||||
private String judgeContent;
|
||||
private BigDecimal manageScore;
|
||||
private BigDecimal selfScore;
|
||||
private Integer taskId;
|
||||
private String reviewType;
|
||||
/**
|
||||
|
|
|
@ -131,7 +131,7 @@ public class ExamineDetailServiceImpl implements ExamineDetailService {
|
|||
examineUser.setId(dto.getExamineId());
|
||||
List<ExamineUser> list1 = userMapper.list(examineUser);
|
||||
if (CollUtil.isEmpty(list1)){
|
||||
throw new ServiceException("未找到考核人员");
|
||||
throw new ServiceException("未在考核任务中");
|
||||
}
|
||||
result.put("examineUser",list1.get(0));
|
||||
result.put("examineTask",examineTaskMapper.queryById(dto.getExamineTaskId()));
|
||||
|
@ -156,9 +156,6 @@ public class ExamineDetailServiceImpl implements ExamineDetailService {
|
|||
examineConfigQueryDto.setReviewType(typeEnum.getType());
|
||||
}
|
||||
List<ExamineConfig> configList = configMapper.list(examineConfigQueryDto);
|
||||
ExamineTask examineTask = examineTaskMapper.queryById(taskId);
|
||||
//系统核算单独处理
|
||||
dealSystemBusinessAccount(examineList, configList,examineTask);
|
||||
Map<Integer, ExamineConfig> configMap = configList.stream().collect(Collectors.toMap(ExamineConfig::getId, Function.identity()));
|
||||
Map<Integer, BigDecimal> scoreMap = new HashMap<>();
|
||||
for (ExamineDetail detail : examineList) {
|
||||
|
@ -181,37 +178,6 @@ public class ExamineDetailServiceImpl implements ExamineDetailService {
|
|||
return scoreMap;
|
||||
}
|
||||
|
||||
private void dealSystemBusinessAccount(List<ExamineDetail> examineList, List<ExamineConfig> configList, ExamineTask examineTask) {
|
||||
Map<Integer, ExamineConfig> systemExamineConfigMap = configList.stream().filter(item ->
|
||||
ReviewTypeEnum.SYSTEM.getType().equals(item.getReviewType())).collect(Collectors.toMap(ExamineConfig::getId, Function.identity()));
|
||||
//如有系统核算才处理
|
||||
if (CollUtil.isNotEmpty(systemExamineConfigMap)) {
|
||||
String workDay = sysDictDataService.selectDictLabel("pms_work_day", examineTask.getYear().toString());
|
||||
workDay = StrUtil.isNotEmpty(workDay) ? workDay : "251";
|
||||
BigDecimal configWorkDay = new BigDecimal(workDay);
|
||||
List<ExamineDetail> collect = examineList.stream().filter(item -> systemExamineConfigMap.containsKey(item.getConfigId())).collect(Collectors.toList());
|
||||
Map<Integer, BigDecimal> workTimeByExamineDetail = workLoggerService.getWorkTimeByExamineDetail(collect.stream().map(ExamineDetail::getExamineId).collect(Collectors.toList()));
|
||||
for (ExamineDetail examineDetail : collect) {
|
||||
BigDecimal bigDecimal = workTimeByExamineDetail.get(examineDetail.getExamineId());
|
||||
if (bigDecimal == null) {
|
||||
examineDetail.setScore(0);
|
||||
continue;
|
||||
}
|
||||
BigDecimal max = configWorkDay.multiply(new BigDecimal("0.9"));
|
||||
BigDecimal min = configWorkDay.multiply(new BigDecimal("0.8"));
|
||||
if (bigDecimal.compareTo(max) >= 0) {
|
||||
//比90%大 满分
|
||||
examineDetail.setScore(10);
|
||||
} else if (bigDecimal.compareTo(min) >= 0) {
|
||||
//比80%大 比90%小 6分
|
||||
examineDetail.setScore(6);
|
||||
} else {
|
||||
//比80%小 0分
|
||||
examineDetail.setScore(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveBatch(List<ExamineDetail> examineDetailList) {
|
||||
|
|
|
@ -44,5 +44,6 @@ public class ExamineTaskDto implements Serializable {
|
|||
private Integer year;
|
||||
private Integer examineStatusSelf;
|
||||
private Integer examineId;
|
||||
private Boolean taskEditFlag;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ public class ExamineUser extends BaseEntity {
|
|||
* 主管评分(权重计算后)
|
||||
*/
|
||||
private BigDecimal manageScore;
|
||||
private BigDecimal selfScore;
|
||||
/**
|
||||
* 个人评分状态 0:待完成 1:已完成
|
||||
*/
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
package tech.unissense.pms.business.examine.user.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import tech.unissense.pms.business.examine.config.domain.ExamineConfig;
|
||||
import tech.unissense.pms.business.examine.config.enums.ReviewTypeEnum;
|
||||
import tech.unissense.pms.business.examine.config.service.impl.ExamineConfigServiceImpl;
|
||||
import tech.unissense.pms.business.examine.detail.domain.ExamineDetail;
|
||||
import tech.unissense.pms.business.examine.detail.dto.ExamineDto;
|
||||
import tech.unissense.pms.business.examine.detail.service.ExamineDetailService;
|
||||
import tech.unissense.pms.business.examine.task.domain.ExamineTask;
|
||||
import tech.unissense.pms.business.examine.task.mapper.ExamineTaskMapper;
|
||||
import tech.unissense.pms.business.examine.user.domain.ExamineUser;
|
||||
import tech.unissense.pms.business.examine.user.mapper.ExamineUserMapper;
|
||||
import tech.unissense.pms.business.examine.user.service.ExamineUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.unissense.pms.business.work.logger.service.IWorkLoggerService;
|
||||
import tech.unissense.pms.common.annotation.DataScope;
|
||||
import tech.unissense.pms.common.utils.SecurityUtils;
|
||||
import tech.unissense.pms.system.service.ISysDictDataService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
@ -19,6 +27,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +42,14 @@ public class ExamineUserServiceImpl implements ExamineUserService {
|
|||
private ExamineUserMapper examineUserMapper;
|
||||
@Autowired
|
||||
private ExamineDetailService detailService;
|
||||
@Autowired
|
||||
private ExamineConfigServiceImpl examineConfigService;
|
||||
@Resource
|
||||
private ExamineTaskMapper taskMapper;
|
||||
@Autowired
|
||||
private IWorkLoggerService workLoggerService;
|
||||
@Autowired
|
||||
private ISysDictDataService sysDictDataService;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
|
@ -97,6 +114,7 @@ public class ExamineUserServiceImpl implements ExamineUserService {
|
|||
examineUser.setExamineStatus(examineDto.getExamineStatus());
|
||||
examineUser.setExamineStatusSelf(examineDto.getExamineStatusSelf());
|
||||
examineUser.setManageScore(examineDto.getManageScore());
|
||||
examineUser.setSelfScore(examineDto.getSelfScore());
|
||||
String examineStatus = StrUtil.isNotEmpty(examineDto.getExamineStatus()) ? examineDto.getExamineStatus() : user.getExamineStatus();
|
||||
String examineStatusSelf = StrUtil.isNotEmpty(examineDto.getExamineStatusSelf()) ? examineDto.getExamineStatusSelf() : user.getExamineStatusSelf();
|
||||
if ("1".equals(examineStatus) && user.getManageUserId() == null) {
|
||||
|
@ -105,6 +123,8 @@ public class ExamineUserServiceImpl implements ExamineUserService {
|
|||
//均已完成 计算总分数
|
||||
boolean flag = "1".equals(examineStatus) && "1".equals(examineStatusSelf);
|
||||
if (flag) {
|
||||
//保存系统核算分数
|
||||
detailService.insert(dealSystemBusinessAccount(examineDto.getExamineId(), examineDto.getTaskId()));
|
||||
Map<Integer, BigDecimal> scoreMap = detailService.calculateScoreByExamineId(examineDto.getTaskId()
|
||||
, Collections.singletonList(examineDto.getExamineId()), ReviewTypeEnum.ALL);
|
||||
examineUser.setScore(scoreMap.get(examineDto.getExamineId()));
|
||||
|
@ -113,6 +133,42 @@ public class ExamineUserServiceImpl implements ExamineUserService {
|
|||
|
||||
}
|
||||
|
||||
private ExamineDetail dealSystemBusinessAccount(Integer examineId, Integer taskId) {
|
||||
ExamineTask examineTask = taskMapper.queryById(taskId);
|
||||
//如有系统核算才处理
|
||||
String workDay = sysDictDataService.selectDictLabel("pms_work_day", examineTask.getYear().toString());
|
||||
workDay = StrUtil.isNotEmpty(workDay) ? workDay : "251";
|
||||
BigDecimal configWorkDay = new BigDecimal(workDay);
|
||||
|
||||
Map<Integer, BigDecimal> workTimeByExamineDetail = workLoggerService.getWorkTimeByExamineDetail(Collections.singletonList(examineId));
|
||||
ExamineDetail examineDetail = new ExamineDetail();
|
||||
examineDetail.setExamineId(examineId);
|
||||
ExamineConfig examineConfig = new ExamineConfig();
|
||||
examineConfig.setExamineTaskId(taskId);
|
||||
examineConfig.setReviewType(ReviewTypeEnum.SYSTEM.getType());
|
||||
List<ExamineConfig> configList = examineConfigService.list(examineConfig);
|
||||
examineDetail.setConfigId(configList.get(0).getId());
|
||||
BigDecimal bigDecimal = workTimeByExamineDetail.get(examineDetail.getExamineId());
|
||||
if (bigDecimal == null) {
|
||||
examineDetail.setScore(0);
|
||||
return examineDetail;
|
||||
}
|
||||
BigDecimal max = configWorkDay.multiply(new BigDecimal("0.9"));
|
||||
BigDecimal min = configWorkDay.multiply(new BigDecimal("0.8"));
|
||||
if (bigDecimal.compareTo(max) >= 0) {
|
||||
//比90%大 满分
|
||||
examineDetail.setScore(10);
|
||||
} else if (bigDecimal.compareTo(min) >= 0) {
|
||||
//比80%大 比90%小 6分
|
||||
examineDetail.setScore(6);
|
||||
} else {
|
||||
//比80%小 0分
|
||||
examineDetail.setScore(0);
|
||||
}
|
||||
return examineDetail;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ExamineUser queryByTaskIdAndUserId(Integer examineTaskId, Integer userId) {
|
||||
return examineUserMapper.queryByTaskIdAndUserId(examineTaskId, userId);
|
||||
|
|
|
@ -256,14 +256,13 @@
|
|||
</select>
|
||||
<select id="listWorkTimeByExamineDetail"
|
||||
resultType="tech.unissense.pms.business.work.logger.domain.WorkLogger">
|
||||
SELECT SUM(w.work_time) AS work_time, e.id
|
||||
FROM pms_work_logger w
|
||||
SELECT w.work_time, e.id
|
||||
FROM ( select sum(work_time) as work_time,user_id from pms_work_logger group by user_id) w
|
||||
JOIN pms_examine_user e ON w.user_id = e.user_id
|
||||
WHERE e.id IN
|
||||
<foreach collection="examineIdList" item="examineId" open="(" separator="," close=")">
|
||||
#{examineId}
|
||||
</foreach>
|
||||
GROUP BY w.user_id
|
||||
</select>
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<result property="examineStatus" column="examine_status" jdbcType="VARCHAR"/>
|
||||
<result property="examineStatusSelf" column="examine_status_self" jdbcType="VARCHAR"/>
|
||||
<result property="manageUserId" column="manage_user_id" jdbcType="INTEGER"/>
|
||||
<result property="selfScore" column="self_score" jdbcType="NUMERIC"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="base_query">
|
||||
|
@ -23,7 +24,8 @@
|
|||
manage_score,
|
||||
examine_status,
|
||||
examine_status_self,
|
||||
manage_user_id
|
||||
manage_user_id,
|
||||
self_score
|
||||
from pms_examine_user
|
||||
|
||||
</sql>
|
||||
|
@ -70,6 +72,7 @@
|
|||
t1.examine_status,
|
||||
t1.examine_status_self,
|
||||
t1.manage_user_id,
|
||||
t1.self_score,
|
||||
t2.nick_name as userName,
|
||||
t3.nick_name as manageUserName
|
||||
from pms_examine_user t1 left join sys_user t2 on t1.user_id = t2.user_id
|
||||
|
@ -164,6 +167,9 @@
|
|||
<if test="manageScore != null">
|
||||
manage_score = #{manageScore},
|
||||
</if>
|
||||
<if test="selfScore != null">
|
||||
self_score = #{selfScore},
|
||||
</if>
|
||||
<if test="examineStatus != null and examineStatus != ''">
|
||||
examine_status = #{examineStatus},
|
||||
</if>
|
||||
|
|
Loading…
Reference in New Issue