|
|
@@ -165,6 +165,7 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
PurchaseApCheck check = purchaseApCheckDao.findOne(id);
|
|
|
if (check != null) {
|
|
|
if (!CollectionUtils.isEmpty(check.getItems()) && check.getCheckStatus().equals("不同意")) {
|
|
|
+ List<String> sqls = new ArrayList<>();
|
|
|
for (PurchaseApCheckItem item : check.getItems()) {
|
|
|
item.setCheckQty(0.0);
|
|
|
Double newYCheckQtyVal = item.getOldYCheckQty();
|
|
|
@@ -201,8 +202,17 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
}
|
|
|
String sql = "update " + sourceTable + " set " + yCheckQtyName + " = " + newYCheckQtyVal + " where "
|
|
|
+ idName + " = " + sourceIdVal;
|
|
|
- commonDao.getJdbcTemplate().execute(sql);
|
|
|
+ sqls.add(sql);
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(sqls)) {
|
|
|
+ try {
|
|
|
+ commonDao.getJdbcTemplate().batchUpdate(sqls.toArray(new String[sqls.size()]));
|
|
|
+ } catch (RuntimeException e) {
|
|
|
+ System.out.println("生成对账单批量更新来源数据失败: " + e.getMessage());
|
|
|
+ throw new IllegalOperatorException("保存失败!");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
check.setCheckStatus("已作废");
|
|
|
purchaseApCheckDao.save(check);
|
|
|
@@ -224,6 +234,7 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
@Override
|
|
|
public void updateYCheckQty(List<HashMap<String, Object>> list) {
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ List<String> sqls = new ArrayList<>();
|
|
|
for (HashMap<String, Object> map : list) {
|
|
|
Set<String> keySet = map.keySet();
|
|
|
Double newYCheckQtyVal = null;
|
|
|
@@ -264,9 +275,15 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
}
|
|
|
String sql = "update " + sourceTable + " set " + yCheckQtyName + " = " + newYCheckQtyVal + " where "
|
|
|
+ idName + " = " + sourceIdVal;
|
|
|
- commonDao.getJdbcTemplate().execute(sql);
|
|
|
-
|
|
|
+ sqls.add(sql);
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(sqls)) {
|
|
|
+ try {
|
|
|
+ commonDao.getJdbcTemplate().batchUpdate(sqls.toArray(new String[sqls.size()]));
|
|
|
+ } catch (RuntimeException e) {
|
|
|
+ System.out.println("生成对账单批量更新来源数据失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -329,15 +346,21 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
}
|
|
|
updateSourceInfo(sources);
|
|
|
items = purchaseApCheckItemDao.save(items);
|
|
|
- // TODO 把items转成主记录的形式
|
|
|
List<PurchaseApCheck> apChecks = new ArrayList<>();
|
|
|
apChecks.add(items.get(0).getApCheck());
|
|
|
saveUserOrders(apChecks);
|
|
|
return purchaseApCheck;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新来源表数据
|
|
|
+ *
|
|
|
+ * @param list 来源库信息
|
|
|
+ * @return 保存结果
|
|
|
+ */
|
|
|
public boolean updateSourceInfo(List<SourceForApcheck> list) {
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ List<String> sqls = new ArrayList<>();
|
|
|
for (SourceForApcheck source : list) {
|
|
|
if (source.hasInfo()) {
|
|
|
String idName = null;
|
|
|
@@ -366,12 +389,18 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
}
|
|
|
String sql = "update " + source.getSourcetable() + " set " + yCheckQtyName + " = "
|
|
|
+ source.getNewYCheckQty() + " where " + idName + " = " + source.getSourceid();
|
|
|
- commonDao.getJdbcTemplate().execute(sql);
|
|
|
- } else {
|
|
|
- throw new IllegalOperatorException("保存失败!");
|
|
|
+ sqls.add(sql);
|
|
|
}
|
|
|
}
|
|
|
- return true;
|
|
|
+ if (!CollectionUtils.isEmpty(sqls)) {
|
|
|
+ try {
|
|
|
+ commonDao.getJdbcTemplate().batchUpdate(sqls.toArray(new String[sqls.size()]));
|
|
|
+ } catch (RuntimeException e) {
|
|
|
+ System.out.println("生成对账单批量更新来源数据失败: " + e.getMessage());
|
|
|
+ throw new IllegalOperatorException("保存失败!");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
throw new IllegalOperatorException("保存失败!");
|
|
|
}
|
|
|
@@ -683,21 +712,23 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<ApCheckAmount> groupCountByCurrency(List<ApCheckAmount> totalTrades) {
|
|
|
- Double rmbCount = totalTrades.stream().filter(tradeCount -> RMB.equals(tradeCount.getCurrency()))
|
|
|
- .mapToDouble(ApCheckAmount::getCount).sum();
|
|
|
- Double usdCount = totalTrades.stream().filter(tradeCount -> USD.equals(tradeCount.getCurrency()))
|
|
|
- .mapToDouble(ApCheckAmount::getCount).sum();
|
|
|
- Double hkdCount = totalTrades.stream().filter(tradeCount -> HKD.equals(tradeCount.getCurrency()))
|
|
|
- .mapToDouble(ApCheckAmount::getCount).sum();
|
|
|
List<ApCheckAmount> resultCounts = new ArrayList<>();
|
|
|
- if (rmbCount > 0) {
|
|
|
- resultCounts.add(new ApCheckAmount(RMB, DecimalUtils.decimalPoint(rmbCount, 2)));
|
|
|
- }
|
|
|
- if (usdCount > 0) {
|
|
|
- resultCounts.add(new ApCheckAmount(USD, DecimalUtils.decimalPoint(usdCount, 2)));
|
|
|
- }
|
|
|
- if (hkdCount > 0) {
|
|
|
- resultCounts.add(new ApCheckAmount(HKD, DecimalUtils.decimalPoint(hkdCount, 2)));
|
|
|
+ if (null != totalTrades && !CollectionUtils.isEmpty(totalTrades)) {
|
|
|
+ Double rmbCount = totalTrades.stream().filter(tradeCount -> null != tradeCount && RMB.equals(tradeCount.getCurrency()))
|
|
|
+ .mapToDouble(ApCheckAmount::getCount).sum();
|
|
|
+ Double usdCount = totalTrades.stream().filter(tradeCount -> null != tradeCount && USD.equals(tradeCount.getCurrency()))
|
|
|
+ .mapToDouble(ApCheckAmount::getCount).sum();
|
|
|
+ Double hkdCount = totalTrades.stream().filter(tradeCount -> null != tradeCount && HKD.equals(tradeCount.getCurrency()))
|
|
|
+ .mapToDouble(ApCheckAmount::getCount).sum();
|
|
|
+ if (rmbCount > 0) {
|
|
|
+ resultCounts.add(new ApCheckAmount(RMB, DecimalUtils.decimalPoint(rmbCount, 2)));
|
|
|
+ }
|
|
|
+ if (usdCount > 0) {
|
|
|
+ resultCounts.add(new ApCheckAmount(USD, DecimalUtils.decimalPoint(usdCount, 2)));
|
|
|
+ }
|
|
|
+ if (hkdCount > 0) {
|
|
|
+ resultCounts.add(new ApCheckAmount(HKD, DecimalUtils.decimalPoint(hkdCount, 2)));
|
|
|
+ }
|
|
|
}
|
|
|
return resultCounts;
|
|
|
}
|
|
|
@@ -841,6 +872,7 @@ public class PurchaseApCheckServiceImpl implements PurchaseApCheckService {
|
|
|
totalTrades.addAll(trades);
|
|
|
threadsSignal.countDown();
|
|
|
});
|
|
|
+ threadsSignal.await();
|
|
|
return groupCountByCurrency(totalTrades);
|
|
|
}
|
|
|
}
|