Commit fb127706 authored by 陈宏杰's avatar 陈宏杰

key删除

parent c6357105
...@@ -3,12 +3,9 @@ package cn.quantgroup.report.controller; ...@@ -3,12 +3,9 @@ package cn.quantgroup.report.controller;
import cn.quantgroup.report.response.GlobalResponse; import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.service.baihang.BaiHangFileReportService; import cn.quantgroup.report.service.baihang.BaiHangFileReportService;
import cn.quantgroup.report.service.baihang.BaiHangZhuDaiService; import cn.quantgroup.report.service.baihang.BaiHangZhuDaiService;
import cn.quantgroup.report.service.common.CommonQueryService;
import cn.quantgroup.report.service.manualTool.CleanningTransactionLogService; import cn.quantgroup.report.service.manualTool.CleanningTransactionLogService;
import cn.quantgroup.report.service.manualTool.ManualToolService; import cn.quantgroup.report.service.manualTool.ManualToolService;
import cn.quantgroup.report.utils.DateUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -16,9 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -16,9 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.File; import java.io.File;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
@RestController @RestController
...@@ -180,4 +175,14 @@ public class ManualToolController { ...@@ -180,4 +175,14 @@ public class ManualToolController {
} }
} }
@RequestMapping("/deleteRedisKey")
public String deleteRedisKey(String keyStr) {
try {
fileReportService.deleteRedisKey(keyStr);
return "SUCCESS";
} catch (Exception e) {
return e.getMessage();
}
}
} }
...@@ -85,11 +85,12 @@ public class BaiHangFileReportService { ...@@ -85,11 +85,12 @@ public class BaiHangFileReportService {
*/ */
@Async @Async
public void createReportFile(String type, String start, String end,int daySplitCount, String loanStartDateStr, String loanEndDateStr) { public void createReportFile(String type, String start, String end,int daySplitCount, String loanStartDateStr, String loanEndDateStr) {
try {
if (!increment(Constant.QG_ZHU_DAI_CREATE_REPORT_FILE_LOCK_KEY)) { if (!increment(Constant.QG_ZHU_DAI_CREATE_REPORT_FILE_LOCK_KEY)) {
log.error("创建报送文件任务已经开始执行...请勿重复操作"); log.error("创建报送文件任务已经开始执行...请勿重复操作");
return ; return ;
} }
redisTemplate.expire(Constant.QG_ZHU_DAI_CREATE_REPORT_FILE_LOCK_KEY, 5, TimeUnit.MINUTES); redisTemplate.expire(Constant.QG_ZHU_DAI_CREATE_REPORT_FILE_LOCK_KEY, 15, TimeUnit.MINUTES);
if (StringUtils.isAnyBlank(type, start, end, loanStartDateStr, loanEndDateStr)) { if (StringUtils.isAnyBlank(type, start, end, loanStartDateStr, loanEndDateStr)) {
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"存在为空参数"); throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"存在为空参数");
} }
...@@ -110,6 +111,11 @@ public class BaiHangFileReportService { ...@@ -110,6 +111,11 @@ public class BaiHangFileReportService {
if (stepEndDate.getTime() > endDate.getTime()){ if (stepEndDate.getTime() > endDate.getTime()){
createReportFile(type,stepStartDate,endDate,loanStartDate,loanEndDate); createReportFile(type,stepStartDate,endDate,loanStartDate,loanEndDate);
} }
} catch (Exception e) {
log.error("创建报送文件异常!",e);
} finally {
deleteRedisKey(Constant.QG_ZHU_DAI_CREATE_REPORT_FILE_LOCK_KEY);
}
} }
private void createReportFile(String type, Date startDate, Date endDate, Date loanStartDate, Date loanEndDate) { private void createReportFile(String type, Date startDate, Date endDate, Date loanStartDate, Date loanEndDate) {
...@@ -597,9 +603,15 @@ public class BaiHangFileReportService { ...@@ -597,9 +603,15 @@ public class BaiHangFileReportService {
} }
} }
private Boolean increment(String key){ private Boolean increment(String key) {
Long increment = redisTemplate.opsForValue().increment(key, 1); Long increment = redisTemplate.opsForValue().increment(key, 1);
return increment <= 1; return increment <= 1;
} }
public void deleteRedisKey(String keyStr) {
if (redisTemplate.hasKey(keyStr)) {
redisTemplate.delete(keyStr);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment