diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 6d225b67..842ff080 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -452,9 +452,14 @@ public class EbomApi extends BaseApi { return ResultVO.success(bomNewEbomParentService.getSource(rowId)); } + /** + * 批量查询物料信息 + * @param query query + * @return 物料信息 + */ @PostMapping("queryMaterials") @ApiOperation("批量查询物料信息") - public ResultVO> queryMaterials(@Valid @RequestBody QueryMaterialsQuery query) { + public ResultVO> queryMaterials(@Valid @RequestBody @NotEmpty List query) { return ResultVO.success(bomNewEbomParentService.queryMaterials(query)); } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index da88d3df..c53c9ab4 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -2350,13 +2350,23 @@ public class BomNewEbomParentService extends ServiceImpl queryMaterials(QueryMaterialsQuery query) { - if (query.getType() == 0) { - return SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(query.getKeys()); - } else if (query.getType() == 1) { - return SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(query.getKeys()); - } else { - throw new NflgBusinessException(STATE.BusinessError, "无效的类别"); + public List queryMaterials(List query) { + List datas = new ArrayList<>(); + List keys = query.stream().map(QueryMaterialsQuery::getMaterialNo) + .filter(StrUtil::isNotBlank) + .distinct() + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(keys)) { + datas.addAll(SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(keys)); } + keys = query.stream() + .filter(it -> StrUtil.isBlank(it.getMaterialNo()) && StrUtil.isNotBlank(it.getDrawingNo())) + .map(QueryMaterialsQuery::getDrawingNo) + .distinct() + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(keys)) { + datas.addAll(SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(keys)); + } + return datas; } }