调整文件下载完删除缓存
This commit is contained in:
@@ -79,10 +79,10 @@ public class DeviceFtpController extends BaseController {
|
|||||||
public HttpResult<String> downloadFile(@RequestParam("nDid") String nDid, @RequestParam("name") String name, @RequestParam("size") Integer size, @RequestParam("fileCheck") String fileCheck){
|
public HttpResult<String> downloadFile(@RequestParam("nDid") String nDid, @RequestParam("name") String name, @RequestParam("size") Integer size, @RequestParam("fileCheck") String fileCheck){
|
||||||
String methodDescribe = getMethodDescribe("downloadFile");
|
String methodDescribe = getMethodDescribe("downloadFile");
|
||||||
String result = deviceFtpService.downloadFile(nDid,name,size,fileCheck);
|
String result = deviceFtpService.downloadFile(nDid,name,size,fileCheck);
|
||||||
if (Objects.isNull(result)) {
|
|
||||||
redisUtil.delete("downloadFilePath:"+name);
|
redisUtil.delete("downloadFilePath:"+name);
|
||||||
redisUtil.delete("fileCheck"+name);
|
redisUtil.delete("fileCheck"+name);
|
||||||
redisUtil.delete("fileDowning");
|
redisUtil.delete("fileDowning:"+nDid);
|
||||||
|
if (Objects.isNull(result)) {
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
} else {
|
} else {
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
|
|||||||
public String downloadFile(String nDid, String name, Integer size, String fileCheck) {
|
public String downloadFile(String nDid, String name, Integer size, String fileCheck) {
|
||||||
String result = null;
|
String result = null;
|
||||||
judgeClientOnline(nDid);
|
judgeClientOnline(nDid);
|
||||||
Object task = redisUtil.getObjectByKey("fileDowning");
|
Object task = redisUtil.getObjectByKey("fileDowning:"+nDid);
|
||||||
if (Objects.nonNull(task)) {
|
if (Objects.nonNull(task)) {
|
||||||
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
|
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
|
|||||||
boolean file = askDeviceDataFeignClient.downloadFile(nDid,name,size,fileCheck).getData();
|
boolean file = askDeviceDataFeignClient.downloadFile(nDid,name,size,fileCheck).getData();
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
redisUtil.delete("fileDowning");
|
redisUtil.delete("fileDowning:"+nDid);
|
||||||
redisUtil.delete("fileCheck"+name);
|
redisUtil.delete("fileCheck"+name);
|
||||||
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOAD_ERROR);
|
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOAD_ERROR);
|
||||||
}
|
}
|
||||||
@@ -111,10 +111,10 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
|
|||||||
result = (String) object;
|
result = (String) object;
|
||||||
redisUtil.delete("downloadFilePath:"+name);
|
redisUtil.delete("downloadFilePath:"+name);
|
||||||
redisUtil.delete("fileCheck"+name);
|
redisUtil.delete("fileCheck"+name);
|
||||||
redisUtil.delete("fileDowning");
|
redisUtil.delete("fileDowning:"+nDid);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
redisUtil.delete("fileDowning");
|
redisUtil.delete("fileDowning:"+nDid);
|
||||||
redisUtil.delete("fileCheck"+name);
|
redisUtil.delete("fileCheck"+name);
|
||||||
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
|
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user