mirror of https://github.com/jeecgboot/jeecg-boot
Refactor HLJob to make it possible to change request URL
parent
0419db4f72
commit
09bcd7938c
|
@ -21,12 +21,13 @@ import java.util.List;
|
|||
*/
|
||||
@Slf4j
|
||||
public class HLRequest {
|
||||
private final static String URL = "http://www.antugj.com:8082/selectTrack.htm";
|
||||
private static final RequestConfig REQUEST_CONFIG = RequestConfig.custom().build();
|
||||
private final String url;
|
||||
|
||||
private final List<String> billCodes;
|
||||
|
||||
public HLRequest(List<String> billCodes) {
|
||||
public HLRequest(String url, List<String> billCodes) {
|
||||
this.url = url;
|
||||
this.billCodes = billCodes;
|
||||
}
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class HLRequest {
|
|||
while (attempts++ < 5) {
|
||||
try {
|
||||
HttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(REQUEST_CONFIG).build();
|
||||
HttpPost request = new HttpPost(URL);
|
||||
HttpPost request = new HttpPost(url);
|
||||
|
||||
// adding the form data
|
||||
request.setEntity(new UrlEncodedFormEntity(generateFormData(), "UTF-8"));
|
||||
|
|
|
@ -35,6 +35,8 @@ public class HLJob implements Job {
|
|||
@Autowired
|
||||
private IPlatformOrderService platformOrderService;
|
||||
|
||||
private final static String URL = "http://www.antugj.com:8082/selectTrack.htm";
|
||||
|
||||
private static final Integer DEFAULT_NUMBER_OF_DAYS = 15;
|
||||
private static final Integer DEFAULT_MAXIMUM_NUMBER_OF_PARCELS_PER_TRANSACTION = 800;
|
||||
private static final List<String> DEFAULT_TRANSPORTERS = Arrays.asList("法国专线普货");
|
||||
|
@ -91,7 +93,7 @@ public class HLJob implements Job {
|
|||
List<HLResponseItem> parcelTraces = new ArrayList<>();
|
||||
List<HLRequest> hlRequests = new ArrayList<>();
|
||||
billCodeLists.forEach(billcodeList -> {
|
||||
HLRequest hlRequest = new HLRequest(billcodeList);
|
||||
HLRequest hlRequest = new HLRequest(URL, billcodeList);
|
||||
hlRequests.add(hlRequest);
|
||||
});
|
||||
List<Boolean> results = new ArrayList<>();
|
||||
|
|
Loading…
Reference in New Issue