|
@@ -125,6 +125,9 @@ public class FdkkSceneEditService {
|
|
}
|
|
}
|
|
|
|
|
|
private JSONArray getProductByJsonObj(JSONArray tags){
|
|
private JSONArray getProductByJsonObj(JSONArray tags){
|
|
|
|
+ HashMap<String,JSONArray> resultMap = new HashMap<>(); //sid, productId array
|
|
|
|
+ HashMap<Object,CdfProduct> productMap = new HashMap<>(); //productId cdf
|
|
|
|
+ JSONArray requestArray = new JSONArray(); //productId all array
|
|
for (Object obj : tags) {
|
|
for (Object obj : tags) {
|
|
JSONObject tag = (JSONObject) obj;
|
|
JSONObject tag = (JSONObject) obj;
|
|
String sid = tag.getString("sid");
|
|
String sid = tag.getString("sid");
|
|
@@ -149,10 +152,32 @@ public class FdkkSceneEditService {
|
|
if(jsonArray == null || jsonArray.size() <=0){
|
|
if(jsonArray == null || jsonArray.size() <=0){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- CdfProductListByIdsRequest param = new CdfProductListByIdsRequest(jsonArray);
|
|
|
|
- CdfProductListByIdsVo vos = cdfClient.getProductListByIds(param);
|
|
|
|
- if(vos.getProductCardList()!=null && vos.getProductCardList().size() >0){
|
|
|
|
- tag.put("products",vos.getProductCardList());
|
|
|
|
|
|
+ resultMap.put(sid,jsonArray);
|
|
|
|
+ requestArray.addAll(jsonArray);
|
|
|
|
+ }
|
|
|
|
+ if(requestArray.size() <=0){
|
|
|
|
+ return tags;
|
|
|
|
+ }
|
|
|
|
+ CdfProductListByIdsRequest param = new CdfProductListByIdsRequest(requestArray);
|
|
|
|
+ CdfProductListByIdsVo vos = cdfClient.getProductListByIds(param);
|
|
|
|
+ if(vos.getProductCardList()!=null && vos.getProductCardList().size() >0){
|
|
|
|
+ for (CdfProduct cdfProduct : vos.getProductCardList()) {
|
|
|
|
+ productMap.put(cdfProduct.getId(),cdfProduct);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (Object obj : tags) {
|
|
|
|
+ JSONObject tag = (JSONObject) obj;
|
|
|
|
+ String sid = tag.getString("sid");
|
|
|
|
+ JSONArray jsonArray = resultMap.get(sid);
|
|
|
|
+ if(jsonArray==null || jsonArray.size()<=0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ List<CdfProduct> cdfProductList = new ArrayList<>();
|
|
|
|
+ for (Object o : jsonArray) {
|
|
|
|
+ cdfProductList.add(productMap.get(o));
|
|
|
|
+ }
|
|
|
|
+ if(cdfProductList.size() >0){
|
|
|
|
+ tag.put("products",cdfProductList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return tags;
|
|
return tags;
|