From 13a3e4eb172546aec2c0961e748701906d77e694 Mon Sep 17 00:00:00 2001 From: mythxb Date: Tue, 2 Apr 2024 17:25:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E6=94=BF=E5=90=8C=E8=B4=A3=E8=AF=84?= =?UTF-8?q?=E5=88=86=20=E9=83=A8=E9=97=A8=E6=80=BB=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rzyc/bean/ex/ItemRatingDto.java | 74 +++++++++++ .../com/rzyc/bean/ex/UnitTotalScoreDto.java | 40 ++++++ .../com/rzyc/mapper/ex/ExPerformMapper.java | 5 + .../java/com/rzyc/model/ex/ExPerform.java | 4 + .../resources/mapper/ex/ExPerformMapper.xml | 8 ++ .../resources/mapper/ex/ExStandardMapper.xml | 6 +- .../rzyc/controller/ExamineController.java | 116 ++++++++++++++++++ 7 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 inventory-dao/src/main/java/com/rzyc/bean/ex/ItemRatingDto.java create mode 100644 inventory-dao/src/main/java/com/rzyc/bean/ex/UnitTotalScoreDto.java diff --git a/inventory-dao/src/main/java/com/rzyc/bean/ex/ItemRatingDto.java b/inventory-dao/src/main/java/com/rzyc/bean/ex/ItemRatingDto.java new file mode 100644 index 0000000..55230a4 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/bean/ex/ItemRatingDto.java @@ -0,0 +1,74 @@ +package com.rzyc.bean.ex; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author dong + * @date 2024-04-02 16:27 + * @Version V1.0 + */ +@ApiModel("管理员评分") +public class ItemRatingDto { + + @NotNull(message = "用户不能为空") + @ApiModelProperty(value = "用户id",required = true) + private String userId; + + @NotNull(message = "评分标准不能为空") + @ApiModelProperty(value = "评分标准id",required = true) + private String standardId; + + @NotNull(message = "分数") + @ApiModelProperty(value = "评分标准id",required = true) + private Double score; + + @NotNull(message = "部门不能为空") + @ApiModelProperty(value = "部门id",required = true) + private String performId; + + @ApiModelProperty(value = "意见建议") + private String opinion; + + public String getOpinion() { + return opinion; + } + + public void setOpinion(String opinion) { + this.opinion = opinion; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getStandardId() { + return standardId; + } + + public void setStandardId(String standardId) { + this.standardId = standardId; + } + + public Double getScore() { + return score; + } + + public void setScore(Double score) { + this.score = score; + } + + public String getPerformId() { + return performId; + } + + public void setPerformId(String performId) { + this.performId = performId; + } +} diff --git a/inventory-dao/src/main/java/com/rzyc/bean/ex/UnitTotalScoreDto.java b/inventory-dao/src/main/java/com/rzyc/bean/ex/UnitTotalScoreDto.java new file mode 100644 index 0000000..72e1557 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/bean/ex/UnitTotalScoreDto.java @@ -0,0 +1,40 @@ +package com.rzyc.bean.ex; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author dong + * @date 2024-04-02 17:10 + * @Version V1.0 + */ +@ApiModel("考核总分") +public class UnitTotalScoreDto { + + + @NotNull(message = "考核不能为空") + @ApiModelProperty(value = "考核id",required = true) + private String examineId; + + @NotNull(message = "部门不能为空") + @ApiModelProperty(value = "部门id",required = true) + private String performId; + + public String getExamineId() { + return examineId; + } + + public void setExamineId(String examineId) { + this.examineId = examineId; + } + + public String getPerformId() { + return performId; + } + + public void setPerformId(String performId) { + this.performId = performId; + } +} diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/ex/ExPerformMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/ex/ExPerformMapper.java index b76a601..39299cf 100644 --- a/inventory-dao/src/main/java/com/rzyc/mapper/ex/ExPerformMapper.java +++ b/inventory-dao/src/main/java/com/rzyc/mapper/ex/ExPerformMapper.java @@ -2,6 +2,7 @@ package com.rzyc.mapper.ex; import com.rzyc.model.ex.ExPerform; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; /** *

@@ -13,4 +14,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface ExPerformMapper extends BaseMapper { + /*查询总分*/ + ExPerform findPerform(@Param("performId") String performId, + @Param("examineId") String examineId); + } diff --git a/inventory-dao/src/main/java/com/rzyc/model/ex/ExPerform.java b/inventory-dao/src/main/java/com/rzyc/model/ex/ExPerform.java index 8e871fb..543b49d 100644 --- a/inventory-dao/src/main/java/com/rzyc/model/ex/ExPerform.java +++ b/inventory-dao/src/main/java/com/rzyc/model/ex/ExPerform.java @@ -5,6 +5,8 @@ import java.util.Date; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -42,6 +44,7 @@ public class ExPerform implements Serializable { @TableField("user_id") private String userId; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "创建时间") @TableField("create_time") private Date createTime; @@ -50,6 +53,7 @@ public class ExPerform implements Serializable { @TableField("create_by") private String createBy; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "修改时间") @TableField("modify_time") private Date modifyTime; diff --git a/inventory-dao/src/main/resources/mapper/ex/ExPerformMapper.xml b/inventory-dao/src/main/resources/mapper/ex/ExPerformMapper.xml index 218aeee..d9e74d3 100644 --- a/inventory-dao/src/main/resources/mapper/ex/ExPerformMapper.xml +++ b/inventory-dao/src/main/resources/mapper/ex/ExPerformMapper.xml @@ -20,4 +20,12 @@ relation_id, perform_id, examine_id, socre_num, user_id, create_time, create_by, modify_time, modify_by + + + diff --git a/inventory-dao/src/main/resources/mapper/ex/ExStandardMapper.xml b/inventory-dao/src/main/resources/mapper/ex/ExStandardMapper.xml index a34265d..10e09f0 100644 --- a/inventory-dao/src/main/resources/mapper/ex/ExStandardMapper.xml +++ b/inventory-dao/src/main/resources/mapper/ex/ExStandardMapper.xml @@ -95,8 +95,10 @@ LEFT JOIN `ex_score` sc ON es.`standard_id` = sc.`standard_id` AND sc.`perform_id` = #{performId} LEFT JOIN `ex_score_file` sf ON sc.`socre_id` = sf.`socre_id` - WHERE es.`item_type` = #{itemType} - AND es.`examine_state` = #{examineState} + WHERE es.`examine_state` = #{examineState} + + AND es.`item_type` = #{itemType} + AND es.`examine_id` = #{examineId} AND (es.`perform_id` = #{performId} OR es.`perform_id` IS NULL OR es.`perform_id` = '') ORDER BY es.`sort_id` ASC; diff --git a/inventory-gov/src/main/java/com/rzyc/controller/ExamineController.java b/inventory-gov/src/main/java/com/rzyc/controller/ExamineController.java index e7b549d..b366255 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/ExamineController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/ExamineController.java @@ -677,4 +677,120 @@ public class ExamineController extends BaseController{ return result; } + + /** + * 考核项评分 + * @version v1.0 + * @author dong + * @date 2024/4/2 16:27 + */ + @LoginAuth + @ApiOperation(value = "考核项评分", notes = "考核项评分") + @PostMapping(value = "itemRating") + public SingleResult itemRating(@Valid @RequestBody ItemRatingDto itemRatingDto)throws Exception{ + SingleResult result = new SingleResult<>(); + + //查询指标项 + ExStandard standard = exStandardMapper.selectById(itemRatingDto.getStandardId()); + if(null != standard){ + + //单项分数 + ExScore exScore = exScoreMapper.findByPerformId(itemRatingDto.getStandardId(),itemRatingDto.getPerformId()); + if(null == exScore){ + exScore = new ExScore(); + exScore.setSocreId(RandomNumber.getUUid()); + exScore.setExamineId(standard.getExamineId()); + exScore.setPerformId(itemRatingDto.getPerformId()); + exScore.setStandardId(standard.getStandardId()); + exScore.setOpinion(itemRatingDto.getOpinion()); + exScore.setSocreNum(itemRatingDto.getScore()); + exScore.setCreateTime(new Date()); + exScore.setModifyTime(new Date()); + exScore.setCreateBy(itemRatingDto.getUserId()); + exScore.setModifyBy(itemRatingDto.getUserId()); + exScoreMapper.insert(exScore); + }else{ + ExScore score = new ExScore(); + score.setSocreId(exScore.getSocreId()); + score.setSocreNum(itemRatingDto.getScore()); + score.setOpinion(itemRatingDto.getOpinion()); + score.setModifyTime(new Date()); + score.setModifyBy(itemRatingDto.getUserId()); + exScoreMapper.updateById(score); + } + + //计算总分 + handleTotalScore(itemRatingDto.getPerformId(),standard.getExamineId(),itemRatingDto.getUserId()); + + + } + + + + + + return result; + } + + /** + * 计算总分 + * @version v1.0 + * @author dong + * @date 2024/4/2 17:07 + */ + private ExPerform handleTotalScore(String PerformId,String examineId,String userId)throws Exception{ + Double scoreNum = 0.0; + ListPerform listPerform = listPerformMapper.selectByPrimaryKey(PerformId); + if(null != listPerform){ + //计算总分 + List exStandards = exStandardMapper.standardScoreList(null,listPerform.getExamineState(),examineId,PerformId); + if(null != exStandards && exStandards.size() > 0){ + for (StandardInfo standardInfo : exStandards){ + if(null != standardInfo.getSocreNum()){ + scoreNum += standardInfo.getSocreNum(); + } + } + } + + } + + ExPerform exPerform = exPerformMapper.findPerform(PerformId,examineId); + if(null == exPerform){ + exPerform = new ExPerform(); + exPerform.setRelationId(RandomNumber.getUUid()); + exPerform.setPerformId(PerformId); + exPerform.setExamineId(examineId); + exPerform.setSocreNum(scoreNum); + exPerform.setUserId(userId); + exPerform.setCreateTime(new Date()); + exPerform.setModifyTime(new Date()); + exPerform.setCreateBy(userId); + exPerform.setModifyBy(userId); + exPerformMapper.insert(exPerform); + }else{ + exPerform.setSocreNum(scoreNum); + exPerform.setUserId(userId); + exPerform.setModifyTime(new Date()); + exPerform.setModifyBy(userId); + exPerformMapper.updateById(exPerform); + } + return exPerform; + } + + /** + * 部门考核总分 + * @version v1.0 + * @author dong + * @date 2024/4/2 15:17 + */ + @LoginAuth + @ApiOperation(value = "部门考核总分", notes = "部门考核总分") + @GetMapping(value = "unitTotalScore") + public SingleResult unitTotalScore(@Valid UnitTotalScoreDto unitTotalScoreDto)throws Exception{ + SingleResult result = new SingleResult<>(); + ExPerform exPerform = handleTotalScore(unitTotalScoreDto.getPerformId(),unitTotalScoreDto.getExamineId(),getUserId()); + result.setData(exPerform); + return result; + } + }