yangys
2024-05-30 a3686cfa49bf53fb91a2ceb960cf15b3ebdac641
smart-man-boot/src/main/java/com/qianwen/smartman/common/cache/cps/TimeSliceCache.java
@@ -86,7 +86,7 @@
    if (Func.isEmpty(members)) {
      ProductionCalendar calendar = (ProductionCalendar)CALENDAR_SERVICE.getOne(Wrappers.<ProductionCalendar>lambdaQuery().eq(ProductionCalendar::getCode, calendarCode));
      
      return (List) Optional.ofNullable(calendar).map(cal -> {
      return Optional.ofNullable(calendar).map(cal -> {
          ProductionCalendarDay calendarDay = CALENDAR_DAY_SERVICE.getOne((Wrappers.<ProductionCalendarDay>lambdaQuery().eq((v0) -> {
              return v0.getCalendarId();
          }, cal.getId())).eq((v0) -> {
@@ -189,15 +189,19 @@
    return (Map<String, CurrentShiftInfoDTO>)currentShiftInfoDTOList.stream().distinct().collect(Collectors.toMap(CurrentShiftInfoDTO::getCalendarCode, v -> v));
  }
  
  /**
   * 构建生产日历切片缓存,从CalendarCacheXxlJob中定时调用
   * @param cacheBuildDTO
   */
  public static void build(CacheBuildDTO cacheBuildDTO) {
    String key = cacheBuildDTO.getTargetDate().format(DateTimeFormatter.ISO_LOCAL_DATE);
    List<TimestampToProductionTimeCacheDto> data = CALENDAR_SERVICE.buildProductionTimeCache(cacheBuildDTO);
    if (Func.isNotEmpty(data))
      data.forEach(t -> {
            String redisKey = CommonUtil.getReallyCacheName("blade:cps::calendar", "calendars:code:".concat(t.getCalendarCode()).concat(":").concat("minute-point:"), key);
            String redisKey = CommonUtil.getReallyCacheName("blade:cps::calendar", "calendars:code:".concat(t.getCalendarCode()).concat(":").concat("minute-point:"), key);//key格式:yyyy-MM-dd
            Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDtoMap = t.getTimeSlicesDTOMap();
            BLADE_REDIS.getRedisTemplate().opsForHash().putAll(redisKey, timeSlicesDtoMap);
            long oneDaySeconds = 86400L;
            long oneDaySeconds = 86400L;//24小时的秒数
            BLADE_REDIS.expire(redisKey, oneDaySeconds * 40L);
          }); 
  }