Browse Source

feat: 对账单未对账页面增加返回数据:应收对账金额(分币别),本月应收对账金额(分币别)

hejq 7 years ago
parent
commit
8dfc753901

+ 19 - 11
src/main/java/com/uas/platform/b2b/controller/SaleApCheckController.java

@@ -206,12 +206,13 @@ public class SaleApCheckController {
      * 获取客户
      * @param keyword 关键字
      * @param params 分页参数
+     * @param checkDate 筛选月份
      * @return 符合条件的客户信息
      */
     @RequestMapping(value = "/customer", method = RequestMethod.GET)
-    public SPage<Vendor> getCustomers(PageParams params, String keyword) {
+    public SPage<Vendor> getCustomers(PageParams params, String keyword, String checkDate) {
         logger.log("应收对账单", "获取客户信息", "获取所有符合条件的客户");
-        return purchaseApCheckService.getCustomerInfo(params, keyword);
+        return purchaseApCheckService.getCustomerInfo(params, keyword, checkDate);
     }
 
 	/**
@@ -364,12 +365,11 @@ public class SaleApCheckController {
 	 */
 	@RequestMapping(value = "/info/search", params = RequestState.DONE, method = RequestMethod.GET)
 	public SPage<PurchaseApCheck> getDoneApChecks(PageParams params, String searchFilter) {
-		logger.log("应收对账单", "获取已确认应收对账单");
+		logger.log("应收对账单", "获取已对账应收对账单");
         SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
         if (StringUtils.isEmpty(filter.getKeyword())) {
             PageInfo pageInfo = new PageInfo(params);
             pageInfo.filter("enUu", SystemSession.getUser().getEnterprise().getUu());
-            pageInfo.filter("checkStatus", "已确认");
             SearchFilter distribute = userService.distribute();
             if (distribute != null && distribute.getDistribute() == null) {
                 return null;
@@ -377,10 +377,18 @@ public class SaleApCheckController {
             if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
                 filter.setDistribute(distribute.getDistribute());
             }
+            SimpleExpression agreed = new SimpleExpression("checkStatus", "已确认", CriterionExpression.Operator.EQ, true);
+            SimpleExpression haveDone = new SimpleExpression("checkStatus", "未对账", CriterionExpression.Operator.EQ, true);
+            SimpleExpression[] expressions = new SimpleExpression[]{agreed, haveDone};
+            LogicalExpression logical = new LogicalExpression(expressions, CriterionExpression.Operator.OR);
+            pageInfo.orExpression(logical);
             return SPageUtils.covertSPage(purchaseApCheckService.findAllByPageInfo(pageInfo, null, filter));
         }
 		com.uas.search.b2b.model.PageParams pageParams = distribute(params, searchFilter);
-		pageParams.getFilters().put("pa_checkstatus", "已确认");
+        List<Object> objectList = new ArrayList<>();
+        objectList.add("已确认");
+        objectList.add("未对账");
+		pageParams.getFilters().put("pa_checkstatus", new MultiValue(objectList, true));
 		return searchService.searchPurchaseApCheckIds(filter.getKeyword(), pageParams);
 	}
 
@@ -487,10 +495,10 @@ public class SaleApCheckController {
 		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
 		ModelAndView modelAndView = new ModelAndView();
 		modelAndView.addObject("dateFormat", dateFormat);
-		modelAndView.addObject("state", "已确认");
+		modelAndView.addObject("state", "已对账");
 		modelAndView.addObject("data", getDoneApChecks(params, searchFilter).getContent());
-		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_已确认"));
-		logger.log("应收对账单", "导出Excel列表", "导出已确认Excel列表");
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_已对账"));
+		logger.log("应收对账单", "导出Excel列表", "导出已对账Excel列表");
 		return modelAndView;
 	}
 
@@ -507,9 +515,9 @@ public class SaleApCheckController {
 		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
 		ModelAndView modelAndView = new ModelAndView();
 		modelAndView.addObject("dateFormat", dateFormat);
-		modelAndView.addObject("state", "待确认");
-		modelAndView.addObject("data", getTodoApChecks(params, searchFilter).getContent());
-		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_待确认"));
+		modelAndView.addObject("state", "未对账");
+		modelAndView.addObject("data", getDoneApChecks(params, searchFilter).getContent());
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_未对账"));
 		logger.log("应收对账单", "导出Excel列表", "导出未对账Excel列表");
 		return modelAndView;
 	}

+ 30 - 0
src/main/java/com/uas/platform/b2b/model/Vendor.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2b.model;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import com.uas.platform.b2b.erp.model.InquiryVendorInfo;
+import com.uas.platform.b2b.publicapi.model.TradeCount;
 import com.uas.platform.core.persistence.Logger;
 import com.uas.platform.core.persistence.OtherUserUU;
 import com.uas.platform.core.persistence.StatusColumn;
@@ -25,6 +26,7 @@ import javax.persistence.Transient;
 import java.io.*;
 import java.util.Date;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -194,6 +196,18 @@ public class Vendor implements Serializable {
 	@Transient
     private Set<String> saleContacts = new HashSet<>();
 
+    /**
+     * 本月应收(前端传入指定月份)
+     */
+	@Transient
+    private List<TradeCount> thisMonthCount;
+
+    /**
+     * 应收总额
+     */
+	@Transient
+    private List<TradeCount> totalCount;
+
 	public Long getId() {
 		return id;
 	}
@@ -391,6 +405,22 @@ public class Vendor implements Serializable {
         this.saleContacts = saleContacts;
     }
 
+    public List<TradeCount> getThisMonthCount() {
+        return thisMonthCount;
+    }
+
+    public void setThisMonthCount(List<TradeCount> thisMonthCount) {
+        this.thisMonthCount = thisMonthCount;
+    }
+
+    public List<TradeCount> getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(List<TradeCount> totalCount) {
+        this.totalCount = totalCount;
+    }
+
     public InquiryVendorInfo covert() {
 		InquiryVendorInfo info = new InquiryVendorInfo();
 		info.setB2b_id(this.id);

+ 50 - 34
src/main/java/com/uas/platform/b2b/model/util/UnCheckedCountSqls.java

@@ -1,6 +1,5 @@
 package com.uas.platform.b2b.model.util;
 
-import com.uas.platform.b2b.publicapi.model.UsoftRate;
 
 /**
  * 未对账总额sql查询语句
@@ -10,63 +9,80 @@ import com.uas.platform.b2b.publicapi.model.UsoftRate;
  */
 public class UnCheckedCountSqls {
 
-
     /**
      * 货款调账未对账金额查询语句
      */
-    public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) " +
-        "from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ? and aa_custuu = ?";
+    public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as amount, aa_currency as currency \n" +
+        "from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ? and aa_custuu = ? " +
+        "group by aa_currency";
+
+    /**
+     * 当月货款调账未对账金额查询语句
+     */
+    public static final String THISMONTH_ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as amount, aa_currency as currency \n" +
+        "from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ? and aa_custuu = ? and aa_date between ? and ?" +
+        "group by aa_currency";
 
     /**
      * 客户采购验收单未对账金额查询语句
      */
-    public static final String SALE_ACCEPT_COUNT_SQL = "select coalesce(sum(case " +
-        " when currency = 'USD' then count * " + UsoftRate.USD_RATE +
-        " when currency = 'HKD' then count * " + UsoftRate.HKD_RATE +
-        " else count end), 0) " +
-        "from (" +
-        "select sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice) as count, pa_currency as currency " +
+    public static final String SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as amount, pa_currency as currency \n" +
         "from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
-        "where pai_qty > coalesce(pai_ycheckqty, 0) and pa_enuu = ? and  pa_venduu = ? and pai_orderprice <> 0 " +
-        "group by pa_currency) a";
+        "where pa_venduu = ? and pa_enuu = ? and pai_qty > coalesce(pai_ycheckqty, 0) and pai_orderprice <> 0 " +
+        "group by pa_currency";
+
+    /**
+     * 客户采购验收单未对账金额查询语句
+     */
+    public static final String THISMONTH_SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as amount, pa_currency as currency \n" +
+        "from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
+        "where pa_venduu = ? and pa_enuu = ? and pai_qty > coalesce(pai_ycheckqty, 0) and pai_orderprice <> 0 and pa_date between ? and ?" +
+        "group by pa_currency";
 
     /**
      * 客户采购验退单未对账金额查询语句
      */
-    public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum(case " +
-        " when currency = 'USD' then count * " + UsoftRate.USD_RATE +
-        " when currency = 'HKD' then count * " + UsoftRate.HKD_RATE +
-        " else count end), 0) " +
-        "from (" +
-        "select sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice) as count, pr_currency as currency " +
+    public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice), 0) as amount, pr_currency as currency \n" +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
-        "where pri_qty > abs(coalesce(pri_ycheckqty, 0)) and pr_venduu = ? and pr_enuu = ? group by pr_currency) a";
+        "where pri_qty > abs(coalesce(pri_ycheckqty, 0)) and pr_venduu = ? and pr_enuu = ? group by pr_currency";
 
-    //todo 不良品出入库价格为0,暂不用计算
+    /**
+     * 客户采购验退单未对账金额查询语句
+     */
+    public static final String THISMONTH_SALE_RETURN_COUNT_SQL = "select sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice) as amount, pr_currency as currency \n" +
+        "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
+        "where pri_qty > abs(coalesce(pri_ycheckqty, 0)) and pr_venduu = ? and pr_enuu = ? and pr_date between ? and ? group by pr_currency";
 
     /**
      * 客户委外验收单未对账金额查询语句
      */
-    public static final String MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum(case " +
-        " when currency = 'USD' then count * " + UsoftRate.USD_RATE +
-        " when currency = 'HKD' then count * " + UsoftRate.HKD_RATE +
-        " else count end), 0) " +
-        "from (" +
-        "select sum((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice) as count,ma_currency as currency " +
+    public static final String MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice), 0) as amount, ma_currency as currency " +
         " from make$accept " +
         "join make$acceptitem on ma_id = mai_paid " +
-        "where mai_qty > coalesce(mai_ycheckqty, 0) and ma_venduu = ? and ma_enuu = ? and mai_orderpice > 0 group by ma_currency) a";
+        "where mai_qty > coalesce(mai_ycheckqty, 0) and ma_venduu = ? and ma_enuu = ? and mai_orderpice > 0 group by ma_currency";
+
+    /**
+     * 客户委外验收单未对账金额查询语句
+     */
+    public static final String THISMONTH_MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice), 0) as amount,ma_currency as currency " +
+        " from make$accept " +
+        "join make$acceptitem on ma_id = mai_paid " +
+        "where mai_qty > coalesce(mai_ycheckqty, 0) and ma_venduu = ? and ma_enuu = ? and mai_orderpice > 0 and ma_date between ? and ? group by ma_currency";
+
+    /**
+     * 客户委外验退单未对账金额查询语句
+     */
+    public static final String MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice), 0) as amount,mr_currency as currency " +
+        " from make$return " +
+        "join make$returnitem on mr_id =  mri_paid " +
+        "where mri_qty > abs(coalesce(mri_ycheckqty, 0)) and mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 group by mr_currency";
 
     /**
      * 客户委外验退单未对账金额查询语句
      */
-    public static final String MAKE_RETURN_COUNT_SQL = "select coalesce(sum(case " +
-        " when currency = 'USD' then count * " + UsoftRate.USD_RATE +
-        " when currency = 'HKD' then count * " + UsoftRate.HKD_RATE +
-        " else count end), 0) " +
-        "from (" +
-        "select sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice) as count,mr_currency as currency " +
+    public static final String THISMONTH_MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice), 0) as amount, mr_currency as currency " +
         " from make$return " +
         "join make$returnitem on mr_id =  mri_paid " +
-        "where mri_qty > abs(coalesce(mri_ycheckqty, 0)) and mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 group by mr_currency) a";
+        "where mri_qty > abs(coalesce(mri_ycheckqty, 0)) and mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mr_date between ? and ? " +
+        "group by mr_currency";
 }

+ 15 - 0
src/main/java/com/uas/platform/b2b/publicapi/model/TradeCount.java

@@ -106,4 +106,19 @@ public class TradeCount implements Serializable {
     public void setEndDate(String endDate) {
         this.endDate = endDate;
     }
+
+    public TradeCount() {
+
+    }
+
+    /**
+     * 通过币别,总额获取交易额
+     *
+     * @param currency 币别
+     * @param amount 总额
+     */
+    public TradeCount(String currency, Double amount) {
+        this.currency = currency;
+        this.amount = new BigDecimal(amount);
+    }
 }

+ 2 - 1
src/main/java/com/uas/platform/b2b/service/PurchaseApCheckService.java

@@ -136,7 +136,8 @@ public interface PurchaseApCheckService {
      *
      * @param params 分页参数
      * @param keyword 关键字
+     * @param checkDate 筛选日期
      * @return 搜索结果
      */
-    SPage<Vendor> getCustomerInfo(PageParams params, String keyword);
+    SPage<Vendor> getCustomerInfo(PageParams params, String keyword, String checkDate);
 }

+ 137 - 26
src/main/java/com/uas/platform/b2b/service/impl/PurchaseApCheckServiceImpl.java

@@ -1,6 +1,8 @@
 package com.uas.platform.b2b.service.impl;
 
 import com.uas.platform.b2b.core.util.ContextUtils;
+import com.uas.platform.b2b.core.util.DateFormatUtils;
+import com.uas.platform.b2b.core.util.DateUtils;
 import com.uas.platform.b2b.core.util.ThreadUtils;
 import com.uas.platform.b2b.dao.CommonDao;
 import com.uas.platform.b2b.dao.EnterpriseDao;
@@ -20,6 +22,7 @@ import com.uas.platform.b2b.model.SearchFilter;
 import com.uas.platform.b2b.model.SourceForApcheck;
 import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.model.util.UnCheckedCountSqls;
+import com.uas.platform.b2b.publicapi.model.TradeCount;
 import com.uas.platform.b2b.search.SearchService;
 import com.uas.platform.b2b.service.OrderRedDotService;
 import com.uas.platform.b2b.service.PurchaseApCheckService;
@@ -48,6 +51,7 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import java.sql.SQLException;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -85,15 +89,27 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
 	@Autowired
     private EnterpriseDao enterpriseDao;
 
-	@Autowired
-    private VendorService vendorService;
-
 	@Autowired
     private SearchService searchService;
 
 	@Autowired
     private UserService userService;
 
+    /**
+     * RMB
+     */
+    private final String RMB = "RMB";
+
+    /**
+     * 港币
+     */
+    private final String HKD = "HKD";
+
+    /**
+     * 美元
+     */
+    private final String USD = "USD";
+
 	@Override
 	public List<PurchaseApCheck> findNotUploadAPcheck() {
 		return purchaseApCheckDao.findByCustUuAndStatusAndCheckStatus(SystemSession.getUser().getEnterprise().getUu(),
@@ -492,39 +508,134 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
      * @return 搜索结果
      */
     @Override
-    public SPage<Vendor> getCustomerInfo(PageParams params, String keyword) {
+    public SPage<Vendor> getCustomerInfo(PageParams params, String keyword, String checkDate) {
         SPage<Vendor> vendorSPage = searchCustomerInfo(params, keyword);
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
         vendorSPage.getContent().stream().filter(customer -> null != customer.getApcheck() && customer.getApcheck() == 1)
             .forEach(customer -> {
                 Long customerUU = customer.getMyEnUU();
-                PurchaseApCheck apCheck = purchaseApCheckDao.findByCustomerUUAndEnUU(customerUU, enUU);
-                if (null != apCheck) {
-                    customer.setLastCheckDate(apCheck.getRecordDate());
+                // 应收总额
+                List<TradeCount> totalTrades = getDueTrade(enUU, customerUU);
+                customer.setTotalCount(totalTrades);
+                // 本月应收
+                if (null != checkDate) {
+                    List<TradeCount> thisMonthTrades = getThisMonthTrade(enUU, customerUU, checkDate);
+                    customer.setThisMonthCount(thisMonthTrades);
                 }
-                final Double[] adjustmentCount = {0D};
-                final Double[] saleAcceptCount = {0D};
-                final Double[] saleReturnCount = {0D};
-                final Double[] makeAcceptCount = {0D};
-                final Double[] makeReturnCount = {0D};
-                ThreadUtils
-                    // 货款调账
-                    .task(() -> adjustmentCount[0] = commonDao.queryForObject(UnCheckedCountSqls.ADJUSTMENT_COUNT_SQL, Double.class, enUU, customerUU))
-                    // 采购验收
-                    .task(() -> saleAcceptCount[0] = commonDao.queryForObject(UnCheckedCountSqls.SALE_ACCEPT_COUNT_SQL, Double.class, enUU, customerUU))
-                    // 采购验退
-                    .task(() -> saleReturnCount[0] = commonDao.queryForObject(UnCheckedCountSqls.SALE_RETURN_COUNT_SQL, Double.class, enUU, customerUU))
-                    // 委外验收
-                    .task(() -> makeAcceptCount[0] = commonDao.queryForObject(UnCheckedCountSqls.MAKE_ACCEPT_COUNT_SQL, Double.class, enUU, customerUU))
-                    // 委外验退
-                    .task(() -> makeReturnCount[0] = commonDao.queryForObject(UnCheckedCountSqls.MAKE_RETURN_COUNT_SQL, Double.class, enUU, customerUU))
-                    .run();
-                Double totalCount = adjustmentCount[0] + saleAcceptCount[0] + saleReturnCount[0] + makeAcceptCount[0] + makeReturnCount[0];
-                customer.setUncheckedCount(totalCount);
             });
         return vendorSPage;
     }
 
+    /**
+     * 获取指定月份应收金额
+     *
+     * @param enUU 企业UU
+     * @param customerUU 客户企业UU
+     * @param checkDate 筛选月份
+     * @return 统计结果
+     */
+    private List<TradeCount> getThisMonthTrade(Long enUU, Long customerUU, String checkDate) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
+        Date date;
+        Date checkTime;
+        try {
+            date = DateUtils.dateAddMonth(format.parse(checkDate), 1);
+            checkTime = format.parse(checkDate);
+        } catch (ParseException e) {
+            throw new IllegalOperatorException("时间格式异常");
+        }
+        String sqlFromDate = DateFormatUtils.DATE_FORMAT.format(checkTime);
+        String sqlEndDate = DateFormatUtils.DATE_FORMAT.format(date);
+        List<TradeCount> totalTrades = new ArrayList<>();
+        ThreadUtils
+            // 货款调账
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_ADJUSTMENT_COUNT_SQL, TradeCount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                totalTrades.addAll(trades);
+            })
+            // 采购验收
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_SALE_ACCEPT_COUNT_SQL, TradeCount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                totalTrades.addAll(trades);
+            })
+            // 采购验退
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_SALE_RETURN_COUNT_SQL, TradeCount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                totalTrades.addAll(trades);
+            })
+            // 委外验收
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_MAKE_ACCEPT_COUNT_SQL, TradeCount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                totalTrades.addAll(trades);
+            })
+            // 委外验退
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_MAKE_RETURN_COUNT_SQL, TradeCount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                totalTrades.addAll(trades);
+            })
+            .run();
+        Double rmbCount = totalTrades.stream().filter(tradeCount -> RMB.equals(tradeCount.getCurrency()) && null != tradeCount.getAmount())
+            .mapToDouble(trade -> trade.getAmount().doubleValue()).sum();
+        Double usdCount = totalTrades.stream().filter(tradeCount -> USD.equals(tradeCount.getCurrency()) && null != tradeCount.getAmount())
+            .mapToDouble(trade -> trade.getAmount().doubleValue()).sum();
+        Double hkdCount = totalTrades.stream().filter(tradeCount -> HKD.equals(tradeCount.getCurrency()) && null != tradeCount.getAmount())
+            .mapToDouble(trade -> trade.getAmount().doubleValue()).sum();
+        List<TradeCount> resultCounts = new ArrayList<>();
+        resultCounts.add(new TradeCount(RMB, rmbCount));
+        resultCounts.add(new TradeCount(USD, usdCount));
+        resultCounts.add(new TradeCount(HKD, hkdCount));
+        return resultCounts;
+    }
+
+    /**
+     * 获取总的应收金额
+     *
+     * @param enUU 企业UU
+     * @param customerUU 客户企业UU
+     * @return 统计结果
+     */
+    private List<TradeCount> getDueTrade(Long enUU, Long customerUU) {
+        List<TradeCount> totalTrades = new ArrayList<>();
+        ThreadUtils
+            // 货款调账
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.ADJUSTMENT_COUNT_SQL, TradeCount.class, enUU, customerUU);
+                totalTrades.addAll(trades);
+            })
+            // 采购验收
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.SALE_ACCEPT_COUNT_SQL, TradeCount.class, enUU, customerUU);
+                totalTrades.addAll(trades);
+            })
+            // 采购验退
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.SALE_RETURN_COUNT_SQL, TradeCount.class, enUU, customerUU);
+                totalTrades.addAll(trades);
+            })
+            // 委外验收
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.MAKE_ACCEPT_COUNT_SQL, TradeCount.class, enUU, customerUU);
+                totalTrades.addAll(trades);
+            })
+            // 委外验退
+            .task(() -> {
+                List<TradeCount> trades = commonDao.query(UnCheckedCountSqls.MAKE_RETURN_COUNT_SQL, TradeCount.class, enUU, customerUU);
+                totalTrades.addAll(trades);
+            })
+            .run();
+        Double rmbCount = totalTrades.stream().filter(tradeCount -> RMB.equals(tradeCount.getCurrency()) && null != tradeCount.getAmount())
+            .mapToDouble(trade -> trade.getAmount().doubleValue()).sum();
+        Double usdCount = totalTrades.stream().filter(tradeCount -> USD.equals(tradeCount.getCurrency()) && null != tradeCount.getAmount())
+            .mapToDouble(trade -> trade.getAmount().doubleValue()).sum();
+        Double hkdCount = totalTrades.stream().filter(tradeCount -> HKD.equals(tradeCount.getCurrency()) && null != tradeCount.getAmount())
+            .mapToDouble(trade -> trade.getAmount().doubleValue()).sum();
+        List<TradeCount> resultCounts = new ArrayList<>();
+        resultCounts.add(new TradeCount(RMB, rmbCount));
+        resultCounts.add(new TradeCount(USD, usdCount));
+        resultCounts.add(new TradeCount(HKD, hkdCount));
+        return resultCounts;
+    }
+
     /**
      * 查询客户信息
      *