فهرست منبع

供应商列表搜索修改;增加供应商列表搜索联想词

dongbw 7 سال پیش
والد
کامیت
e3972e8dbb

+ 10 - 0
src/main/java/com/uas/platform/b2c/common/search/constant/SearchUrl.java

@@ -28,6 +28,16 @@ public class SearchUrl {
      */
      */
     public static final String NONSTANDARD_PRODUCT_ID_URL = "/search/nonStandardProductIds?enUU={enUU}&keyword={keyword}&page={page}&size={size}";
     public static final String NONSTANDARD_PRODUCT_ID_URL = "/search/nonStandardProductIds?enUU={enUU}&keyword={keyword}&page={page}&size={size}";
 
 
+    /**
+     * 标准型号联想(物料)
+     */
+    public static final String PRODUCT_SIMILAR_PCMPCODE_URL = "/search/product/similarPCmpCodes?keyword={keyword}&size={size}";
+
+    /**
+     * 类目联想(物料)
+     */
+    public static final String PRODUCT_SIMILAR_KIND_URL = "/search/product/similarKind?keyword={keyword}&size={size}";
+
     /**
     /**
      * 获取类目的数据
      * 获取类目的数据
      *
      *

+ 12 - 0
src/main/java/com/uas/platform/b2c/common/search/controller/SearcherController.java

@@ -281,6 +281,18 @@ public class SearcherController {
 		return  searcherService.getSimilarKeywords(keyword);
 		return  searcherService.getSimilarKeywords(keyword);
 	}
 	}
 
 
+	/**
+	 * 根据输入获取联想词(包括型号、类目、品牌,按顺序获取)
+	 *
+	 * @param keyword 关键词
+	 * @return 获取联想词(包括型号、类目、品牌)
+	 */
+	@RequestMapping(value = "/product/similarKeywords", method = RequestMethod.GET)
+	@ResponseBody
+	public Map<String,Object> getProductSimilarKeywords(String keyword) {
+		return  searcherService.getProductSimilarKeywords(keyword);
+	}
+
 	/**
 	/**
 	 * 根据输入获取联想词(器件)
 	 * 根据输入获取联想词(器件)
 	 * 
 	 * 

+ 26 - 0
src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/SearchServiceImpl.java

@@ -262,6 +262,32 @@ public class SearchServiceImpl implements SearchService{
         }
         }
     }
     }
 
 
+    @Override
+    public Map<String,Object> getProductSimilarKeywords(String keyword) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        String pCmpCode = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.PRODUCT_SIMILAR_PCMPCODE_URL, String.class, map);
+        String pBrandEn = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_BRAND_URL, String.class, map);
+        String kind = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.PRODUCT_SIMILAR_KIND_URL, String.class, map);
+        if(StringUtils.isEmpty(pCmpCode) && StringUtils.isEmpty(pBrandEn) && StringUtils.isEmpty(kind)) {
+            return null;
+        }else {
+            try {
+                List<Object> reMapPCmpCode = FastjsonUtils.fromJsonArray(pCmpCode);
+                List<Object> reMapPBrandEn = FastjsonUtils.fromJsonArray(pBrandEn);
+                List<Object> reMapKind = FastjsonUtils.fromJsonArray(kind);
+                map.clear();
+                map.put("pCmpCode",reMapPCmpCode);
+                map.put("pBrandEn",reMapPBrandEn);
+                map.put("kind",reMapKind);
+                return map;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
     @Override
     @Override
     public List<Map<String, Object>> getSimilarComponents(String keyword) throws SearchException {
     public List<Map<String, Object>> getSimilarComponents(String keyword) throws SearchException {
         Map<String, Object> map = new HashedMap();
         Map<String, Object> map = new HashedMap();

+ 2 - 0
src/main/java/com/uas/platform/b2c/common/search/rpc/service/SearchService.java

@@ -37,6 +37,8 @@ public interface SearchService {
 
 
     Map<String,Object> getSimilarKeywords(String keyword) throws SearchException;
     Map<String,Object> getSimilarKeywords(String keyword) throws SearchException;
 
 
+    Map<String,Object> getProductSimilarKeywords(String keyword) throws SearchException;
+
     List<Map<String, Object>> getSimilarComponents(String keyword) throws SearchException;
     List<Map<String, Object>> getSimilarComponents(String keyword) throws SearchException;
 
 
     List<Map<String, Object>> getSimilarBrands(String keyword) throws SearchException;
     List<Map<String, Object>> getSimilarBrands(String keyword) throws SearchException;

+ 8 - 0
src/main/java/com/uas/platform/b2c/common/search/service/SearcherService.java

@@ -119,6 +119,14 @@ public interface SearcherService {
 	 */
 	 */
 	public Map<String,Object> getSimilarKeywords(String keyword);
 	public Map<String,Object> getSimilarKeywords(String keyword);
 
 
+	/**
+	 * 根据输入获取联想词(包括器件、类目、品牌,按顺序获取)
+	 *
+	 * @param keyword 关键词
+	 * @return 联想词
+	 */
+	Map<String,Object> getProductSimilarKeywords(String keyword);
+
 	/**
 	/**
 	 * 根据输入的原厂型号获取联想词
 	 * 根据输入的原厂型号获取联想词
 	 * 
 	 * 

+ 28 - 11
src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java

@@ -26,17 +26,6 @@ import com.uas.platform.core.exception.SystemException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.model.PageParams;
 import com.uas.search.exception.SearchException;
 import com.uas.search.exception.SearchException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import javax.servlet.http.HttpServletRequest;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +38,18 @@ import org.springframework.ui.ModelMap;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
 /**
 /**
  * 搜索索引
  * 搜索索引
  *
  *
@@ -379,6 +380,22 @@ public class SearcherServiceImpl implements SearcherService {
         return result;
         return result;
     }
     }
 
 
+    @Override
+    public Map<String, Object> getProductSimilarKeywords(String keyword) {
+        Map<String, Object> result = null;
+        try {
+            result = searchService.getProductSimilarKeywords(keyword);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        for (Entry<String, Object> entry : result.entrySet()) {
+            if (((List) entry.getValue()).size() > 8) {
+                entry.setValue(((List) entry.getValue()).subList(0, 8));
+            }
+        }
+        return result;
+    }
+
     @Override
     @Override
     public List<Map<String, Object>> getSimilarComponents(String componentCode) {
     public List<Map<String, Object>> getSimilarComponents(String componentCode) {
         List<Map<String, Object>> components = new ArrayList<>();
         List<Map<String, Object>> components = new ArrayList<>();

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

@@ -34,16 +34,17 @@ public class VendorIntroductionController {
 
 
 
 
     /**
     /**
-     * 根据关键词(非必填)获取供应商资源列表
+     * 根据关键词(非必填)精确匹配来获取供应商资源列表
      *
      *
      * @param size  the params 一页的大小
      * @param size  the params 一页的大小
 	 * @param page 第几页
 	 * @param page 第几页
      * @param keyword the keyword  搜索关键字
      * @param keyword the keyword  搜索关键字
+	 * @param field 字段   kind  类目 cmpCode 型号  brand 品牌
      * @return the Page<VendorIntroduction> 返回一页的数据
      * @return the Page<VendorIntroduction> 返回一页的数据
      */
      */
     @RequestMapping(value = "/vendor/list", method = RequestMethod.GET)
     @RequestMapping(value = "/vendor/list", method = RequestMethod.GET)
-	public Page<VendorIntroduction> getVendorIntroductionList(int page, int size, String keyword) {
-		return vendorIntroductionService.getVendorIntroduction(page, size, keyword);
+	public Page<VendorIntroduction> getVendorIntroductionList(int page, int size, String keyword, String field) {
+		return vendorIntroductionService.getVendorIntroduction(page, size, keyword, field);
 	}
 	}
 
 
 	/**
 	/**

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

@@ -12,13 +12,15 @@ public interface VendorIntroductionService {
 
 
 
 
     /**
     /**
-     * 获取供应商资源列表
-     * @param page 页码
-     * @param size 每页大小
-     * @param keyword  关键词
-     * @return 供应商资源page
+     * 根据关键词(非必填)精确匹配来获取供应商资源列表
+     *
+     * @param size  the params 一页的大小
+     * @param page 第几页
+     * @param keyword the keyword  搜索关键字
+     * @param field 字段   kind  类目 cmpCode 型号  brand 品牌
+     * @return the Page<VendorIntroduction> 返回一页的数据
      */
      */
-    Page<VendorIntroduction> getVendorIntroduction(int page, int size, String keyword);
+    Page<VendorIntroduction> getVendorIntroduction(int page, int size, String keyword, String field);
 
 
     /**
     /**
      * 根据vendUU获取企业物料列表
      * 根据vendUU获取企业物料列表

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

@@ -28,28 +28,67 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	private V_ProductPrivateDao v_productPrivateDao;
 	private V_ProductPrivateDao v_productPrivateDao;
 
 
 	/**
 	/**
-	 * 获取供应商资源列表
-	 * @param page    页码
-	 * @param size    每页大小
-	 * @param keyword 关键词
-	 * @return 供应商资源page
-     * @version 2018年5月15日 11:53:06 增加限制,要求营业执照号长度大于12才显示
+	 * 类目
+	 */
+	private static final String KIND_EQUAL = "kind";
+
+	/**
+	 * 型号
+	 */
+	private static final String PCMPCODE_EQUAL = "pCmpCode";
+
+	/**
+	 * 品牌
+	 */
+	private static final String PBRANDEN_EQUAL = "pBrandEn";
+
+	/**
+	 * 根据关键词(非必填)精确匹配来获取供应商资源列表
+	 *
+	 * @param size  the params 一页的大小
+	 * @param page 第几页
+	 * @param keyword the keyword  搜索关键字
+	 * @param field 字段   kind  类目 cmpCode 型号  brand 品牌
+	 * @return the Page<VendorIntroduction> 返回一页的数据
 	 */
 	 */
 	@Override
 	@Override
-	public Page<VendorIntroduction> getVendorIntroduction(int page, int size, String keyword) {
+	public Page<VendorIntroduction> getVendorIntroduction(int page, int size, String keyword, String field) {
 		long start = System.currentTimeMillis();
 		long start = System.currentTimeMillis();
+		String enterpriseCondition = " 1=1 ";
+		String productCondition = "";
+		// 拼接查询条件
 		if (!StringUtils.isEmpty(keyword)) {
 		if (!StringUtils.isEmpty(keyword)) {
             keyword = keyword.trim();
             keyword = keyword.trim();
+			enterpriseCondition = "(en_name like '%" + keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '% "
+					+ keyword + "%')";
+            if (!StringUtils.isEmpty(field)) {
+            	switch (field) {
+					case KIND_EQUAL :
+						productCondition = "pr_kind = '" + keyword + "'";
+						break;
+					case PCMPCODE_EQUAL :
+						productCondition = "pr_pcmpcode = '" + keyword + "'";
+						break;
+					case PBRANDEN_EQUAL :
+						productCondition = "pr_pbranden = '" + keyword + "'";
+						break;
+				}
+			}
         }
         }
         Long enUU = 0L;
         Long enUU = 0L;
         if (null != SystemSession.getUser() && null != SystemSession.getUser().getEnterprise()) {
         if (null != SystemSession.getUser() && null != SystemSession.getUser().getEnterprise()) {
             enUU = SystemSession.getUser().getEnterprise().getUu();
             enUU = SystemSession.getUser().getEnterprise().getUu();
         }
         }
 		// 查询所有企业个数
 		// 查询所有企业个数
-		Integer total = getTotalCount(enUU, keyword);
+		Integer total = getTotalCount(enUU, enterpriseCondition, productCondition);
 		// 查询企业
 		// 查询企业
-		List<VendorIntroduction> vendorIntroductions = getEnterpriseWithCondition(enUU, keyword, page, size);
-//		System.out.println("查找完企业UU" + (System.currentTimeMillis() - start));
+		List<VendorIntroduction> vendorIntroductions;
+		if (!StringUtils.isEmpty(productCondition)) {
+			vendorIntroductions = getEnterpriseWithProductCondition(enUU, enterpriseCondition, productCondition,  page, size);
+		} else {
+			vendorIntroductions = getEnterpriseWithoutProductCondition(enUU, enterpriseCondition,  page, size);
+		}
+		System.out.println("查找完企业UU" + (System.currentTimeMillis() - start));
 		return new Page<VendorIntroduction>(page, size, vendorIntroductions, total);
 		return new Page<VendorIntroduction>(page, size, vendorIntroductions, total);
 	}
 	}
 
 
@@ -113,91 +152,97 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	/**
 	/**
 	 * 获取供应商资源信息
 	 * 获取供应商资源信息
 	 * @param enUU 本企业UU
 	 * @param enUU 本企业UU
-	 * @param keyword 关键词
+	 * @param enterpriseCondition 企业搜索条件
+	 * @param productCondition 物料搜索条件
 	 * @param page 页码
 	 * @param page 页码
 	 * @param size 尺寸
 	 * @param size 尺寸
 	 * @return
 	 * @return
 	 */
 	 */
-	private List<VendorIntroduction> getEnterpriseWithCondition(Long enUU, String keyword, int page, int size) {
+	private List<VendorIntroduction> getEnterpriseWithProductCondition(Long enUU, String enterpriseCondition, String productCondition, int page, int size) {
+		StringBuilder enterpriseSql = new StringBuilder();
+		// 查询所有符合条件的enUU的语句,按待售物料数量排序
+		String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, enterpriseCondition, productCondition);
+		// 获取企业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 " +
+				",st.st_uuid,st.st_status from sec$enterprises en left join store$info st on st.st_enuu = en.en_uu right join (").append(enUUSql)
+				.append(" ) a on en.en_uu = a.en_uu order by en.en_weight desc, counts desc");
+		// 查找非供应商的卖当前商品的企业UU
+		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, 0) 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);
+		System.out.println("ens:" + vendorIntroductionUusSql);
+		return commonDao.query(vendorIntroductionUusSql.toString(), VendorIntroduction.class);
+	}
+
+	/**
+	 * 获取供应商资源信息
+	 * @param enUU 本企业UU
+	 * @param enterpriseCondition 企业搜索条件
+	 * @param page 页码
+	 * @param size 尺寸
+	 * @return
+	 */
+	private List<VendorIntroduction> getEnterpriseWithoutProductCondition(Long enUU, String enterpriseCondition, int page, int size) {
 		StringBuilder enterpriseSql = new StringBuilder();
 		StringBuilder enterpriseSql = new StringBuilder();
-//		// 查询所有符合条件的enUU的语句,按待售物料数量排序
-//		String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, keyword);
 		// 获取企业sql
 		// 获取企业sql
 		enterpriseSql.append("select en.en_uu enUU, en.en_name enName, en.en_shortname enShortname, en.en_address enAddress, en.en_tel enTel, " +
 		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 " +
 				"en.en_email enEmail, en.en_corporation enCorporation, en.en_businesscode enBusinesscode, en.en_industry enIndustry, en.en_Businessscope enBusinessScope " +
 				",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%' " +
 				",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 (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' or en_area like '%香港%') and " +
 				"and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' or en_area like '%香港%') and " +
 				" (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and en_uu <> ")
 				" (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) 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("%')");
-		}
+				.append(enUU).append(" and ").append(enterpriseCondition);
 		// rownum 控制
 		// rownum 控制
 		String rownumSql = ") s order by isStore 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
-		// (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 ("
 		String vendorIntroductionUusSql = "select s.*, if( st_enuu is not null and st_status = 'OPENED', 1, 0) isStore from ("
 				+ enterpriseSql + rownumSql;
 				+ enterpriseSql + rownumSql;
-//		String vendorIntroductionUusSql = "select s.*,( " + prodInfoSql + ") productInfo, (" + storeSql +
-//				") isStore from (select t.*,rownum as r1 from (" + enterpriseSql + rownumSql;
-//        System.out.println("ens:" + vendorIntroductionUusSql);
 		return commonDao.query(vendorIntroductionUusSql, VendorIntroduction.class);
 		return commonDao.query(vendorIntroductionUusSql, VendorIntroduction.class);
 	}
 	}
 
 
 	/**
 	/**
 	 * 获取所有符合条件企业数量
 	 * 获取所有符合条件企业数量
 	 * @param enUU  本企业UU
 	 * @param enUU  本企业UU
-	 * @param keyword 关键词
+	 * @param enterpriseCondition 企业过滤条件
+	 * @param productCondition 物料过滤条件
 	 * @return
 	 * @return
 	 */
 	 */
-	private Integer getTotalCount(Long enUU, String keyword) {
+	private Integer getTotalCount(Long enUU, String enterpriseCondition, String productCondition) {
 		StringBuilder enCountSql = new StringBuilder();
 		StringBuilder enCountSql = new StringBuilder();
-		// 含名称、地址、、行业、经营范围搜索 物料型号、名称
-		if (!StringUtils.isEmpty(keyword)) {
-			String keywordSql = getKeywordSql(enUU, keyword);
-			enCountSql.append("select count(1) from (").append(keywordSql);
-		} else {
-			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 (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' or en_area like '%香港%')" +
-					" and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and en_uu <> ").append(enUU);
+		enCountSql.append("select count(1) from (select en_uu,count(1) from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
+				" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
+				" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
+				" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]') and ").append(enterpriseCondition).append(") and en_uu <> ")
+				.append(enUU).append(") e ");
+		if (!StringUtils.isEmpty(productCondition)) {
+			enCountSql.append("right join ( select pr_enuu from v$product$private where ").append(productCondition).append(") p on pr_enuu = en_uu");
 		}
 		}
 		enCountSql.append(" group by en_uu )a");
 		enCountSql.append(" group by en_uu )a");
-//        System.out.println("en_count:" + enCountSql.toString());
+        System.out.println("en_count:" + enCountSql.toString());
 		return commonDao.queryForObject(enCountSql.toString(), Integer.class);
 		return commonDao.queryForObject(enCountSql.toString(), Integer.class);
 	}
 	}
 
 
-	/**
-	 * 拼接关键词Sql
-	 * @param enUU
-	 * @param keyword
-	 * @return
-	 */
-	private String getKeywordSql(Long enUU, String keyword) {
-		return "select en_uu,count(1) as counts from sec$enterprises where en_name not like '%测试%' " +
-				"and lower(en_name) not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' or en_area like '%香港%') and (en_name like '%"
-				+ keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '%" + keyword + "%') and en_uu <> " + enUU +
-                " and (en_name not regexp '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5a-zA-Z0-9]'))";
-	}
-
 	/**
 	/**
 	 * 拼接所有待售物料所属企业UU,按enUU分组,按物料数量倒序
 	 * 拼接所有待售物料所属企业UU,按enUU分组,按物料数量倒序
 	 * @param enUU 当前企业UU
 	 * @param enUU 当前企业UU
-	 * @param keyword 搜索关键词
+	 * @param enterpriseCondition 企业过滤条件
+	 * @param productCondition 物料匹配条件
 	 * @return
 	 * @return
 	 */
 	 */
-	private String getEnUUGroupByEnUUOrderByCount(Long enUU, String keyword) {
+	private String getEnUUGroupByEnUUOrderByCount(Long enUU, String enterpriseCondition, String productCondition) {
 		StringBuilder enUUSql = new StringBuilder();
 		StringBuilder enUUSql = new StringBuilder();
 		// 含名称、企业执照号、地址、邮箱、电话、行业、经营范围搜索
 		// 含名称、企业执照号、地址、邮箱、电话、行业、经营范围搜索
-		if (!StringUtils.isEmpty(keyword)) {
-			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 where en.en_uu <> ").append(enUU);
+		enUUSql.append("select en_uu, count(1) as counts from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
+				" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
+				" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
+				" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and ").append(enterpriseCondition).append(" and en_uu <> ").append(enUU)
+				.append(") e");
+		if (!StringUtils.isEmpty(productCondition)) {
+			enUUSql.append(" right join ( select pr_enuu from v$product$private where ").append(productCondition).append(") p on pr_enuu = en_uu");
 		}
 		}
 		enUUSql.append(" group by en_uu order by count(1) desc ");
 		enUUSql.append(" group by en_uu order by count(1) desc ");
 		return enUUSql.toString();
 		return enUUSql.toString();