现在遇到了一个业务问题,假设存在一个仓库和位置的主子表关系
例如:仓库1 --- 01 02 03 仓库2 --- 01 02 03
判断前端传入的值是否符合规则(仓库和位置的值匹配,仓库值不为空,库位可以为空)
目前我用的是list.contain()方法做的判断,代码如下
//inboundItems 是数据集合
public boolean checkItem(List<InboundItem> inboundItems) {
int count = 0;
if (CollUtil.isNotEmpty(inboundItems)) {
//通过sql获取仓库和位置匹配的list
List<CabinAndStorePlaceVO> result = inboundReceiptService.getCabinAndStorePlace();
for (InboundItem inboundItem : inboundItems) {
if (StringUtils.isNotBlank(inboundItem.getStorePlaceId())) {
if (result.contains(new CabinAndStorePlaceVO().setCabinId(inboundItem.getStoreId()).setStorePlaceId(inboundItem.getStorePlaceId()))) {
count++;
}
}
}
} else {
return true;
}
if (count > 0) {
return true;
} else {
return false;
}
}
还有什么更加简单方便的办法吗?