查看评分详情

master
wany 2024-09-10 09:27:05 +08:00
parent f196358465
commit 8ef24e5320
6 changed files with 57 additions and 15 deletions

View File

@ -12,6 +12,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* :
@ -40,9 +41,15 @@ public class AssessTeamRatingController extends AbstractCommonFileController{
}
@Operation(summary = "我的待办/已办-查看评分详情")
@GetMapping("/detail/{teamId}")
public R<List<AssessRatingVo>> detail(@Schema(name = "teamId") @PathVariable("teamId") Long teamId) {
return R.ok(service.detail(teamId));
@GetMapping("/do/detail/{teamId}")
public R<List<AssessRatingVo>> doDetail(@Schema(name = "teamId") @PathVariable("teamId") Long teamId) {
return R.ok(service.doDetail(teamId));
}
@Operation(summary = "考核任务清单-查看评分详情")
@GetMapping("/scoreDetail/{objectId}")
public R<Map<Long,List<AssessRatingVo>>> scoreDetail(@Schema(name = "objectId") @PathVariable("objectId") Long objectId) {
return R.ok(service.scoreDetail(objectId));
}

View File

@ -22,4 +22,11 @@ public class AssessRatingVo extends AssessTeamRating{
@Schema(description="标准分数")
private Integer standardScore;
@Schema(description="考核成员id")
@JsonSerialize(using = ToStringSerializer.class)
private Long teamUserId;
@Schema(description="考核成员")
private String teamUserName;
}

View File

@ -45,7 +45,7 @@ public interface AssessTaskMapper extends BaseMapper<AssessTask> {
and t.start_date <![CDATA[>=]]> #{obj.dateRangeSo.start}
</if>
<if test="obj.dateRangeSo != null and obj.dateRangeSo.end != null">
and t.end_date <![CDATA[<=]]> #{obj.dateRangeSo.end}
and t.start_date <![CDATA[<=]]> #{obj.dateRangeSo.end}
</if>
<if test="obj.status != null">
and t.status = #{obj.status}

View File

@ -19,7 +19,7 @@ public interface AssessTeamRatingMapper extends BaseMapper<AssessTeamRating> {
@Select("""
<script>
select t1.*,t2.indicator_name,t2.category_id,t3.name as categoryName from public.assess_team_rating t1
select t1.*,t2.indicator_name,t2.category_id,t3.name from public.assess_team_rating t1
left join public.assess_indicator t2 on t1.indicator_id = t2.id
left join public.assess_category t3 on t2.category_id = t3.id
where t1.team_id = #{teamId}
@ -27,4 +27,16 @@ public interface AssessTeamRatingMapper extends BaseMapper<AssessTeamRating> {
</script>
""")
List<AssessRatingVo> scoreDetail(@Param("teamId") Long teamId);
@Select("""
<script>
select t1.*,t2.indicator_name,t2.category_id,t3.name,t4.team_user_id,t4.team_user_name from public.assess_team_rating t1
left join public.assess_indicator t2 on t1.indicator_id = t2.id
left join public.assess_category t3 on t2.category_id = t3.id
left join public.assess_team t4 on t1.team_id = t4.id
where t1.team_id in (select id from public.assess_team where object_id = #{objectId})
order by t2.order_index
</script>
""")
List<AssessRatingVo> scoreByObjectId(@Param("objectId") Long objectId);
}

View File

@ -95,7 +95,7 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
queryWrapper.ge(AssessTask::getStartDate,page.getDateRangeSo().getStart());
}
if(page.getDateRangeSo() != null && page.getDateRangeSo().getEnd() != null){
queryWrapper.le(AssessTask::getEndDate,page.getDateRangeSo().getEnd());
queryWrapper.le(AssessTask::getStartDate,page.getDateRangeSo().getEnd());
}
return this.page(page.getPageSo().toPage(),queryWrapper);
}

View File

@ -15,8 +15,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -99,12 +99,8 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
List<AssessTeam> finishTeams = teams.stream().filter(o -> o.getStatus() == 2).collect(Collectors.toList());
if(teams.size() == finishTeams.size()){
Integer scoreWay = task.getScoreWay();
BigDecimal assessScore;
if(scoreWay == 1){
assessScore = finishTeams.stream().min(Comparator.comparing(AssessTeam::getAssessScore)).get().getAssessScore();
}else {
assessScore = finishTeams.stream().map(AssessTeam::getAssessScore).reduce(BigDecimal.ZERO,BigDecimal::add).divide(BigDecimal.valueOf(finishTeams.size()),2, RoundingMode.HALF_UP);
}
List<Long> teamIds = finishTeams.stream().map(AssessTeam::getId).collect(Collectors.toList());
BigDecimal assessScore = calcScore(scoreWay,teamIds);
Integer level = calcLevel(template, assessScore);
AssessObject object = objectMapper.selectById(objectId);
object.setStatus(2);
@ -120,11 +116,26 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
}
}
private BigDecimal calcScore(Integer scoreWay, List<Long> teamIds) {
BigDecimal score = new BigDecimal(0);
List<AssessTeamRating> ratings = this.list(new QueryWrapper<AssessTeamRating>().in("team_id",teamIds));
Map<Long, List<BigDecimal>> map = ratings.stream().collect(Collectors.groupingBy(AssessTeamRating::getIndicatorId,Collectors.mapping(AssessTeamRating::getAssessScore,Collectors.toList())));
map.entrySet().forEach(o->{
List<BigDecimal> value = o.getValue();
if (scoreWay == 1){
score.add(value.stream().min(BigDecimal::compareTo).get());
}else{
score.add(value.stream().reduce(BigDecimal.ZERO,BigDecimal::add).divide(BigDecimal.valueOf(value.size()),2, RoundingMode.HALF_UP));
}
});
return score;
}
public String getGroupId() {
return "assessTeamRating";
}
public List<AssessRatingVo> detail(Long teamId) {
public List<AssessRatingVo> doDetail(Long teamId) {
List<AssessRatingVo> list = this.baseMapper.scoreDetail(teamId);
for (AssessRatingVo vo : list){
if(vo.getIsNeedRectify() == 1){
@ -146,6 +157,11 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
teamMapper.updateById(assessTeam);
return this.saveBatch(ratings);
}
public Map<Long,List<AssessRatingVo>> scoreDetail(Long objectId) {
List<AssessRatingVo> list = this.baseMapper.scoreByObjectId(objectId);
return list.stream().collect(Collectors.groupingBy(AssessTeamRating::getIndicatorId));
}
}