From 0a09c33f1c07ba195851adbb7f3119371afd467c Mon Sep 17 00:00:00 2001 From: hshansha Date: Mon, 7 Jul 2025 08:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=8A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kaohe/controller/KhPingceController.java | 88 ++++++++++++------- .../kaohe/controller/KhVoteController.java | 16 ++-- .../service/impl/KhVoteEmpServiceImpl.java | 12 ++- .../resources/mapper/kaohe/KhVoteMapper.xml | 4 +- 4 files changed, 75 insertions(+), 45 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 7ad9057..efdfc9f 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 @@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletResponse; import com.ruoyi.kaohe.domain.*; import com.ruoyi.kaohe.service.IKhPcEmpService; +import com.ruoyi.kaohe.service.IKhVoteEmpService; +import com.ruoyi.kaohe.service.IKhVoteService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -27,26 +29,57 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * 考核评测Controller - * + * * @author hs * @date 2025-06-17 */ @RestController @RequestMapping("/kaohe/pingce") -public class KhPingceController extends BaseController -{ +public class KhPingceController extends BaseController { @Autowired private IKhPingceService khPingceService; @Autowired private IKhPcEmpService pcEmpService; + @Autowired + private IKhVoteEmpService voteEmpService; + @Autowired + private IKhVoteService khVoteService; + + /** + * 生成考核结果 + */ + // @PreAuthorize("@ss.hasPermi('kaohe:pingce:list')") + @GetMapping("/generateResult") + public TableDataInfo generateResult(Long id) { + KhVote khVote = new KhVote(); + khVote.setPingceId(id); + //查询该考核任务下的所有评分任务 + List votes = khVoteService.selectKhVoteList(khVote); + for (KhVote vote : votes) { + KhVoteEmp khVoteEmp = new KhVoteEmp(); + khVoteEmp.setVoteId(vote.getId()); + //查询该评分任务对应的所有被考核对象详情 + List khVoteEmps = voteEmpService.selectKhVoteEmpList(khVoteEmp); + for (KhVoteEmp voteEmp : khVoteEmps) { + //根据考核类型存储不同数据 + if(vote.getKhitemTypeid().equals(1L)){ + + }else if(vote.getKhitemTypeid().equals(2L)) { + + }else{ + + } + } + } + return getDataTable(null); + } /** * 查询考核评测列表 */ @PreAuthorize("@ss.hasPermi('kaohe:pingce:list')") @GetMapping("/list") - public TableDataInfo list(KhPingce khPingce) - { + public TableDataInfo list(KhPingce khPingce) { startPage(); List list = khPingceService.selectKhPingceList(khPingce); return getDataTable(list); @@ -58,8 +91,7 @@ public class KhPingceController extends BaseController @PreAuthorize("@ss.hasPermi('kaohe:pingce:export')") @Log(title = "考核评测", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, KhPingce khPingce) - { + public void export(HttpServletResponse response, KhPingce khPingce) { List list = khPingceService.selectKhPingceList(khPingce); ExcelUtil util = new ExcelUtil(KhPingce.class); util.exportExcel(response, list, "考核评测数据"); @@ -70,8 +102,7 @@ public class KhPingceController extends BaseController */ @PreAuthorize("@ss.hasPermi('kaohe:pingce:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(khPingceService.selectKhPingceById(id)); } @@ -82,19 +113,18 @@ public class KhPingceController extends BaseController @Log(title = "考核评测", businessType = BusinessType.INSERT) @Transactional @PostMapping - public AjaxResult add(@RequestBody KhPingce khPingce) - { + public AjaxResult add(@RequestBody KhPingce khPingce) { khPingceService.insertKhPingce(khPingce); //增加关联表 List pcEmps = khPingce.getPcBkhdxs(); - if(pcEmps !=null&& pcEmps.size()>0){ - for(Bkhdx item:pcEmps){ + if (pcEmps != null && pcEmps.size() > 0) { + for (Bkhdx item : pcEmps) { KhPcEmp pcEmp = new KhPcEmp(); - pcEmp.setPcId(khPingce.getId()); - pcEmp.setBkhdxId(item.getBkhdxId()); - pcEmp.setBkhdxName(item.getBkhdxName()); - pcEmp.setDeptId(item.getDeptId()); - pcEmp.setDeptName(item.getDeptName()); + pcEmp.setPcId(khPingce.getId()); + pcEmp.setBkhdxId(item.getBkhdxId()); + pcEmp.setBkhdxName(item.getBkhdxName()); + pcEmp.setDeptId(item.getDeptId()); + pcEmp.setDeptName(item.getDeptName()); pcEmpService.insertKhPcEmp(pcEmp); } } @@ -108,22 +138,21 @@ public class KhPingceController extends BaseController @Log(title = "考核评测", businessType = BusinessType.UPDATE) @PutMapping @Transactional - public AjaxResult edit(@RequestBody KhPingce khPingce) - { + public AjaxResult edit(@RequestBody KhPingce khPingce) { khPingceService.updateKhPingce(khPingce); List pcEmps = khPingce.getPcBkhdxs(); - if(pcEmps !=null&& pcEmps.size()>0){ + 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()); - if(ids!=null&&ids.size()>0){ + if (ids != null && ids.size() > 0) { pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()])); } //增加新的关联 - for(Bkhdx item:pcEmps){ + for (Bkhdx item : pcEmps) { KhPcEmp pcEmp = new KhPcEmp(); pcEmp.setPcId(khPingce.getId()); pcEmp.setBkhdxId(item.getBkhdxId()); @@ -133,7 +162,7 @@ public class KhPingceController extends BaseController pcEmpService.insertKhPcEmp(pcEmp); } } - return AjaxResult.success(); + return AjaxResult.success(); } /** @@ -141,13 +170,12 @@ public class KhPingceController extends BaseController */ @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')") @Log(title = "考核评测", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { - for(Long id:ids){ + @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()+" 不是未开始状态,不允许删除"); + 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/KhVoteController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteController.java index 369b4dc..113bc73 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteController.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteController.java @@ -1,19 +1,15 @@ package com.ruoyi.kaohe.controller; -import java.math.BigDecimal; -import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; - import com.ruoyi.kaohe.domain.KhPcEmp; -import com.ruoyi.kaohe.domain.KhPingce; import com.ruoyi.kaohe.domain.KhVoteEmp; import com.ruoyi.kaohe.service.IKhPcEmpService; import com.ruoyi.kaohe.service.IKhVoteEmpService; import org.springframework.scheduling.annotation.Scheduled; +import java.math.BigDecimal; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -90,6 +86,7 @@ public class KhVoteController extends BaseController { @PreAuthorize("@ss.hasPermi('kaohe:vote:list')") @GetMapping("/listByConditons") public TableDataInfo getListByConditons(KhVote khVote) { + khVote.setState("2"); startPage(); List list = khVoteService.getListByPcIdAndItemIds(khVote); return getDataTable(list); @@ -129,7 +126,6 @@ public class KhVoteController extends BaseController { KhPcEmp query = new KhPcEmp(); query.setPcId(khVote.getPingceId()); List pcEmps = pcEmpService.selectKhPcEmpList(query); - BigDecimal initv= new BigDecimal("O"); for (KhPcEmp pcEmp : pcEmps) { //新增投票选项关联表 KhVoteEmp voteEmp = new KhVoteEmp(); @@ -140,10 +136,10 @@ public class KhVoteController extends BaseController { voteEmp.setPercentage(khVote.getPercentage()); voteEmp.setKhitemTypeid(khVote.getKhitemTypeid()); if(khVote.getKhitemTypeid().equals(1L)){ - voteEmp.setOptionA(initv); - voteEmp.setOptionB(initv); - voteEmp.setOptionC(initv); - voteEmp.setOptionD(initv); + voteEmp.setOptionA(BigDecimal.ZERO); + voteEmp.setOptionB(BigDecimal.ZERO); + voteEmp.setOptionC(BigDecimal.ZERO); + voteEmp.setOptionD(BigDecimal.ZERO); } voteEmpService.insertKhVoteEmp(voteEmp); } diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteEmpServiceImpl.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteEmpServiceImpl.java index d7308d3..6f57b44 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteEmpServiceImpl.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteEmpServiceImpl.java @@ -12,6 +12,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.kaohe.domain.KhVoteRecard; import com.ruoyi.kaohe.domain.KhVoteRecardParam; +import com.ruoyi.kaohe.mapper.KhVoteItemsMapper; import com.ruoyi.kaohe.mapper.KhVoteRecardMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -33,6 +34,8 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService private KhVoteEmpMapper khVoteEmpMapper; @Autowired private KhVoteRecardMapper khVoteRecardMapper; + @Autowired + private KhVoteItemsMapper khVoteItemsMapper; /** * 查询投票选项 @@ -116,6 +119,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService List voteEmpList = param.getVoteEmpList(); Date nowDate = DateUtils.getNowDate(); Long typeid = param.getKhitemTypeid(); + // khVoteItemsMapper.s 从数据库获取分值 BigDecimal a = new BigDecimal("100"); BigDecimal b = new BigDecimal("80"); BigDecimal c = new BigDecimal("60"); @@ -126,16 +130,16 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService KhVoteEmp oldvoteEmp = khVoteEmpMapper.selectKhVoteEmpById(voteEmp.getId()); if (typeid.equals(1L)) {//选项评分 //存储投票详情到map - if(voteEmp.getOptionA().compareTo(new BigDecimal("0"))==1){ + if(voteEmp.getOptionA().compareTo(BigDecimal.ZERO)==1){ xuanxiangDetails.put(voteEmp.getBkhdxName(),voteEmp.getOptionA()); } - if(voteEmp.getOptionB().compareTo(new BigDecimal("0"))==1){ + if(voteEmp.getOptionB().compareTo(BigDecimal.ZERO)==1){ xuanxiangDetails.put(voteEmp.getBkhdxName(),voteEmp.getOptionB()); } - if(voteEmp.getOptionC().compareTo(new BigDecimal("0"))==1){ + if(voteEmp.getOptionC().compareTo(BigDecimal.ZERO)==1){ xuanxiangDetails.put(voteEmp.getBkhdxName(),voteEmp.getOptionC()); } - if(voteEmp.getOptionD().compareTo(new BigDecimal("0"))==1){ + if(voteEmp.getOptionD().compareTo(BigDecimal.ZERO)==1){ xuanxiangDetails.put(voteEmp.getBkhdxName(),voteEmp.getOptionD()); } //修改投票情况 diff --git a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteMapper.xml b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteMapper.xml index a7b72e2..de2d09d 100644 --- a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteMapper.xml +++ b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhVoteMapper.xml @@ -53,7 +53,8 @@ select v.*,it.type_id from kh_vote v left join kh_items it on v.khitem_id =it.id and pingce_id = #{pingceId} - and state = #{state} + + and state != #{state} and khitem_id in #{itemId} @@ -61,6 +62,7 @@ +