From 093bcf5a9eac931038ca8991bcdeb29853bd2020 Mon Sep 17 00:00:00 2001 From: hshansha Date: Mon, 27 Oct 2025 12:30:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=80=83=E6=A0=B8=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=B6=EF=BC=8C=E6=9C=AA=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E5=8F=AF=E5=88=A0=E9=99=A4=E4=B8=94=E5=88=A0=E9=99=A4=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kaohe/controller/KhPingceController.java | 2 +- .../service/impl/KhPingceServiceImpl.java | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 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 ad2bfe8..8fa43cd 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 @@ -147,7 +147,7 @@ public class KhPingceController extends BaseController { for (Long id : ids) { KhPingce khPingce = khPingceService.selectKhPingceById(id); if (!khPingce.getState().equals("0")) { - return AjaxResult.error("评测:" + khPingce.getPcTitle() + " 不是未开始状态,不允许删除"); + return AjaxResult.error("评测:" + khPingce.getPcTitle() + " 当前状态不能删除"); } } return toAjax(khPingceService.deleteKhPingceByIds(ids)); diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhPingceServiceImpl.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhPingceServiceImpl.java index b81d4e2..e354f76 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhPingceServiceImpl.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhPingceServiceImpl.java @@ -1,12 +1,17 @@ package com.ruoyi.kaohe.service.impl; import java.util.List; +import java.util.stream.Collectors; + import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.kaohe.domain.KhPcEmp; +import com.ruoyi.kaohe.mapper.KhPcEmpMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.kaohe.mapper.KhPingceMapper; import com.ruoyi.kaohe.domain.KhPingce; import com.ruoyi.kaohe.service.IKhPingceService; +import org.springframework.transaction.annotation.Transactional; /** * 考核评测Service业务层处理 @@ -19,6 +24,8 @@ public class KhPingceServiceImpl implements IKhPingceService { @Autowired private KhPingceMapper khPingceMapper; + @Autowired + private KhPcEmpMapper khPcEmpMapper; /** * 查询考核评测 @@ -77,9 +84,21 @@ public class KhPingceServiceImpl implements IKhPingceService * @return 结果 */ @Override + @Transactional public int deleteKhPingceByIds(Long[] ids) { - return khPingceMapper.deleteKhPingceByIds(ids); + int r = khPingceMapper.deleteKhPingceByIds(ids); + for (Long id : ids) { + //删除原来关联 + KhPcEmp query = new KhPcEmp(); + query.setPcId(id); + List temItems = khPcEmpMapper.selectKhPcEmpList(query); + List pcEmpIds = temItems.stream().map(KhPcEmp::getId).collect(Collectors.toList()); + if (pcEmpIds != null && pcEmpIds.size() > 0) { + khPcEmpMapper.deleteKhPcEmpByIds(pcEmpIds.toArray(new Long[pcEmpIds.size()])); + } + } + return r; } /** From 68d46179490bb8b12c70d22e289fa93e0993be5f Mon Sep 17 00:00:00 2001 From: hshansha Date: Mon, 27 Oct 2025 12:30:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=83=E6=A0=B8=E4=BB=BB=E5=8A=A1=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kaohe/controller/KhVoteController.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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 5d327bf..2942db3 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 @@ -4,8 +4,10 @@ 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.IKhPingceService; import com.ruoyi.kaohe.service.IKhVoteEmpService; import org.springframework.scheduling.annotation.Scheduled; import java.math.BigDecimal; @@ -44,6 +46,8 @@ public class KhVoteController extends BaseController { private IKhPcEmpService pcEmpService; @Autowired private IKhVoteEmpService voteEmpService; + @Autowired + private IKhPingceService khPingceService; @Scheduled(cron = "0 * * * * ?") // 每分钟的第0秒执行一次 监测时间修改评分状态 public void performTask() { @@ -60,14 +64,35 @@ public class KhVoteController extends BaseController { if (state.equals("0") && (now.after(sTime) && now.before(eTime))) { vote.setState("1"); khVoteService.updateKhVote(vote); - System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " + vote.getVoteTitle() + " 状态为进行中"); + System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " +vote.getId()+" "+ vote.getVoteTitle() + " 状态为进行中"); } if (now.after(eTime)) { vote.setState("2"); khVoteService.updateKhVote(vote); - System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " + vote.getVoteTitle() + " 状态为已完成"); + System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " +vote.getId()+" "+ vote.getVoteTitle() + " 状态为已完成"); } } + //修改考核任务状态,当考核任务下所有评分都为已完成时,修改考核任务状态为已完成 + KhPingce param = new KhPingce(); + param.setState("1"); + List pingces = khPingceService.selectKhPingceList(param); + for (KhPingce pingce : pingces) { + boolean finishflag=true; + KhVote khVote = new KhVote(); + khVote.setPingceId(pingce.getId()); + List khVotes = khVoteService.selectKhVoteList(khVote); + for (KhVote vote : khVotes) { + if(!vote.getState().equals("2")){ + finishflag=false; + } + } + if(finishflag){ + pingce.setState("2"); + khPingceService.updateKhPingce(pingce); + System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改考核任务: " +pingce.getId()+" "+ pingce.getPcTitle() + " 状态为已完成"); + } + } + } /**