1.remove init method

main
Gary 9 months ago
parent a6537e3461
commit b792b647f5

@ -45,10 +45,9 @@ public class SaticScheduleTask {
@Autowired @Autowired
private TagDao tagDao; private TagDao tagDao;
@PostConstruct /*
private void init() { * @PostConstruct private void init() { updateAutoComplete(); }
updateAutoComplete(); */
}
// 1.凌晨4点执行更新期刊tag // 1.凌晨4点执行更新期刊tag
@Scheduled(cron = "0 0 4 * * *") @Scheduled(cron = "0 0 4 * * *")
@ -61,27 +60,29 @@ public class SaticScheduleTask {
} }
// 2.凌晨4:20点执行更新分词 // 2.凌晨4:20点执行更新分词
@Scheduled(cron = "0 20 4 * * *") /*
private void updateAutoComplete() { * @Scheduled(cron = "0 20 4 * * *") private void updateAutoComplete() {
Stream<Entry<String, Set<String>>> journalSongStream = journalSongDao.findAll().parallelStream() * Stream<Entry<String, Set<String>>> journalSongStream =
.map(j -> getJournalSongMap(j)).flatMap(m -> m.entrySet().stream()); * journalSongDao.findAll().parallelStream() .map(j ->
* getJournalSongMap(j)).flatMap(m -> m.entrySet().stream());
Stream<Entry<String, Set<String>>> journalStream = journalDao.findValidJournals().parallelStream() *
.map(j -> getJournalMap(j)).flatMap(m -> m.entrySet().stream()); * Stream<Entry<String, Set<String>>> journalStream =
* journalDao.findValidJournals().parallelStream() .map(j ->
Map<String, List<Entry<String, Set<String>>>> map = Stream.concat(journalSongStream, journalStream) * getJournalMap(j)).flatMap(m -> m.entrySet().stream());
.collect(Collectors.groupingBy(e -> e.getKey())); *
* Map<String, List<Entry<String, Set<String>>>> map =
int keyCount = map.size(); * Stream.concat(journalSongStream, journalStream)
int cacheKeyCount = cacheChannel.keys(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE).size(); * .collect(Collectors.groupingBy(e -> e.getKey()));
if (keyCount != cacheKeyCount) { *
map.entrySet().parallelStream().forEach(e -> { * int keyCount = map.size(); int cacheKeyCount =
List<String> value = e.getValue().stream().flatMap(a -> a.getValue().stream()).distinct().sorted() * cacheChannel.keys(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE).
.collect(Collectors.toList()); * size(); if (keyCount != cacheKeyCount) {
cacheChannel.set(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE, e.getKey(), value); * map.entrySet().parallelStream().forEach(e -> { List<String> value =
}); * e.getValue().stream().flatMap(a -> a.getValue().stream()).distinct().sorted()
} * .collect(Collectors.toList());
} * cacheChannel.set(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE,
* e.getKey(), value); }); } }
*/
private Map<String, Set<String>> getJournalMap(Journal j) { private Map<String, Set<String>> getJournalMap(Journal j) {
Map<String, Set<String>> map = new HashMap<>(); Map<String, Set<String>> map = new HashMap<>();

Loading…
Cancel
Save