FWBTask.java 2.8 KB
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()) );




    }

}