|
@@ -18,6 +18,7 @@ import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -26,7 +27,7 @@ public class ProgramService extends ServiceImpl<ProgramMapper, Program> implemen
|
|
|
@Resource
|
|
|
private EpgDisableConfigService sspDisableConfigService;
|
|
|
|
|
|
- private final Cache<Integer, Object> cache = Caffeine.newBuilder().expireAfterWrite(15, TimeUnit.MINUTES).build();
|
|
|
+ private final Cache<Integer, Object> cache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build();
|
|
|
|
|
|
public List<Map<String, Object>> getProgramList(Integer channelId) {
|
|
|
System.out.println("-------------------获取epg-----------------------");
|
|
@@ -61,11 +62,29 @@ public class ProgramService extends ServiceImpl<ProgramMapper, Program> implemen
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> cacheEpg(Integer channelId) {
|
|
|
- return (List<Map<String, Object>>)cache.get(channelId, key -> getProgramList(channelId));
|
|
|
+ return (List<Map<String, Object>>)cache.get(channelId, key -> getDisableProgramList(channelId));
|
|
|
}
|
|
|
|
|
|
public void setCache(Integer channelId){
|
|
|
System.out.println("更新缓存" + channelId);
|
|
|
cache.put(channelId, getProgramList(channelId));
|
|
|
}
|
|
|
+
|
|
|
+ public List<Map<String, Object>> getDisableProgramList(Integer channelId) {
|
|
|
+
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ LocalDateTime end = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 23, 59, 59);
|
|
|
+ LocalDateTime start = end.minusDays(7).plusSeconds(1);
|
|
|
+ List<Map<String, Object>> rs = new ArrayList<>();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("M月d日");
|
|
|
+
|
|
|
+ Map<LocalDateTime, EpgDisableConfig> sspDisableConfigMap = sspDisableConfigService.cfMap(channelId, start, end);
|
|
|
+
|
|
|
+ baseMapper.listByChannel(channelId, start, end).stream().filter(program -> sspDisableConfigMap.containsKey(program.getStartTime()))
|
|
|
+ .peek(program -> program.setStatus(1)).collect(Collectors.groupingBy(Program::getBroadcastDate))
|
|
|
+ .forEach((k, v) -> rs.add(ImmutableMap.of("date", k.format(formatter), "title", k.format(formatter1), "epg", v)));
|
|
|
+ rs.sort(Comparator.comparing((Map<String, Object> o) -> o.get("date").toString()));
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
}
|