|
@@ -83,7 +83,30 @@ public class IotDeviceBomController {
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-device-bom:query')")
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-device-bom:query')")
|
|
public CommonResult<PageResult<IotDeviceBomRespVO>> getIotDeviceBomPage(@Valid IotDeviceBomPageReqVO pageReqVO) {
|
|
public CommonResult<PageResult<IotDeviceBomRespVO>> getIotDeviceBomPage(@Valid IotDeviceBomPageReqVO pageReqVO) {
|
|
PageResult<IotDeviceBomDO> pageResult = iotDeviceBomService.getIotDeviceBomPage(pageReqVO);
|
|
PageResult<IotDeviceBomDO> pageResult = iotDeviceBomService.getIotDeviceBomPage(pageReqVO);
|
|
- return success(BeanUtils.toBean(pageResult, IotDeviceBomRespVO.class));
|
|
|
|
|
|
+ if (CollUtil.isEmpty(pageResult.getList())) {
|
|
|
|
+ return success(PageResult.empty());
|
|
|
|
+ }
|
|
|
|
+ List<Long> bomNodeIds = pageResult.getList().stream()
|
|
|
|
+ .map(IotDeviceBomDO::getId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ IotDeviceMaterialSaveReqVO saveReqVO = new IotDeviceMaterialSaveReqVO();
|
|
|
|
+ saveReqVO.setBomNodeIds(bomNodeIds);
|
|
|
|
+ List<IotDeviceMaterialDO> bomMaterials = iotDeviceMaterialService.getIotDeviceMaterials(saveReqVO);
|
|
|
|
+ Map<Long, Integer> bomMaterialCount = new HashMap<>();
|
|
|
|
+ if (CollUtil.isNotEmpty(bomMaterials)) {
|
|
|
|
+ bomMaterials.forEach(material -> {
|
|
|
|
+ if (bomMaterialCount.containsKey(material.getBomNodeId())) {
|
|
|
|
+ bomMaterialCount.put(material.getBomNodeId(), bomMaterialCount.get(material.getBomNodeId())+1);
|
|
|
|
+ } else {
|
|
|
|
+ bomMaterialCount.put(material.getBomNodeId(), 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // return success(BeanUtils.toBean(pageResult, IotDeviceBomRespVO.class));
|
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotDeviceBomRespVO.class, bom -> {
|
|
|
|
+ Integer materialCount = bomMaterialCount.getOrDefault(bom.getId(), 0);
|
|
|
|
+ bom.setMaterials(materialCount);
|
|
|
|
+ }));
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
|
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|