ResponseEntity<Page<WmsInventoryHistoryVO>> ok = ResponseEntity.ok(service.selectList(new WmsInventoryHistory(), page));
WmsInventoryHistory wmsInventoryHistory = new WmsInventoryHistory();
wmsInventoryHistory.setWarehouseId(itemQuery.getWarehouseId());
wmsInventoryHistory.setAreaId(itemQuery.getAreaId());
wmsInventoryHistory.setRackId(itemQuery.getRackId());
wmsInventoryHistory.setQuantity(itemQuery.getQuantity());
if (itemQuery.getFormType()!= null && itemQuery.getFormType().length > 1) {
wmsInventoryHistory.setFormType(Integer.valueOf(itemQuery.getFormType()[1]));
}
Page<WmsInventoryHistoryVO> wmsInventoryHistoryVOS = service.selectList(wmsInventoryHistory, page);
//当使用条件进行查询物料名称编号
WmsItem qw = new WmsItem();
if (itemQuery.getItemName()!=null&&!"".equals(itemQuery.getItemName())||itemQuery.getItemNo()!=null&&!"".equals(itemQuery.getItemNo())) {
qw.setItemName(itemQuery.getItemName());
qw.setItemNo(itemQuery.getItemNo());
qw.setDelFlag(0);
List<WmsItem> wmsItems = itemMapper.selectByEntity(qw);
if (wmsItems.size() > 0) {
//当wmsInventoryHistory.getItemId = wmsItems.getObjId();相同时放入Page<WmsInventoryHistoryVO> wmsInventoryHistoryVOS中过滤wmsInventoryHistoryVOS
List<WmsInventoryHistoryVO> filteredVOS = wmsInventoryHistoryVOS.getContent().stream()
.filter(vo -> {
// 遍历wmsItems列表,检查是否有匹配的getObjId
return wmsItems.stream().anyMatch(item -> item.getObjId().equals(vo.getItemId()));
})
.collect(Collectors.toList());
Page<WmsInventoryHistoryVO> filteredPage = new PageImpl<>(filteredVOS, wmsInventoryHistoryVOS.getPageable(), filteredVOS.size());
ok = ResponseEntity.ok(filteredPage);
}
}else {
ok = ResponseEntity.ok(wmsInventoryHistoryVOS);
}
return ok;
标签:ok,qw,wmsInventoryHistory,wmsInventoryHistoryVOS,wmsItems,过滤,集合,id,itemQuery
From: https://www.cnblogs.com/188221creat/p/18388617