Browse Source

feat(apCheck): 供应商客户列表数据查询增加空值判断

hejq 7 years ago
parent
commit
fdf48de90d

+ 24 - 16
src/main/java/com/uas/platform/b2b/service/impl/PurchaseApCheckServiceImpl.java

@@ -664,24 +664,32 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
             .collect(Collectors.toSet());
         List<ApCheckAmountDetail> detailList = new ArrayList<>();
         currencySet.forEach(currency -> {
-            List<String> totalAmount = customer.getTotalCount().stream()
-                .filter(count -> currency.equals(count.getCurrency()))
-                .map(ApCheckAmount::getAmount).collect(Collectors.toList());
-            List<String> thisPeriodAmount = customer.getThisMonthCount().stream()
-                .filter(count -> currency.equals(count.getCurrency()))
-                .map(ApCheckAmount::getAmount).collect(Collectors.toList());
-            List<String> thisPeriodTodoAmount = customer.getThisMonthTodoCount().stream()
-                .filter(count -> currency.equals(count.getCurrency()))
-                .map(ApCheckAmount::getAmount).collect(Collectors.toList());
-            List<String> thisPeriodDoneAmount = customer.getThisMonthDoneCount().stream()
-                .filter(count -> currency.equals(count.getCurrency()))
-                .map(ApCheckAmount::getAmount).collect(Collectors.toList());
             ApCheckAmountDetail detail = new ApCheckAmountDetail();
             detail.setCurrency(currency);
-            detail.setThisPeriodAmount(thisPeriodAmount.size() > 0 ? thisPeriodAmount.get(0) : null);
-            detail.setTotalAmount(totalAmount.size() > 0 ? totalAmount.get(0) : null);
-            detail.setThisPeriodTodoAmount(thisPeriodTodoAmount.size() > 0 ? thisPeriodTodoAmount.get(0) : null);
-            detail.setThisPeriodDoneAmount(thisPeriodDoneAmount.size() > 0 ? thisPeriodDoneAmount.get(0) : null);
+            if (!StringUtils.isEmpty(customer.getTotalCount())) {
+                List<String> totalAmount = customer.getTotalCount().stream()
+                    .filter(count -> currency.equals(count.getCurrency()))
+                    .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                detail.setTotalAmount(totalAmount.size() > 0 ? totalAmount.get(0) : null);
+            }
+            if (!StringUtils.isEmpty(customer.getThisMonthCount())) {
+                List<String> thisPeriodAmount = customer.getThisMonthCount().stream()
+                    .filter(count -> currency.equals(count.getCurrency()))
+                    .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                detail.setThisPeriodAmount(thisPeriodAmount.size() > 0 ? thisPeriodAmount.get(0) : null);
+            }
+            if (!StringUtils.isEmpty(customer.getThisMonthTodoCount())) {
+                List<String> thisPeriodTodoAmount = customer.getThisMonthTodoCount().stream()
+                    .filter(count -> currency.equals(count.getCurrency()))
+                    .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                detail.setThisPeriodTodoAmount(thisPeriodTodoAmount.size() > 0 ? thisPeriodTodoAmount.get(0) : null);
+            }
+            if (!StringUtils.isEmpty(customer.getThisMonthDoneCount())) {
+                List<String> thisPeriodDoneAmount = customer.getThisMonthDoneCount().stream()
+                    .filter(count -> currency.equals(count.getCurrency()))
+                    .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                detail.setThisPeriodDoneAmount(thisPeriodDoneAmount.size() > 0 ? thisPeriodDoneAmount.get(0) : null);
+            }
             detailList.add(detail);
         });
         customer.setAmountDetailList(detailList);