| | |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.andon.vo.config.MesProAndonConfigSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.andon.MesProAndonConfigDO; |
| | | import cn.iocoder.yudao.module.mes.service.pro.andon.MesProAndonConfigService; |
| | | import cn.iocoder.yudao.module.system.api.permission.RoleApi; |
| | | import cn.iocoder.yudao.module.system.api.permission.dto.RoleRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | @Resource |
| | | private RoleApi roleApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建安灯呼叫配置") |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得安灯呼叫配置") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-andon-config:query')") |
| | | public CommonResult<MesProAndonConfigRespVO> getAndonConfig(@RequestParam("id") Long id) { |
| | | MesProAndonConfigDO config = andonConfigService.getAndonConfig(id); |
| | | if (config == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得安灯呼叫配置分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-andon-config:query')") |
| | | public CommonResult<PageResult<MesProAndonConfigRespVO>> getAndonConfigPage(@Valid MesProAndonConfigPageReqVO pageReqVO) { |
| | | PageResult<MesProAndonConfigDO> pageResult = andonConfigService.getAndonConfigPage(pageReqVO); |
| | | return success(new PageResult<>(buildConfigRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | |
| | | @GetMapping("/list") |
| | | @Operation(summary = "获得安灯呼叫配置列表") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-andon-config:query')") |
| | | public CommonResult<List<MesProAndonConfigRespVO>> getAndonConfigList() { |
| | | List<MesProAndonConfigDO> list = andonConfigService.getAndonConfigList(); |
| | | return success(buildConfigRespVOList(list)); |
| | |
| | | // 1. 批量获取关联数据 |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesProAndonConfigDO::getHandlerUserId)); |
| | | Map<Long, RoleRespDTO> roleMap = roleApi.getRoleMap( |
| | | convertSet(list, MesProAndonConfigDO::getHandlerRoleId)); |
| | | // 2. 拼接 VO |
| | | return BeanUtils.toBean(list, MesProAndonConfigRespVO.class, vo -> |
| | | MapUtils.findAndThen(userMap, vo.getHandlerUserId(), |
| | | user -> vo.setHandlerUserNickname(user.getNickname()))); |
| | | return BeanUtils.toBean(list, MesProAndonConfigRespVO.class, vo -> { |
| | | MapUtils.findAndThen(userMap, vo.getHandlerUserId(), |
| | | user -> vo.setHandlerUserNickname(user.getNickname())); |
| | | MapUtils.findAndThen(roleMap, vo.getHandlerRoleId(), |
| | | role -> vo.setHandlerRoleName(role.getName())); |
| | | }); |
| | | } |
| | | |
| | | } |