|
@@ -9,7 +9,6 @@ import com.sinoqixin.bgdrocketmq.vo.AjaxResult;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.context.annotation.PropertySource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
@@ -17,28 +16,22 @@ import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-@PropertySource(value = {"classpath:rocketMQ.properties"})
|
|
|
public class GetProducePlanDetailApiService {
|
|
|
-
|
|
|
- /*@Value("${queryPlanInfoForPowerSupplyUrl_simulation}")
|
|
|
- private String queryPlanInfoForPowerSupplyUrl;
|
|
|
- @Value("${queryPlanBusinessInfoUrl_simulation}")
|
|
|
- private String queryPlanBusinessInfoUrl;*/
|
|
|
-
|
|
|
//分省标识
|
|
|
private final static String TOP_PROVINCE_FLAG = "7F079D562F9A8360BE8CA1292A27AF28";
|
|
|
private final static String BUSINESS_TYPES = "Source_164";
|
|
|
- @Value("${queryPlanInfoForPowerSupplyUrl_formal}")
|
|
|
+
|
|
|
+ @Value("${consumer.queryPlanInfoForPowerSupplyUrl_formal}")
|
|
|
private String queryPlanInfoForPowerSupplyUrl;
|
|
|
- @Value("${queryPlanBusinessInfoUrl_formal}")
|
|
|
+ @Value("${consumer.queryPlanBusinessInfoUrl_formal}")
|
|
|
private String queryPlanBusinessInfoUrl;
|
|
|
- @Value("${getToken_url}")
|
|
|
+ @Value("${consumer.getToken_url}")
|
|
|
private String getTokenUrl;
|
|
|
- @Value("${getToken_account}")
|
|
|
+ @Value("${consumer.getToken_account}")
|
|
|
private String getTokenAccount;
|
|
|
- @Value("${getToken_password}")
|
|
|
+ @Value("${consumer.getToken_password}")
|
|
|
private String getTokenPassword;
|
|
|
- @Value("${getToken_authCode}")
|
|
|
+ @Value("${consumer.getToken_authCode}")
|
|
|
private String getTokenAuthCode;
|
|
|
|
|
|
public AjaxResult getPlanBusinessInfoByApi(String planIds, String bureauCode, int timeout) {
|
|
@@ -65,12 +58,11 @@ public class GetProducePlanDetailApiService {
|
|
|
headerMap.put("topProvinceFlag", TOP_PROVINCE_FLAG);
|
|
|
|
|
|
log.info("【queryPlanBusinessInfo】开始请求,地址:{},请求头:{},请求体:{}", queryPlanBusinessInfoUrl, headerMap, bodyMap);
|
|
|
- try {
|
|
|
- HttpResponse httpResponse = HttpRequest.post(queryPlanBusinessInfoUrl)
|
|
|
- .headerMap(headerMap, false)
|
|
|
- .timeout(timeout)
|
|
|
- .body(JSONObject.toJSONString(bodyMap))
|
|
|
- .execute();
|
|
|
+ try(HttpResponse httpResponse = HttpRequest.post(queryPlanBusinessInfoUrl)
|
|
|
+ .headerMap(headerMap, false)
|
|
|
+ .timeout(timeout)
|
|
|
+ .body(JSONObject.toJSONString(bodyMap))
|
|
|
+ .execute()) {
|
|
|
if (httpResponse == null) {
|
|
|
return AjaxResult.error("【queryPlanBusinessInfoUrl】请求返回结果 httpResponse 为空");
|
|
|
}
|
|
@@ -88,7 +80,7 @@ public class GetProducePlanDetailApiService {
|
|
|
}
|
|
|
return AjaxResult.error(httpResponse.body());
|
|
|
} catch (HttpException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("", e);
|
|
|
log.info("【queryPlanBusinessInfoUrl】请求异常,请求地址:{},请求头部:{},请求参数:{},异常信息:{}", queryPlanBusinessInfoUrl, headerMap, bodyMap, e.getMessage());
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
}
|
|
@@ -129,12 +121,11 @@ public class GetProducePlanDetailApiService {
|
|
|
headerMap.put("access-token", token);
|
|
|
headerMap.put("topProvinceFlag", TOP_PROVINCE_FLAG);
|
|
|
log.info("【queryPlanInfoForPowerSupply】开始请求,地址:{},请求头:{},请求体:{}", queryPlanInfoForPowerSupplyUrl, headerMap, bodyMap);
|
|
|
- try {
|
|
|
- HttpResponse httpResponse = HttpRequest.post(queryPlanInfoForPowerSupplyUrl)
|
|
|
- .headerMap(headerMap, false)
|
|
|
- .timeout(timeout)
|
|
|
- .body(JSONObject.toJSONString(bodyMap))
|
|
|
- .execute();
|
|
|
+ try (HttpResponse httpResponse = HttpRequest.post(queryPlanInfoForPowerSupplyUrl)
|
|
|
+ .headerMap(headerMap, false)
|
|
|
+ .timeout(timeout)
|
|
|
+ .body(JSONObject.toJSONString(bodyMap))
|
|
|
+ .execute()) {
|
|
|
if (httpResponse == null) {
|
|
|
return AjaxResult.error("【queryPlanInfoForPowerSupply】请求返回结果 httpResponse 为空");
|
|
|
}
|
|
@@ -142,21 +133,13 @@ public class GetProducePlanDetailApiService {
|
|
|
log.info("【queryPlanInfoForPowerSupply】本次请求status:{},地址:{},返回结果是:{}", code, queryPlanInfoForPowerSupplyUrl, httpResponse.body());
|
|
|
if (httpResponse.isOk()) {
|
|
|
String jsonStr = httpResponse.body();
|
|
|
-// JSONObject jsonObject = JSONObject.parseObject(jsonStr);
|
|
|
-
|
|
|
return AjaxResult.success("queryPlanInfoForPowerSupply获取成功", jsonStr);
|
|
|
-
|
|
|
- /*if (jsonObject.getInteger("code") == 200) {
|
|
|
- return AjaxResult.success(jsonStr);
|
|
|
- } else {
|
|
|
- log.info("【queryPlanInfoForPowerSupply】请求返回结果异常,请求地址:{},请求头部:{},请求参数:{},返回结果是:{}", queryPlanInfoForPowerSupplyUrl, headerMap, bodyMap, httpResponse.body());
|
|
|
- }*/
|
|
|
} else {
|
|
|
log.info("【queryPlanInfoForPowerSupply】请求数据失败,请求地址:{},请求头部:{},请求参数:{},返回结果是:{}", queryPlanInfoForPowerSupplyUrl, headerMap, bodyMap, httpResponse.body());
|
|
|
}
|
|
|
return AjaxResult.error(httpResponse.body());
|
|
|
} catch (HttpException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("", e);
|
|
|
log.info("【queryPlanInfoForPowerSupply】请求异常,请求地址:{},请求头部:{},请求参数:{},异常信息:{}", queryPlanInfoForPowerSupplyUrl, headerMap, bodyMap, e.getMessage());
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
}
|
|
@@ -174,12 +157,12 @@ public class GetProducePlanDetailApiService {
|
|
|
bodyMap.put("password", getTokenPassword);
|
|
|
bodyMap.put("authCode", getTokenAuthCode);
|
|
|
log.info("【queryPlanInfoForPowerSupply】开始请求,地址:{},请求体:{}", queryPlanInfoForPowerSupplyUrl, bodyMap);
|
|
|
- try {
|
|
|
- HttpResponse httpResponse = HttpRequest.post(getTokenUrl)
|
|
|
- .timeout(timeout)
|
|
|
- .header("Content-Type", "application/json")
|
|
|
- .body(JSONObject.toJSONString(bodyMap))
|
|
|
- .execute();
|
|
|
+ try (HttpResponse httpResponse = HttpRequest.post(getTokenUrl)
|
|
|
+ .timeout(timeout)
|
|
|
+ .header("Content-Type", "application/json")
|
|
|
+ .body(JSONObject.toJSONString(bodyMap))
|
|
|
+ .execute()) {
|
|
|
+
|
|
|
if (httpResponse == null) {
|
|
|
return AjaxResult.error("【getToken】请求返回结果 httpResponse 为空");
|
|
|
}
|
|
@@ -199,7 +182,7 @@ public class GetProducePlanDetailApiService {
|
|
|
return AjaxResult.error(httpResponse.body());
|
|
|
}
|
|
|
} catch (HttpException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("", e);
|
|
|
log.info("【getToken】请求异常,请求地址:{},请求参数:{},异常信息:{}", getTokenUrl, bodyMap, e.getMessage());
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
}
|