审查视图

src/main/java/com/example/demo/scheduled/FWBTask.java 2.8 KB
朱兆平 authored
1 2
package com.example.demo.scheduled;
朱兆平 authored
3 4 5 6 7 8 9 10 11
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;
朱兆平 authored
12 13
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
朱兆平 authored
14
import org.springframework.beans.factory.annotation.Autowired;
朱兆平 authored
15 16 17
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
朱兆平 authored
18 19
import java.math.BigDecimal;
import java.math.BigInteger;
朱兆平 authored
20 21 22 23 24 25 26 27 28 29 30 31 32 33
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");
朱兆平 authored
34 35 36

    @Autowired
    private  T_ETL_MESSAGE_Service message_service;
37 38

//    @Scheduled(fixedRate = 5000)
朱兆平 authored
39
    @Scheduled(cron="0/10 * *  * * ?")
40
    public void FWB_analysis(){
朱兆平 authored
41 42
        logger.info("scheduled - fixedRate - print time every 5 seconds:{}", format.format(new Date()) );
朱兆平 authored
43 44 45 46 47
        //读取fwb报文
        List<T_ETL_MESSAGE> messageList = message_service.selectFWB();
        for (T_ETL_MESSAGE message : messageList){
            String content = message.getContent();
            BigDecimal fid = message.getFid();
朱兆平 authored
48
朱兆平 authored
49 50 51
            T_ETL_FWB_Handle fwb_handle = new T_ETL_FWB_Handle();
            fwb_handle.insertHandle(content,fid);
        }
朱兆平 authored
52 53 54


朱兆平 authored
55 56 57
        long beginTime = System.currentTimeMillis();

朱兆平 authored
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    }

    /**
     "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触发
     */
74 75 76 77 78
    @Scheduled(cron="0/10 * *  * * ?")
    public void scheduledCronDemo(){
        logger.info("scheduled - cron - print time every 10 seconds:{}", format.format(new Date()) );

朱兆平 authored
79
80 81

    }
朱兆平 authored
82
朱兆平 authored
83
}