From 3b5a6a6232847a7dfac0fe109efb81872d24845f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=9B=A8=E7=94=9F?= Date: Mon, 25 May 2020 15:11:54 +0800 Subject: [PATCH] p --- .../gszc/service/impl/InvoiceServiceImpl.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java b/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java index 51b12b7..de9c5a1 100644 --- a/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java +++ b/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java @@ -159,20 +159,22 @@ public class InvoiceServiceImpl extends ServiceImpl impl public JSONObject pcDisableInvoiceList(Integer pageNum, Integer pageSize, String copycatId) { - Integer count = null; - List invoiceList; + Integer count = 0; + List invoiceList = new ArrayList<>(); if (null == copycatId) { count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "disable")); invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "disable").orderBy("create_date", false)); } else { List customList = customMapper.selectList(new EntityWrapper().eq("copycat_id", copycatId)); - count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "disable").in("custom_id", customList.stream().map(item -> - item.getId() - ).collect(Collectors.toList()))); - invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "disable").in("custom_id", customList.stream().map(item -> - item.getId() - ).collect(Collectors.toList())).orderBy("create_date", false)); + if (customList.size() != 0) { + count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "disable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList()))); + invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "disable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList())).orderBy("create_date", false)); + } } for (Invoice invoice : invoiceList) { @@ -182,7 +184,7 @@ public class InvoiceServiceImpl extends ServiceImpl impl InvoiceHeader invoiceHeader = invoiceHeaderMapper.selectById(invoiceHeaderId); invoice.setCustomName(custom.getCompanyName()); invoice.setInvoiceHeaderName(invoiceHeader.getCompanyName()); - if(null!=custom.getCopycatId()){ + if (null != custom.getCopycatId()) { PcUser pcUser = pcUserMapper.selectById(custom.getCopycatId()); invoice.setCopycatName(pcUser.getName()); } @@ -194,20 +196,22 @@ public class InvoiceServiceImpl extends ServiceImpl impl } public JSONObject pcEnableInvoiceList(Integer pageNum, Integer pageSize, String copycatId) { - Integer count = null; - List invoiceList; + Integer count = 0; + List invoiceList = new ArrayList<>(); if (null == copycatId) { count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "enable")); invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "enable").orderBy("create_date", false)); } else { List customList = customMapper.selectList(new EntityWrapper().eq("copycat_id", copycatId)); - count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "enable").in("custom_id", customList.stream().map(item -> - item.getId() - ).collect(Collectors.toList()))); - invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "enable").in("custom_id", customList.stream().map(item -> - item.getId() - ).collect(Collectors.toList())).orderBy("create_date", false)); + if (customList.size() != 0) { + count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "enable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList()))); + invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "enable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList())).orderBy("create_date", false)); + } } for (Invoice invoice : invoiceList) { String invoiceHeaderId = invoice.getInvoiceHeaderId(); @@ -216,7 +220,7 @@ public class InvoiceServiceImpl extends ServiceImpl impl InvoiceHeader invoiceHeader = invoiceHeaderMapper.selectById(invoiceHeaderId); invoice.setCustomName(custom.getCompanyName()); invoice.setInvoiceHeaderName(invoiceHeader.getCompanyName()); - if(null!=custom.getCopycatId()){ + if (null != custom.getCopycatId()) { PcUser pcUser = pcUserMapper.selectById(custom.getCopycatId()); invoice.setCopycatName(pcUser.getName()); }