Commit bdf696ac authored by yuanshuo's avatar yuanshuo

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

1.新增接口/system/user/getInspectionNew用来在发起任务时,直接获取所有人的信息,并不是先获取主检然后再获取检验员了
2.更改TaskServiceImpl文件中关于leader部分的寻找,之前是通过前端传来的isLeader标识符寻找,改成for循环找到的第一个主检人员设置为leader。
3.暂存任务时,由于之前添加了两个字段enterpriseName和enterpriseId所以暂存任务时也要将这两个加上。
parent 30c41068
......@@ -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) {
leader = auditor;
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) {
leader = auditor;
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;
......@@ -10,14 +11,14 @@ import com.ruoyi.common.core.domain.entity.SysUser;
/**
* 用户表 数据层
*
*
* @author ruoyi
*/
public interface SysUserMapper
{
/**
* 根据条件分页查询用户列表
*
*
* @param sysUser 用户信息
* @return 用户信息集合信息
*/
......@@ -25,7 +26,7 @@ public interface SysUserMapper
/**
* 根据条件分页查询已配用户角色列表
*
*
* @param user 用户信息
* @return 用户信息集合信息
*/
......@@ -33,7 +34,7 @@ public interface SysUserMapper
/**
* 根据条件分页查询未分配用户角色列表
*
*
* @param user 用户信息
* @return 用户信息集合信息
*/
......@@ -41,7 +42,7 @@ public interface SysUserMapper
/**
* 通过用户名查询用户
*
*
* @param userName 用户名
* @return 用户对象信息
*/
......@@ -49,7 +50,7 @@ public interface SysUserMapper
/**
* 通过用户ID查询用户
*
*
* @param userId 用户ID
* @return 用户对象信息
*/
......@@ -57,7 +58,7 @@ public interface SysUserMapper
/**
* 新增用户信息
*
*
* @param user 用户信息
* @return 结果
*/
......@@ -65,7 +66,7 @@ public interface SysUserMapper
/**
* 修改用户信息
*
*
* @param user 用户信息
* @return 结果
*/
......@@ -73,7 +74,7 @@ public interface SysUserMapper
/**
* 修改用户头像
*
*
* @param userName 用户名
* @param avatar 头像地址
* @return 结果
......@@ -82,7 +83,7 @@ public interface SysUserMapper
/**
* 重置用户密码
*
*
* @param userName 用户名
* @param password 密码
* @return 结果
......@@ -91,7 +92,7 @@ public interface SysUserMapper
/**
* 通过用户ID删除用户
*
*
* @param userId 用户ID
* @return 结果
*/
......@@ -99,7 +100,7 @@ public interface SysUserMapper
/**
* 批量删除用户信息
*
*
* @param userIds 需要删除的用户ID
* @return 结果
*/
......@@ -107,7 +108,7 @@ public interface SysUserMapper
/**
* 校验用户名称是否唯一
*
*
* @param userName 用户名称
* @return 结果
*/
......@@ -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<>();
......
......@@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
<resultMap id="deptResult" type="SysDept">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
......@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="leader" column="leader" />
<result property="status" column="dept_status" />
</resultMap>
<resultMap id="RoleResult" type="SysRole">
<id property="roleId" column="role_id" />
<result property="roleName" column="role_name" />
......@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="dataScope" column="data_scope" />
<result property="status" column="role_status" />
</resultMap>
<sql id="selectUserVo">
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.signature_picture,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
......@@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
</sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
......@@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
......@@ -102,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
......@@ -120,25 +120,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
</select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_id = #{userId}
</select>
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
</select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
</select>
......@@ -188,7 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate()
)
</insert>
<update id="updateUser" parameterType="SysUser">
update sys_user
<set>
......@@ -210,28 +210,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set>
where user_id = #{userId}
</update>
<update id="updateUserStatus" parameterType="SysUser">
update sys_user set status = #{status} where user_id = #{userId}
</update>
<update id="updateUserAvatar" parameterType="SysUser">
update sys_user set avatar = #{avatar} where user_name = #{userName}
</update>
<update id="resetUserPwd" parameterType="SysUser">
update sys_user set password = #{password} where user_name = #{userName}
</update>
<delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId}
</delete>
<delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</foreach>
</delete>
<select id="countTaskByUserId" resultType="com.ruoyi.system.domain.vo.UserCountVo">
select count(*) countNum, tr.user_id userId, s.nick_name nikeName
......@@ -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>
\ No newline at end of file
</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