diff --git a/src/main/java/com/company/agentfoundation/config/FoundationProperties.java b/src/main/java/com/company/agentfoundation/config/FoundationProperties.java index 5d417fd..cbad673 100644 --- a/src/main/java/com/company/agentfoundation/config/FoundationProperties.java +++ b/src/main/java/com/company/agentfoundation/config/FoundationProperties.java @@ -154,6 +154,7 @@ public class FoundationProperties { private String clientSecret; private int pageSize = 500; private int maxPages = 1000; + private int maxResponseBytes = 10 * 1024 * 1024; private int connectTimeoutMs = 10000; private int readTimeoutMs = 60000; private int maxRetries = 2; @@ -173,6 +174,8 @@ public class FoundationProperties { public void setPageSize(int pageSize) { this.pageSize = pageSize; } public int getMaxPages() { return maxPages; } public void setMaxPages(int maxPages) { this.maxPages = maxPages; } + public int getMaxResponseBytes() { return maxResponseBytes; } + public void setMaxResponseBytes(int maxResponseBytes) { this.maxResponseBytes = maxResponseBytes; } public int getConnectTimeoutMs() { return connectTimeoutMs; } public void setConnectTimeoutMs(int connectTimeoutMs) { this.connectTimeoutMs = connectTimeoutMs; } public int getReadTimeoutMs() { return readTimeoutMs; } diff --git a/src/main/java/com/company/agentfoundation/crm/report/CustomerDailyReportService.java b/src/main/java/com/company/agentfoundation/crm/report/CustomerDailyReportService.java index c45956e..a6888c4 100644 --- a/src/main/java/com/company/agentfoundation/crm/report/CustomerDailyReportService.java +++ b/src/main/java/com/company/agentfoundation/crm/report/CustomerDailyReportService.java @@ -115,12 +115,11 @@ public class CustomerDailyReportService { stage(funnel, "VISIT", "到店", visit, appointment); stage(funnel, "DEAL", "成交", deal, visit); - Map allCustomerParams = new LinkedHashMap<>(); - allCustomerParams.put("createTimeEnd", API_TIME.format(endExclusive)); - addSelfParameter(allCustomerParams, scope, "deliverTargetIds"); - List activeCustomers = distinct(fetchScoped(CUSTOMER, allCustomerParams, "blSchoolId", scope), "customerId") - .stream().filter(row -> "1".equals(text(row, "status")) && present(row, "deliverTime")).toList(); - List> alerts = alerts(activeCustomers, followups, endExclusive); + LocalDateTime alertAsOf = endDate.isBefore(today) + ? endExclusive : LocalDateTime.now(BUSINESS_ZONE); + List activeCustomers = reportCustomers.stream() + .filter(row -> "1".equals(text(row, "status")) && present(row, "deliverTime")).toList(); + List> alerts = alerts(activeCustomers, followups, alertAsOf); long over24Hours = alerts.stream().mapToLong(row -> number(row.get("customerCount"))).sum(); long over3Days = alerts.stream().mapToLong(row -> number(row.get("over3DaysCount"))).sum(); diff --git a/src/main/java/com/company/agentfoundation/integration/xuebang/XuebangHttpTransport.java b/src/main/java/com/company/agentfoundation/integration/xuebang/XuebangHttpTransport.java index b141eaa..a93fb4f 100644 --- a/src/main/java/com/company/agentfoundation/integration/xuebang/XuebangHttpTransport.java +++ b/src/main/java/com/company/agentfoundation/integration/xuebang/XuebangHttpTransport.java @@ -26,6 +26,8 @@ public class XuebangHttpTransport { this.webClient = builder.clone() .baseUrl(config.getBaseUrl()) .clientConnector(new ReactorClientHttpConnector(httpClient)) + .codecs(codecs -> codecs.defaultCodecs() + .maxInMemorySize(Math.max(config.getMaxResponseBytes(), 256 * 1024))) .build(); this.readTimeout = Duration.ofMillis(Math.max(config.getReadTimeoutMs(), 1)); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d19974b..2186631 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -38,7 +38,7 @@ foundation: coze: base-url: https://api.coze.cn chat-path: /v1/workflows/chat - api-key: cztei_q8DKvlTaGtfA4tOAij6f9EexaRlwRiDP5XvESFauvBDzJXsz1VcPPEMetmYSd5wGA + api-key: cztei_loBGQ9Xrhq70zquw89ZM6wnBFuHXV7traCchSpfEJOTiMIytf7n7RIKVC7vp1Fq0S default-workflow: wecom-default workflows: wecom-default: @@ -80,6 +80,7 @@ foundation: client-secret: "RkDSYCNXD0eBF09ofNfxWMmSZzIWF9QzGWu8GUKAUH5d1sQeXE6JxfScDGFx2Q5EisYRL7IZqij56CqbICeI9pC/EbSdNh8QRgV00S+e6sYbmQImMcRipLsH1t/Bnr1pKRwSBIcj8y8UQThyVT1Ve4Zl/p4J295J4rbLcSo29W0=" page-size: 500 max-pages: 1000 + max-response-bytes: 10485760 connect-timeout-ms: 10000 read-timeout-ms: 60000 max-retries: 2 diff --git a/src/test/java/com/company/agentfoundation/crm/report/CustomerDailyReportServiceTest.java b/src/test/java/com/company/agentfoundation/crm/report/CustomerDailyReportServiceTest.java index e3071dc..ec73d33 100644 --- a/src/test/java/com/company/agentfoundation/crm/report/CustomerDailyReportServiceTest.java +++ b/src/test/java/com/company/agentfoundation/crm/report/CustomerDailyReportServiceTest.java @@ -30,7 +30,9 @@ class CustomerDailyReportServiceTest { List reportCustomers = nodes( "{\"customerId\":\"c1\",\"customerName\":\"A\",\"contact\":\"1\",\"cusOrgName\":\"web\",\"blSchoolName\":\"S\",\"intentionName\":\"high\",\"status\":\"1\",\"deliverTime\":\"2026-07-21 08:00:00\",\"deliverUserId\":\"u1\",\"deliverUserName\":\"Advisor\"}", - "{\"customerId\":\"c2\",\"customerName\":\"B\",\"contact\":\"2\",\"cusTypeName\":\"walk-in\",\"blSchoolName\":\"S\",\"intentionName\":\"low\",\"status\":\"1\",\"deliverTime\":\"2026-07-21 09:00:00\",\"deliverUserId\":\"u1\",\"deliverUserName\":\"Advisor\"}"); + "{\"customerId\":\"c2\",\"customerName\":\"B\",\"contact\":\"2\",\"cusTypeName\":\"walk-in\",\"blSchoolName\":\"S\",\"intentionName\":\"low\",\"status\":\"1\",\"deliverTime\":\"2026-07-21 09:00:00\",\"deliverUserId\":\"u1\",\"deliverUserName\":\"Advisor\"}", + "{\"customerId\":\"old1\",\"customerName\":\"C\",\"contact\":\"3\",\"cusOrgName\":\"web\",\"blSchoolName\":\"S\",\"intentionName\":\"high\",\"status\":\"1\",\"deliverTime\":\"2026-07-17 00:00:00\",\"deliverUserId\":\"u1\",\"deliverUserName\":\"Advisor\"}", + "{\"customerId\":\"old2\",\"customerName\":\"D\",\"contact\":\"4\",\"cusOrgName\":\"web\",\"blSchoolName\":\"S\",\"intentionName\":\"high\",\"status\":\"1\",\"deliverTime\":\"2026-07-20 00:00:00\",\"deliverUserId\":\"u1\",\"deliverUserName\":\"Advisor\"}"); List activeCustomers = nodes( "{\"customerId\":\"old1\",\"status\":\"1\",\"deliverTime\":\"2026-07-17 00:00:00\",\"deliverUserId\":\"u1\",\"deliverUserName\":\"Advisor\"}", "{\"customerId\":\"old2\",\"status\":\"1\",\"deliverTime\":\"2026-07-20 00:00:00\",\"deliverUserId\":\"u1\",\"deliverUserName\":\"Advisor\"}"); @@ -50,7 +52,7 @@ class CustomerDailyReportServiceTest { new CustomerDailyReportRequest(LocalDate.of(2026, 7, 21), LocalDate.of(2026, 7, 21), "admin")); Map metrics = (Map) report.get("coreMetrics"); - assertThat(metrics.get("added")).isEqualTo(2L); + assertThat(metrics.get("added")).isEqualTo(4L); assertThat(metrics.get("followed")).isEqualTo(2L); assertThat(metrics.get("firstCall")).isEqualTo(1L); assertThat(metrics.get("converted")).isEqualTo(1L);