这种根据upc、会员的不同,增加数据。要怎么判断才可以添加红框内的数据啊???
//保存到库存(delStorageInventory)
Member member = this.memberService.findBySn(sn);
List<DelStorageInventory> delStorageInventoryMembers = delStorageInventoryService.findByMember(member);
List<DelStorageInventory> delStorageInventorys = delStorageInventoryService.findByUPC(delStorageInventory.getUpc());
//当upc查找到的库存为0,或者member查找到的库存为0时,执行添加操作
if (delStorageInventoryMembers.size() == 0 || delStorageInventorys.size() == 0 || (member != null && member.getDelStorageInventorys() != null && member.getDelStorageInventorys().size() > 0)) {
delStorageInventory.setMember(this.memberService.findBySn(sn));
delStorageInventory.setOperator(this.adminService.getCurrent());
delStorageInventory.setDelStorage(this.delStorageService.find(delStorageId));
delStorageInventory.setSn(this.snService.generate(Sn.Type.delStorageInventory));
/** 数据验证 */
if(!isValid(delStorageInventory, new Class[0])) {
return ERROR_VIEW;
}
this.delStorageInventoryService.save(delStorageInventory);
}
javaWeb
------解决方案--------------------
upc、会员 作为key 去数据库检索,没有的话就新增一条数据。