新版本

This commit is contained in:
tanglong 2026-07-22 09:40:11 +08:00
parent c7f133c642
commit 106c3c9dcd
5 changed files with 16 additions and 9 deletions

View File

@ -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; }

View File

@ -115,12 +115,11 @@ public class CustomerDailyReportService {
stage(funnel, "VISIT", "到店", visit, appointment);
stage(funnel, "DEAL", "成交", deal, visit);
Map<String, Object> allCustomerParams = new LinkedHashMap<>();
allCustomerParams.put("createTimeEnd", API_TIME.format(endExclusive));
addSelfParameter(allCustomerParams, scope, "deliverTargetIds");
List<JsonNode> activeCustomers = distinct(fetchScoped(CUSTOMER, allCustomerParams, "blSchoolId", scope), "customerId")
.stream().filter(row -> "1".equals(text(row, "status")) && present(row, "deliverTime")).toList();
List<Map<String, Object>> alerts = alerts(activeCustomers, followups, endExclusive);
LocalDateTime alertAsOf = endDate.isBefore(today)
? endExclusive : LocalDateTime.now(BUSINESS_ZONE);
List<JsonNode> activeCustomers = reportCustomers.stream()
.filter(row -> "1".equals(text(row, "status")) && present(row, "deliverTime")).toList();
List<Map<String, Object>> 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();

View File

@ -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));
}

View File

@ -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

View File

@ -30,7 +30,9 @@ class CustomerDailyReportServiceTest {
List<JsonNode> 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<JsonNode> 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);