| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.hrm.api.employee.HrmEmployeeApi; |
| | | import cn.iocoder.yudao.module.hrm.api.employee.dto.HrmEmployeeSimpleRespDTO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.worker.MesMdWorkstationEmployeeRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.worker.MesMdWorkstationWorkerRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.worker.MesMdWorkstationWorkerSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationWorkerDO; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Resource |
| | | private PostApi postApi; |
| | | |
| | | @Resource |
| | | private HrmEmployeeApi hrmEmployeeApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建人力资源") |
| | |
| | | @GetMapping("/list-by-workstation") |
| | | @Operation(summary = "获得人力资源列表") |
| | | @Parameter(name = "workstationId", description = "工作站编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:md-workstation:query')") |
| | | public CommonResult<List<MesMdWorkstationWorkerRespVO>> getWorkstationWorkerList( |
| | | @RequestParam("workstationId") Long workstationId) { |
| | | List<MesMdWorkstationWorkerDO> list = workstationWorkerService.getWorkstationWorkerListByWorkstationId(workstationId); |
| | | return success(buildWorkstationWorkerRespVOList(list)); |
| | | } |
| | | |
| | | @GetMapping("/list-user-by-workstation") |
| | | @Operation(summary = "获得工作站对应岗位的员工列表(取自员工管理数据,不要求开通系统账号)") |
| | | @Parameter(name = "workstationId", description = "工作站编号", required = true) |
| | | public CommonResult<List<MesMdWorkstationEmployeeRespVO>> getUserListByWorkstation( |
| | | @RequestParam("workstationId") Long workstationId) { |
| | | List<MesMdWorkstationWorkerDO> list = workstationWorkerService.getWorkstationWorkerListByWorkstationId(workstationId); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return success(Collections.emptyList()); |
| | | } |
| | | List<Long> postIds = cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList(list, MesMdWorkstationWorkerDO::getPostId); |
| | | if (CollUtil.isEmpty(postIds)) { |
| | | return success(Collections.emptyList()); |
| | | } |
| | | List<HrmEmployeeSimpleRespDTO> employees = hrmEmployeeApi.getEmployeeListByPostIds(postIds); |
| | | List<MesMdWorkstationEmployeeRespVO> result = new ArrayList<>(employees.size()); |
| | | for (HrmEmployeeSimpleRespDTO employee : employees) { |
| | | MesMdWorkstationEmployeeRespVO vo = new MesMdWorkstationEmployeeRespVO(); |
| | | vo.setId(employee.getId()); |
| | | vo.setNickname(employee.getName()); |
| | | vo.setDeptId(employee.getDeptId()); |
| | | vo.setPhone(employee.getPhone()); |
| | | result.add(vo); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | private List<MesMdWorkstationWorkerRespVO> buildWorkstationWorkerRespVOList(List<MesMdWorkstationWorkerDO> list) { |