Commit 9b071682 authored by 宋源硕's avatar 宋源硕

Merge branch 'songyuanshuo' into 'dev'

2024/11/27新增和修改方法

See merge request !465
parents 360fccb7 bdf696ac
......@@ -20,6 +20,7 @@ import com.ruoyi.domain.*;
import com.ruoyi.domain.vo.CaseStatisticsVO;
import com.ruoyi.mapper.*;
import com.ruoyi.service.*;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.*;
import com.ruoyi.web.response.*;
......@@ -138,6 +139,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Autowired
private TestRecordsMapper testRecordsMapper;
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Override
public List<Task> findList(TaskListRequest request) {
return taskMapper.findList(request);
......@@ -196,8 +200,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
List<Long> roleIdList = sysUserRoleMapper.selectRoleIdByUserId(auditor.getUserId());
for (Long roleId : roleIdList){
if (roleId.equals(112L)){
leader = auditor;
auditor.setIsLeader(1);
break;
}
}
if (leader != null){
break;
}
}
......@@ -334,8 +345,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
List<Long> roleIdList = sysUserRoleMapper.selectRoleIdByUserId(auditor.getUserId());
for (Long roleId : roleIdList){
if (roleId.equals(112L)){
leader = auditor;
auditor.setIsLeader(1);
break;
}
}
if (leader != null){
break;
}
}
......@@ -588,10 +606,32 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
}
if(request.getEnterpriseName() != null){
task.setEnterpriseName(request.getEnterpriseName());
}
if (request.getEnterpriseId() != null){
task.setEnterpriseId(request.getEnterpriseId());
}
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
for(TaskUserRelation auditor : auditors) {
List<Long> roleIdList = sysUserRoleMapper.selectRoleIdByUserId(auditor.getUserId());
for (Long roleId : roleIdList){
if (roleId.equals(112L)){
leader = auditor;
auditor.setIsLeader(1);
break;
}
}
if (leader != null){
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
break;
}
}
/*TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
if (auditors != null && auditors.size() != 0) {
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
......@@ -603,7 +643,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 任务组长
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
}
}*/
// 暂存
taskService.save(task);
......@@ -657,6 +697,23 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
for(TaskUserRelation auditor : auditors) {
List<Long> roleIdList = sysUserRoleMapper.selectRoleIdByUserId(auditor.getUserId());
for (Long roleId : roleIdList){
if (roleId.equals(112L)){
leader = auditor;
auditor.setIsLeader(1);
break;
}
}
if (leader != null){
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
break;
}
}
/*TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
if (auditors != null && auditors.size() != 0) {
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
......@@ -667,7 +724,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 任务组长
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
}
}*/
// 更新暂存
taskService.updateById(task);
......
......@@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.vo.SysUserVO;
import com.ruoyi.system.domain.vo.SysUserVONew;
import com.ruoyi.system.request.InspectionRequest;
import com.ruoyi.system.service.*;
import com.ruoyi.web.request.UserByRoleRequest;
......@@ -136,6 +137,11 @@ public class SysUserController extends BaseController
return R.ok(userService.getInspection());
}
@ApiOperation("获取检验人员列表新")
@PostMapping("/getInspectionNew")
public R<List<SysUserVONew>> getInspectionNew() {
return R.ok(userService.getInspectionNew());
}
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "param1", value = "arg[1]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
......
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class SysUserVONew {
@ApiModelProperty("用户id")
private Long userId;
@ApiModelProperty("用户账号")
private String userName;
@ApiModelProperty("用户昵称")
private String nickname;
@ApiModelProperty("部门名称")
private String deptName;
@ApiModelProperty("角色id")
private List<Long> roleId;
@ApiModelProperty("帐号状态(0正常 1停用)")
private String status;
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
private String delFlag;
}
......@@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.vo.SysUserVO;
import com.ruoyi.system.domain.vo.SysUserVONew;
import com.ruoyi.system.domain.vo.UserCountVo;
import com.ruoyi.system.request.InspectionRequest;
import org.apache.ibatis.annotations.Param;
......@@ -161,4 +162,9 @@ public interface SysUserMapper
* @return
*/
List<SysUserVO> getInspection();
/**
* 获取检验人员列表
* @return
*/
List<SysUserVONew> getInspectionNew();
}
......@@ -66,4 +66,9 @@ public interface SysUserRoleMapper
*根据roleId查询审核员Id
* */
List<Long> selectReviewerIdByRoleId(Long roleId);
/*
* 根据用户获取角色id
* */
List<Long> selectRoleIdByUserId(Long userId);
}
......@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.vo.SysUserVO;
import com.ruoyi.system.domain.vo.SysUserVONew;
import com.ruoyi.system.request.InspectionRequest;
/**
......@@ -239,4 +240,6 @@ public interface ISysUserService
* @return
*/
List<SysUserVO> getInspection();
List<SysUserVONew> getInspectionNew();
}
......@@ -7,6 +7,7 @@ import javax.validation.Validator;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.system.domain.vo.SysUserVO;
import com.ruoyi.system.domain.vo.SysUserVONew;
import com.ruoyi.system.domain.vo.UserCountVo;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.request.InspectionRequest;
......@@ -621,6 +622,24 @@ public class SysUserServiceImpl implements ISysUserService
return deduplicatedList;
}
/**
* 获取检验人员列表
* @return
*/
@Override
public List<SysUserVONew> getInspectionNew() {
List<SysUserVONew> userList = userMapper.getInspectionNew();
for (SysUserVONew sysUserVONew : userList){
List<Long> roleId = userRoleMapper.selectRoleIdByUserId(sysUserVONew.getUserId());
sysUserVONew.setRoleId(roleId);
}
// 使用Stream API进行去重,基于userId字段
/*List<SysUserVO> deduplicatedList = userList.stream()
.filter(distinctByKey(user -> user.getUserId()))
.collect(Collectors.toList());*/
return userList;
}
// 辅助方法,用于去重
private static <T> java.util.function.Predicate<T> distinctByKey(java.util.function.Function<? super T, ?> keyExtractor) {
java.util.Map<Object, Boolean> seen = new java.util.concurrent.ConcurrentHashMap<>();
......
......@@ -260,5 +260,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where sr.role_id IN (106, 112)
and u.del_flag = '0'
</select>
<select id="getInspectionNew" resultType="com.ruoyi.system.domain.vo.SysUserVONew">
select u.user_id,u.user_name,u.nick_name,u.status,u.del_flag, sd.dept_name
from sys_user u
left join sys_user_role sr on u.user_id = sr.user_id
left join sys_dept sd on sd.dept_id = u.dept_id
where sr.role_id IN (106, 112)
and u.del_flag = '0'
</select>
</mapper>
......@@ -20,6 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectReviewerIdByRoleId" resultType="java.lang.Long">
select user_id from sys_user_role where role_id = #{roleId}
</select>
<select id="selectRoleIdByUserId" resultType="java.lang.Long">
select role_id
from sys_user_role
where user_id = #{userId}
</select>
<delete id="deleteUserRole" parameterType="Long">
delete from sys_user_role where user_id in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment