|
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.platform.b2b.core.util.BoundedExecutor;
|
|
|
import com.uas.platform.b2b.core.util.DateFormatUtils;
|
|
|
import com.uas.platform.b2b.core.util.DateUtils;
|
|
|
+import com.uas.platform.b2b.core.util.StringUtil;
|
|
|
import com.uas.platform.b2b.core.util.ThreadUtils;
|
|
|
import com.uas.platform.b2b.dao.CommonDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseApCheckItemInfoDao;
|
|
|
@@ -165,37 +166,18 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
|
|
|
List<ProductIoGroup> groupList = new ArrayList<>();
|
|
|
codeSet.forEach(code -> {
|
|
|
ProductIoGroup group = new ProductIoGroup();
|
|
|
- group.setOrderCode(code);
|
|
|
- // 筛选单号一样的明细
|
|
|
- List<ErpProdIODetail> details = erpProdIo.getDetails().parallelStream()
|
|
|
- .filter(detail -> code.equals(detail.getOrdercode())).collect(Collectors.toList());
|
|
|
- for (ErpProdIODetail detail : details) {
|
|
|
- if (Constant.NO == detail.getHaveChecked()) {
|
|
|
- group.setAllChecked(Constant.NO);
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
+ group.setOrderCode("");
|
|
|
+ List<ErpProdIODetail> details = erpProdIo.getDetails().stream()
|
|
|
+ .filter(detail -> StringUtils.isEmpty(detail.getOrdercode())).collect(Collectors.toList());
|
|
|
+ collectOrders(group, details);
|
|
|
+ } else {
|
|
|
+ group.setOrderCode(code);
|
|
|
+ // 筛选单号一样的明细
|
|
|
+ List<ErpProdIODetail> details = erpProdIo.getDetails().stream()
|
|
|
+ .filter(detail -> code.equals(detail.getOrdercode())).collect(Collectors.toList());
|
|
|
+ collectOrders(group, details);
|
|
|
}
|
|
|
- group.setDetails(details);
|
|
|
- // 统计发货数量
|
|
|
- Double sendQty = details.stream().mapToDouble(ErpProdIODetail::getQty).sum();
|
|
|
- group.setSendQty(sendQty);
|
|
|
- // 统计对账数量
|
|
|
- Double checkQty = details.stream().mapToDouble(ErpProdIODetail::getThischeckqty).sum();
|
|
|
- group.setCheckQty(checkQty);
|
|
|
- // 明细筛选币别
|
|
|
- Set<String> currencySet = details.stream().map(ErpProdIODetail::getCurrency).collect(Collectors.toSet());
|
|
|
- // 根据币别统计金额
|
|
|
- currencySet.forEach(currency -> {
|
|
|
- List<ApCheckAmount> amounts = new ArrayList<>();
|
|
|
- Double amount = details.stream().filter(tradeCount -> null != tradeCount && currency.equals(tradeCount.getCurrency()))
|
|
|
- .mapToDouble(ErpProdIODetail::getMoney).sum();
|
|
|
- if (amount > 0) {
|
|
|
- amounts.add(new ApCheckAmount(currency, DecimalUtils.decimalPoint(amount, 2)));
|
|
|
- }
|
|
|
- group.setCheckAmountList(amounts);
|
|
|
- });
|
|
|
- // 按照是否已对账排序
|
|
|
- group.getDetails().sort(comparing(ErpProdIODetail::getHaveChecked));
|
|
|
groupList.add(group);
|
|
|
});
|
|
|
erpProdIo.setGroupList(groupList);
|
|
|
@@ -204,6 +186,42 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分组处理数据
|
|
|
+ *
|
|
|
+ * @param group 应收对账明细单据分组
|
|
|
+ * @param details 筛选后的数据
|
|
|
+ */
|
|
|
+ private void collectOrders(ProductIoGroup group, List<ErpProdIODetail> details) {
|
|
|
+ for (ErpProdIODetail detail : details) {
|
|
|
+ if (Constant.NO == detail.getHaveChecked()) {
|
|
|
+ group.setAllChecked(Constant.NO);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ group.setDetails(details);
|
|
|
+ // 统计发货数量
|
|
|
+ Double sendQty = details.stream().mapToDouble(ErpProdIODetail::getQty).sum();
|
|
|
+ group.setSendQty(sendQty);
|
|
|
+ // 统计对账数量
|
|
|
+ Double checkQty = details.stream().mapToDouble(ErpProdIODetail::getThischeckqty).sum();
|
|
|
+ group.setCheckQty(checkQty);
|
|
|
+ // 明细筛选币别
|
|
|
+ Set<String> currencySet = details.stream().map(ErpProdIODetail::getCurrency).collect(Collectors.toSet());
|
|
|
+ // 根据币别统计金额
|
|
|
+ currencySet.forEach(currency -> {
|
|
|
+ List<ApCheckAmount> amounts = new ArrayList<>();
|
|
|
+ Double amount = details.stream().filter(tradeCount -> null != tradeCount && currency.equals(tradeCount.getCurrency()))
|
|
|
+ .mapToDouble(ErpProdIODetail::getMoney).sum();
|
|
|
+ if (amount > 0) {
|
|
|
+ amounts.add(new ApCheckAmount(currency, DecimalUtils.decimalPoint(amount, 2)));
|
|
|
+ }
|
|
|
+ group.setCheckAmountList(amounts);
|
|
|
+ });
|
|
|
+ // 按照是否已对账排序
|
|
|
+ group.getDetails().sort(comparing(ErpProdIODetail::getHaveChecked));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设置对账金额信息
|
|
|
*
|