TaskAnalysis.java
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.tianbo.analysis.task;
import com.tianbo.util.Date.DateUtil;
import com.tianbo.util.IO.FileTool;
import com.tianbo.analysis.handle.CustomXmlHandleThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.Iterator;
import java.util.List;
/**
* 回执解析定时任务
*/
@Slf4j
@Component
public class TaskAnalysis {
//回执读取目录
@Value("${custom.receptDirectory}")
private String receptDir;
@Scheduled(fixedDelay = 500000)
public void startTask(){
//回执目录
String readDir = receptDir;
try{
File fileDirectory = new File(readDir);
List<File> files = FileTool.readDirectoryFiles(fileDirectory);
Iterator<File> it = files.iterator();
while(it.hasNext()){
File file = it.next();
try {
CustomXmlHandleThread customXmlHandleThread = new CustomXmlHandleThread();
customXmlHandleThread.setXmlfile(file);
Thread thread = new Thread(customXmlHandleThread);
thread.start();
}catch (Exception e){
e.printStackTrace();
log.error("解析回执出错",e);
}
}
}catch (Exception e){
e.printStackTrace();
log.error("获取目录文件出错",e);
}
}
}