|
|
@@ -147,6 +147,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
@@ -164,8 +165,11 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.Callable;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
+import java.util.concurrent.Future;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
@@ -3526,7 +3530,25 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setSelfSale(StringConstant.SALE_SELF);
|
|
|
}
|
|
|
goods.setFrozen(getFrozenCount(goods.getBatchCode()));
|
|
|
- goods.setMaxPriceIndex(goods.getPrices().size() - 1);
|
|
|
+ List<GoodsQtyPrice> prices = goods.getPrices();
|
|
|
+ if (CollectionUtils.isNotEmpty(prices)) {
|
|
|
+ int size = prices.size();
|
|
|
+ StringBuffer gradeBuffer = new StringBuffer();
|
|
|
+ StringBuffer priceBuffer = new StringBuffer();
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ if (gradeBuffer.length() > 0) {
|
|
|
+ gradeBuffer.append("\n");
|
|
|
+ priceBuffer.append("\n");
|
|
|
+ }
|
|
|
+ String priceEnd = i + 1 == size ? "以上" : prices.get(i).getEnd().toString();
|
|
|
+ gradeBuffer.append(prices.get(i).getStart()).append("-").append(priceEnd);
|
|
|
+ String currencyName = StringConstant.RMB.equals(goods.getCurrencyName()) ? "¥" : "$";
|
|
|
+ Double price = StringConstant.RMB.equals(goods.getCurrencyName()) ? prices.get(i).getRMBPrice() : prices.get(i).getUSDPrice();
|
|
|
+ priceBuffer.append(currencyName).append(price);
|
|
|
+ }
|
|
|
+ goods.setPriceGradeStr(gradeBuffer.toString());
|
|
|
+ goods.setPriceStr(priceBuffer.toString());
|
|
|
+ }
|
|
|
}
|
|
|
return page;
|
|
|
}
|
|
|
@@ -4127,4 +4149,81 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
return new com.uas.sso.support.Page<>(pageable.getPageNumber(), pageable.getPageSize(), kindList, count);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导出数据
|
|
|
+ * TODO 后续提成公共方法,暂时没写好
|
|
|
+ *
|
|
|
+ * @param info 分页信息
|
|
|
+ * @param goodsFilter 过滤条件
|
|
|
+ * @return List<Goods>
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Goods> multiSearch(PageInfo info, GoodsFilter goodsFilter) {
|
|
|
+ List<Goods> goodsList = new ArrayList<>();
|
|
|
+ List<Future<List<Goods>>> futureList = new ArrayList<>();
|
|
|
+ BigDecimal pageSize = new BigDecimal(info.getPageSize());
|
|
|
+ BigDecimal pageCount = new BigDecimal(com.uas.platform.b2c.core.constant.IntegerConstant.PAGE_COUNT);
|
|
|
+ int maxPoolSize = (int) Math.ceil(pageSize.divide(pageCount).doubleValue());
|
|
|
+ ExecutorService exs = Executors.newFixedThreadPool(maxPoolSize);
|
|
|
+ for (int i = 0; i < maxPoolSize; i++) {
|
|
|
+ futureList.add(exs.submit(new CallableTask(i + 1, goodsFilter, info.getPageSize())));
|
|
|
+ }
|
|
|
+ for (Future<List<Goods>> future : futureList) {
|
|
|
+ while (true) {
|
|
|
+ if (future.isDone() && !future.isCancelled()) {
|
|
|
+ List<Goods> goods = null;
|
|
|
+ try {
|
|
|
+ goods = future.get();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (ExecutionException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ goodsList.addAll(goods);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return goodsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private class CallableTask implements Callable<List<Goods>> {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 线程序号
|
|
|
+ */
|
|
|
+ Integer i;
|
|
|
+ /**
|
|
|
+ * 过滤条件
|
|
|
+ */
|
|
|
+ GoodsFilter goodsFilter;
|
|
|
+ /**
|
|
|
+ * 分页大小
|
|
|
+ */
|
|
|
+ Integer pageSize;
|
|
|
+
|
|
|
+ public CallableTask(int i, GoodsFilter goodsFilter, int pageSize) {
|
|
|
+ super();
|
|
|
+ this.i = i;
|
|
|
+ this.goodsFilter = goodsFilter;
|
|
|
+ this.pageSize = pageSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Computes a result, or throws an exception if unable to do so.
|
|
|
+ *
|
|
|
+ * @return computed result
|
|
|
+ * @throws Exception if unable to compute a result
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Goods> call() throws Exception {
|
|
|
+ int count = pageSize > com.uas.platform.b2c.core.constant.IntegerConstant.PAGE_COUNT ?
|
|
|
+ com.uas.platform.b2c.core.constant.IntegerConstant.PAGE_COUNT : pageSize;
|
|
|
+ PageInfo info = new PageInfo(i, count);
|
|
|
+ List<Goods> goods = getPageDataOfBackground(info, goodsFilter).getContent();
|
|
|
+ return goods;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|