Browse Source

B2C物料搜索 - 增加企业UU字段。

dongbw 7 years ago
parent
commit
def7f7501b

+ 6 - 4
mall-search/src/main/java/com/uas/search/controller/SearchController.java

@@ -49,15 +49,16 @@ public class SearchController {
 	 * @param keyword 关键词
 	 * @param page  页码
 	 * @param size  尺寸
+	 * @param enUU 企业UU
 	 * @param request request
 	 * @return idPage
 	 * @throws IOException 输入异常
 	 */
 	@RequestMapping("/standardProductIds")
 	@ResponseBody
-	public SPage<Long> searchStandardProductIds(@RequestParam String keyword, Integer page, Integer size,
+	public SPage<Long> searchStandardProductIds(String keyword, Integer page, Integer size, @RequestParam Long enUU,
 									HttpServletRequest request) throws IOException {
-		return searchService.getStandardProductIds(keyword, page, size);
+		return searchService.getStandardProductIds(enUU, keyword, page, size);
 	}
 
 	/**
@@ -65,15 +66,16 @@ public class SearchController {
 	 * @param keyword 关键词
 	 * @param page  页码
 	 * @param size  尺寸
+	 * @param enUU 企业UU
 	 * @param request request
 	 * @return idPage
 	 * @throws IOException 输入异常
 	 */
 	@RequestMapping("/nonStandardProductIds")
 	@ResponseBody
-	public SPage<Long> searchNonStandardProductIds(@RequestParam String keyword, Integer page, Integer size,
+	public SPage<Long> searchNonStandardProductIds(String keyword, Integer page, Integer size, @RequestParam Long enUU,
 										  HttpServletRequest request) throws IOException {
-		return searchService.getNonStandardProductIds(keyword, page, size);
+		return searchService.getNonStandardProductIds(enUU, keyword, page, size);
 	}
 
 	/**

+ 4 - 2
mall-search/src/main/java/com/uas/search/service/SearchService.java

@@ -524,23 +524,25 @@ public interface SearchService {
 
 	/**
 	 * 查询标准物料
+	 * @param enUU 企业UU
 	 * @param keyword 关键词
 	 * @param page  页码
 	 * @param size  尺寸
 	 * @return idPage
 	 * @throws IOException 输入异常
 	 */
-    SPage<Long> getStandardProductIds(String keyword, Integer page, Integer size) throws IOException;
+    SPage<Long> getStandardProductIds(Long enUU, String keyword, Integer page, Integer size) throws IOException;
 
 	/**
 	 * 查询非标准物料
+	 * @param enUU 企业UU
 	 * @param keyword 关键词
 	 * @param page  页码
 	 * @param size  尺寸
 	 * @return idPage
 	 * @throws IOException 输入异常
 	 */
-	SPage<Long> getNonStandardProductIds(String keyword, Integer page, Integer size) throws IOException;
+	SPage<Long> getNonStandardProductIds(Long enUU, String keyword, Integer page, Integer size) throws IOException;
 
 	/**
 	 * 根据id获取物料

+ 8 - 6
mall-search/src/main/java/com/uas/search/service/impl/SearchServiceImpl.java

@@ -55,9 +55,9 @@ public class SearchServiceImpl implements SearchService {
 	 * @throws IOException 输入异常
 	 */
 	@Override
-	public SPage<Long> getStandardProductIds(String keyword, Integer page, Integer size) throws IOException {
+	public SPage<Long> getStandardProductIds(Long enUU, String keyword, Integer page, Integer size) throws IOException {
 		List<Long> ids = new ArrayList<>();
-		SPage<Document> documents = getStandardProductDocuments(keyword, page, size);
+		SPage<Document> documents = getStandardProductDocuments(enUU, keyword, page, size);
 		SPage<Long> sPage = new SPage<>(documents.getTotalPage(), documents.getTotalElement(), documents.getPage(),
 				documents.getSize(), documents.isFirst(), documents.isLast());
 		for (Document document : documents.getContent()) {
@@ -77,9 +77,9 @@ public class SearchServiceImpl implements SearchService {
 	 * @throws IOException 输入异常
 	 */
 	@Override
-	public SPage<Long> getNonStandardProductIds(String keyword, Integer page, Integer size) throws IOException {
+	public SPage<Long> getNonStandardProductIds(Long enUU, String keyword, Integer page, Integer size) throws IOException {
 		List<Long> ids = new ArrayList<>();
-		SPage<Document> documents = getNonStandardProductDocuments(keyword, page, size);
+		SPage<Document> documents = getNonStandardProductDocuments(enUU, keyword, page, size);
 		SPage<Long> sPage = new SPage<>(documents.getTotalPage(), documents.getTotalElement(), documents.getPage(),
 				documents.getSize(), documents.isFirst(), documents.isLast());
 		for (Document document : documents.getContent()) {
@@ -89,11 +89,12 @@ public class SearchServiceImpl implements SearchService {
 		return sPage;
 	}
 
-	private SPage<Document> getStandardProductDocuments(String keyword, Integer page, Integer size) throws IOException {
+	private SPage<Document> getStandardProductDocuments(Long enUU, String keyword, Integer page, Integer size) throws IOException {
 //		if (SearchUtils.isKeywordInvalid(keyword)) {
 //			throw new IllegalArgumentException("搜索关键词无效:" + keyword);
 //		}
 		BooleanQuery q1 = new BooleanQuery();
+		q1.add(new TermQuery(new Term(SearchConstants.PRODUCT_PRIVATE_ENUU_FIELD, String.valueOf(enUU))), BooleanClause.Occur.MUST);
 		q1.add(new TermQuery(new Term(SearchConstants.PRODUCT_PRIVATE_STANDARD_FIELD, String.valueOf(1))), BooleanClause.Occur.MUST);
 		q1.add(new TermQuery(new Term(SearchConstants.PRODUCT_PRIVATE_B2CENABLED_FIELD, String.valueOf(1))), BooleanClause.Occur.MUST);
 		BooleanQuery booleanQuery = new BooleanQuery();
@@ -109,11 +110,12 @@ public class SearchServiceImpl implements SearchService {
 		return SearchUtils.getDocuments(SearchConstants.PRODUCTS_PRIVATE_TABLE_NAME, booleanQuery, new Sort(sortProduct(keyword)), page, size);
 	}
 
-	private SPage<Document> getNonStandardProductDocuments(String keyword, Integer page, Integer size) throws IOException {
+	private SPage<Document> getNonStandardProductDocuments(Long enUU, String keyword, Integer page, Integer size) throws IOException {
 //		if (SearchUtils.isKeywordInvalid(keyword)) {
 //			throw new IllegalArgumentException("搜索关键词无效:" + keyword);
 //		}
 		BooleanQuery q1 = new BooleanQuery();
+		q1.add(new TermQuery(new Term(SearchConstants.PRODUCT_PRIVATE_ENUU_FIELD, String.valueOf(enUU))), BooleanClause.Occur.MUST);
 		q1.add(new TermQuery(new Term(SearchConstants.PRODUCT_PRIVATE_STANDARD_FIELD, String.valueOf(0))), BooleanClause.Occur.MUST);
 		q1.add(new TermQuery(new Term(SearchConstants.PRODUCT_PRIVATE_B2CENABLED_FIELD, String.valueOf(1))), BooleanClause.Occur.MUST);
 		BooleanQuery booleanQuery = new BooleanQuery();