public static String postHttp(String url, String map) throws IOException {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
log.info("请求时间" + DateUtil.now() + "_请求URL" + url + "_请求参数" + map);
// 设置请求的header
httppost.addHeader("Content-type", "application/json");
// 设置请求的参数
StringEntity entity = new StringEntity(map, "utf-8");
httppost.setEntity(entity);
HttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == 200) {
/*读返回数据*/
String conResult = EntityUtils.toString(response.getEntity());
if (conResult != null && !conResult.equals("[]") && StringUtils.isNotBlank(conResult) && StringUtils.isNotBlank(conResult)) {
log.info("请求时间" + DateUtil.now() + "_回调参数" + conResult);
return conResult;
} else {
log.info("请求时间" + DateUtil.now() + "_返回数据为空");
return "返回数据为空";
}
} else {
String err = response.getStatusLine().getStatusCode() + "";
log.error("请求时间" + DateUtil.now() + "_错误参数" + err);
return err;
}
}
请求封装参数
List<> redisData = getRedisData();
for (HouseProperty redisDatum : redisData) {
HousePropertyArrayList.add(redisDatum);
}
Map<String, Object> stringObjectHashMap = new HashMap<>();
stringObjectHashMap.put("systemId", "");
stringObjectHashMap.put("isFull", "");
// map键可以封装list作为值
stringObjectHashMap.put("masterData", HousePropertyArrayList);
String url;
if (mdmHouseInfoEntities.size() == 1) {
url = "";
} else {
url = ";
}
String s = postHttp(url, JSON.toJSONString(stringObjectHashMap));
Map mapTypes = JSON.parseObject(s);
if ("OK".equals(mapTypes.get("status"))){
String fb = redisService.getFuzzyMatching("fs_house_u_*");
sumit(fb);
}