考核任务按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.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;
@ -162,8 +155,9 @@ public class KhPingceController extends BaseController {
* /
* idpcBkhdxsaddOrDelbkhdxType
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:modifyBkhdx')")
@Log(title = "考核评测", businessType = BusinessType.UPDATE)
@DeleteMapping("/modifyBkhdx")
@PutMapping("/modifyBkhdx")
@Transactional
public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) {
Long id = bkhdxParam.getId();
@ -176,7 +170,7 @@ public class KhPingceController extends BaseController {
vote.setPingceId(id);
List<KhVote> khVotes = khVoteService.selectKhVoteList(vote);
if (bkhdxParam.getAddOrDel().equals("0")) { //0添加被考核对象
if (bkhdxParam.getAddOrDel().equals("0")) { //0添加被考核对象 1删除
for (Bkhdx item : pcEmps) {
KhPcEmp pcEmp = new KhPcEmp();
pcEmp.setPcId(bkhdxParam.getId());
@ -242,15 +236,48 @@ public class KhPingceController extends BaseController {
/**
* voteemp voteemp
* vote_recard
* idsnull voteemp voteemp
* ids id-----votevoteemp
* vote_recard
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
@Log(title = "考核评测", businessType = BusinessType.DELETE)
@DeleteMapping("/clean")
@Transactional
public AjaxResult removeTest() {
//已完成的数据直接清除任务及所有关联数据
public AjaxResult removeTest(@RequestParam Long[] ids) {
if(ids!=null&&ids.length>0){ //按任务id-----修改所有关联的vote的voteemp数据为原始状态
for (Long jxzId : ids) {
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);
}
}
}
}
}
}else{//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
//已完成的数据直接清除任务及所有关联数据————完全删除已完成任务
KhPingce khPingce = new KhPingce();
khPingce.setState("2");
List<KhPingce> wPingces = khPingceService.selectKhPingceList(khPingce);
@ -258,7 +285,6 @@ public class KhPingceController extends BaseController {
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");
@ -294,6 +320,8 @@ public class KhPingceController extends BaseController {
}
}
}
}
return toAjax(1);
}
}

Loading…
Cancel
Save