public Page<WmsInventoryVO> queryPage(WmsInventoryQuery query, Pageable page) {
List<WmsInventory> list = selectList(query, page);
List<WmsInventoryVO> res = inventoryConvert.dos2vos(list);
injectAreaAndItemInfo(res);
return new PageImpl<>(res, page, ((com.github.pagehelper.Page) list).getTotal());
}
public void injectAreaAndItemInfo(List<? extends WmsAreaAndItemInfo> res) {
if (CollUtil.isEmpty(res)) {
return;
}
Set<String> itemIds = new HashSet<>();
res.forEach(it -> {
if (it.getItemId() != null) {
itemIds.add(it.getItemId());
}
});
Map<String, WmsItem> items = itemService.selectByIdIn(itemIds)
.stream().collect(Collectors.toMap(WmsItem::getObjId, it -> it));
res.forEach(it -> {
if (it.getItemId() != null && items.containsKey(it.getItemId())) {
WmsItem item = items.get(it.getItemId());
it.setItemName(item.getItemName());
it.setItemNo(item.getItemNo());
it.setItemDelFlag(item.getDelFlag());
}
});
}
public List<WmsItem> selectByIdIn(Collection<String> ids) {
// 如果主键集合为空,直接返回空集合
if (ids == null || ids.isEmpty()) {
return new ArrayList<>();
}
QueryWrapper<WmsItem> qw = new QueryWrapper<>();
qw.in("obj_id", ids);
return itemMapper.selectList(qw);
}
标签:对表,getItemId,return,res,List,item,plus,mybatis,new
From: https://www.cnblogs.com/188221creat/p/18317805