|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
|
import com.uas.platform.b2b.core.util.ContextUtils;
|
|
|
+import com.uas.platform.b2b.core.util.SplitArray;
|
|
|
import com.uas.platform.b2b.model.Product;
|
|
|
import com.uas.platform.b2b.model.ProductInfo;
|
|
|
import com.uas.platform.b2b.model.ProductUsers;
|
|
|
@@ -382,22 +383,28 @@ public class ProductUtils {
|
|
|
*/
|
|
|
public static Map<String, ProductInfo> findByEnUUAndCodes(Long enUU, Set<String> codeSet) {
|
|
|
HashMap<String, Object> map = new HashMap<>(2);
|
|
|
- map.put("enUU", enUU);
|
|
|
- map.put("codes", FlexJsonUtils.toJsonDeep(codeSet));
|
|
|
- Response res = null;
|
|
|
- try {
|
|
|
- res = HttpUtil.sendGetRequest(PRODUCT_PUBLIC_SERVICE_URL + "/product/get/findByEnUUAndCodes", map);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ // 设置每次最多传参200个,多余的分批查找
|
|
|
+ int maxSize = 200;
|
|
|
+ List<String> strings = new ArrayList<>(codeSet);
|
|
|
+ List<List<String>> codesList = SplitArray.splitAry(strings, maxSize);
|
|
|
Map<String, ProductInfo> resultMap = new HashedMap();
|
|
|
- if (HttpStatus.OK.value() == res.getStatusCode()) {
|
|
|
- List<ProductInfo> productInfoList = JSONObject.parseArray(res.getResponseText(), ProductInfo.class);
|
|
|
- for (ProductInfo productInfo : productInfoList) {
|
|
|
- resultMap.put(productInfo.getCode(), productInfo);
|
|
|
+ for (List<String> codes : codesList) {
|
|
|
+ map.put("enUU", enUU);
|
|
|
+ map.put("codes", FlexJsonUtils.toJsonDeep(codes));
|
|
|
+ Response res = null;
|
|
|
+ try {
|
|
|
+ res = HttpUtil.sendGetRequest(PRODUCT_PUBLIC_SERVICE_URL + "/product/get/findByEnUUAndCodes", map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (HttpStatus.OK.value() == res.getStatusCode()) {
|
|
|
+ List<ProductInfo> productInfoList = JSONObject.parseArray(res.getResponseText(), ProductInfo.class);
|
|
|
+ for (ProductInfo productInfo : productInfoList) {
|
|
|
+ resultMap.put(productInfo.getCode(), productInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ logger.error("findByEnUUAndCodes http response status error: " + res.getStatusCode());
|
|
|
}
|
|
|
- } else {
|
|
|
- logger.error("findByEnUUAndCodes http response status error: " + res.getStatusCode());
|
|
|
}
|
|
|
return resultMap;
|
|
|
}
|