ScheduledTask.java 1.04 KB
package com.xkl.config;

import com.xkl.domain.XklAmpReportMetaScoreStandardEntity;
import com.xkl.repository.XklAmpReportMetaScoreStandardRespository;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Iterator;


/**
 * Created by win7 on 2016/11/21.
 * 定时任务读取打分标准
 */
@Component
@CommonsLog
public class ScheduledTask {
    @Autowired
    private XklAmpReportMetaScoreStandardRespository scoreStandardRespository;

    @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
    public void getTableMap(){
        log.info("Load ScoreStandard Table");
        Iterator<XklAmpReportMetaScoreStandardEntity> it=scoreStandardRespository.findAll().iterator();
        while(it.hasNext()){
            XklAmpReportMetaScoreStandardEntity scoreStandard=it.next();
            Constants.scoreMap.put(scoreStandard.getItemId(),scoreStandard);
        }
    }
}