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 f76b68d..861ca3c 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 @@ -6,18 +6,13 @@ import javax.servlet.http.HttpServletResponse; import com.ruoyi.kaohe.domain.KhItems; import com.ruoyi.kaohe.domain.KhTemItem; +import com.ruoyi.kaohe.domain.KhVote; import com.ruoyi.kaohe.service.IKhTemItemService; +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; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -41,6 +36,8 @@ public class KhTemplateController extends BaseController private IKhTemplateService khTemplateService; @Autowired private IKhTemItemService temItemService; + @Autowired + private IKhVoteService voteService; /** * 查询考核模板列表 @@ -77,6 +74,28 @@ public class KhTemplateController extends BaseController return success(khTemplateService.selectKhTemplateById(id)); } + /** + * 根据模板查询出考核项及考核项对应的投票 + * @param id + * @return + */ + @GetMapping(value = "/getItemVote") + public AjaxResult getInfo(@RequestParam("id") Long id,@RequestParam("pingceId") Long pingceId) + { + KhTemplate khTemplate = khTemplateService.selectKhTemplateById(id); + List items = khTemplate.getItems(); + for(KhItems item:items){ + KhVote query = new KhVote(); + query.setPingceId(pingceId); + query.setKhitemId(item.getId()); + List khVotes = voteService.selectKhVoteList(query); + if(khVotes!=null&&khVotes.size()>0){ + item.setVote(khVotes.get(0)); + } + } + return success(khTemplate); + } + /** * 新增考核模板 */ 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 1b25566..01afd6c 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 @@ -2,8 +2,14 @@ package com.ruoyi.kaohe.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.kaohe.domain.KhPcEmp; +import com.ruoyi.kaohe.domain.KhVoteEmp; +import com.ruoyi.kaohe.service.IKhPcEmpService; +import com.ruoyi.kaohe.service.IKhVoteEmpService; 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; @@ -33,6 +39,10 @@ public class KhVoteController extends BaseController { @Autowired private IKhVoteService khVoteService; + @Autowired + private IKhPcEmpService pcEmpService; + @Autowired + private IKhVoteEmpService voteEmpService; /** * 查询投票评测列表 @@ -75,9 +85,25 @@ public class KhVoteController extends BaseController @PreAuthorize("@ss.hasPermi('kaohe:vote:add')") @Log(title = "投票评测", businessType = BusinessType.INSERT) @PostMapping + @Transactional public AjaxResult add(@RequestBody KhVote khVote) { - return toAjax(khVoteService.insertKhVote(khVote)); + khVoteService.insertKhVote(khVote); + //根据评测id查询职工评测关联 职工 + KhPcEmp query = new KhPcEmp(); + query.setPcId(khVote.getPingceId()); + List pcEmps = pcEmpService.selectKhPcEmpList(query); + for(KhPcEmp pcEmp:pcEmps){ + //新增投票选项关联表 + KhVoteEmp voteEmp = new KhVoteEmp(); + voteEmp.setEmpId(pcEmp.getEmpId()); + voteEmp.setEmpName(pcEmp.getEmpName()); + voteEmp.setVoteId(khVote.getId()); + voteEmp.setVoteTitle(khVote.getVoteTitle()); + voteEmp.setPercentage(khVote.getPercentage()); + voteEmpService.insertKhVoteEmp(voteEmp); + } + return AjaxResult.success(); } /** diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhItems.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhItems.java index b47f689..8edb18a 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhItems.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhItems.java @@ -30,7 +30,17 @@ public class KhItems extends BaseEntity @Excel(name = "考核类型") private String type; - public void setId(Long id) + private KhVote vote; + + public KhVote getVote() { + return vote; + } + + public void setVote(KhVote vote) { + this.vote = vote; + } + + public void setId(Long id) { this.id = id; }