From e6d4d10e8e5345d61a928bf632bcef8d039a2151 Mon Sep 17 00:00:00 2001 From: hshansha Date: Thu, 19 Jun 2025 08:33:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E6=97=B6=E5=85=B3=E8=81=94=E8=AF=84?= =?UTF-8?q?=E6=B5=8B=E5=91=98=E5=B7=A5=E8=A1=A8=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=99=90=E5=88=B6=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kaohe/controller/KhPingceController.java | 54 +++++++++++++++++-- .../controller/KhTemplateController.java | 2 + .../java/com/ruoyi/kaohe/domain/KhPingce.java | 14 ++++- .../resources/mapper/kaohe/KhPingceMapper.xml | 12 +++-- 4 files changed, 75 insertions(+), 7 deletions(-) diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java index 3132db0..5327e96 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java @@ -1,9 +1,14 @@ package com.ruoyi.kaohe.controller; import java.util.List; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.kaohe.domain.*; +import com.ruoyi.kaohe.service.IKhPcEmpService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -16,7 +21,6 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.kaohe.domain.KhPingce; import com.ruoyi.kaohe.service.IKhPingceService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; @@ -33,6 +37,8 @@ public class KhPingceController extends BaseController { @Autowired private IKhPingceService khPingceService; + @Autowired + private IKhPcEmpService pcEmpService; /** * 查询考核评测列表 @@ -74,10 +80,25 @@ public class KhPingceController extends BaseController */ @PreAuthorize("@ss.hasPermi('kaohe:pingce:add')") @Log(title = "考核评测", businessType = BusinessType.INSERT) + @Transactional @PostMapping public AjaxResult add(@RequestBody KhPingce khPingce) { - return toAjax(khPingceService.insertKhPingce(khPingce)); + khPingceService.insertKhPingce(khPingce); + //增加关联表 + List pcEmps = khPingce.getPcEmps(); + if(pcEmps !=null&& pcEmps.size()>0){ + for(KhEmployee item:pcEmps){ + KhPcEmp pcEmp = new KhPcEmp(); + pcEmp.setPcId(khPingce.getId()); + pcEmp.setEmpId(item.getId()); + pcEmp.setEmpName(item.getEmpName()); + pcEmp.setDeptId(item.getDeptId()); + pcEmp.setDeptName(item.getDeptName()); + pcEmpService.insertKhPcEmp(pcEmp); + } + } + return AjaxResult.success(); } /** @@ -86,9 +107,30 @@ public class KhPingceController extends BaseController @PreAuthorize("@ss.hasPermi('kaohe:pingce:edit')") @Log(title = "考核评测", businessType = BusinessType.UPDATE) @PutMapping + @Transactional public AjaxResult edit(@RequestBody KhPingce khPingce) { - return toAjax(khPingceService.updateKhPingce(khPingce)); + khPingceService.updateKhPingce(khPingce); + + List pcEmps = khPingce.getPcEmps(); + if(pcEmps !=null&& pcEmps.size()>0){ + //删除原来关联 + KhPcEmp query = new KhPcEmp(); + query.setPcId(khPingce.getId()); + List temItems = pcEmpService.selectKhPcEmpList(query); + List ids = temItems.stream().map(KhPcEmp::getId).collect(Collectors.toList()); + pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()])); + //增加新的关联 + for(KhEmployee item:pcEmps){ + KhPcEmp pcEmp = new KhPcEmp(); + pcEmp.setEmpId(item.getId()); + pcEmp.setEmpName(item.getEmpName()); + pcEmp.setDeptId(item.getDeptId()); + pcEmp.setDeptName(item.getDeptName()); + pcEmpService.insertKhPcEmp(pcEmp); + } + } + return AjaxResult.success(); } /** @@ -99,6 +141,12 @@ public class KhPingceController extends BaseController @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { + for(Long id:ids){ + KhPingce khPingce = khPingceService.selectKhPingceById(id); + if(!khPingce.getState().equals("0")){ + return AjaxResult.error("评测:"+khPingce.getPcTitle()+" 不是未开始状态,不允许删除"); + } + } return toAjax(khPingceService.deleteKhPingceByIds(ids)); } } diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhTemplateController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhTemplateController.java index 9b53a6e..f76b68d 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhTemplateController.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhTemplateController.java @@ -87,6 +87,7 @@ public class KhTemplateController extends BaseController public AjaxResult add(@RequestBody KhTemplate khTemplate) { khTemplateService.insertKhTemplate(khTemplate); + //增加关联表 List items = khTemplate.getItems(); if(items !=null&& items.size()>0){ for(KhItems item:items){ @@ -119,6 +120,7 @@ public class KhTemplateController extends BaseController List temItems = temItemService.selectKhTemItemList(query); List ids = temItems.stream().map(KhTemItem::getId).collect(Collectors.toList()); temItemService.deleteKhTemItemByIds(ids.toArray(new Long[ids.size()])); + //增加新的关联 for(KhItems item:items){ KhTemItem temItem = new KhTemItem(); temItem.setTemName(khTemplate.getTemName()); diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhPingce.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhPingce.java index c050b1b..84de18d 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhPingce.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhPingce.java @@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import java.util.List; + /** * 考核评测对象 kh_pingce * @@ -42,7 +44,17 @@ public class KhPingce extends BaseEntity @Excel(name = "评测状态(0 开始 1 进行中 2 完成)") private String state; - public void setId(Long id) + private List pcEmps; + + public List getPcEmps() { + return pcEmps; + } + + public void setPcEmps(List pcEmps) { + this.pcEmps = pcEmps; + } + + public void setId(Long id) { this.id = id; } diff --git a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhPingceMapper.xml b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhPingceMapper.xml index a672c70..393e419 100644 --- a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhPingceMapper.xml +++ b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhPingceMapper.xml @@ -17,6 +17,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + @@ -24,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" From 9025e4fee495b18511521c219d39d780c05e35e8 Mon Sep 17 00:00:00 2001 From: hshansha Date: Thu, 19 Jun 2025 09:18:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E5=85=B3=E8=81=94=E8=A1=A8?= =?UTF-8?q?=E5=AD=97=E6=AE=B5pc=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/kaohe/controller/KhPingceController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java index 5327e96..a6bbc8a 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java @@ -123,6 +123,7 @@ public class KhPingceController extends BaseController //增加新的关联 for(KhEmployee item:pcEmps){ KhPcEmp pcEmp = new KhPcEmp(); + pcEmp.setPcId(khPingce.getId()); pcEmp.setEmpId(item.getId()); pcEmp.setEmpName(item.getEmpName()); pcEmp.setDeptId(item.getDeptId()); From 4978f7a55a38352d87050bd1ff1fb46825bbbc9a Mon Sep 17 00:00:00 2001 From: hshansha Date: Thu, 19 Jun 2025 09:27:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8A=95=E7=A5=A8=E3=80=81=E6=8A=95?= =?UTF-8?q?=E7=A5=A8=E9=80=89=E9=A1=B9=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/kaohe/domain/KhVote.java | 14 +++ .../com/ruoyi/kaohe/domain/KhVoteEmp.java | 95 ++++++++++++------- .../mapper/kaohe/KhVoteEmpMapper.xml | 28 ++++-- .../resources/mapper/kaohe/KhVoteMapper.xml | 7 +- 4 files changed, 102 insertions(+), 42 deletions(-) diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVote.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVote.java index ceac548..b86e060 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVote.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVote.java @@ -1,5 +1,6 @@ package com.ruoyi.kaohe.domain; +import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -58,6 +59,10 @@ public class KhVote extends BaseEntity @Excel(name = "最大投票数") private Long maxNum; + /** 评分占比(0-1之间) */ + @Excel(name = "评分占比(0-1之间)") + private BigDecimal percentage; + /** 状态(0 未开始 1 进行中 2 完成) */ @Excel(name = "状态(0 未开始 1 进行中 2 完成)") private String state; @@ -127,6 +132,14 @@ public class KhVote extends BaseEntity this.vDescription = vDescription; } + public BigDecimal getPercentage() { + return percentage; + } + + public void setPercentage(BigDecimal percentage) { + this.percentage = percentage; + } + public String getvDescription() { return vDescription; @@ -185,6 +198,7 @@ public class KhVote extends BaseEntity .append("sTime", getsTime()) .append("eTime", geteTime()) .append("maxNum", getMaxNum()) + .append("percentage", getPercentage()) .append("state", getState()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteEmp.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteEmp.java index 14630d2..eef7360 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteEmp.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteEmp.java @@ -1,5 +1,6 @@ package com.ruoyi.kaohe.domain; +import java.math.BigDecimal; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -7,9 +8,9 @@ import com.ruoyi.common.core.domain.BaseEntity; /** * 投票选项对象 kh_vote_emp - * + * * @author hs - * @date 2025-06-17 + * @date 2025-06-19 */ public class KhVoteEmp extends BaseEntity { @@ -46,102 +47,132 @@ public class KhVoteEmp extends BaseEntity @Excel(name = "当前投票分数") private Long voteScore; - public void setId(Long id) + /** 评分占比(0-1之间) */ + @Excel(name = "评分占比(0-1之间)") + private BigDecimal percentage; + + /** 最终分数 */ + @Excel(name = "最终分数") + private Long endScore; + + public void setId(Long id) { this.id = id; } - public Long getId() + public Long getId() { return id; } - public void setVoteId(Long voteId) + public void setVoteId(Long voteId) { this.voteId = voteId; } - public Long getVoteId() + public Long getVoteId() { return voteId; } - public void setVoteTitle(String voteTitle) + public void setVoteTitle(String voteTitle) { this.voteTitle = voteTitle; } - public String getVoteTitle() + public String getVoteTitle() { return voteTitle; } - public void setEmpId(Long empId) + public void setEmpId(Long empId) { this.empId = empId; } - public Long getEmpId() + public Long getEmpId() { return empId; } - public void setEmpName(String empName) + public void setEmpName(String empName) { this.empName = empName; } - public String getEmpName() + public String getEmpName() { return empName; } - public void setContent(String content) + public void setContent(String content) { this.content = content; } - public String getContent() + public String getContent() { return content; } - public void setVoteNum(Long voteNum) + public void setVoteNum(Long voteNum) { this.voteNum = voteNum; } - public Long getVoteNum() + public Long getVoteNum() { return voteNum; } - public void setVoteScore(Long voteScore) + public void setVoteScore(Long voteScore) { this.voteScore = voteScore; } - public Long getVoteScore() + public Long getVoteScore() { return voteScore; } + public void setPercentage(BigDecimal percentage) + { + this.percentage = percentage; + } + + public BigDecimal getPercentage() + { + return percentage; + } + + public void setEndScore(Long endScore) + { + this.endScore = endScore; + } + + public Long getEndScore() + { + return endScore; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("voteId", getVoteId()) - .append("voteTitle", getVoteTitle()) - .append("empId", getEmpId()) - .append("empName", getEmpName()) - .append("content", getContent()) - .append("voteNum", getVoteNum()) - .append("voteScore", getVoteScore()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + .append("id", getId()) + .append("voteId", getVoteId()) + .append("voteTitle", getVoteTitle()) + .append("empId", getEmpId()) + .append("empName", getEmpName()) + .append("content", getContent()) + .append("voteNum", getVoteNum()) + .append("voteScore", getVoteScore()) + .append("percentage", getPercentage()) + .append("endScore", getEndScore()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteEmpMapper.xml b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteEmpMapper.xml index 773194a..101a01f 100644 --- a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteEmpMapper.xml +++ b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteEmpMapper.xml @@ -1,9 +1,9 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -21,12 +23,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, vote_id, vote_title, emp_id, emp_name, content, vote_num, vote_score, create_by, create_time, update_by, update_time, remark from kh_vote_emp + select id, vote_id, vote_title, emp_id, emp_name, content, vote_num, vote_score, percentage, end_score, create_by, create_time, update_by, update_time, remark from kh_vote_emp - + @@ -39,6 +40,7 @@ and s_time = #{sTime} and e_time = #{eTime} and max_num = #{maxNum} + and percentage = #{percentage} and state = #{state} @@ -60,6 +62,7 @@ s_time, e_time, max_num, + percentage, state, create_by, create_time, @@ -77,6 +80,7 @@ #{sTime}, #{eTime}, #{maxNum}, + #{percentage}, #{state}, #{createBy}, #{createTime}, @@ -98,6 +102,7 @@ s_time = #{sTime}, e_time = #{eTime}, max_num = #{maxNum}, + percentage = #{percentage}, state = #{state}, create_by = #{createBy}, create_time = #{createTime},