gaoluyang
7 天以前 7bd10d34e8a8dc2437ec8551eb511e37634d7306
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryController.java
@@ -55,6 +55,9 @@
    @Resource
    private cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService workstationService;
    @Resource
    private cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService processService;
    @PostMapping("/create")
    @Operation(summary = "创建设备")
    @PreAuthorize("@ss.hasPermission('mes:dv-machinery:create')")
@@ -82,7 +85,6 @@
    @GetMapping("/get")
    @Operation(summary = "获得设备")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:dv-machinery:query')")
    public CommonResult<MesDvMachineryRespVO> getMachinery(@RequestParam("id") Long id) {
        MesDvMachineryDO machinery = machineryService.getMachinery(id);
        if (machinery == null) {
@@ -93,7 +95,6 @@
    @GetMapping("/page")
    @Operation(summary = "获得设备分页")
    @PreAuthorize("@ss.hasPermission('mes:dv-machinery:query')")
    public CommonResult<PageResult<MesDvMachineryRespVO>> getMachineryPage(@Valid MesDvMachineryPageReqVO pageReqVO) {
        PageResult<MesDvMachineryDO> pageResult = machineryService.getMachineryPage(pageReqVO);
        return success(new PageResult<>(buildMachineryRespVOList(pageResult.getList()), pageResult.getTotal()));
@@ -114,7 +115,6 @@
    @GetMapping("/simple-list")
    @Operation(summary = "获得设备精简列表", description = "主要用于前端的下拉选项")
    @PreAuthorize("@ss.hasPermission('mes:dv-machinery:query')")
    public CommonResult<List<MesDvMachineryRespVO>> getMachinerySimpleList() {
        List<MesDvMachineryDO> list = machineryService.getMachineryList();
        return success(BeanUtils.toBean(list, MesDvMachineryRespVO.class));
@@ -160,6 +160,8 @@
                convertSet(list, MesDvMachineryDO::getWorkshopId));
        Map<Long, cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO> workstationMap =
                workstationService.getWorkstationMap(convertSet(list, MesDvMachineryDO::getWorkstationId));
        Map<Long, cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO> processMap =
                processService.getProcessMap(convertSet(list, MesDvMachineryDO::getProcessId));
        // 2. 拼接 VO
        return BeanUtils.toBean(list, MesDvMachineryRespVO.class, vo -> {
            MapUtils.findAndThen(machineryTypeMap, vo.getMachineryTypeId(),
@@ -168,6 +170,8 @@
                    workshop -> vo.setWorkshopName(workshop.getName()));
            MapUtils.findAndThen(workstationMap, vo.getWorkstationId(),
                    workstation -> vo.setWorkstationName(workstation.getName()));
            MapUtils.findAndThen(processMap, vo.getProcessId(),
                    process -> vo.setProcessName(process.getName()));
        });
    }