FWBTask.java
2.8 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.example.demo.scheduled;
import com.example.demo.handle.T_ETL_FWB_Handle;
import com.example.demo.model.T_ETL_MESSAGE;
import com.example.demo.model.T_TXD_FWB;
import com.example.demo.model.T_TXD_FWBPARTY;
import com.example.demo.service.T_ETL_MESSAGE_Service;
import com.example.demo.service.T_TXD_FWB_Service;
import com.example.demo.util.XML.XML2ENTITY;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 定时任务
*/
@Component
public class FWBTask {
private static final Logger logger = LoggerFactory.getLogger(FWBTask.class);
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
private T_ETL_MESSAGE_Service message_service;
// @Scheduled(fixedRate = 5000)
@Scheduled(cron="0/10 * * * * ?")
public void FWB_analysis(){
logger.info("scheduled - fixedRate - print time every 5 seconds:{}", format.format(new Date()) );
//读取fwb报文
List<T_ETL_MESSAGE> messageList = message_service.selectFWB();
for (T_ETL_MESSAGE message : messageList){
String content = message.getContent();
BigDecimal fid = message.getFid();
T_ETL_FWB_Handle fwb_handle = new T_ETL_FWB_Handle();
fwb_handle.insertHandle(content,fid);
}
long beginTime = System.currentTimeMillis();
}
/**
"0/5 * * * * ?" 每5秒触发
"0 0 12 * * ?" 每天中午十二点触发
"0 15 10 ? * *" 每天早上10:15触发
"0 15 10 * * ?" 每天早上10:15触发
"0 15 10 * * ? *" 每天早上10:15触发
"0 15 10 * * ? 2005" 2005年的每天早上10:15触发
"0 * 14 * * ?" 每天从下午2点开始到2点59分每分钟一次触发
"0 0/5 14 * * ?" 每天从下午2点开始到2:55分结束每5分钟一次触发
"0 0/5 14,18 * * ?" 每天的下午2点至2:55和6点至6点55分两个时间段内每5分钟一次触发
"0 0-5 14 * * ?" 每天14:00至14:05每分钟一次触发
"0 10,44 14 ? 3 WED" 三月的每周三的14:10和14:44触发
"0 15 10 ? * MON-FRI" 每个周一、周二、周三、周四、周五的10:15触发
*/
@Scheduled(cron="0/10 * * * * ?")
public void scheduledCronDemo(){
logger.info("scheduled - cron - print time every 10 seconds:{}", format.format(new Date()) );
}
}