|
@@ -1,10 +1,12 @@
|
|
|
package com.shanghaichengdi.downloadcenterserver.faced;
|
|
|
|
|
|
import com.shanghaichengdi.downloadcentercommon.util.ImageDownload;
|
|
|
+import com.shanghaichengdi.downloadcenterserver.cache.UrlData;
|
|
|
import java.io.File;
|
|
|
import java.net.URL;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -24,6 +26,7 @@ public class PicDownloadFaced extends Thread {
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
+ List<String> imgUrlToSave = new ArrayList<>(this.imageUrls.size());
|
|
|
String time = passTime;
|
|
|
Date times = null;
|
|
|
try {
|
|
@@ -49,7 +52,8 @@ public class PicDownloadFaced extends Thread {
|
|
|
boolean isSuccess = false;
|
|
|
URL url = null;
|
|
|
try {
|
|
|
- String photoFile = "/shipAnalysis/HDImages/" + dirs + "/" + "P" + i + "_" + newTime + ".jpg";
|
|
|
+ String urlToSave = dirs + "/" + "P" + i + "_" + newTime + ".jpg";
|
|
|
+ String photoFile = "/shipAnalysis/HDImages/" + urlToSave;
|
|
|
while (!isSuccess) {
|
|
|
try {
|
|
|
isSuccess = ImageDownload.download(imageUrl, photoFile);
|
|
@@ -58,11 +62,17 @@ public class PicDownloadFaced extends Thread {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ imgUrlToSave.add(urlToSave);
|
|
|
i++;
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ addQueue(imgUrlToSave);
|
|
|
+ }
|
|
|
+
|
|
|
+ private synchronized static void addQueue(List<String> imgUrlToSave) {
|
|
|
+ UrlData.URL_IMG_TO_SAVE.add(imgUrlToSave);
|
|
|
}
|
|
|
}
|