Browse Source

修改供应商资源物料列表查询方法,处理数据量较大时,加载慢的问题。

dongbw 7 years ago
parent
commit
37a691c8a3

+ 3 - 9
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -258,12 +258,12 @@ public class ProductServiceImpl implements ProductService {
     @Override
     public Page<V_ProductPrivate> getAllProducts(final PageInfo page, String keyword, String type, Long userUU) {
         Long enUU = SystemSession.getUser().getEnterprise().getUu();
-//        page.expression(PredicateUtils.eq("enUU", enuu, true));
-//        page.expression(PredicateUtils.isNotNull("pcmpcode"));
-//        page.expression(PredicateUtils.isNotNull("pbranden"));
         if (StringUtils.isEmpty(type)) {
             type = "nStandard";
         }
+//        page.expression(PredicateUtils.eq("enUU", enuu, true));
+//        page.expression(PredicateUtils.isNotNull("pcmpcode"));
+//        page.expression(PredicateUtils.isNotNull("pbranden"));
 //        if (type.contains("standard")) {
 //           SPage<Long> ids = searchService.get
 //        } else if (type.contains("nonStandard")) {
@@ -585,12 +585,6 @@ public class ProductServiceImpl implements ProductService {
                 }
                 productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
                 productPrivateDao.save(productPrivate);
-                product.setB2cEnabled(IntegerConstant.NO_SHORT);
-                // 设置物料不可用时,为了更新索引,也需要更新物料资料
-                product.setIsSale(Constant.NO);
-                product.setIsPurchase(Constant.NO);
-                product.setErpDate(new Date());
-                productDao.save(product);
                 //productDao.delete(id);  不允许删除
             } else {
                 throw new

+ 11 - 21
src/main/java/com/uas/platform/b2c/trade/vendor/service/impl/VendorIntroductionServiceImpl.java

@@ -1,12 +1,15 @@
 package com.uas.platform.b2c.trade.vendor.service.impl;
 
 import com.uas.platform.b2c.common.base.dao.CommonDao;
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
+import com.uas.platform.b2c.common.search.util.SPage;
 import com.uas.platform.b2c.core.constant.IntegerConstant;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
 import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
 import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
 import com.uas.platform.b2c.trade.vendor.service.VendorIntroductionService;
+import com.uas.ps.core.util.CollectionUtils;
 import com.uas.sso.support.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -27,6 +30,9 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	@Autowired
 	private V_ProductPrivateDao v_productPrivateDao;
 
+	@Autowired
+	private SearchService searchService;
+
 	/**
 	 * 获取供应商资源列表
 	 * @param page    页码
@@ -64,28 +70,12 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	 */
 	@Override
 	public Page<V_ProductPrivate> getVendorProductList(int page, int size, Long vendUU, String keyword) {
-		String whereCondition = " 1 = 1 ";
-		if (!StringUtils.isEmpty(keyword)) {
-		    keyword = keyword.trim();
-			// 物料名称、规格、品牌、原厂型号、单位
-			whereCondition = " (pr_title like '%" + keyword + "%' or pr_spec like '%" + keyword + "%' or pr_brand like '%"
-					+ keyword + "%' or pr_cmpcode like '%" + keyword + "%' or pr_unit like '%" + keyword + "%' or pr_kind like '%"
-					+ keyword + "%') ";
+		SPage<Long> ids = searchService.getProducts(vendUU, keyword, page, size, "all");
+		if (CollectionUtils.isEmpty(ids.getContent())) {
+			return null;
 		}
-		long start = System.currentTimeMillis();
-		// and Pr_Title not like '%测试%' and lower(Pr_Title) not like '%test%' and Pr_code not like '%测试%' and lower(Pr_code) not like '%test%'
-		String prodSql = "select a.* from (select pr_id id, pr_code prodNum, pr_title prodName, pr_spec spec, pr_cmpcode cmpCode, pr_unit unit, pr_kind kind, "
-				+ " pr_brand brand, pr_pbranden pbranden, pr_standard standard from v$product$private where pr_enuu = "
-				+ vendUU + " and " + whereCondition + " and pr_pbranden is not null and pr_pcmpcode is not null and ifnull(pr_b2cenabled, 1) <> 0 order by pr_standard desc, pr_id desc) a limit " + (page - 1) * size + "," + size;
-//		System.out.println("prod:" + prodSql);
-		// and Pr_Title not like '%测试%' and lower(Pr_Title) not like '%test%' and Pr_code not like '%测试%' and lower(Pr_code) not like '%test%'
-		String countSql = "select count(1) from v$product$private where pr_enuu = " + vendUU + " and " + whereCondition
-				+ " and pr_pbranden is not null and pr_pcmpcode is not null and ifnull(pr_b2cenabled, 1) <> 0";
-		Integer count = commonDao.queryForObject(countSql, Integer.class);
-//		System.out.println("count:" + countSql);
-		List<V_ProductPrivate> products = commonDao.query(prodSql, V_ProductPrivate.class);
-//		System.out.println("耗时" + (System.currentTimeMillis() - start));
-		return new Page<>(page, size, products, count);
+		List<V_ProductPrivate> productPrivateList = v_productPrivateDao.findAll(ids.getContent());
+		return new Page<>(page, size, productPrivateList, (int) ids.getTotalElement());
 	}
 
 	/**