Browse Source

处理查询商城物料数量语句执行时间超长,导致进入供应商物料列表页等待时间久的问题。

dongbw 7 years ago
parent
commit
0c148acbb8

+ 11 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/dao/V_ProductPrivateDao.java

@@ -34,11 +34,12 @@ public interface V_ProductPrivateDao extends JpaRepository<V_ProductPrivate, Lon
     List<V_ProductPrivate> findProductInId(@Param("idList") List<Long> idList);
     List<V_ProductPrivate> findProductInId(@Param("idList") List<Long> idList);
 
 
     /**
     /**
-     * 获取供应商待售有效物料数量
+     * 获取供应商待售有效物料数量 -- 数量大时,极慢。 ex:10042875
      *
      *
      * @param enuu     the enuu 企业enuu
      * @param enuu     the enuu 企业enuu
      * @return count by enuu and status
      * @return count by enuu and status
      */
      */
+    @Deprecated
     @Query(value = "select count(1) from v$product$private pp where " +
     @Query(value = "select count(1) from v$product$private pp where " +
             "pp.pr_enuu=:enuu and pp.pr_pcmpcode is not null and pp.pr_pbranden is not null and pp.pr_b2cenabled = :enabled", nativeQuery = true)
             "pp.pr_enuu=:enuu and pp.pr_pcmpcode is not null and pp.pr_pbranden is not null and pp.pr_b2cenabled = :enabled", nativeQuery = true)
     Integer getCountByEnuuAndEnabled(@Param("enuu") Long enuu, @Param("enabled") Integer enabled);
     Integer getCountByEnuuAndEnabled(@Param("enuu") Long enuu, @Param("enabled") Integer enabled);
@@ -51,4 +52,13 @@ public interface V_ProductPrivateDao extends JpaRepository<V_ProductPrivate, Lon
      */
      */
     @Query(value = "select p from V_ProductPrivate p where id in :idList and p.spec is not null")
     @Query(value = "select p from V_ProductPrivate p where id in :idList and p.spec is not null")
     List<V_ProductPrivate> findProductInIdAndSpecIsNotNull(@Param("idList") List<Long> idList);
     List<V_ProductPrivate> findProductInIdAndSpecIsNotNull(@Param("idList") List<Long> idList);
+
+    /**
+     * 是否存在有效物料检查
+     * @param enUU  查询企业UU
+     * @return
+     */
+    @Query(value = "select 1 from v$product$private pp where " +
+            "pp.pr_enuu=:enUU and pp.pr_pcmpcode is not null and pp.pr_pbranden is not null and pp.pr_b2cenabled = 1 limit 1", nativeQuery = true)
+    Integer hasValidProduct(@Param("enUU") Long enUU);
 }
 }

+ 3 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/controller/VendorIntroductionController.java

@@ -80,6 +80,8 @@ public class VendorIntroductionController {
      * 查找该企业待售物料数量
      * 查找该企业待售物料数量
      * @param vendUU 供应商UU
      * @param vendUU 供应商UU
      * @return 物料内容
      * @return 物料内容
+	 *  2018年7月9日 11:16:08  由于优软商城10042875账号下,物料数量巨大,导致点击跳转物料列表页时,此接口等待时间超长。
+	 * 		现修改为,有物料时,返回1  无物料时返回0
      */
      */
     @RequestMapping(value = "/product/count", method = RequestMethod.GET)
     @RequestMapping(value = "/product/count", method = RequestMethod.GET)
     public ModelMap getVendorProductCount(Long vendUU) {
     public ModelMap getVendorProductCount(Long vendUU) {
@@ -89,6 +91,7 @@ public class VendorIntroductionController {
             map.put("count", count);
             map.put("count", count);
             map.put("success", true);
             map.put("success", true);
         } catch (Exception e) {
         } catch (Exception e) {
+        	e.printStackTrace();
             map.put("success", false);
             map.put("success", false);
             map.put("message", e.getMessage());
             map.put("message", e.getMessage());
         }
         }

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

@@ -5,7 +5,6 @@ import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.base.dao.CommonDao;
 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.rpc.service.SearchService;
 import com.uas.platform.b2c.common.search.util.SPage;
 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.core.support.SystemSession;
 import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
 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.prod.commodity.model.V_ProductPrivate;
@@ -150,7 +149,8 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	 */
 	 */
 	@Override
 	@Override
 	public Integer getVendorProductCount(Long vendUU) {
 	public Integer getVendorProductCount(Long vendUU) {
-		return v_productPrivateDao.getCountByEnuuAndEnabled(vendUU, IntegerConstant.YES_SHORT);
+		Integer ifCount = v_productPrivateDao.hasValidProduct(vendUU);
+		return null != ifCount ? ifCount : 0;
 	}
 	}
 
 
 	/**
 	/**
@@ -196,11 +196,9 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 		// 查找非供应商的卖当前商品的企业UU
 		// 查找非供应商的卖当前商品的企业UU
 		StringBuilder vendorIntroductionUusSql = new StringBuilder();
 		StringBuilder vendorIntroductionUusSql = new StringBuilder();
 		// 行数 控制
 		// 行数 控制
-		String rownumSql = ") s order by isStore desc,prodCounts desc,enUU asc limit " + (page - 1) * size + "," + size ;
-		vendorIntroductionUusSql.append("select s.*, if( st_uuid is not null and st_status = 'OPENED', 1, null) isStore");
-		vendorIntroductionUusSql.append(",(select count(1) from ( select pr_enuu from v$product$private where ").append(productCondition)
-				.append(" and ifnull(pr_b2cenabled, 1) = 1 and pr_pbranden is not null and pr_pcmpcode is not null) p1 where pr_enuu = enUU) prodCounts");
-		vendorIntroductionUusSql.append(" from (").append(enterpriseSql).append(rownumSql);
+		String rownumSql = ") s order by isStore desc,enUU asc limit " + (page - 1) * size + "," + size ;
+		vendorIntroductionUusSql.append("select s.*, if( st_uuid is not null and st_status = 'OPENED', 1, null) isStore from (")
+                .append(enterpriseSql).append(rownumSql);
 		return commonDao.query(vendorIntroductionUusSql.toString(), VendorIntroduction.class);
 		return commonDao.query(vendorIntroductionUusSql.toString(), VendorIntroduction.class);
 	}
 	}