cl
3 天以前 d8cbfdcac8292522dd3c39e5cafdf19a43d15a5d
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/CloudWmsNotifySchedule.java
@@ -32,7 +32,8 @@
    @Scheduled(cron = "0/30 * * * * ?")
    public void syncCloudWmsNotify() {
        List<CloudWmsNotifyLog> pending = cloudWmsNotifyLogService.listPending(BATCH_LIMIT, 999);
        // List<CloudWmsNotifyLog> pending = cloudWmsNotifyLogService.listPending(BATCH_LIMIT, 999);
        List<CloudWmsNotifyLog> pending = cloudWmsNotifyLogService.listPending(BATCH_LIMIT, -1);
        if (pending.isEmpty()) {
            return;
        }
@@ -44,7 +45,10 @@
                if (maxRetry == null || intervalSeconds == null || intervalSeconds <= 0) {
                    continue;
                }
                if (logRecord.getRetryCount() != null && logRecord.getRetryCount() >= maxRetry) {
                // if (logRecord.getRetryCount() != null && logRecord.getRetryCount() >= maxRetry) {
                if (!isInfiniteRetry(maxRetry)
                        && logRecord.getRetryCount() != null
                        && logRecord.getRetryCount() >= maxRetry) {
                    continue;
                }
                if (logRecord.getLastNotifyTime() != null) {
@@ -99,7 +103,7 @@
        Object codeObj = res != null ? res.get("code") : null;
        boolean success = Integer.valueOf(200).equals(codeObj);
        int status = success ? cloudWmsNotifyLogService.getNotifyStatusSuccess() : cloudWmsNotifyLogService.getNotifyStatusPending();
        if (!success && nextRetry >= effectiveMaxRetry) {
        if (!success && !isInfiniteRetry(effectiveMaxRetry) && nextRetry >= effectiveMaxRetry) {
            status = cloudWmsNotifyLogService.getNotifyStatusFail();
        }
        logRecord.setLastRequestBody(requestBody);
@@ -116,8 +120,16 @@
        logRecord.setLastResponseBody(errorMsg);
        logRecord.setLastNotifyTime(now);
        logRecord.setRetryCount(nextRetry);
        logRecord.setNotifyStatus(nextRetry >= effectiveMaxRetry ? cloudWmsNotifyLogService.getNotifyStatusFail() : cloudWmsNotifyLogService.getNotifyStatusPending());
        // logRecord.setNotifyStatus(nextRetry >= effectiveMaxRetry ? cloudWmsNotifyLogService.getNotifyStatusFail() : cloudWmsNotifyLogService.getNotifyStatusPending());
        logRecord.setNotifyStatus(!isInfiniteRetry(effectiveMaxRetry) && nextRetry >= effectiveMaxRetry
                ? cloudWmsNotifyLogService.getNotifyStatusFail()
                : cloudWmsNotifyLogService.getNotifyStatusPending());
        logRecord.setUpdateTime(now);
        cloudWmsNotifyLogService.updateById(logRecord);
    }
    /** maxRetry = -1 表示无限重发 */
    private boolean isInfiniteRetry(Integer maxRetry) {
        return maxRetry != null && maxRetry == -1;
    }
}