|
|
@@ -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("' ");
|
|
|
}
|