我的待办,我的已办,评分保存,评分完成,我的待办/已办中评分详情
parent
50dc78cd13
commit
ae73871617
|
|
@ -63,12 +63,17 @@ public class AssessTaskController extends AbstractCommonFileController{
|
|||
return R.ok(service.start(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "考核任务清单")
|
||||
@Operation(summary = "我的待办")
|
||||
@PostMapping("/myTodo/page")
|
||||
public R<Page<AssessTask>> myTodo(@Validated @RequestBody AssessTaskPageSo page) {
|
||||
return R.ok(service.myTodo(page));
|
||||
}
|
||||
|
||||
@Operation(summary = "我的已办")
|
||||
@PostMapping("/myDone/page")
|
||||
public R<Page<AssessTask>> myDone(@Validated @RequestBody AssessTaskPageSo page) {
|
||||
return R.ok(service.myDone(page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.model.AssessTeamRating;
|
||||
import com.gunshi.project.xyt.entity.vo.AssessRatingVo;
|
||||
import com.gunshi.project.xyt.entity.vo.AssessScoreVo;
|
||||
import com.gunshi.project.xyt.service.AssessTeamRatingService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -28,10 +27,22 @@ public class AssessTeamRatingController extends AbstractCommonFileController{
|
|||
private AssessTeamRatingService service;
|
||||
|
||||
|
||||
@Operation(summary = "评分")
|
||||
@Operation(summary = "完成评分")
|
||||
@PostMapping("/score")
|
||||
public R<Boolean> score(@Validated @RequestBody List<AssessTeamRating> dto) {
|
||||
return R.ok(service.score(dto));
|
||||
public R<Boolean> score(@Validated @RequestBody AssessScoreVo vo) {
|
||||
return R.ok(service.score(vo));
|
||||
}
|
||||
|
||||
@Operation(summary = "保存评分")
|
||||
@PostMapping("/saveScore")
|
||||
public R<Boolean> saveScore(@Validated @RequestBody AssessScoreVo vo) {
|
||||
return R.ok(service.saveScore(vo));
|
||||
}
|
||||
|
||||
@Operation(summary = "我的待办/已办-查看评分详情")
|
||||
@GetMapping("/detail/{teamId}")
|
||||
public R<List<AssessRatingVo>> detail(@Schema(name = "teamId") @PathVariable("teamId") Long teamId) {
|
||||
return R.ok(service.detail(teamId));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.xyt.model.AssessTeamRating;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AssessRatingVo extends AssessTeamRating{
|
||||
|
||||
@Schema(description="考核类目id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description="考核类目名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description="指标名称")
|
||||
private String indicatorName;
|
||||
|
||||
@Schema(description="标准分数")
|
||||
private Integer standardScore;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import com.gunshi.project.xyt.model.AssessTeamRating;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AssessScoreVo {
|
||||
|
||||
@Schema(description="任务Id")
|
||||
private Long taskId;
|
||||
|
||||
@Schema(description="总分")
|
||||
private BigDecimal score;
|
||||
|
||||
@Schema(description="评分信息")
|
||||
private List<AssessTeamRating> ratings;
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.gunshi.project.xyt.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.project.xyt.entity.so.AssessTaskPageSo;
|
||||
import com.gunshi.project.xyt.model.AssessObject;
|
||||
import com.gunshi.project.xyt.model.AssessTask;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -28,8 +29,15 @@ public interface AssessTaskMapper extends BaseMapper<AssessTask> {
|
|||
|
||||
@Select("""
|
||||
<script>
|
||||
select t.* from public.assess_task t where t.task_id in
|
||||
(select distinct(task_id) from public.assess_team where team_user_id = #{obj.userId} and status = 1)
|
||||
select t.* from public.assess_task t where t.id in
|
||||
(select distinct(task_id) from public.assess_team where team_user_id = #{obj.userId}
|
||||
<if test="type == 1">
|
||||
and status in (1,9)
|
||||
</if>
|
||||
<if test="type == 2">
|
||||
and status = 2
|
||||
</if>
|
||||
)
|
||||
<if test="obj.taskName != null and obj.taskName != ''">
|
||||
and t.task_name like concat('%', #{obj.taskName}, '%')
|
||||
</if>
|
||||
|
|
@ -44,5 +52,15 @@ public interface AssessTaskMapper extends BaseMapper<AssessTask> {
|
|||
</if>
|
||||
</script>
|
||||
""")
|
||||
Page<AssessTask> myTodo(Page<AssessTask> page,@Param("obj") AssessTaskPageSo page1);
|
||||
Page<AssessTask> myTodo(Page<AssessTask> page,@Param("obj") AssessTaskPageSo page1,@Param("type") Integer type);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select t.object_user_id,t.object_user_name,s.id,s.standard_score,s.assess_score,s.assess_level,s.status from public.assess_object t
|
||||
left join public.assess_team s on t.id = s.object_id
|
||||
where t.task_id = #{taskId} and s.team_user_id = #{userId}
|
||||
</script>
|
||||
""")
|
||||
List<AssessObject> selectObject(@Param("taskId") Long id,@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,13 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.entity.vo.AssessRatingVo;
|
||||
import com.gunshi.project.xyt.model.AssessTeamRating;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 考核评分详情
|
||||
|
|
@ -12,4 +17,14 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
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
|
||||
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}
|
||||
order by t2.order_index
|
||||
</script>
|
||||
""")
|
||||
List<AssessRatingVo> scoreDetail(@Param("teamId") Long teamId);
|
||||
}
|
||||
|
|
@ -93,10 +93,10 @@ public class AssessTeam implements Serializable {
|
|||
private Integer assessLevel;
|
||||
|
||||
/**
|
||||
* 状态(0未启动 1评分中 2已完成)
|
||||
* 状态(0未启动 1评分中 2已完成 9评分保存)
|
||||
*/
|
||||
@TableField(value="status")
|
||||
@Schema(description="状态(0未启动 1评分中 2已完成)")
|
||||
@Schema(description="状态(0未启动 1评分中 2已完成 9评分保存)")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
@ -118,7 +118,26 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
|
|||
}
|
||||
|
||||
public Page<AssessTask> myTodo(AssessTaskPageSo page) {
|
||||
return this.baseMapper.myTodo(page.getPageSo().toPage(),page);
|
||||
Page<AssessTask> res = this.baseMapper.myTodo(page.getPageSo().toPage(), page,1);
|
||||
if (res.getRecords() != null && res.getRecords().size() > 0) {
|
||||
fillObject(res.getRecords(),page.getUserId());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private void fillObject(List<AssessTask> records,Long userId) {
|
||||
for (AssessTask record : records) {
|
||||
List<AssessObject> list = this.baseMapper.selectObject(record.getId(),userId);
|
||||
record.setAssessObjects(list);
|
||||
}
|
||||
}
|
||||
|
||||
public Page<AssessTask> myDone(AssessTaskPageSo page) {
|
||||
Page<AssessTask> res = this.baseMapper.myTodo(page.getPageSo().toPage(), page,2);
|
||||
if (res.getRecords() != null && res.getRecords().size() > 0) {
|
||||
fillObject(res.getRecords(),page.getUserId());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,23 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.AssessTeamMapper;
|
||||
import com.gunshi.project.xyt.mapper.AssessTeamRatingMapper;
|
||||
import com.gunshi.project.xyt.model.AssessTeam;
|
||||
import com.gunshi.project.xyt.model.AssessTeamRating;
|
||||
import com.gunshi.project.xyt.entity.vo.AssessRatingVo;
|
||||
import com.gunshi.project.xyt.entity.vo.AssessScoreVo;
|
||||
import com.gunshi.project.xyt.mapper.*;
|
||||
import com.gunshi.project.xyt.model.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
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.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 考核评分详情
|
||||
|
|
@ -27,34 +32,120 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
|
|||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
@Autowired
|
||||
private AssessObjectMapper objectMapper;
|
||||
|
||||
@Autowired
|
||||
private AssessTaskMapper taskMapper;
|
||||
|
||||
@Autowired
|
||||
private AssessTeamMapper teamMapper;
|
||||
|
||||
@Autowired
|
||||
private AssessTemplateMapper templateMapper;
|
||||
|
||||
public Boolean score(List<AssessTeamRating> dto) {
|
||||
for(AssessTeamRating rating : dto){
|
||||
|
||||
public Boolean score(AssessScoreVo vo) {
|
||||
List<AssessTeamRating> ratings = vo.getRatings();
|
||||
Long teamId = ratings.get(0).getTeamId();
|
||||
this.delData(teamId);
|
||||
for(AssessTeamRating rating : ratings){
|
||||
rating.setId(IdWorker.getId());
|
||||
fileService.saveFile(rating.getFiles(), getGroupId(), rating.getId().toString());
|
||||
}
|
||||
AssessTask task = taskMapper.selectById(vo.getTaskId());
|
||||
//更新该考核人员对考核对象的状态为已评分
|
||||
Long teamId = dto.get(0).getTeamId();
|
||||
AssessTeam assessTeam = teamMapper.selectById(teamId);
|
||||
assessTeam.setStatus(2);
|
||||
//获取模板信息
|
||||
AssessTemplate template = templateMapper.selectById(task.getTemplateId());
|
||||
//根据总得分计算等级
|
||||
Integer level = calcLevel(template,vo.getScore());
|
||||
assessTeam.setAssessScore(vo.getScore());
|
||||
assessTeam.setAssessLevel(level);
|
||||
teamMapper.updateById(assessTeam);
|
||||
updateObjectAndTask(assessTeam.getObjectId(),assessTeam.getTaskId());
|
||||
return this.saveBatch(dto);
|
||||
updateObjectAndTask(assessTeam.getObjectId(),vo.getTaskId(),template,task);
|
||||
return this.saveBatch(ratings);
|
||||
}
|
||||
|
||||
private void updateObjectAndTask(Long objectId, Long taskId) {
|
||||
private void delData(Long teamId) {
|
||||
List<AssessTeamRating> teamRatings = this.list(new QueryWrapper<AssessTeamRating>().eq("team_id", teamId));
|
||||
if(CollectionUtils.isNotEmpty(teamRatings)){
|
||||
List<Long> ratingIds = teamRatings.stream().map(AssessTeamRating::getId).collect(Collectors.toList());
|
||||
fileService.remove(new QueryWrapper<FileAssociations>().in("business_id",ratingIds));
|
||||
this.remove(new QueryWrapper<AssessTeamRating>().eq("team_id", teamId));
|
||||
}
|
||||
}
|
||||
|
||||
private Integer calcLevel(AssessTemplate template, BigDecimal score) {
|
||||
BigDecimal excellentScore = template.getExcellentScore();
|
||||
BigDecimal goodScore = template.getGoodScore();
|
||||
BigDecimal passScore = template.getPassScore();
|
||||
if(score.compareTo(excellentScore) >= 0){
|
||||
return 1;
|
||||
}else if(score.compareTo(goodScore) >=0 && score.compareTo(excellentScore) < 0){
|
||||
return 2;
|
||||
}else if(score.compareTo(passScore) >=0 && score.compareTo(goodScore) < 0){
|
||||
return 3;
|
||||
}else{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateObjectAndTask(Long objectId, Long taskId,AssessTemplate template,AssessTask task) {
|
||||
//先判断该次评分是否是该考核对象的最后一次评分
|
||||
//todo
|
||||
//如果为最后一次评分,就要计算该考核对象的最终得分
|
||||
teamMapper.selectCount(new QueryWrapper<AssessTeam>().eq("object_id",objectId));
|
||||
List<AssessTeam> teams = teamMapper.selectList(new QueryWrapper<AssessTeam>().eq("object_id", objectId).eq("task_id", taskId));
|
||||
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);
|
||||
}
|
||||
Integer level = calcLevel(template, assessScore);
|
||||
AssessObject object = objectMapper.selectById(objectId);
|
||||
object.setStatus(2);
|
||||
object.setAssessScore(assessScore);
|
||||
object.setAssessLevel(level);
|
||||
objectMapper.updateById(object);
|
||||
//判断该考核任务是否存在未打分的对象,不存在则更新考核任务的状态为已完成
|
||||
Long taskCount = objectMapper.selectCount(new QueryWrapper<AssessObject>().eq("task_id", taskId).eq("status", 1));
|
||||
if(taskCount == 0){
|
||||
task.setStatus(2);
|
||||
taskMapper.updateById(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return "assessTeamRating";
|
||||
}
|
||||
|
||||
public List<AssessRatingVo> detail(Long teamId) {
|
||||
List<AssessRatingVo> list = this.baseMapper.scoreDetail(teamId);
|
||||
for (AssessRatingVo vo : list){
|
||||
if(vo.getIsNeedRectify() == 1){
|
||||
vo.setFiles(fileService.getFiles(getGroupId(),vo.getId().toString()));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Boolean saveScore(AssessScoreVo vo) {
|
||||
List<AssessTeamRating> ratings = vo.getRatings();
|
||||
for(AssessTeamRating rating : ratings){
|
||||
rating.setId(IdWorker.getId());
|
||||
fileService.saveFile(rating.getFiles(), getGroupId(), rating.getId().toString());
|
||||
}
|
||||
Long teamId = ratings.get(0).getTeamId();
|
||||
AssessTeam assessTeam = teamMapper.selectById(teamId);
|
||||
assessTeam.setStatus(9);
|
||||
teamMapper.updateById(assessTeam);
|
||||
return this.saveBatch(ratings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue