@@ -12,6 +12,6 @@ public interface YgzInterfaceLogRepo extends AbstractJpaRepo<YgzInterfaceLog, St | |||
@Query(" from YgzInterfaceLog where uniqueId = ?1 and ifCode =?2 and status =?3") | |||
YgzInterfaceLog findBy(String uniqueId, String ifCode, InterfaceStatus status); | |||
@Query(" from YgzInterfaceLog where sendStatus = ?1") | |||
List<YgzInterfaceLog> listBy(YgzSendStatus sendStatus); | |||
@Query(" from YgzInterfaceLog where sendStatus = ?1 and resendTimes < 5") | |||
List<YgzInterfaceLog> listBySendStatusLessThen5Times(YgzSendStatus sendStatus); | |||
} |
@@ -61,7 +61,7 @@ public class DeviceQueryRecordManagerImpl extends AbstractCommManager implements | |||
@Override | |||
public CardObuQueryResponseDTO cardObuQuery(CardObuQueryRequestDTO requestDTO) { | |||
// 1. 创建返回对象 | |||
// 1. 创建返回对象 | |||
CardObuQueryResponseDTO response = new CardObuQueryResponseDTO(); | |||
// 2. 根据卡号查询卡信息 | |||
@@ -70,7 +70,7 @@ public class DeviceQueryRecordManagerImpl extends AbstractCommManager implements | |||
// 可能会存在卡不存在的情况,所以,如果卡不存在,不报错,卡存在,则返回卡数据 | |||
if (cardInfo != null) { | |||
response.setCardStatus(cardInfo.getCardStatus()); | |||
response.setCardType(CardType.fromCode(cardInfo.getCardType())); | |||
response.setCardType(cardInfo.getCardTypeNew()); | |||
} | |||
// 3. 根据OBU号查询OBU信息 | |||
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(requestDTO.getObuId()); |
@@ -34,7 +34,7 @@ public class YgzDataSendManagerImpl extends AbstractCommManager implements YgzDa | |||
long begin = System.currentTimeMillis(); | |||
logger.info("开始---同步营改增数据"); | |||
try { | |||
List<YgzInterfaceLog> logs = logRepo.listBy(YgzSendStatus.WAIT_SEND); | |||
List<YgzInterfaceLog> logs = logRepo.listBySendStatusLessThen5Times(YgzSendStatus.WAIT_SEND); | |||
logger.info("营改增---查询营改增记录条数:{}", logs.size()); | |||
for (YgzInterfaceLog log : logs) { | |||
executor.execute(() -> { |
@@ -70,6 +70,12 @@ public class YgzObuUploadManager extends AbstractCommNioManager implements LogMa | |||
} else if (errorMsg.contains("installChannelId请填写0")) { | |||
// request.getObu().setInstallChannelId("0"); | |||
return serviceHandle(request); | |||
} else if (errorMsg.contains("已存在") && request.getOperation() == Operation.ADD) { | |||
request.setOperation(Operation.UPDATE); | |||
return serviceHandle(request); | |||
} else if (errorMsg.contains("不存在") && request.getOperation() == Operation.UPDATE) { | |||
request.setOperation(Operation.ADD); | |||
return serviceHandle(request);// 重发 | |||
} | |||
if (errorMsg.contains("请先上传用户信息")) { // 1/2 | |||
// 按序补传信息 尝试一次 |
@@ -65,6 +65,23 @@ public class AbstractCommNioManager extends AbstractManager { | |||
} | |||
protected void handleLog(String uniqueId, Operation operation, DataSourceEnum dataSource, YgzServiceCmd cmd, YgzInterfaceLog log) { | |||
YgzInterfaceLog oldLog = logRepo.findBy(uniqueId, cmd.getIfCode(), InterfaceStatus.FAILED); | |||
// 重发 | |||
if (oldLog != null && oldLog.getSendStatus() == YgzSendStatus.WAIT_SEND && oldLog.getResendTimes() < 5) { | |||
oldLog.setOperation(operation); | |||
oldLog.setSource(dataSource); | |||
oldLog.setResendTimes(oldLog.getResendTimes() + 1); | |||
if (oldLog.getResendTimes() == 5) | |||
oldLog.setSendStatus(log.getStatus() == InterfaceStatus.SUCCESS ? YgzSendStatus.SEND_SUCCESS : YgzSendStatus.SEND_FAILED); | |||
else | |||
oldLog.setSendStatus(log.getStatus() == InterfaceStatus.SUCCESS ? YgzSendStatus.SEND_SUCCESS : YgzSendStatus.WAIT_SEND); | |||
oldLog.setResponseJson(log.getResponseJson()); | |||
oldLog.setStatus(log.getStatus()); | |||
oldLog.setErrorMsg(log.getErrorMsg()); | |||
logRepo.save(oldLog); | |||
return; | |||
} | |||
//成功 | |||
if (log.getStatus() == InterfaceStatus.SUCCESS) { | |||
log.setUniqueId(uniqueId); | |||
@@ -75,11 +92,7 @@ public class AbstractCommNioManager extends AbstractManager { | |||
log.setSendStatus(YgzSendStatus.SEND_SUCCESS); | |||
log.setSource(dataSource); | |||
logRepo.persist(log); | |||
return; | |||
} | |||
//失败第一次 | |||
YgzInterfaceLog oldLog = logRepo.findBy(uniqueId, cmd.getIfCode(), InterfaceStatus.FAILED); | |||
if (oldLog == null) { | |||
} else { | |||
log.setUniqueId(uniqueId); | |||
log.setOperation(operation); | |||
log.setNioTransferType(cmd.getTransferType()); | |||
@@ -88,18 +101,6 @@ public class AbstractCommNioManager extends AbstractManager { | |||
log.setSendStatus(YgzSendStatus.WAIT_SEND); | |||
log.setSource(dataSource); | |||
logRepo.persist(log); | |||
return; | |||
} | |||
// 重发 | |||
if (oldLog.getSendStatus() == YgzSendStatus.WAIT_SEND && oldLog.getResendTimes() < 5) { | |||
oldLog.setOperation(operation); | |||
oldLog.setSource(dataSource); | |||
oldLog.setResendTimes(oldLog.getResendTimes() + 1); | |||
if (oldLog.getResendTimes() == 5) | |||
oldLog.setSendStatus(YgzSendStatus.SEND_FAILED); | |||
oldLog.setResponseJson(log.getResponseJson()); | |||
oldLog.setErrorMsg(log.getErrorMsg()); | |||
logRepo.save(oldLog); | |||
} | |||
} | |||
} |