From b792b647f53a58dd6e0614c305d3b17ddb09ce3f Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 6 Mar 2024 00:54:34 +0800 Subject: [PATCH] 1.remove init method --- .../luoo/music/config/SaticScheduleTask.java | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java b/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java index 618b0c1..723b1e5 100644 --- a/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java +++ b/luoo_music/src/main/java/com/luoo/music/config/SaticScheduleTask.java @@ -45,10 +45,9 @@ public class SaticScheduleTask { @Autowired private TagDao tagDao; - @PostConstruct - private void init() { - updateAutoComplete(); - } + /* + * @PostConstruct private void init() { updateAutoComplete(); } + */ // 1.凌晨4点执行更新期刊tag @Scheduled(cron = "0 0 4 * * *") @@ -61,27 +60,29 @@ public class SaticScheduleTask { } // 2.凌晨4:20点执行更新分词 - @Scheduled(cron = "0 20 4 * * *") - private void updateAutoComplete() { - Stream>> journalSongStream = journalSongDao.findAll().parallelStream() - .map(j -> getJournalSongMap(j)).flatMap(m -> m.entrySet().stream()); - - Stream>> journalStream = journalDao.findValidJournals().parallelStream() - .map(j -> getJournalMap(j)).flatMap(m -> m.entrySet().stream()); - - Map>>> map = Stream.concat(journalSongStream, journalStream) - .collect(Collectors.groupingBy(e -> e.getKey())); - - int keyCount = map.size(); - int cacheKeyCount = cacheChannel.keys(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE).size(); - if (keyCount != cacheKeyCount) { - map.entrySet().parallelStream().forEach(e -> { - List 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); - }); - } - } + /* + * @Scheduled(cron = "0 20 4 * * *") private void updateAutoComplete() { + * Stream>> journalSongStream = + * journalSongDao.findAll().parallelStream() .map(j -> + * getJournalSongMap(j)).flatMap(m -> m.entrySet().stream()); + * + * Stream>> journalStream = + * journalDao.findValidJournals().parallelStream() .map(j -> + * getJournalMap(j)).flatMap(m -> m.entrySet().stream()); + * + * Map>>> map = + * Stream.concat(journalSongStream, journalStream) + * .collect(Collectors.groupingBy(e -> e.getKey())); + * + * int keyCount = map.size(); int cacheKeyCount = + * cacheChannel.keys(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE). + * size(); if (keyCount != cacheKeyCount) { + * map.entrySet().parallelStream().forEach(e -> { List 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> getJournalMap(Journal j) { Map> map = new HashMap<>();