|
|
@@ -19,6 +19,8 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class SatelliteRadarImageDataService {
|
|
|
+ public static final String BASE_URL = "http://www.nmc.cn/";
|
|
|
+
|
|
|
@Value("${yb.fixedTime}")
|
|
|
private Boolean ybFixedTime;
|
|
|
/**
|
|
|
@@ -36,6 +38,7 @@ public class SatelliteRadarImageDataService {
|
|
|
if (ybFixedTime) {
|
|
|
return;
|
|
|
}
|
|
|
+ this.downloadFY4ATrueColorPicture();
|
|
|
this.FY4Ainfrared();
|
|
|
this.FY4AWaterVapour();
|
|
|
this.radarChinaAll();
|
|
|
@@ -44,11 +47,11 @@ public class SatelliteRadarImageDataService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * FY4A红外,三分钟一次
|
|
|
+ * FY4A红外
|
|
|
*/
|
|
|
private void FY4Ainfrared() {
|
|
|
log.info("下载FY4A红外图片");
|
|
|
- String url = "http://www.nmc.cn/publish/satellite/FY4A-infrared.htm";
|
|
|
+ String url = BASE_URL + "publish/satellite/FY4A-infrared.htm";
|
|
|
try {
|
|
|
Document doc = Jsoup.connect(url).timeout(10000).get();
|
|
|
Elements HYS = doc.getElementsByClass("col-xs-12 time ");
|
|
|
@@ -107,11 +110,75 @@ public class SatelliteRadarImageDataService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * FY4A水汽,3分钟一次
|
|
|
+ * FY4A真彩色
|
|
|
+ */
|
|
|
+ public void downloadFY4ATrueColorPicture() {
|
|
|
+ log.info("下载FY4A真彩色图片");
|
|
|
+ String url = BASE_URL + "publish/satellite/FY4A-true-color.htm";
|
|
|
+ try {
|
|
|
+ Document doc = Jsoup.connect(url).timeout(10000).get();
|
|
|
+ Elements HYS = doc.getElementsByClass("col-xs-12 time ");
|
|
|
+ Elements e = doc.getElementsByClass("col-xs-12 time actived");
|
|
|
+ HYS.add(e.get(0));
|
|
|
+ File file = new File(duplicateFile);
|
|
|
+ if (!file.exists()) {
|
|
|
+ file.createNewFile(); // 创建新文件,有同名的文件的话直接覆盖
|
|
|
+ }
|
|
|
+ FileOutputStream fos = new FileOutputStream(file, true);
|
|
|
+ OutputStreamWriter osw = new OutputStreamWriter(fos);
|
|
|
+ BufferedWriter bw = new BufferedWriter(osw);
|
|
|
+ BufferedReader reader = null;
|
|
|
+ for (int i = 0; i < HYS.size(); i++) {
|
|
|
+ Elements a = HYS.get(i).getElementsByAttribute("data-img");
|
|
|
+ String imgUrl = a.attr("data-img");
|
|
|
+ log.info("imgUrl:" + imgUrl);
|
|
|
+ String[] timeStrList = imgUrl.split("_");
|
|
|
+ String timeStr = timeStrList[timeStrList.length - 1];
|
|
|
+ String dtr = timeStr.substring(0, 12);
|
|
|
+ String yearPlist = dtr.substring(0, 4);
|
|
|
+ String monthPlist = dtr.substring(4, 6);
|
|
|
+ String dayPlist = dtr.substring(6, 8);
|
|
|
+ String timePlist = dtr.substring(8, 10);
|
|
|
+ String minutePlist = dtr.substring(10, 12);
|
|
|
+ String fileName = "IMAGE,fyzc," + yearPlist + "_" + monthPlist + "_" + dayPlist + "_" + timePlist + "_" + minutePlist + "_00.JPG";
|
|
|
+ log.info("fileName:" + fileName);
|
|
|
+ reader = new BufferedReader(new FileReader(
|
|
|
+ duplicateFile));
|
|
|
+ String line = reader.readLine();
|
|
|
+ int temp = 0;
|
|
|
+ while (line != null) {
|
|
|
+ if(line.equals(fileName)){
|
|
|
+ temp = temp+1;
|
|
|
+ line = null;
|
|
|
+ }else {
|
|
|
+ line = reader.readLine();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(temp>0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ bw.write(fileName);
|
|
|
+ bw.newLine();
|
|
|
+ bw.flush();
|
|
|
+ String saveFile = downloadFilePath + fileName;
|
|
|
+ downloadPicture(imgUrl, saveFile);
|
|
|
+ }
|
|
|
+ bw.close();
|
|
|
+ osw.close();
|
|
|
+ fos.close();
|
|
|
+ reader.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * FY4A水汽
|
|
|
*/
|
|
|
private void FY4AWaterVapour() {
|
|
|
log.info("下载FY4A水汽图片");
|
|
|
- String url = "http://www.nmc.cn/publish/satellite/FY4A-water-vapour.htm";
|
|
|
+ String url = BASE_URL + "publish/satellite/FY4A-water-vapour.htm";
|
|
|
try {
|
|
|
Document doc = Jsoup.connect(url).timeout(10000).get();
|
|
|
Elements HYS = doc.getElementsByClass("col-xs-12 time ");
|
|
|
@@ -170,11 +237,11 @@ public class SatelliteRadarImageDataService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 增强,半小时一次
|
|
|
+ * 增强
|
|
|
*/
|
|
|
private void watervapor() {
|
|
|
log.info("下载增强图片");
|
|
|
- String url = "http://www.nmc.cn/publish/satellite/fy2e/water_vapor.html";
|
|
|
+ String url = BASE_URL + "publish/satellite/fy2e/water_vapor.html";
|
|
|
try {
|
|
|
Document doc = Jsoup.connect(url).timeout(10000).get();
|
|
|
Elements HYS = doc.getElementsByClass("col-xs-12 time ");
|
|
|
@@ -237,7 +304,7 @@ public class SatelliteRadarImageDataService {
|
|
|
*/
|
|
|
private void radarChinaAll() {
|
|
|
log.info("下载全国雷达拼图图片");
|
|
|
- String url = "http://www.nmc.cn/publish/radar/chinaall.html";
|
|
|
+ String url = BASE_URL + "publish/radar/chinaall.html";
|
|
|
try {
|
|
|
Document doc = Jsoup.connect(url).timeout(10000).get();
|
|
|
Elements HYS = doc.getElementsByClass("col-xs-12 time ");
|