1
This commit is contained in:
parent
ce90f714e2
commit
cccf884a2c
@ -129,4 +129,6 @@ public class BaseConstants {
|
||||
/** 字典:超时自动总检配置 */
|
||||
public static final String AUTO_INSPECTION = "auto_inspection";
|
||||
|
||||
public static final String MAP_NO_DATA = "map_no_data";
|
||||
|
||||
}
|
||||
|
@ -44,4 +44,12 @@ public interface RepairWorkerMapper extends BaseMapper<RepairWorker> {
|
||||
* @return cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO
|
||||
**/
|
||||
RepairWorkerRespVO getByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询所有维修工信息
|
||||
* @author PQZ
|
||||
* @date 17:28 2024/11/4
|
||||
* @return cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO
|
||||
**/
|
||||
List<RepairWorkerRespVO> listAllWorker();
|
||||
}
|
||||
|
@ -28,14 +28,14 @@ public interface RepairWorkerService extends IService<RepairWorker> {
|
||||
**/
|
||||
void saveWorkers(List<UserDTO> userList);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id查询对应维修的角色,维修工人则查询班组,非维修工人查询角色
|
||||
* 查询所有维修工
|
||||
* @author PQZ
|
||||
* @date 17:21 2024/11/4
|
||||
* @param userId 用户id
|
||||
* @return java.lang.String
|
||||
* @date 14:07 2024/11/7
|
||||
* @return java.util.List<cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO>
|
||||
**/
|
||||
String getWorkerRoleName(Long userId);
|
||||
List<RepairWorkerRespVO> listAllWorker();
|
||||
|
||||
/**
|
||||
* 更新维修工人
|
||||
|
@ -1,23 +1,29 @@
|
||||
package cn.iocoder.yudao.module.base.service.impl;
|
||||
|
||||
import cn.iocoder.yudao.common.RepairRoleEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.base.entity.RepairRecords;
|
||||
import cn.iocoder.yudao.module.base.entity.RepairRecordsItem;
|
||||
import cn.iocoder.yudao.module.base.entity.RepairWorker;
|
||||
import cn.iocoder.yudao.module.base.mapper.RepairRecordsMapper;
|
||||
import cn.iocoder.yudao.module.base.service.RepairRecordsItemService;
|
||||
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
|
||||
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
|
||||
import cn.iocoder.yudao.module.base.vo.RepairRecordsPageReqVO;
|
||||
import cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO;
|
||||
import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO;
|
||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.common.BaseConstants.REPAIR_RECORD_TYPE_RECORD;
|
||||
@ -39,7 +45,9 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
|
||||
private RepairRecordsItemService itemService;
|
||||
@Resource
|
||||
private RepairWorkerService workerService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private PermissionApi permissionApi;
|
||||
|
||||
/**
|
||||
* 保存维修记录
|
||||
@ -83,9 +91,21 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
|
||||
public List<RepairRecordsRespVO> queryList(RepairRecordsPageReqVO pageReqVO) {
|
||||
//根据条件查询维修记录
|
||||
List<RepairRecordsRespVO> list = repairRecordsMapper.queryRepairRecords(pageReqVO);
|
||||
List<Long> userIds = list.stream().map(RepairRecords::getDealUserId).collect(Collectors.toList());
|
||||
//所有维修工
|
||||
List<RepairWorkerRespVO> allWorker = workerService.listAllWorker();
|
||||
//转换成map
|
||||
Map<Long,RepairWorkerRespVO> mapWorker = allWorker.stream().collect(Collectors.toMap(RepairWorker::getUserId,worker -> worker));
|
||||
//用户及角色
|
||||
Map<Long,List<String>> userRoleMap = permissionApi.roleCodesByUserIds(userIds);
|
||||
//为每一条维修记录设置查询附件
|
||||
list.forEach(item -> {
|
||||
item.setRoleName(workerService.getWorkerRoleName(item.getDealUserId()));
|
||||
String workerName = mapWorker.getOrDefault(item.getDealUserId(),new RepairWorkerRespVO()).getWorkerTypeStr();
|
||||
if (null != workerName) {
|
||||
item.setRoleName(workerName);
|
||||
} else {
|
||||
item.setRoleName(getRoleName(userRoleMap.get(item.getDealUserId())));
|
||||
}
|
||||
List<RepairRecordsItem> itemList = itemService.getByMainId(REPAIR_RECORD_TYPE_RECORD, item.getId(), pageReqVO.getIsOpen());
|
||||
item.setItemList(itemList);
|
||||
//相对路径按照“,”分隔
|
||||
@ -94,6 +114,37 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色匹配名称
|
||||
* @author PQZ
|
||||
* @date 14:52 2024/11/7
|
||||
* @param codes 用户的角色codes集合
|
||||
* @return java.lang.String
|
||||
**/
|
||||
private String getRoleName(List<String> codes) {
|
||||
//维修业务管理员
|
||||
if (codes.contains(RepairRoleEnum.ADMIN.getCode())) {
|
||||
return RepairRoleEnum.ADMIN.getName();
|
||||
}
|
||||
// 总检
|
||||
if (codes.contains(RepairRoleEnum.INSPECTION.getCode())) {
|
||||
return RepairRoleEnum.INSPECTION.getName();
|
||||
}
|
||||
// 服务顾问
|
||||
if (codes.contains(RepairRoleEnum.ADVISOR.getCode())) {
|
||||
return RepairRoleEnum.ADVISOR.getName();
|
||||
}
|
||||
// 维修仓库管理员
|
||||
if (codes.contains(RepairRoleEnum.WAREHOUSE.getCode())) {
|
||||
return RepairRoleEnum.WAREHOUSE.getName();
|
||||
}
|
||||
// 维修财务
|
||||
if (codes.contains(RepairRoleEnum.WXCW.getCode())) {
|
||||
return RepairRoleEnum.WXCW.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前用户和工单主表id查询当前在维修的项目信息
|
||||
*
|
||||
|
@ -1,10 +1,8 @@
|
||||
package cn.iocoder.yudao.module.base.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.RepairRoleEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.app.controller.admin.NotifyMessageSocket;
|
||||
@ -22,9 +20,6 @@ import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
|
||||
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
|
||||
@ -39,7 +34,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.yaml.snakeyaml.events.Event;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
@ -116,50 +110,18 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id查询对应维修的角色,维修工人则查询班组,非维修工人查询角色
|
||||
* 查询所有维修工
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return java.lang.String
|
||||
* @return java.util.List<cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO>
|
||||
* @author PQZ
|
||||
* @date 17:21 2024/11/4
|
||||
* @date 14:07 2024/11/7
|
||||
**/
|
||||
@Override
|
||||
public String getWorkerRoleName(Long userId) {
|
||||
RepairWorkerRespVO worker = workerMapper.getByUserId(userId);
|
||||
//如果为空说明不是维修工,查询当前用户的角色
|
||||
if (null != worker) {
|
||||
return worker.getWorkerTypeStr();
|
||||
} else {
|
||||
List<Long> roleIds = permissionApi.getRoleIdsByUserId(userId);
|
||||
// 所有的角色信息
|
||||
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
||||
// 过滤出登录用户有的角色信息
|
||||
List<RoleReqDTO> collect = roleList.stream().filter(item -> roleIds.contains(item.getId())).collect(Collectors.toList());
|
||||
// 取出角色code
|
||||
List<String> codes = collect.stream().map(RoleReqDTO::getCode).collect(Collectors.toList());
|
||||
//维修业务管理员
|
||||
if (codes.contains(RepairRoleEnum.ADMIN.getCode())) {
|
||||
return RepairRoleEnum.ADMIN.getName();
|
||||
}
|
||||
// 总检
|
||||
if (codes.contains(RepairRoleEnum.INSPECTION.getCode())) {
|
||||
return RepairRoleEnum.INSPECTION.getName();
|
||||
}
|
||||
// 服务顾问
|
||||
if (codes.contains(RepairRoleEnum.ADVISOR.getCode())) {
|
||||
return RepairRoleEnum.ADVISOR.getName();
|
||||
}
|
||||
// 维修仓库管理员
|
||||
if (codes.contains(RepairRoleEnum.WAREHOUSE.getCode())) {
|
||||
return RepairRoleEnum.WAREHOUSE.getName();
|
||||
}
|
||||
// 维修财务
|
||||
if (codes.contains(RepairRoleEnum.WXCW.getCode())) {
|
||||
return RepairRoleEnum.WXCW.getName();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
public List<RepairWorkerRespVO> listAllWorker() {
|
||||
return workerMapper.listAllWorker();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +48,16 @@
|
||||
main.deleted = 0
|
||||
AND main.user_id = #{userId}
|
||||
</select>
|
||||
<select id="listAllWorker" resultType="cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO">
|
||||
SELECT
|
||||
main.*,
|
||||
sdd.label AS workerTypeStr
|
||||
FROM
|
||||
dl_repair_worker main
|
||||
LEFT JOIN system_dict_data sdd ON sdd.dict_type = 'repair_work_type' AND main.work_type = sdd.`value`
|
||||
WHERE
|
||||
main.deleted = 0
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespD
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -73,6 +74,15 @@ public interface PermissionApi {
|
||||
**/
|
||||
List<Long> getRoleIdsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 通过用户id查询角色
|
||||
* @author PQZ
|
||||
* @date 14:29 2024/11/7
|
||||
* @param userIds 用户id集合
|
||||
* @return key用户id,value角色codes
|
||||
**/
|
||||
Map<Long,List<String>> roleCodesByUserIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 根据权限ID拿拥有该权限的所有人
|
||||
* @author 小李
|
||||
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.api.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserRoleDTO {
|
||||
private Long userId;
|
||||
private String roleCode;
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.api.permission;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -77,6 +79,21 @@ public class PermissionApiImpl implements PermissionApi {
|
||||
return roleIds.stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户id查询角色
|
||||
*
|
||||
* @param userIds 用户id集合
|
||||
* @return key用户id,value角色codes
|
||||
* @author PQZ
|
||||
* @date 14:29 2024/11/7
|
||||
**/
|
||||
@Override
|
||||
public Map<Long, List<String>> roleCodesByUserIds(List<Long> userIds) {
|
||||
List<UserRoleDTO> userRoleDTOList = permissionService.userRoleDTOList(userIds);
|
||||
Map<Long, List<String>> resultMap = userRoleDTOList.stream().collect(Collectors.groupingBy(UserRoleDTO::getUserId,Collectors.mapping(UserRoleDTO::getRoleCode,Collectors.toList())));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据权限ID拿拥有该权限的所有人
|
||||
* @author 小李
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.permission;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -42,4 +42,13 @@ public interface UserRoleMapper extends BaseMapperX<UserRoleDO> {
|
||||
List<UserDTO> selectByRoleCode(@Param("tenantId") Long tenantId, @Param("roleCode") String roleCode);
|
||||
|
||||
IPage<UserDTO> selectListByRoleId(@Param("page") Page<UserDTO> page,@Param("role") RolePageReqVO role);
|
||||
|
||||
/**
|
||||
* 通过用户id查询用户关联角色code
|
||||
* @author PQZ
|
||||
* @date 14:39 2024/11/7
|
||||
* @param userIds 用户id集合
|
||||
* @return java.util.List<cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO>
|
||||
**/
|
||||
List<UserRoleDTO> userCodes(@Param("userIds") List<Long> userIds);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.service.permission;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -26,6 +27,15 @@ public interface PermissionService {
|
||||
*/
|
||||
boolean hasAnyPermissions(Long userId, String... permissions);
|
||||
|
||||
/**
|
||||
* 查询用户及角色
|
||||
* @author PQZ
|
||||
* @date 14:42 2024/11/7
|
||||
* @param userIds 用户id
|
||||
* @return java.util.List<cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO>
|
||||
**/
|
||||
List<UserRoleDTO> userRoleDTOList(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 判断是否有角色,任一一个即可
|
||||
*
|
||||
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleMenuDO;
|
||||
@ -38,7 +39,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
||||
import static javafx.scene.input.KeyCode.H;
|
||||
|
||||
/**
|
||||
* 权限 Service 实现类
|
||||
@ -87,6 +87,19 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
return roleService.hasAnySuperAdmin(convertSet(roles, RoleDO::getId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户及角色
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @return java.util.List<cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO>
|
||||
* @author PQZ
|
||||
* @date 14:42 2024/11/7
|
||||
**/
|
||||
@Override
|
||||
public List<UserRoleDTO> userRoleDTOList(List<Long> userIds) {
|
||||
return userRoleMapper.userCodes(userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断指定角色,是否拥有该 permission 权限
|
||||
*
|
||||
|
@ -35,4 +35,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="userCodes" resultType="cn.iocoder.yudao.module.system.api.user.dto.UserRoleDTO">
|
||||
SELECT
|
||||
su.id AS userId,sr.code AS roleCode
|
||||
FROM
|
||||
system_users su
|
||||
LEFT JOIN system_user_role sur ON su.id = sur.user_id AND sur.deleted = 0
|
||||
LEFT JOIN system_role sr ON sur.role_id = sr.id AND sr.deleted = 0
|
||||
WHERE su.deleted = 0
|
||||
AND su.id IN
|
||||
<foreach item="item" collection="userIds" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user