Browse Source

【供应商资源】列表搜索条件修改,增加获取供应商物料数量接口

dongbw 7 years ago
parent
commit
caa377f482

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

@@ -32,4 +32,15 @@ public interface V_ProductPrivateDao extends JpaRepository<V_ProductPrivate, Lon
      */
     @Query(value = "select p from V_ProductPrivate p where id in :idList")
     List<V_ProductPrivate> findProductInId(@Param("idList") List<Long> idList);
+
+    /**
+     * 获取供应商待售有效物料数量
+     *
+     * @param enuu     the enuu 企业enuu
+     * @return count by enuu and status
+     */
+    @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)
+    Integer getCountByEnuuAndEnabled(@Param("enuu") Long enuu, @Param("enabled") Integer enabled);
+
 }

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

@@ -57,7 +57,6 @@ public class VendorIntroductionController {
 	@RequestMapping(value = "/product/list", method = RequestMethod.GET)
 	public Page<V_ProductPrivate> getVendorProductList(int page, int size, Long vendUU, String keyword) {
 		Page<V_ProductPrivate> productPage = vendorIntroductionService.getVendorProductList(page, size, vendUU, keyword);
-        logger.log("供应商资源","获取供应商物料列表:" + vendUU);
 		return productPage;
 	}
 
@@ -69,10 +68,28 @@ public class VendorIntroductionController {
 	@RequestMapping(value = "/product/detail", method = RequestMethod.GET)
 	public V_ProductPrivate getVendorProductDetail(Long id) {
 		V_ProductPrivate product = vendorIntroductionService.getVendorProductDetail(id);
-		logger.log("供应商资源","获取供应商物料详情:" + id);
 		return product;
 	}
 
+    /**
+     * 查找该企业待售物料数量
+     * @param vendUU 供应商UU
+     * @return 物料内容
+     */
+    @RequestMapping(value = "/product/count", method = RequestMethod.GET)
+    public ModelMap getVendorProductCount(Long vendUU) {
+        ModelMap map = new ModelMap();
+        try {
+            Integer count = vendorIntroductionService.getVendorProductCount(vendUU);
+            map.put("count", count);
+            map.put("success", true);
+        } catch (Exception e) {
+            map.put("success", false);
+            map.put("message", e.getMessage());
+        }
+        return map;
+    }
+
 	/**
 	 * 获取企业邀请完善信息历史记录
 	 * @param vendUU 供应商企业UU
@@ -81,7 +98,6 @@ public class VendorIntroductionController {
 	@RequestMapping(value = "/invite/history", method = RequestMethod.GET)
 	public InviteVendorHistory getInviteVendorHistoryByVendUU(Long vendUU) {
 		InviteVendorHistory inviteVendorHistory = inviteVendorHistoryService.getInviteVendorHistoryByVendUU(vendUU);
-		logger.log("供应商资源","获取企业邀请完善信息历史记录,vendUU:" + vendUU);
 		return inviteVendorHistory;
 	}
 

+ 6 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/service/VendorIntroductionService.java

@@ -37,4 +37,10 @@ public interface VendorIntroductionService {
      */
     V_ProductPrivate getVendorProductDetail(Long id);
 
+    /**
+     * 获取供应商产品数目
+     * @param vendUU 供应商UU
+     * @return
+     */
+    Integer getVendorProductCount(Long vendUU);
 }

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

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.trade.vendor.service.impl;
 
 import com.uas.platform.b2c.common.base.dao.CommonDao;
+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;
@@ -43,7 +44,7 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
         if (null != SystemSession.getUser() && null != SystemSession.getUser().getEnterprise()) {
             enUU = SystemSession.getUser().getEnterprise().getUu();
         }
-		// 查询所有物料个数
+		// 查询所有企业个数
 		Integer total = getTotalCount(enUU, keyword);
 		// 查询企业
 		List<VendorIntroduction> vendorIntroductions = getEnterpriseWithCondition(enUU, keyword, page, size);
@@ -97,6 +98,17 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 		return v_productPrivateDao.findOne(id);
 	}
 
+	/**
+	 * 获取供应商产品数目
+	 *
+	 * @param vendUU 供应商UU
+	 * @return
+	 */
+	@Override
+	public Integer getVendorProductCount(Long vendUU) {
+		return v_productPrivateDao.getCountByEnuuAndEnabled(vendUU, IntegerConstant.YES_SHORT);
+	}
+
 	/**
 	 * 获取供应商资源信息
 	 * @param enUU 本企业UU
@@ -107,25 +119,26 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	 */
 	private List<VendorIntroduction> getEnterpriseWithCondition(Long enUU, String keyword, int page, int size) {
 		StringBuilder enterpriseSql = new StringBuilder();
-		// 查询所有符合条件的enUU的语句,按待售物料数量排序
-		String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, keyword);
+//		// 查询所有符合条件的enUU的语句,按待售物料数量排序
+//		String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, keyword);
 		// 获取企业sql
 		enterpriseSql.append("select en.en_uu enUU, en.en_name enName, en.en_shortname enShortname, en.en_address enAddress, en.en_tel enTel, " +
 				"en.en_email enEmail, en.en_corporation enCorporation, en.en_businesscode enBusinesscode, en.en_industry enIndustry, en.en_Businessscope enBusinessScope " +
-				" from sec$enterprises en right join (").append(enUUSql)
-				.append(" ) a on en.en_uu = a.en_uu order by en.en_weight desc, counts desc");
+				",st.st_enuu,st.st_status from sec$enterprises en left join store$info st on st.st_enuu = en.en_uu where en_name not like '%测试%'  and en_name not like '%test%' and en_uu <> ")
+			.append(enUU);
+		if (!StringUtils.isEmpty(keyword)) {
+			enterpriseSql.append(" and (en_name like '%").append(keyword).append("%' or en_address like '%").append(keyword).append("%' or en_industry like '%").append(keyword)
+			.append("%')");
+		}
 		// rownum 控制
-		String rownumSql = ") s order by isStore desc,prodCounts desc,enUU asc limit " + (page - 1) * size + "," + size ;
+		String rownumSql = ") s order by isStore desc,enUU asc limit " + (page - 1) * size + "," + size ;
 //		// 查询企业简要物料信息语句
 //		String prodInfoSql = "select wm_concat(pr_title || (case when pr_brand is not null then '(' || pr_brand || ')' else ' ' end)) from v$product$private where pr_enuu=en_uu and "
 //				+ " and pr_issale = 1 and pr_b2cenabled = 1 and rownum<5 ";
 		// 查询企业是否开店语句
 		// 查找非供应商的卖当前商品的企业UU
-		String vendorIntroductionUusSql = "select s.*, ( select 1 from store$info where st_enuu = enUU and st_status = 'OPENED') isStore, "
-                + "(select 1 from v$product$private where ifnull(pr_b2cenabled, 1) = 1 and pr_issale = 1 and pr_pbranden is not null " +
-                "and pr_pcmpcode is not null and pr_enuu = enUU limit 0,1) hasProduct,"
-                + "(select count(1) from v$product$private where ifnull(pr_b2cenabled, 1) = 1 " +
-                "and pr_pbranden is not null and pr_pcmpcode is not null and pr_enuu = enUU and pr_issale = 1) prodCounts from ("
+		// (select 1 from v$product$private where ifnull(pr_b2cenabled, 1) = 1 and pr_issale = 1 and pr_pbranden is not null and pr_pcmpcode is not null and pr_enuu = enUU limit 0,1) hasProduct
+		String vendorIntroductionUusSql = "select s.*, if( st_enuu is not null and st_status = 'OPENED', 1, 0) isStore from ("
 				+ enterpriseSql + rownumSql;
 //		String vendorIntroductionUusSql = "select s.*,( " + prodInfoSql + ") productInfo, (" + storeSql +
 //				") isStore from (select t.*,rownum as r1 from (" + enterpriseSql + rownumSql;
@@ -146,10 +159,10 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 			String keywordSql = getKeywordSql(enUU, keyword);
 			enCountSql.append("select count(1) from (").append(keywordSql);
 		} else {
-			enCountSql.append("select count(1) from (select count(1) from (select * from sec$enterprises where en_name not like '%测试%' " +
-					" and lower(en_name) not like '%test%') en left join products on en.en_uu = pr_enuu where en_uu <> ").append(enUU);
+			enCountSql.append("select count(1) from (select en_uu,count(1) from sec$enterprises where en_name not like '%测试%' " +
+					" and en_name not like '%test%'and en_uu <> ").append(enUU);
 		}
-		enCountSql.append(" group by en_uu ) a");
+		enCountSql.append(" group by en_uu )a");
         System.out.println("en_count:" + enCountSql.toString());
 		return commonDao.queryForObject(enCountSql.toString(), Integer.class);
 	}
@@ -161,11 +174,10 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	 * @return
 	 */
 	private String getKeywordSql(Long enUU, String keyword) {
-		return "select en_uu,count(1) as counts from sec$enterprises left join v$product$private on pr_enuu = en_uu where en_name not like '%测试%' " +
-				"and lower(en_name) not like '%test%' and ((en_name like '%"
+		return "select en_uu,count(1) as counts from sec$enterprises where en_name not like '%测试%' " +
+				"and lower(en_name) not like '%test%' and (en_name like '%"
 				+ keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '%" + keyword
-				+ "%') or ((pr_cmpcode like '%" + keyword + "%' or pr_brand like '%" + keyword
-				+ "%') and ifnull(pr_b2cenabled, 1) = 1 and pr_issale = 1 and pr_pbranden is not null and pr_pcmpcode is not null)) and en_uu <> " + enUU;
+				+ "%') and en_uu <> " + enUU;
 	}
 
 	/**
@@ -181,7 +193,7 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 			enUUSql.append(getKeywordSql(enUU, keyword));
 		} else {
 			enUUSql.append("select en_uu, count(1) as counts from (select * from sec$enterprises where en_name not like '%测试%' " +
-					" and lower(en_name) not like '%test%') en left join products on en.en_uu = pr_enuu where en.en_uu <> ").append(enUU);
+					" and lower(en_name) not like '%test%') en where en.en_uu <> ").append(enUU);
 		}
 		enUUSql.append(" group by en_uu order by count(1) desc ");
 		return enUUSql.toString();