DirectivesPstThread.java
1.36 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
package com.bsth.data.directive;
import com.bsth.entity.directive.D60;
import com.bsth.entity.directive.D64;
import com.bsth.entity.directive.Directive;
import com.bsth.repository.directive.D60Repository;
import com.bsth.repository.directive.D64Repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.LinkedList;
/**
* 指令持久化线程
* Created by panzhao on 2017/3/6.
*/
@Component
public class DirectivesPstThread extends Thread {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
D60Repository d60Repository;
@Autowired
D64Repository d64Repository;
@Override
public void run() {
LinkedList<Directive> list = DayOfDirectives.pstDirectives;
Directive directive;
for (int i = 0; i < 1000; i++) {
try {
directive = list.poll();
if (directive instanceof D60) {
d60Repository.save((D60) directive);
}
if (directive instanceof D64) {
d64Repository.save((D64) directive);
}
} catch (Exception e) {
logger.error("", e);
}
}
}
}