ScheduledTask.java
3.01 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
package com.xkl.config;
import com.xkl.domain.XklAmpReportAverageScoreEntity;
import com.xkl.domain.XklAmpReportCategoryEntity;
import com.xkl.domain.XklAmpReportMetaItemsEntity;
import com.xkl.domain.XklAmpReportMetaScoreStandardEntity;
import com.xkl.repository.XklAmpReportAveScoreRespository;
import com.xkl.repository.XklAmpReportCategoryRespository;
import com.xkl.repository.XklAmpReportMetaItemsRespository;
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 implements Constants{
@Autowired
private XklAmpReportMetaScoreStandardRespository scoreStandardRespository;
@Autowired
private XklAmpReportMetaItemsRespository metaItemsRespository;
@Autowired
private XklAmpReportCategoryRespository reportCategoryRespository;
@Autowired
private XklAmpReportAveScoreRespository reportAveScoreRespository;
@Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
public void getTableMap(){
log.info("Load ScoreStandard and reportCategory Table");
Iterator<XklAmpReportMetaScoreStandardEntity> it=scoreStandardRespository.findAll().iterator();
while(it.hasNext()){
XklAmpReportMetaScoreStandardEntity scoreStandard=it.next();
scoreMap.put(scoreStandard.getItemId(),scoreStandard);
}
}
@Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
public void getWeightedScoreMap(){
log.info("Load WeightedScore Table");
Iterator<XklAmpReportCategoryEntity> iterator = reportCategoryRespository.findAll().iterator();
while (iterator.hasNext()){
XklAmpReportCategoryEntity reportCategory = iterator.next();
weightedScoreMap.put(reportCategory.getId(),reportCategory);
}
}
@Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
public void getItemMetaMap(){
log.info("Load ItemMeta Table");
Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator();
while(it.hasNext()){
XklAmpReportMetaItemsEntity reportMetaItems = it.next();
itemMetaMap.put(reportMetaItems.getItemId(),reportMetaItems);
}
}
@Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
public void getAveScoreMap(){
log.info("Load AveScore Table");
Iterator<XklAmpReportAverageScoreEntity> iterator = reportAveScoreRespository.findAll().iterator();
while (iterator.hasNext()){
XklAmpReportAverageScoreEntity reportCategory = iterator.next();
String ageAndType = reportCategory.getAgeId()+"-"+reportCategory.getScoreType();
aveScoreMap.put(ageAndType,reportCategory.getAverageScore());
}
}
}