From d1715c2c2b4078c870065e88b9999ee0ce550dea Mon Sep 17 00:00:00 2001 From: PQZ Date: Mon, 4 Nov 2024 18:44:19 +0800 Subject: [PATCH] 1 --- .../base/mapper/RepairWorkerMapper.java | 9 +++ .../base/service/RepairWorkerService.java | 9 +++ .../impl/RepairRecordsServiceImpl.java | 4 ++ .../service/impl/RepairWorkerServiceImpl.java | 57 +++++++++++++++++++ .../module/base/vo/RepairRecordsRespVO.java | 2 + .../module/base/vo/RepairWorkerRespVO.java | 2 +- .../mapper/base/RepairWorkerMapper.xml | 11 ++++ 7 files changed, 93 insertions(+), 1 deletion(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairWorkerMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairWorkerMapper.java index 980d8c6b..a371e049 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairWorkerMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairWorkerMapper.java @@ -35,4 +35,13 @@ public interface RepairWorkerMapper extends BaseMapper { * @date 2024年10月10日 **/ List getAllWorkerIds(); + + /** + * 根据userId查询维修工信息 + * @author PQZ + * @date 17:28 2024/11/4 + * @param userId 用户id + * @return cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO + **/ + RepairWorkerRespVO getByUserId(Long userId); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java index c267c455..05a1946a 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java @@ -27,6 +27,15 @@ public interface RepairWorkerService extends IService { * @param userList 选中用户集合 **/ void saveWorkers(List userList); + + /** + * 根据用户id查询对应维修的角色,维修工人则查询班组,非维修工人查询角色 + * @author PQZ + * @date 17:21 2024/11/4 + * @param userId 用户id + * @return java.lang.String + **/ + String getWorkerRoleName(Long userId); /** * 更新维修工人 diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsServiceImpl.java index ceca1561..d3c8d0fb 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsServiceImpl.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.base.entity.RepairRecordsItem; 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.system.api.user.AdminUserApi; @@ -36,6 +37,8 @@ public class RepairRecordsServiceImpl extends ServiceImpl list = repairRecordsMapper.queryRepairRecords(pageReqVO); //为每一条维修记录设置查询附件 list.forEach(item -> { + item.setRoleName(workerService.getWorkerRoleName(item.getDealUserId())); List itemList = itemService.getByMainId(REPAIR_RECORD_TYPE_RECORD, item.getId(), pageReqVO.getIsOpen()); item.setItemList(itemList); //相对路径按照“,”分隔 diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java index 3c96809e..62d1f243 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.base.service.impl; import cn.hutool.core.collection.CollectionUtil; +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; @@ -15,6 +16,9 @@ import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; 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.dto.UserDTO; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService; @@ -57,6 +61,13 @@ public class RepairWorkerServiceImpl extends ServiceImpl roleIds = permissionApi.getRoleIdsByUserId(userId); + // 所有的角色信息 + List roleList = roleApi.getRoleList(); + // 过滤出登录用户有的角色信息 + List collect = roleList.stream().filter(item -> roleIds.contains(item.getId())).collect(Collectors.toList()); + // 取出角色code + List 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; + } + @Override public void updateWorker(RepairWorkerSaveReqVO updateReqVO) { // 更新 diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java index 76e0cb96..c6498082 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java @@ -16,5 +16,7 @@ public class RepairRecordsRespVO extends RepairRecords { private List itemList; /**维修记录关联附件信息*/ private String images; + /**角色、岗位名称*/ + private String roleName; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairWorkerRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairWorkerRespVO.java index cf02492d..c0df46b2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairWorkerRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairWorkerRespVO.java @@ -9,7 +9,7 @@ import lombok.Data; @Data @ExcelIgnoreUnannotated public class RepairWorkerRespVO extends RepairWorker { - + private String workerTypeStr; } diff --git a/dl-module-repair/src/main/resources/mapper/base/RepairWorkerMapper.xml b/dl-module-repair/src/main/resources/mapper/base/RepairWorkerMapper.xml index c51f3010..68b75801 100644 --- a/dl-module-repair/src/main/resources/mapper/base/RepairWorkerMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/base/RepairWorkerMapper.xml @@ -37,6 +37,17 @@ WHERE main.deleted = 0 +