Просмотр исходного кода

feat(prodIoPay, apCheckAmount): 更新付款记录同步功能;增加发货金额查询功能开发

hejq 7 лет назад
Родитель
Сommit
55226d6cf8

+ 14 - 1
db/ddl.sql

@@ -188,4 +188,17 @@ create table `prodiopay` (
   `pi_source_id` bigint(20) default null COMMENT 'erp明细id',
   `pi_date` datetime default null COMMENT '录入日期',
   primary key (`pi_id`)
-) ENGINE=InnoDB auto_increment=1 default CHARSET=utf8;
+) ENGINE=InnoDB auto_increment=1 default CHARSET=utf8;
+
+-- date: 2019-01-04 9:49
+-- author: hejq
+-- content: 对账明细增加付款金额
+alter table purc$apcheckitem add column pai_payment double COMMENT '付款金额';
+
+-- date: 2019-01-04 13:59
+-- author: hejq
+-- content: 对账单明细增加送货明细id,送货数量和单价
+alter table purc$apcheckitem
+  add column pai_send_id BIGINT COMMENT '送货单明细id',
+  add column pai_send_qty DOUBLE COMMENT '送货数量',
+  add column pai_send_price DOUBLE COMMENT '送货单价';

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

@@ -70,7 +70,7 @@ public class SaleApCheckController {
 	private ErpProdIODetailService erpProdIODetailService;
 
 	@Autowired
-	PurchaseApCheckService purchaseApCheckService;
+    private PurchaseApCheckService purchaseApCheckService;
 
 	@Autowired
 	private VendorService vendorService;
@@ -431,8 +431,8 @@ public class SaleApCheckController {
         // 排序条件
         List<Sort> sortList = new ArrayList<>();
         // 如果日期为空,设置的默认时间2000/1/1 1:1:1
-        sortList.add(new Sort("pa_recorddate", false, Type.INT, new Long(946659661)));
-        sortList.add(new Sort("pa_id", false, Type.INT, new Long(1)));
+        sortList.add(new Sort("pa_recorddate", false, Type.INT, 946659661L));
+        sortList.add(new Sort("pa_id", false, Type.INT, 1L));
         pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
         return pageParams;
     }

+ 220 - 0
src/main/java/com/uas/platform/b2b/model/ErpProdIODetail.java

@@ -194,6 +194,21 @@ public class ErpProdIODetail implements Serializable {
      */
     private String sendcode;
 
+    /**
+     * 送货单明细id
+     */
+    private Long sendId;
+
+    /**
+     * 发货数量
+     */
+    private Double sendQty;
+
+    /**
+     * 发货价格
+     */
+    private Double sendPrice;
+
     /**
      * 仓库
      */
@@ -219,6 +234,11 @@ public class ErpProdIODetail implements Serializable {
      */
     private Long apCheckId;
 
+    /**
+     * 付款金额
+     */
+    private Double payment;
+
     public ErpProdIODetail() {}
 
     /**
@@ -252,6 +272,10 @@ public class ErpProdIODetail implements Serializable {
         this.thischeckqty = item.getCheckQty();
         this.pidate = item.getSourceDate();
         this.qty = item.getCheckQty();
+        this.payment = item.getPayment();
+        this.sendId = item.getSendId();
+        this.sendQty = item.getSendQty();
+        this.sendPrice = item.getSendPrice();
     }
 
     @Id
@@ -506,6 +530,30 @@ public class ErpProdIODetail implements Serializable {
         this.sendcode = sendcode;
     }
 
+    public Long getSendId() {
+        return sendId;
+    }
+
+    public void setSendId(Long sendId) {
+        this.sendId = sendId;
+    }
+
+    public Double getSendQty() {
+        return sendQty;
+    }
+
+    public void setSendQty(Double sendQty) {
+        this.sendQty = sendQty;
+    }
+
+    public Double getSendPrice() {
+        return sendPrice;
+    }
+
+    public void setSendPrice(Double sendPrice) {
+        this.sendPrice = sendPrice;
+    }
+
     public String getWhname() {
         return whname;
     }
@@ -545,4 +593,176 @@ public class ErpProdIODetail implements Serializable {
     public void setApCheckId(Long apCheckId) {
         this.apCheckId = apCheckId;
     }
+
+    public Double getPayment() {
+        return payment;
+    }
+
+    public void setPayment(Double payment) {
+        this.payment = payment;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof ErpProdIODetail)) {
+            return false;
+        }
+
+        ErpProdIODetail detail = (ErpProdIODetail) o;
+
+        if (id != null ? !id.equals(detail.id) : detail.id != null) {
+            return false;
+        }
+        if (inoutno != null ? !inoutno.equals(detail.inoutno) : detail.inoutno != null) {
+            return false;
+        }
+        if (detno != null ? !detno.equals(detail.detno) : detail.detno != null) {
+            return false;
+        }
+        if (piclass != null ? !piclass.equals(detail.piclass) : detail.piclass != null) {
+            return false;
+        }
+        if (ordercode != null ? !ordercode.equals(detail.ordercode) : detail.ordercode != null) {
+            return false;
+        }
+        if (orderdetno != null ? !orderdetno.equals(detail.orderdetno) : detail.orderdetno != null) {
+            return false;
+        }
+        if (prodcode != null ? !prodcode.equals(detail.prodcode) : detail.prodcode != null) {
+            return false;
+        }
+        if (prodspec != null ? !prodspec.equals(detail.prodspec) : detail.prodspec != null) {
+            return false;
+        }
+        if (prodtitle != null ? !prodtitle.equals(detail.prodtitle) : detail.prodtitle != null) {
+            return false;
+        }
+        if (produnit != null ? !produnit.equals(detail.produnit) : detail.produnit != null) {
+            return false;
+        }
+        if (qty != null ? !qty.equals(detail.qty) : detail.qty != null) {
+            return false;
+        }
+        if (orderprice != null ? !orderprice.equals(detail.orderprice) : detail.orderprice != null) {
+            return false;
+        }
+        if (currency != null ? !currency.equals(detail.currency) : detail.currency != null) {
+            return false;
+        }
+        if (taxrate != null ? !taxrate.equals(detail.taxrate) : detail.taxrate != null) {
+            return false;
+        }
+        if (ycheckqty != null ? !ycheckqty.equals(detail.ycheckqty) : detail.ycheckqty != null) {
+            return false;
+        }
+        if (thischeckqty != null ? !thischeckqty.equals(detail.thischeckqty) : detail.thischeckqty != null) {
+            return false;
+        }
+        if (custname != null ? !custname.equals(detail.custname) : detail.custname != null) {
+            return false;
+        }
+        if (custuu != null ? !custuu.equals(detail.custuu) : detail.custuu != null) {
+            return false;
+        }
+        if (custuseruu != null ? !custuseruu.equals(detail.custuseruu) : detail.custuseruu != null) {
+            return false;
+        }
+        if (sourceid != null ? !sourceid.equals(detail.sourceid) : detail.sourceid != null) {
+            return false;
+        }
+        if (sourcetable != null ? !sourcetable.equals(detail.sourcetable) : detail.sourcetable != null) {
+            return false;
+        }
+        if (sourceDate != null ? !sourceDate.equals(detail.sourceDate) : detail.sourceDate != null) {
+            return false;
+        }
+        if (enuu != null ? !enuu.equals(detail.enuu) : detail.enuu != null) {
+            return false;
+        }
+        if (pidate != null ? !pidate.equals(detail.pidate) : detail.pidate != null) {
+            return false;
+        }
+        if (rate != null ? !rate.equals(detail.rate) : detail.rate != null) {
+            return false;
+        }
+        if (receivecode != null ? !receivecode.equals(detail.receivecode) : detail.receivecode != null) {
+            return false;
+        }
+        if (receivename != null ? !receivename.equals(detail.receivename) : detail.receivename != null) {
+            return false;
+        }
+        if (money != null ? !money.equals(detail.money) : detail.money != null) {
+            return false;
+        }
+        if (nowmoney != null ? !nowmoney.equals(detail.nowmoney) : detail.nowmoney != null) {
+            return false;
+        }
+        if (factory != null ? !factory.equals(detail.factory) : detail.factory != null) {
+            return false;
+        }
+        if (sendcode != null ? !sendcode.equals(detail.sendcode) : detail.sendcode != null) {
+            return false;
+        }
+        if (whname != null ? !whname.equals(detail.whname) : detail.whname != null) {
+            return false;
+        }
+        if (recorder != null ? !recorder.equals(detail.recorder) : detail.recorder != null) {
+            return false;
+        }
+        if (apCheckDate != null ? !apCheckDate.equals(detail.apCheckDate) : detail.apCheckDate != null) {
+            return false;
+        }
+        if (haveChecked != null ? !haveChecked.equals(detail.haveChecked) : detail.haveChecked != null) {
+            return false;
+        }
+        if (apCheckId != null ? !apCheckId.equals(detail.apCheckId) : detail.apCheckId != null) {
+            return false;
+        }
+        return payment != null ? payment.equals(detail.payment) : detail.payment == null;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = id != null ? id.hashCode() : 0;
+        result = 31 * result + (inoutno != null ? inoutno.hashCode() : 0);
+        result = 31 * result + (detno != null ? detno.hashCode() : 0);
+        result = 31 * result + (piclass != null ? piclass.hashCode() : 0);
+        result = 31 * result + (ordercode != null ? ordercode.hashCode() : 0);
+        result = 31 * result + (orderdetno != null ? orderdetno.hashCode() : 0);
+        result = 31 * result + (prodcode != null ? prodcode.hashCode() : 0);
+        result = 31 * result + (prodspec != null ? prodspec.hashCode() : 0);
+        result = 31 * result + (prodtitle != null ? prodtitle.hashCode() : 0);
+        result = 31 * result + (produnit != null ? produnit.hashCode() : 0);
+        result = 31 * result + (qty != null ? qty.hashCode() : 0);
+        result = 31 * result + (orderprice != null ? orderprice.hashCode() : 0);
+        result = 31 * result + (currency != null ? currency.hashCode() : 0);
+        result = 31 * result + (taxrate != null ? taxrate.hashCode() : 0);
+        result = 31 * result + (ycheckqty != null ? ycheckqty.hashCode() : 0);
+        result = 31 * result + (thischeckqty != null ? thischeckqty.hashCode() : 0);
+        result = 31 * result + (custname != null ? custname.hashCode() : 0);
+        result = 31 * result + (custuu != null ? custuu.hashCode() : 0);
+        result = 31 * result + (custuseruu != null ? custuseruu.hashCode() : 0);
+        result = 31 * result + (sourceid != null ? sourceid.hashCode() : 0);
+        result = 31 * result + (sourcetable != null ? sourcetable.hashCode() : 0);
+        result = 31 * result + (sourceDate != null ? sourceDate.hashCode() : 0);
+        result = 31 * result + (enuu != null ? enuu.hashCode() : 0);
+        result = 31 * result + (pidate != null ? pidate.hashCode() : 0);
+        result = 31 * result + (rate != null ? rate.hashCode() : 0);
+        result = 31 * result + (receivecode != null ? receivecode.hashCode() : 0);
+        result = 31 * result + (receivename != null ? receivename.hashCode() : 0);
+        result = 31 * result + (money != null ? money.hashCode() : 0);
+        result = 31 * result + (nowmoney != null ? nowmoney.hashCode() : 0);
+        result = 31 * result + (factory != null ? factory.hashCode() : 0);
+        result = 31 * result + (sendcode != null ? sendcode.hashCode() : 0);
+        result = 31 * result + (whname != null ? whname.hashCode() : 0);
+        result = 31 * result + (recorder != null ? recorder.hashCode() : 0);
+        result = 31 * result + (apCheckDate != null ? apCheckDate.hashCode() : 0);
+        result = 31 * result + (haveChecked != null ? haveChecked.hashCode() : 0);
+        result = 31 * result + (apCheckId != null ? apCheckId.hashCode() : 0);
+        result = 31 * result + (payment != null ? payment.hashCode() : 0);
+        return result;
+    }
 }

+ 58 - 2
src/main/java/com/uas/platform/b2b/model/PurchaseApCheckItem.java

@@ -199,6 +199,24 @@ public class PurchaseApCheckItem implements Serializable {
 	@Column(name = "pai_sendcode")
 	private String sendcode;
 
+    /**
+     * 送货单明细id
+     */
+    @Column(name = "pai_send_id")
+    private Long sendId;
+
+    /**
+     * 送货数量
+     */
+    @Column(name = "pai_send_qty")
+    private Double sendQty;
+
+    /**
+     * 送货价格
+     */
+    @Column(name = "pai_send_price")
+    private Double sendPrice;
+
 	/**
 	 * 仓库
 	 */
@@ -218,6 +236,12 @@ public class PurchaseApCheckItem implements Serializable {
 	@JoinColumn(name = "pai_paid", nullable = false)
 	private PurchaseApCheck apCheck;
 
+    /**
+     * 付款金额
+     */
+    @Column(name = "pai_payment")
+    private Double payment;
+
 	public Long getId() {
 		return id;
 	}
@@ -444,7 +468,31 @@ public class PurchaseApCheckItem implements Serializable {
 		this.sendcode = sendcode;
 	}
 
-	public String getWhname() {
+    public Long getSendId() {
+        return sendId;
+    }
+
+    public void setSendId(Long sendId) {
+        this.sendId = sendId;
+    }
+
+    public Double getSendQty() {
+        return sendQty;
+    }
+
+    public void setSendQty(Double sendQty) {
+        this.sendQty = sendQty;
+    }
+
+    public Double getSendPrice() {
+        return sendPrice;
+    }
+
+    public void setSendPrice(Double sendPrice) {
+        this.sendPrice = sendPrice;
+    }
+
+    public String getWhname() {
 		return whname;
 	}
 
@@ -460,7 +508,15 @@ public class PurchaseApCheckItem implements Serializable {
 		this.billed = billed;
 	}
 
-	public static List<PurchaseApCheck> distinct(List<PurchaseApCheckItem> items) {
+    public Double getPayment() {
+        return payment;
+    }
+
+    public void setPayment(Double payment) {
+        this.payment = payment;
+    }
+
+    public static List<PurchaseApCheck> distinct(List<PurchaseApCheckItem> items) {
 		List<PurchaseApCheck> purchaseApChecks = new ArrayList<PurchaseApCheck>();
 		Set<Long> keys = new HashSet<>();
 		for (PurchaseApCheckItem item : items) {

+ 59 - 13
src/main/java/com/uas/platform/b2b/model/PurchaseApCheckItemInfo.java

@@ -189,7 +189,25 @@ public class PurchaseApCheckItemInfo implements Serializable {
 	@Column(name = "pai_sendcode")
 	private String sendcode;
 
-	/**
+    /**
+     * 送货单明细id
+     */
+    @Column(name = "pai_send_id")
+    private Long sendId;
+
+    /**
+     * 送货数量
+     */
+    @Column(name = "pai_send_qty")
+    private Double sendQty;
+
+    /**
+     * 送货价格
+     */
+    @Column(name = "pai_send_price")
+    private Double sendPrice;
+
+    /**
 	 * 仓库
 	 */
 	@Column(name = "pai_whname")
@@ -201,6 +219,9 @@ public class PurchaseApCheckItemInfo implements Serializable {
 	@Column(name = "pai_billed")
 	private Double billed;
 
+    /**
+     * 对账主表id
+     */
 	@Column(name = "pai_paid")
 	private Long paid;
 
@@ -211,6 +232,12 @@ public class PurchaseApCheckItemInfo implements Serializable {
 	@JoinColumn(name = "pai_paid", insertable = false, updatable = false)
 	private PurchaseApCheckInfo apCheck;
 
+    /**
+     * 付款金额
+     */
+	@Column(name = "pai_payment")
+    private Double payment;
+
 	public Long getId() {
 		return id;
 	}
@@ -445,7 +472,31 @@ public class PurchaseApCheckItemInfo implements Serializable {
 		this.sendcode = sendcode;
 	}
 
-	public String getWhname() {
+    public Long getSendId() {
+        return sendId;
+    }
+
+    public void setSendId(Long sendId) {
+        this.sendId = sendId;
+    }
+
+    public Double getSendQty() {
+        return sendQty;
+    }
+
+    public void setSendQty(Double sendQty) {
+        this.sendQty = sendQty;
+    }
+
+    public Double getSendPrice() {
+        return sendPrice;
+    }
+
+    public void setSendPrice(Double sendPrice) {
+        this.sendPrice = sendPrice;
+    }
+
+    public String getWhname() {
 		return whname;
 	}
 
@@ -461,16 +512,11 @@ public class PurchaseApCheckItemInfo implements Serializable {
 		this.billed = billed;
 	}
 
-	public static List<PurchaseApCheckInfo> distinct(List<PurchaseApCheckItemInfo> items) {
-		List<PurchaseApCheckInfo> purchaseApChecks = new ArrayList<PurchaseApCheckInfo>();
-		Set<Long> keys = new HashSet<Long>();
-		for (PurchaseApCheckItemInfo item : items) {
-			if (!keys.contains(item.apCheck.getId())) {
-				purchaseApChecks.add(item.apCheck);
-				keys.add(item.apCheck.getId());
-			}
-		}
-		return purchaseApChecks;
-	}
+    public Double getPayment() {
+        return payment;
+    }
 
+    public void setPayment(Double payment) {
+        this.payment = payment;
+    }
 }

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

@@ -260,6 +260,18 @@ public class Vendor implements Serializable {
 	@Transient
     @Getter@Setter private List<ApCheckAmountDetail> amountDetailList;
 
+    /**
+     * 付款记录
+     */
+	@Transient
+    @Getter@Setter private List<ApCheckAmount> paymentList;
+
+    /**
+     * 发货金额
+     */
+	@Transient
+    @Getter@Setter private List<ApCheckAmount> sendAmounts;
+
 	public Long getId() {
 		return id;
 	}

+ 69 - 0
src/main/java/com/uas/platform/b2b/model/util/ProdIoPayCountSqls.java

@@ -0,0 +1,69 @@
+package com.uas.platform.b2b.model.util;
+
+/**
+ * 出入库单付款记录金额统计
+ *
+ * @author hejq
+ * @date 2019-01-04 11:34
+ */
+public class ProdIoPayCountSqls {
+
+    /**
+     * 货款调账付款记录
+     */
+    public static final String ADJUSTMENT_COUNT_SQL = "select sum(coalesce(aa_payment, 0)) as count, aa_currency as currency from purc$apbilladjustment" +
+        " where aa_enuu = ? and aa_custuu = ? and aa_date >= ? and aa_date < ? and coalesce(aa_payment, 0) > 0" +
+        " group by aa_currency, aa_payment";
+
+    /**
+     * 客户采购验收单付款记录
+     */
+    public static final String SALE_ACCEPT_COUNT_SQL = "select sum(coalesce(pai_payment, 0)) as count, pa_currency as currency" +
+        " from purc$accept left join `purc$acceptitem` on pai_paid = pa_id " +
+        " where pa_venduu = ? and pa_enuu = ? and pa_date >= ? and pa_date < ? and coalesce(pai_payment, 0) > 0" +
+        " group by pa_currency, pai_payment";
+
+    /**
+     * 客户采购验退单付款记录
+     */
+    public static final String SALE_RETURN_COUNT_SQL = "select sum(coalesce(pri_payment, 0)) as count, pr_currency as currency " +
+        " from `purc$return` left join `purc$returnitem` on pr_id = pri_prid " +
+        " where pr_venduu = ? and pr_enuu = ? and pr_date >= ? and pr_date < ? and coalesce(pri_payment, 0) > 0 " +
+        " group by pr_currency,pri_payment";
+
+    /**
+     * 客户委外验收单付款记录
+     */
+    public static final String MAKE_ACCEPT_COUNT_SQL = "select sum(coalesce(mai_payment, 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 and ma_date >= ? and ma_date < ? and coalesce(mai_payment, 0) > 0" +
+        " group by ma_currency,mai_payment";
+
+    /**
+     * 客户委外验退单付款记录
+     */
+    public static final String MAKE_RETURN_COUNT_SQL = "select sum(coalesce(mri_payment, 0)) as count, mr_currency as currency" +
+        " from make$return" +
+        " join make$returnitem on mr_id =  mri_paid" +
+        " where mr_venduu = ? and mr_enuu = ? and mri_orderpice > 0 and mr_date >= ? and mr_date < ? and coalesce(mri_payment, 0) > 0" +
+        " group by mr_currency,mri_payment";
+
+    /**
+     * 不良品入库单付款记录
+     */
+    public static final String SALE_BAD_IN_COUNT_SQL = "select sum(pbi_payment) as count, pb_currency as currency" +
+        " from purc$badin" +
+        " join purc$badinitem on pb_id = pbi_pbid" +
+        " where pb_venduu = ? and pb_enuu = ? and pb_date >= ? and pb_date < ? and coalesce(pbi_payment, 0) > 0" +
+        " group by pb_currency, pbi_payment";
+
+    /**
+     * 不良品出库单付款记录
+     */
+    public static final String SALE_BAD_OUT_COUNT_SQL = "select sum(poi_payment) as count, po_currency as currency" +
+        " from purc$badout" +
+        " join purc$badoutitem on po_id = poi_poid" +
+        " where po_venduu = ? and po_enuu = ? and po_date >=? and po_date < ?" +
+        " group by poi_payment,po_currency";
+}

+ 17 - 0
src/main/java/com/uas/platform/b2b/model/util/SendAmountSqls.java

@@ -0,0 +1,17 @@
+package com.uas.platform.b2b.model.util;
+
+/**
+ * 送货单sql
+ *
+ * @author hejq
+ * @date 2019-01-04 14:05
+ */
+public class SendAmountSqls {
+
+    public static final String SALE_ACCEPT_COUNT_SQL = "select sum(si_price * si_price) as count, pa_currency as currency " +
+        "  from purc$accept " +
+        "  left join `purc$acceptitem` on pai_paid = pa_id" +
+        "  left join `sale$senditem` on b2b_si_id = si_id" +
+        "  where  pa_venduu = ? and pa_enuu = ? and pa_date >= ? and pa_date < ? and b2b_si_id is not null" +
+        "  group by si_price * si_price, pa_currency";
+}

+ 1 - 1
src/main/java/com/uas/platform/b2b/publicapi/model/ApCheckAmountDetail.java

@@ -24,7 +24,7 @@ public class ApCheckAmountDetail {
     /**
      * 本期发货
      */
-    private Double thisPeriodSendQty;
+    private String thisPeriodSendQty;
 
     /**
      * 本期未对

+ 21 - 0
src/main/java/com/uas/platform/b2b/service/ErpProdIODetailService.java

@@ -6,6 +6,7 @@ import com.uas.platform.b2b.model.ErpProdIODetail;
 import com.uas.platform.b2b.model.ErpProdIo;
 import com.uas.platform.b2b.model.PurchaseApCheck;
 import com.uas.platform.b2b.model.PurchaseApCheckItemInfo;
+import com.uas.platform.b2b.publicapi.model.ApCheckAmount;
 
 import java.util.List;
 
@@ -79,4 +80,24 @@ public interface ErpProdIODetailService {
      * @param erpProdIo 出入库单信息
      */
     void groupByOrderCode(ErpProdIo erpProdIo);
+
+    /**
+     * 统计付款数据
+     * 1、 根据来源表,id,付款记录去重处理
+     * 2、 将去重后的结果筛选统计
+     *
+     * @param details 查询的详情
+     * @return 统计结果
+     */
+    List<ApCheckAmount> countPayment(List<ErpProdIODetail> details);
+
+    /**
+     * 统计送货金额
+     * 1、 根据来源表,id,送货金额去重处理
+     * 2、 将去重后的结果筛选统计
+     *
+     * @param details 查询的详情
+     * @return 统计结果
+     */
+    List<ApCheckAmount> countSendAmounts(List<ErpProdIODetail> details);
 }

+ 24 - 0
src/main/java/com/uas/platform/b2b/service/PurchaseApCheckService.java

@@ -274,4 +274,28 @@ public interface PurchaseApCheckService {
      * @return 对账结果
      */
     ModelMap checkCount(PurchaseApCheck apCheck);
+
+    /**
+     * 获取付款记录
+     *
+     * @param vendorUU 供应商UU
+     * @param customerUU 客户UU
+     * @param checkDate 对账日期(月份)
+     * @param fromDate 起始时间
+     * @param endDate 截止时间
+     * @return 数据统计
+     */
+    List<ApCheckAmount> getPaymentTrade(Long vendorUU, Long customerUU, String checkDate, Long fromDate, Long endDate);
+
+    /**
+     * 获取发货金额
+     *
+     * @param vendorUU 供应商UU
+     * @param customerUU 客户UU
+     * @param checkDate 对账日期(月份)
+     * @param fromDate 起始时间
+     * @param endDate 截止时间
+     * @return 数据统计
+     */
+    List<ApCheckAmount> getSendAmountTrade(Long vendorUU, Long customerUU, String checkDate, Long fromDate, Long endDate);
 }

+ 94 - 9
src/main/java/com/uas/platform/b2b/service/impl/ErpProdIODetailServiceImpl.java

@@ -38,6 +38,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
@@ -171,21 +172,105 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
                 List<ErpProdIODetail> details = erpProdIo.getDetails().stream()
                     .filter(detail -> StringUtils.isEmpty(detail.getOrdercode())).collect(Collectors.toList());
                 collectOrders(group, details);
+                // 付款记录
+                List<ApCheckAmount> paymentList = countPayment(details);
+                group.setCheckAmountList(paymentList);
+                // 发货记录
+                List<ApCheckAmount> sendAmounts = countSendAmounts(details);
+                group.setSendAmountList(sendAmounts);
             } else {
                 group.setOrderCode(code);
                 // 筛选单号一样的明细
                 List<ErpProdIODetail> details = erpProdIo.getDetails().stream()
                     .filter(detail -> code.equals(detail.getOrdercode())).collect(Collectors.toList());
                 collectOrders(group, details);
+                // 付款记录
+                List<ApCheckAmount> paymentList = countPayment(details);
+                group.setCheckAmountList(paymentList);
+                // 发货记录
+                List<ApCheckAmount> sendAmounts = countSendAmounts(details);
+                group.setSendAmountList(sendAmounts);
             }
             groupList.add(group);
         });
         erpProdIo.setGroupList(groupList);
+        // 统计付款金额
+        List<ApCheckAmount> amountList = countPayment(erpProdIo.getDetails());
+        erpProdIo.setThisPeriodDoneAmount(amountList);
         if (!CollectionUtil.isEmpty(groupList)) {
             erpProdIo.getGroupList().sort(comparing(ProductIoGroup::getAllChecked));
         }
     }
 
+    /**
+     * 统计送货金额
+     * 1、 根据来源表,id,送货金额去重处理
+     * 2、 将去重后的结果筛选统计
+     *
+     * @param details 查询的详情
+     * @return 统计结果
+     */
+    @Override
+    public List<ApCheckAmount> countSendAmounts(List<ErpProdIODetail> details) {
+        List<ApCheckAmount> amountList = new ArrayList<>();
+        if (!CollectionUtil.isEmpty(details)) {
+            List<ErpProdIODetail> filterDetails = details.stream().filter(detail -> null != detail.getSendId() && null != detail.getSendQty() && null != detail.getSendPrice())
+                .collect(Collectors.toList());
+            Set<ErpProdIODetail> ioDetailSet = new HashSet<>();
+            Set<String> currencySet = new HashSet<>();
+            filterDetails.forEach(detail -> {
+                ErpProdIODetail ioDetail = new ErpProdIODetail();
+                ioDetail.setSendId(detail.getSendId());
+                ioDetail.setSendQty(detail.getQty());
+                ioDetail.setSendPrice(detail.getSendPrice());
+                ioDetail.setCurrency(detail.getCurrency());
+                ioDetailSet.add(ioDetail);
+                currencySet.add(ioDetail.getCurrency());
+            });
+            currencySet.forEach(currency -> {
+                Double payment = ioDetailSet.stream().filter(detail -> currency.equals(detail.getCurrency()))
+                    .mapToDouble(detail -> detail.getSendPrice() * detail.getSendQty()).sum();
+                amountList.add(new ApCheckAmount(currency, 100d));
+            });
+        }
+        return amountList;
+    }
+
+    /**
+     * 统计付款数据
+     * 1、 根据来源表,id,付款记录去重处理
+     * 2、 将去重后的结果筛选统计
+     *
+     * @param details 查询的详情
+     * @return 统计结果
+     */
+    @Override
+    public List<ApCheckAmount> countPayment(List<ErpProdIODetail> details) {
+        if (!CollectionUtil.isEmpty(details)) {
+            List<ErpProdIODetail> filterDetails = details.stream().filter(detail -> null != detail.getPayment()).collect(Collectors.toList());
+            Set<ErpProdIODetail> detailSet = new HashSet<>();
+            Set<String> currencySet = new HashSet<>();
+            filterDetails.forEach(detail -> {
+                ErpProdIODetail prodIODetail = new ErpProdIODetail();
+                prodIODetail.setCurrency(detail.getCurrency());
+                prodIODetail.setPayment(detail.getPayment());
+                prodIODetail.setSourcetable(detail.getSourcetable());
+                prodIODetail.setSourceid(detail.getSourceid());
+                detailSet.add(prodIODetail);
+                currencySet.add(detail.getCurrency());
+            });
+            List<ApCheckAmount> amountList = new ArrayList<>();
+            currencySet.forEach(currency -> {
+                Double payment = detailSet.stream().filter(detail -> currency.equals(detail.getCurrency()) && null != detail.getPayment())
+                    .mapToDouble(ErpProdIODetail::getPayment).sum();
+                amountList.add(new ApCheckAmount(currency, 100d));
+            });
+            return amountList;
+        } else {
+            return new ArrayList<>();
+        }
+    }
+
     /**
      * 分组处理数据
      *
@@ -371,7 +456,7 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
                 "mri_whname as whname, mri_ycheckqty as ycheckqty, make$orders.pr_code as prodcode, make$orders.pr_spec as prodspec, " +
                 "make$orders.pr_title as prodtitle, make$orders.pr_unit as produnit, " +
                 "((-(1) *  mri_qty ) - coalesce(mri_ycheckqty, 0)) as thischeckqty, mr_enuu as custuu, ma_useruu custuseruu, mr_venduu as enuu, mri_id as sourceid, " +
-                "mr_sendcode as sendcode, ma_factory as pd_factory, en_name custname from make$return  " +
+                "mr_sendcode as sendcode, ma_factory as pd_factory, en_name custname, mri_payment payment from make$return  " +
                 "join make$returnitem on mr_id =  mri_paid " +
                 "join make$orders on mri_odid = ma_id  " +
                 "left join sec$enterprises on mr_enuu = en_uu " +
@@ -426,7 +511,7 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
                 "make$accept.ma_currency as currency, mai_taxrate as taxrate, mai_whname as whname, mai_ycheckqty as ycheckqty, " +
                 "make$orders.pr_code as prodcode, make$orders.pr_spec as prodspec, make$orders.pr_title as prodtitle, make$orders.pr_unit as produnit, " +
                 "(mai_qty - coalesce(mai_ycheckqty, 0)) as thischeckqty, make$accept.ma_enuu as custuu, make$orders.ma_useruu custuseruu, make$accept.ma_venduu as enuu, " +
-                "mai_id as sourceid, ma_sendcode as sendcode, ma_factory as factory, en_name custname from make$accept " +
+                "mai_id as sourceid, ma_sendcode as sendcode, ma_factory as factory, en_name custname, mai_payment payment from make$accept " +
                 "join make$acceptitem on make$accept.ma_id = mai_paid " +
                 "join make$orders on mai_odid = make$orders.ma_id " +
                 "left join sec$enterprises on make$accept.ma_enuu = en_uu " +
@@ -480,7 +565,7 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
                 "purc$orderitems.pd_number as orderdetno, poi_number as detno, (-(1) * poi_qty ) as qty, 0 as pd_orderprice, po_currency as currency, " +
                 "poi_taxrate as taxrate, poi_whname as whname, poi_ycheckqty as ycheckqty, pr_code as prodcode, pr_spec as prodspec, pr_title as prodtitle, pr_unit as produnit, " +
                 "((-(1) * poi_qty ) - coalesce( poi_ycheckqty, 0)) as thischeckqty, po_enuu as custuu, pu_useruu custuseruu, po_venduu as enuu, poi_id as sourceid, " +
-                "po_sendcode as sendcode, purc$orderitems.pd_factory as factory, en_name custname from purc$badout " +
+                "po_sendcode as sendcode, purc$orderitems.pd_factory as factory, en_name custname, poi_payment payment from purc$badout " +
                 "join purc$badoutitem on po_id = poi_poid  " +
                 "left join purc$orderitems on poi_pdid = pd_id " +
                 "left join purc$orders on pu_id = pd_puid " +
@@ -535,7 +620,7 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
                 "pd_number as orderdetno, pbi_number as detno, pbi_qty as qty, 0 as pd_orderprice, pb_currency as currency, pbi_taxrate as taxrate, " +
                 "pbi_whname as whname, pbi_ycheckqty as ycheckqty, pr_code as prodcode, pr_spec as prodspec, pr_title as prodtitle, pr_unit as produnit, " +
                 "(pbi_qty - coalesce(pbi_ycheckqty, 0)) as thischeckqty, pb_enuu as custuu, pu_useruu custuseruu, pb_venduu as enuu, pbi_id as sourceid, " +
-                "pb_sendcode as sendcode, pd_factory as factory, en_name custname from purc$badin " +
+                "pb_sendcode as sendcode, pd_factory as factory, en_name custname, pbi_payment payment from purc$badin " +
                 "join purc$badinitem on pb_id = pbi_pbid " +
                 "left join purc$orderitems on pbi_pdid = pd_id " +
                 "left join purc$orders on pu_id = pd_puid " +
@@ -590,7 +675,7 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
                 "pri_number as detno, (-(1) * pri_qty ) as qty, pri_orderprice as orderprice, pr_currency as currency, pri_taxrate as taxrate, " +
                 "pri_whname as whname, purc$returnitem.pr_code as prodcode, purc$returnitem.pr_spec as prodspec, purc$returnitem.pr_title as prodtitle, purc$returnitem.pr_unit as produnit, " +
                 "pri_ycheckqty as ycheckqty, ((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) as thischeckqty, pr_enuu as custuu, pu_useruu custuseruu, pr_venduu as enuu, " +
-                "pri_id as sourceid, pr_sendcode as sendcode, pd_factory as factory, en_name custname from purc$return " +
+                "pri_id as sourceid, pr_sendcode as sendcode, pd_factory as factory, en_name custname, pri_payment payment from purc$return " +
                 "join purc$returnitem on pr_id = pri_prid " +
                 "left join purc$orderitems on pri_pdid = pd_id " +
                 "left join purc$orders on pu_id = pd_puid " +
@@ -640,12 +725,12 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
      * @return 客户采购验收单信息
      */
     private List<ErpProdIODetail> getSaleAccepts(StringBuffer distributes, ApcheckKeyWord keyword, String fromDate, String endDate, Long enUU) {
-        StringBuffer sql = new StringBuffer("select pa_code as inoutno, pa_date as pidate, pa_rate as rate, pa_receivecode as receivcode, " +
-                "pa_receivename as receivename, '客户采购验收单' as piclass, 'purc$acceptitem' as sourcetable, pu_code as ordercode, " +
+        StringBuffer sql = new StringBuffer("select pa_code as inoutno, pa_date as pidate, pa_rate as rate, pa_receivecode as receivcode, pa_receivename as receivename, '客户采购验收单' as piclass, 'purc$acceptitem' as sourcetable, pu_code as ordercode, " +
                 "pd_number as orderdetno, pai_number as detno, pai_qty as qty, pai_orderprice as orderprice, pa_currency as currency, " +
                 "pai_taxrate as taxrate,  pai_whname as whname, purc$acceptitem.pr_code as prodcode, purc$acceptitem.pr_spec as prodspec, purc$acceptitem.pr_unit as produnit, " +
                 "purc$acceptitem.pr_title as prodtitle, pai_ycheckqty as ycheckqty, (pai_qty - coalesce(pai_ycheckqty, 0)) as thischeckqty, " +
-                "pa_enuu as custuu, pu_useruu custuseruu, pa_venduu as enuu, pai_id as sourceid, pa_sendcode as sendcode, pd_factory as factory, en_name custname from purc$accept " +
+                "pa_enuu as custuu, pu_useruu custuseruu, pa_venduu as enuu, pai_id as sourceid, pa_sendcode as sendcode, pd_factory as factory, en_name custname," +
+                " pai_payment payment from purc$accept " +
                 "join purc$acceptitem on pai_paid = pa_id " +
                 "left join purc$orderitems on pai_pdid = pd_id " +
                 "left join purc$orders on purc$orders.pu_id = pd_puid " +
@@ -700,7 +785,7 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
                 "aa_orderdetno orderdetno, aa_detno detno, aa_prid prid, aa_prodcode prodcode, aa_prodspec prodspec, aa_prodtitle prodtitle, aa_produnit as produnit, " +
                 "aa_qty qty, aa_orderprice orderprice, aa_currency currency, aa_taxrate taxrate, aa_whname whname, aa_ycheckqty ycheckqty, " +
                 "(aa_qty - coalesce(aa_ycheckqty, 0)) as thischeckqty, aa_custuu custuu, aa_custuseruu custuseruu, aa_enuu enuu, aa_id sourceid, aa_sendcode sendcode, " +
-                "aa_factory factory, aa_custname custname from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ").append(enUU).append(" ");
+                "aa_factory factory, aa_custname custname, aa_payment payment from purc$apbilladjustment where coalesce(aa_thischeckqty, 0) <> 0 and aa_enuu = ").append(enUU).append(" ");
         if (!StringUtils.isEmpty(keyword.getReceiveName())) {
             sql.append("and aa_receivename = '").append(keyword.getReceiveName()).append("' ");
         }

+ 96 - 12
src/main/java/com/uas/platform/b2b/service/impl/PurchaseApCheckServiceImpl.java

@@ -30,6 +30,8 @@ import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.model.util.ApCheckAllCountSqls;
 import com.uas.platform.b2b.model.util.ApCheckDoneCountSqls;
 import com.uas.platform.b2b.model.util.ApCheckTodoCountSqls;
+import com.uas.platform.b2b.model.util.ProdIoPayCountSqls;
+import com.uas.platform.b2b.model.util.SendAmountSqls;
 import com.uas.platform.b2b.publicapi.model.ApCheckAmount;
 import com.uas.platform.b2b.publicapi.model.ApCheckAmountDetail;
 import com.uas.platform.b2b.service.ErpProdIODetailService;
@@ -342,8 +344,8 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
 	        commonDao.getJdbcTemplate().batchUpdate("insert into purc$apcheckitem(pai_number, pai_custuseruu, pai_prid, pai_ordercode,pai_orderclass, " +
                 "pai_orderdetno, pai_inoutno, pai_inoutnodetno, pai_prodcode, pai_prodtitle, pai_prodspec, pai_produnit, pai_price,pai_taxrate, pai_checkqty, " +
                 "pai_amount, pai_custcheckqty, pai_remark, pai_status, pai_sourcetable, pai_sourceid, pai_source_date, pai_oldycheckqty, pai_receivecode, pai_receivename, " +
-                "pai_sendcode, pai_whname, pai_billed, pai_paid) " +
-                "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+                "pai_sendcode, pai_whname, pai_billed, pai_paid, pai_payment) " +
+                "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
                 items, items.size(), (pa, i) -> {
 	                pa.setObject(1, num[0]++);
                     pa.setObject(2, i.getCustUserUU());
@@ -376,6 +378,7 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
                     pa.setObject(27, i.getWhname());
                     pa.setObject(28, i.getBilled());
                     pa.setObject(29, apCheckId);
+                    pa.setObject(30, i.getPayment());
                 });
         }
     }
@@ -641,17 +644,79 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
             customer.setThisMonthCount(thisMonthTrades);
             // 总额存在再进行其他查询
             if (!CollectionUtils.isEmpty(thisMonthTrades)) {
-                // 本月应收(未
+                // 本月应收(未对账
                 List<ApCheckAmount> thisMonthTodoTrades = getThisMonthTodoTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
                 customer.setThisMonthTodoCount(thisMonthTodoTrades);
-                // 本月应收(已
+                // 本月应收(已对账
                 List<ApCheckAmount> thisMonthDoneTrades = getThisMonthDoneTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
                 customer.setThisMonthDoneCount(thisMonthDoneTrades);
+                // 本期付款记录
+                List<ApCheckAmount> paymentList = this.getPaymentTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
+                customer.setPaymentList(paymentList);
+                // 本期发货金额
+                List<ApCheckAmount> sendAmounts = this.getSendAmountTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
+                customer.setSendAmounts(sendAmounts);
             }
             setAmountDetail(customer);
         }
     }
 
+    /**
+     * 获取发货金额
+     *
+     * @param vendorUU   供应商UU
+     * @param customerUU 客户UU
+     * @param checkDate  对账日期(月份)
+     * @param fromDate   起始时间
+     * @param endDate    截止时间
+     * @return 数据统计
+     */
+    @Override
+    public List<ApCheckAmount> getSendAmountTrade(Long vendorUU, Long customerUU, String checkDate, Long fromDate, Long endDate) {
+        DateFilter filter = erpProdIODetailService.initFilter(fromDate, endDate, checkDate);
+        // 目前只有采购验收单关联送货单
+        List<ApCheckAmount> sendAmounts = commonDao.query(SendAmountSqls.SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        return groupCountByCurrency(sendAmounts);
+    }
+
+    /**
+     * 获取付款记录
+     *
+     * @param vendorUU   供应商UU
+     * @param customerUU 客户UU
+     * @param checkDate  对账日期(月份)
+     * @param fromDate   起始时间
+     * @param endDate    截止时间
+     * @return 数据统计
+     */
+    @Override
+    public List<ApCheckAmount> getPaymentTrade(Long vendorUU, Long customerUU, String checkDate, Long fromDate, Long endDate) {
+        DateFilter filter = erpProdIODetailService.initFilter(fromDate, endDate, checkDate);
+        List<ApCheckAmount> totalTrades = new ArrayList<>();
+        // 货款调账
+        List<ApCheckAmount> trades = commonDao.query(ProdIoPayCountSqls.ADJUSTMENT_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        totalTrades.addAll(trades);
+        // 采购验收
+        List<ApCheckAmount> saleAcceptTrades = commonDao.query(ProdIoPayCountSqls.SALE_ACCEPT_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        totalTrades.addAll(saleAcceptTrades);
+        // 采购验退
+        List<ApCheckAmount> saleReturnTrades = commonDao.query(ProdIoPayCountSqls.SALE_RETURN_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        totalTrades.addAll(saleReturnTrades);
+        // 委外验收
+        List<ApCheckAmount> makeAcceptTrades = commonDao.query(ProdIoPayCountSqls.MAKE_ACCEPT_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        totalTrades.addAll(makeAcceptTrades);
+        // 委外验退
+        List<ApCheckAmount> makeReturnTrades = commonDao.query(ProdIoPayCountSqls.MAKE_RETURN_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        totalTrades.addAll(makeReturnTrades);
+        // 不良品出库
+        List<ApCheckAmount> saleBadOutTrades = commonDao.query(ProdIoPayCountSqls.SALE_BAD_OUT_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        totalTrades.addAll(saleBadOutTrades);
+        // 不良品入库
+        List<ApCheckAmount> saleBadInTrades = commonDao.query(ProdIoPayCountSqls.SALE_BAD_IN_COUNT_SQL, ApCheckAmount.class, vendorUU, customerUU, filter.getFromDate(), filter.getEndDate());
+        totalTrades.addAll(saleBadInTrades);
+        return groupCountByCurrency(totalTrades);
+    }
+
     /**
      * 设置对账明细数据
      *
@@ -665,30 +730,49 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
         List<ApCheckAmountDetail> detailList = new ArrayList<>();
         currencySet.forEach(currency -> {
             ApCheckAmountDetail detail = new ApCheckAmountDetail();
+            // 本月应收
             if (!StringUtils.isEmpty(customer.getThisMonthCount())) {
                 List<String> thisPeriodAmount = customer.getThisMonthCount().stream()
                     .filter(count -> currency.equals(count.getCurrency()))
                     .map(ApCheckAmount::getAmount).collect(Collectors.toList());
                 detail.setThisPeriodAmount(thisPeriodAmount.size() > 0 ? thisPeriodAmount.get(0) : null);
             }
+            // 本期应收存在再处理后续
             if (!StringUtils.isEmpty(detail.getThisPeriodAmount())) {
                 List<String> totalAmount = customer.getTotalCount().stream()
                     .filter(count -> currency.equals(count.getCurrency()))
                     .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                // 应收总额
                 detail.setTotalAmount(totalAmount.size() > 0 ? totalAmount.get(0) : null);
                 detail.setCurrency(currency);
                 if (!StringUtils.isEmpty(customer.getThisMonthTodoCount())) {
                     List<String> thisPeriodTodoAmount = customer.getThisMonthTodoCount().stream()
                         .filter(count -> currency.equals(count.getCurrency()))
                         .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                    // 本期应收
                     detail.setThisPeriodTodoAmount(thisPeriodTodoAmount.size() > 0 ? thisPeriodTodoAmount.get(0) : null);
                 }
                 if (!StringUtils.isEmpty(customer.getThisMonthDoneCount())) {
                     List<String> thisPeriodDoneAmount = customer.getThisMonthDoneCount().stream()
                         .filter(count -> currency.equals(count.getCurrency()))
                         .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                    // 本期已对账
                     detail.setThisPeriodDoneAmount(thisPeriodDoneAmount.size() > 0 ? thisPeriodDoneAmount.get(0) : null);
                 }
+                // 本期付款记录
+                if (!CollectionUtils.isEmpty(customer.getPaymentList())) {
+                    List<String> paymentList = customer.getPaymentList().stream()
+                        .filter(count -> currency.equals(count.getCurrency()))
+                        .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                    detail.setThisPeriodReceipt(paymentList.size() > 0 ? paymentList.get(0) : null);
+                }
+                // 本期发货金额
+                if (!CollectionUtils.isEmpty(customer.getSendAmounts())) {
+                    List<String> sendAmounts = customer.getSendAmounts().stream()
+                        .filter(count -> currency.equals(count.getCurrency()))
+                        .map(ApCheckAmount::getAmount).collect(Collectors.toList());
+                    detail.setThisPeriodSendQty(sendAmounts.size() > 0 ? sendAmounts.get(0) : null);
+                }
                 detailList.add(detail);
             }
         });
@@ -1045,15 +1129,15 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
      */
     @Override
     public ModelMap checkCount(PurchaseApCheck apCheck) {
-        if (apCheck != null) {
-            // 针对当前对账数据进行校验操作
-            enableCheck(apCheck.getItems());
-            apCheck = this.save(apCheck);
-            LOGGER.log("应收对账单", "多个单据生成同一张应收对账单", apCheck.getRemark(), null, apCheck.getId());
-            return new ModelMap("id", apCheck.getId());
+        if (null == apCheck) {
+            LOGGER.log("应收对账单", "生成对账单失败,未选择对账数据");
+            throw new IllegalOperatorException("保存失败!");
         }
-        LOGGER.log("应收对账单", "生成对账单失败,未选择对账数据");
-        throw new IllegalOperatorException("保存失败!");
+        // 针对当前对账数据进行校验操作
+        enableCheck(apCheck.getItems());
+        apCheck = this.save(apCheck);
+        LOGGER.log("应收对账单", "多个单据生成同一张应收对账单", apCheck.getRemark(), null, apCheck.getId());
+        return new ModelMap("id", apCheck.getId());
     }
 
     /**

+ 6 - 1
src/main/webapp/resources/tpl/index/fa/apCheck.html

@@ -804,7 +804,12 @@
 											<span>合计:</span>
 											验收数量:<span>{{check.checkQty >= 0 ? (check.checkQty | number:2) :'暂无数据'}}</span>
 											发货数量:<span>{{check.sendQty >= 0 ? (check.sendQty | number:2) : '暂无数据'}}</span>
-											应收金额:<span>{{check.checkAmountList >= 0 ? (check.checkAmountList | number: 2) : '暂无数据'}}</span>
+											应收金额:<span ng-if="check.checkAmountList.length > 0" ng-repeat="count in check.checkAmountList">
+                                                        <em>{{count.currency}}: {{count.amount}}</em>
+                                                    </span>
+                                                    <span ng-if="check.checkAmountList.length == 0">
+                                                        暂无数据
+                                                    </span>
 											发货金额:<span>{{check.sendAmountList >= 0 ? (check.sendAmountList | number: 2) : '暂无数据'}}</span>
 										</div>
 										<a ng-show="check.showDetail" class="order-count-click" ng-click="check.showDetail = !check.showDetail">收起 <i class="fa fa-angle-up"></i></a>