重调接口代码优化

release
xuliangwei 2 years ago
parent 6a791ac327
commit 5668fb1193
  1. 16
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/RequestRecordServiceImpl.java

@ -17,6 +17,7 @@ import com.dxhy.erp.service.RequestRecordService;
import com.dxhy.erp.service.SNPushCheckRecordService;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@ -118,14 +119,18 @@ public class RequestRecordServiceImpl extends MpBaseServiceImpl<RequestRecordDao
@Override
public ResponseEntity<?> reCall(RequestRecord requestRecord) {
try {
DynamicContextHolder.push(dbname+DbConstant.BUSINESS_READ);
RequestRecord dbRecord = requestRecordDao.selectById(requestRecord.getId());
log.info("数据库匹配信息:{}", JSONObject.toJSONString(dbRecord));
if (dbRecord == null || dbRecord.getStatus() != 0) {
if (dbRecord == null) {
return ResponseEntity.ok(JSONObject.toJSONString(R.error("请求信息错误,请确认后再发送!")));
}
if (dbRecord.getStatus() == 0) {
return ResponseEntity.ok(JSONObject.toJSONString(R.error("该请求已成功,无法继续重调!")));
}
if (dbRecord.getIsRecall() == 0) {
return ResponseEntity.ok(JSONObject.toJSONString(R.error("该请求参数不符合标准,无法进行重调,请校验参数后再申请!")));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("该请求参数不符合标准,无法进行重调!")));
}
RequestRecordEnum[] RequestRecordEnums = RequestRecordEnum.values();
@ -177,12 +182,17 @@ public class RequestRecordServiceImpl extends MpBaseServiceImpl<RequestRecordDao
}
catch (Exception e) {
log.info("重调出现异常,异常信息:{}",e);
e.printStackTrace();
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse),
JSONObject.toJSONString(data), "重调用失败,异常信息:{}"+JSONObject.toJSONString(e.getMessage()), 0);
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)));
}
}
}
} catch (Exception e) {
log.info("请求处理异常,异常信息:{}", JSONObject.toJSONString(e));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("请求处理异常,请校正参数!")));
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error("未找到相应信息!")));
}

Loading…
Cancel
Save