This commit is contained in:
PQZ 2024-11-04 18:44:19 +08:00
parent ab35fd68c2
commit d1715c2c2b
7 changed files with 93 additions and 1 deletions

View File

@ -35,4 +35,13 @@ public interface RepairWorkerMapper extends BaseMapper<RepairWorker> {
* @date 2024年10月10日
**/
List<Long> 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);
}

View File

@ -28,6 +28,15 @@ 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
**/
String getWorkerRoleName(Long userId);
/**
* 更新维修工人
*

View File

@ -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<RepairRecordsMapper, R
private AdminUserApi userApi;
@Resource
private RepairRecordsItemService itemService;
@Resource
private RepairWorkerService workerService;
/**
@ -82,6 +85,7 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
List<RepairRecordsRespVO> list = repairRecordsMapper.queryRepairRecords(pageReqVO);
//为每一条维修记录设置查询附件
list.forEach(item -> {
item.setRoleName(workerService.getWorkerRoleName(item.getDealUserId()));
List<RepairRecordsItem> itemList = itemService.getByMainId(REPAIR_RECORD_TYPE_RECORD, item.getId(), pageReqVO.getIsOpen());
item.setItemList(itemList);
//相对路径按照分隔

View File

@ -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<RepairWorkerMapper, Rep
@Resource
private DictDataApi dictDataApi;
@Resource
@Lazy
private RoleApi roleApi;
@Resource
@Lazy
private PermissionApi permissionApi;
/**
* 批量创建维修工人
@ -87,6 +98,52 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
}
}
/**
* 根据用户id查询对应维修的角色维修工人则查询班组非维修工人查询角色
*
* @param userId 用户id
* @return java.lang.String
* @author PQZ
* @date 17:21 2024/11/4
**/
@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;
}
@Override
public void updateWorker(RepairWorkerSaveReqVO updateReqVO) {
// 更新

View File

@ -16,5 +16,7 @@ public class RepairRecordsRespVO extends RepairRecords {
private List<RepairRecordsItem> itemList;
/**维修记录关联附件信息*/
private String images;
/**角色、岗位名称*/
private String roleName;
}

View File

@ -9,7 +9,7 @@ import lombok.Data;
@Data
@ExcelIgnoreUnannotated
public class RepairWorkerRespVO extends RepairWorker {
private String workerTypeStr;
}

View File

@ -37,6 +37,17 @@
WHERE
main.deleted = 0
</select>
<select id="getByUserId" 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
AND main.user_id = #{userId}
</select>
</mapper>