Commit e676dd19 authored by Quxl's avatar Quxl

x

parent 7c27fdd2
......@@ -41,21 +41,24 @@ public class ProductsTask {
@Scheduled(cron="${pds.cron.products_download}")
public void execute() {
log.debug(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN");
boolean boo = true;
int loopCount = 0;
while(boo) {
boo = executeUpdateTask() > 0 && loopCount++ < 10;
}
log.debug(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN START");
this.executeUpdateTask();
log.debug(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN END");
}
private int executeUpdateTask() {
private void executeUpdateTask() {
Map<String, String> headers = new HashMap<String, String>();
headers.put(authKey, authValue);
boolean isFinishd = false;
while(!isFinishd) {
String responseBody = HttpUtil.get(urlQuery, headers);
JSONObject jsonObject = JSON.parseObject(responseBody);
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++) {
JSONObject productJsonObject = jsonArray.getJSONObject(i);
String article_description = productJsonObject.getString("article_description");
......@@ -110,8 +113,7 @@ public class ProductsTask {
}
}
}
return jsonArray == null ? 0 : jsonArray.size();
}
}
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