|
|
@ -115,6 +115,7 @@ public class IndexCalculateController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 指标计算 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
private void indexCalculate(CalculateCommonFormDTO formDTO) { |
|
|
@ -137,29 +138,34 @@ public class IndexCalculateController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交异步计算 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private void submitCalculate(CalculateCommonFormDTO formDTO) { |
|
|
|
Future<?> future = singleThreadPool.submit(() -> { |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); |
|
|
|
if (aBoolean) { |
|
|
|
log.error("客户Id:{},全部指标计算完成,总耗时:{}秒", formDTO.getCustomerId(), (System.currentTimeMillis() - start) / 1000); |
|
|
|
} |
|
|
|
try { |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); |
|
|
|
if (aBoolean) { |
|
|
|
log.error("客户Id:{},全部指标计算完成,总耗时:{}秒", formDTO.getCustomerId(), (System.currentTimeMillis() - start) / 1000); |
|
|
|
} |
|
|
|
|
|
|
|
redisUtils.delete(RedisKeys.getCustomerStatsCalFlag(formDTO.getCustomerId())); |
|
|
|
futureMap.remove(formDTO.getCustomerId()); |
|
|
|
redisUtils.delete(RedisKeys.getCustomerStatsCalFlag(formDTO.getCustomerId())); |
|
|
|
futureMap.remove(formDTO.getCustomerId()); |
|
|
|
|
|
|
|
//测试代码
|
|
|
|
//try {
|
|
|
|
// Thread.sleep(20000l);
|
|
|
|
// System.out.println(System.currentTimeMillis());
|
|
|
|
//} catch (InterruptedException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
//}
|
|
|
|
//redisUtils.delete(RedisKeys.getCustomerStatsCalFlag(formDTO.getCustomerId()));
|
|
|
|
//futureMap.remove(formDTO.getCustomerId());
|
|
|
|
//测试代码
|
|
|
|
//try {
|
|
|
|
// Thread.sleep(20000l);
|
|
|
|
// System.out.println(System.currentTimeMillis());
|
|
|
|
//} catch (InterruptedException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
//}
|
|
|
|
//redisUtils.delete(RedisKeys.getCustomerStatsCalFlag(formDTO.getCustomerId()));
|
|
|
|
//futureMap.remove(formDTO.getCustomerId());
|
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("submitCalculate exception", e); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
futureMap.put(formDTO.getCustomerId(), future); |
|
|
@ -172,6 +178,7 @@ public class IndexCalculateController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 终止计算 |
|
|
|
* |
|
|
|
* @param form |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -194,10 +201,14 @@ public class IndexCalculateController { |
|
|
|
@PostMapping("reAll") |
|
|
|
public Result<Boolean> calculateAll(@RequestBody CalculateCommonFormDTO formDTO) { |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); |
|
|
|
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); |
|
|
|
if (aBoolean) { |
|
|
|
return new Result<Boolean>().ok(true); |
|
|
|
try { |
|
|
|
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); |
|
|
|
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); |
|
|
|
if (aBoolean) { |
|
|
|
return new Result<Boolean>().ok(true); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
return new Result<Boolean>().error(e.getMessage()); |
|
|
|
} |
|
|
|
return new Result<Boolean>().error("指标计算失败"); |
|
|
|
} |
|
|
|