修改被考核对象数量接口、生成测试账号为数字

main
hshansha 1 month ago
parent 0b4a25046c
commit acb579a6db

@ -1,9 +1,6 @@
package com.ruoyi.web.controller.system;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
@ -172,6 +169,7 @@ public class SysUserController extends BaseController
@Transactional
public AjaxResult adds(@RequestBody SysUser user)
{
Random random = new Random();
List<SysUser> userList = new ArrayList();
Integer num = user.getNum();
if(num!=null&&num>0){
@ -183,7 +181,11 @@ public class SysUserController extends BaseController
}
HashSet<String> accounts = new HashSet<>();
while (accounts.size() < num) {
String randomUserName = RandomStringUtils.randomAlphanumeric(8);
//大小写字母、数字组成
// String randomUserName = RandomStringUtils.randomAlphanumeric(8);
//客户要求改为8位纯数字
String randomUserName =String.valueOf(random.nextInt(90000000) + 10000000) ;
//int randomUserName = (int)(Math.random() * 90000000) + 10000000;
//查询是否有相同账号
SysUser param = new SysUser();
param.setUserName(randomUserName);
@ -279,7 +281,7 @@ public class SysUserController extends BaseController
@DeleteMapping("/pcIds/{pcIds}")
public AjaxResult removeBypcIds(@PathVariable Long[] pcIds)
{
return toAjax(userService.deleteUserByPcIds(pcIds));
return userService.deleteUserByPcIds(pcIds);
}
/**

@ -11,6 +11,7 @@ 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.impl.KhVoteServiceImpl;
import com.ruoyi.kaohe.util.PinYinUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@ -157,23 +158,108 @@ public class KhPingceController extends BaseController {
return toAjax(khPingceService.deleteKhPingceByIds(ids));
}
/**
* /
* idpcBkhdxsaddOrDelbkhdxType
*/
@Log(title = "考核评测", businessType = BusinessType.UPDATE)
@DeleteMapping("/modifyBkhdx")
@Transactional
public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) {
Long id = bkhdxParam.getId();
List<Bkhdx> pcEmps = bkhdxParam.getPcBkhdxs();
if (pcEmps == null || pcEmps.size() <= 0) {
return AjaxResult.error("选择的被考核对象为空!");
}
//查询已发布考核项vote
KhVote vote = new KhVote();
vote.setPingceId(id);
List<KhVote> khVotes = khVoteService.selectKhVoteList(vote);
if (bkhdxParam.getAddOrDel().equals("0")) { //0添加被考核对象
for (Bkhdx item : pcEmps) {
KhPcEmp pcEmp = new KhPcEmp();
pcEmp.setPcId(bkhdxParam.getId());
pcEmp.setBkhdxId(item.getBkhdxId());
pcEmp.setBkhdxName(item.getBkhdxName());
pcEmp.setDeptId(item.getDeptId());
pcEmp.setDeptName(item.getDeptName());
pcEmpService.insertKhPcEmp(pcEmp);
}
//已发布考核需添加对应考核项的关联人
if (khVotes != null && khVotes.size() > 0) {
for (KhVote khVote : khVotes) {
for (Bkhdx item : pcEmps) {
//新增投票选项关联表
KhVoteEmp voteEmp = new KhVoteEmp();
voteEmp.setBkhdxId(item.getBkhdxId());
voteEmp.setBkhdxName(item.getBkhdxName());
voteEmp.setVoteId(khVote.getId());
voteEmp.setVoteTitle(khVote.getVoteTitle());
voteEmp.setPercentage(khVote.getPercentage());
voteEmp.setKhitemTypeid(khVote.getKhitemTypeid());
if (khVote.getKhitemTypeid().equals(1L)) {
voteEmp.setOptionA(BigDecimal.ZERO);
voteEmp.setOptionB(BigDecimal.ZERO);
voteEmp.setOptionC(BigDecimal.ZERO);
voteEmp.setOptionD(BigDecimal.ZERO);
}
khVoteEmpService.insertKhVoteEmp(voteEmp);
}
}
}
} else {
//删除关联
KhPcEmp query = new KhPcEmp();
query.setPcId(id);
List<KhPcEmp> temItems = pcEmpService.selectKhPcEmpList(query);
List<Long> ids = temItems.stream().map(KhPcEmp::getId).collect(Collectors.toList());
if (ids != null && ids.size() > 0) {
pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()]));
}
//已发布考核vote 删除对应数据
if (khVotes != null && khVotes.size() > 0) {
List<Long> veIds = new ArrayList<>();
for (KhVote khVote : khVotes) {
KhVoteEmp vEmp = new KhVoteEmp();
vEmp.setVoteId(khVote.getId());
List<KhVoteEmp> khVEmps = khVoteEmpService.selectKhVoteEmpList(vEmp);
for (Bkhdx item : pcEmps) {
for (KhVoteEmp khVEmp : khVEmps) {
if (khVEmp.getBkhdxId().equals(item.getBkhdxId())) {
veIds.add(khVEmp.getId());
}
}
}
}
if (veIds.size() > 0) {
khVoteEmpService.deleteKhVoteEmpByIds(veIds.toArray(new Long[veIds.size()]));
}
}
}
return AjaxResult.success();
}
/**
* voteemp voteemp
* vote_recard
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
@Log(title = "考核评测", businessType = BusinessType.DELETE)
@DeleteMapping("/clean")
@Transactional
public AjaxResult removeTest() {
//已完成
//已完成的数据直接清除任务及所有关联数据
KhPingce khPingce = new KhPingce();
khPingce.setState("2");
List<KhPingce> wPingces = khPingceService.selectKhPingceList(khPingce);
List<Long> wIds = wPingces.stream().map(KhPingce::getId).collect(Collectors.toList());
khPingceService.deleteKhPingceByIds2(wIds.toArray(new Long[wIds.size()]));
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数据为原始状态
//进行中 的数据 修改关联的vote及voteemp数据为原始状态
KhPingce jxz = new KhPingce();
jxz.setState("1");
List<KhPingce> jxzPingces = khPingceService.selectKhPingceList(jxz);
@ -186,17 +272,17 @@ public class KhPingceController extends BaseController {
if (vIds != null && vIds.size() > 0) {
//修改voteemp
for (Long vId : vIds) {
KhVoteEmp vemp = new KhVoteEmp();
KhVoteEmp vemp = new KhVoteEmp();
vemp.setVoteId(vId);
List<KhVoteEmp> vEmps = khVoteEmpService.selectKhVoteEmpList(vemp);
if(vEmps != null && vEmps.size() > 0){
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)){
if (uPEmp.getKhitemTypeid().equals(1L)) {
uPEmp.setOptionA(BigDecimal.ZERO);
uPEmp.setOptionB(BigDecimal.ZERO);
uPEmp.setOptionC(BigDecimal.ZERO);

@ -0,0 +1,50 @@
package com.ruoyi.kaohe.domain;
import com.ruoyi.common.annotation.Excel;
import java.util.List;
public class ModifyBkhdxParam {
/** 主键 */
private Long id;
private List<Bkhdx> pcBkhdxs;
//0添加 1删除
private String addOrDel;
/** 被考核对象类型(0部门1职工) */
private String bkhdxType;
public String getBkhdxType() {
return bkhdxType;
}
public void setBkhdxType(String bkhdxType) {
this.bkhdxType = bkhdxType;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAddOrDel() {
return addOrDel;
}
public void setAddOrDel(String addOrDel) {
this.addOrDel = addOrDel;
}
public List<Bkhdx> getPcBkhdxs() {
return pcBkhdxs;
}
public void setPcBkhdxs(List<Bkhdx> pcBkhdxs) {
this.pcBkhdxs = pcBkhdxs;
}
}

@ -1,6 +1,8 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
@ -204,7 +206,7 @@ public interface ISysUserService
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
int deleteUserByPcIds(Long[] pcIds);
AjaxResult deleteUserByPcIds(Long[] pcIds);
List<SysUser> selectldUserlist(SysUser user);
}

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.validation.Validator;
import com.ruoyi.common.core.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -482,7 +484,8 @@ public class SysUserServiceImpl implements ISysUserService
@Override
@Transactional
public int deleteUserByPcIds(Long[] pcIds) {
public AjaxResult deleteUserByPcIds(Long[] pcIds) {
Integer uNum=0;//有几个pcId存在需要删除的用户的数量
for (Long pcId : pcIds) {
SysUser param = new SysUser();
param.setPcId(pcId);
@ -498,10 +501,14 @@ public class SysUserServiceImpl implements ISysUserService
userRoleMapper.deleteUserRole(userIds.stream().toArray(Long[]::new));
// 删除用户与岗位关联
userPostMapper.deleteUserPost(userIds.stream().toArray(Long[]::new));
uNum++;
}
}
return userMapper.deleteUserByPcIds(pcIds);
if(uNum>0){
return userMapper.deleteUserByPcIds(pcIds) > 0 ? AjaxResult.success() : AjaxResult.error();
} else{
return AjaxResult.success("没有发现需要清理的账号!");
}
}
/**

Loading…
Cancel
Save