考核任务按id清除已评测打分的数据

main 70
hshansha 1 month ago
parent acb579a6db
commit ed6907d80a

@ -16,14 +16,7 @@ import com.ruoyi.kaohe.util.PinYinUtil;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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 com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -162,8 +155,9 @@ public class KhPingceController extends BaseController {
* / * /
* idpcBkhdxsaddOrDelbkhdxType * idpcBkhdxsaddOrDelbkhdxType
*/ */
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:modifyBkhdx')")
@Log(title = "考核评测", businessType = BusinessType.UPDATE) @Log(title = "考核评测", businessType = BusinessType.UPDATE)
@DeleteMapping("/modifyBkhdx") @PutMapping("/modifyBkhdx")
@Transactional @Transactional
public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) { public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) {
Long id = bkhdxParam.getId(); Long id = bkhdxParam.getId();
@ -176,7 +170,7 @@ public class KhPingceController extends BaseController {
vote.setPingceId(id); vote.setPingceId(id);
List<KhVote> khVotes = khVoteService.selectKhVoteList(vote); List<KhVote> khVotes = khVoteService.selectKhVoteList(vote);
if (bkhdxParam.getAddOrDel().equals("0")) { //0添加被考核对象 if (bkhdxParam.getAddOrDel().equals("0")) { //0添加被考核对象 1删除
for (Bkhdx item : pcEmps) { for (Bkhdx item : pcEmps) {
KhPcEmp pcEmp = new KhPcEmp(); KhPcEmp pcEmp = new KhPcEmp();
pcEmp.setPcId(bkhdxParam.getId()); pcEmp.setPcId(bkhdxParam.getId());
@ -242,58 +236,92 @@ public class KhPingceController extends BaseController {
/** /**
* voteemp voteemp * idsnull voteemp voteemp
* vote_recard * ids id-----votevoteemp
* vote_recard
*/ */
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')") // @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
@Log(title = "考核评测", businessType = BusinessType.DELETE) @Log(title = "考核评测", businessType = BusinessType.DELETE)
@DeleteMapping("/clean") @DeleteMapping("/clean")
@Transactional @Transactional
public AjaxResult removeTest() { public AjaxResult removeTest(@RequestParam Long[] ids) {
//已完成的数据直接清除任务及所有关联数据 if(ids!=null&&ids.length>0){ //按任务id-----修改所有关联的vote的voteemp数据为原始状态
KhPingce khPingce = new KhPingce(); for (Long jxzId : ids) {
khPingce.setState("2"); KhVote vote = new KhVote();
List<KhPingce> wPingces = khPingceService.selectKhPingceList(khPingce); vote.setPingceId(jxzId);
if (wPingces != null && wPingces.size() > 0) { List<KhVote> votes = khVoteService.selectKhVoteList(vote);
List<Long> wIds = wPingces.stream().map(KhPingce::getId).collect(Collectors.toList()); List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList());
khPingceService.deleteKhPingceByIds2(wIds.toArray(new Long[wIds.size()])); if (vIds != null && vIds.size() > 0) {
} //修改voteemp
for (Long vId : vIds) {
//进行中 的数据 修改关联的vote及voteemp数据为原始状态 KhVoteEmp vemp = new KhVoteEmp();
KhPingce jxz = new KhPingce(); vemp.setVoteId(vId);
jxz.setState("1"); List<KhVoteEmp> vEmps = khVoteEmpService.selectKhVoteEmpList(vemp);
List<KhPingce> jxzPingces = khPingceService.selectKhPingceList(jxz); if (vEmps != null && vEmps.size() > 0) {
List<Long> jxzIds = jxzPingces.stream().map(KhPingce::getId).collect(Collectors.toList()); //修改关联的员工数据到最初创建状态
for (Long jxzId : jxzIds) { for (KhVoteEmp uPEmp : vEmps) {
KhVote vote = new KhVote(); uPEmp.setVoteNum(BigDecimal.ZERO);
vote.setPingceId(jxzId); uPEmp.setVoteScore(BigDecimal.ZERO);
List<KhVote> votes = khVoteService.selectKhVoteList(vote); uPEmp.setAvgScore(BigDecimal.ZERO);
List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList()); uPEmp.setEndScore(BigDecimal.ZERO);
if (vIds != null && vIds.size() > 0) { if (uPEmp.getKhitemTypeid().equals(1L)) {
//修改voteemp uPEmp.setOptionA(BigDecimal.ZERO);
for (Long vId : vIds) { uPEmp.setOptionB(BigDecimal.ZERO);
KhVoteEmp vemp = new KhVoteEmp(); uPEmp.setOptionC(BigDecimal.ZERO);
vemp.setVoteId(vId); uPEmp.setOptionD(BigDecimal.ZERO);
List<KhVoteEmp> vEmps = khVoteEmpService.selectKhVoteEmpList(vemp); }
if (vEmps != null && vEmps.size() > 0) { khVoteEmpService.updateKhVoteEmp(uPEmp);
//修改关联的员工数据到最初创建状态 }
for (KhVoteEmp uPEmp : vEmps) { }
uPEmp.setVoteNum(BigDecimal.ZERO); }
uPEmp.setVoteScore(BigDecimal.ZERO); }
uPEmp.setAvgScore(BigDecimal.ZERO); }
uPEmp.setEndScore(BigDecimal.ZERO); }else{//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
if (uPEmp.getKhitemTypeid().equals(1L)) { //已完成的数据直接清除任务及所有关联数据————完全删除已完成任务
uPEmp.setOptionA(BigDecimal.ZERO); KhPingce khPingce = new KhPingce();
uPEmp.setOptionB(BigDecimal.ZERO); khPingce.setState("2");
uPEmp.setOptionC(BigDecimal.ZERO); List<KhPingce> wPingces = khPingceService.selectKhPingceList(khPingce);
uPEmp.setOptionD(BigDecimal.ZERO); if (wPingces != null && wPingces.size() > 0) {
List<Long> wIds = wPingces.stream().map(KhPingce::getId).collect(Collectors.toList());
khPingceService.deleteKhPingceByIds2(wIds.toArray(new Long[wIds.size()]));
}
//进行中 的数据 修改关联的vote及voteemp数据为原始状态
KhPingce jxz = new KhPingce();
jxz.setState("1");
List<KhPingce> jxzPingces = khPingceService.selectKhPingceList(jxz);
List<Long> jxzIds = jxzPingces.stream().map(KhPingce::getId).collect(Collectors.toList());
for (Long jxzId : jxzIds) {
KhVote vote = new KhVote();
vote.setPingceId(jxzId);
List<KhVote> votes = khVoteService.selectKhVoteList(vote);
List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList());
if (vIds != null && vIds.size() > 0) {
//修改voteemp
for (Long vId : vIds) {
KhVoteEmp vemp = new KhVoteEmp();
vemp.setVoteId(vId);
List<KhVoteEmp> vEmps = khVoteEmpService.selectKhVoteEmpList(vemp);
if (vEmps != null && vEmps.size() > 0) {
//修改关联的员工数据到最初创建状态
for (KhVoteEmp uPEmp : vEmps) {
uPEmp.setVoteNum(BigDecimal.ZERO);
uPEmp.setVoteScore(BigDecimal.ZERO);
uPEmp.setAvgScore(BigDecimal.ZERO);
uPEmp.setEndScore(BigDecimal.ZERO);
if (uPEmp.getKhitemTypeid().equals(1L)) {
uPEmp.setOptionA(BigDecimal.ZERO);
uPEmp.setOptionB(BigDecimal.ZERO);
uPEmp.setOptionC(BigDecimal.ZERO);
uPEmp.setOptionD(BigDecimal.ZERO);
}
khVoteEmpService.updateKhVoteEmp(uPEmp);
} }
khVoteEmpService.updateKhVoteEmp(uPEmp);
} }
} }
} }
} }
} }
return toAjax(1); return toAjax(1);
} }
} }

Loading…
Cancel
Save