考核任务编辑修改,评分修改,审核通过,驳回,作废

master
wany 2024-09-10 15:08:27 +08:00
parent 8ef24e5320
commit 3de7f0e535
10 changed files with 282 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R; import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.so.AssessTaskPageSo; import com.gunshi.project.xyt.entity.so.AssessTaskPageSo;
import com.gunshi.project.xyt.entity.vo.AssessResultVo;
import com.gunshi.project.xyt.model.AssessTask; import com.gunshi.project.xyt.model.AssessTask;
import com.gunshi.project.xyt.service.AssessTaskService; import com.gunshi.project.xyt.service.AssessTaskService;
import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Insert;
@ -13,6 +14,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* : * :
* author: xusan * author: xusan
@ -75,6 +79,30 @@ public class AssessTaskController extends AbstractCommonFileController{
return R.ok(service.myDone(page)); return R.ok(service.myDone(page));
} }
@Operation(summary = "审核通过")
@GetMapping("/pass/{id}")
public R<String> pass(@Schema(name = "id") @PathVariable("id") Long id) {
return R.ok(service.pass(id));
}
@Operation(summary = "作废")
@GetMapping("/cancel/{id}")
public R<String> cancel(@Schema(name = "id") @PathVariable("id") Long id) {
return R.ok(service.cancel(id));
}
@Operation(summary = "驳回评分")
@GetMapping("/reject/{id}")
public R<String> reject(@Schema(name = "id") @PathVariable("id") Long id) {
return R.ok(service.reject(id));
}
@Operation(summary = "考核结果")
@GetMapping("/result/{id}")
public R<List<AssessResultVo>> result(@Schema(name = "id") @PathVariable("id") Long id) {
return R.ok(service.result(id));
}
@Override @Override
public String getGroupId() { public String getGroupId() {
return "assessTask"; return "assessTask";

View File

@ -0,0 +1,47 @@
package com.gunshi.project.xyt.entity.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.math.BigDecimal;
@Data
@ExcelIgnoreUnannotated
public class AssessResultVo {
@ExcelProperty({"考核对象"})
@ColumnWidth(15)
private String objectUserName;
@ExcelProperty({"考核类目"})
private String categoryName;
@ExcelProperty({"指标名称"})
private String indicatorName;
@ExcelProperty({"扣分"})
private BigDecimal deductScore;
@ExcelProperty({"考核得分"})
private BigDecimal resScore;
@ExcelIgnore
@JsonSerialize(using = ToStringSerializer.class)
private Long objectId;
@ExcelIgnore
@JsonSerialize(using = ToStringSerializer.class)
private Long indicatorId;
@ExcelIgnore
private Integer standardScore;
@ExcelIgnore
private BigDecimal assessScore;
}

View File

@ -0,0 +1,15 @@
package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.xyt.model.AssessObjectRating;
import org.apache.ibatis.annotations.Mapper;
/**
* :
* author: xusan
* date: 2024-09-10 10:44:14
*/
@Mapper
public interface AssessObjectRatingMapper extends BaseMapper<AssessObjectRating> {
}

View File

@ -3,6 +3,7 @@ package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.project.xyt.entity.so.AssessTaskPageSo; import com.gunshi.project.xyt.entity.so.AssessTaskPageSo;
import com.gunshi.project.xyt.entity.vo.AssessResultVo;
import com.gunshi.project.xyt.model.AssessObject; import com.gunshi.project.xyt.model.AssessObject;
import com.gunshi.project.xyt.model.AssessTask; import com.gunshi.project.xyt.model.AssessTask;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -29,7 +30,7 @@ public interface AssessTaskMapper extends BaseMapper<AssessTask> {
@Select(""" @Select("""
<script> <script>
select t.* from public.assess_task t where t.id in select t.* from public.assess_task t where t.status != 4 and t.id in
(select distinct(task_id) from public.assess_team where team_user_id = #{obj.userId} (select distinct(task_id) from public.assess_team where team_user_id = #{obj.userId}
<if test="type == 1"> <if test="type == 1">
and status in (1,9) and status in (1,9)
@ -63,4 +64,14 @@ public interface AssessTaskMapper extends BaseMapper<AssessTask> {
""") """)
List<AssessObject> selectObject(@Param("taskId") Long id,@Param("userId") Long userId); List<AssessObject> selectObject(@Param("taskId") Long id,@Param("userId") Long userId);
@Select("""
<script>
select t.object_id,t.indicator_id,t.standard_score,t.assess_score,s.object_user_name,s.assess_score as resScore,m.indicator_name,n.name as categoryName from public.assess_object_rating t
left join public.assess_object s on t.object_id = s.id
left join public.assess_indicator m on t.indicator_id = m.id
left join public.assess_category n on m.category_id = n.id
where s.task_id = #{taskId}
</script>
""")
List<AssessResultVo> result(@Param("taskId") Long id);
} }

View File

@ -0,0 +1,63 @@
package com.gunshi.project.xyt.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* :
* author: xusan
* date: 2024-09-10 10:44:14
*/
@Schema(description="考核对象指标得分详情")
@Data
@TableName("public.assess_object_rating")
public class AssessObjectRating implements Serializable {
public final static String thisTableName = "AssessObjectRating";
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value="id", type= IdType.AUTO)
@Schema(description="主键")
private Long id;
/**
* id
*/
@TableField(value="object_id")
@Schema(description="考核对象id")
private Long objectId;
/**
* id
*/
@TableField(value="indicator_id")
@Schema(description="考核指标id")
private Long indicatorId;
/**
*
*/
@TableField(value="standard_score")
@Schema(description="标准分数")
private Integer standardScore;
/**
*
*/
@TableField(value="assess_score")
@Schema(description="考核得分")
private BigDecimal assessScore;
}

View File

@ -72,6 +72,10 @@ public class AssessTask implements Serializable {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long templateId; private Long templateId;
@TableField(exist = false)
@Schema(description="模板名称")
private String templateName;
/** /**
* *
*/ */
@ -97,10 +101,10 @@ public class AssessTask implements Serializable {
private Date endDate; private Date endDate;
/** /**
* 0 1 2 3 5 * 0 1 2 3 4
*/ */
@TableField(value="status") @TableField(value="status")
@Schema(description="状态0未启动 1评分中 2审核中 3已审核 5已作废)") @Schema(description="状态0未启动 1评分中 2审核中 3已审核 4已作废)")
private Integer status; private Integer status;
/** /**

View File

@ -0,0 +1,23 @@
package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.mapper.AssessObjectRatingMapper;
import com.gunshi.project.xyt.model.AssessObjectRating;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* :
* author: xusan
* date: 2024-09-10 10:44:14
*/
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class AssessObjectRatingService extends ServiceImpl<AssessObjectRatingMapper, AssessObjectRating>
{
}

View File

@ -34,13 +34,19 @@ public class AssessObjectService extends ServiceImpl<AssessObjectMapper, AssessO
o.setId(objectId); o.setId(objectId);
o.setTaskId(taskId); o.setTaskId(taskId);
o.setStatus(0); o.setStatus(0);
assessTeams.stream().forEach(t->{ for(int i =0 ;i <assessTeams.size();i++){
AssessTeam t = new AssessTeam();
t.setTeamUserId(assessTeams.get(i).getTeamUserId());
t.setTeamUserName(assessTeams.get(i).getTeamUserName());
t.setStandardScore(assessTeams.get(i).getStandardScore());
t.setObjectId(assessTeams.get(i).getObjectId());
t.setId(IdWorker.getId()); t.setId(IdWorker.getId());
t.setTaskId(taskId); t.setTaskId(taskId);
System.out.println(objectId);
t.setObjectId(objectId); t.setObjectId(objectId);
t.setStatus(0); t.setStatus(0);
}); teams.add(t);
teams.addAll(assessTeams); }
}); });
this.saveBatch(assessObjects); this.saveBatch(assessObjects);
assessTeamService.saveBatch(teams); assessTeamService.saveBatch(teams);

View File

@ -7,18 +7,23 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.so.AssessTaskPageSo; import com.gunshi.project.xyt.entity.so.AssessTaskPageSo;
import com.gunshi.project.xyt.entity.vo.AssessResultVo;
import com.gunshi.project.xyt.mapper.AssessTaskMapper; import com.gunshi.project.xyt.mapper.AssessTaskMapper;
import com.gunshi.project.xyt.mapper.AssessTemplateMapper;
import com.gunshi.project.xyt.model.AssessObject; import com.gunshi.project.xyt.model.AssessObject;
import com.gunshi.project.xyt.model.AssessTask; import com.gunshi.project.xyt.model.AssessTask;
import com.gunshi.project.xyt.model.AssessTeam; import com.gunshi.project.xyt.model.AssessTeam;
import com.gunshi.project.xyt.model.AssessTemplate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* : * :
@ -36,6 +41,9 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
@Autowired @Autowired
private FileAssociationsService fileService; private FileAssociationsService fileService;
@Autowired
private AssessTemplateMapper templateMapper;
public AssessTask saveData(AssessTask dto) { public AssessTask saveData(AssessTask dto) {
dto.setId(IdWorker.getId()); dto.setId(IdWorker.getId());
dto.setStatus(0); dto.setStatus(0);
@ -77,6 +85,8 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
public AssessTask detail(Long id) { public AssessTask detail(Long id) {
AssessTask task = this.getById(id); AssessTask task = this.getById(id);
AssessTemplate template = templateMapper.selectById(task.getTemplateId());
task.setTemplateName(template.getTemplateName());
task.setFiles(fileService.getFiles(getGroupId(),id.toString())); task.setFiles(fileService.getFiles(getGroupId(),id.toString()));
task.setAssessTeams(assessObjectService.getTeam(id)); task.setAssessTeams(assessObjectService.getTeam(id));
task.setAssessObjects(assessObjectService.getObject(id)); task.setAssessObjects(assessObjectService.getObject(id));
@ -97,15 +107,19 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
if(page.getDateRangeSo() != null && page.getDateRangeSo().getEnd() != null){ if(page.getDateRangeSo() != null && page.getDateRangeSo().getEnd() != null){
queryWrapper.le(AssessTask::getStartDate,page.getDateRangeSo().getEnd()); queryWrapper.le(AssessTask::getStartDate,page.getDateRangeSo().getEnd());
} }
return this.page(page.getPageSo().toPage(),queryWrapper); Page<AssessTask> res = this.page(page.getPageSo().toPage(), queryWrapper);
if (res.getRecords() != null && res.getRecords().size() > 0) {
for (AssessTask record : res.getRecords()) {
record.setAssessObjects(assessObjectService.getObject(record.getId()));
}
}
return res;
} }
public String start(Long id) { public String start(Long id) {
AssessTask task = this.getById(id); AssessTask task = this.getById(id);
task.setStatus(1); task.setStatus(1);
this.updateById(task); this.updateById(task);
//生成考核评分任务
Long templateId = task.getTemplateId();
//任务中的考核对象 //任务中的考核对象
List<AssessObject> objects = assessObjectService.getObject(id); List<AssessObject> objects = assessObjectService.getObject(id);
objects.stream().forEach(o->o.setStatus(1)); objects.stream().forEach(o->o.setStatus(1));
@ -139,6 +153,41 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
} }
return res; return res;
} }
public String pass(Long id) {
AssessTask task = this.getById(id);
task.setStatus(3);
this.updateById(task);
return "审核通过";
}
public String cancel(Long id) {
AssessTask task = this.getById(id);
task.setStatus(4);
this.updateById(task);
return "作废成功";
}
public String reject(Long id) {
AssessTask task = this.getById(id);
task.setStatus(1);
this.updateById(task);
//任务中的考核对象
List<AssessObject> objects = assessObjectService.getObject(id);
objects.stream().forEach(o->o.setStatus(1));
assessObjectService.updateBatchById(objects);
//任务中的考核成员
List<AssessTeam> teams = assessObjectService.getTeam(id);
teams.stream().forEach(o->o.setStatus(1));
assessObjectService.updateTeams(teams);
return "驳回评分成功";
}
public List<AssessResultVo> result(Long id) {
List<AssessResultVo> list = this.baseMapper.result(id);
list.stream().forEach(o->o.setDeductScore(new BigDecimal(o.getStandardScore()).subtract(o.getAssessScore())));
return list.stream().filter(o->o.getDeductScore().compareTo(new BigDecimal(0)) > 0).collect(Collectors.toList());
}
} }

View File

@ -15,8 +15,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -44,6 +46,9 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
@Autowired @Autowired
private AssessTemplateMapper templateMapper; private AssessTemplateMapper templateMapper;
@Autowired
private AssessObjectRatingService assessObjectRatingService;
public Boolean score(AssessScoreVo vo) { public Boolean score(AssessScoreVo vo) {
List<AssessTeamRating> ratings = vo.getRatings(); List<AssessTeamRating> ratings = vo.getRatings();
@ -64,14 +69,15 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
assessTeam.setAssessScore(vo.getScore()); assessTeam.setAssessScore(vo.getScore());
assessTeam.setAssessLevel(level); assessTeam.setAssessLevel(level);
teamMapper.updateById(assessTeam); teamMapper.updateById(assessTeam);
Boolean res = this.saveBatch(ratings);
updateObjectAndTask(assessTeam.getObjectId(),vo.getTaskId(),template,task); updateObjectAndTask(assessTeam.getObjectId(),vo.getTaskId(),template,task);
return this.saveBatch(ratings); return res;
} }
private void delData(Long teamId) { private void delData(Long teamId) {
List<AssessTeamRating> teamRatings = this.list(new QueryWrapper<AssessTeamRating>().eq("team_id", teamId)); List<AssessTeamRating> teamRatings = this.list(new QueryWrapper<AssessTeamRating>().eq("team_id", teamId));
if(CollectionUtils.isNotEmpty(teamRatings)){ if(CollectionUtils.isNotEmpty(teamRatings)){
List<Long> ratingIds = teamRatings.stream().map(AssessTeamRating::getId).collect(Collectors.toList()); List<String> ratingIds = teamRatings.stream().map(AssessTeamRating::getId).map(Objects::toString).collect(Collectors.toList());
fileService.remove(new QueryWrapper<FileAssociations>().in("business_id",ratingIds)); fileService.remove(new QueryWrapper<FileAssociations>().in("business_id",ratingIds));
this.remove(new QueryWrapper<AssessTeamRating>().eq("team_id", teamId)); this.remove(new QueryWrapper<AssessTeamRating>().eq("team_id", teamId));
} }
@ -100,7 +106,7 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
if(teams.size() == finishTeams.size()){ if(teams.size() == finishTeams.size()){
Integer scoreWay = task.getScoreWay(); Integer scoreWay = task.getScoreWay();
List<Long> teamIds = finishTeams.stream().map(AssessTeam::getId).collect(Collectors.toList()); List<Long> teamIds = finishTeams.stream().map(AssessTeam::getId).collect(Collectors.toList());
BigDecimal assessScore = calcScore(scoreWay,teamIds); BigDecimal assessScore = calcScore(scoreWay,teamIds,objectId);
Integer level = calcLevel(template, assessScore); Integer level = calcLevel(template, assessScore);
AssessObject object = objectMapper.selectById(objectId); AssessObject object = objectMapper.selectById(objectId);
object.setStatus(2); object.setStatus(2);
@ -116,19 +122,32 @@ public class AssessTeamRatingService extends ServiceImpl<AssessTeamRatingMapper,
} }
} }
private BigDecimal calcScore(Integer scoreWay, List<Long> teamIds) { private BigDecimal calcScore(Integer scoreWay, List<Long> teamIds,Long objectId) {
BigDecimal score = new BigDecimal(0); final BigDecimal[] score = {new BigDecimal(0)};
List<AssessTeamRating> ratings = this.list(new QueryWrapper<AssessTeamRating>().in("team_id",teamIds)); 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<Long, List<BigDecimal>> map = ratings.stream().collect(Collectors.groupingBy(AssessTeamRating::getIndicatorId,Collectors.mapping(AssessTeamRating::getAssessScore,Collectors.toList())));
Map<Long, List<Integer>> standardMap = ratings.stream().collect(Collectors.groupingBy(AssessTeamRating::getIndicatorId,Collectors.mapping(AssessTeamRating::getStandardScore,Collectors.toList())));
List<AssessObjectRating> list = new ArrayList<>();
map.entrySet().forEach(o->{ map.entrySet().forEach(o->{
List<BigDecimal> value = o.getValue(); List<BigDecimal> value = o.getValue();
AssessObjectRating objectRating = new AssessObjectRating();
objectRating.setId(IdWorker.getId());
objectRating.setObjectId(objectId);
objectRating.setIndicatorId(o.getKey());
objectRating.setStandardScore(standardMap.get(o.getKey()).get(0));
if (scoreWay == 1){ if (scoreWay == 1){
score.add(value.stream().min(BigDecimal::compareTo).get()); BigDecimal val = value.stream().min(BigDecimal::compareTo).get();
objectRating.setAssessScore(val);
score[0] = score[0].add(val);
}else{ }else{
score.add(value.stream().reduce(BigDecimal.ZERO,BigDecimal::add).divide(BigDecimal.valueOf(value.size()),2, RoundingMode.HALF_UP)); BigDecimal vide = value.stream().reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(value.size()), 2, RoundingMode.HALF_UP);
objectRating.setAssessScore(vide);
score[0] = score[0].add(vide);
} }
list.add(objectRating);
}); });
return score; assessObjectRatingService.saveBatch(list);
return score[0];
} }
public String getGroupId() { public String getGroupId() {