Commit e676dd19 authored by Quxl's avatar Quxl

x

parent 7c27fdd2
...@@ -41,21 +41,24 @@ public class ProductsTask { ...@@ -41,21 +41,24 @@ public class ProductsTask {
@Scheduled(cron="${pds.cron.products_download}") @Scheduled(cron="${pds.cron.products_download}")
public void execute() { public void execute() {
log.debug(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN"); log.debug(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN START");
boolean boo = true; this.executeUpdateTask();
int loopCount = 0; log.debug(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN END");
while(boo) {
boo = executeUpdateTask() > 0 && loopCount++ < 10;
}
} }
private int executeUpdateTask() { private void executeUpdateTask() {
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put(authKey, authValue); headers.put(authKey, authValue);
boolean isFinishd = false;
while(!isFinishd) {
String responseBody = HttpUtil.get(urlQuery, headers); String responseBody = HttpUtil.get(urlQuery, headers);
JSONObject jsonObject = JSON.parseObject(responseBody); JSONObject jsonObject = JSON.parseObject(responseBody);
JSONArray jsonArray = jsonObject.getJSONArray("data"); JSONArray jsonArray = jsonObject.getJSONArray("data");
if(jsonArray != null) { if(jsonArray == null || jsonArray.size() == 0) {
isFinishd = true;
} else {
for(int i = 0; i < jsonArray.size(); i++) { for(int i = 0; i < jsonArray.size(); i++) {
JSONObject productJsonObject = jsonArray.getJSONObject(i); JSONObject productJsonObject = jsonArray.getJSONObject(i);
String article_description = productJsonObject.getString("article_description"); String article_description = productJsonObject.getString("article_description");
...@@ -110,8 +113,7 @@ public class ProductsTask { ...@@ -110,8 +113,7 @@ public class ProductsTask {
} }
} }
} }
}
return jsonArray == null ? 0 : jsonArray.size();
} }
public static void main(String[] args) { public static void main(String[] args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment