diff --git a/src/main/java/com/example/demo/Export/ExportServiceImpl.java b/src/main/java/com/example/demo/Export/ExportServiceImpl.java index 4580b2b..d4eb27c 100644 --- a/src/main/java/com/example/demo/Export/ExportServiceImpl.java +++ b/src/main/java/com/example/demo/Export/ExportServiceImpl.java @@ -272,7 +272,7 @@ public class ExportServiceImpl implements ExportService { @Override public Result addExportLive(LiveDTO dto) { - return addExport(dto, "直播明细", "live:queue:export_queue", "beanConsumeLive"); + return addExport(dto, "直播明细", "lives:queue:export_queue", "beanConsumeLive"); } @Override diff --git a/src/main/java/com/example/demo/service/listen/LiveListener.java b/src/main/java/com/example/demo/service/listen/LiveListener.java index bf9f863..05ffed6 100644 --- a/src/main/java/com/example/demo/service/listen/LiveListener.java +++ b/src/main/java/com/example/demo/service/listen/LiveListener.java @@ -21,7 +21,7 @@ public class LiveListener extends BaseMessageListener{ @Autowired public LiveListener(RedisUtil redisQueueUtil) { - super(redisQueueUtil, "live:queue:export_queue"); + super(redisQueueUtil, "lives:queue:export_queue"); } @Override diff --git a/src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java b/src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java index 3a67a45..862ec37 100644 --- a/src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java +++ b/src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java @@ -77,7 +77,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { @Autowired private AuthenticationManager authenticationManager; // 每页查询的数据量 - private static final int PAGE_SIZE = 1000; + private static final int PAGE_SIZE = 5000; @Autowired private ExportMapper exportMapper; @@ -373,31 +373,55 @@ public class ExportExcelServiceImpl implements ExportExcelService { // 8. 检查文件是否存在且不为空 if (tempFile != null && tempFile.exists() && tempFile.length() > 0) { - // 9. 上传到OSS - try { - ExcelUploadUtil uploadUtil = new ExcelUploadUtil(uploadUrl); - File excelFile = new File(tempFile.toURI()); - String result = uploadUtil.uploadExcel(excelFile, "export/excel/"); - - JsonNode uploadResult = objectMapper.readTree(result); - long code = uploadResult.path("code").asLong(); - String fileUrl = ""; - JsonNode dataNode = uploadResult.path("data"); - - if (dataNode.isObject()) { - fileUrl = dataNode.path("url").asText(); - } else if (dataNode.isTextual()) { - fileUrl = dataNode.asText(); + // 定义最大重试次数 + int maxRetries = 2; + int retryCount = 0; + boolean uploadSuccess = false; // 标记上传是否成功 + Exception lastException = null; // 记录最后一次异常 + + while (retryCount < maxRetries) { + try { + // 9. 上传到OSS + ExcelUploadUtil uploadUtil = new ExcelUploadUtil(uploadUrl); + File excelFile = new File(tempFile.toURI()); + String result = uploadUtil.uploadExcel(excelFile, "export/excel/"); + + JsonNode uploadResult = objectMapper.readTree(result); + long code = uploadResult.path("code").asLong(); + String fileUrl = ""; + JsonNode dataNode = uploadResult.path("data"); + + if (dataNode.isObject()) { + fileUrl = dataNode.path("url").asText(); + } else if (dataNode.isTextual()) { + fileUrl = dataNode.asText(); + } + + // 检查上传是否成功 + if (code == 200 && !fileUrl.isEmpty()) { + aiEmotionService.updateStatus(recordId, 2, fileUrl, "", totalCount); + uploadSuccess = true; // 标记上传成功 + break; // 成功后退出循环 + } else { + // 如果返回的状态码不是200或URL为空 + lastException = new Exception("上传成功但URL为空或解析失败"); + } + } catch (Exception e) { + // 捕获上传过程中的异常 + lastException = e; } - if (code == 200 && !fileUrl.isEmpty()) { - aiEmotionService.updateStatus(recordId, 2, fileUrl, "", totalCount); - } else { - aiEmotionService.updateStatus(recordId, 3, "", "上传成功但URL为空或解析失败", 0); + retryCount++; + if (!uploadSuccess && retryCount < maxRetries) { + log.warn("第{}次上传失败,正在尝试重新上传...", retryCount); } - } catch (Exception e) { - aiEmotionService.updateStatus(recordId, 3, "", StringUtils.substring(e.getMessage(), 0, 500), 0); - throw new Exception("文件上传云端失败", e); + } + + // 如果经过多次尝试仍然失败 + if (!uploadSuccess) { + // 更新状态为失败,并记录最后一次异常信息 + aiEmotionService.updateStatus(recordId, 3, "", StringUtils.substring(lastException.getMessage(), 0, 500), 0); + throw new Exception("文件上传云端失败", lastException); } } else { throw new Exception("导出的Excel文件不存在或为空"); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 6dbb6d6..451a575 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -11,6 +11,38 @@ spring: hikari: pool-name: mysql1HikariCP maximum-pool-size: 10 + mysql2: + jdbc-url: jdbc:mysql://52.220.141.241:3306/hljw?serverTimezone=Asia/Shanghai + username: gold_coin + password: NaVILnQottaWpMTw0o + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql2HikariCP + maximum-pool-size: 10 + mysql3: + jdbc-url: jdbc:mysql://52.220.141.241:3306/pay?serverTimezone=Asia/Shanghai + username: gold_coin + password: NaVILnQottaWpMTw0o + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql3HikariCP + maximum-pool-size: 10 + mysql4: + jdbc-url: jdbc:mysql://39.101.133.168:3306/cms?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true + username: cms + password: AF42R3ib6YkFaemm + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql3HikariCP + maximum-pool-size: 10 + mysql5: + jdbc-url: jdbc:mysql://52.220.141.241:3306/live?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true + username: gold_coin + password: NaVILnQottaWpMTw0o + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql5HikariCP + maximum-pool-size: 10 sqlserver1: jdbc-url: jdbc:sqlserver://10.19.183.6:1433;databaseName=hwhcGold;encrypt=true;sslProtocol=TLSv1;trustServerCertificate=true; username: hwhc_gold_query diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 02eab97..6b0cecc 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -11,6 +11,38 @@ spring: hikari: pool-name: mysql1HikariCP maximum-pool-size: 10 + mysql2: + jdbc-url: jdbc:mysql://39.101.133.168:3306/hljw?serverTimezone=Asia/Shanghai + username: hljw + password: 5dmWCCKfEk3TTeyn + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql2HikariCP + maximum-pool-size: 10 + mysql3: + jdbc-url: jdbc:mysql://121.89.234.155:3306/pay_xxcg_com?serverTimezone=Asia/Shanghai + username: pay_xxcg_com + password: 4hHmzxZH4rF4c5xr + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql3HikariCP + maximum-pool-size: 10 + mysql4: + jdbc-url: jdbc:mysql://39.101.133.168:3306/cms?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true + username: cms + password: AF42R3ib6YkFaemm + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql3HikariCP + maximum-pool-size: 10 + mysql5: + jdbc-url: jdbc:mysql://39.101.133.168:3306/live?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true + username: live + password: p4jMAMShNM8HTrbX + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql5HikariCP + maximum-pool-size: 10 sqlserver1: jdbc-url: jdbc:sqlserver://10.19.183.6:1433;databaseName=hwhcGold;encrypt=true;sslProtocol=TLSv1;trustServerCertificate=true; username: hwhc_gold_query diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index df574ea..0bd95af 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -11,6 +11,38 @@ spring: hikari: pool-name: mysql1HikariCP maximum-pool-size: 10 + mysql2: + jdbc-url: jdbc:mysql://39.101.133.168:3306/hljw?serverTimezone=Asia/Shanghai + username: hljw + password: 5dmWCCKfEk3TTeyn + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql2HikariCP + maximum-pool-size: 10 + mysql3: + jdbc-url: jdbc:mysql://121.89.234.155:3306/pay_xxcg_com?serverTimezone=Asia/Shanghai + username: pay_xxcg_com + password: 4hHmzxZH4rF4c5xr + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql3HikariCP + maximum-pool-size: 10 + mysql4: + jdbc-url: jdbc:mysql://39.101.133.168:3306/cms?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true + username: cms + password: AF42R3ib6YkFaemm + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql3HikariCP + maximum-pool-size: 10 + mysql5: + jdbc-url: jdbc:mysql://39.101.133.168:3306/live?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true + username: live + password: p4jMAMShNM8HTrbX + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + pool-name: mysql5HikariCP + maximum-pool-size: 10 sqlserver1: jdbc-url: jdbc:sqlserver://10.19.183.6:1433;databaseName=hwhcGold;encrypt=true;sslProtocol=TLSv1;trustServerCertificate=true; username: hwhc_gold_query @@ -56,7 +88,7 @@ feishu: url: https://open.feishu.cn/open-apis/bot/v2/hook/384c78aa-8df1-498b-9c47-04e890ed9877 bean: recharge: - # url: http://api.homilychart.com/hljwgo/api/wallet/recharge + # url: http://api.homilychart.com/hljwgo/api/wallet/recharge url: http://39.101.133.168:8828/hljwgo/api/wallet/recharge consume: url: http://39.101.133.168:8828/hljwgo/api/wallet/pay diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d4dabb8..151cfba 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,39 +13,6 @@ spring: hikari: pool-name: mysql1HikariCP maximum-pool-size: 10 - - mysql2: - jdbc-url: jdbc:mysql://39.101.133.168:3306/hljw?serverTimezone=Asia/Shanghai - username: hljw - password: 5dmWCCKfEk3TTeyn - driver-class-name: com.mysql.cj.jdbc.Driver - hikari: - pool-name: mysql2HikariCP - maximum-pool-size: 10 - mysql3: - jdbc-url: jdbc:mysql://121.89.234.155:3306/pay_xxcg_com?serverTimezone=Asia/Shanghai - username: pay_xxcg_com - password: 4hHmzxZH4rF4c5xr - driver-class-name: com.mysql.cj.jdbc.Driver - hikari: - pool-name: mysql3HikariCP - maximum-pool-size: 10 - mysql4: - jdbc-url: jdbc:mysql://39.101.133.168:3306/cms?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true - username: cms - password: AF42R3ib6YkFaemm - driver-class-name: com.mysql.cj.jdbc.Driver - hikari: - pool-name: mysql3HikariCP - maximum-pool-size: 10 - mysql5: - jdbc-url: jdbc:mysql://39.101.133.168:3306/live?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true - username: live - password: p4jMAMShNM8HTrbX - driver-class-name: com.mysql.cj.jdbc.Driver - hikari: - pool-name: mysql5HikariCP - maximum-pool-size: 10 sqlserver1: jdbc-url: jdbc:sqlserver://52.76.43.43:1433;databaseName=hwhcGold;encrypt=true;sslProtocol=TLSv1;trustServerCertificate=true; username: hwhc_gold_query