版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Maxiao1204/article/details/82905750
private String getBigDataRecProductIds(Map<String, Object> recRequestParams, List<String> productList,Map<String, String> productScoreMap) {
String rec_batch_id = "";
logger.info("获取大数据推荐http post:" + recUrl + "params:" + JSONObject.toJSON(recRequestParams));
LogUtils.startLogWeb("请求智能推荐城市热销");
String result = HttpUtils.post(recUrl, recRequestParams, 1000);
LogUtils.endLogWeb();
logger.info("获取大数据推荐http post:" + recUrl + "result:" + result);
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject == null) {
return null;
}
if (jsonObject.get("rec_batch_id") != null) {
rec_batch_id = jsonObject.get("rec_batch_id").toString();
if (jsonObject.get("rec_list") != null) {
JSONArray jsonArray = (JSONArray) jsonObject.get("rec_list");
Iterator<Object> iterator = jsonArray.iterator();
while (iterator.hasNext()) {
Map<String, Object> recMap = (Map<String, Object>) iterator.next();
if (recMap.get("product_id") != null && recMap.get("category_id") != null && recMap.get("rec_score") != null) {
String productId = recMap.get("product_id").toString();
String categoryId = recMap.get("category_id").toString();
String productScore = recMap.get("rec_score").toString();
productList.add(productId);
productScoreMap.put(productId + "_" + categoryId, productScore);
}
}
}
} else {
logger.warn("cityHotsaleRec warn未获取到推荐数据 params:" + JSONObject.toJSON(recRequestParams));
if (jsonObject.get("errorMessage") != null) {
LogUtils.appendLogWeb("大数据未获取推荐 cause:" + jsonObject.get("errorMessage").toString());
}
}
return rec_batch_id;
}