Explorar el Código

Merge branch 'dev' into dev-mysql

yujia hace 8 años
padre
commit
14483054cf
Se han modificado 26 ficheros con 906 adiciones y 502 borrados
  1. 1 1
      src/main/java/com/uas/platform/b2c/common/base/api/FileUploadController.java
  2. 1 2
      src/main/java/com/uas/platform/b2c/common/base/api/UploadController.java
  3. 30 0
      src/main/java/com/uas/platform/b2c/common/base/constant/FileClientConstant.java
  4. 0 8
      src/main/java/com/uas/platform/b2c/common/base/service/FileService.java
  5. 0 9
      src/main/java/com/uas/platform/b2c/common/base/service/ImageService.java
  6. 18 28
      src/main/java/com/uas/platform/b2c/common/base/service/impl/DFSImageServiceImpl.java
  7. 106 0
      src/main/java/com/uas/platform/b2c/common/base/service/impl/FileClientImpl.java
  8. 2 31
      src/main/java/com/uas/platform/b2c/common/base/service/impl/FileServiceImpl.java
  9. 4 5
      src/main/java/com/uas/platform/b2c/common/search/api/SearchServiceImpl.java
  10. 118 0
      src/main/java/com/uas/platform/b2c/common/search/constant/SearchUrl.java
  11. 5 2
      src/main/java/com/uas/platform/b2c/common/search/controller/SearcherController.java
  12. 19 0
      src/main/java/com/uas/platform/b2c/common/search/rpc/Readme.md
  13. 60 0
      src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/OrderSearchServiceImpl.java
  14. 377 0
      src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/SearchServiceImpl.java
  15. 35 0
      src/main/java/com/uas/platform/b2c/common/search/rpc/service/OrderSearchService.java
  16. 53 0
      src/main/java/com/uas/platform/b2c/common/search/rpc/service/SearchService.java
  17. 7 5
      src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java
  18. 0 351
      src/main/java/com/uas/platform/b2c/core/utils/HttpUtils.java
  19. 38 6
      src/main/java/com/uas/platform/b2c/prod/commodity/controller/GoodsController.java
  20. 1 1
      src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentGoodsDao.java
  21. 1 1
      src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentGoodsServiceImpl.java
  22. 1 1
      src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java
  23. 1 1
      src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java
  24. 1 2
      src/main/resources/spring/context.xml
  25. 0 23
      src/main/resources/spring/dubbo-consumer.xml
  26. 27 25
      src/test/java/com/uas/platform/b2c/RegistForMall.java

+ 1 - 1
src/main/java/com/uas/platform/b2c/common/base/api/FileUploadController.java

@@ -49,7 +49,7 @@ public class FileUploadController {
 		for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
 			MultipartFile mf = entity.getValue();
 			try {
-				String path = fileService.save(mf);
+				String path = fileService.save(mf.getOriginalFilename(), mf.getBytes());
 				Map<String, Object> map = new HashMap<String, Object>();
 				map.put("path", path);
 				map.put("fileName", mf.getOriginalFilename());

+ 1 - 2
src/main/java/com/uas/platform/b2c/common/base/api/UploadController.java

@@ -12,7 +12,6 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -43,7 +42,7 @@ public class UploadController {
         for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
             MultipartFile mf = entity.getValue();
             try {
-                IPicture picture = imageService.uploadFile(mf);
+                IPicture picture = imageService.save(mf.getOriginalFilename(), mf.getBytes());
                 pictures.add(picture);
             } catch (Exception e) {
                 e.printStackTrace();

+ 30 - 0
src/main/java/com/uas/platform/b2c/common/base/constant/FileClientConstant.java

@@ -0,0 +1,30 @@
+package com.uas.platform.b2c.common.base.constant;
+
+public class FileClientConstant {
+
+    /**
+     * 文件上传
+     */
+    public final static String FILE_UPLOAD = "http://10.10.100.200:9999/file/upload";
+
+
+    /**
+     * 文件下载
+     */
+    public final static String FILE_DOWNLOAD = "http://10.10.100.200:9999/file/download";
+
+    /**
+     * 文件删除
+     */
+    public final static String FILE_DELETE = "http://10.10.100.200:9999/file/delete";
+
+    /**
+     * 文件信息
+     */
+    public final static String FILE_INFO = "http://10.10.100.200:9999/file/info";
+
+    /**
+     * 文件额外属性
+     */
+    public final static String FILE_METADATA = "http://10.10.100.200:9999/file/metadata";
+}

+ 0 - 8
src/main/java/com/uas/platform/b2c/common/base/service/FileService.java

@@ -1,7 +1,6 @@
 package com.uas.platform.b2c.common.base.service;
 
 import com.uas.platform.b2c.common.base.model.FileUpload;
-import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 文件上传
@@ -17,13 +16,6 @@ public interface FileService {
      */
     public String save(FileUpload fileUpload);
 
-    /**
-     * 保存文件
-     * @param mf 需要上传的文件
-     * @return 文件路径
-     */
-    public String save(MultipartFile mf);
-
     /**
      * 用户上传文件
      * @param fileName 文件名

+ 0 - 9
src/main/java/com/uas/platform/b2c/common/base/service/ImageService.java

@@ -1,7 +1,6 @@
 package com.uas.platform.b2c.common.base.service;
 
 import com.uas.platform.b2c.common.base.model.IPicture;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.util.List;
@@ -38,12 +37,4 @@ public interface ImageService {
 	 * @return 文件
 	 */
 	public IPicture save(String fileName, byte[] fileBytes);
-
-	/**
-	 * 保存图片
-	 * @param mf MultipartFile 文件的信息
-	 * @return
-	 * @throws Exception
-	 */
-    IPicture uploadFile(MultipartFile mf) throws Exception;
 }

+ 18 - 28
src/main/java/com/uas/platform/b2c/common/base/service/impl/DFSImageServiceImpl.java

@@ -1,19 +1,14 @@
 package com.uas.platform.b2c.common.base.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.uas.dfs.service.FileClient;
-import com.uas.platform.b2c.common.base.constant.FileUrl;
 import com.uas.platform.b2c.common.base.dao.DBPictureRepository;
 import com.uas.platform.b2c.common.base.model.DBPicture;
 import com.uas.platform.b2c.common.base.model.IPicture;
 import com.uas.platform.b2c.common.base.service.ImageService;
-import com.uas.platform.b2c.core.utils.FastjsonUtils;
-import com.uas.platform.b2c.core.utils.HttpUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
@@ -34,14 +29,9 @@ public class DFSImageServiceImpl implements ImageService {
         List<DBPicture> pictures = new ArrayList<DBPicture>();
         for (File file : files) {
             try {
-                HttpUtils.Response response = HttpUtils.upload(FileUrl.FILE_UPLOAD, file, null);
-                if (response.getStatusCode() == 200) {
-                    JSONObject obj = FastjsonUtils.parseObject(response.getResponseText());
-                    String fileUrl = (String) obj.get("path");
-                    pictures.add(new DBPicture(file.getName(), fileUrl, com.uas.platform.core.util.FileUtils.getImagePixel(file)));
-                } else {
-                    throw new IllegalStateException(response.getResponseText());
-                }
+                String fileUrl = fileClient.upload(FileUtils.readFileToByteArray(file), file.length(),
+                        FilenameUtils.getExtension(file.getName()), null);
+                pictures.add(new DBPicture(file.getName(), fileUrl, com.uas.platform.core.util.FileUtils.getImagePixel(file)));
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -52,7 +42,7 @@ public class DFSImageServiceImpl implements ImageService {
     @Override
     public DBPicture save(File file) {
         try {
-            String fileUrl = fileClient.uploadImage(FileUtils.readFileToByteArray(file), file.length(),
+            String fileUrl = fileClient.upload(FileUtils.readFileToByteArray(file), file.length(),
                     FilenameUtils.getExtension(file.getName()), null);
             return pictureRepository.save(new DBPicture(file.getName(), fileUrl, com.uas.platform.core.util.FileUtils.getImagePixel(file)));
         } catch (IOException e) {
@@ -63,22 +53,22 @@ public class DFSImageServiceImpl implements ImageService {
 
     @Override
     public IPicture save(String fileName, byte[] fileBytes) {
-        String fileUrl = fileClient.uploadImage(fileBytes, fileBytes.length, FilenameUtils.getExtension(fileName), null);
+        String fileUrl = fileClient.upload(fileBytes, fileBytes.length, FilenameUtils.getExtension(fileName), null);
         return pictureRepository.save(new DBPicture(fileName, fileUrl, com.uas.platform.core.util.FileUtils.getImagePixel(fileBytes)));
     }
 
-    @Override
-    public IPicture uploadFile(MultipartFile mf) throws Exception {
-        HttpUtils.Response response = HttpUtils.upload(FileUrl.FILE_UPLOAD, mf, null);
-        if (response.getStatusCode() == 200) {
-            JSONObject obj = FastjsonUtils.parseObject(response.getResponseText());
-
-            String fileName = mf.getOriginalFilename();
-            String fileUrl = (String) obj.get("path");
-            return pictureRepository.save(new DBPicture(fileName, fileUrl, com.uas.platform.core.util.FileUtils.getImagePixel(mf.getBytes())));
-        } else {
-            throw new IllegalStateException(response.getResponseText());
-        }
-    }
+//    @Override
+//    public IPicture uploadFile(MultipartFile mf) throws Exception {
+//        HttpUtils.Response response = HttpUtils.upload(FileUrl.FILE_UPLOAD, mf, null);
+//        if (response.getStatusCode() == 200) {
+//            JSONObject obj = FastjsonUtils.parseObject(response.getResponseText());
+//
+//            String fileName = mf.getOriginalFilename();
+//            String fileUrl = (String) obj.get("path");
+//            return pictureRepository.save(new DBPicture(fileName, fileUrl, com.uas.platform.core.util.FileUtils.getImagePixel(mf.getBytes())));
+//        } else {
+//            throw new IllegalStateException(response.getResponseText());
+//        }
+//    }
 
 }

+ 106 - 0
src/main/java/com/uas/platform/b2c/common/base/service/impl/FileClientImpl.java

@@ -0,0 +1,106 @@
+package com.uas.platform.b2c.common.base.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.dfs.domain.FileInfo;
+import com.uas.dfs.domain.MetaData;
+import com.uas.dfs.service.FileClient;
+import com.uas.platform.b2c.common.base.constant.FileClientConstant;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.http.*;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+@Service
+public class FileClientImpl implements FileClient {
+
+    private final RestTemplate restTemplate;
+
+    @Autowired
+    public FileClientImpl(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+
+    @Override
+    public String upload(byte[] bytes, long l, final String s, Set<MetaData> set) {
+        HttpHeaders headers = new HttpHeaders();
+        MediaType type = MediaType.parseMediaType("multipart/form-data;charset=UTF-8");
+        headers.setContentType(type);
+
+        File file = new File(s);
+        try {
+            OutputStream output = new FileOutputStream(file);
+            BufferedOutputStream bufferedOutput = new BufferedOutputStream(output);
+            bufferedOutput.write(bytes);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        MultiValueMap<String, Object> form = new LinkedMultiValueMap<String, Object>();
+        ByteArrayResource arrayResource = new ByteArrayResource(bytes){
+            @Override
+            public String getFilename() throws IllegalStateException {
+                return "test." + s;
+            }
+
+        };
+        form.add("file", arrayResource);
+
+        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(form, headers);
+        ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(FileClientConstant.FILE_UPLOAD, requestEntity, JSONObject.class);
+        return responseEntity.getBody().getString("path");
+    }
+
+    @Override
+    public byte[] download(String s) {
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("path", s);
+        HttpHeaders headers = new HttpHeaders();
+        ResponseEntity<byte[]> response = restTemplate.exchange(FileClientConstant.FILE_DOWNLOAD, HttpMethod.GET,
+                new HttpEntity<byte[]>(headers), byte[].class, params);
+        return response.getBody();
+    }
+
+    @Override
+    public void delete(String s) {
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("path", s);
+        restTemplate.delete(FileClientConstant.FILE_DELETE, params);
+    }
+
+    @Override
+    public String uploadImage(byte[] bytes, long l, String s, Set<MetaData> set) {
+        // 项目无用到,暂不实现
+        return null;
+    }
+
+    @Override
+    public FileInfo getInfo(String s) {
+        // 项目无用到,暂不实现
+        return null;
+    }
+
+    @Override
+    public Set<MetaData> getMetaData(String s) {
+        // 项目无用到,暂不实现
+        return null;
+    }
+
+    @Override
+    public void mergeMetaData(String s, Set<MetaData> set) {
+        // 项目无用到,暂不实现
+    }
+
+    @Override
+    public void overrideMetaData(String s, Set<MetaData> set) {
+        // 项目无用到,暂不实现
+    }
+
+}

+ 2 - 31
src/main/java/com/uas/platform/b2c/common/base/service/impl/FileServiceImpl.java

@@ -1,17 +1,12 @@
 package com.uas.platform.b2c.common.base.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.uas.dfs.service.FileClient;
-import com.uas.platform.b2c.common.base.constant.FileUrl;
 import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.common.base.service.FileService;
-import com.uas.platform.b2c.core.utils.FastjsonUtils;
-import com.uas.platform.b2c.core.utils.HttpUtils;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
 @Service
@@ -25,32 +20,8 @@ public class FileServiceImpl implements FileService {
 		CommonsMultipartFile file = fileUpload.getFile();
 		try {
 			// 上传到文件系统
-			HttpUtils.Response response = HttpUtils.upload(FileUrl.FILE_UPLOAD, file, null);
-			if (response.getStatusCode() == 200) {
-				JSONObject obj = FastjsonUtils.parseObject(response.getResponseText());
-				String fileUrl = (String) obj.get("path");
-				return fileUrl;
-			} else {
-				throw new IllegalStateException(response.getResponseText());
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw new IllegalOperatorException("附件上传失败");
-		}
-	}
-
-	@Override
-	public String save(MultipartFile mf) {
-		try {
-            HttpUtils.Response response = HttpUtils.upload(FileUrl.FILE_UPLOAD, mf, null);
-            if (response.getStatusCode() == 200) {
-                JSONObject obj = FastjsonUtils.parseObject(response.getResponseText());
-
-                String fileUrl = (String) obj.get("path");
-                return fileUrl;
-            }else {
-                throw new IllegalStateException(response.getResponseText());
-            }
+			return fileClient.upload(file.getBytes(), file.getSize(),
+					FilenameUtils.getExtension(file.getOriginalFilename()), null);
 		} catch (Exception e) {
 			e.printStackTrace();
 			throw new IllegalOperatorException("附件上传失败");

+ 4 - 5
src/main/java/com/uas/platform/b2c/common/search/api/SearchServiceImpl.java

@@ -1,16 +1,15 @@
 package com.uas.platform.b2c.common.search.api;
 
-import java.util.List;
-import java.util.Map;
-
+import com.uas.api.b2c_erp.search.service.SearchService;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.uas.api.b2c_erp.search.service.SearchService;
+import java.util.List;
+import java.util.Map;
 
 public class SearchServiceImpl implements SearchService {
 
 	@Autowired
-	private com.uas.search.service.SearchService searchService;
+	private com.uas.platform.b2c.common.search.rpc.service.SearchService searchService;
 
 	@Override
 	public List<Map<String, Object>> getAssociateBrands(String keyword) {

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

@@ -0,0 +1,118 @@
+package com.uas.platform.b2c.common.search.constant;
+
+/**
+ * 搜索对应的链接
+ *
+ * @author yuj 2017-10-19 19:35
+ */
+public class SearchUrl {
+
+    /**
+     * 获取类目id
+     */
+    public static final String KIND_ID_URL = "http://10.10.100.191:8092/search/kindIds/{keyword}";
+
+    /**
+     * 获取类目的数据
+     *
+     */
+    public static final String KIND_INFO_URL = "http://10.10.100.191:8092/search/kinds/{keyword}?page={page}&size={size}";
+
+    /**
+     * 搜索品牌的id
+     */
+    public static final String BRAND_ID_URL = "http://10.10.100.191:8092/search/brandIds/{keyword}?page={page}&size={size}";
+
+    /**
+     * 搜索品牌的具体信息
+     */
+    public static final String BRAND_INFO_URL = "http://10.10.100.191:8092/search/brands/{keyword}?page={page}&size={size}";
+
+
+    /**
+     * 搜索器件的id
+     */
+    public static final String COMPONENT_ID_URL = "http://10.10.100.191:8092/search/componentIds?keyword={keyword}&params={params}";
+
+    /**
+     * 根据品牌id后去类目的id
+     */
+    public static final String KIND_ID_COMPONENT_URL = "http://10.10.100.191:8092/search/kindIdsByComponent?keyword={keyword}&brandId={brandId}";
+
+    /**
+     * 根据品牌id后去类目信息
+     */
+    public static final String KIND_COMPONENT_URL = "http://10.10.100.191:8092/search/kindsByComponent?keyword={keyword}&brandId={brandId}";
+
+    /**
+     * 根据类目的id,获取品牌id信息
+     */
+    public static final String BREAND_ID_COMPONENT_URL = "http://10.10.100.191:8092/search/brandIdsByComponent?keyword={keyword}&kindId={kindId}";
+
+
+    /**
+     * 根据类目的id,获取品牌信息
+     */
+    public static final String BREAND_COMPONENT_URL = "http://10.10.100.191:8092/search/brandsByComponent?keyword={keyword}&kindId={kindId}";
+
+
+    /**
+     * 根据关键字联想
+     */
+    public static final String SIMILAR_KEYWORD_URL = "http://10.10.100.191:8092/search/similarKeywords/{keyword}";
+
+
+    /**
+     * 根据关键字联想器件
+     */
+    public static final String SIMILAR_COMPONENT_URL = "http://10.10.100.191:8092/search/similarComponents/{keyword}";
+
+
+    /**
+     * 根据关键字联想品牌
+     */
+    public static final String SIMILAR_BRAND_URL = "http://10.10.100.191:8092/search/similarBrands/{keyword}";
+
+
+    /**
+     * 根据关键字联想类目
+     */
+    public static final String SIMILAR_KIND_URL = "http://10.10.100.191:8092/search/similarKinds/{keyword}";
+
+
+
+    /**
+     * 获取某个信息的叶子节点
+     */
+    public static final String SIMILAR_LEAF_KIND_URL = "http://10.10.100.191:8092/search/similarLeafKinds/{keyword}";
+
+
+    /**
+     * 获取类目的层级
+     */
+    public static final String SIMILAR__KIND_LEVEL_URL = "http://10.10.100.191:8092/search/similarKindsByLevel?kindName={kindName}&level={level}";
+
+
+    /**
+     * 属性值搜索
+     */
+    public static final String PROPERTYVALUES_URL = "http://10.10.100.191:8092/search/similarPropertyValues?kindId={kindId}&propertyId={propertyId}&keyword={keyword}&topNum={topNum}";
+
+
+    /**
+     * 搜索库存信息
+     */
+    public static final String GOODIS_URL= "http://10.10.100.191:8092/search/goodsIds?keyword={keyword}&params={params}";
+
+
+    /**
+     * 搜索库存
+     */
+    public static final String GOODS_COLLECT_URL= "http://10.10.100.191:8092/search/collectBySearchGoods?keyword={keyword}&collectedField={collectedField}&filters={filters}";
+
+    /**
+     * 搜索订单
+     */
+    public static final String ORDER_SEARCH_URL = "http://10.10.100.191:8092/search/orderIds?tableName={tableName}&keyword={keyword}&page={page}&size={size}&status={status}&buyeruu={buyeruu}&buyerenuu={buyerenuu}&sellerenuu={sellerenuu}&mintime={mintime}&maxtime={maxtime}";
+
+}

+ 5 - 2
src/main/java/com/uas/platform/b2c/common/search/controller/SearcherController.java

@@ -85,7 +85,7 @@ public class SearcherController {
 		// 搜索类目
 		String type = request.getParameter("type");
 		if ("all".equals(type)) {
-			ModelMap results = new ModelMap();
+			/*ModelMap results = new ModelMap();
 			PageParams pageParams = new PageParams();
 			results = searcherService.searchComponentGoodsNums(w, pageParams);
 			if (((Integer)results.get("total")).intValue() == 0){
@@ -105,7 +105,10 @@ public class SearcherController {
                 // 跳转至器件搜索结果页
                 w = URLEncoder.encode(w, "UTF-8");
                 response.sendRedirect("commonSearch#/component?keyword=" + w);
-            }
+            }*/
+
+			w = URLEncoder.encode(w, "UTF-8");
+			response.sendRedirect("commonSearch#/component?keyword=" + w);
 			/*map = searcherService.searchKind(w, null);
 			int kindTotal = (int) map.get("total");
 			if (kindTotal > 1) {

+ 19 - 0
src/main/java/com/uas/platform/b2c/common/search/rpc/Readme.md

@@ -0,0 +1,19 @@
+## name
+
+rpc
+
+## 名称
+
+调用远程的搜索的接口
+
+## 创建人
+
+yujia
+
+## 创建时间
+
+2017年10月20日8:49:26
+
+## 说明
+
+使用Http协议调用远程的接口获取数据。

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

@@ -0,0 +1,60 @@
+package com.uas.platform.b2c.common.search.rpc.service.Impl;
+
+import com.uas.platform.b2c.common.search.constant.SearchUrl;
+import com.uas.platform.b2c.common.search.rpc.service.OrderSearchService;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import com.uas.search.exception.SearchException;
+import com.uas.search.model.BaseOrder;
+import com.uas.search.model.PageParams;
+import com.uas.search.model.SPage;
+import org.apache.commons.collections.map.HashedMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+/**
+ * description
+ *
+ * @author yuj 2017-10-21 9:50
+ */
+@Service
+public class OrderSearchServiceImpl implements OrderSearchService {
+
+    private final RestTemplate restTemplate;
+
+    @Autowired
+    public OrderSearchServiceImpl(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+
+    @Override
+    public SPage<BaseOrder> getOrderIdsWithDetail(String keyword, Table_name tableName, PageParams var3) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("tableName", tableName);
+        map.put("page", var3.getPage());
+        map.put("size", var3.getSize());
+        Map<PageParams.FilterField, Object> filters = var3.getFilters();
+        map.put("status", filters.get(PageParams.FilterField.ORDER_STATUS));
+        map.put("buyeruu", filters.get(PageParams.FilterField.ORDER_BUYER_UU));
+        map.put("buyerenuu", filters.get(PageParams.FilterField.ORDER_BUYER_EN_UU));
+        map.put("sellerenuu", filters.get(PageParams.FilterField.ORDER_SELLER_EN_UU));
+        map.put("mintime", filters.get(PageParams.FilterField.ORDER_MIN_TIME));
+        map.put("maxtime", filters.get(PageParams.FilterField.ORDER_MAX_TIME));
+        String str = restTemplate.getForObject(SearchUrl.ORDER_SEARCH_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                SPage<BaseOrder> reMap = FastjsonUtils.fromJson(str, SPage.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+}

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

@@ -0,0 +1,377 @@
+package com.uas.platform.b2c.common.search.rpc.service.Impl;
+
+
+import com.uas.platform.b2c.common.search.constant.SearchUrl;
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
+import com.uas.search.exception.SearchException;
+import com.uas.search.model.CollectField;
+import com.uas.search.model.PageParams;
+import com.uas.search.model.SPage;
+import org.apache.commons.collections.map.HashedMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 通过resttemplate调用搜索接口的实现方法
+ *
+ * @author yuj 2017-10-20 8:57
+ */
+@Service
+public class SearchServiceImpl implements SearchService{
+
+    private final RestTemplate restTemplate;
+
+    @Autowired
+    public SearchServiceImpl(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+
+    @Override
+    public SPage<Long> getKindIds(String keyword, Integer page, Integer size) throws SearchException {
+        Map<String, Object> map = initSearchMap(keyword, page, size);
+        String str = restTemplate.getForObject(SearchUrl.KIND_ID_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                SPage<Long> sPage = FastjsonUtils.fromJson(str, SPage.class);
+                return sPage;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public SPage<Map<String, Object>> getKinds(String keyword, Integer page, Integer size) throws SearchException {
+        Map<String, Object> map = initSearchMap(keyword, page, size);
+        String str = restTemplate.getForObject(SearchUrl.KIND_INFO_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                SPage<Map<String, Object>> sPage = FastjsonUtils.fromJson(str, SPage.class);
+                return sPage;
+            }catch (Exception e) {
+                e.printStackTrace();
+              return null;
+            }
+        }
+    }
+
+    @Override
+    public SPage<Long> getBrandIds(String keyword, Integer page, Integer size) throws SearchException {
+        Map<String, Object> map = initSearchMap(keyword, page, size);
+        String str = restTemplate.getForObject(SearchUrl.BRAND_ID_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                SPage<Long> sPage = FastjsonUtils.fromJson(str, SPage.class);
+                return sPage;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+
+    }
+
+    @Override
+    public SPage<Map<String, List<Integer>>> getBrands(String keyword, Integer page, Integer size) throws SearchException {
+        Map<String, Object> map = initSearchMap(keyword, page, size);
+        String str = restTemplate.getForObject(SearchUrl.BRAND_INFO_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                SPage<Map<String, List<Integer>>> sPage = FastjsonUtils.fromJson(str, SPage.class);
+                return sPage;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public Map<String, Object> getComponentIds(String keyword, PageParams var2) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("params", FlexJsonUtils.toJsonDeep(var2));
+        String str = restTemplate.getForObject(SearchUrl.COMPONENT_ID_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                Map<String, Object> reMap = FastjsonUtils.fromJson(str, Map.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public Set<Long> getKindIdsBySearchComponent(String keyword, String brandId) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("brandId", brandId);
+        String str = restTemplate.getForObject(SearchUrl.KIND_ID_COMPONENT_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                Set<Long> reMap = FastjsonUtils.fromJson(str, Set.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> getKindsBySearchComponent(String keyword, String brandId) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("brandId", brandId);
+        String str = restTemplate.getForObject(SearchUrl.KIND_COMPONENT_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public Set<Long> getBrandIdsBySearchComponent(String keyword, String kindId) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("kindId", kindId);
+        String str = restTemplate.getForObject(SearchUrl.BREAND_ID_COMPONENT_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                Set<Long> reMap = FastjsonUtils.fromJson(str, Set.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("kindId", kindId);
+        String str = restTemplate.getForObject(SearchUrl.BREAND_COMPONENT_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<String> getSimilarKeywords(String keyword) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        String str = restTemplate.getForObject(SearchUrl.SIMILAR_KEYWORD_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<String> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> getSimilarComponents(String keyword) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        String str = restTemplate.getForObject(SearchUrl.SIMILAR_COMPONENT_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> getSimilarBrands(String keyword) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        String str = restTemplate.getForObject(SearchUrl.SIMILAR_BRAND_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> getSimilarKinds(String keyword) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        String str = restTemplate.getForObject(SearchUrl.SIMILAR_KIND_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> getSimilarLeafKinds(String keyword) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        String str = restTemplate.getForObject(SearchUrl.SIMILAR_LEAF_KIND_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> getSimilarKindsByLevel(String kindName, Short level) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("kindName", kindName);
+        map.put("level", level);
+        String str = restTemplate.getForObject(SearchUrl.SIMILAR__KIND_LEVEL_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, String>> getSimilarPropertyValues(Long kindId, Long propertyId, String keyword, Long topNum) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("kindId", kindId);
+        map.put("propertyId", propertyId);
+        map.put("keyword", keyword);
+        map.put("topNum", topNum);
+        String str = restTemplate.getForObject(SearchUrl.PROPERTYVALUES_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, String>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public Map<String, Object> getGoodsIds(String keyword, PageParams var2) throws SearchException {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("params", FlexJsonUtils.toJsonDeep(var2));
+        String str = restTemplate.getForObject(SearchUrl.GOODIS_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                Map<String, Object> reMap = FastjsonUtils.fromJson(str, Map.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public List<Map<String, Object>> collectBySearchGoods(String keyword, CollectField collectField, Map<PageParams.FilterField, Object> filters) {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("collectedField", collectField);
+        map.put("filters", FastjsonUtils.toJson(filters));
+        String str = restTemplate.getForObject(SearchUrl.GOODS_COLLECT_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                List<Map<String, Object>> reMap = FastjsonUtils.fromJson(str, List.class);
+                return reMap;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
+    public Map<String , Object> initSearchMap(String keyword, Integer page, Integer size) {
+        Map<String, Object> map = new HashedMap();
+        map.put("keyword", keyword);
+        map.put("page", page);
+        map.put("size", size);
+        return map;
+    }
+}

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

@@ -0,0 +1,35 @@
+package com.uas.platform.b2c.common.search.rpc.service;
+
+import com.uas.search.exception.SearchException;
+import com.uas.search.model.BaseOrder;
+import com.uas.search.model.PageParams;
+import com.uas.search.model.SPage;
+
+/**
+ * Created by yujia on 2017/10/21.
+ */
+public interface OrderSearchService {
+
+    SPage<BaseOrder> getOrderIdsWithDetail(String var1, OrderSearchService.Table_name var2, PageParams var3) throws SearchException;
+
+    public static enum Table_name {
+        ORDER("order"),
+        PURCHASE("purchase"),
+        ORDER_INVOICE("order_invoice"),
+        PURCHASE_INVOICE("purchase_invocie");
+
+        private String phrase;
+
+        private Table_name(String phrase) {
+            this.phrase = phrase;
+        }
+
+        public String value() {
+            return this.phrase;
+        }
+
+        public String toString() {
+            return this.phrase;
+        }
+    }
+}

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

@@ -0,0 +1,53 @@
+package com.uas.platform.b2c.common.search.rpc.service;
+
+/**
+ * Created by yujia on 2017/10/20.
+ *
+ * 通过http方式调用远端的搜索接口
+ */
+import com.uas.search.exception.SearchException;
+import com.uas.search.model.CollectField;
+import com.uas.search.model.PageParams;
+import com.uas.search.model.SPage;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface SearchService {
+    SPage<Long> getKindIds(String keyword, Integer page, Integer size) throws SearchException;
+
+    SPage<Map<String, Object>> getKinds(String keyword, Integer page, Integer size) throws SearchException;
+
+    SPage<Long> getBrandIds(String keyword, Integer page, Integer size) throws SearchException;
+
+    SPage<Map<String, List<Integer>>> getBrands(String keyword, Integer page, Integer size) throws SearchException;
+
+    Map<String, Object> getComponentIds(String keyword, PageParams var2) throws SearchException;
+
+    Set<Long> getKindIdsBySearchComponent(String keyword, String brandId) throws SearchException;
+
+    List<Map<String, Object>> getKindsBySearchComponent(String keyword, String brandId) throws SearchException;
+
+    Set<Long> getBrandIdsBySearchComponent(String keyword, String kindId) throws SearchException;
+
+    List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) throws SearchException;
+
+    List<String> getSimilarKeywords(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>> getSimilarKinds(String keyword) throws SearchException;
+
+    List<Map<String, Object>> getSimilarLeafKinds(String keyword) throws SearchException;
+
+    List<Map<String, Object>> getSimilarKindsByLevel(String kindName, Short level) throws SearchException;
+
+    List<Map<String, String>> getSimilarPropertyValues(Long kindId, Long propertyId, String keyword, Long topNum) throws SearchException;
+
+    Map<String, Object> getGoodsIds(String keyword, PageParams var2) throws SearchException;
+
+    List<Map<String, Object>> collectBySearchGoods(String keyword, CollectField collectField, Map<PageParams.FilterField, Object> filters);
+}

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

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.common.search.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.common.search.service.SearcherService;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
@@ -15,7 +16,6 @@ import com.uas.search.model.CollectField;
 import com.uas.search.model.PageParams.FilterField;
 import com.uas.search.model.SPage;
 import com.uas.search.model.Sort;
-import com.uas.search.service.SearchService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,7 +83,7 @@ public class SearcherServiceImpl implements SearcherService {
 	@Override
 	public ModelMap searchBrand(String keyword, String field) {
 		ModelMap map = new ModelMap();
-		SPage<Map<String, Object>> brands = null;
+		SPage<Map<String, List<Integer>>> brands = null;
 		try {
 			brands = searchService.getBrands(keyword,1,1024*1024*1024);
 		} catch (SearchException e) {
@@ -160,12 +160,14 @@ public class SearcherServiceImpl implements SearcherService {
 			map.put("components", new ArrayList<>());// 当前页器件内容
 			return map;
 		}
-		List<Long> componentIds = (List<Long>)results.get("componentIds");
-		List<Long> goodsIds = (List<Long>)results.get("goodsIds");
+		List<Integer> componentIds = (List<Integer>)results.get("componentIds");
+		List<Integer> goodsIds = (List<Integer>)results.get("goodsIds");
 		List<ComponentGoods> components = new ArrayList<>();
 		if (!CollectionUtils.isEmpty(componentIds)) {
 			for (int i = 0 ;i < componentIds.size() ; i++){
-				ComponentGoods componentGoods = componentGoodsDao.findByCmpIdAndGoId(componentIds.get(i),goodsIds.get(i));
+				Long cid = Long.valueOf(componentIds.get(i).toString());
+				Long gid = goodsIds.get(i) == null ? null : Long.valueOf(goodsIds.get(i).toString());
+				ComponentGoods componentGoods = componentGoodsDao.findByCmpIdAndGoId(cid, gid);
 				if (componentGoods != null){
 					components.add(componentGoods);
 				}

+ 0 - 351
src/main/java/com/uas/platform/b2c/core/utils/HttpUtils.java

@@ -1,351 +0,0 @@
-package com.uas.platform.b2c.core.utils;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.entity.mime.content.FileBody;
-import org.apache.http.entity.mime.content.InputStreamBody;
-import org.apache.http.entity.mime.content.StringBody;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URLEncoder;
-import java.util.*;
-import java.util.Map.Entry;
-
-public class HttpUtils {
-
-	/**
-	 * 发起POST、PUT请求
-	 * 
-	 * @param params
-	 * @return
-	 * @throws Exception
-	 */
-	public static Response get(String url, Map<String, Object> params) throws Exception {
-		CloseableHttpClient httpClient = HttpClients.createDefault();
-		HttpEntityEnclosingRequestBase request = null;
-		CloseableHttpResponse response = null;
-		try {
-			StringBuilder buf = new StringBuilder(url);
-			if (params != null && !params.isEmpty()) {
-				if (url.indexOf("?") == -1)
-					buf.append("?");
-				else if (!url.endsWith("&"))
-					buf.append("&");
-				Set<Entry<String, Object>> entrys = params.entrySet();
-				for (Entry<String, Object> entry : entrys) {
-					buf.append(entry.getKey()).append("=").append(URLEncoder.encode(String.valueOf(entry.getValue()), "UTF-8")).append("&");
-				}
-			}
-			request = new HttpPost(buf.toString());
-			response = httpClient.execute(request);
-			return Response.getResponse(response);
-		} finally {
-			request.releaseConnection();
-			try {
-				httpClient.close();
-			} catch (IOException e) {
-			}
-			if (response != null) {
-				try {
-					response.close();
-				} catch (IOException e) {
-				}
-			}
-		}
-	}
-
-	/**
-	 * 发起POST、PUT请求
-	 *
-	 * @param datas
-	 * @return
-	 * @throws Exception
-	 */
-	public static Response post(String url, Collection<?> datas) throws Exception {
-		CloseableHttpClient httpClient = HttpClients.createDefault();
-		HttpEntityEnclosingRequestBase request = new HttpPost(url);
-		CloseableHttpResponse response = null;
-		try {
-			if (datas != null && !datas.isEmpty()) {
-				request.setEntity(new StringEntity(FastjsonUtils.toJson(datas), ContentType.create("text/plain", Consts.UTF_8)));
-			}
-			response = httpClient.execute(request);
-			return Response.getResponse(response);
-		} finally {
-			request.releaseConnection();
-			try {
-				httpClient.close();
-			} catch (IOException e) {
-			}
-			if (response != null) {
-				try {
-					response.close();
-				} catch (IOException e) {
-				}
-			}
-		}
-	}
-
-	/**
-	 * 发起POST、PUT请求
-	 *
-	 * @param params
-	 * @return
-	 * @throws Exception
-	 */
-	public static Response post(String url, Map<String, String> params) throws Exception {
-		CloseableHttpClient httpClient = HttpClients.createDefault();
-		HttpEntityEnclosingRequestBase request = new HttpPost(url);
-		CloseableHttpResponse response = null;
-		try {
-			List<NameValuePair> nvps = new ArrayList<NameValuePair>();
-			if (params != null && !params.isEmpty()) {
-				Set<Entry<String, String>> entrys = params.entrySet();
-				for (Entry<String, String> entry : entrys) {
-					nvps.add(new BasicNameValuePair(entry.getKey(), URLEncoder.encode(entry.getValue(), "UTF-8")));
-				}
-			}
-			request.setEntity(new UrlEncodedFormEntity(nvps));
-			response = httpClient.execute(request);
-			return Response.getResponse(response);
-		} finally {
-			request.releaseConnection();
-			try {
-				httpClient.close();
-			} catch (IOException e) {
-			}
-			if (response != null) {
-				try {
-					response.close();
-				} catch (IOException e) {
-				}
-			}
-		}
-	}
-
-	/**
-	 * http上传文件
-	 * 
-	 * @param url
-	 *            请求地址
-	 * @param filePath
-	 *            附件路径
-	 * @param params
-	 *            参数
-	 * @return
-	 * @throws Exception
-	 * @throws IOException
-	 * @throws IllegalStateException
-	 */
-	public static Response upload(String url, String filePath, Map<String, String> params) throws IllegalStateException, IOException,
-			Exception {
-		CloseableHttpClient httpClient = null;
-		CloseableHttpResponse response = null;
-		try {
-			httpClient = HttpClients.createDefault();
-			HttpPost httpPost = new HttpPost(url);
-			FileBody fileBody = new FileBody(new File(filePath));
-			MultipartEntityBuilder builder = MultipartEntityBuilder.create();
-			builder.addPart("file", fileBody);
-			if (params != null) {
-				for (String paramKey : params.keySet()) {
-					StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
-					builder.addPart(paramKey, body);
-				}
-			}
-			HttpEntity reqEntity = builder.build();
-			httpPost.setEntity(reqEntity);
-			response = httpClient.execute(httpPost);
-			return Response.getResponse(response);
-		} finally {
-			try {
-				if (response != null) {
-					response.close();
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			try {
-				if (httpClient != null) {
-					httpClient.close();
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-
-	/**
-	 * http上传文件
-	 *
-	 * @param url
-	 *            请求地址
-	 * @param file
-	 *            文件
-	 * @param params
-	 *            参数
-	 * @return
-	 * @throws Exception
-	 * @throws IOException
-	 * @throws IllegalStateException
-	 */
-	public static Response upload(String url, File file, Map<String, String> params) throws IllegalStateException, IOException,
-			Exception {
-		CloseableHttpClient httpClient = null;
-		CloseableHttpResponse response = null;
-		try {
-			httpClient = HttpClients.createDefault();
-			HttpPost httpPost = new HttpPost(url);
-			FileBody fileBody = new FileBody(file);
-			MultipartEntityBuilder builder = MultipartEntityBuilder.create();
-			builder.addPart("file", fileBody);
-			if (params != null) {
-				for (String paramKey : params.keySet()) {
-					StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
-					builder.addPart(paramKey, body);
-				}
-			}
-			HttpEntity reqEntity = builder.build();
-			httpPost.setEntity(reqEntity);
-			response = httpClient.execute(httpPost);
-			return Response.getResponse(response);
-		} finally {
-			try {
-				if (response != null) {
-					response.close();
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			try {
-				if (httpClient != null) {
-					httpClient.close();
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	/**
-	 * http上传文件
-	 *
-	 * @param url
-	 *            请求地址
-	 * @param multipartFile
-	 *            附件路径
-	 * @param params
-	 *            参数
-	 * @return
-	 * @throws Exception
-	 * @throws IOException
-	 * @throws IllegalStateException
-	 */
-	public static Response upload(String url, MultipartFile multipartFile, Map<String, String> params) throws IllegalStateException, IOException,
-			Exception {
-		CloseableHttpClient httpClient = null;
-		CloseableHttpResponse response = null;
-		try {
-			httpClient = HttpClients.createDefault();
-			HttpPost httpPost = new HttpPost(url);
-			InputStreamBody streamBody = new InputStreamBody(multipartFile.getInputStream(),
-				multipartFile.getOriginalFilename());
-			MultipartEntityBuilder builder = MultipartEntityBuilder.create();
-			builder.addPart("file", streamBody);
-			if (params != null) {
-				for (String paramKey : params.keySet()) {
-					StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
-					builder.addPart(paramKey, body);
-				}
-			}
-			HttpEntity reqEntity = builder.build();
-			httpPost.setEntity(reqEntity);
-			response = httpClient.execute(httpPost);
-			return Response.getResponse(response);
-		} finally {
-			try {
-				if (response != null) {
-					response.close();
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			try {
-				if (httpClient != null) {
-					httpClient.close();
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	/**
-	 * 下载
-	 * 
-	 * @param url
-	 * @return
-	 * @throws ClientProtocolException
-	 * @throws IOException
-	 */
-	public static InputStream download(String url) throws ClientProtocolException, IOException {
-		CloseableHttpClient httpClient = HttpClients.createDefault();
-		HttpGet httpGet = new HttpGet(url);
-		CloseableHttpResponse response = httpClient.execute(httpGet);
-		return response.getEntity().getContent();
-	}
-
-	public static class Response {
-		private int statusCode;
-		private String responseText;
-
-		public int getStatusCode() {
-			return statusCode;
-		}
-
-		public void setStatusCode(int statusCode) {
-			this.statusCode = statusCode;
-		}
-
-		public String getResponseText() {
-			return responseText;
-		}
-
-		public void setResponseText(String responseText) {
-			this.responseText = responseText;
-		}
-
-		public Response() {
-		}
-
-		public Response(HttpResponse response) throws IllegalStateException, IOException, Exception {
-			this.statusCode = response.getStatusLine().getStatusCode();
-			this.responseText = IOUtils.toString(response.getEntity().getContent());
-		}
-
-		public static Response getResponse(HttpResponse response) throws IllegalStateException, IOException, Exception {
-			if (response != null)
-				return new Response(response);
-			return null;
-		}
-	}
-}

+ 38 - 6
src/main/java/com/uas/platform/b2c/prod/commodity/controller/GoodsController.java

@@ -1,5 +1,12 @@
 package com.uas.platform.b2c.prod.commodity.controller;
 
+import com.uas.platform.b2c.common.base.model.FileUpload;
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
+import com.uas.platform.b2c.core.support.view.JxlsExcelView;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
@@ -7,20 +14,15 @@ import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
 import com.uas.platform.b2c.prod.commodity.model.GoodsSimple;
 import com.uas.platform.b2c.prod.commodity.service.GoodsHistoryService;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
-import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
 import com.uas.platform.b2c.prod.product.component.service.ComponentService;
-import com.uas.platform.b2c.core.support.SystemSession;
-import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
-import com.uas.platform.b2c.core.utils.FastjsonUtils;
-import com.uas.platform.b2c.core.utils.StringUtilB2C;
-import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.model.Status;
+import org.apache.commons.collections.map.HashedMap;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -65,6 +67,9 @@ public class GoodsController {
 	@Autowired
 	private GoodsDao goodsDao;
 
+	@Autowired
+	private SearchService searchService;
+
     /**
      * 发布(上架)产品
      *
@@ -644,4 +649,31 @@ public class GoodsController {
 		logger.log("商品管理", "下架该公司所有商品");
 		return goodsService.downAllGoodsByEnterprise(eName);
 	}
+
+	@RequestMapping(value = "/test/str", method = RequestMethod.GET)
+	public void getTest() {
+		searchService.getKindIds("电阻", 1, 10);
+
+		searchService.getKinds("电阻", 1, 10);
+
+		searchService.getBrandIds("Panasonic", 1, 10);
+
+		searchService.getBrands("Panasonic", 1, 10);
+
+		com.uas.search.model.PageParams page = new com.uas.search.model.PageParams();
+		page.setPage(1);
+		page.setSize(10);
+		searchService.getComponentIds("ac", page);
+
+		Map<com.uas.search.model.PageParams.FilterField, Object> filters = new HashedMap();
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_KINDID, "401,23");
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_BRANDID, "45");
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_STORE_TYPE, "DISTRIBUTION");
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_CRNAME, "RMB-USD");
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_MINPRICERMB, "0");
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_MAXPRICERMB, "10");
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_MINPRICEUSD, "0");
+		filters.put(com.uas.search.model.PageParams.FilterField.GOODS_MAXPRICEUSD, "10");
+		page.setFilters(filters);
+	}
 }

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentGoodsDao.java

@@ -37,5 +37,5 @@ public interface ComponentGoodsDao extends JpaSpecificationExecutor<ComponentGoo
 	 * @param goID 批次id
 	 * @return 产品列表信息
 	 */
-	public ComponentGoods findByCmpIdAndGoId(Long cmpId,Long goID);
+	public ComponentGoods findByCmpIdAndGoId(Long cmpId, Long goID);
 }

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentGoodsServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.product.component.service.impl;
 
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentGoods;
 import com.uas.platform.b2c.prod.product.component.service.ComponentGoodsService;
@@ -9,7 +10,6 @@ import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.search.model.PageParams;
 import com.uas.search.model.PageParams.FilterField;
-import com.uas.search.service.SearchService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.prod.product.component.service.impl;
 
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.SplitChar;
 import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
@@ -31,7 +32,6 @@ import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
 import com.uas.search.model.PageParams;
 import com.uas.search.model.PageParams.FilterField;
-import com.uas.search.service.SearchService;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java

@@ -12,6 +12,7 @@ import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.TradeLog;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.base.service.SendMessageService;
+import com.uas.platform.b2c.common.search.rpc.service.OrderSearchService;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.SplitChar;
 import com.uas.platform.b2c.core.support.SystemSession;
@@ -84,7 +85,6 @@ import com.uas.platform.core.util.serializer.FlexJsonUtils;
 import com.uas.search.model.BaseOrder;
 import com.uas.search.model.PageParams;
 import com.uas.search.model.SPage;
-import com.uas.search.service.OrderSearchService;
 import org.apache.commons.collections.map.HashedMap;
 import org.apache.commons.lang.time.DateUtils;
 import org.springframework.beans.BeanUtils;

+ 1 - 2
src/main/resources/spring/context.xml

@@ -187,8 +187,7 @@
 		init-method="init">
 		<property name="configPath" value="classpath:${profile}/account.properties" />
 	</bean>
-	
-	<import resource="classpath:spring/dubbo-consumer.xml"/>
+
 	<import resource="classpath:spring/ehcache.xml"/>
 	<import resource="classpath:spring/jpa.xml"/>
 	<import resource="classpath:spring/redis.xml"/>

+ 0 - 23
src/main/resources/spring/dubbo-consumer.xml

@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-	http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
-
-	<dubbo:application name="b2c_consumer" owner="${dubbo.owner}" />
-
-	<dubbo:registry address="${zk.url}" check="false" />
-
-	<!-- 分布式文件服务 -->
-	<dubbo:reference id="fileClient" interface="com.uas.dfs.service.FileClient" />
-
-	<!-- 搜索服务 -->
-	<dubbo:reference id="searchService"
-		interface="com.uas.search.service.SearchService" timeout="10000"
-		group="${dubbo.group}" />
-	<dubbo:reference id="orderSearchService"
-		interface="com.uas.search.service.OrderSearchService" timeout="10000"
-		group="${dubbo.group}" />
-
-
-</beans>

+ 27 - 25
src/test/java/com/uas/platform/b2c/RegistForMall.java

@@ -1,34 +1,36 @@
 package com.uas.platform.b2c;
 
-import com.alibaba.fastjson.JSON;
-import com.uas.account.entity.UserSpaceDetail;
-import com.uas.sso.common.util.HttpUtil;
-import com.uas.sso.common.util.HttpUtil.ResponseWrap;
-import org.springframework.ui.ModelMap;
-import org.springframework.util.StringUtils;
+import com.alibaba.dubbo.common.json.JSONObject;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import org.apache.commons.collections.map.HashedMap;
 
-import java.util.Date;
+import java.util.ArrayList;
+import java.util.Map;
 
 public class RegistForMall {
 
 	public static void main(String args[]) throws Exception {
-		UserSpaceDetail detail = new UserSpaceDetail();
-		detail.setName("B2B公司研发测试数据-不要购买-wangyuchao");
-		detail.setShortName("B2B公司");
-		detail.setAdminName("余佳");
-		detail.setAdminTel("15989329613");
-		detail.setAdminEmail("yuj@usoftchina.com");
-		detail.setBusinessCode("11122233344456789");
-		detail.setRegisterDate(new Date().getTime());
-		detail.setTel("15989329613");
-		detail.setFax("11-2222222");
-		String url = "http://113.105.74.135:8001/api/userspace";
-		if (!StringUtils.isEmpty(url)) {
-			ResponseWrap res = HttpUtil.doPost(url,
-					new ModelMap("_operate", "registForMall").addAttribute("detail", JSON.toJSON(detail)));
-			System.out.println(res.getContent());
-			if (!res.isSuccess())
-				throw new Exception(res.getContent());
-		}
+//		UserSpaceDetail detail = new UserSpaceDetail();
+//		detail.setName("B2B公司研发测试数据-不要购买-wangyuchao");
+//		detail.setShortName("B2B公司");
+//		detail.setAdminName("余佳");
+//		detail.setAdminTel("15989329613");
+//		detail.setAdminEmail("yuj@usoftchina.com");
+//		detail.setBusinessCode("11122233344456789");
+//		detail.setRegisterDate(new Date().getTime());
+//		detail.setTel("15989329613");
+//		detail.setFax("11-2222222");
+//		String url = "http://113.105.74.135:8001/api/userspace";
+//		if (!StringUtils.isEmpty(url)) {
+//			ResponseWrap res = HttpUtil.doPost(url,
+//					new ModelMap("_operate", "registForMall").addAttribute("detail", JSON.toJSON(detail)));
+//			System.out.println(res.getContent());
+//			if (!res.isSuccess())
+//				throw new Exception(res.getContent());
+//		}
+		Map<String ,Object> map = new HashedMap();
+		map.put("OK", new Object());
+		System.out.println(FastjsonUtils.toJson(map));
+		System.out.println(new ArrayList<>());
 	}
 }