正在显示
1 个修改的文件
包含
24 行增加
和
15 行删除
@@ -3,6 +3,7 @@ package com.tianbo.analysis.task; | @@ -3,6 +3,7 @@ package com.tianbo.analysis.task; | ||
3 | import com.tianbo.util.Date.DateUtil; | 3 | import com.tianbo.util.Date.DateUtil; |
4 | import com.tianbo.util.IO.FileTool; | 4 | import com.tianbo.util.IO.FileTool; |
5 | import com.tianbo.analysis.handle.CustomXmlHandle; | 5 | import com.tianbo.analysis.handle.CustomXmlHandle; |
6 | +import lombok.extern.slf4j.Slf4j; | ||
6 | import org.apache.commons.io.FileUtils; | 7 | import org.apache.commons.io.FileUtils; |
7 | import org.springframework.beans.factory.annotation.Value; | 8 | import org.springframework.beans.factory.annotation.Value; |
8 | import org.springframework.scheduling.annotation.Scheduled; | 9 | import org.springframework.scheduling.annotation.Scheduled; |
@@ -15,6 +16,7 @@ import java.util.List; | @@ -15,6 +16,7 @@ import java.util.List; | ||
15 | /** | 16 | /** |
16 | * 回执解析定时任务 | 17 | * 回执解析定时任务 |
17 | */ | 18 | */ |
19 | +@Slf4j | ||
18 | @Component | 20 | @Component |
19 | public class TaskAnalysis { | 21 | public class TaskAnalysis { |
20 | 22 | ||
@@ -39,25 +41,32 @@ public class TaskAnalysis { | @@ -39,25 +41,32 @@ public class TaskAnalysis { | ||
39 | String readDir = receptDir + "/" + today; | 41 | String readDir = receptDir + "/" + today; |
40 | String backdireByDay = bakupDir + "/" + today; | 42 | String backdireByDay = bakupDir + "/" + today; |
41 | 43 | ||
42 | - List<File> files = FileTool.readDirectoryFiles(new File(readDir)); | ||
43 | - Iterator<File> it = files.iterator(); | ||
44 | - while(it.hasNext()){ | ||
45 | - File file = it.next(); | ||
46 | - try { | ||
47 | - //解析 | ||
48 | - int i = new CustomXmlHandle().handelXmlDocument(file); | ||
49 | - //操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份 | ||
50 | - if(i>0){ | ||
51 | - File bakupDirectory = new File(backdireByDay); | ||
52 | - FileUtils.moveFileToDirectory(file,bakupDirectory,true); | ||
53 | - }else { | 44 | + try{ |
45 | + List<File> files = FileTool.readDirectoryFiles(new File(readDir)); | ||
46 | + Iterator<File> it = files.iterator(); | ||
47 | + while(it.hasNext()){ | ||
48 | + File file = it.next(); | ||
49 | + try { | ||
50 | + //解析 | ||
51 | + int i = new CustomXmlHandle().handelXmlDocument(file); | ||
52 | + //操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份 | ||
53 | + if(i>0){ | ||
54 | + File bakupDirectory = new File(backdireByDay); | ||
55 | + FileUtils.moveFileToDirectory(file,bakupDirectory,true); | ||
56 | + }else { | ||
57 | + errBak(file); | ||
58 | + } | ||
59 | + }catch (Exception e){ | ||
60 | + e.printStackTrace(); | ||
61 | + log.error("解析回执出错",e); | ||
54 | errBak(file); | 62 | errBak(file); |
55 | } | 63 | } |
56 | - }catch (Exception e){ | ||
57 | - e.printStackTrace(); | ||
58 | - errBak(file); | ||
59 | } | 64 | } |
65 | + }catch (Exception e){ | ||
66 | + e.printStackTrace(); | ||
67 | + log.error("获取目录文件出错",e); | ||
60 | } | 68 | } |
69 | + | ||
61 | } | 70 | } |
62 | 71 | ||
63 | public void errBak(File file){ | 72 | public void errBak(File file){ |
-
请 注册 或 登录 后发表评论