From 7beaa9a06a71e89913347f80f549cb9d7cefc7ad Mon Sep 17 00:00:00 2001 From: nieziyan Date: Thu, 19 Oct 2023 20:32:05 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Adel=20PHDFile=20Cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/common/cache/LocalCache.java | 4 ++++ .../org/jeecg/modules/controller/GammaController.java | 10 ++++++++++ .../java/org/jeecg/modules/service/IGammaService.java | 2 ++ .../jeecg/modules/service/impl/GammaServiceImpl.java | 9 +++++++++ 4 files changed, 25 insertions(+) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/LocalCache.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/LocalCache.java index 9c23f8e3..98bbd56a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/LocalCache.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/LocalCache.java @@ -5,6 +5,7 @@ import com.google.common.cache.CacheBuilder; import org.jeecg.modules.entity.vo.PHDFile; import org.springframework.stereotype.Component; +import java.util.Map; import java.util.concurrent.TimeUnit; @Component @@ -30,4 +31,7 @@ public class LocalCache { this.phdCache = phdCache; } + public void deletePHDCache(String key){ + this.phdCache.invalidate(key); + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index 097ab0fd..2326c3af 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -1,8 +1,10 @@ package org.jeecg.modules.controller; +import com.google.common.cache.Cache; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.cache.LocalCache; import org.jeecg.modules.base.bizVo.GammaRLR; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.feignclient.SystemClient; @@ -15,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; +import java.util.concurrent.ConcurrentMap; @RestController @RequestMapping("gamma") @@ -52,6 +55,13 @@ public class GammaController { public Result gammaByFile(String fileName, HttpServletRequest request) { return gammaService.gammaByFile(fileName, request); } + + @DeleteMapping("delPHDCache") + @ApiOperation(value = "删除PHD文件缓存", notes = "删除PHD文件缓存") + public void delPHDCache(@RequestParam String fileName) { + gammaService.delPHDCache(fileName); + } + @GetMapping("Compare") public Result Compare(String fileName, String compareFileName, HttpServletRequest request) { return gammaService.Compare(fileName, compareFileName, request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index 6d1387c0..fac3a44d 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -20,6 +20,8 @@ public interface IGammaService{ Result gammaByFile(String fileName, HttpServletRequest request); + void delPHDCache(String fileName); + Result Compare(String fileName, String compareFileName, HttpServletRequest request); Result Strip(String fileName, String stripFileName, Double ratioRate, HttpServletRequest request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 0b621631..8c61626c 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -807,6 +807,15 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi return result; } + @Override + public void delPHDCache(String fileName) { + LoginUser loginUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); + String username = loginUser.getUsername(); + String key = fileName + StrUtil.DASHED + username; + // 删除指定key的Cache + localCache.deletePHDCache(key); + } + @Override public Result Compare(String fileName, String compareFileName, HttpServletRequest request) { Result result = new Result();