controller:
@RequestMapping(value = "/reProcessSubmitList", method = RequestMethod.POST)
@ApiOperation("批量提交")
public ObjectRestResponse batchAuitByMq(@Validated @RequestBody Td51CustRiskUpdateDTO td51CustRiskUpdateDTO) throws Exception {
ObjectRestResponse objectRestResponse = null;
//批量提交
String message = "";
boolean locked = false;
String value = UUID.randomUUID().toString();
try{
locked = redisDistributedLocker.tryLock(TASK_KEY_EXTRACTHALF+"_"+orgKey, value, 30, TimeUnit.MINUTES);
if (!locked) {
throw new BusinessException("正在执行一键提交,请勿重复点击!");
}else{
message = custRiskProcessService.batchAuitByMq(td51CustRiskUpdateDTO);
}
}catch(Exception e){
log.error("批量提交错误,{}",e);
}finally {
if (locked) {
log.info("删除批量提交redis锁开始key===" + TASK_KEY_EXTRACTHALF);
redisDistributedLocker.releaseLock(TASK_KEY_EXTRACTHALF+"_"+orgKey, value);
log.info("删除批量提交redis锁结束key===" + TASK_KEY_EXTRACTHALF);
}
}
objectRestResponse = new ObjectRestResponse(HttpStatus.HTTP_OK, "评级结果开始一键提交", message);
return objectRestResponse;
}
service层:
@Override
public String batchAuitByMq(Td51CustRiskUpdateDTO td51CustRiskUpdateDTO) {
String message = "";
/**
* 判断是否重置批量任务进度
*/
if (ObjectUtil.isNotNull(td51CustRiskUpdateDTO)) {
Long resultCount = selectTd51CustRiskPageCount(td51CustRiskPageDTO);
if (resultCount != null && resultCount > 0) {
Long resultNum = td51CustRiskProcessMapper.selectTd51CustRiskPageCount(td51CustRiskPageDTO);
if (resultNum != null && resultNum > 0) {
message = "风险事件处理初审与复核不能是同一人操作!";
} else {
message = "正在进行一键提交,请稍后";
}
} else {
message = "没有符合条件的客户信息需要批量处理!";
return message;
}
td51CustRiskPageDTO.setAuditUser("");
//另起线程进行数据处理。
new CustRiskProcessServiceImpl.MyThread(userInfo, td51CustRiskPageDTO, hierarchy) {
@Override
public void run() {
try {
//数据提交
batchSubmit(resultCount, td51CustRiskPageDTO,td51CustRiskUpdateDTO);
} catch (Exception e) {
log.error("一键提交失败,错误信息为,{}", e);
//如果报错删除td54BatchSchedule表中此机构的数据,让其可以再次提交
td54BatchScheduleMapper.deleteScheduleByOrgkey(td51CustRiskPageDTO.getOrgKey());
throw new RuntimeException(e);
}
}
}.start();
}
return message;
}