Browse Source
两个接口用途不同,不要混用: - POST /webApi/warehouse/listWarehouseHasPerm → warehouses(ctx) 当前客户有权限的仓(实测 69 条,跳过 -999 后 68) - POST /webApi/warehouse/listActive → activeWarehouses(ctx, inbound) 平台全量激活仓(118 条),**含当前客户没授权的** 有权限的 68 个仓里有 50 个不在 listActive 结果里,所以给客户选仓必须用前者。 -999 是「智能分仓」哨兵值(divideWarehouse),不是真实仓,映射时跳过—— 和物流产品接口的 -998 是同一套路。 listActive 的 warehouseOperationType:0 尾程 111 条 / 1 头程 7 条 / 不传 118 条(文档说必填,实测不传也通)。 统一模型口径:warehouseCode 放仓编码(USLA),数字 id 进 providerWarehouseId。 listActive 比 listWarehouseHasPerm 多 30 个字段(容量 / 营业时间 / 负责人邮箱等), DTO 只声明统一模型用得上的十几个,其余由 Jackson 忽略。 顺带把之前 warehouses() 的显式拒绝换成真实实现,DIRECTORY 能力位从此完整。 Co-Authored-By: Claude <noreply@anthropic.com>master
9 changed files with 607 additions and 10 deletions
@ -0,0 +1,112 @@
@@ -0,0 +1,112 @@
|
||||
package common.ecommerce.edayun.adapter; |
||||
|
||||
import common.ecommerce.edayun.dto.EdayunWarehouseDtos; |
||||
import common.ecommerce.warehouse.enums.WarehouseProvider; |
||||
import common.ecommerce.warehouse.model.WarehouseFacility; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 易达云仓库清单映射 |
||||
* ({@code warehouse/listActive} 与 {@code warehouse/listWarehouseHasPerm})。 |
||||
* |
||||
* <p><b>两个接口用途不同</b>:</p> |
||||
* <ul> |
||||
* <li>{@code listWarehouseHasPerm} = 当前客户<b>有权限</b>的仓(69 条)——下单用这个</li> |
||||
* <li>{@code listActive} = 平台侧<b>全量</b>激活仓(118 条)——含未授权的仓</li> |
||||
* </ul> |
||||
* |
||||
* <p>{@code -999} 是「智能分仓」的哨兵值(名称 {@code divideWarehouse}), |
||||
* 不是真实仓,映射时跳过。</p> |
||||
*/ |
||||
public final class EdayunWarehouseMapper { |
||||
|
||||
/** 「智能分仓」哨兵值。 */ |
||||
static final String ID_SMART_SPLIT = "-999"; |
||||
|
||||
/** 仓库类型:头程仓。 */ |
||||
static final int OPERATION_TYPE_INBOUND = 1; |
||||
/** 仓库类型:尾程仓。 */ |
||||
static final int OPERATION_TYPE_OUTBOUND = 0; |
||||
|
||||
private EdayunWarehouseMapper() { |
||||
} |
||||
|
||||
/** 激活仓库请求。 */ |
||||
public static EdayunWarehouseDtos.ListActiveRequest toListActiveRequest( |
||||
boolean inboundWarehouse) { |
||||
EdayunWarehouseDtos.ListActiveRequest req = |
||||
new EdayunWarehouseDtos.ListActiveRequest(); |
||||
req.warehouseOperationType = inboundWarehouse |
||||
? OPERATION_TYPE_INBOUND : OPERATION_TYPE_OUTBOUND; |
||||
return req; |
||||
} |
||||
|
||||
/** 权限内仓库请求(接口无参数)。 */ |
||||
public static EdayunWarehouseDtos.ListPermittedRequest toListPermittedRequest() { |
||||
return new EdayunWarehouseDtos.ListPermittedRequest(); |
||||
} |
||||
|
||||
/** 响应 → 统一模型;跳过 {@code -999} 与缺 code 的行。 */ |
||||
public static List<WarehouseFacility> toFacilities( |
||||
List<EdayunWarehouseDtos.WarehouseRow> rows) { |
||||
if (rows == null || rows.isEmpty()) { |
||||
return Collections.emptyList(); |
||||
} |
||||
List<WarehouseFacility> out = new ArrayList<WarehouseFacility>(rows.size()); |
||||
for (EdayunWarehouseDtos.WarehouseRow row : rows) { |
||||
WarehouseFacility facility = toFacility(row); |
||||
if (facility != null) { |
||||
out.add(facility); |
||||
} |
||||
} |
||||
return out; |
||||
} |
||||
|
||||
/** |
||||
* 一行 → 统一仓资料。 |
||||
* |
||||
* <p>统一模型的口径:{@code warehouseCode} 用<b>仓编码</b>(如 {@code USLA}), |
||||
* 不是数字 id——那个进 {@code providerWarehouseId}。</p> |
||||
*/ |
||||
static WarehouseFacility toFacility(EdayunWarehouseDtos.WarehouseRow row) { |
||||
if (row == null || !hasText(row.warehouseCode)) { |
||||
return null; |
||||
} |
||||
if (ID_SMART_SPLIT.equals(trim(row.warehouseId))) { |
||||
return null; |
||||
} |
||||
return WarehouseFacility.builder() |
||||
.sourceProvider(WarehouseProvider.EDAYUN) |
||||
.providerWarehouseId(trim(row.warehouseId)) |
||||
.warehouseCode(row.warehouseCode.trim()) |
||||
.name(firstNonBlank(row.warehouseName, row.warehouseNameEn)) |
||||
.country(row.countryCode) |
||||
.province(row.provinceCode) |
||||
.city(row.cityName) |
||||
.state(row.provinceCode) |
||||
// 仓方只给单行地址,落在 address1
|
||||
.address1(row.address) |
||||
.postcode(row.zipCode) |
||||
.contactName(row.warehouseManagerName) |
||||
.mobilePhone(row.warehouseManagerTel) |
||||
.build(); |
||||
} |
||||
|
||||
private static String firstNonBlank(String a, String b) { |
||||
if (hasText(a)) { |
||||
return a.trim(); |
||||
} |
||||
return hasText(b) ? b.trim() : null; |
||||
} |
||||
|
||||
private static String trim(String v) { |
||||
return v == null ? null : v.trim(); |
||||
} |
||||
|
||||
private static boolean hasText(String v) { |
||||
return v != null && !v.trim().isEmpty(); |
||||
} |
||||
} |
||||
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
package common.ecommerce.edayun.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 易达云报文结构:获取激活仓库列表 |
||||
* ({@code POST /webApi/warehouse/listActive})。 |
||||
* |
||||
* <p>返回的是<b>平台侧全量仓库</b>(含未授权给当前客户的),字段比 |
||||
* 「权限内仓库」多得多(47 个 vs 17 个)。下单要用的是 |
||||
* {@code listWarehouseHasPerm}——那个才是当前客户可用的仓。</p> |
||||
*/ |
||||
public final class EdayunWarehouseDtos { |
||||
|
||||
private EdayunWarehouseDtos() { |
||||
} |
||||
|
||||
/** 激活仓库查询请求。 */ |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public static final class ListActiveRequest { |
||||
/** |
||||
* 仓库类型:0 尾程仓 / 1 头程仓。 |
||||
* |
||||
* <p>文档标必填,实测不传会返回两者之和(118 条 vs 0 类型 111 条 + 1 类型 7 条)。</p> |
||||
*/ |
||||
public Integer warehouseOperationType; |
||||
} |
||||
|
||||
/** 权限内仓库查询请求:无参数。 */ |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public static final class ListPermittedRequest { |
||||
// 接口不收参数,保留空类是为了和「一个接口一个 DTO」的约定一致
|
||||
} |
||||
|
||||
/** 两个接口共用同一个响应结构。 */ |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public static final class ListWarehouseResponse { |
||||
public Integer code; |
||||
public String msg; |
||||
public List<WarehouseRow> data; |
||||
public String traceId; |
||||
} |
||||
|
||||
/** |
||||
* 一个仓库。 |
||||
* |
||||
* <p>只声明两个接口都会返回的字段;{@code listActive} 多出来的 30 个字段 |
||||
* (容量、营业时间、负责人邮箱等)统一模型用不到,不声明——Jackson 会忽略未知字段。</p> |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public static final class WarehouseRow { |
||||
|
||||
/** 仓 id(字符串形式,如 {@code "40269"})。 */ |
||||
public String warehouseId; |
||||
/** 仓名称(中文)。 */ |
||||
public String warehouseName; |
||||
/** 仓名称(英文)。 */ |
||||
public String warehouseNameEn; |
||||
/** 仓编码,如 {@code USALA-Q031}。 */ |
||||
public String warehouseCode; |
||||
/** 仓库位置编码(权限内接口给 {@code WH-<id>})。 */ |
||||
public String warehouseLocationCode; |
||||
public String countryCode; |
||||
/** 地址原文(单行)。 */ |
||||
public String address; |
||||
|
||||
/** 仓库区域类型:0 普通 / 1 分区(码表未给全)。 */ |
||||
public Integer warehouseRegionType; |
||||
/** 当前时间(毫秒);权限内接口实测恒为 null。 */ |
||||
public Long currentTime; |
||||
/** 时区,如 {@code America/Los_Angeles}。 */ |
||||
public String timeZone; |
||||
|
||||
// ---- 仅 listActive 返回,权限内接口没有 ----
|
||||
/** 州 / 省编码,如 {@code US01}。 */ |
||||
public String provinceCode; |
||||
/** 城市编码 / 名称。 */ |
||||
public String cityCode; |
||||
public String cityName; |
||||
public String zipCode; |
||||
/** 仓库类型:0 尾程仓 / 1 头程仓。 */ |
||||
public Integer warehouseOperationType; |
||||
/** 仓状态;实测全是 0。 */ |
||||
public Integer warehouseStatus; |
||||
/** 父仓 id(子仓才有)。 */ |
||||
public String parentWarehouseId; |
||||
/** 是否私有仓。 */ |
||||
public Integer privateFlag; |
||||
/** 仓库负责人。 */ |
||||
public String warehouseManagerName; |
||||
public String warehouseManagerTel; |
||||
} |
||||
} |
||||
@ -0,0 +1,184 @@
@@ -0,0 +1,184 @@
|
||||
package common.ecommerce.edayun.adapter; |
||||
|
||||
import common.ecommerce.edayun.dto.EdayunWarehouseDtos; |
||||
import common.ecommerce.http.JacksonJsonCodec; |
||||
import common.ecommerce.shared.spi.ChannelSecret; |
||||
import common.ecommerce.shared.testkit.RecordingTransport; |
||||
import common.ecommerce.shared.testkit.Responses; |
||||
import common.ecommerce.warehouse.enums.WarehouseProvider; |
||||
import common.ecommerce.warehouse.model.WarehouseFacility; |
||||
import common.ecommerce.warehouse.sdk.WarehouseConnection; |
||||
import common.ecommerce.warehouse.sdk.WarehouseContext; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import java.time.Clock; |
||||
import java.time.Instant; |
||||
import java.time.ZoneOffset; |
||||
import java.util.List; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||
import static org.junit.jupiter.api.Assertions.assertNull; |
||||
import static org.junit.jupiter.api.Assertions.assertTrue; |
||||
|
||||
/** |
||||
* 仓库清单({@code listActive} / {@code listWarehouseHasPerm})。 |
||||
* |
||||
* <p>重点:-999(智能分仓)要跳过、warehouseCode 用仓编码不是数字 id、 |
||||
* listActive 与 listWarehouseHasPerm 用途不同。</p> |
||||
*/ |
||||
class EdayunWarehouseTest { |
||||
|
||||
private static final Clock CLOCK = Clock.fixed(Instant.parse("2026-11-16T00:00:00Z"), ZoneOffset.UTC); |
||||
|
||||
private static WarehouseContext ctx() { |
||||
return WarehouseContext.of("EDY-WH", WarehouseProvider.EDAYUN, "2", |
||||
WarehouseConnection.of("https://test.example/openapi", |
||||
ChannelSecret.builder().appKey("k").appSecret("s") |
||||
.clientId("c").clientSecret("cs").build()), |
||||
"req-wh", CLOCK); |
||||
} |
||||
|
||||
private static RecordingTransport stub(String path, String body) { |
||||
return RecordingTransport.create() |
||||
.route(common.ecommerce.edayun.EdayunConstants.PATH_TOKEN, req -> Responses.ok( |
||||
"{\"access_token\":\"T1\",\"token_type\":\"bearer\"}")) |
||||
.route(path, req -> Responses.ok(body)); |
||||
} |
||||
|
||||
// ------------------------------------------------------------ 请求
|
||||
|
||||
/** 头程 / 尾程映射到 1 / 0。 */ |
||||
@Test |
||||
void operationTypeMaps() { |
||||
assertEquals(Integer.valueOf(1), |
||||
EdayunWarehouseMapper.toListActiveRequest(true).warehouseOperationType); |
||||
assertEquals(Integer.valueOf(0), |
||||
EdayunWarehouseMapper.toListActiveRequest(false).warehouseOperationType); |
||||
} |
||||
|
||||
// ------------------------------------------------------------ 响应
|
||||
|
||||
private static EdayunWarehouseDtos.WarehouseRow row() { |
||||
EdayunWarehouseDtos.WarehouseRow r = new EdayunWarehouseDtos.WarehouseRow(); |
||||
r.warehouseId = "2"; |
||||
r.warehouseName = "美西1仓"; |
||||
r.warehouseNameEn = "Los Angeles Warehouse"; |
||||
r.warehouseCode = "USLA"; |
||||
r.warehouseLocationCode = "WH-2"; |
||||
r.countryCode = "US"; |
||||
r.address = "1251 S Rockefeller Ave, Unit B"; |
||||
r.warehouseRegionType = 0; |
||||
r.timeZone = "America/Los_Angeles"; |
||||
return r; |
||||
} |
||||
|
||||
private static EdayunWarehouseDtos.WarehouseRow sentinel() { |
||||
EdayunWarehouseDtos.WarehouseRow r = new EdayunWarehouseDtos.WarehouseRow(); |
||||
r.warehouseId = "-999"; |
||||
r.warehouseName = "使用分仓规则"; |
||||
r.warehouseNameEn = "divideWarehouse"; |
||||
r.warehouseCode = "USMC"; |
||||
return r; |
||||
} |
||||
|
||||
@Test |
||||
void mapsFacility() { |
||||
WarehouseFacility f = EdayunWarehouseMapper.toFacility(row()); |
||||
|
||||
// 统一模型的口径:warehouseCode 是仓编码,数字 id 进 providerWarehouseId
|
||||
assertEquals("USLA", f.warehouseCode()); |
||||
assertEquals("2", f.providerWarehouseId()); |
||||
assertEquals("美西1仓", f.name()); |
||||
assertEquals("US", f.country()); |
||||
assertEquals("1251 S Rockefeller Ave, Unit B", f.address1()); |
||||
assertEquals(WarehouseProvider.EDAYUN, f.sourceProvider()); |
||||
// 权限内接口没有 zipCode / 负责人
|
||||
assertNull(f.postcode()); |
||||
assertNull(f.contactName()); |
||||
} |
||||
|
||||
/** listActive 多给的字段也要能映射。 */ |
||||
@Test |
||||
void mapsExtraFieldsFromListActive() { |
||||
EdayunWarehouseDtos.WarehouseRow r = row(); |
||||
r.provinceCode = "US01"; |
||||
r.cityName = "Los Angeles"; |
||||
r.zipCode = "91761"; |
||||
r.warehouseManagerName = "Bo-LA6"; |
||||
r.warehouseManagerTel = "1234567"; |
||||
|
||||
WarehouseFacility f = EdayunWarehouseMapper.toFacility(r); |
||||
|
||||
assertEquals("US01", f.province()); |
||||
assertEquals("US01", f.state()); |
||||
assertEquals("Los Angeles", f.city()); |
||||
assertEquals("91761", f.postcode()); |
||||
assertEquals("Bo-LA6", f.contactName()); |
||||
assertEquals("1234567", f.mobilePhone()); |
||||
} |
||||
|
||||
/** -999 是「使用分仓规则」的哨兵值,不是真实仓。 */ |
||||
@Test |
||||
void smartSplitSentinelIsSkipped() { |
||||
List<WarehouseFacility> list = EdayunWarehouseMapper.toFacilities( |
||||
java.util.Arrays.asList(row(), sentinel())); |
||||
|
||||
assertEquals(1, list.size()); |
||||
assertEquals("USLA", list.get(0).warehouseCode()); |
||||
} |
||||
|
||||
/** 没有仓编码的行跳过——统一模型要求 warehouseCode 非空。 */ |
||||
@Test |
||||
void rowsWithoutCodeAreSkipped() { |
||||
EdayunWarehouseDtos.WarehouseRow bad = row(); |
||||
bad.warehouseCode = " "; |
||||
|
||||
assertEquals(1, EdayunWarehouseMapper.toFacilities( |
||||
java.util.Arrays.asList(bad, row())).size()); |
||||
assertNull(EdayunWarehouseMapper.toFacility(null)); |
||||
} |
||||
|
||||
@Test |
||||
void emptyRowsYieldEmptyList() { |
||||
assertTrue(EdayunWarehouseMapper.toFacilities(null).isEmpty()); |
||||
assertTrue(EdayunWarehouseMapper.toFacilities( |
||||
java.util.Collections.<EdayunWarehouseDtos.WarehouseRow>emptyList()).isEmpty()); |
||||
} |
||||
|
||||
// ------------------------------------------------------------ 门面
|
||||
|
||||
@Test |
||||
void adapterQueriesPermittedWarehouses() { |
||||
RecordingTransport transport = stub( |
||||
common.ecommerce.edayun.EdayunConstants.PATH_WAREHOUSE_PERMITTED, |
||||
"{\"code\":200,\"msg\":\"操作成功\",\"data\":[" |
||||
+ "{\"warehouseId\":\"2\",\"warehouseName\":\"美西1仓\"," |
||||
+ "\"warehouseCode\":\"USLA\",\"countryCode\":\"US\"}," |
||||
+ "{\"warehouseId\":\"-999\",\"warehouseName\":\"使用分仓规则\"," |
||||
+ "\"warehouseCode\":\"USMC\"}]}"); |
||||
|
||||
List<WarehouseFacility> list = new EdayunAdapter(transport, new JacksonJsonCodec()) |
||||
.warehouses(ctx()); |
||||
|
||||
assertEquals(1, list.size()); |
||||
assertEquals("USLA", list.get(0).warehouseCode()); |
||||
} |
||||
|
||||
/** listActive 要带 warehouseOperationType,且同样跳过 -999。 */ |
||||
@Test |
||||
void adapterQueriesActiveWarehouses() { |
||||
RecordingTransport transport = stub( |
||||
common.ecommerce.edayun.EdayunConstants.PATH_WAREHOUSE_ACTIVE, |
||||
"{\"code\":200,\"msg\":\"操作成功\",\"data\":[" |
||||
+ "{\"warehouseId\":\"40222\",\"warehouseName\":\"上海浦东新区实体仓\"," |
||||
+ "\"warehouseCode\":\"LS1130\",\"warehouseOperationType\":1}]}"); |
||||
|
||||
List<WarehouseFacility> list = new EdayunAdapter(transport, new JacksonJsonCodec()) |
||||
.activeWarehouses(ctx(), true); |
||||
|
||||
assertEquals(1, list.size()); |
||||
assertEquals("LS1130", list.get(0).warehouseCode()); |
||||
assertTrue(transport.lastDataRequest().body() |
||||
.contains("\"warehouseOperationType\":1")); |
||||
} |
||||
} |
||||
@ -0,0 +1,102 @@
@@ -0,0 +1,102 @@
|
||||
package common.ecommerce.edayun.probe; |
||||
|
||||
import common.ecommerce.edayun.EdayunConstants; |
||||
import common.ecommerce.edayun.adapter.EdayunAdapter; |
||||
import common.ecommerce.http.JacksonJsonCodec; |
||||
import common.ecommerce.http.OkHttpTransport; |
||||
import common.ecommerce.shared.error.ChannelException; |
||||
import common.ecommerce.shared.spi.ChannelSecret; |
||||
import common.ecommerce.warehouse.enums.WarehouseProvider; |
||||
import common.ecommerce.warehouse.model.WarehouseFacility; |
||||
import common.ecommerce.warehouse.sdk.WarehouseConnection; |
||||
import common.ecommerce.warehouse.sdk.WarehouseContext; |
||||
import org.junit.jupiter.api.Assumptions; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; |
||||
|
||||
import java.time.Clock; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
|
||||
/** |
||||
* 仓库清单联调探针:<b>只读</b>。 |
||||
* |
||||
* <pre> |
||||
* # 只看报文(不联网) |
||||
* mvn -pl warehouse-sdk-edayun -DfailIfNoTests=false \ |
||||
* -Dedayun.probe.warehouse=true -Dtest=EdayunWarehouseProbeTest test |
||||
* |
||||
* # 真查(只读) |
||||
* ... -Dedayun.probe.warehouse=true -Dedayun.probe.call=true \ |
||||
* -Dedayun.probe.clientId=... -Dedayun.probe.clientSecret=... \ |
||||
* -Dedayun.probe.appKey=... -Dedayun.probe.appSecret=... |
||||
* </pre> |
||||
* |
||||
* <p>两个接口都查:权限内(下单用这个)与全量激活仓(含未授权的)。</p> |
||||
*/ |
||||
@EnabledIfSystemProperty(named = "edayun.probe.warehouse", matches = "true") |
||||
class EdayunWarehouseProbeTest { |
||||
|
||||
private static final String BASE_URL = opt("edayun.probe.baseUrl", EdayunConstants.PR_BASE_URL); |
||||
private static final String CLIENT_ID = System.getProperty("edayun.probe.clientId", ""); |
||||
private static final String CLIENT_SECRET = System.getProperty("edayun.probe.clientSecret", ""); |
||||
private static final String APP_KEY = System.getProperty("edayun.probe.appKey", ""); |
||||
private static final String APP_SECRET = System.getProperty("edayun.probe.appSecret", ""); |
||||
private static final boolean CALL = Boolean.getBoolean("edayun.probe.call"); |
||||
|
||||
@Test |
||||
void probeWarehouses() { |
||||
System.out.println("\n================ edayun / POST " |
||||
+ EdayunConstants.PATH_WAREHOUSE_PERMITTED + " (权限内) ================"); |
||||
System.out.println("[request] {}"); |
||||
System.out.println("\n================ edayun / POST " |
||||
+ EdayunConstants.PATH_WAREHOUSE_ACTIVE + " (全量) ================"); |
||||
System.out.println("[request] {\"warehouseOperationType\":0}"); |
||||
|
||||
Assumptions.assumeTrue(CALL, "dry-run:未加 -Dedayun.probe.call=true,不实际调用"); |
||||
Assumptions.assumeTrue(!CLIENT_ID.trim().isEmpty() && !CLIENT_SECRET.trim().isEmpty() |
||||
&& !APP_KEY.trim().isEmpty() && !APP_SECRET.trim().isEmpty(), |
||||
"真查需要 -Dedayun.probe.clientId / clientSecret / appKey / appSecret"); |
||||
|
||||
try { |
||||
WarehouseContext ctx = WarehouseContext.of("EDY-PROBE", WarehouseProvider.EDAYUN, null, |
||||
WarehouseConnection.of(BASE_URL, |
||||
ChannelSecret.builder() |
||||
.appKey(APP_KEY).appSecret(APP_SECRET) |
||||
.clientId(CLIENT_ID).clientSecret(CLIENT_SECRET) |
||||
.build()), |
||||
"probe-" + UUID.randomUUID(), Clock.systemUTC()); |
||||
EdayunAdapter adapter = new EdayunAdapter( |
||||
new OkHttpTransport("common-ecommerce/1.0.0 (edayun-probe)", 10_000, 60_000), |
||||
new JacksonJsonCodec()); |
||||
|
||||
print("权限内", adapter.warehouses(ctx)); |
||||
print("全量尾程", adapter.activeWarehouses(ctx, false)); |
||||
print("全量头程", adapter.activeWarehouses(ctx, true)); |
||||
} catch (RuntimeException e) { |
||||
String msg = e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage(); |
||||
System.out.println("[ERROR] " + e.getClass().getSimpleName() + ": " |
||||
+ (msg.length() <= 800 ? msg : msg.substring(0, 800) + "…")); |
||||
if (e instanceof ChannelException) { |
||||
ChannelException ce = (ChannelException) e; |
||||
System.out.println(" platformCode=" + ce.platformCode() |
||||
+ " retryable=" + ce.retryable()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void print(String label, List<WarehouseFacility> list) { |
||||
System.out.println("[OK] " + label + " warehouses=" + list.size()); |
||||
for (int i = 0; i < Math.min(5, list.size()); i++) { |
||||
WarehouseFacility f = list.get(i); |
||||
System.out.println(" " + f.providerWarehouseId() + " " + f.warehouseCode() |
||||
+ " " + f.name() + " " + f.country()); |
||||
} |
||||
} |
||||
|
||||
private static String opt(String name, String fallback) { |
||||
String value = System.getProperty(name, ""); |
||||
String trimmed = value == null ? "" : value.trim(); |
||||
return trimmed.isEmpty() ? fallback : trimmed; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue