From 3de7f0e5355ec56258dec60fee07d860b8a584fe Mon Sep 17 00:00:00 2001 From: wany <13995595726@qq.com> Date: Tue, 10 Sep 2024 15:08:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E6=A0=B8=E4=BB=BB=E5=8A=A1=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=8C=E8=AF=84=E5=88=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E5=AE=A1=E6=A0=B8=E9=80=9A=E8=BF=87=EF=BC=8C?= =?UTF-8?q?=E9=A9=B3=E5=9B=9E=EF=BC=8C=E4=BD=9C=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyt/controller/AssessTaskController.java | 28 +++++++++ .../project/xyt/entity/vo/AssessResultVo.java | 47 ++++++++++++++ .../xyt/mapper/AssessObjectRatingMapper.java | 15 +++++ .../project/xyt/mapper/AssessTaskMapper.java | 13 +++- .../project/xyt/model/AssessObjectRating.java | 63 +++++++++++++++++++ .../gunshi/project/xyt/model/AssessTask.java | 8 ++- .../service/AssessObjectRatingService.java | 23 +++++++ .../xyt/service/AssessObjectService.java | 12 +++- .../xyt/service/AssessTaskService.java | 55 +++++++++++++++- .../xyt/service/AssessTeamRatingService.java | 35 ++++++++--- 10 files changed, 282 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java create mode 100644 src/main/java/com/gunshi/project/xyt/mapper/AssessObjectRatingMapper.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/AssessObjectRating.java create mode 100644 src/main/java/com/gunshi/project/xyt/service/AssessObjectRatingService.java diff --git a/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java b/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java index f1a8b86..660db92 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java @@ -3,6 +3,7 @@ package com.gunshi.project.xyt.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gunshi.core.result.R; 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.service.AssessTaskService; 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.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; + +import java.util.List; + /** * 描述: 考核任务 * author: xusan @@ -75,6 +79,30 @@ public class AssessTaskController extends AbstractCommonFileController{ return R.ok(service.myDone(page)); } + @Operation(summary = "审核通过") + @GetMapping("/pass/{id}") + public R pass(@Schema(name = "id") @PathVariable("id") Long id) { + return R.ok(service.pass(id)); + } + + @Operation(summary = "作废") + @GetMapping("/cancel/{id}") + public R cancel(@Schema(name = "id") @PathVariable("id") Long id) { + return R.ok(service.cancel(id)); + } + + @Operation(summary = "驳回评分") + @GetMapping("/reject/{id}") + public R reject(@Schema(name = "id") @PathVariable("id") Long id) { + return R.ok(service.reject(id)); + } + + @Operation(summary = "考核结果") + @GetMapping("/result/{id}") + public R> result(@Schema(name = "id") @PathVariable("id") Long id) { + return R.ok(service.result(id)); + } + @Override public String getGroupId() { return "assessTask"; diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java new file mode 100644 index 0000000..911208d --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java @@ -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; +} diff --git a/src/main/java/com/gunshi/project/xyt/mapper/AssessObjectRatingMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/AssessObjectRatingMapper.java new file mode 100644 index 0000000..7759a1a --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/mapper/AssessObjectRatingMapper.java @@ -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 { + +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/mapper/AssessTaskMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/AssessTaskMapper.java index b96b8c7..5c7bca1 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/AssessTaskMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/AssessTaskMapper.java @@ -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.entity.vo.AssessResultVo; import com.gunshi.project.xyt.model.AssessObject; import com.gunshi.project.xyt.model.AssessTask; import org.apache.ibatis.annotations.Mapper; @@ -29,7 +30,7 @@ public interface AssessTaskMapper extends BaseMapper { @Select(""" + """) + List result(@Param("taskId") Long id); } \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/AssessObjectRating.java b/src/main/java/com/gunshi/project/xyt/model/AssessObjectRating.java new file mode 100644 index 0000000..4358af5 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/AssessObjectRating.java @@ -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; + +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/AssessTask.java b/src/main/java/com/gunshi/project/xyt/model/AssessTask.java index efc1241..c00c150 100644 --- a/src/main/java/com/gunshi/project/xyt/model/AssessTask.java +++ b/src/main/java/com/gunshi/project/xyt/model/AssessTask.java @@ -72,6 +72,10 @@ public class AssessTask implements Serializable { @JsonSerialize(using = ToStringSerializer.class) private Long templateId; + @TableField(exist = false) + @Schema(description="模板名称") + private String templateName; + /** * 考核批次 */ @@ -97,10 +101,10 @@ public class AssessTask implements Serializable { private Date endDate; /** - * 状态(0未启动 1评分中 2审核中 3已审核 5已作废) + * 状态(0未启动 1评分中 2审核中 3已审核 4已作废) */ @TableField(value="status") - @Schema(description="状态(0未启动 1评分中 2审核中 3已审核 5已作废)") + @Schema(description="状态(0未启动 1评分中 2审核中 3已审核 4已作废)") private Integer status; /** diff --git a/src/main/java/com/gunshi/project/xyt/service/AssessObjectRatingService.java b/src/main/java/com/gunshi/project/xyt/service/AssessObjectRatingService.java new file mode 100644 index 0000000..7dd74c5 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/AssessObjectRatingService.java @@ -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 +{ + +} + + diff --git a/src/main/java/com/gunshi/project/xyt/service/AssessObjectService.java b/src/main/java/com/gunshi/project/xyt/service/AssessObjectService.java index 9ae4528..830245b 100644 --- a/src/main/java/com/gunshi/project/xyt/service/AssessObjectService.java +++ b/src/main/java/com/gunshi/project/xyt/service/AssessObjectService.java @@ -34,13 +34,19 @@ public class AssessObjectService extends ServiceImpl{ + for(int i =0 ;i @Autowired private FileAssociationsService fileService; + @Autowired + private AssessTemplateMapper templateMapper; + public AssessTask saveData(AssessTask dto) { dto.setId(IdWorker.getId()); dto.setStatus(0); @@ -77,6 +85,8 @@ public class AssessTaskService extends ServiceImpl public AssessTask detail(Long id) { AssessTask task = this.getById(id); + AssessTemplate template = templateMapper.selectById(task.getTemplateId()); + task.setTemplateName(template.getTemplateName()); task.setFiles(fileService.getFiles(getGroupId(),id.toString())); task.setAssessTeams(assessObjectService.getTeam(id)); task.setAssessObjects(assessObjectService.getObject(id)); @@ -97,15 +107,19 @@ public class AssessTaskService extends ServiceImpl if(page.getDateRangeSo() != null && page.getDateRangeSo().getEnd() != null){ queryWrapper.le(AssessTask::getStartDate,page.getDateRangeSo().getEnd()); } - return this.page(page.getPageSo().toPage(),queryWrapper); + Page 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) { AssessTask task = this.getById(id); task.setStatus(1); this.updateById(task); - //生成考核评分任务 - Long templateId = task.getTemplateId(); //任务中的考核对象 List objects = assessObjectService.getObject(id); objects.stream().forEach(o->o.setStatus(1)); @@ -139,6 +153,41 @@ public class AssessTaskService extends ServiceImpl } 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 objects = assessObjectService.getObject(id); + objects.stream().forEach(o->o.setStatus(1)); + assessObjectService.updateBatchById(objects); + //任务中的考核成员 + List teams = assessObjectService.getTeam(id); + teams.stream().forEach(o->o.setStatus(1)); + assessObjectService.updateTeams(teams); + return "驳回评分成功"; + } + + public List result(Long id) { + List 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()); + } } diff --git a/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java b/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java index ac43e26..8801ed2 100644 --- a/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java +++ b/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java @@ -15,8 +15,10 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -44,6 +46,9 @@ public class AssessTeamRatingService extends ServiceImpl ratings = vo.getRatings(); @@ -64,14 +69,15 @@ public class AssessTeamRatingService extends ServiceImpl teamRatings = this.list(new QueryWrapper().eq("team_id", teamId)); if(CollectionUtils.isNotEmpty(teamRatings)){ - List ratingIds = teamRatings.stream().map(AssessTeamRating::getId).collect(Collectors.toList()); + List ratingIds = teamRatings.stream().map(AssessTeamRating::getId).map(Objects::toString).collect(Collectors.toList()); fileService.remove(new QueryWrapper().in("business_id",ratingIds)); this.remove(new QueryWrapper().eq("team_id", teamId)); } @@ -100,7 +106,7 @@ public class AssessTeamRatingService extends ServiceImpl 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); AssessObject object = objectMapper.selectById(objectId); object.setStatus(2); @@ -116,19 +122,32 @@ public class AssessTeamRatingService extends ServiceImpl teamIds) { - BigDecimal score = new BigDecimal(0); + private BigDecimal calcScore(Integer scoreWay, List teamIds,Long objectId) { + final BigDecimal[] score = {new BigDecimal(0)}; List ratings = this.list(new QueryWrapper().in("team_id",teamIds)); Map> map = ratings.stream().collect(Collectors.groupingBy(AssessTeamRating::getIndicatorId,Collectors.mapping(AssessTeamRating::getAssessScore,Collectors.toList()))); + Map> standardMap = ratings.stream().collect(Collectors.groupingBy(AssessTeamRating::getIndicatorId,Collectors.mapping(AssessTeamRating::getStandardScore,Collectors.toList()))); + List list = new ArrayList<>(); map.entrySet().forEach(o->{ List 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){ - 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{ - 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() {