Commit 84965cff8532ff16cc9a25dd05c34286ea900773

Authored by YunaiV
1 parent c7c29637

refactor(mes-dv): getMachinery 复用 buildMachineryRespVOList 方法

将 getMachinery() 中手动拼接设备类型名/车间名的逻辑,
改为复用 buildMachineryRespVOList() 的批量 Map 查询方式,消除重复代码。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryController.java
@@ -81,24 +81,12 @@ public class MesDvMachineryController { @@ -81,24 +81,12 @@ public class MesDvMachineryController {
81 @PreAuthorize("@ss.hasPermission('mes:dv-machinery:query')") 81 @PreAuthorize("@ss.hasPermission('mes:dv-machinery:query')")
82 public CommonResult<MesDvMachineryRespVO> getMachinery(@RequestParam("id") Long id) { 82 public CommonResult<MesDvMachineryRespVO> getMachinery(@RequestParam("id") Long id) {
83 MesDvMachineryDO machinery = machineryService.getMachinery(id); 83 MesDvMachineryDO machinery = machineryService.getMachinery(id);
84 - MesDvMachineryRespVO respVO = BeanUtils.toBean(machinery, MesDvMachineryRespVO.class);  
85 - // 拼接设备类型名称和车间名称  
86 - // TODO @AI:复用下 buildMachineryRespVOList 方法;  
87 - if (respVO != null) {  
88 - if (respVO.getMachineryTypeId() != null) {  
89 - MesDvMachineryTypeDO machineryType = machineryTypeService.getMachineryType(respVO.getMachineryTypeId());  
90 - if (machineryType != null) {  
91 - respVO.setMachineryTypeName(machineryType.getName());  
92 - }  
93 - }  
94 - if (respVO.getWorkshopId() != null) {  
95 - MesMdWorkshopDO workshop = workshopService.getWorkshop(respVO.getWorkshopId());  
96 - if (workshop != null) {  
97 - respVO.setWorkshopName(workshop.getName());  
98 - }  
99 - } 84 + if (machinery == null) {
  85 + return success(null);
100 } 86 }
101 - return success(respVO); 87 + // 复用 buildMachineryRespVOList 拼接设备类型名称和车间名称
  88 + List<MesDvMachineryRespVO> list = buildMachineryRespVOList(Collections.singletonList(machinery));
  89 + return success(list.get(0));
102 } 90 }
103 91
104 @GetMapping("/page") 92 @GetMapping("/page")