考核任务删除考核对象修改、清理数据接口修改

main 74
hshansha 1 month ago
parent a9b34f690d
commit 67822a9d9d

@ -8,9 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.kaohe.domain.*;
import com.ruoyi.kaohe.service.IKhPcEmpService;
import com.ruoyi.kaohe.service.IKhVoteEmpService;
import com.ruoyi.kaohe.service.IKhVoteService;
import com.ruoyi.kaohe.service.*;
import com.ruoyi.kaohe.service.impl.KhVoteServiceImpl;
import com.ruoyi.kaohe.util.PinYinUtil;
import org.springframework.security.access.prepost.PreAuthorize;
@ -21,7 +19,6 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kaohe.service.IKhPingceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
@ -42,6 +39,8 @@ public class KhPingceController extends BaseController {
private IKhVoteService khVoteService;
@Autowired
private IKhVoteEmpService khVoteEmpService;
@Autowired
private IKhVoteRecardService khVoteRecardService;
/**
*
@ -156,7 +155,7 @@ public class KhPingceController extends BaseController {
* idpcBkhdxsaddOrDelbkhdxType
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:modifyBkhdx')")
@Log(title = "考核评测", businessType = BusinessType.UPDATE)
@Log(title = "任务添加/删除被考核对象", businessType = BusinessType.UPDATE)
@PutMapping("/modifyBkhdx")
@Transactional
public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) {
@ -204,10 +203,17 @@ public class KhPingceController extends BaseController {
}
} else {
//删除关联
List<Long> ids = new ArrayList<>();
KhPcEmp query = new KhPcEmp();
query.setPcId(id);
List<KhPcEmp> temItems = pcEmpService.selectKhPcEmpList(query);
List<Long> ids = temItems.stream().map(KhPcEmp::getId).collect(Collectors.toList());
List<KhPcEmp> pcEmpsItems = pcEmpService.selectKhPcEmpList(query);
for (Bkhdx pcEmp : pcEmps) {
for (KhPcEmp pcEmpsItem : pcEmpsItems) {
if (pcEmpsItem.getBkhdxId().equals(pcEmp.getBkhdxId())) {
ids.add(pcEmpsItem.getId());
}
}
}
if (ids != null && ids.size() > 0) {
pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()]));
}
@ -237,18 +243,18 @@ public class KhPingceController extends BaseController {
/**
* idsnull voteemp voteemp
* vote_recard
* vote_recard
* ids id-----votevoteemp
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
@Log(title = "考核评测", businessType = BusinessType.DELETE)
@Log(title = "任务清除打分数据", businessType = BusinessType.DELETE)
@DeleteMapping("/clean")
@Transactional
public AjaxResult removeTest(@RequestParam Long[] ids) {
if (ids != null && ids.length > 0) { //按任务id-----修改所有关联的vote的voteemp数据为原始状态
for (Long jxzId : ids) {
for (Long cleanId : ids) {
KhVote vote = new KhVote();
vote.setPingceId(jxzId);
vote.setPingceId(cleanId);
List<KhVote> votes = khVoteService.selectKhVoteList(vote);
if (votes != null && votes.size() > 0) {
List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList());
@ -274,9 +280,18 @@ public class KhPingceController extends BaseController {
}
}
}
//清空投票记录表 根据pcId查询
KhVoteRecard vr = new KhVoteRecard();
vr.setPcId(cleanId);
List<KhVoteRecard> khVoteRecards = khVoteRecardService.selectKhVoteRecardList(vr);
if (khVoteRecards != null & khVoteRecards.size() > 0) {
List<Long> vrIds = khVoteRecards.stream().map(KhVoteRecard::getId).collect(Collectors.toList());
khVoteRecardService.deleteKhVoteRecardByIds(vrIds.toArray(new Long[vrIds.size()]));
}
}
}
} else {//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
return toAjax(1);
} /*else {//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
//已完成的数据直接清除任务及所有关联数据————完全删除已完成任务
KhPingce khPingce = new KhPingce();
khPingce.setState("2");
@ -289,7 +304,7 @@ public class KhPingceController extends BaseController {
KhPingce jxz = new KhPingce();
jxz.setState("1");
List<KhPingce> jxzPingces = khPingceService.selectKhPingceList(jxz);
if(jxzPingces!=null&&jxzPingces.size()>0){
if (jxzPingces != null && jxzPingces.size() > 0) {
List<Long> jxzIds = jxzPingces.stream().map(KhPingce::getId).collect(Collectors.toList());
for (Long jxzId : jxzIds) {
KhVote vote = new KhVote();
@ -319,11 +334,21 @@ public class KhPingceController extends BaseController {
}
}
}
//清空投票记录表 根据pcId查询
KhVoteRecard vr = new KhVoteRecard();
vr.setPcId(jxzId);
List<KhVoteRecard> khVoteRecards = khVoteRecardService.selectKhVoteRecardList(vr);
if (khVoteRecards != null & khVoteRecards.size() > 0) {
List<Long> vrIds = khVoteRecards.stream().map(KhVoteRecard::getId).collect(Collectors.toList());
khVoteRecardService.deleteKhVoteRecardByIds(vrIds.toArray(new Long[vrIds.size()]));
}
}
}
}
AjaxResult.success("按要求清理数据库成功")
}*/
return toAjax(1);
return AjaxResult.error("请选择需要清理的考核任务!");
}
}

Loading…
Cancel
Save