|
|
@@ -13,14 +13,8 @@ import java.util.Set;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import com.punchsettle.server.atomic.entity.PiStatus;
|
|
|
-import com.punchsettle.server.atomic.service.IPiStatusService;
|
|
|
-import com.punchsettle.server.constant.CacheNameConstant;
|
|
|
-import com.punchsettle.server.constant.ContinueStatusEnum;
|
|
|
-import com.punchsettle.server.utiis.SpringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.cache.CacheManager;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -28,8 +22,10 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import com.punchsettle.server.atomic.StatPiTask;
|
|
|
+import com.punchsettle.server.atomic.entity.PiStatus;
|
|
|
import com.punchsettle.server.atomic.entity.PiTask;
|
|
|
import com.punchsettle.server.atomic.entity.PiTaskHistory;
|
|
|
+import com.punchsettle.server.atomic.service.IPiStatusService;
|
|
|
import com.punchsettle.server.atomic.service.IPiTaskHistoryService;
|
|
|
import com.punchsettle.server.atomic.service.IPiTaskService;
|
|
|
import com.punchsettle.server.atomic.service.IStatPiTaskMonthService;
|
|
|
@@ -38,6 +34,8 @@ import com.punchsettle.server.common.constant.CommonEnableStatusEnum;
|
|
|
import com.punchsettle.server.common.exception.BusinessException;
|
|
|
import com.punchsettle.server.common.utils.Assert;
|
|
|
import com.punchsettle.server.constant.ArchiveStatusEnum;
|
|
|
+import com.punchsettle.server.constant.CacheNameConstant;
|
|
|
+import com.punchsettle.server.constant.ContinueStatusEnum;
|
|
|
import com.punchsettle.server.constant.PunchInExtraMethodEnum;
|
|
|
import com.punchsettle.server.constant.PunchInMethodEnum;
|
|
|
import com.punchsettle.server.constant.PunchInResultEnum;
|
|
|
@@ -59,10 +57,12 @@ import com.punchsettle.server.pojo.punchIn.PunchInRequest;
|
|
|
import com.punchsettle.server.pojo.stat.StatPiTaskQuery;
|
|
|
import com.punchsettle.server.pojo.ucharts.LineSeriesVO;
|
|
|
import com.punchsettle.server.pojo.ucharts.LineVO;
|
|
|
+import com.punchsettle.server.service.manager.ICacheManager;
|
|
|
import com.punchsettle.server.service.manager.ICalendarManager;
|
|
|
import com.punchsettle.server.service.manager.IPunchInCoreManager;
|
|
|
import com.punchsettle.server.service.manager.IPunchInManager;
|
|
|
import com.punchsettle.server.utiis.DateUtils;
|
|
|
+import com.punchsettle.server.utiis.SpringUtils;
|
|
|
import com.punchsettle.server.utiis.UserUtils;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -96,7 +96,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
private ICalendarManager calendarManager;
|
|
|
|
|
|
@Autowired
|
|
|
- private CacheManager cacheManager;
|
|
|
+ private ICacheManager cacheManager;
|
|
|
|
|
|
@Autowired
|
|
|
private IPiStatusService piStatusService;
|
|
|
@@ -387,12 +387,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
}
|
|
|
|
|
|
// 清除缓存
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_FOR_USER).evict(currentUserId);
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_VO).evict(currentUserId);
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_PUNCH_IN_HISTORY).evict(String.format("%s_%s", currentUserId, today));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_HISTORY_LIST_FOR_USER).evict(String.format("%s_%s", currentUserId, today));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_STAT).evict(String.format("%s_%s", currentUserId, today.toString().substring(0, 7)));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_STAT).evict(String.format("%s_%s", currentUserId, today.toString().substring(0, 4)));
|
|
|
+ clearCache(currentUserId, false, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -406,10 +401,8 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
|
|
|
piTaskService.insert(addPiTask);
|
|
|
|
|
|
- // 清楚缓存
|
|
|
- Long currentUserId = UserUtils.getCurrentUserId();
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_FOR_USER).evict(currentUserId);
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_VO).evict(currentUserId);
|
|
|
+ // 清除缓存
|
|
|
+ clearCache(UserUtils.getCurrentUserId(), false, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -481,11 +474,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
}
|
|
|
|
|
|
// 清楚缓存
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_VO).evict(currentUserId);
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_PUNCH_IN_HISTORY).evict(String.format("%s_%s", currentUserId, punchInDate));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_HISTORY_LIST_FOR_USER).evict(String.format("%s_%s", currentUserId, punchInDate));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_STAT).evict(String.format("%s_%s", currentUserId, punchInDate.substring(0, 7)));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_STAT).evict(String.format("%s_%s", currentUserId, punchInDate.substring(0, 4)));
|
|
|
+ clearCache(currentUserId, true, true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -500,9 +489,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
piTaskService.insert(addPiTask);
|
|
|
|
|
|
// 清楚缓存
|
|
|
- Long currentUserId = UserUtils.getCurrentUserId();
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_FOR_USER).evict(currentUserId);
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_VO).evict(currentUserId);
|
|
|
+ clearCache(UserUtils.getCurrentUserId(), false, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -547,13 +534,7 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
piTaskHistoryService.update(updatePiTaskHistory);
|
|
|
|
|
|
// 清楚缓存
|
|
|
- Long currentUserId = UserUtils.getCurrentUserId();
|
|
|
- String punchInDate = LocalDate.now().toString();
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_LIST_VO).evict(currentUserId);
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_PUNCH_IN_HISTORY).evict(String.format("%s_%s", currentUserId, punchInDate));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_HISTORY_LIST_FOR_USER).evict(String.format("%s_%s", currentUserId, punchInDate));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_STAT).evict(String.format("%s_%s", currentUserId, punchInDate.substring(0, 7)));
|
|
|
- cacheManager.getCache(CacheNameConstant.TASK_STAT).evict(String.format("%s_%s", currentUserId, punchInDate.substring(0, 4)));
|
|
|
+ clearCache(UserUtils.getCurrentUserId(), true, true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -692,4 +673,16 @@ public class PunchInManagerImpl implements IPunchInManager {
|
|
|
|
|
|
return piTaskHistories;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void clearCache(Long userId, boolean deleteHistory, boolean deleteStat) {
|
|
|
+ cacheManager.batchEvict(Arrays.asList(CacheNameConstant.TASK_LIST_FOR_USER, CacheNameConstant.TASK_LIST_VO), userId);
|
|
|
+ if (deleteHistory) {
|
|
|
+ cacheManager.batchEvictLike(Arrays.asList(CacheNameConstant.TASK_PUNCH_IN_HISTORY, CacheNameConstant.TASK_HISTORY_LIST_FOR_USER), String.valueOf(userId));
|
|
|
+ }
|
|
|
+ if (deleteStat) {
|
|
|
+ cacheManager.batchEvictLike(Arrays.asList(CacheNameConstant.TASK_STAT), String.valueOf(userId));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|