Browse Source

refactor(edayun): 修正 printBarcode / newPrintCaseMark 的语义归属

仓方确认两个端点名与实际打印的东西是反的:
- /webApi/skuInfo/v2/printBarcode          → 实际是箱唛(外箱标)
- /webApi/entryInfo/v1/newPrintCaseMark*   → 实际是 SKU 标

代码按实际语义命名(端点不变):
- printCaseMarks(...) + CaseMarkPrintCommand / CaseMarkPaperSize / CASE_MARK_PRINT
- printSkuLabel(...)  + EdayunSkuLabelDtos / EdayunSkuLabelMapper / EdayunSkuLabelPaper

纸张尺寸真机实测(MediaBox)发现文档标称有错:
  pageSize=2 文档说 6×4cm,实测 100×150mm
  pageSize=3 文档说 A4,  实测 60×40mm
枚举按实测尺寸命名,码值原样保留。

其余三个尺寸与文档一致:0→70×30、1→100×60。

Co-Authored-By: Claude <noreply@anthropic.com>
master
chenchuchuan 4 days ago
parent
commit
b675dd67e0
  1. 137
      docs-warehouse/edayun/README.md
  2. 4
      docs-warehouse/edayun/TODO.md
  3. 8
      warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/capability/CaseMarkPrintCapable.java
  4. 37
      warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/enums/BarcodePaperSize.java
  5. 47
      warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/enums/CaseMarkPaperSize.java
  6. 4
      warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/enums/WarehouseCapability.java
  7. 34
      warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/model/CaseMarkPrintCommand.java
  8. 18
      warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/sdk/WarehouseOperations.java
  9. 17
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/EdayunConstants.java
  10. 91
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunAdapter.java
  11. 70
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunBarcodeMapper.java
  12. 134
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunCaseMarkMapper.java
  13. 127
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunSkuLabelMapper.java
  14. 52
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/dto/EdayunBarcodeDtos.java
  15. 56
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/dto/EdayunCaseMarkDtos.java
  16. 69
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/dto/EdayunSkuLabelDtos.java
  17. 10
      warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/enums/EdayunSkuLabelPaper.java
  18. 166
      warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/adapter/EdayunBarcodeTest.java
  19. 218
      warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/adapter/EdayunCaseMarkTest.java
  20. 158
      warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/adapter/EdayunSkuLabelTest.java
  21. 22
      warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/probe/EdayunCaseMarkProbeTest.java

137
docs-warehouse/edayun/README.md

@ -27,8 +27,8 @@
| BOL 查询(平台仓订单) | ✅ 已对接(`POST /webApi/fbaOrder/v1/getOrderBolList`) | | BOL 查询(平台仓订单) | ✅ 已对接(`POST /webApi/fbaOrder/v1/getOrderBolList`) |
| 物流产品清单 | ✅ 已对接(`POST /webApi/order/listByLogisticProductHasPerm`) | | 物流产品清单 | ✅ 已对接(`POST /webApi/order/listByLogisticProductHasPerm`) |
| 物流轨迹 | ✅ 已对接(`POST /webApi/track/getTrackInfoList`) | | 物流轨迹 | ✅ 已对接(`POST /webApi/track/getTrackInfoList`) |
| 打印条码 | ✅ 已对接(`POST /webApi/skuInfo/v2/printBarcode`) | | 打印箱唛 | ✅ 已对接(`POST /webApi/skuInfo/v2/printBarcode`) |
| 打印箱唛 | ⚠️ 已实现(`POST /webApi/entryInfo/v1/newPrintCaseMarkContentType`),**真机未启用** | | 打印 SKU 标 | ⚠️ 已实现(`POST /webApi/entryInfo/v1/newPrintCaseMarkContentType`),**真机未启用** |
| 其它业务接口 | ⬜ 等文档 | | 其它业务接口 | ⬜ 等文档 |
| 回调 | ⬜ 等文档 | | 回调 | ⬜ 等文档 |
| 真机验证 | ⬜ 等测试环境 | | 真机验证 | ⬜ 等测试环境 |
@ -1143,123 +1143,72 @@ POST /webApi/track/getTrackInfoList → List<TrackEvent> / TrackingInfo
**PR 环境没有任何可查到的轨迹**,映射只被单测覆盖。 **PR 环境没有任何可查到的轨迹**,映射只被单测覆盖。
## 打印条码 ## 打印箱唛 / SKU 标
``` ### 两个端点名与实际语义是反的
POST /webApi/skuInfo/v2/printBarcode → WarehouseLabel
```
### 与入库 SKU 贴标不是一回事 已与仓方确认:
| | `inbound().printSkuLabel()` | `printBarcodes()` | | 端点 | 实际打印 | 我们的方法 | 能力位 |
|---|---|---| |---|---|---|---|
| 对象 | 入库计划单 | **任意 SKU** | | `/webApi/skuInfo/v2/printBarcode` | **箱唛**(外箱标) | `printCaseMarks(...)` | `CASE_MARK_PRINT` |
| 绑定 | 必填入库单号 | 不绑单据 | | `/webApi/entryInfo/v1/newPrintCaseMarkContentType` | **SKU 标** | `printSkuLabel(...)` | 走入库 `SKU_LABEL` 语义 |
| 纸张 | 14 种小尺寸 | **4 档** |
| 返回 | 异步任务号 | **同步 PDF 地址** |
因为纸张集合完全不同,新增了独立枚举 `BarcodePaperSize`(7×3cm / 10×6cm / 6×4cm / A4), **不要被路径名误导**。代码里两个方法的 javadoc 都写了这条提醒。
没有复用 `SkuLabelSizeType`——那可是 14 个取值,混用会误导调用方。
### 响应 `data` 是文件地址字符串 ### 箱唛(printBarcode)
```json ```
{"code":200,"msg":"操作成功","data":"https://.../barcode123.pdf","traceId":null} POST /webApi/skuInfo/v2/printBarcode → WarehouseLabel
``` ```
不是对象、也不是任务号——仓方同步生成 PDF。映射到 `WarehouseLabel.url()`。 请求体按 SKU 列表打,服务端把每个 SKU 的条码排版成箱唛 PDF。
### 本地提前挡住的两条 **四种纸张尺寸实测(MediaBox,单位 pt):**
| 约束 | 仓方提示 | 我们 | | `pageSize` | 文档标称 | 实测 MediaBox | 折算 |
|---|---|---| |---|---|---|---|
| SKU 数 > 50 | `最多打印50个SKU` | `BarcodePrintCommand` 构造期就拒 | | 0 | 7×3cm | `198 × 85` | 69.9 × 30.0 mm |
| 份数 ≤ 0 | `内部服务器错误` | 同上 | | 1 | 10×6cm | `284 × 170` | 100.2 × 60.0 mm |
| 2 | 6×4cm | `283 × 425` | **99.9 × 150.0 mm** |
| 3 | A4 | `170 × 113` | **60.0 × 39.9 mm** |
仓方对非法 `num` 回的是「内部服务器错误」,看不出原因,所以本地先挡。 **`pageSize=2` 和 `pageSize=3` 的文档标称与实际相反**:文档说 2 是「6×4cm」、
3 是「A4」,实际 2 打出来是 100×150mm、3 打出来是 60×40mm。
枚举按**实测尺寸**命名(`SIZE_60_40` / `SIZE_100_150`),码值原样保留。
### 其它实测校验 **本地提前挡的两条**(仓方都回「内部服务器错误」,看不出原因):
| 场景 | 仓方返回 | | 约束 | 本地行为 |
|---|---| |---|---|
| 缺 `productInfos` / 空数组 | `产品信息不能为空` | | SKU 数 > 50 | 构造期拒绝(仓方提示「最多打印50个SKU」) |
| 缺 `pageSize` | `纸张尺寸不能为空` | | 份数 ≤ 0 | 构造期拒绝 |
| `pageSize=9`(非法) | `内部服务器错误` |
| SKU 不存在 | `sku=NO-SUCH-SKU信息不存在` |
### `isPrintSkuName` 只在 true 时下发
`false` 是仓方默认值,不下发,省得干扰它自己的默认。
### 真机验证(2026-11-16) `isPrintSkuName` 只在 `true` 时下发,`false` 交给仓方默认。
`ybtest` + A4 + `isPrintSkuName=true` → 拿到真实 PDF:
`https://oss.edayun.com/test/2026/11/16/02/.../barcode7640824581948387426.pdf`
四种纸张尺寸都返回 `code=200`。 **真机(2026-11-16)**:`ybtest` 拿到真实 PDF,四种纸张都 `code=200`。
仓方其它校验:缺 `productInfos` →「产品信息不能为空」、缺 `pageSize` →
「纸张尺寸不能为空」、SKU 不存在 →「sku=XXX信息不存在」。
## 打印箱唛 ### SKU 标(newPrintCaseMarkContentType)
``` ```
POST /webApi/entryInfo/v1/newPrintCaseMarkContentType → WarehouseLabel POST /webApi/entryInfo/v1/newPrintCaseMarkContentType → WarehouseLabel
``` ```
### 真机:接口不存在或未启用 **真机未启用**:PR 环境该路径报「接口不存在或未启用」,去掉
`ContentType` 后缀的 `newPrintCaseMark` 能过参数校验(缺 `pageSize` 报
PR 环境实测(2026-11-16): 「纸张不能为空」、缺 `madeInChina` 报「产地标签不能为空」),但补全后一律
「内部服务器错误」。所以本接口实现是**按文档写的**,映射只有单测覆盖。
| 路径 | 结果 |
|---|---|
| `entryInfo/v1/newPrintCaseMarkContentType` | `code=500`「接口不存在或未启用!」 |
| `entryInfo/v1/printCaseMarkContentType` / `printCaseMark` / `v2/...` | 同上 |
| `entryInfo/v1/newPrintCaseMark`(无后缀) | **能过参数校验** |
`newPrintCaseMark` 的校验提示确认了必填项:缺 `pageSize` →「纸张不能为空」,
缺 `madeInChina` →「产地标签不能为空」。但**补全后一律「内部服务器错误」**,
试过 skuCode、箱序号区间、`twoPrint`、`separation`、四种纸张,都没过。
所以本接口的实现是**按文档写的**,没有真机返回可对照——映射只有单测覆盖。
### 纸张码值不连续
| 易达云 | 尺寸 | 统一枚举 |
|---|---|---|
| 4 | 100×100 | `LabelSizeType.SIZE_100_100` |
| 2 | 100×150 | `LabelSizeType.SIZE_100_150` |
| 5 | A4 | `LabelSizeType.A4`(本次新增) |
**码值是 4 / 2 / 5,不是 1/2/3**,不能按顺序推。统一枚举原来只有三种
(100×100 / 100×150 / 104×98),A4 是这次为箱唛新增的。
104×98(美国信纸)易达云不支持,`EdayunCaseMarkPaper.of()` 会显式拒绝。
### 统一模型只能表达「整单打印」
`BoxLabelCommand` 没有「选哪些箱」的字段,所以选箱条件
(`caseCodeList` / `skuCode` / 箱序号区间 / 客户箱号区间)默认不下发,
由仓方整单打印。
要打部分箱用扩展重载:
```java
edaunAdapter.printCaseMarks(ctx, cmd,
new EdayunCaseMarkMapper.CaseSelection()
.caseCodes(Arrays.asList("B001", "B002")));
```
四个维度全空时本地拒绝——文档写明「必须有一个不为空」。
### 两个易达云特有开关默认关 纸张码值不连续:`100×100=4` / `100×150=2` / `A4=5`。统一枚举
`LabelSizeType` 为此补了 `A4`。
| 字段 | 默认 | 原因 |
|---|---|---|
| `madeInChina` | 0 否 | 统一模型没有「原产地标注」概念,猜「打」会让每箱多一行 |
| `separation` | false | 分隔符是易达云特有的分页提示,统一模型没有对应语义 |
### 返回同步 PDF 统一模型的 `BoxLabelCommand` 没有「选哪些箱」,默认整单打印;部分箱用
`printSkuLabel(ctx, cmd, CaseSelection)` 重载(系统箱号 / SKU / 箱序号区间 /
客户箱号区间四选一,全空本地拒)。
响应 `data` 是地址字符串,不是任务号——所以返回 `WarehouseLabel` 而不是 `madeInChina` 与 `separation` 是易达云特有语义,统一模型没有对应概念 → 默认关。
`LabelPrintTask`(那个是运去哪风格的异步任务语义)。
## 待确认(问易达云) ## 待确认(问易达云)

4
docs-warehouse/edayun/TODO.md

@ -68,7 +68,9 @@
| 66 | 条码文件地址的**有效期**未知(OSS 链接) | 原样返回,不缓存 | 宿主存旧链接可能 403 | | 66 | 条码文件地址的**有效期**未知(OSS 链接) | 原样返回,不缓存 | 宿主存旧链接可能 403 |
| 67 | 条码打印是否有限流 / 是否计费 | 未处理 | 大批量打印可能被限 | | 67 | 条码打印是否有限流 / 是否计费 | 未处理 | 大批量打印可能被限 |
| 68 | **箱唛接口在 PR 环境未启用**(`newPrintCaseMarkContentType` 报「接口不存在或未启用」;去掉后缀的 `newPrintCaseMark` 能过参数校验但一律「内部服务器错误」) | 按文档实现,映射只有单测 | 上线前必须真机验证 | | 68 | **箱唛接口在 PR 环境未启用**(`newPrintCaseMarkContentType` 报「接口不存在或未启用」;去掉后缀的 `newPrintCaseMark` 能过参数校验但一律「内部服务器错误」) | 按文档实现,映射只有单测 | 上线前必须真机验证 |
| 69 | 箱唛纸张码值 4/2/5 不连续 | 独立枚举 `EdayunCaseMarkPaper`,按映射表走 | 无(已规避) | | 69 | SKU 标纸张码值 4/2/5 不连续 | 独立枚举 `EdayunSkuLabelPaper`,按映射表走 | 无(已规避) |
| 72 | **`printBarcode` 的 pageSize=2 / pageSize=3 文档标称与实际相反**(文档 2=6×4cm、3=A4;实测 2=100×150mm、3=60×40mm) | 枚举按实测尺寸命名,码值不变 | 按文档标称选纸会打错 |
| 73 | 两个端点名与实际语义相反(printBarcode=箱唛、newPrintCaseMark=SKU 标) | 代码按实际语义命名并在 javadoc 标注 | 无(已规避) |
| 70 | 箱唛的 `madeInChina` / `separation` 统一模型没有语义 | 默认关 | 需要打「Made in China」时得走扩展重载 | | 70 | 箱唛的 `madeInChina` / `separation` 统一模型没有语义 | 默认关 | 需要打「Made in China」时得走扩展重载 |
| 71 | 箱唛选箱条件(系统箱号 / SKU / 箱序号 / 客户箱号)统一模型没有 | 提供 `CaseSelection` 扩展重载 | 宿主想要部分箱打印必须用易达云专有 API | | 71 | 箱唛选箱条件(系统箱号 / SKU / 箱序号 / 客户箱号)统一模型没有 | 提供 `CaseSelection` 扩展重载 | 宿主想要部分箱打印必须用易达云专有 API |
|---|---|---|---| |---|---|---|---|

8
warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/capability/BarcodePrintCapable.java → warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/capability/CaseMarkPrintCapable.java

@ -1,12 +1,12 @@
package common.ecommerce.warehouse.capability; package common.ecommerce.warehouse.capability;
import common.ecommerce.warehouse.model.BarcodePrintCommand; import common.ecommerce.warehouse.model.CaseMarkPrintCommand;
import common.ecommerce.warehouse.model.WarehouseLabel; import common.ecommerce.warehouse.model.WarehouseLabel;
import common.ecommerce.warehouse.sdk.WarehouseAdapter; import common.ecommerce.warehouse.sdk.WarehouseAdapter;
import common.ecommerce.warehouse.sdk.WarehouseContext; import common.ecommerce.warehouse.sdk.WarehouseContext;
/** /**
* 商品条码打印能力:按 SKU 打条码贴纸,不依赖任何单据。 * 箱唛打印能力:按 SKU 打外箱标(箱唛)。
* *
* <p>与 {@link InboundCapable#printSkuLabel} 不是一回事:那个是<b>入库计划单</b>的贴标 * <p>与 {@link InboundCapable#printSkuLabel} 不是一回事:那个是<b>入库计划单</b>的贴标
* (绑定入库单号、有 14 种小纸尺寸、仓方异步生成);这个是<b>按 SKU 打条码</b>, * (绑定入库单号、有 14 种小纸尺寸、仓方异步生成);这个是<b>按 SKU 打条码</b>,
@ -14,7 +14,7 @@ import common.ecommerce.warehouse.sdk.WarehouseContext;
* *
* <p>只读语义(不改业务状态),但会生成文件;重复调用只是再生成一份。</p> * <p>只读语义(不改业务状态),但会生成文件;重复调用只是再生成一份。</p>
*/ */
public interface BarcodePrintCapable extends WarehouseAdapter { public interface CaseMarkPrintCapable extends WarehouseAdapter {
/** /**
* 打印 SKU 条码。 * 打印 SKU 条码。
@ -23,5 +23,5 @@ public interface BarcodePrintCapable extends WarehouseAdapter {
* @throws common.ecommerce.warehouse.error.WarehouseUnsupportedCapabilityException * @throws common.ecommerce.warehouse.error.WarehouseUnsupportedCapabilityException
* 该仓不声明 {@code BARCODE_PRINT} * 该仓不声明 {@code BARCODE_PRINT}
*/ */
WarehouseLabel printBarcodes(WarehouseContext ctx, BarcodePrintCommand cmd); WarehouseLabel printCaseMarks(WarehouseContext ctx, CaseMarkPrintCommand cmd);
} }

37
warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/enums/BarcodePaperSize.java

@ -1,37 +0,0 @@
package common.ecommerce.warehouse.enums;
/**
* SKU 条码打印的纸张尺寸。
*
* <p>易达云 {@code printBarcode} 的 {@code pageSize}:0 7×3cm / 1 10×6cm /
* 2 6×4cm / 3 A4。<b>只有这 4 档</b>,与入库贴标用的
* {@link SkuLabelSizeType}(14 种小尺寸)不是一套,不能互换。</p>
*/
public enum BarcodePaperSize {
/** 0:70mm × 30mm。 */
SIZE_70_30(0, "7×3cm"),
/** 1:100mm × 60mm。 */
SIZE_100_60(1, "10×6cm"),
/** 2:60mm × 40mm。 */
SIZE_60_40(2, "6×4cm"),
/** 3:A4。 */
A4(3, "A4");
private final int code;
private final String label;
BarcodePaperSize(int code, String label) {
this.code = code;
this.label = label;
}
/** 仓方码值。 */
public int code() {
return code;
}
public String label() {
return label;
}
}

47
warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/enums/CaseMarkPaperSize.java

@ -0,0 +1,47 @@
package common.ecommerce.warehouse.enums;
/**
* 箱唛打印的纸张尺寸(易达云 {@code printBarcode} 的 {@code pageSize})。
*
* <p><b>名称按真机实测尺寸取,不是按文档标称</b>——文档的 2 / 3 两档与实测相反。
* 实测是 PDF MediaBox 折算的毫米数(1pt = 25.4/72 mm):</p>
*
* <table>
* <tr><th>码值</th><th>文档标称</th><th>实测</th><th>枚举</th></tr>
* <tr><td>0</td><td>7×3cm</td><td>69.9 × 30.0 mm</td><td>{@link #SIZE_70_30}</td></tr>
* <tr><td>1</td><td>10×6cm</td><td>100.2 × 60.0 mm</td><td>{@link #SIZE_100_60}</td></tr>
* <tr><td>2</td><td>6×4cm</td><td><b>99.9 × 150.0 mm</b></td><td>{@link #SIZE_100_150}</td></tr>
* <tr><td>3</td><td>A4</td><td><b>60.0 × 39.9 mm</b></td><td>{@link #SIZE_60_40}</td></tr>
* </table>
*
* <p>与入库贴标用的 {@link SkuLabelSizeType}(14 种小尺寸)不是一套,不能互换。</p>
*/
public enum CaseMarkPaperSize {
/** 0:约 70mm × 30mm(文档 7×3cm,实测一致)。 */
SIZE_70_30(0, "70×30mm"),
/** 1:约 100mm × 60mm(文档 10×6cm,实测一致)。 */
SIZE_100_60(1, "100×60mm"),
/** 2:约 100mm × 150mm(<b>文档标 6×4cm,实测不符</b>)。 */
SIZE_100_150(2, "100×150mm"),
/** 3:约 60mm × 40mm(<b>文档标 A4,实测不符</b>)。 */
SIZE_60_40(3, "60×40mm");
private final int code;
private final String label;
CaseMarkPaperSize(int code, String label) {
this.code = code;
this.label = label;
}
/** 仓方码值。 */
public int code() {
return code;
}
/** 实测尺寸的显示名。 */
public String label() {
return label;
}
}

4
warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/enums/WarehouseCapability.java

@ -58,8 +58,8 @@ public enum WarehouseCapability {
CHANNEL_RECOMMEND(240, "最优渠道推荐"), CHANNEL_RECOMMEND(240, "最优渠道推荐"),
/** 物流异动单:召回 / 换址 / 在途异常(对已交运的运单发起处理) */ /** 物流异动单:召回 / 换址 / 在途异常(对已交运的运单发起处理) */
TRACKING_CHANGE(250, "物流异动单"), TRACKING_CHANGE(250, "物流异动单"),
/** 商品条码打印(不依赖单据,按 SKU 打条码) */ /** 箱唛打印(不依赖单据,按 SKU 打外箱标) */
BARCODE_PRINT(260, "商品条码打印"); CASE_MARK_PRINT(260, "箱唛打印");
private final int code; private final int code;
private final String label; private final String label;

34
warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/model/BarcodePrintCommand.java → warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/model/CaseMarkPrintCommand.java

@ -1,13 +1,13 @@
package common.ecommerce.warehouse.model; package common.ecommerce.warehouse.model;
import common.ecommerce.warehouse.enums.BarcodePaperSize; import common.ecommerce.warehouse.enums.CaseMarkPaperSize;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
* SKU 条码打印命令(打商品条码,不是入库单的 SKU 贴标)。 * 箱唛打印命令(打外箱标,不是入库单的 SKU 贴标)。
* *
* <p>与 {@link SkuLabelCommand} 的区别:那个是<b>入库计划单</b>的贴标(绑定 * <p>与 {@link SkuLabelCommand} 的区别:那个是<b>入库计划单</b>的贴标(绑定
* 入库单号、14 种小纸尺寸);这个是<b>按 SKU 打条码</b>,不依赖任何单据, * 入库单号、14 种小纸尺寸);这个是<b>按 SKU 打条码</b>,不依赖任何单据,
@ -16,19 +16,19 @@ import java.util.List;
* <p>仓方<b>同步</b>返回文件地址(不是异步任务),所以返回的是 * <p>仓方<b>同步</b>返回文件地址(不是异步任务),所以返回的是
* {@link WarehouseLabel} 而不是 {@link LabelPrintTask}。</p> * {@link WarehouseLabel} 而不是 {@link LabelPrintTask}。</p>
*/ */
public final class BarcodePrintCommand { public final class CaseMarkPrintCommand {
/** 一次最多打多少种 SKU。 */ /** 一次最多打多少种 SKU。 */
public static final int MAX_SKUS = 50; public static final int MAX_SKUS = 50;
private final BarcodePaperSize paperSize; private final CaseMarkPaperSize paperSize;
/** 备注,如 {@code Made in China}。 */ /** 备注,如 {@code Made in China}。 */
private final String remark; private final String remark;
/** 是否打印 SKU 名称。 */ /** 是否打印 SKU 名称。 */
private final boolean printSkuName; private final boolean printSkuName;
private final List<BarcodeItem> items; private final List<CaseMarkItem> items;
private BarcodePrintCommand(Builder b) { private CaseMarkPrintCommand(Builder b) {
if (b.paperSize == null) { if (b.paperSize == null) {
throw new IllegalArgumentException("paperSize is required"); throw new IllegalArgumentException("paperSize is required");
} }
@ -42,14 +42,14 @@ public final class BarcodePrintCommand {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"at most " + MAX_SKUS + " skus per print, got " + b.items.size()); "at most " + MAX_SKUS + " skus per print, got " + b.items.size());
} }
this.items = Collections.unmodifiableList(new ArrayList<BarcodeItem>(b.items)); this.items = Collections.unmodifiableList(new ArrayList<CaseMarkItem>(b.items));
} }
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
public BarcodePaperSize paperSize() { public CaseMarkPaperSize paperSize() {
return paperSize; return paperSize;
} }
@ -63,17 +63,17 @@ public final class BarcodePrintCommand {
return printSkuName; return printSkuName;
} }
public List<BarcodeItem> items() { public List<CaseMarkItem> items() {
return items; return items;
} }
/** 一个 SKU 及其打印份数。 */ /** 一个 SKU 及其打印份数。 */
public static final class BarcodeItem { public static final class CaseMarkItem {
private final String providerSku; private final String providerSku;
private final int copies; private final int copies;
public BarcodeItem(String providerSku, int copies) { public CaseMarkItem(String providerSku, int copies) {
if (providerSku == null || providerSku.trim().isEmpty()) { if (providerSku == null || providerSku.trim().isEmpty()) {
throw new IllegalArgumentException("providerSku must not be blank"); throw new IllegalArgumentException("providerSku must not be blank");
} }
@ -94,12 +94,12 @@ public final class BarcodePrintCommand {
} }
public static final class Builder { public static final class Builder {
private BarcodePaperSize paperSize; private CaseMarkPaperSize paperSize;
private String remark; private String remark;
private boolean printSkuName; private boolean printSkuName;
private final List<BarcodeItem> items = new ArrayList<BarcodeItem>(); private final List<CaseMarkItem> items = new ArrayList<CaseMarkItem>();
public Builder paperSize(BarcodePaperSize v) { public Builder paperSize(CaseMarkPaperSize v) {
this.paperSize = v; this.paperSize = v;
return this; return this;
} }
@ -115,12 +115,12 @@ public final class BarcodePrintCommand {
} }
public Builder item(String providerSku, int copies) { public Builder item(String providerSku, int copies) {
this.items.add(new BarcodeItem(providerSku, copies)); this.items.add(new CaseMarkItem(providerSku, copies));
return this; return this;
} }
public BarcodePrintCommand build() { public CaseMarkPrintCommand build() {
return new BarcodePrintCommand(this); return new CaseMarkPrintCommand(this);
} }
} }
} }

18
warehouse-sdk-core/src/main/java/common/ecommerce/warehouse/sdk/WarehouseOperations.java

@ -4,7 +4,7 @@ import common.ecommerce.shared.audit.CallObserver;
import common.ecommerce.shared.audit.CallSupport; import common.ecommerce.shared.audit.CallSupport;
import common.ecommerce.shared.idempotency.IdempotencyGuard; import common.ecommerce.shared.idempotency.IdempotencyGuard;
import common.ecommerce.shared.support.Page; import common.ecommerce.shared.support.Page;
import common.ecommerce.warehouse.capability.BarcodePrintCapable; import common.ecommerce.warehouse.capability.CaseMarkPrintCapable;
import common.ecommerce.warehouse.capability.BolCapable; import common.ecommerce.warehouse.capability.BolCapable;
import common.ecommerce.warehouse.capability.DestructionCapable; import common.ecommerce.warehouse.capability.DestructionCapable;
import common.ecommerce.warehouse.capability.InboundCapable; import common.ecommerce.warehouse.capability.InboundCapable;
@ -25,7 +25,7 @@ import common.ecommerce.warehouse.enums.InventorySyncStrategy;
import common.ecommerce.warehouse.enums.WarehouseCapability; import common.ecommerce.warehouse.enums.WarehouseCapability;
import common.ecommerce.warehouse.enums.WarehouseProvider; import common.ecommerce.warehouse.enums.WarehouseProvider;
import common.ecommerce.warehouse.error.WarehouseUnsupportedCapabilityException; import common.ecommerce.warehouse.error.WarehouseUnsupportedCapabilityException;
import common.ecommerce.warehouse.model.BarcodePrintCommand; import common.ecommerce.warehouse.model.CaseMarkPrintCommand;
import common.ecommerce.warehouse.model.BillingDocument; import common.ecommerce.warehouse.model.BillingDocument;
import common.ecommerce.warehouse.model.BoxLabelCommand; import common.ecommerce.warehouse.model.BoxLabelCommand;
import common.ecommerce.warehouse.model.ChannelRecommendQuery; import common.ecommerce.warehouse.model.ChannelRecommendQuery;
@ -344,19 +344,19 @@ public final class WarehouseOperations {
} }
/** /**
* 打印 SKU 条码(不依赖单据)。 * 打印箱唛(外箱标,不依赖入库单)。
* *
* <p>与 {@code inbound().printSkuLabel()} 不同:那个绑定入库计划单, * <p>与 {@code inbound().printSkuLabel()} 不同:那个是入库计划单的 SKU 贴标,
* 这个只按 SKU 打。仓方同步返回文件地址,所以不走幂等守卫—— * 这个只按 SKU 打外箱标。仓方同步返回文件地址,所以不走幂等守卫——
* 重复调用只是再生成一份,不改业务状态。</p> * 重复调用只是再生成一份,不改业务状态。</p>
*/ */
public WarehouseLabel printBarcodes(BarcodePrintCommand cmd) { public WarehouseLabel printCaseMarks(CaseMarkPrintCommand cmd) {
require(WarehouseCapability.BARCODE_PRINT, BarcodePrintCapable.class); require(WarehouseCapability.CASE_MARK_PRINT, CaseMarkPrintCapable.class);
return CallSupport.observe(observer, ctx, "warehouse.barcode.print", return CallSupport.observe(observer, ctx, "warehouse.caseMark.print",
CallSupport.params("paperSize", cmd.paperSize(), CallSupport.params("paperSize", cmd.paperSize(),
"skuCount", cmd.items().size()), "skuCount", cmd.items().size()),
r -> CallSupport.NO_COUNT, r -> CallSupport.NO_COUNT,
() -> ((BarcodePrintCapable) adapter).printBarcodes(ctx, cmd)); () -> ((CaseMarkPrintCapable) adapter).printCaseMarks(ctx, cmd));
} }
/** 费用视图。 */ /** 费用视图。 */

17
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/EdayunConstants.java

@ -100,11 +100,20 @@ public final class EdayunConstants {
/** 查询订单物流轨迹({@code POST /webApi/track/getTrackInfoList})。 */ /** 查询订单物流轨迹({@code POST /webApi/track/getTrackInfoList})。 */
public static final String PATH_TRACK = "/webApi/track/getTrackInfoList"; public static final String PATH_TRACK = "/webApi/track/getTrackInfoList";
/** 打印条码({@code POST /webApi/skuInfo/v2/printBarcode})。 */ /**
public static final String PATH_BARCODE_PRINT = "/webApi/skuInfo/v2/printBarcode"; * 打印箱唛({@code POST /webApi/skuInfo/v2/printBarcode})。
*
* <p>端点名是 printBarcode,实际打的是箱唛——已与仓方确认。</p>
*/
public static final String PATH_CASE_MARK_PRINT = "/webApi/skuInfo/v2/printBarcode";
/** 打印箱唛({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。 */ /**
public static final String PATH_CASE_MARK_PRINT = "/webApi/entryInfo/v1/newPrintCaseMarkContentType"; * 打印 SKU 标({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。
*
* <p>端点名是 newPrintCaseMark,实际打的是 SKU 标——已与仓方确认。</p>
*/
public static final String PATH_SKU_LABEL_PRINT =
"/webApi/entryInfo/v1/newPrintCaseMarkContentType";
/** 物流增值:签收服务。 */ /** 物流增值:签收服务。 */
public static final String ADD_SERVICE_SIGNATURE = "is_signature"; public static final String ADD_SERVICE_SIGNATURE = "is_signature";

91
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunAdapter.java

@ -3,11 +3,10 @@ package common.ecommerce.edayun.adapter;
import common.ecommerce.edayun.EdayunConstants; import common.ecommerce.edayun.EdayunConstants;
import common.ecommerce.edayun.auth.EdayunTokenClient; import common.ecommerce.edayun.auth.EdayunTokenClient;
import common.ecommerce.edayun.dto.EdayunAccountFlowDtos; import common.ecommerce.edayun.dto.EdayunAccountFlowDtos;
import common.ecommerce.edayun.dto.EdayunBarcodeDtos;
import common.ecommerce.edayun.dto.EdayunBolDtos; import common.ecommerce.edayun.dto.EdayunBolDtos;
import common.ecommerce.edayun.dto.EdayunCaseMarkDtos;
import common.ecommerce.edayun.dto.EdayunCancelDtos; import common.ecommerce.edayun.dto.EdayunCancelDtos;
import common.ecommerce.edayun.dto.EdayunCancelReturnDtos; import common.ecommerce.edayun.dto.EdayunCancelReturnDtos;
import common.ecommerce.edayun.dto.EdayunCaseMarkDtos;
import common.ecommerce.edayun.dto.EdayunCreateOrderDtos; import common.ecommerce.edayun.dto.EdayunCreateOrderDtos;
import common.ecommerce.edayun.dto.EdayunCreateProductDtos; import common.ecommerce.edayun.dto.EdayunCreateProductDtos;
import common.ecommerce.edayun.dto.EdayunFeeEstimateDtos; import common.ecommerce.edayun.dto.EdayunFeeEstimateDtos;
@ -22,6 +21,7 @@ import common.ecommerce.edayun.dto.EdayunRentDetailDtos;
import common.ecommerce.edayun.dto.EdayunReturnDetailDtos; import common.ecommerce.edayun.dto.EdayunReturnDetailDtos;
import common.ecommerce.edayun.dto.EdayunReturnDtos; import common.ecommerce.edayun.dto.EdayunReturnDtos;
import common.ecommerce.edayun.dto.EdayunRmaListDtos; import common.ecommerce.edayun.dto.EdayunRmaListDtos;
import common.ecommerce.edayun.dto.EdayunSkuLabelDtos;
import common.ecommerce.edayun.dto.EdayunTrackDtos; import common.ecommerce.edayun.dto.EdayunTrackDtos;
import common.ecommerce.edayun.enums.EdayunCancelStatus; import common.ecommerce.edayun.enums.EdayunCancelStatus;
import common.ecommerce.edayun.http.EdayunRequestFactory; import common.ecommerce.edayun.http.EdayunRequestFactory;
@ -35,8 +35,8 @@ import common.ecommerce.shared.spi.ChannelSecret;
import common.ecommerce.shared.spi.LockProvider; import common.ecommerce.shared.spi.LockProvider;
import common.ecommerce.shared.spi.TokenStore; import common.ecommerce.shared.spi.TokenStore;
import common.ecommerce.shared.support.Page; import common.ecommerce.shared.support.Page;
import common.ecommerce.warehouse.capability.BarcodePrintCapable;
import common.ecommerce.warehouse.capability.BolCapable; import common.ecommerce.warehouse.capability.BolCapable;
import common.ecommerce.warehouse.capability.CaseMarkPrintCapable;
import common.ecommerce.warehouse.capability.InboundCapable; import common.ecommerce.warehouse.capability.InboundCapable;
import common.ecommerce.warehouse.capability.InventoryCapable; import common.ecommerce.warehouse.capability.InventoryCapable;
import common.ecommerce.warehouse.capability.LogisticsProductCapable; import common.ecommerce.warehouse.capability.LogisticsProductCapable;
@ -54,12 +54,12 @@ import common.ecommerce.warehouse.enums.WarehouseCapability;
import common.ecommerce.warehouse.enums.WarehouseProvider; import common.ecommerce.warehouse.enums.WarehouseProvider;
import common.ecommerce.warehouse.error.WarehouseException; import common.ecommerce.warehouse.error.WarehouseException;
import common.ecommerce.warehouse.error.WarehouseUnsupportedCapabilityException; import common.ecommerce.warehouse.error.WarehouseUnsupportedCapabilityException;
import common.ecommerce.warehouse.model.BarcodePrintCommand;
import common.ecommerce.warehouse.model.BillingDocument; import common.ecommerce.warehouse.model.BillingDocument;
import common.ecommerce.warehouse.model.BoxLabelCommand;
import common.ecommerce.warehouse.model.BolDocument; import common.ecommerce.warehouse.model.BolDocument;
import common.ecommerce.warehouse.model.BoxLabelCommand;
import common.ecommerce.warehouse.model.CancelCommand; import common.ecommerce.warehouse.model.CancelCommand;
import common.ecommerce.warehouse.model.CancelResult; import common.ecommerce.warehouse.model.CancelResult;
import common.ecommerce.warehouse.model.CaseMarkPrintCommand;
import common.ecommerce.warehouse.model.FeeEstimateQuery; import common.ecommerce.warehouse.model.FeeEstimateQuery;
import common.ecommerce.warehouse.model.FeeEstimateResult; import common.ecommerce.warehouse.model.FeeEstimateResult;
import common.ecommerce.warehouse.model.FeeQuery; import common.ecommerce.warehouse.model.FeeQuery;
@ -102,7 +102,7 @@ import java.util.List;
public final class EdayunAdapter implements WarehouseAdapter, WarehouseProductCapable, public final class EdayunAdapter implements WarehouseAdapter, WarehouseProductCapable,
OutboundCapable, WarehouseFeeCapable, WarehouseFeeEstimateCapable, InventoryCapable, OutboundCapable, WarehouseFeeCapable, WarehouseFeeEstimateCapable, InventoryCapable,
InboundCapable, WarehouseReturnCapable, BolCapable, LogisticsProductCapable, InboundCapable, WarehouseReturnCapable, BolCapable, LogisticsProductCapable,
TrackingCapable, BarcodePrintCapable { TrackingCapable, CaseMarkPrintCapable {
/** 物流产品查询的适用业务:1 店铺订单(默认口径)。 */ /** 物流产品查询的适用业务:1 店铺订单(默认口径)。 */
private static final int APPLICABLE_BUSINESS_STORE_ORDER = 1; private static final int APPLICABLE_BUSINESS_STORE_ORDER = 1;
@ -160,7 +160,7 @@ public final class EdayunAdapter implements WarehouseAdapter, WarehouseProductCa
WarehouseCapability.INVENTORY_QUERY, WarehouseCapability.INBOUND, WarehouseCapability.INVENTORY_QUERY, WarehouseCapability.INBOUND,
WarehouseCapability.RETURN, WarehouseCapability.BOL, WarehouseCapability.RETURN, WarehouseCapability.BOL,
WarehouseCapability.LOGISTICS_PRODUCT, WarehouseCapability.TRACKING, WarehouseCapability.LOGISTICS_PRODUCT, WarehouseCapability.TRACKING,
WarehouseCapability.BARCODE_PRINT); WarehouseCapability.CASE_MARK_PRINT);
} }
/** /**
@ -973,11 +973,16 @@ public final class EdayunAdapter implements WarehouseAdapter, WarehouseProductCa
// ------------------------------------------------------------------ 条码打印 // ------------------------------------------------------------------ 条码打印
// ------------------------------------------------------------------ 箱唛
/** /**
* 打印 SKU 条码({@code POST /webApi/skuInfo/v2/printBarcode})。 * 打印箱唛({@code POST /webApi/skuInfo/v2/printBarcode})。
* *
* <p>与入库贴标({@code inbound().printSkuLabel})不同:这个只按 SKU 打, * <p><b>端点名叫 printBarcode,但实际打的是箱唛(外箱标)</b>——已与仓方确认。
* 不绑单据,且仓方<b>同步返回 PDF 地址</b>。</p> * 真正的 SKU 标走 {@code printSkuLabel}(端点 {@code newPrintCaseMark})。</p>
*
* <p>与入库箱标({@code inbound().printBoxLabel})不同:那个是运去哪风格的
* 异步任务(只回任务号),易达云这个<b>同步返回 PDF 地址</b>。</p>
* *
* <p>真机实测的仓方校验:{@code productInfos} 为空报「产品信息不能为空」, * <p>真机实测的仓方校验:{@code productInfos} 为空报「产品信息不能为空」,
* 缺 {@code pageSize} 报「纸张尺寸不能为空」,{@code pageSize} 非 0~3 报 * 缺 {@code pageSize} 报「纸张尺寸不能为空」,{@code pageSize} 非 0~3 报
@ -985,21 +990,21 @@ public final class EdayunAdapter implements WarehouseAdapter, WarehouseProductCa
* 报「最多打印50个SKU」。本地已提前挡住后两者。</p> * 报「最多打印50个SKU」。本地已提前挡住后两者。</p>
*/ */
@Override @Override
public WarehouseLabel printBarcodes(WarehouseContext ctx, BarcodePrintCommand cmd) { public WarehouseLabel printCaseMarks(WarehouseContext ctx, CaseMarkPrintCommand cmd) {
EdayunBarcodeDtos.PrintBarcodeRequest body = EdayunBarcodeMapper.toRequest(cmd); EdayunCaseMarkDtos.PrintCaseMarkRequest body = EdayunCaseMarkMapper.toRequest(cmd);
String bodyJson = json.toJson(body); String bodyJson = json.toJson(body);
HttpResponse resp = send(ctx, EdayunConstants.PATH_BARCODE_PRINT, bodyJson, HttpResponse resp = send(ctx, EdayunConstants.PATH_CASE_MARK_PRINT, bodyJson,
"warehouse.barcode.print"); "warehouse.caseMark.print");
EdayunBarcodeDtos.PrintBarcodeResponse parsed = EdayunCaseMarkDtos.PrintCaseMarkResponse parsed =
json.fromJson(resp.body(), EdayunBarcodeDtos.PrintBarcodeResponse.class); json.fromJson(resp.body(), EdayunCaseMarkDtos.PrintCaseMarkResponse.class);
requireSuccess(ctx, parsed == null ? null : parsed.code, requireSuccess(ctx, parsed == null ? null : parsed.code,
parsed == null ? null : parsed.msg, resp, "warehouse.barcode.print"); parsed == null ? null : parsed.msg, resp, "warehouse.caseMark.print");
if (parsed.data == null || parsed.data.trim().isEmpty()) { if (parsed.data == null || parsed.data.trim().isEmpty()) {
throw WarehouseException.builder() throw WarehouseException.builder()
.message("edayun printBarcode returned no file url") .message("edayun printBarcode returned no file url")
.operation("warehouse.barcode.print") .operation("warehouse.caseMark.print")
.warehouseCode(ctx.warehouseCode()) .warehouseCode(ctx.warehouseCode())
.provider(provider().name()) .provider(provider().name())
.requestId(ctx.requestId()) .requestId(ctx.requestId())
@ -1007,57 +1012,57 @@ public final class EdayunAdapter implements WarehouseAdapter, WarehouseProductCa
.retryable(false) .retryable(false)
.build(); .build();
} }
return EdayunBarcodeMapper.toLabel(parsed.data.trim(), cmd); return EdayunCaseMarkMapper.toLabel(parsed.data.trim(), cmd);
} }
// ------------------------------------------------------------------ 箱唛 // ------------------------------------------------------------------ SKU 标
/** /**
* 打印箱唛({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。 * 打印 SKU 标({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。
* *
* <p>与入库箱标({@code inbound().printBoxLabel})不同:那个是运去哪风格的 * <p><b>端点名叫 newPrintCaseMark,但实际打的是 SKU 标</b>——已与仓方确认。
* 异步任务(只回任务号),易达云这个<b>同步返回 PDF 地址</b>。</p> * 箱唛走 {@code printCaseMarks}(端点 {@code printBarcode})。</p>
* *
* <p>统一模型的 {@code BoxLabelCommand} 没有「选哪些箱」的字段, * <p>统一模型的 {@code BoxLabelCommand} 没有「选哪些箱」的字段,
* 所以默认整单打印;要打部分箱用 {@link #printCaseMarks} 的重载。</p> * 所以默认整单打印;要打部分箱用重载。</p>
* *
* <p><b>真机未验证</b>:PR 环境该接口返回「接口不存在或未启用」, * <p><b>真机未验证</b>:PR 环境该接口返回「接口不存在或未启用」,
* 换到 {@code /newPrintCaseMark}(无 ContentType 后缀)能过参数校验 * 换到 {@code /newPrintCaseMark}(无 ContentType 后缀)能过参数校验
* (缺 pageSize 报「纸张不能为空」、缺 madeInChina 报「产地标签不能为空」), * (缺 pageSize 报「纸张不能为空」、缺 madeInChina 报「产地标签不能为空」),
* 但补全后一律「内部服务器错误」。见 docs-warehouse/edayun/TODO.md。</p> * 但补全后一律「内部服务器错误」。见 docs-warehouse/edayun/TODO.md。</p>
*/ */
public WarehouseLabel printCaseMarks(WarehouseContext ctx, BoxLabelCommand cmd) { public WarehouseLabel printSkuLabel(WarehouseContext ctx, BoxLabelCommand cmd) {
EdayunCaseMarkDtos.PrintCaseMarkRequest body = EdayunCaseMarkMapper.toRequest(cmd); EdayunSkuLabelDtos.PrintSkuLabelRequest body = EdayunSkuLabelMapper.toRequest(cmd);
return sendCaseMark(ctx, body); return sendSkuLabel(ctx, body);
} }
/** /**
* 打印箱唛(可选箱)。 * 打印 SKU 标(可选箱)。
* *
* @param selection 选箱条件;四选一,全空时本地拒绝 * @param selection 选箱条件;四选一,全空时本地拒绝
*/ */
public WarehouseLabel printCaseMarks(WarehouseContext ctx, BoxLabelCommand cmd, public WarehouseLabel printSkuLabel(WarehouseContext ctx, BoxLabelCommand cmd,
EdayunCaseMarkMapper.CaseSelection selection) { EdayunSkuLabelMapper.CaseSelection selection) {
EdayunCaseMarkDtos.PrintCaseMarkRequest body = EdayunSkuLabelDtos.PrintSkuLabelRequest body =
EdayunCaseMarkMapper.toRequest(cmd, selection); EdayunSkuLabelMapper.toRequest(cmd, selection);
return sendCaseMark(ctx, body); return sendSkuLabel(ctx, body);
} }
private WarehouseLabel sendCaseMark(WarehouseContext ctx, private WarehouseLabel sendSkuLabel(WarehouseContext ctx,
EdayunCaseMarkDtos.PrintCaseMarkRequest body) { EdayunSkuLabelDtos.PrintSkuLabelRequest body) {
String bodyJson = json.toJson(body); String bodyJson = json.toJson(body);
HttpResponse resp = send(ctx, EdayunConstants.PATH_CASE_MARK_PRINT, bodyJson, HttpResponse resp = send(ctx, EdayunConstants.PATH_SKU_LABEL_PRINT, bodyJson,
"warehouse.caseMark.print"); "warehouse.skuLabel.print");
EdayunCaseMarkDtos.PrintCaseMarkResponse parsed = EdayunSkuLabelDtos.PrintSkuLabelResponse parsed =
json.fromJson(resp.body(), EdayunCaseMarkDtos.PrintCaseMarkResponse.class); json.fromJson(resp.body(), EdayunSkuLabelDtos.PrintSkuLabelResponse.class);
requireSuccess(ctx, parsed == null ? null : parsed.code, requireSuccess(ctx, parsed == null ? null : parsed.code,
parsed == null ? null : parsed.msg, resp, "warehouse.caseMark.print"); parsed == null ? null : parsed.msg, resp, "warehouse.skuLabel.print");
if (parsed.data == null || parsed.data.trim().isEmpty()) { if (parsed.data == null || parsed.data.trim().isEmpty()) {
throw WarehouseException.builder() throw WarehouseException.builder()
.message("edayun printCaseMark returned no file url") .message("edayun newPrintCaseMark returned no file url")
.operation("warehouse.caseMark.print") .operation("warehouse.skuLabel.print")
.warehouseCode(ctx.warehouseCode()) .warehouseCode(ctx.warehouseCode())
.provider(provider().name()) .provider(provider().name())
.requestId(ctx.requestId()) .requestId(ctx.requestId())
@ -1065,7 +1070,7 @@ public final class EdayunAdapter implements WarehouseAdapter, WarehouseProductCa
.retryable(false) .retryable(false)
.build(); .build();
} }
return EdayunCaseMarkMapper.toLabel(parsed.data.trim()); return EdayunSkuLabelMapper.toLabel(parsed.data.trim());
} }
// ------------------------------------------------------------------ internals // ------------------------------------------------------------------ internals

70
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunBarcodeMapper.java

@ -1,70 +0,0 @@
package common.ecommerce.edayun.adapter;
import common.ecommerce.edayun.dto.EdayunBarcodeDtos;
import common.ecommerce.warehouse.model.BarcodePrintCommand;
import common.ecommerce.warehouse.model.WarehouseLabel;
import java.util.ArrayList;
import java.util.List;
/**
* 易达云条码打印映射({@code POST /webApi/skuInfo/v2/printBarcode})。
*
* <p>响应 {@code data} 是文件地址字符串——同步生成,不像入库箱标那样只有任务号。</p>
*/
public final class EdayunBarcodeMapper {
/** 单次最多打印的 SKU 数(文档:最大 50 个)。 */
static final int MAX_SKUS = 50;
private EdayunBarcodeMapper() {
}
/**
* 统一命令 → 打印请求。
*
* @throws IllegalArgumentException SKU 数超限(本地先挡,省一次失败请求)
*/
public static EdayunBarcodeDtos.PrintBarcodeRequest toRequest(BarcodePrintCommand cmd) {
EdayunBarcodeDtos.PrintBarcodeRequest req = new EdayunBarcodeDtos.PrintBarcodeRequest();
req.pageSize = cmd.paperSize().code();
req.remark = cmd.remark();
// 只有 true 才下发:false 是仓方默认,不下发省得干扰它自己的默认值
req.isPrintSkuName = cmd.printSkuName() ? Boolean.TRUE : null;
req.productInfos = toItems(cmd.items());
return req;
}
private static List<EdayunBarcodeDtos.ProductInfo> toItems(
List<BarcodePrintCommand.BarcodeItem> items) {
if (items.size() > MAX_SKUS) {
throw new IllegalArgumentException(
"edayun prints at most " + MAX_SKUS + " skus at once, got " + items.size()
+ "; split into multiple calls");
}
List<EdayunBarcodeDtos.ProductInfo> out =
new ArrayList<EdayunBarcodeDtos.ProductInfo>(items.size());
for (BarcodePrintCommand.BarcodeItem item : items) {
EdayunBarcodeDtos.ProductInfo info = new EdayunBarcodeDtos.ProductInfo();
info.skuCode = item.providerSku();
info.num = item.copies();
out.add(info);
}
return out;
}
/**
* 响应 → 面单对象。
*
* <p>文件地址可能为空——仓方生成失败时仍可能回 {@code code=200}。调用方应在
* 调用前确认 {@code data} 非空,适配器已做该检查。</p>
*/
public static WarehouseLabel toLabel(String fileUrl, BarcodePrintCommand cmd) {
return WarehouseLabel.builder()
// 仓库不返回文件 id,用 SKU 数 + 纸张尺寸拼一个可追溯的编号
.labelId("barcode-" + cmd.paperSize().name() + "-" + cmd.items().size())
.format("PDF")
.url(fileUrl)
.build();
}
}

134
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunCaseMarkMapper.java

@ -1,127 +1,71 @@
package common.ecommerce.edayun.adapter; package common.ecommerce.edayun.adapter;
import common.ecommerce.edayun.dto.EdayunCaseMarkDtos; import common.ecommerce.edayun.dto.EdayunCaseMarkDtos;
import common.ecommerce.edayun.enums.EdayunCaseMarkPaper; import common.ecommerce.warehouse.model.CaseMarkPrintCommand;
import common.ecommerce.warehouse.model.BoxLabelCommand;
import common.ecommerce.warehouse.model.WarehouseLabel; import common.ecommerce.warehouse.model.WarehouseLabel;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* 易达云箱唛映射({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。 * 易达云箱唛映射({@code POST /webApi/skuInfo/v2/printBarcode})。
* *
* <p><b>统一模型只能表达「整单打印」</b>:{@code BoxLabelCommand} 没有「选哪些箱」 * <p>端点名叫 printBarcode,但实际打的是<b>箱唛</b>(外箱标)——已与仓方确认。
* 的字段,所以选箱条件(系统箱号列表 / SKU / 箱序号区间 / 客户箱号区间) * 响应 {@code data} 是 PDF 地址字符串,同步生成。</p>
* 一律不下发——仓方默认整单。要打部分箱请走 {@code printCaseMarks} 的扩展重载。</p>
*
* <p>响应 {@code data} 是 PDF 地址,同步生成;而统一模型的
* {@code LabelPrintTask} 是异步任务语义(只有任务号)。所以这里返回
* {@link WarehouseLabel},把地址放在 {@code url()}。</p>
*/ */
public final class EdayunCaseMarkMapper { public final class EdayunCaseMarkMapper {
/** 是否需要 Made in China:是。 */ /** 单次最多打印的 SKU 数(文档:最大 50 个)。 */
static final int MADE_IN_CHINA_YES = 1; static final int MAX_SKUS = 50;
/** 是否需要 Made in China:否。 */
static final int MADE_IN_CHINA_NO = 0;
private EdayunCaseMarkMapper() { private EdayunCaseMarkMapper() {
} }
/** /**
* 统一命令 → 箱唛请求(整单打印)。 * 统一命令 → 打印请求。
* *
* @throws IllegalArgumentException 尺寸不在易达云支持的三档内 * @throws IllegalArgumentException SKU 数超限(本地先挡,省一次失败请求)
*/ */
public static EdayunCaseMarkDtos.PrintCaseMarkRequest toRequest(BoxLabelCommand cmd) { public static EdayunCaseMarkDtos.PrintCaseMarkRequest toRequest(CaseMarkPrintCommand cmd) {
EdayunCaseMarkDtos.PrintCaseMarkRequest req = EdayunCaseMarkDtos.PrintCaseMarkRequest req = new EdayunCaseMarkDtos.PrintCaseMarkRequest();
new EdayunCaseMarkDtos.PrintCaseMarkRequest(); req.pageSize = cmd.paperSize().code();
// 统一模型里 providerInboundNo 就是仓侧 REV 单号 req.remark = cmd.remark();
req.entryCode = cmd.providerInboundNo(); // 只有 true 才下发:false 是仓方默认,不下发省得干扰它自己的默认值
req.isPrintSkuName = cmd.printSkuName() ? Boolean.TRUE : null;
EdayunCaseMarkPaper paper = EdayunCaseMarkPaper.of(cmd.sizeType()); req.productInfos = toItems(cmd.items());
req.pageSize = paper.code();
// 统一模型没有「原产地标注」,默认不打 Made in China——猜「打」会让每箱多一行
req.madeInChina = MADE_IN_CHINA_NO;
// 分隔符是易达云特有的分页提示,统一模型没有对应语义,默认关
req.separation = Boolean.FALSE;
req.twoPrint = cmd.twoCopies() ? 1 : 0;
return req; return req;
} }
/** private static List<EdayunCaseMarkDtos.ProductInfo> toItems(
* 带选箱条件的请求(易达云专有能力)。 List<CaseMarkPrintCommand.CaseMarkItem> items) {
* if (items.size() > MAX_SKUS) {
* <p>选箱条件四选一,全部为空时仓方会报错,这里本地先拒。</p>
*/
public static EdayunCaseMarkDtos.PrintCaseMarkRequest toRequest(BoxLabelCommand cmd,
CaseSelection selection) {
EdayunCaseMarkDtos.PrintCaseMarkRequest req = toRequest(cmd);
if (selection == null || selection.isEmpty()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"edayun case mark needs at least one box selector" "edayun prints at most " + MAX_SKUS + " skus at once, got " + items.size()
+ " (case codes / sku / serial range / seller case range)"); + "; split into multiple calls");
} }
req.caseCodeList = selection.caseCodes; List<EdayunCaseMarkDtos.ProductInfo> out =
req.skuCode = selection.skuCode; new ArrayList<EdayunCaseMarkDtos.ProductInfo>(items.size());
req.startCaseSerialNo = selection.startCaseSerialNo; for (CaseMarkPrintCommand.CaseMarkItem item : items) {
req.endCaseSerialNo = selection.endCaseSerialNo; EdayunCaseMarkDtos.ProductInfo info = new EdayunCaseMarkDtos.ProductInfo();
req.startSellerCaseNo = selection.startSellerCaseNo; info.skuCode = item.providerSku();
req.endSellerCaseNo = selection.endSellerCaseNo; info.num = item.copies();
return req; out.add(info);
}
return out;
} }
/** 响应 → 面单对象;地址为空视为失败。 */ /**
public static WarehouseLabel toLabel(String fileUrl) { * 响应 → 面单对象。
*
* <p>文件地址可能为空——仓方生成失败时仍可能回 {@code code=200}。调用方应在
* 调用前确认 {@code data} 非空,适配器已做该检查。</p>
*/
public static WarehouseLabel toLabel(String fileUrl, CaseMarkPrintCommand cmd) {
return WarehouseLabel.builder() return WarehouseLabel.builder()
// 仓方不回文件 id // 仓库不返回文件 id,用 SKU 数 + 纸张尺寸拼一个可追溯的编号
.labelId("case-mark") .labelId("barcode-" + cmd.paperSize().name() + "-" + cmd.items().size())
.format("PDF") .format("PDF")
.url(fileUrl) .url(fileUrl)
.build(); .build();
} }
/** 选箱条件:四个维度都是「有就用」。 */
public static final class CaseSelection {
private List<String> caseCodes;
private String skuCode;
private String startCaseSerialNo;
private String endCaseSerialNo;
private String startSellerCaseNo;
private String endSellerCaseNo;
public CaseSelection caseCodes(List<String> v) {
this.caseCodes = v;
return this;
}
public CaseSelection skuCode(String v) {
this.skuCode = v;
return this;
}
public CaseSelection caseSerialRange(String start, String end) {
this.startCaseSerialNo = start;
this.endCaseSerialNo = end;
return this;
}
public CaseSelection sellerCaseRange(String start, String end) {
this.startSellerCaseNo = start;
this.endSellerCaseNo = end;
return this;
}
boolean isEmpty() {
return (caseCodes == null || caseCodes.isEmpty())
&& isBlank(skuCode)
&& isBlank(startCaseSerialNo) && isBlank(endCaseSerialNo)
&& isBlank(startSellerCaseNo) && isBlank(endSellerCaseNo);
}
private static boolean isBlank(String v) {
return v == null || v.trim().isEmpty();
}
}
} }

127
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/adapter/EdayunSkuLabelMapper.java

@ -0,0 +1,127 @@
package common.ecommerce.edayun.adapter;
import common.ecommerce.edayun.dto.EdayunSkuLabelDtos;
import common.ecommerce.edayun.enums.EdayunSkuLabelPaper;
import common.ecommerce.warehouse.model.BoxLabelCommand;
import common.ecommerce.warehouse.model.WarehouseLabel;
import java.util.List;
/**
* 易达云 SKU 标映射({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。
*
* <p><b>统一模型只能表达「整单打印」</b>:{@code BoxLabelCommand} 没有「选哪些箱」
* 的字段,所以选箱条件(系统箱号列表 / SKU / 箱序号区间 / 客户箱号区间)
* 一律不下发——仓方默认整单。要打部分箱请走 {@code printSkuLabel} 的扩展重载。</p>
*
* <p>响应 {@code data} 是 PDF 地址,同步生成;而统一模型的
* {@code LabelPrintTask} 是异步任务语义(只有任务号)。所以这里返回
* {@link WarehouseLabel},把地址放在 {@code url()}。</p>
*/
public final class EdayunSkuLabelMapper {
/** 是否需要 Made in China:是。 */
static final int MADE_IN_CHINA_YES = 1;
/** 是否需要 Made in China:否。 */
static final int MADE_IN_CHINA_NO = 0;
private EdayunSkuLabelMapper() {
}
/**
* 统一命令 → SKU 标请求(整单打印)。
*
* @throws IllegalArgumentException 尺寸不在易达云支持的三档内
*/
public static EdayunSkuLabelDtos.PrintSkuLabelRequest toRequest(BoxLabelCommand cmd) {
EdayunSkuLabelDtos.PrintSkuLabelRequest req =
new EdayunSkuLabelDtos.PrintSkuLabelRequest();
// 统一模型里 providerInboundNo 就是仓侧 REV 单号
req.entryCode = cmd.providerInboundNo();
EdayunSkuLabelPaper paper = EdayunSkuLabelPaper.of(cmd.sizeType());
req.pageSize = paper.code();
// 统一模型没有「原产地标注」,默认不打 Made in China——猜「打」会让每箱多一行
req.madeInChina = MADE_IN_CHINA_NO;
// 分隔符是易达云特有的分页提示,统一模型没有对应语义,默认关
req.separation = Boolean.FALSE;
req.twoPrint = cmd.twoCopies() ? 1 : 0;
return req;
}
/**
* 带选箱条件的请求(易达云专有能力)。
*
* <p>选箱条件四选一,全部为空时仓方会报错,这里本地先拒。</p>
*/
public static EdayunSkuLabelDtos.PrintSkuLabelRequest toRequest(BoxLabelCommand cmd,
CaseSelection selection) {
EdayunSkuLabelDtos.PrintSkuLabelRequest req = toRequest(cmd);
if (selection == null || selection.isEmpty()) {
throw new IllegalArgumentException(
"edayun sku label needs at least one box selector"
+ " (case codes / sku / serial range / seller case range)");
}
req.caseCodeList = selection.caseCodes;
req.skuCode = selection.skuCode;
req.startCaseSerialNo = selection.startCaseSerialNo;
req.endCaseSerialNo = selection.endCaseSerialNo;
req.startSellerCaseNo = selection.startSellerCaseNo;
req.endSellerCaseNo = selection.endSellerCaseNo;
return req;
}
/** 响应 → 面单对象;地址为空视为失败。 */
public static WarehouseLabel toLabel(String fileUrl) {
return WarehouseLabel.builder()
// 仓方不回文件 id
.labelId("case-mark")
.format("PDF")
.url(fileUrl)
.build();
}
/** 选箱条件:四个维度都是「有就用」。 */
public static final class CaseSelection {
private List<String> caseCodes;
private String skuCode;
private String startCaseSerialNo;
private String endCaseSerialNo;
private String startSellerCaseNo;
private String endSellerCaseNo;
public CaseSelection caseCodes(List<String> v) {
this.caseCodes = v;
return this;
}
public CaseSelection skuCode(String v) {
this.skuCode = v;
return this;
}
public CaseSelection caseSerialRange(String start, String end) {
this.startCaseSerialNo = start;
this.endCaseSerialNo = end;
return this;
}
public CaseSelection sellerCaseRange(String start, String end) {
this.startSellerCaseNo = start;
this.endSellerCaseNo = end;
return this;
}
boolean isEmpty() {
return (caseCodes == null || caseCodes.isEmpty())
&& isBlank(skuCode)
&& isBlank(startCaseSerialNo) && isBlank(endCaseSerialNo)
&& isBlank(startSellerCaseNo) && isBlank(endSellerCaseNo);
}
private static boolean isBlank(String v) {
return v == null || v.trim().isEmpty();
}
}
}

52
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/dto/EdayunBarcodeDtos.java

@ -1,52 +0,0 @@
package common.ecommerce.edayun.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
/**
* 易达云报文结构:打印条码({@code POST /webApi/skuInfo/v2/printBarcode})。
*
* <p>一个文件对应一个接口。响应 {@code data} 是<b>文件地址字符串</b>,
* 不是对象——与入库箱标那种「异步任务号」不同,这里同步给文件。</p>
*/
public final class EdayunBarcodeDtos {
private EdayunBarcodeDtos() {
}
/** 打印请求。 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PrintBarcodeRequest {
/** 备注,如 {@code Made in China};≤64。 */
public String remark;
/** 是否打印 SKU 名称。 */
public Boolean isPrintSkuName;
/** 纸张尺寸:0 7×3cm / 1 10×6cm / 2 6×4cm / 3 A4。<b>必填</b>。 */
public Integer pageSize;
/** 产品信息,最大 50 个 SKU。<b>必填</b>。 */
public List<ProductInfo> productInfos;
}
/** 一个 SKU。 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class ProductInfo {
public String skuCode;
/** 打印份数;必须 > 0。 */
public Integer num;
}
/** 打印响应。 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PrintBarcodeResponse {
public Integer code;
public String msg;
/** 条码文件地址(PDF)。 */
public String data;
/** 文档标为 object,实际是字符串 {@code "null"};保留 Object 避免解析失败。 */
public Object traceId;
}
}

56
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/dto/EdayunCaseMarkDtos.java

@ -5,20 +5,13 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List; import java.util.List;
/** /**
* 易达云报文结构:打印箱唛 * 易达云报文结构:打印箱唛({@code POST /webApi/skuInfo/v2/printBarcode})。
* ({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。
* *
* <p>一个文件对应一个接口。响应 {@code data} 是<b>箱唛 PDF 地址字符串</b>, * <p>一个文件对应一个接口。响应 {@code data} 是<b>箱唛 PDF 地址字符串</b>,
* 同步生成,不是任务号。</p> * 同步生成,不是任务号。</p>
* *
* <p><b>选箱条件四选一</b>(文档原文:箱序号 / 客户箱号 / sku 编码 / 系统箱号 * <p><b>接口名与语义不一致</b>:端点叫 {@code printBarcode},但实际打的是
* 必须有一个不为空):</p> * 箱唛(外箱标)。已与仓方确认,不要被路径名误导。</p>
* <ul>
* <li>系统箱号:{@code caseCodeList}</li>
* <li>SKU:{@code skuCode}</li>
* <li>箱序号区间:{@code startCaseSerialNo} ~ {@code endCaseSerialNo}</li>
* <li>客户箱号区间:{@code startSellerCaseNo} ~ {@code endSellerCaseNo}</li>
* </ul>
*/ */
public final class EdayunCaseMarkDtos { public final class EdayunCaseMarkDtos {
@ -29,30 +22,24 @@ public final class EdayunCaseMarkDtos {
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PrintCaseMarkRequest { public static final class PrintCaseMarkRequest {
/** EDA 入库单号(REV 单号)。必填。 */ /** 备注,如 {@code Made in China};≤64。 */
public String entryCode; public String remark;
/** 是否打印 SKU 名称。 */
public Boolean isPrintSkuName;
/** 系统箱号列表(如 {@code B00231164777837})。 */ /** 纸张尺寸:0 7×3cm / 1 10×6cm / 2 6×4cm / 3 A4。<b>必填</b>。 */
public List<String> caseCodeList;
/** SKU 编码。 */
public String skuCode;
/** 箱序号开始。 */
public String startCaseSerialNo;
/** 箱序号结束。 */
public String endCaseSerialNo;
/** 开始打印的客户箱号。 */
public String startSellerCaseNo;
/** 结束打印的客户箱号。 */
public String endSellerCaseNo;
/** 纸张尺寸:2 100×150 / 4 100×100 / 5 A4。<b>必填</b>。 */
public Integer pageSize; public Integer pageSize;
/** 是否需要 Made in China:0 否 / 1 是。<b>必填</b>。 */
public Integer madeInChina; /** 产品信息,最大 50 个 SKU。<b>必填</b>。 */
/** 是否打印分隔符(第一页与下一页不一致时插提示页)。<b>必填</b>。 */ public List<ProductInfo> productInfos;
public Boolean separation; }
/** 每箱打印两份:0 否 / 1 是。 */
public Integer twoPrint; /** 一个 SKU。 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class ProductInfo {
public String skuCode;
/** 打印份数;必须 > 0。 */
public Integer num;
} }
/** 打印响应。 */ /** 打印响应。 */
@ -60,8 +47,9 @@ public final class EdayunCaseMarkDtos {
public static final class PrintCaseMarkResponse { public static final class PrintCaseMarkResponse {
public Integer code; public Integer code;
public String msg; public String msg;
/** 箱唛 PDF 地址。 */ /** 条码文件地址(PDF)。 */
public String data; public String data;
public String traceId; /** 文档标为 object,实际是字符串 {@code "null"};保留 Object 避免解析失败。 */
public Object traceId;
} }
} }

69
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/dto/EdayunSkuLabelDtos.java

@ -0,0 +1,69 @@
package common.ecommerce.edayun.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
/**
* 易达云报文结构:打印 SKU 标
* ({@code POST /webApi/entryInfo/v1/newPrintCaseMarkContentType})。
*
* <p>一个文件对应一个接口。响应 {@code data} 是<b>PDF 地址字符串</b>,同步生成。</p>
*
* <p><b>接口名与语义不一致</b>:端点叫 {@code newPrintCaseMark}(箱唛),
* 但实际打的是 SKU 标。已与仓方确认,不要被路径名误导。</p>
*
* <p><b>选箱条件四选一</b>(文档原文:箱序号 / 客户箱号 / sku 编码 / 系统箱号
* 必须有一个不为空):</p>
* <ul>
* <li>系统箱号:{@code caseCodeList}</li>
* <li>SKU:{@code skuCode}</li>
* <li>箱序号区间:{@code startCaseSerialNo} ~ {@code endCaseSerialNo}</li>
* <li>客户箱号区间:{@code startSellerCaseNo} ~ {@code endSellerCaseNo}</li>
* </ul>
*/
public final class EdayunSkuLabelDtos {
private EdayunSkuLabelDtos() {
}
/** 打印 SKU 标请求。 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PrintSkuLabelRequest {
/** EDA 入库单号(REV 单号)。必填。 */
public String entryCode;
/** 系统箱号列表(如 {@code B00231164777837})。 */
public List<String> caseCodeList;
/** SKU 编码。 */
public String skuCode;
/** 箱序号开始。 */
public String startCaseSerialNo;
/** 箱序号结束。 */
public String endCaseSerialNo;
/** 开始打印的客户箱号。 */
public String startSellerCaseNo;
/** 结束打印的客户箱号。 */
public String endSellerCaseNo;
/** 纸张尺寸:2 100×150 / 4 100×100 / 5 A4。<b>必填</b>。 */
public Integer pageSize;
/** 是否需要 Made in China:0 否 / 1 是。<b>必填</b>。 */
public Integer madeInChina;
/** 是否打印分隔符(第一页与下一页不一致时插提示页)。<b>必填</b>。 */
public Boolean separation;
/** 每箱打印两份:0 否 / 1 是。 */
public Integer twoPrint;
}
/** 打印响应。 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class PrintSkuLabelResponse {
public Integer code;
public String msg;
/** 箱唛 PDF 地址。 */
public String data;
public String traceId;
}
}

10
warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/enums/EdayunCaseMarkPaper.java → warehouse-sdk-edayun/src/main/java/common/ecommerce/edayun/enums/EdayunSkuLabelPaper.java

@ -3,7 +3,7 @@ package common.ecommerce.edayun.enums;
import common.ecommerce.warehouse.enums.LabelSizeType; import common.ecommerce.warehouse.enums.LabelSizeType;
/** /**
* 易达云箱唛纸张尺寸({@code newPrintCaseMark} 的 {@code pageSize})。 * 易达云 SKU 标纸张尺寸({@code newPrintCaseMark} 的 {@code pageSize})。
* *
* <p>只有三档,且码值与统一枚举 {@link LabelSizeType} 完全不同:</p> * <p>只有三档,且码值与统一枚举 {@link LabelSizeType} 完全不同:</p>
* <table> * <table>
@ -15,7 +15,7 @@ import common.ecommerce.warehouse.enums.LabelSizeType;
* *
* <p>注意码值不连续(4 / 2 / 5),不要按顺序推。</p> * <p>注意码值不连续(4 / 2 / 5),不要按顺序推。</p>
*/ */
public enum EdayunCaseMarkPaper { public enum EdayunSkuLabelPaper {
/** 4:100×100mm。 */ /** 4:100×100mm。 */
SIZE_100_100(4, "100×100", LabelSizeType.SIZE_100_100), SIZE_100_100(4, "100×100", LabelSizeType.SIZE_100_100),
@ -28,7 +28,7 @@ public enum EdayunCaseMarkPaper {
private final String label; private final String label;
private final LabelSizeType core; private final LabelSizeType core;
EdayunCaseMarkPaper(int code, String label, LabelSizeType core) { EdayunSkuLabelPaper(int code, String label, LabelSizeType core) {
this.code = code; this.code = code;
this.label = label; this.label = label;
this.core = core; this.core = core;
@ -48,8 +48,8 @@ public enum EdayunCaseMarkPaper {
} }
/** 统一尺寸 → 易达云码值;不支持的尺寸显式拒绝。 */ /** 统一尺寸 → 易达云码值;不支持的尺寸显式拒绝。 */
public static EdayunCaseMarkPaper of(LabelSizeType size) { public static EdayunSkuLabelPaper of(LabelSizeType size) {
for (EdayunCaseMarkPaper v : values()) { for (EdayunSkuLabelPaper v : values()) {
if (v.core == size) { if (v.core == size) {
return v; return v;
} }

166
warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/adapter/EdayunBarcodeTest.java

@ -1,166 +0,0 @@
package common.ecommerce.edayun.adapter;
import common.ecommerce.edayun.dto.EdayunBarcodeDtos;
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.BarcodePaperSize;
import common.ecommerce.warehouse.enums.WarehouseProvider;
import common.ecommerce.warehouse.model.BarcodePrintCommand;
import common.ecommerce.warehouse.model.WarehouseLabel;
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 static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* 打印条码({@code /webApi/skuInfo/v2/printBarcode})映射。
*
* <p>重点:响应 data 是文件地址、同步返回(不是任务号)、50 个 SKU 上限。</p>
*/
class EdayunBarcodeTest {
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-barcode", CLOCK);
}
private static RecordingTransport stub(String body) {
return RecordingTransport.create()
.route(common.ecommerce.edayun.EdayunConstants.PATH_TOKEN, req -> Responses.ok(
"{\"access_token\":\"T1\",\"token_type\":\"bearer\"}"))
.route(common.ecommerce.edayun.EdayunConstants.PATH_BARCODE_PRINT,
req -> Responses.ok(body));
}
private static BarcodePrintCommand command() {
return BarcodePrintCommand.builder()
.paperSize(BarcodePaperSize.SIZE_70_30)
.remark("Made in China")
.printSkuName(false)
.item("ybtest", 2)
.build();
}
// ------------------------------------------------------------ 请求
@Test
void mapsRequest() {
EdayunBarcodeDtos.PrintBarcodeRequest req = EdayunBarcodeMapper.toRequest(command());
assertEquals(Integer.valueOf(0), req.pageSize);
assertEquals("Made in China", req.remark);
assertEquals(1, req.productInfos.size());
assertEquals("ybtest", req.productInfos.get(0).skuCode);
assertEquals(Integer.valueOf(2), req.productInfos.get(0).num);
}
/** isPrintSkuName 只在 true 时下发,false 交给仓方默认。 */
@Test
void printSkuNameOnlySentWhenTrue() {
assertNull(EdayunBarcodeMapper.toRequest(command()).isPrintSkuName);
BarcodePrintCommand withName = BarcodePrintCommand.builder()
.paperSize(BarcodePaperSize.A4)
.printSkuName(true)
.item("sku", 1)
.build();
assertEquals(Boolean.TRUE, EdayunBarcodeMapper.toRequest(withName).isPrintSkuName);
}
@Test
void paperSizesMap() {
assertEquals(0, BarcodePaperSize.SIZE_70_30.code());
assertEquals(1, BarcodePaperSize.SIZE_100_60.code());
assertEquals(2, BarcodePaperSize.SIZE_60_40.code());
assertEquals(3, BarcodePaperSize.A4.code());
}
/** 超过 50 个 SKU 本地就挡,不发请求(仓方也会报「最多打印50个SKU」)。 */
@Test
void moreThan50SkusRejectedLocally() {
BarcodePrintCommand.Builder b = BarcodePrintCommand.builder()
.paperSize(BarcodePaperSize.A4);
for (int i = 0; i < 51; i++) {
b.item("SKU-" + i, 1);
}
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
() -> EdayunBarcodeMapper.toRequest(b.build()));
assertTrue(ex.getMessage().contains("at most 50"), ex.getMessage());
}
/** 空 SKU 列表与非法份数在命令构造期就被拒。 */
@Test
void invalidCommandRejectedAtConstruction() {
assertThrows(IllegalArgumentException.class,
() -> BarcodePrintCommand.builder().paperSize(BarcodePaperSize.A4).build());
assertThrows(IllegalArgumentException.class,
() -> BarcodePrintCommand.builder().paperSize(BarcodePaperSize.A4)
.item("sku", 0));
assertThrows(IllegalArgumentException.class,
() -> BarcodePrintCommand.builder().paperSize(BarcodePaperSize.A4)
.item(" ", 1));
// 缺纸张尺寸
assertThrows(IllegalArgumentException.class,
() -> BarcodePrintCommand.builder().item("sku", 1).build());
}
// ------------------------------------------------------------ 响应
/** data 是文件地址字符串,直接落 WarehouseLabel.url。 */
@Test
void responseDataIsFileUrl() {
RecordingTransport transport = stub("{\"code\":200,\"msg\":\"操作成功\","
+ "\"data\":\"https://oss.edayun.com/barcode1.pdf\",\"traceId\":null}");
WarehouseLabel label = new EdayunAdapter(transport, new JacksonJsonCodec())
.printBarcodes(ctx(), command());
assertEquals("https://oss.edayun.com/barcode1.pdf", label.url());
assertEquals("PDF", label.format());
assertNull(label.contentBase64());
assertTrue(transport.lastDataRequest().body().contains("\"skuCode\":\"ybtest\""));
}
/** code=200 但 data 为空 → 抛异常,不能返回没有文件的对象。 */
@Test
void blankDataFails() {
RecordingTransport transport = stub(
"{\"code\":200,\"msg\":\"操作成功\",\"data\":\" \"}");
assertThrows(RuntimeException.class,
() -> new EdayunAdapter(transport, new JacksonJsonCodec())
.printBarcodes(ctx(), command()));
}
/** 仓方业务错误(如 SKU 不存在)要抛异常并带出原因。 */
@Test
void businessErrorFails() {
RecordingTransport transport = stub(
"{\"code\":500,\"msg\":\"sku=NO-SUCH信息不存在\",\"data\":null}");
try {
new EdayunAdapter(transport, new JacksonJsonCodec())
.printBarcodes(ctx(), command());
org.junit.jupiter.api.Assertions.fail("should have thrown");
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("SKU") || e.getMessage().contains("sku"), e.getMessage());
}
}
}

218
warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/adapter/EdayunCaseMarkTest.java

@ -1,158 +1,166 @@
package common.ecommerce.edayun.adapter; package common.ecommerce.edayun.adapter;
import common.ecommerce.edayun.dto.EdayunCaseMarkDtos; import common.ecommerce.edayun.dto.EdayunCaseMarkDtos;
import common.ecommerce.edayun.enums.EdayunCaseMarkPaper; import common.ecommerce.http.JacksonJsonCodec;
import common.ecommerce.warehouse.enums.LabelDownloadMode; import common.ecommerce.shared.spi.ChannelSecret;
import common.ecommerce.warehouse.enums.LabelSizeType; import common.ecommerce.shared.testkit.RecordingTransport;
import common.ecommerce.warehouse.enums.LabelsPerPage; import common.ecommerce.shared.testkit.Responses;
import common.ecommerce.warehouse.model.BoxLabelCommand; import common.ecommerce.warehouse.enums.CaseMarkPaperSize;
import common.ecommerce.warehouse.enums.WarehouseProvider;
import common.ecommerce.warehouse.model.CaseMarkPrintCommand;
import common.ecommerce.warehouse.model.WarehouseLabel; import common.ecommerce.warehouse.model.WarehouseLabel;
import common.ecommerce.warehouse.sdk.WarehouseConnection;
import common.ecommerce.warehouse.sdk.WarehouseContext;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.time.Clock;
import java.time.Instant;
import java.time.ZoneOffset;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* 箱唛打印({@code newPrintCaseMarkContentType})映射。 * 箱唛打印({@code /webApi/skuInfo/v2/printBarcode})映射。
* *
* <p>重点:码值不连续(4/2/5)、统一模型只能表达整单打印、 * <p>重点:响应 data 是文件地址、同步返回(不是任务号)、50 个 SKU 上限。</p>
* Made in China 与分隔符默认关。</p>
*/ */
class EdayunCaseMarkTest { class EdayunCaseMarkTest {
private static BoxLabelCommand command(LabelSizeType size) { private static final Clock CLOCK = Clock.fixed(Instant.parse("2026-11-16T00:00:00Z"), ZoneOffset.UTC);
return BoxLabelCommand.builder()
.providerInboundNo("REV0023116477")
.inboundRequestNo("IB-001")
.sizeType(size)
.labelsPerPage(LabelsPerPage.ONE)
.downloadMode(LabelDownloadMode.PDF)
.twoCopies(true)
.build();
}
// ------------------------------------------------------------ 纸张映射
/** 易达云码值不连续:100×100=4、100×150=2、A4=5。 */ private static WarehouseContext ctx() {
@Test return WarehouseContext.of("EDY-WH", WarehouseProvider.EDAYUN, "2",
void paperCodesAreNotSequential() { WarehouseConnection.of("https://test.example/openapi",
assertEquals(4, EdayunCaseMarkPaper.SIZE_100_100.code()); ChannelSecret.builder().appKey("k").appSecret("s")
assertEquals(2, EdayunCaseMarkPaper.SIZE_100_150.code()); .clientId("c").clientSecret("cs").build()),
assertEquals(5, EdayunCaseMarkPaper.A4.code()); "req-barcode", CLOCK);
} }
@Test private static RecordingTransport stub(String body) {
void mapsCoreSizes() { return RecordingTransport.create()
assertEquals(EdayunCaseMarkPaper.SIZE_100_100, .route(common.ecommerce.edayun.EdayunConstants.PATH_TOKEN, req -> Responses.ok(
EdayunCaseMarkPaper.of(LabelSizeType.SIZE_100_100)); "{\"access_token\":\"T1\",\"token_type\":\"bearer\"}"))
assertEquals(EdayunCaseMarkPaper.SIZE_100_150, .route(common.ecommerce.edayun.EdayunConstants.PATH_CASE_MARK_PRINT,
EdayunCaseMarkPaper.of(LabelSizeType.SIZE_100_150)); req -> Responses.ok(body));
assertEquals(LabelSizeType.SIZE_100_100,
EdayunCaseMarkPaper.SIZE_100_100.core());
assertEquals(LabelSizeType.A4, EdayunCaseMarkPaper.A4.core());
} }
/** 统一模型的 104×98(美国信纸)易达云不支持,要显式拒绝。 */ private static CaseMarkPrintCommand command() {
@Test return CaseMarkPrintCommand.builder()
void unsupportedSizeIsRejected() { .paperSize(CaseMarkPaperSize.SIZE_70_30)
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, .remark("Made in China")
() -> EdayunCaseMarkPaper.of(LabelSizeType.SIZE_104_98)); .printSkuName(false)
assertTrue(ex.getMessage().contains("only 100x100 / 100x150 / A4"), ex.getMessage()); .item("ybtest", 2)
.build();
} }
// ------------------------------------------------------------ 请求 // ------------------------------------------------------------ 请求
@Test @Test
void mapsWholeOrderPrint() { void mapsRequest() {
EdayunCaseMarkDtos.PrintCaseMarkRequest req = EdayunCaseMarkDtos.PrintCaseMarkRequest req = EdayunCaseMarkMapper.toRequest(command());
EdayunCaseMarkMapper.toRequest(command(LabelSizeType.SIZE_100_100));
assertEquals(Integer.valueOf(0), req.pageSize);
assertEquals("REV0023116477", req.entryCode); assertEquals("Made in China", req.remark);
assertEquals(Integer.valueOf(4), req.pageSize); assertEquals(1, req.productInfos.size());
assertEquals(Integer.valueOf(EdayunCaseMarkMapper.MADE_IN_CHINA_NO), req.madeInChina); assertEquals("ybtest", req.productInfos.get(0).skuCode);
assertEquals(Boolean.FALSE, req.separation); assertEquals(Integer.valueOf(2), req.productInfos.get(0).num);
assertEquals(Integer.valueOf(1), req.twoPrint);
// 统一模型没有选箱字段,默认整单
assertNull(req.caseCodeList);
assertNull(req.skuCode);
assertNull(req.startCaseSerialNo);
} }
/** 一箱一份时 twoPrint=0。 */ /** isPrintSkuName 只在 true 时下发,false 交给仓方默认。 */
@Test @Test
void singleCopyMapsZero() { void printSkuNameOnlySentWhenTrue() {
BoxLabelCommand one = BoxLabelCommand.builder() assertNull(EdayunCaseMarkMapper.toRequest(command()).isPrintSkuName);
.providerInboundNo("REV1").inboundRequestNo("IB-1")
.sizeType(LabelSizeType.SIZE_100_150)
.labelsPerPage(LabelsPerPage.ONE)
.build();
assertEquals(Integer.valueOf(0), EdayunCaseMarkMapper.toRequest(one).twoPrint); CaseMarkPrintCommand withName = CaseMarkPrintCommand.builder()
.paperSize(CaseMarkPaperSize.SIZE_60_40)
.printSkuName(true)
.item("sku", 1)
.build();
assertEquals(Boolean.TRUE, EdayunCaseMarkMapper.toRequest(withName).isPrintSkuName);
} }
/** Made in China 与分隔符是易达云特有语义,统一模型没有 → 默认关。 */
@Test @Test
void madeInChinaAndSeparationDefaultOff() { void paperSizesMap() {
EdayunCaseMarkDtos.PrintCaseMarkRequest req = assertEquals(0, CaseMarkPaperSize.SIZE_70_30.code());
EdayunCaseMarkMapper.toRequest(command(LabelSizeType.SIZE_100_150)); assertEquals(1, CaseMarkPaperSize.SIZE_100_60.code());
assertEquals(2, CaseMarkPaperSize.SIZE_100_150.code());
assertEquals(Integer.valueOf(0), req.madeInChina); assertEquals(3, CaseMarkPaperSize.SIZE_60_40.code());
assertEquals(Boolean.FALSE, req.separation);
} }
// ------------------------------------------------------------ 选箱 /** 超过 50 个 SKU 本地就挡,不发请求(仓方也会报「最多打印50个SKU」)。 */
@Test @Test
void mapsCaseCodes() { void moreThan50SkusRejectedLocally() {
EdayunCaseMarkMapper.CaseSelection sel = new EdayunCaseMarkMapper.CaseSelection() CaseMarkPrintCommand.Builder b = CaseMarkPrintCommand.builder()
.caseCodes(java.util.Arrays.asList("B001", "B002")); .paperSize(CaseMarkPaperSize.SIZE_60_40);
for (int i = 0; i < 51; i++) {
EdayunCaseMarkDtos.PrintCaseMarkRequest req = EdayunCaseMarkMapper.toRequest( b.item("SKU-" + i, 1);
command(LabelSizeType.SIZE_100_100), sel); }
assertEquals(java.util.Arrays.asList("B001", "B002"), req.caseCodeList); IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
} () -> EdayunCaseMarkMapper.toRequest(b.build()));
@Test assertTrue(ex.getMessage().contains("at most 50"), ex.getMessage());
void mapsRangesAndSku() {
EdayunCaseMarkMapper.CaseSelection sel = new EdayunCaseMarkMapper.CaseSelection()
.skuCode("SKU-1")
.caseSerialRange("1", "2")
.sellerCaseRange("S1", "S2");
EdayunCaseMarkDtos.PrintCaseMarkRequest req = EdayunCaseMarkMapper.toRequest(
command(LabelSizeType.A4), sel);
assertEquals("SKU-1", req.skuCode);
assertEquals("1", req.startCaseSerialNo);
assertEquals("2", req.endCaseSerialNo);
assertEquals("S1", req.startSellerCaseNo);
assertEquals("S2", req.endSellerCaseNo);
// A4 码值是 5
assertEquals(Integer.valueOf(5), req.pageSize);
} }
/** 选箱条件全空时本地拒——仓方要求四选一。 */ /** 空 SKU 列表与非法份数在命令构造期就被拒。 */
@Test @Test
void emptySelectionIsRejected() { void invalidCommandRejectedAtConstruction() {
assertThrows(IllegalArgumentException.class,
() -> CaseMarkPrintCommand.builder().paperSize(CaseMarkPaperSize.SIZE_60_40).build());
assertThrows(IllegalArgumentException.class, assertThrows(IllegalArgumentException.class,
() -> EdayunCaseMarkMapper.toRequest(command(LabelSizeType.SIZE_100_100), () -> CaseMarkPrintCommand.builder().paperSize(CaseMarkPaperSize.SIZE_60_40)
new EdayunCaseMarkMapper.CaseSelection())); .item("sku", 0));
assertThrows(IllegalArgumentException.class, assertThrows(IllegalArgumentException.class,
() -> EdayunCaseMarkMapper.toRequest(command(LabelSizeType.SIZE_100_100), null)); () -> CaseMarkPrintCommand.builder().paperSize(CaseMarkPaperSize.SIZE_60_40)
.item(" ", 1));
// 缺纸张尺寸
assertThrows(IllegalArgumentException.class,
() -> CaseMarkPrintCommand.builder().item("sku", 1).build());
} }
// ------------------------------------------------------------ 响应 // ------------------------------------------------------------ 响应
/** 响应 data 是 PDF 地址,同步返回(不是任务号)。 */ /** data 是文件地址字符串,直接落 WarehouseLabel.url。 */
@Test @Test
void labelCarriesUrl() { void responseDataIsFileUrl() {
WarehouseLabel label = EdayunCaseMarkMapper.toLabel("https://oss/case.pdf"); RecordingTransport transport = stub("{\"code\":200,\"msg\":\"操作成功\","
+ "\"data\":\"https://oss.edayun.com/barcode1.pdf\",\"traceId\":null}");
WarehouseLabel label = new EdayunAdapter(transport, new JacksonJsonCodec())
.printCaseMarks(ctx(), command());
assertEquals("https://oss/case.pdf", label.url()); assertEquals("https://oss.edayun.com/barcode1.pdf", label.url());
assertEquals("PDF", label.format()); assertEquals("PDF", label.format());
assertNull(label.contentBase64()); assertNull(label.contentBase64());
assertTrue(transport.lastDataRequest().body().contains("\"skuCode\":\"ybtest\""));
}
/** code=200 但 data 为空 → 抛异常,不能返回没有文件的对象。 */
@Test
void blankDataFails() {
RecordingTransport transport = stub(
"{\"code\":200,\"msg\":\"操作成功\",\"data\":\" \"}");
assertThrows(RuntimeException.class,
() -> new EdayunAdapter(transport, new JacksonJsonCodec())
.printCaseMarks(ctx(), command()));
}
/** 仓方业务错误(如 SKU 不存在)要抛异常并带出原因。 */
@Test
void businessErrorFails() {
RecordingTransport transport = stub(
"{\"code\":500,\"msg\":\"sku=NO-SUCH信息不存在\",\"data\":null}");
try {
new EdayunAdapter(transport, new JacksonJsonCodec())
.printCaseMarks(ctx(), command());
org.junit.jupiter.api.Assertions.fail("should have thrown");
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("SKU") || e.getMessage().contains("sku"), e.getMessage());
}
} }
} }

158
warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/adapter/EdayunSkuLabelTest.java

@ -0,0 +1,158 @@
package common.ecommerce.edayun.adapter;
import common.ecommerce.edayun.dto.EdayunSkuLabelDtos;
import common.ecommerce.edayun.enums.EdayunSkuLabelPaper;
import common.ecommerce.warehouse.enums.LabelDownloadMode;
import common.ecommerce.warehouse.enums.LabelSizeType;
import common.ecommerce.warehouse.enums.LabelsPerPage;
import common.ecommerce.warehouse.model.BoxLabelCommand;
import common.ecommerce.warehouse.model.WarehouseLabel;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* SKU 标打印({@code newPrintCaseMarkContentType})映射。
*
* <p>重点:码值不连续(4/2/5)、统一模型只能表达整单打印、
* Made in China 与分隔符默认关。</p>
*/
class EdayunSkuLabelTest {
private static BoxLabelCommand command(LabelSizeType size) {
return BoxLabelCommand.builder()
.providerInboundNo("REV0023116477")
.inboundRequestNo("IB-001")
.sizeType(size)
.labelsPerPage(LabelsPerPage.ONE)
.downloadMode(LabelDownloadMode.PDF)
.twoCopies(true)
.build();
}
// ------------------------------------------------------------ 纸张映射
/** 易达云码值不连续:100×100=4、100×150=2、A4=5。 */
@Test
void paperCodesAreNotSequential() {
assertEquals(4, EdayunSkuLabelPaper.SIZE_100_100.code());
assertEquals(2, EdayunSkuLabelPaper.SIZE_100_150.code());
assertEquals(5, EdayunSkuLabelPaper.A4.code());
}
@Test
void mapsCoreSizes() {
assertEquals(EdayunSkuLabelPaper.SIZE_100_100,
EdayunSkuLabelPaper.of(LabelSizeType.SIZE_100_100));
assertEquals(EdayunSkuLabelPaper.SIZE_100_150,
EdayunSkuLabelPaper.of(LabelSizeType.SIZE_100_150));
assertEquals(LabelSizeType.SIZE_100_100,
EdayunSkuLabelPaper.SIZE_100_100.core());
assertEquals(LabelSizeType.A4, EdayunSkuLabelPaper.A4.core());
}
/** 统一模型的 104×98(美国信纸)易达云不支持,要显式拒绝。 */
@Test
void unsupportedSizeIsRejected() {
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
() -> EdayunSkuLabelPaper.of(LabelSizeType.SIZE_104_98));
assertTrue(ex.getMessage().contains("only 100x100 / 100x150 / A4"), ex.getMessage());
}
// ------------------------------------------------------------ 请求
@Test
void mapsWholeOrderPrint() {
EdayunSkuLabelDtos.PrintSkuLabelRequest req =
EdayunSkuLabelMapper.toRequest(command(LabelSizeType.SIZE_100_100));
assertEquals("REV0023116477", req.entryCode);
assertEquals(Integer.valueOf(4), req.pageSize);
assertEquals(Integer.valueOf(EdayunSkuLabelMapper.MADE_IN_CHINA_NO), req.madeInChina);
assertEquals(Boolean.FALSE, req.separation);
assertEquals(Integer.valueOf(1), req.twoPrint);
// 统一模型没有选箱字段,默认整单
assertNull(req.caseCodeList);
assertNull(req.skuCode);
assertNull(req.startCaseSerialNo);
}
/** 一箱一份时 twoPrint=0。 */
@Test
void singleCopyMapsZero() {
BoxLabelCommand one = BoxLabelCommand.builder()
.providerInboundNo("REV1").inboundRequestNo("IB-1")
.sizeType(LabelSizeType.SIZE_100_150)
.labelsPerPage(LabelsPerPage.ONE)
.build();
assertEquals(Integer.valueOf(0), EdayunSkuLabelMapper.toRequest(one).twoPrint);
}
/** Made in China 与分隔符是易达云特有语义,统一模型没有 → 默认关。 */
@Test
void madeInChinaAndSeparationDefaultOff() {
EdayunSkuLabelDtos.PrintSkuLabelRequest req =
EdayunSkuLabelMapper.toRequest(command(LabelSizeType.SIZE_100_150));
assertEquals(Integer.valueOf(0), req.madeInChina);
assertEquals(Boolean.FALSE, req.separation);
}
// ------------------------------------------------------------ 选箱
@Test
void mapsCaseCodes() {
EdayunSkuLabelMapper.CaseSelection sel = new EdayunSkuLabelMapper.CaseSelection()
.caseCodes(java.util.Arrays.asList("B001", "B002"));
EdayunSkuLabelDtos.PrintSkuLabelRequest req = EdayunSkuLabelMapper.toRequest(
command(LabelSizeType.SIZE_100_100), sel);
assertEquals(java.util.Arrays.asList("B001", "B002"), req.caseCodeList);
}
@Test
void mapsRangesAndSku() {
EdayunSkuLabelMapper.CaseSelection sel = new EdayunSkuLabelMapper.CaseSelection()
.skuCode("SKU-1")
.caseSerialRange("1", "2")
.sellerCaseRange("S1", "S2");
EdayunSkuLabelDtos.PrintSkuLabelRequest req = EdayunSkuLabelMapper.toRequest(
command(LabelSizeType.A4), sel);
assertEquals("SKU-1", req.skuCode);
assertEquals("1", req.startCaseSerialNo);
assertEquals("2", req.endCaseSerialNo);
assertEquals("S1", req.startSellerCaseNo);
assertEquals("S2", req.endSellerCaseNo);
// A4 码值是 5
assertEquals(Integer.valueOf(5), req.pageSize);
}
/** 选箱条件全空时本地拒——仓方要求四选一。 */
@Test
void emptySelectionIsRejected() {
assertThrows(IllegalArgumentException.class,
() -> EdayunSkuLabelMapper.toRequest(command(LabelSizeType.SIZE_100_100),
new EdayunSkuLabelMapper.CaseSelection()));
assertThrows(IllegalArgumentException.class,
() -> EdayunSkuLabelMapper.toRequest(command(LabelSizeType.SIZE_100_100), null));
}
// ------------------------------------------------------------ 响应
/** 响应 data 是 PDF 地址,同步返回(不是任务号)。 */
@Test
void labelCarriesUrl() {
WarehouseLabel label = EdayunSkuLabelMapper.toLabel("https://oss/case.pdf");
assertEquals("https://oss/case.pdf", label.url());
assertEquals("PDF", label.format());
assertNull(label.contentBase64());
}
}

22
warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/probe/EdayunBarcodeProbeTest.java → warehouse-sdk-edayun/src/test/java/common/ecommerce/edayun/probe/EdayunCaseMarkProbeTest.java

@ -2,15 +2,15 @@ package common.ecommerce.edayun.probe;
import common.ecommerce.edayun.EdayunConstants; import common.ecommerce.edayun.EdayunConstants;
import common.ecommerce.edayun.adapter.EdayunAdapter; import common.ecommerce.edayun.adapter.EdayunAdapter;
import common.ecommerce.edayun.adapter.EdayunBarcodeMapper; import common.ecommerce.edayun.adapter.EdayunCaseMarkMapper;
import common.ecommerce.edayun.dto.EdayunBarcodeDtos; import common.ecommerce.edayun.dto.EdayunCaseMarkDtos;
import common.ecommerce.http.JacksonJsonCodec; import common.ecommerce.http.JacksonJsonCodec;
import common.ecommerce.http.OkHttpTransport; import common.ecommerce.http.OkHttpTransport;
import common.ecommerce.shared.error.ChannelException; import common.ecommerce.shared.error.ChannelException;
import common.ecommerce.shared.spi.ChannelSecret; import common.ecommerce.shared.spi.ChannelSecret;
import common.ecommerce.warehouse.enums.BarcodePaperSize; import common.ecommerce.warehouse.enums.CaseMarkPaperSize;
import common.ecommerce.warehouse.enums.WarehouseProvider; import common.ecommerce.warehouse.enums.WarehouseProvider;
import common.ecommerce.warehouse.model.BarcodePrintCommand; import common.ecommerce.warehouse.model.CaseMarkPrintCommand;
import common.ecommerce.warehouse.model.WarehouseLabel; import common.ecommerce.warehouse.model.WarehouseLabel;
import common.ecommerce.warehouse.sdk.WarehouseConnection; import common.ecommerce.warehouse.sdk.WarehouseConnection;
import common.ecommerce.warehouse.sdk.WarehouseContext; import common.ecommerce.warehouse.sdk.WarehouseContext;
@ -22,7 +22,7 @@ import java.time.Clock;
import java.util.UUID; import java.util.UUID;
/** /**
* 打印条码联调探针:<b>只读</b>(生成 PDF,不改仓侧业务数据)。 * 箱唛打印联调探针:<b>只读</b>(生成 PDF,不改仓侧业务数据)。
* *
* <pre> * <pre>
* # 只看报文(不联网) * # 只看报文(不联网)
@ -37,7 +37,7 @@ import java.util.UUID;
* </pre> * </pre>
*/ */
@EnabledIfSystemProperty(named = "edayun.probe.barcode", matches = "true") @EnabledIfSystemProperty(named = "edayun.probe.barcode", matches = "true")
class EdayunBarcodeProbeTest { class EdayunCaseMarkProbeTest {
private static final String BASE_URL = opt("edayun.probe.baseUrl", EdayunConstants.PR_BASE_URL); 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_ID = System.getProperty("edayun.probe.clientId", "");
@ -49,18 +49,18 @@ class EdayunBarcodeProbeTest {
@Test @Test
void probePrintBarcode() { void probePrintBarcode() {
BarcodePrintCommand cmd = BarcodePrintCommand.builder() CaseMarkPrintCommand cmd = CaseMarkPrintCommand.builder()
.paperSize(BarcodePaperSize.A4) .paperSize(CaseMarkPaperSize.SIZE_60_40)
.remark("PROBE") .remark("PROBE")
.printSkuName(true) .printSkuName(true)
.item(SKU, 1) .item(SKU, 1)
.build(); .build();
EdayunBarcodeDtos.PrintBarcodeRequest req = EdayunBarcodeMapper.toRequest(cmd); EdayunCaseMarkDtos.PrintCaseMarkRequest req = EdayunCaseMarkMapper.toRequest(cmd);
String bodyJson = new JacksonJsonCodec().toJson(req); String bodyJson = new JacksonJsonCodec().toJson(req);
System.out.println("\n================ edayun / POST " System.out.println("\n================ edayun / POST "
+ EdayunConstants.PATH_BARCODE_PRINT + " ================"); + EdayunConstants.PATH_CASE_MARK_PRINT + " ================");
System.out.println("[probe] baseUrl=" + BASE_URL + " sku=" + SKU); System.out.println("[probe] baseUrl=" + BASE_URL + " sku=" + SKU);
System.out.println("[request] " + bodyJson); System.out.println("[request] " + bodyJson);
@ -81,7 +81,7 @@ class EdayunBarcodeProbeTest {
new OkHttpTransport("common-ecommerce/1.0.0 (edayun-probe)", 10_000, 60_000), new OkHttpTransport("common-ecommerce/1.0.0 (edayun-probe)", 10_000, 60_000),
new JacksonJsonCodec()); new JacksonJsonCodec());
WarehouseLabel label = adapter.printBarcodes(ctx, cmd); WarehouseLabel label = adapter.printCaseMarks(ctx, cmd);
System.out.println("[OK] labelId=" + label.labelId() + " format=" + label.format() System.out.println("[OK] labelId=" + label.labelId() + " format=" + label.format()
+ " url=" + label.url()); + " url=" + label.url());
} catch (RuntimeException e) { } catch (RuntimeException e) {
Loading…
Cancel
Save