Browse Source

perf(购物车): 增大获取购物车时间打印。

yuj 7 years ago
parent
commit
d84c587914

+ 9 - 0
src/main/java/com/uas/platform/b2c/trade/presale/service/impl/CartServiceImpl.java

@@ -417,6 +417,7 @@ public class CartServiceImpl implements CartService {
 //		info.sorting("id", Sort.Direction.DESC);
 		info.sorting(Sort.Direction.DESC, "storeUuid", "id");
 		// 获取当前页的购物车记录信息
+		long l = System.currentTimeMillis();
 		Page<Cart> carts = cartDao.findAll(new Specification<Cart>() {
 			@Override
 			public Predicate toPredicate(Root<Cart> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
@@ -424,6 +425,8 @@ public class CartServiceImpl implements CartService {
 				return null;
 			}
 		}, info);
+		long l1 = System.currentTimeMillis();
+		System.out.println((l1 - l) + "获取时间购物车时间");
 		// 将购物车记录按店铺进行分类
 
 		if (!CollectionUtils.isEmpty(carts.getContent())) {
@@ -449,7 +452,10 @@ public class CartServiceImpl implements CartService {
 		//从历史库存中获取上架信息
 		List<Long> historyIds = goodsHistoryDao.findMaxIdByBatchCodes(batchCodes);
 		if (org.apache.commons.collections.CollectionUtils.isNotEmpty(historyIds)) {
+			long l = System.currentTimeMillis();
 			List<GoodsHistory> histories = goodsHistoryDao.findAll(historyIds);
+			long l1 = System.currentTimeMillis();
+			System.out.println((l1 - l) + "获取历史库存时间");
 			for (GoodsHistory history : histories) {
 				for (Cart cart : carts) {
 					if (cart.getBatchCode().equals(history.getBatchCode())) {
@@ -479,7 +485,10 @@ public class CartServiceImpl implements CartService {
 		String sql = "select cmp_code, go_batchcode from trade$goods where cmp_code in (:codes) and go_status = " + com.uas.platform.b2c.core.constant.Status.AVAILABLE.value();
 		Map<String, Object> codeMaps = new HashMap<>();
 		codeMaps.put("codes", codes);
+		long l = System.currentTimeMillis();
 		List<Map<String, Object>> maps = namedParameterJdbcTemplate.queryForList(sql, codeMaps);
+		long l1 = System.currentTimeMillis();
+		System.out.println((l1 - l) + "获取相似产品时间");
 		for (Map<String, Object> numMap : maps) {
 			Object code = numMap.get("cmp_code");
 			for (Cart cart : carts) {