|
@@ -73,58 +73,6 @@ public class DownLoadService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void downloadJob() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- //@Valid注解启动后台校验,
|
|
|
- ModelAndView modelAndView = new ModelAndView();
|
|
|
- Long startT = System.currentTimeMillis();
|
|
|
- log.info("下载RB文件开始,时间:" + DateTimeUtil.getStringDate());
|
|
|
-
|
|
|
- String message = "下载成功!";
|
|
|
- log.info("开始执行定时任务:http下载文件");
|
|
|
- String body = HttpRequest.get("https://117.78.19.70:9010/client/getDownLoadFileAll/" + "J00059").execute().body();
|
|
|
- JSONObject json = JSONUtil.parseObj(body);
|
|
|
- String code = json.get("code").toString();
|
|
|
- String data = json.get("data").toString();
|
|
|
- if (code.equals("0") && data.length() > 0) {
|
|
|
- JSONArray array = JSONUtil.parseArray(data);
|
|
|
- List<FileCreateLog> list = array.toList(FileCreateLog.class);
|
|
|
- Date date = new Date();
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
|
|
|
- String dir = "/Users/wanghongchen/fsdownload/"+"J00059"+"/"+"new/";
|
|
|
- String dirBak = "/Users/wanghongchen/fsdownload/"+"J00059"+"/"+"backups/"+simpleDateFormat.format(date)+"/";
|
|
|
- //循环backups下的文件,有文件则不下载
|
|
|
- File fileDirectory = new File(dir);
|
|
|
- if(!fileDirectory.exists()){
|
|
|
- fileDirectory.mkdir();
|
|
|
- }
|
|
|
- File bakDirectory = new File(dirBak);
|
|
|
- if(!bakDirectory.exists()){
|
|
|
- bakDirectory.mkdir();
|
|
|
- }
|
|
|
- try {
|
|
|
- for (FileCreateLog fileCreateLog : list) {
|
|
|
- File file= new File(bakDirectory+File.separator+fileCreateLog.getFileName());
|
|
|
- if(!file.exists()){
|
|
|
- String url = "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
|
|
|
- long a = HttpUtil.downloadFile(url, dir + File.separatorChar + fileCreateLog.getFileName());
|
|
|
- if(a>0){
|
|
|
- log.info("J00059"+"场站"+fileCreateLog.getFileName()+"文件下载成功");
|
|
|
- }
|
|
|
- }else{
|
|
|
- log.info("文件已经下载过了");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("文件下载失败", e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
|
|
|
}
|