|
|
@@ -551,51 +551,73 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
* @return 搜索结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public SPage<Vendor> getCustomerInfo(PageParams params, String keyword, String checkDate, Long fromDate, Long endDate) {
|
|
|
+ public SPage<Vendor> getCustomerInfo(PageParams params, String keyword, String checkDate, Long fromDate, Long endDate) throws InterruptedException {
|
|
|
List<Vendor> vendors = findCustomerByPage(params, keyword);
|
|
|
- final Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
SPage<Vendor> vendorSPage = new SPage<>();
|
|
|
if (!CollectionUtils.isEmpty(vendors)) {
|
|
|
- vendors.stream().filter(customer -> null != customer.getApcheck() && customer.getApcheck() == 1)
|
|
|
- .forEach(customer -> {
|
|
|
- Long customerUU = customer.getMyEnUU();
|
|
|
- if (!StringUtils.isEmpty(customer.getTotalCountString())) {
|
|
|
- List<ApCheckAmount> tradeCounts = JSON.parseArray(customer.getTotalCountString(), ApCheckAmount.class);
|
|
|
- customer.setTotalCount(tradeCounts);
|
|
|
- }
|
|
|
- // 本月应收(总额)
|
|
|
- List<ApCheckAmount> thisMonthTrades = null;
|
|
|
- try {
|
|
|
- thisMonthTrades = getThisMonthTrade(enUU, customerUU, checkDate, fromDate, endDate);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- customer.setThisMonthCount(thisMonthTrades);
|
|
|
- // 总额存在再进行其他查询
|
|
|
- if (!CollectionUtils.isEmpty(thisMonthTrades)) {
|
|
|
- // 本月应收(未收)
|
|
|
- List<ApCheckAmount> thisMonthTodoTrades = null;
|
|
|
- try {
|
|
|
- thisMonthTodoTrades = getThisMonthTodoTrade(enUU, customerUU, checkDate, fromDate, endDate);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- customer.setThisMonthTodoCount(thisMonthTodoTrades);
|
|
|
- // 本月应收(已收)
|
|
|
- List<ApCheckAmount> thisMonthDoneTrades = null;
|
|
|
- try {
|
|
|
- thisMonthDoneTrades = getThisMonthDoneTrade(enUU, customerUU, checkDate, fromDate, endDate);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- customer.setThisMonthDoneCount(thisMonthDoneTrades);
|
|
|
- }
|
|
|
- });
|
|
|
+ List<Vendor> filterVendors = vendors.stream().filter(customer -> null != customer.getApcheck() && customer.getApcheck() == 1).collect(Collectors.toList());
|
|
|
+ final CountDownLatch threadsSignal = new CountDownLatch(1);
|
|
|
+ filterVendors.forEach(customer -> {
|
|
|
+ try {
|
|
|
+ executor.submitTask(() -> {
|
|
|
+ this.countApCheck(customer, checkDate, fromDate, endDate);
|
|
|
+ threadsSignal.countDown();
|
|
|
+ });
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ threadsSignal.await();
|
|
|
setVendorSPage(params, vendors, vendorSPage);
|
|
|
}
|
|
|
return vendorSPage;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 统计对账数据
|
|
|
+ *
|
|
|
+ * @param customer 客户信息
|
|
|
+ * @param checkDate 对账月份
|
|
|
+ * @param fromDate 起始时间
|
|
|
+ * @param endDate 截止时间
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void countApCheck(Vendor customer, String checkDate, Long fromDate, Long endDate) {
|
|
|
+ final Long customerUU = customer.getMyEnUU();
|
|
|
+ final Long vendorUU = customer.getVendEnUU();
|
|
|
+ if (!StringUtils.isEmpty(customer.getTotalCountString())) {
|
|
|
+ List<ApCheckAmount> tradeCounts = JSON.parseArray(customer.getTotalCountString(), ApCheckAmount.class);
|
|
|
+ customer.setTotalCount(tradeCounts);
|
|
|
+ // 本月应收(总额)
|
|
|
+ List<ApCheckAmount> thisMonthTrades = null;
|
|
|
+ try {
|
|
|
+ thisMonthTrades = getThisMonthTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ customer.setThisMonthCount(thisMonthTrades);
|
|
|
+ // 总额存在再进行其他查询
|
|
|
+ if (!CollectionUtils.isEmpty(thisMonthTrades)) {
|
|
|
+ // 本月应收(未收)
|
|
|
+ List<ApCheckAmount> thisMonthTodoTrades = null;
|
|
|
+ try {
|
|
|
+ thisMonthTodoTrades = getThisMonthTodoTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ customer.setThisMonthTodoCount(thisMonthTodoTrades);
|
|
|
+ // 本月应收(已收)
|
|
|
+ List<ApCheckAmount> thisMonthDoneTrades = null;
|
|
|
+ try {
|
|
|
+ thisMonthDoneTrades = getThisMonthDoneTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ customer.setThisMonthDoneCount(thisMonthDoneTrades);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设置供应商信息
|
|
|
* @param params 分页参数
|
|
|
@@ -604,18 +626,27 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void setVendorSPage(PageParams params, List<Vendor> vendors, SPage<Vendor> vendorSPage) {
|
|
|
- List<Vendor> filterVendors = vendors.stream()
|
|
|
- .filter(vendor -> (null != vendor.getThisMonthCount() && !CollectionUtils.isEmpty(vendor.getThisMonthCount()))).collect(Collectors.toList());
|
|
|
- int startIndex = (params.getPage() - 1) * params.getCount();
|
|
|
- int endIndex = params.getPage() * params.getCount();
|
|
|
- int totalCount = filterVendors.size();
|
|
|
- int totalPage = (int) Math.ceil(totalCount / params.getCount());
|
|
|
- vendorSPage.setTotalElement(filterVendors.size());
|
|
|
- vendorSPage.setTotalPage(totalPage);
|
|
|
- vendorSPage.setPage(params.getPage());
|
|
|
- vendorSPage.setSize(params.getCount());
|
|
|
- List<Vendor> vendorList = filterVendors.subList(startIndex, endIndex > totalCount ? totalCount : endIndex);
|
|
|
- vendorSPage.setContent(vendorList);
|
|
|
+ if (!CollectionUtils.isEmpty(vendors)) {
|
|
|
+ List<Vendor> filterVendors = vendors.stream()
|
|
|
+ .filter(vendor -> (null != vendor.getThisMonthCount() && !CollectionUtils.isEmpty(vendor.getThisMonthCount()))).collect(Collectors.toList());
|
|
|
+ // 起始序号
|
|
|
+ int startIndex = (params.getPage() - 1) * params.getCount();
|
|
|
+ // 截止序号
|
|
|
+ int endIndex = params.getPage() * params.getCount();
|
|
|
+ // 筛选后的总数
|
|
|
+ int totalCount = filterVendors.size();
|
|
|
+ // 筛选后的总页码
|
|
|
+ int totalPage = (int) Math.ceil(totalCount / params.getCount());
|
|
|
+ // 默认起始序号
|
|
|
+ int defaultIndex = totalPage * params.getCount();
|
|
|
+ vendorSPage.setTotalElement(filterVendors.size());
|
|
|
+ vendorSPage.setTotalPage(totalPage);
|
|
|
+ vendorSPage.setPage(params.getPage() > totalPage ? totalPage : params.getPage());
|
|
|
+ vendorSPage.setSize(params.getCount());
|
|
|
+ // 如果前端传入页码值过大,返回能取到的最大值页面及获取相关数据
|
|
|
+ List<Vendor> vendorList = filterVendors.subList(startIndex > totalCount ? defaultIndex : startIndex, endIndex > totalCount ? totalCount : endIndex);
|
|
|
+ vendorSPage.setContent(vendorList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|