|
@@ -1319,20 +1319,30 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
|
public Result<StorageBill> queryPageListNoToken(@RequestParam(name="ccmNo") String ccmNo,
|
|
|
@RequestParam(name="positionNum") String positionNum) {
|
|
|
|
|
|
+ // 避免 NullPointerException,使用 Collections.emptyList()
|
|
|
+ List<BilletAutoTmp> billetAutoTmpList = Collections.emptyList();
|
|
|
+
|
|
|
+ // 查询最新的 StorageBill
|
|
|
LambdaQueryWrapper<StorageBill> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
- .eq(StorageBill::getPositionNum,positionNum)
|
|
|
- .orderByDesc(StorageBill::getCreateTime).last("LIMIT 1");
|
|
|
+ .eq(StorageBill::getPositionNum, positionNum)
|
|
|
+ .orderByDesc(StorageBill::getCreateTime)
|
|
|
+ .last("LIMIT 1");
|
|
|
|
|
|
StorageBill latestStorageBill = storageBillService.getOne(queryWrapper);
|
|
|
- LambdaQueryWrapper<BilletAutoTmp> tmpQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- tmpQueryWrapper.eq(BilletAutoTmp::getStorageBillId, latestStorageBill.getId());
|
|
|
- List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(tmpQueryWrapper);
|
|
|
|
|
|
- if(CollectionUtils.isNotEmpty(billetAutoTmpList)){
|
|
|
-
|
|
|
- latestStorageBill.setAmountTotal(latestStorageBill.getAmountTotal() + billetAutoTmpList.size());
|
|
|
+ // 判空,避免 NullPointerException
|
|
|
+ if (latestStorageBill != null) {
|
|
|
+ LambdaQueryWrapper<BilletAutoTmp> tmpQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ tmpQueryWrapper.eq(BilletAutoTmp::getStorageBillId, latestStorageBill.getId());
|
|
|
+ billetAutoTmpList = billetAutoTmpService.list(tmpQueryWrapper);
|
|
|
|
|
|
+ // 计算 amountTotal,防止 null 计算异常
|
|
|
+ int amountTotal = latestStorageBill.getAmountTotal() != null ? latestStorageBill.getAmountTotal() : 0;
|
|
|
+ latestStorageBill.setAmountTotal(amountTotal + billetAutoTmpList.size());
|
|
|
+ } else {
|
|
|
+ // 如果没有找到 StorageBill,直接返回空对象,避免 Result.OK(null)
|
|
|
+ return Result.OK(new StorageBill());
|
|
|
}
|
|
|
|
|
|
return Result.OK(latestStorageBill);
|