Browse Source

feat: 应付对账供应商和应收对账客户返回数据增加 本月已付和本月未付数据返回

hejq 7 years ago
parent
commit
478a5b75b7

+ 7 - 11
src/main/java/com/uas/platform/b2b/core/util/BoundedExecutor.java

@@ -26,17 +26,13 @@ public class BoundedExecutor {
 			throws InterruptedException {
 			throws InterruptedException {
 		semaphore.acquire();
 		semaphore.acquire();
 		try {
 		try {
-			executor.execute(new Runnable() {
-
-				@Override
-				public void run() {
-					try {
-						command.run();
-					} finally {
-						semaphore.release();
-					}
-				}
-			});
+			executor.execute(() -> {
+                try {
+                    command.run();
+                } finally {
+                    semaphore.release();
+                }
+            });
 		} catch (RejectedExecutionException ignored) {
 		} catch (RejectedExecutionException ignored) {
 			semaphore.release();
 			semaphore.release();
 		}
 		}

+ 15 - 2
src/main/java/com/uas/platform/b2b/core/util/ThreadTask.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2b.core.util;
 
 
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executor;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
@@ -18,7 +19,11 @@ public class ThreadTask {
     /**
     /**
      * 线程池
      * 线程池
      */
      */
-    private ThreadPoolExecutor executor;
+    private ThreadPoolExecutor poolExecutor;
+
+    private static volatile Executor executor;
+
+    private static final int MAX_THREADS = 1600;
 
 
     /**
     /**
      * 核心线程池大小
      * 核心线程池大小
@@ -37,7 +42,7 @@ public class ThreadTask {
 
 
     private ThreadTask() {
     private ThreadTask() {
         workQueue = new ArrayBlockingQueue<Runnable>(maximumPoolSize);
         workQueue = new ArrayBlockingQueue<Runnable>(maximumPoolSize);
-        this.executor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, 0L, TimeUnit.MILLISECONDS, workQueue);
+        this.poolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, 0L, TimeUnit.MILLISECONDS, workQueue);
     }
     }
 
 
     public static ThreadTask getInstance(){
     public static ThreadTask getInstance(){
@@ -47,4 +52,12 @@ public class ThreadTask {
     public void execute(Runnable r){
     public void execute(Runnable r){
         executor.execute(r);
         executor.execute(r);
     }
     }
+
+    public static void task(Runnable runnable) {
+        try {
+            new BoundedExecutor(executor, MAX_THREADS).submitTask(runnable);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
 }
 }

+ 16 - 2
src/main/java/com/uas/platform/b2b/model/Vendor.java

@@ -218,8 +218,6 @@ public class Vendor implements Serializable {
     /**
     /**
      * 本月应收(前端传入指定月份)
      * 本月应收(前端传入指定月份)
      */
      */
-	@Transient
-    private List<ApCheckAmount> thisMonthCount;
     @Transient
     @Transient
     private List<ApCheckAmount> thisMonthCount;
     private List<ApCheckAmount> thisMonthCount;
 
 
@@ -470,6 +468,22 @@ public class Vendor implements Serializable {
         this.totalCount = totalCount;
         this.totalCount = totalCount;
     }
     }
 
 
+    public List<ApCheckAmount> getThisMonthDoneCount() {
+        return thisMonthDoneCount;
+    }
+
+    public void setThisMonthDoneCount(List<ApCheckAmount> thisMonthDoneCount) {
+        this.thisMonthDoneCount = thisMonthDoneCount;
+    }
+
+    public List<ApCheckAmount> getThisMonthTodoCount() {
+        return thisMonthTodoCount;
+    }
+
+    public void setThisMonthTodoCount(List<ApCheckAmount> thisMonthTodoCount) {
+        this.thisMonthTodoCount = thisMonthTodoCount;
+    }
+
     public String getTotalCountString() {
     public String getTotalCountString() {
         return totalCountString;
         return totalCountString;
     }
     }

+ 23 - 23
src/main/java/com/uas/platform/b2b/model/util/ApCheckeAllCountSqls.java

@@ -2,87 +2,87 @@ package com.uas.platform.b2b.model.util;
 
 
 
 
 /**
 /**
- * 对账总额sql查询语句
+ * 对账总额sql查询语句
  *
  *
  * @author hejq
  * @author hejq
- * @date 2018-12-04 9:48
+ * @date 2018-12-18 10:31
  */
  */
-public class ApCheckeTodoCountSqls {
+public class ApCheckeAllCountSqls {
 
 
     /**
     /**
      * 货款调账未对账金额查询语句
      * 货款调账未对账金额查询语句
      */
      */
-    public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as count, aa_currency as currency \n" +
-        "from purc$apbilladjustment where aa_enuu = ? and aa_custuu = ? and coalesce(aa_thischeckqty, 0) <> 0 " +
+    public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty) * aa_orderprice), 0) as count, aa_currency as currency \n" +
+        "from purc$apbilladjustment where aa_enuu = ? and aa_custuu = ? " +
         "group by aa_currency";
         "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 count, aa_currency as currency \n" +
-        "from purc$apbilladjustment where aa_enuu = ? and aa_custuu = ? and aa_date between ? and ? and coalesce(aa_thischeckqty, 0) <> 0" +
+    public static final String THISMONTH_ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty) * aa_orderprice), 0) as count, aa_currency as currency \n" +
+        "from purc$apbilladjustment where aa_enuu = ? and aa_custuu = ? and aa_date between ? and ? " +
         "group by aa_currency";
         "group by aa_currency";
 
 
     /**
     /**
      * 客户采购验收单未对账金额查询语句
      * 客户采购验收单未对账金额查询语句
      */
      */
-    public static final String SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as count, pa_currency as currency \n" +
+    public static final String SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty) * pai_orderprice), 0) as count, pa_currency as currency \n" +
         "from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
         "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 " +
+        "where pa_venduu = ? and pa_enuu = ? pai_orderprice <> 0 " +
         "group by pa_currency";
         "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 count, pa_currency as currency \n" +
+    public static final String THISMONTH_SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty) * pai_orderprice), 0) as count, pa_currency as currency \n" +
         "from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
         "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 ?" +
+        "where pa_venduu = ? and pa_enuu = ? and pai_orderprice <> 0 and pa_date between ? and ? " +
         "group by pa_currency";
         "group by pa_currency";
 
 
     /**
     /**
      * 客户采购验退单未对账金额查询语句
      * 客户采购验退单未对账金额查询语句
      */
      */
-    public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice), 0) as count, pr_currency as currency \n" +
+    public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum((-1 * pri_qty ) *  pri_orderprice), 0) as count, pr_currency as currency \n" +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
-        "where pr_venduu = ? and pr_enuu = ? and pri_qty > abs(coalesce(pri_ycheckqty, 0)) group by pr_currency";
+        "where pr_venduu = ? and pr_enuu = ? group by pr_currency";
 
 
     /**
     /**
      * 客户采购验退单未对账金额查询语句
      * 客户采购验退单未对账金额查询语句
      */
      */
-    public static final String THISMONTH_SALE_RETURN_COUNT_SQL = "select sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice) as count, pr_currency as currency \n" +
+    public static final String THISMONTH_SALE_RETURN_COUNT_SQL = "select sum(((-(1) * pri_qty )) *  pri_orderprice) as count, pr_currency as currency \n" +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
-        "where pr_venduu = ? and pr_enuu = ? and pr_date between ? and ? and pri_qty > abs(coalesce(pri_ycheckqty, 0)) group by pr_currency";
+        "where 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((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice), 0) as count, ma_currency as currency " +
+    public static final String MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum((mai_qty) * mai_orderpice), 0) as count, ma_currency as currency " +
         " from make$accept " +
         " from make$accept " +
         "join make$acceptitem on ma_id = mai_paid " +
         "join make$acceptitem on ma_id = mai_paid " +
-        "where ma_venduu = ? and ma_enuu = ? and mai_orderpice > 0 and  mai_qty > coalesce(mai_ycheckqty, 0) group by ma_currency";
+        "where 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 count, ma_currency as currency " +
+    public static final String THISMONTH_MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum((mai_qty) * mai_orderpice), 0) as count, ma_currency as currency " +
         " from make$accept " +
         " from make$accept " +
         "join make$acceptitem on ma_id = mai_paid " +
         "join make$acceptitem on ma_id = mai_paid " +
-        "where ma_venduu = ? and ma_enuu = ? and mai_orderpice > 0 and ma_date between ? and ? and mai_qty > coalesce(mai_ycheckqty, 0) group by ma_currency";
+        "where 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 count,mr_currency as currency " +
+    public static final String MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-1 *  mri_qty )) * mri_orderpice), 0) as count,mr_currency as currency " +
         " from make$return " +
         " from make$return " +
         "join make$returnitem on mr_id =  mri_paid " +
         "join make$returnitem on mr_id =  mri_paid " +
-        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mri_qty > abs(coalesce(mri_ycheckqty, 0)) group by mr_currency";
+        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 group by mr_currency";
 
 
     /**
     /**
      * 客户委外验退单未对账金额查询语句
      * 客户委外验退单未对账金额查询语句
      */
      */
-    public static final String THISMONTH_MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice), 0) as count, mr_currency as currency " +
+    public static final String THISMONTH_MAKE_RETURN_COUNT_SQL = "select coalesce(sum((-1 *  mri_qty ) * mri_orderpice), 0) as count, mr_currency as currency " +
         " from make$return " +
         " from make$return " +
         "join make$returnitem on mr_id =  mri_paid " +
         "join make$returnitem on mr_id =  mri_paid " +
-        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mr_date between ? and ? and mri_qty > abs(coalesce(mri_ycheckqty, 0)) " +
+        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mr_date between ? and ?  " +
         "group by mr_currency";
         "group by mr_currency";
 }
 }

+ 22 - 22
src/main/java/com/uas/platform/b2b/model/util/ApCheckeDoneCountSqls.java

@@ -2,31 +2,31 @@ package com.uas.platform.b2b.model.util;
 
 
 
 
 /**
 /**
- * 对账总额sql查询语句
+ * 对账总额sql查询语句
  *
  *
  * @author hejq
  * @author hejq
- * @date 2018-12-04 9:48
+ * @date 2018-12-18 10:13
  */
  */
-public class ApCheckeTodoCountSqls {
+public class ApCheckeDoneCountSqls {
 
 
     /**
     /**
      * 货款调账未对账金额查询语句
      * 货款调账未对账金额查询语句
      */
      */
-    public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as count, aa_currency as currency \n" +
+    public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as count, aa_currency as currency \n" +
         "from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ? and aa_custuu = ? " +
         "from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ? and aa_custuu = ? " +
         "group by aa_currency";
         "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 count, aa_currency as currency \n" +
+    public static final String THISMONTH_ADJUSTMENT_COUNT_SQL = "select coalesce(sum((coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as count, 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 ?" +
         "from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ? and aa_custuu = ? and aa_date between ? and ?" +
         "group by aa_currency";
         "group by aa_currency";
 
 
     /**
     /**
      * 客户采购验收单未对账金额查询语句
      * 客户采购验收单未对账金额查询语句
      */
      */
-    public static final String SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as count, pa_currency as currency \n" +
+    public static final String SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as count, pa_currency as currency \n" +
         "from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
         "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 " +
         "where pa_venduu = ? and pa_enuu = ? and pai_qty > coalesce(pai_ycheckqty, 0) and pai_orderprice <> 0 " +
         "group by pa_currency";
         "group by pa_currency";
@@ -34,55 +34,55 @@ public class ApCheckeTodoCountSqls {
     /**
     /**
      * 客户采购验收单未对账金额查询语句
      * 客户采购验收单未对账金额查询语句
      */
      */
-    public static final String THISMONTH_SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as count, pa_currency as currency \n" +
+    public static final String THISMONTH_SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as count, pa_currency as currency \n" +
         "from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
         "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 ?" +
+        "where pa_venduu = ? and pa_enuu = ? and pai_orderprice <> 0 and pa_date between ? and ? " +
         "group by pa_currency";
         "group by pa_currency";
 
 
     /**
     /**
      * 客户采购验退单未对账金额查询语句
      * 客户采购验退单未对账金额查询语句
      */
      */
-    public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice), 0) as count, pr_currency as currency \n" +
+    public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum(coalesce(pri_ycheckqty, 0) *  pri_orderprice), 0) as count, pr_currency as currency \n" +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
         "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";
+        "where pr_venduu = ? and pr_enuu = ? group by pr_currency";
 
 
     /**
     /**
      * 客户采购验退单未对账金额查询语句
      * 客户采购验退单未对账金额查询语句
      */
      */
-    public static final String THISMONTH_SALE_RETURN_COUNT_SQL = "select sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice) as count, pr_currency as currency \n" +
+    public static final String THISMONTH_SALE_RETURN_COUNT_SQL = "select sum(coalesce(pri_ycheckqty, 0) *  pri_orderprice) as count, pr_currency as currency \n" +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
         "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";
+        "where 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((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice), 0) as count, 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";
+        public static final String MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum(coalesce(mai_ycheckqty, 0) * mai_orderpice), 0) as count, ma_currency as currency " +
+            " from make$accept " +
+            "join make$acceptitem on ma_id = mai_paid " +
+            "where 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 count, ma_currency as currency " +
+    public static final String THISMONTH_MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum(coalesce(mai_ycheckqty, 0) * mai_orderpice), 0) as count, ma_currency as currency " +
         " from make$accept " +
         " from make$accept " +
         "join make$acceptitem on ma_id = mai_paid " +
         "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";
+        "where 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 count,mr_currency as currency " +
+    public static final String MAKE_RETURN_COUNT_SQL = "select coalesce(sum(coalesce(mri_ycheckqty, 0) * mri_orderpice), 0) as count,mr_currency as currency " +
         " from make$return " +
         " from make$return " +
         "join make$returnitem on mr_id =  mri_paid " +
         "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";
+        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 group by mr_currency";
 
 
     /**
     /**
      * 客户委外验退单未对账金额查询语句
      * 客户委外验退单未对账金额查询语句
      */
      */
-    public static final String THISMONTH_MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice), 0) as count, mr_currency as currency " +
+    public static final String THISMONTH_MAKE_RETURN_COUNT_SQL = "select coalesce(sum(coalesce(mri_ycheckqty, 0) * mri_orderpice), 0) as count, mr_currency as currency " +
         " from make$return " +
         " from make$return " +
         "join make$returnitem on mr_id =  mri_paid " +
         "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 and mr_date between ? and ? " +
+        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mr_date between ? and ? " +
         "group by mr_currency";
         "group by mr_currency";
 }
 }

+ 10 - 10
src/main/java/com/uas/platform/b2b/model/util/ApCheckeTodoCountSqls.java

@@ -7,20 +7,20 @@ package com.uas.platform.b2b.model.util;
  * @author hejq
  * @author hejq
  * @date 2018-12-04 9:48
  * @date 2018-12-04 9:48
  */
  */
-public class UnCheckedCountSqls {
+public class ApCheckeTodoCountSqls {
 
 
     /**
     /**
      * 货款调账未对账金额查询语句
      * 货款调账未对账金额查询语句
      */
      */
     public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as count, aa_currency as currency \n" +
     public static final String ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as count, aa_currency as currency \n" +
-        "from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ? and aa_custuu = ? " +
+        "from purc$apbilladjustment where aa_enuu = ? and aa_custuu = ? and coalesce(aa_thischeckqty, 0) <> 0 " +
         "group by aa_currency";
         "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 count, aa_currency as currency \n" +
     public static final String THISMONTH_ADJUSTMENT_COUNT_SQL = "select coalesce(sum((aa_qty - coalesce(aa_ycheckqty, 0)) * aa_orderprice), 0) as count, 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 ?" +
+        "from purc$apbilladjustment where aa_enuu = ? and aa_custuu = ? and aa_date between ? and ? and coalesce(aa_thischeckqty, 0) <> 0 " +
         "group by aa_currency";
         "group by aa_currency";
 
 
     /**
     /**
@@ -36,7 +36,7 @@ public class UnCheckedCountSqls {
      */
      */
     public static final String THISMONTH_SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as count, pa_currency as currency \n" +
     public static final String THISMONTH_SALE_ACCEPT_COUNT_SQL = "select coalesce(sum((pai_qty - coalesce(pai_ycheckqty, 0)) * pai_orderprice), 0) as count, pa_currency as currency \n" +
         "from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
         "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 ?" +
+        "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";
         "group by pa_currency";
 
 
     /**
     /**
@@ -44,14 +44,14 @@ public class UnCheckedCountSqls {
      */
      */
     public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice), 0) as count, pr_currency as currency \n" +
     public static final String SALE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice), 0) as count, pr_currency as currency \n" +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
         "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";
+        "where pr_venduu = ? and pr_enuu = ? and pri_qty > abs(coalesce(pri_ycheckqty, 0)) group by pr_currency";
 
 
     /**
     /**
      * 客户采购验退单未对账金额查询语句
      * 客户采购验退单未对账金额查询语句
      */
      */
     public static final String THISMONTH_SALE_RETURN_COUNT_SQL = "select sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice) as count, pr_currency as currency \n" +
     public static final String THISMONTH_SALE_RETURN_COUNT_SQL = "select sum(((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) *  pri_orderprice) as count, pr_currency as currency \n" +
         "from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
         "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";
+        "where pr_venduu = ? and pr_enuu = ? and pr_date between ? and ? and pri_qty > abs(coalesce(pri_ycheckqty, 0)) group by pr_currency";
 
 
     /**
     /**
      * 客户委外验收单未对账金额查询语句
      * 客户委外验收单未对账金额查询语句
@@ -59,7 +59,7 @@ public class UnCheckedCountSqls {
     public static final String MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice), 0) 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 count, ma_currency as currency " +
         " from make$accept " +
         " from make$accept " +
         "join make$acceptitem on ma_id = mai_paid " +
         "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";
+        "where ma_venduu = ? and ma_enuu = ? and mai_orderpice > 0 and  mai_qty > coalesce(mai_ycheckqty, 0) group by ma_currency";
 
 
     /**
     /**
      * 客户委外验收单未对账金额查询语句
      * 客户委外验收单未对账金额查询语句
@@ -67,7 +67,7 @@ public class UnCheckedCountSqls {
     public static final String THISMONTH_MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice), 0) as count, ma_currency as currency " +
     public static final String THISMONTH_MAKE_ACCEPT_COUNT_SQL = "select coalesce(sum((mai_qty - coalesce(mai_ycheckqty, 0)) * mai_orderpice), 0) as count, ma_currency as currency " +
         " from make$accept " +
         " from make$accept " +
         "join make$acceptitem on ma_id = mai_paid " +
         "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";
+        "where ma_venduu = ? and ma_enuu = ? and mai_orderpice > 0 and ma_date between ? and ? and mai_qty > coalesce(mai_ycheckqty, 0) group by ma_currency";
 
 
     /**
     /**
      * 客户委外验退单未对账金额查询语句
      * 客户委外验退单未对账金额查询语句
@@ -75,7 +75,7 @@ public class UnCheckedCountSqls {
     public static final String MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice), 0) as count,mr_currency as currency " +
     public static final String MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice), 0) as count,mr_currency as currency " +
         " from make$return " +
         " from make$return " +
         "join make$returnitem on mr_id =  mri_paid " +
         "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";
+        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mri_qty > abs(coalesce(mri_ycheckqty, 0)) group by mr_currency";
 
 
     /**
     /**
      * 客户委外验退单未对账金额查询语句
      * 客户委外验退单未对账金额查询语句
@@ -83,6 +83,6 @@ public class UnCheckedCountSqls {
     public static final String THISMONTH_MAKE_RETURN_COUNT_SQL = "select coalesce(sum(((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) * mri_orderpice), 0) 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 count, mr_currency as currency " +
         " from make$return " +
         " from make$return " +
         "join make$returnitem on mr_id =  mri_paid " +
         "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 and mr_date between ? and ? " +
+        "where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mr_date between ? and ? and mri_qty > abs(coalesce(mri_ycheckqty, 0)) " +
         "group by mr_currency";
         "group by mr_currency";
 }
 }

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

@@ -155,7 +155,7 @@ public interface PurchaseApCheckService {
     List<ApCheckAmount> getDueTrade(Long enUU, Long customerUU);
     List<ApCheckAmount> getDueTrade(Long enUU, Long customerUU);
 
 
     /**
     /**
-     * 获取指定月份应收金额
+     * 获取指定月份应收金额(总额)
      *
      *
      * @param enUU 企业UU
      * @param enUU 企业UU
      * @param customerUU 客户企业UU
      * @param customerUU 客户企业UU
@@ -165,4 +165,44 @@ public interface PurchaseApCheckService {
      * @return 统计结果
      * @return 统计结果
      */
      */
     List<ApCheckAmount> getThisMonthTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate);
     List<ApCheckAmount> getThisMonthTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate);
+
+    /**
+     * 获取指定月份应收金额(未收)
+     *
+     * @param enUU 企业UU
+     * @param customerUU 客户企业UU
+     * @param checkDate 筛选月份
+     * @param fromDate 开始时间
+     * @param endDate 截止时间
+     * @return 统计结果
+     */
+    List<ApCheckAmount> getThisMonthTodoTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate);
+
+    /**
+     * 获取指定月份应收金额(已收)
+     *
+     * @param enUU 企业UU
+     * @param customerUU 客户企业UU
+     * @param checkDate 筛选月份
+     * @param fromDate 开始时间
+     * @param endDate 截止时间
+     * @return 统计结果
+     */
+    List<ApCheckAmount> getThisMonthDoneTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate);
+
+    /**
+     * 根据统计信息按币别分类处理
+     *
+     * @param totalTrades 总额
+     * @return 处理后的数据
+     */
+    List<ApCheckAmount> groupCountByCurrency(List<ApCheckAmount> totalTrades);
+
+    /**
+     * 设置供应商信息
+     * @param params 分页参数
+     * @param vendors 查询结果
+     * @param vendorSPage 分页处理
+     */
+    void setVendorSPage(PageParams params, List<Vendor> vendors, SPage<Vendor> vendorSPage);
 }
 }

+ 15 - 9
src/main/java/com/uas/platform/b2b/service/impl/PurchaseApBillServiceImpl.java

@@ -227,10 +227,11 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
      */
      */
     @Override
     @Override
     public SPage<Vendor> getVendorInfo(com.uas.platform.core.model.PageParams params, String keyword, String checkDate, Long fromDate, Long endDate) {
     public SPage<Vendor> getVendorInfo(com.uas.platform.core.model.PageParams params, String keyword, String checkDate, Long fromDate, Long endDate) {
-        SPage<Vendor> vendorSPage = findVendorByPage(params, keyword);
+        List<Vendor> vendors = findVendorByPage(params, keyword);
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
-        if (!org.springframework.util.CollectionUtils.isEmpty(vendorSPage.getContent())) {
-            vendorSPage.getContent().stream().filter(customer -> null != customer.getApcheck() && customer.getApcheck() == 1)
+        SPage<Vendor> vendorSPage = new SPage<>();
+        if (!org.springframework.util.CollectionUtils.isEmpty(vendors)) {
+            vendors.stream().filter(customer -> null != customer.getApcheck() && customer.getApcheck() == 1)
                 .forEach(customer -> {
                 .forEach(customer -> {
                     Long vendorUU = customer.getVendEnUU();
                     Long vendorUU = customer.getVendEnUU();
                     if (!com.uas.ps.core.util.StringUtils.isEmpty(customer.getTotalCountString())) {
                     if (!com.uas.ps.core.util.StringUtils.isEmpty(customer.getTotalCountString())) {
@@ -238,9 +239,15 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
                         customer.setTotalCount(tradeCounts);
                         customer.setTotalCount(tradeCounts);
                     }
                     }
                     // 本月应收
                     // 本月应收
-                    List<ApCheckAmount> thisMonthTrades = purchaseApCheckService.getThisMonthTrade(vendorUU, enUU, checkDate, fromDate, endDate);
-                    customer.setThisMonthCount(thisMonthTrades);
+                    List<ApCheckAmount> thisMonthTodoTrades = purchaseApCheckService.getThisMonthTodoTrade(vendorUU, enUU, checkDate, fromDate, endDate);
+                    customer.setThisMonthTodoCount(thisMonthTodoTrades);
+                    List<ApCheckAmount> thisMonthDoneTrades = purchaseApCheckService.getThisMonthDoneTrade(vendorUU, enUU, checkDate, fromDate, endDate);
+                    customer.setThisMonthDoneCount(thisMonthDoneTrades);
+                    List<ApCheckAmount> thisMonthAllTrades = purchaseApCheckService.getThisMonthTrade(vendorUU, enUU, checkDate, fromDate, endDate);
+                    customer.setThisMonthCount(thisMonthAllTrades);
                 });
                 });
+            vendors.stream().filter(vendor -> null != vendor.getThisMonthCount());
+            purchaseApCheckService.setVendorSPage(params, vendors, vendorSPage);
         }
         }
         return vendorSPage;
         return vendorSPage;
     }
     }
@@ -252,7 +259,7 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
      * @param keyword 搜索关键词
      * @param keyword 搜索关键词
      * @return 搜索结果
      * @return 搜索结果
      */
      */
-    private SPage<Vendor> findVendorByPage(com.uas.platform.core.model.PageParams params, String keyword) {
+    private List<Vendor> findVendorByPage(com.uas.platform.core.model.PageParams params, String keyword) {
         PageInfo pageInfo = new PageInfo(params.getPage(), params.getCount());
         PageInfo pageInfo = new PageInfo(params.getPage(), params.getCount());
         org.springframework.data.domain.Sort sort = new org.springframework.data.domain.Sort( org.springframework.data.domain.Sort.Direction.DESC, "totalCountString");
         org.springframework.data.domain.Sort sort = new org.springframework.data.domain.Sort( org.springframework.data.domain.Sort.Direction.DESC, "totalCountString");
         pageInfo.setSort(sort);
         pageInfo.setSort(sort);
@@ -269,9 +276,8 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
         if (!com.uas.ps.core.util.StringUtils.isEmpty(keyword)) {
         if (!com.uas.ps.core.util.StringUtils.isEmpty(keyword)) {
             pageInfo.expression(PredicateUtils.like("vendorEnterprise.enName", keyword, true));
             pageInfo.expression(PredicateUtils.like("vendorEnterprise.enName", keyword, true));
         }
         }
-        Page<Vendor> vendors = vendorDao.findAll((Root<Vendor> root, CriteriaQuery<?> query, CriteriaBuilder builder) ->
-            query.where(pageInfo.getPredicates(root, query, builder)).getRestriction(), pageInfo);
-        return SPageUtils.covertSPage(vendors);
+        return vendorDao.findAll((Root<Vendor> root, CriteriaQuery<?> query, CriteriaBuilder builder) ->
+            query.where(pageInfo.getPredicates(root, query, builder)).getRestriction());
     }
     }
 
 
     /**
     /**

+ 162 - 56
src/main/java/com/uas/platform/b2b/service/impl/PurchaseApCheckServiceImpl.java

@@ -3,8 +3,6 @@ package com.uas.platform.b2b.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.uas.platform.b2b.constant.StringConstant;
 import com.uas.platform.b2b.constant.StringConstant;
 import com.uas.platform.b2b.core.util.ContextUtils;
 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.core.util.ThreadUtils;
 import com.uas.platform.b2b.dao.CommonDao;
 import com.uas.platform.b2b.dao.CommonDao;
 import com.uas.platform.b2b.dao.EnterpriseDao;
 import com.uas.platform.b2b.dao.EnterpriseDao;
@@ -14,6 +12,7 @@ import com.uas.platform.b2b.dao.PurchaseApCheckItemDao;
 import com.uas.platform.b2b.dao.PurchaseApCheckTodoDao;
 import com.uas.platform.b2b.dao.PurchaseApCheckTodoDao;
 import com.uas.platform.b2b.dao.VendorDao;
 import com.uas.platform.b2b.dao.VendorDao;
 import com.uas.platform.b2b.event.PurchaseApCheckReplyReleaseEvent;
 import com.uas.platform.b2b.event.PurchaseApCheckReplyReleaseEvent;
+import com.uas.platform.b2b.model.DateFilter;
 import com.uas.platform.b2b.model.Enterprise;
 import com.uas.platform.b2b.model.Enterprise;
 import com.uas.platform.b2b.model.OrderRedDotAll;
 import com.uas.platform.b2b.model.OrderRedDotAll;
 import com.uas.platform.b2b.model.OrderType;
 import com.uas.platform.b2b.model.OrderType;
@@ -24,15 +23,16 @@ import com.uas.platform.b2b.model.PurchaseApCheckTodo;
 import com.uas.platform.b2b.model.SearchFilter;
 import com.uas.platform.b2b.model.SearchFilter;
 import com.uas.platform.b2b.model.SourceForApcheck;
 import com.uas.platform.b2b.model.SourceForApcheck;
 import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.model.Vendor;
-import com.uas.platform.b2b.model.util.UnCheckedCountSqls;
+import com.uas.platform.b2b.model.util.ApCheckeAllCountSqls;
+import com.uas.platform.b2b.model.util.ApCheckeDoneCountSqls;
+import com.uas.platform.b2b.model.util.ApCheckeTodoCountSqls;
 import com.uas.platform.b2b.publicapi.model.ApCheckAmount;
 import com.uas.platform.b2b.publicapi.model.ApCheckAmount;
-import com.uas.platform.b2b.publicapi.model.TradeCount;
 import com.uas.platform.b2b.search.SearchService;
 import com.uas.platform.b2b.search.SearchService;
+import com.uas.platform.b2b.service.ErpProdIODetailService;
 import com.uas.platform.b2b.service.OrderRedDotService;
 import com.uas.platform.b2b.service.OrderRedDotService;
 import com.uas.platform.b2b.service.PurchaseApCheckService;
 import com.uas.platform.b2b.service.PurchaseApCheckService;
 import com.uas.platform.b2b.service.UserService;
 import com.uas.platform.b2b.service.UserService;
 import com.uas.platform.b2b.support.DecimalUtils;
 import com.uas.platform.b2b.support.DecimalUtils;
-import com.uas.platform.b2b.support.SPageUtils;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.Constant;
@@ -57,9 +57,9 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import javax.persistence.criteria.Root;
 import java.sql.SQLException;
 import java.sql.SQLException;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.HashSet;
@@ -119,6 +119,9 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
      */
      */
     private final String USD = "USD";
     private final String USD = "USD";
 
 
+    @Autowired
+    private ErpProdIODetailService erpProdIODetailService;
+
 	@Override
 	@Override
 	public List<PurchaseApCheck> findNotUploadAPcheck() {
 	public List<PurchaseApCheck> findNotUploadAPcheck() {
 		return purchaseApCheckDao.findByCustUuAndStatusAndCheckStatus(SystemSession.getUser().getEnterprise().getUu(),
 		return purchaseApCheckDao.findByCustUuAndStatusAndCheckStatus(SystemSession.getUser().getEnterprise().getUu(),
@@ -522,24 +525,54 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
      */
      */
     @Override
     @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) {
-        SPage<Vendor> vendorSPage = findCustomerByPage(params, keyword);
+        List<Vendor> vendors = findCustomerByPage(params, keyword);
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
-        if (!CollectionUtils.isEmpty(vendorSPage.getContent())) {
-            vendorSPage.getContent().stream().filter(customer -> null != customer.getApcheck() && customer.getApcheck() == 1)
+        SPage<Vendor> vendorSPage = new SPage<>();
+        if (!CollectionUtils.isEmpty(vendors)) {
+            vendors.stream().filter(customer -> null != customer.getApcheck() && customer.getApcheck() == 1)
                 .forEach(customer -> {
                 .forEach(customer -> {
                     Long customerUU = customer.getMyEnUU();
                     Long customerUU = customer.getMyEnUU();
                     if (!StringUtils.isEmpty(customer.getTotalCountString())) {
                     if (!StringUtils.isEmpty(customer.getTotalCountString())) {
                         List<ApCheckAmount> tradeCounts = JSON.parseArray(customer.getTotalCountString(), ApCheckAmount.class);
                         List<ApCheckAmount> tradeCounts = JSON.parseArray(customer.getTotalCountString(), ApCheckAmount.class);
                         customer.setTotalCount(tradeCounts);
                         customer.setTotalCount(tradeCounts);
                     }
                     }
-                    // 本月应收
+                    // 本月应收(未收)
+                    List<ApCheckAmount> thisMonthTodoTrades = getThisMonthTodoTrade(enUU, customerUU, checkDate, fromDate, endDate);
+                    customer.setThisMonthTodoCount(thisMonthTodoTrades);
+                    // 本月应收(已收)
+                    List<ApCheckAmount> thisMonthDoneTrades = getThisMonthDoneTrade(enUU, customerUU, checkDate, fromDate, endDate);
+                    customer.setThisMonthDoneCount(thisMonthDoneTrades);
+                    // 本月应收(总额)
                     List<ApCheckAmount> thisMonthTrades = getThisMonthTrade(enUU, customerUU, checkDate, fromDate, endDate);
                     List<ApCheckAmount> thisMonthTrades = getThisMonthTrade(enUU, customerUU, checkDate, fromDate, endDate);
                     customer.setThisMonthCount(thisMonthTrades);
                     customer.setThisMonthCount(thisMonthTrades);
                 });
                 });
+            vendors.stream().filter(vendor -> null != vendor.getThisMonthCount());
+            setVendorSPage(params, vendors, vendorSPage);
         }
         }
         return vendorSPage;
         return vendorSPage;
     }
     }
 
 
+    /**
+     * 设置供应商信息
+     * @param params 分页参数
+     * @param vendors 查询结果
+     * @param vendorSPage 分页处理
+     */
+    @Override
+    public void setVendorSPage(PageParams params, List<Vendor> vendors, SPage<Vendor> vendorSPage) {
+        List<Vendor> vendorList;
+        int startIndex = (params.getPage() - 1) * params.getCount();
+        int endIndex = params.getPage() * params.getCount();
+        int totalCount = vendors.size();
+        int totalPage = (int) Math.ceil(totalCount / params.getCount());
+        vendorSPage.setTotalElement(vendors.size());
+        vendorSPage.setTotalPage(totalPage);
+        vendorSPage.setPage(params.getPage());
+        vendorSPage.setSize(params.getCount());
+        vendorList = vendors.subList(startIndex, endIndex > totalCount ? totalCount : endIndex);
+        vendorSPage.setContent(vendorList);
+    }
+
     /**
     /**
      * 通过分页信息查询客户信息
      * 通过分页信息查询客户信息
      *
      *
@@ -547,15 +580,13 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
      * @param keyword 搜索关键词
      * @param keyword 搜索关键词
      * @return 搜索结果
      * @return 搜索结果
      */
      */
-    private SPage<Vendor> findCustomerByPage(PageParams params, String keyword) {
+    private List<Vendor> findCustomerByPage(PageParams params, String keyword) {
         // 只使用前端的页码和分页大小,防止排序信息注入
         // 只使用前端的页码和分页大小,防止排序信息注入
         SearchFilter filter = userService.distribute();
         SearchFilter filter = userService.distribute();
         if (filter != null && filter.getDistribute() == null) {
         if (filter != null && filter.getDistribute() == null) {
-            return new SPage<>();
+            return new ArrayList<>();
         }
         }
         PageInfo pageInfo = new PageInfo(params.getPage(), params.getCount());
         PageInfo pageInfo = new PageInfo(params.getPage(), params.getCount());
-        org.springframework.data.domain.Sort sort = new org.springframework.data.domain.Sort( org.springframework.data.domain.Sort.Direction.DESC, "totalCountString");
-        pageInfo.setSort(sort);
         /*
         /*
          * 过滤条件
          * 过滤条件
          * 1、 当前企业为供应商
          * 1、 当前企业为供应商
@@ -573,13 +604,16 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
         if (!StringUtils.isEmpty(keyword)) {
         if (!StringUtils.isEmpty(keyword)) {
             pageInfo.expression(PredicateUtils.like("myEnterprise.enName", keyword, true));
             pageInfo.expression(PredicateUtils.like("myEnterprise.enName", keyword, true));
         }
         }
-        Page<Vendor> vendors = vendorDao.findAll((Root<Vendor> root, CriteriaQuery<?> query, CriteriaBuilder builder) ->
-            query.where(pageInfo.getPredicates(root, query, builder)).getRestriction(), pageInfo);
-        return SPageUtils.covertSPage(vendors);
+        /*
+         * 1、 筛选所有符合条件的客户信息
+         * 2、 后端做其他数据操作处理
+         */
+        return vendorDao.findAll((Root<Vendor> root, CriteriaQuery<?> query, CriteriaBuilder builder) ->
+            query.where(pageInfo.getPredicates(root, query, builder)).getRestriction());
     }
     }
 
 
     /**
     /**
-     * 获取指定月份应收金额
+     * 获取指定月份应收金额(未收)
      *
      *
      * @param enUU 企业UU
      * @param enUU 企业UU
      * @param customerUU 客户企业UU
      * @param customerUU 客户企业UU
@@ -589,62 +623,46 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
      * @return 统计结果
      * @return 统计结果
      */
      */
     @Override
     @Override
-    public List<ApCheckAmount> getThisMonthTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate) {
-        String sqlFromDate;
-        String sqlEndDate;
-        /*
-         * 1、 如果前端指定开始截止时间,直接使用
-         * 2、 如果前端未指定,采用选择月份,使用月份处理
-         * 3、 截止时间筛为指定月份加1,即下月一号,采用小于这天,能取到当月所有数据
-         */
-        final Integer oneDayMilliseconds = 86400000;
-        boolean onlyCheckDate = (null == fromDate || null == endDate) && null != checkDate;
-        if (null != fromDate && null != endDate ) {
-            sqlFromDate = DateFormatUtils.DATE_FORMAT.format(new Date(fromDate));
-            sqlEndDate = DateFormatUtils.DATE_FORMAT.format(new Date(endDate + oneDayMilliseconds));
-        } else if (onlyCheckDate) {
-            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("时间格式异常");
-            }
-            sqlFromDate = DateFormatUtils.DATE_FORMAT.format(checkTime);
-            sqlEndDate = DateFormatUtils.DATE_FORMAT.format(date);
-        } else {
-            throw new IllegalOperatorException("请选择对账时间");
-        }
+    public List<ApCheckAmount> getThisMonthTodoTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate) {
+        DateFilter filter = erpProdIODetailService.initFilter(fromDate, endDate, checkDate);
         List<ApCheckAmount> totalTrades = new ArrayList<>();
         List<ApCheckAmount> totalTrades = new ArrayList<>();
         ThreadUtils
         ThreadUtils
             // 货款调账
             // 货款调账
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_ADJUSTMENT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeTodoCountSqls.THISMONTH_ADJUSTMENT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 采购验收
             // 采购验收
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeTodoCountSqls.THISMONTH_SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 采购验退
             // 采购验退
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_SALE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeTodoCountSqls.THISMONTH_SALE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 委外验收
             // 委外验收
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_MAKE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeTodoCountSqls.THISMONTH_MAKE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 委外验退
             // 委外验退
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.THISMONTH_MAKE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, sqlFromDate, sqlEndDate);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeTodoCountSqls.THISMONTH_MAKE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             .run();
             .run();
+        return groupCountByCurrency(totalTrades);
+    }
+
+    /**
+     * 根据统计信息按币别分类处理
+     * @param totalTrades 总额
+     * @return 处理后的数据
+     */
+    @Override
+    public List<ApCheckAmount> groupCountByCurrency(List<ApCheckAmount> totalTrades) {
         Double rmbCount = totalTrades.stream().filter(tradeCount -> RMB.equals(tradeCount.getCurrency()))
         Double rmbCount = totalTrades.stream().filter(tradeCount -> RMB.equals(tradeCount.getCurrency()))
             .mapToDouble(ApCheckAmount::getCount).sum();
             .mapToDouble(ApCheckAmount::getCount).sum();
         Double usdCount = totalTrades.stream().filter(tradeCount -> USD.equals(tradeCount.getCurrency()))
         Double usdCount = totalTrades.stream().filter(tradeCount -> USD.equals(tradeCount.getCurrency()))
@@ -664,6 +682,94 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
         return resultCounts;
         return resultCounts;
     }
     }
 
 
+    /**
+     * 获取指定月份应收金额(已收)
+     *
+     * @param enUU 企业UU
+     * @param customerUU 客户企业UU
+     * @param checkDate 筛选月份
+     * @param fromDate 开始时间
+     * @param endDate 截止时间
+     * @return 统计结果
+     */
+    @Override
+    public List<ApCheckAmount> getThisMonthDoneTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate) {
+        DateFilter filter = erpProdIODetailService.initFilter(fromDate, endDate, checkDate);
+        List<ApCheckAmount> totalTrades = new ArrayList<>();
+        ThreadUtils
+            // 货款调账
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeDoneCountSqls.THISMONTH_ADJUSTMENT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 采购验收
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeDoneCountSqls.THISMONTH_SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 采购验退
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeDoneCountSqls.THISMONTH_SALE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 委外验收
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeDoneCountSqls.THISMONTH_MAKE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 委外验退
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeDoneCountSqls.THISMONTH_MAKE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            .run();
+        return groupCountByCurrency(totalTrades);
+    }
+
+    /**
+     * 获取指定月份应收金额(总额)
+     *
+     * @param enUU       企业UU
+     * @param customerUU 客户企业UU
+     * @param checkDate  筛选月份
+     * @param fromDate   开始时间
+     * @param endDate    截止时间
+     * @return 统计结果
+     */
+    @Override
+    public List<ApCheckAmount> getThisMonthTrade(Long enUU, Long customerUU, String checkDate, Long fromDate, Long endDate) {
+        DateFilter filter = erpProdIODetailService.initFilter(fromDate, endDate, checkDate);
+        List<ApCheckAmount> totalTrades = new ArrayList<>();
+        ThreadUtils
+            // 货款调账
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.THISMONTH_ADJUSTMENT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 采购验收
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.THISMONTH_SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 采购验退
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.THISMONTH_SALE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 委外验收
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.THISMONTH_MAKE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            // 委外验退
+            .task(() -> {
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.THISMONTH_MAKE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU, filter.getFromDate(), filter.getEndDate());
+                totalTrades.addAll(trades);
+            })
+            .run();
+        return groupCountByCurrency(totalTrades);
+    }
+
     /**
     /**
      * 获取总的应收金额
      * 获取总的应收金额
      *
      *
@@ -677,27 +783,27 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
         ThreadUtils
         ThreadUtils
             // 货款调账
             // 货款调账
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.ADJUSTMENT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.ADJUSTMENT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 采购验收
             // 采购验收
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 采购验退
             // 采购验退
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.SALE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.SALE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 委外验收
             // 委外验收
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.MAKE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.MAKE_ACCEPT_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             // 委外验退
             // 委外验退
             .task(() -> {
             .task(() -> {
-                List<ApCheckAmount> trades = commonDao.query(UnCheckedCountSqls.MAKE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
+                List<ApCheckAmount> trades = commonDao.query(ApCheckeAllCountSqls.MAKE_RETURN_COUNT_SQL, ApCheckAmount.class, enUU, customerUU);
                 totalTrades.addAll(trades);
                 totalTrades.addAll(trades);
             })
             })
             .run();
             .run();