作者 [wgf]

添加 SL数据格式 DEMO

1 ### dw example 使用手册 1 ### dw example 使用手册
2 2
  3 +数据格式
  4 +---
  5 + - `OBJ`:传统的JSON格式,返回数组包含严格的 key:value
  6 +
  7 + - `SL`:修剪过的JSON格式,字段名称和字段值分别分开存储在不同数组种
  8 + ```
  9 + {
  10 + "headData": [
  11 + "currency_id",
  12 + "currency_code",
  13 + "currency_name"
  14 + ]
  15 + },
  16 + "columnDataList": [
  17 + [
  18 + 14186,
  19 + "USD",
  20 + "美元"
  21 + ],
  22 + [
  23 + 14187,
  24 + "USD",
  25 + "美元"
  26 + ],
  27 + ...
  28 + ]
  29 + }
  30 + ```
  31 + 因为SL格式每次数据交互只序列化一次key,和传统的JSON结构相比。生成的JSON字符串长度会缩小20% ~ 40%,
  32 + 但相对的比较难解析,可以在`DwParamVo`中指定格式。
  33 +
  34 +
3 修改配置文件 35 修改配置文件
4 --- 36 ---
5 修改 application.yml 的 `dwAppId`、 `dwAppSecret` 配置 37 修改 application.yml 的 `dwAppId`、 `dwAppSecret` 配置
@@ -15,5 +15,5 @@ public interface DwApi { @@ -15,5 +15,5 @@ public interface DwApi {
15 /** 15 /**
16 * FBA-库存快照 16 * FBA-库存快照
17 */ 17 */
18 - String FBA_FULFILLMENT_CURRENT_INVENTORY_VIEW_API = "/stock/fba_fulfillment_current_inventory_view"; 18 + String FULFILLMENT_CURRENT_INVENTORY = "/stock/fulfillment_current_inventory";
19 } 19 }
1 -package com.aukey.example.entity;  
2 -  
3 -/**  
4 - * @author: wgf  
5 - * @create: 2020-05-19 17:18  
6 - * @description:  
7 - **/  
8 -public class FbaFulfillmentCurrentInventoryView {  
9 - private String corporationName;  
10 - private String groupCode;  
11 - private String groupName;  
12 - private String deptCode;  
13 - private String deptName;  
14 - private String companySku;  
15 - private String amazonSku;  
16 - private String fnsku;  
17 -  
18 - /**  
19 - * ......  
20 - * more field  
21 - */  
22 -  
23 - public String getCorporationName() {  
24 - return corporationName;  
25 - }  
26 -  
27 - public void setCorporationName(String corporationName) {  
28 - this.corporationName = corporationName;  
29 - }  
30 -  
31 - public String getGroupCode() {  
32 - return groupCode;  
33 - }  
34 -  
35 - public void setGroupCode(String groupCode) {  
36 - this.groupCode = groupCode;  
37 - }  
38 -  
39 - public String getGroupName() {  
40 - return groupName;  
41 - }  
42 -  
43 - public void setGroupName(String groupName) {  
44 - this.groupName = groupName;  
45 - }  
46 -  
47 - public String getDeptCode() {  
48 - return deptCode;  
49 - }  
50 -  
51 - public void setDeptCode(String deptCode) {  
52 - this.deptCode = deptCode;  
53 - }  
54 -  
55 - public String getDeptName() {  
56 - return deptName;  
57 - }  
58 -  
59 - public void setDeptName(String deptName) {  
60 - this.deptName = deptName;  
61 - }  
62 -  
63 - public String getCompanySku() {  
64 - return companySku;  
65 - }  
66 -  
67 - public void setCompanySku(String companySku) {  
68 - this.companySku = companySku;  
69 - }  
70 -  
71 - public String getAmazonSku() {  
72 - return amazonSku;  
73 - }  
74 -  
75 - public void setAmazonSku(String amazonSku) {  
76 - this.amazonSku = amazonSku;  
77 - }  
78 -  
79 - public String getFnsku() {  
80 - return fnsku;  
81 - }  
82 -  
83 - public void setFnsku(String fnsku) {  
84 - this.fnsku = fnsku;  
85 - }  
86 -}  
  1 +package com.aukey.example.entity;
  2 +
  3 +import java.util.Date;
  4 +
  5 +/**
  6 + * @author: wgf
  7 + * @create: 2020-05-19 17:18
  8 + * @description:
  9 + **/
  10 +public class FulfillmentCurrentInventory {
  11 + private Integer id;
  12 + private Integer accountId;
  13 + private String accountName;
  14 + private String siteName;
  15 + private Integer areaId;
  16 + private String area;
  17 + private Date snapshotDate;
  18 + private Date createDate;
  19 + private String fnSku;
  20 + private String amazonSku;
  21 + private String productName;
  22 +
  23 + public Integer getId() {
  24 + return id;
  25 + }
  26 +
  27 + public void setId(Integer id) {
  28 + this.id = id;
  29 + }
  30 +
  31 + public Integer getAccountId() {
  32 + return accountId;
  33 + }
  34 +
  35 + public void setAccountId(Integer accountId) {
  36 + this.accountId = accountId;
  37 + }
  38 +
  39 + public String getAccountName() {
  40 + return accountName;
  41 + }
  42 +
  43 + public void setAccountName(String accountName) {
  44 + this.accountName = accountName;
  45 + }
  46 +
  47 + public String getSiteName() {
  48 + return siteName;
  49 + }
  50 +
  51 + public void setSiteName(String siteName) {
  52 + this.siteName = siteName;
  53 + }
  54 +
  55 + public Integer getAreaId() {
  56 + return areaId;
  57 + }
  58 +
  59 + public void setAreaId(Integer areaId) {
  60 + this.areaId = areaId;
  61 + }
  62 +
  63 + public String getArea() {
  64 + return area;
  65 + }
  66 +
  67 + public void setArea(String area) {
  68 + this.area = area;
  69 + }
  70 +
  71 + public Date getSnapshotDate() {
  72 + return snapshotDate;
  73 + }
  74 +
  75 + public void setSnapshotDate(Date snapshotDate) {
  76 + this.snapshotDate = snapshotDate;
  77 + }
  78 +
  79 + public Date getCreateDate() {
  80 + return createDate;
  81 + }
  82 +
  83 + public void setCreateDate(Date createDate) {
  84 + this.createDate = createDate;
  85 + }
  86 +
  87 + public String getFnSku() {
  88 + return fnSku;
  89 + }
  90 +
  91 + public void setFnSku(String fnSku) {
  92 + this.fnSku = fnSku;
  93 + }
  94 +
  95 + public String getAmazonSku() {
  96 + return amazonSku;
  97 + }
  98 +
  99 + public void setAmazonSku(String amazonSku) {
  100 + this.amazonSku = amazonSku;
  101 + }
  102 +
  103 + public String getProductName() {
  104 + return productName;
  105 + }
  106 +
  107 + public void setProductName(String productName) {
  108 + this.productName = productName;
  109 + }
  110 +}
1 package com.aukey.example.util; 1 package com.aukey.example.util;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 -import com.alibaba.fastjson.JSONException;  
5 import com.alibaba.fastjson.JSONReader; 4 import com.alibaba.fastjson.JSONReader;
6 import com.alibaba.fastjson.TypeReference; 5 import com.alibaba.fastjson.TypeReference;
7 import com.aukey.example.vo.DwParamVo; 6 import com.aukey.example.vo.DwParamVo;
@@ -31,7 +30,7 @@ import java.util.function.Supplier; @@ -31,7 +30,7 @@ import java.util.function.Supplier;
31 * @author: wgf 30 * @author: wgf
32 * @create: 2020-05-13 11:21 31 * @create: 2020-05-13 11:21
33 * @description: dw帮助工具类 32 * @description: dw帮助工具类
34 - * 33 + * <p>
35 * 关于 java url 编码问题 34 * 关于 java url 编码问题
36 * Java官方的URLEncoder.encode 实际上是为了post请求的content-type为x-www-form-urlencoded来设计的 35 * Java官方的URLEncoder.encode 实际上是为了post请求的content-type为x-www-form-urlencoded来设计的
37 * 在进行特殊参数转义的时候会将空格转为 + 36 * 在进行特殊参数转义的时候会将空格转为 +
@@ -268,14 +267,9 @@ public class DwHelperUtil { @@ -268,14 +267,9 @@ public class DwHelperUtil {
268 jsonReader.startArray(); 267 jsonReader.startArray();
269 268
270 while (jsonReader.hasNext()) { 269 while (jsonReader.hasNext()) {
271 - try {  
272 T t = constructor.get(); 270 T t = constructor.get();
273 jsonReader.readObject(t); 271 jsonReader.readObject(t);
274 container.add(t); 272 container.add(t);
275 - } catch (JSONException ex) {  
276 - Object o = jsonReader.readObject();  
277 - log.info("json数据转换异常:{}", o.toString());  
278 - }  
279 273
280 if (container.size() == batchSize) { 274 if (container.size() == batchSize) {
281 callback.accept(container); 275 callback.accept(container);
@@ -292,14 +286,16 @@ public class DwHelperUtil { @@ -292,14 +286,16 @@ public class DwHelperUtil {
292 log.info("{} 流式读取已读条数:{}", dwDataApi, total); 286 log.info("{} 流式读取已读条数:{}", dwDataApi, total);
293 container.clear(); 287 container.clear();
294 } 288 }
295 -  
296 - //结束读取  
297 - jsonReader.endArray();  
298 } else { 289 } else {
299 log.info("流式读取异常 [ url:{} ] [ code:{} ]", dwDataApi, response.code()); 290 log.info("流式读取异常 [ url:{} ] [ code:{} ]", dwDataApi, response.code());
300 } 291 }
301 - 292 + } catch (Exception e) {
  293 + log.error(e.getMessage(), e);
  294 + throw e;
302 } finally { 295 } finally {
  296 + //结束读取
  297 + jsonReader.endArray();
  298 +
303 if (Objects.nonNull(jsonReader)) { 299 if (Objects.nonNull(jsonReader)) {
304 jsonReader.close(); 300 jsonReader.close();
305 } 301 }
@@ -321,8 +317,9 @@ public class DwHelperUtil { @@ -321,8 +317,9 @@ public class DwHelperUtil {
321 317
322 protected static Response executeHttpPostRequest(String url, Map<String, Object> paramMap) throws Exception { 318 protected static Response executeHttpPostRequest(String url, Map<String, Object> paramMap) throws Exception {
323 OkHttpClient client = new OkHttpClient.Builder() 319 OkHttpClient client = new OkHttpClient.Builder()
324 - .connectTimeout(60 * 30 * 2, TimeUnit.SECONDS)  
325 - .readTimeout(60 * 1, TimeUnit.SECONDS) 320 + .connectTimeout(60 * 60 * 2, TimeUnit.SECONDS)
  321 + .writeTimeout(60 * 2, TimeUnit.SECONDS)
  322 + .readTimeout(60 * 2, TimeUnit.SECONDS)
326 .build(); 323 .build();
327 324
328 url = jointUrl(url, paramMap); 325 url = jointUrl(url, paramMap);
@@ -11,9 +11,10 @@ import java.util.List; @@ -11,9 +11,10 @@ import java.util.List;
11 * 11 *
12 * @author 吴耿锋 12 * @author 吴耿锋
13 * @version 2018年5月11日 13 * @version 2018年5月11日
  14 + * 对应 OBJ 返回数据类型
14 */ 15 */
15 16
16 -public class PageVo<T> implements Serializable { 17 +public class ObjVo<T> implements Serializable {
17 18
18 19
19 @ApiModelProperty("页数") 20 @ApiModelProperty("页数")
  1 +package com.aukey.example.vo;
  2 +
  3 +import java.util.List;
  4 +
  5 +/**
  6 + * @author: wgf
  7 + * @create: 2020-05-22 15:42
  8 + * @description:
  9 + **/
  10 +public class SlNodeVo {
  11 +
  12 + /**
  13 + * 字段名称
  14 + */
  15 + private List<String> headData;
  16 +
  17 + /**
  18 + * 数据列表
  19 + */
  20 + private List<List<Object>> columnDataList;
  21 +
  22 + public List<List<Object>> getColumnDataList() {
  23 + return columnDataList;
  24 + }
  25 +
  26 + public void setColumnDataList(List<List<Object>> columnDataList) {
  27 + this.columnDataList = columnDataList;
  28 + }
  29 +
  30 + public List<String> getHeadData() {
  31 + return headData;
  32 + }
  33 +
  34 + public void setHeadData(List<String> headData) {
  35 + this.headData = headData;
  36 + }
  37 +}
  1 +package com.aukey.example.vo;
  2 +
  3 +/**
  4 + * @author: wgf
  5 + * @create: 2020-05-22 14:55
  6 + * @description: 对应 SL 返回数据类型
  7 + * 返回数据和字段在 SlNodeVo
  8 + * SL这种方式需要对数据进行格式化
  9 + **/
  10 +public class SlVo {
  11 +
  12 + private Integer total;
  13 +
  14 + private Integer pageNumber;
  15 +
  16 + private SlNodeVo data;
  17 +
  18 + public Integer getTotal() {
  19 + return total;
  20 + }
  21 +
  22 + public void setTotal(Integer total) {
  23 + this.total = total;
  24 + }
  25 +
  26 + public Integer getPageNumber() {
  27 + return pageNumber;
  28 + }
  29 +
  30 + public void setPageNumber(Integer pageNumber) {
  31 + this.pageNumber = pageNumber;
  32 + }
  33 +
  34 + public SlNodeVo getData() {
  35 + return data;
  36 + }
  37 +
  38 + public void setData(SlNodeVo data) {
  39 + this.data = data;
  40 + }
  41 +}
@@ -4,11 +4,12 @@ import com.alibaba.fastjson.JSON; @@ -4,11 +4,12 @@ import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.TypeReference; 4 import com.alibaba.fastjson.TypeReference;
5 import com.aukey.example.constant.DwApi; 5 import com.aukey.example.constant.DwApi;
6 import com.aukey.example.entity.CurrencySet; 6 import com.aukey.example.entity.CurrencySet;
7 -import com.aukey.example.entity.FbaFulfillmentCurrentInventoryView; 7 +import com.aukey.example.entity.FulfillmentCurrentInventory;
8 import com.aukey.example.util.DwHelperUtil; 8 import com.aukey.example.util.DwHelperUtil;
9 import com.aukey.example.vo.DwParamVo; 9 import com.aukey.example.vo.DwParamVo;
10 import com.aukey.example.vo.DwResultVo; 10 import com.aukey.example.vo.DwResultVo;
11 -import com.aukey.example.vo.PageVo; 11 +import com.aukey.example.vo.ObjVo;
  12 +import com.aukey.example.vo.SlVo;
12 import io.swagger.annotations.Api; 13 import io.swagger.annotations.Api;
13 import io.swagger.annotations.ApiOperation; 14 import io.swagger.annotations.ApiOperation;
14 import org.slf4j.Logger; 15 import org.slf4j.Logger;
@@ -51,9 +52,9 @@ public class TestApiController { @@ -51,9 +52,9 @@ public class TestApiController {
51 private String appId; 52 private String appId;
52 53
53 54
54 - @ApiOperation(value = "小批量读取 DEMO")  
55 - @GetMapping("/query_all")  
56 - public void queryAll() { 55 + @ApiOperation(value = "小批量读取 OBJ 方式")
  56 + @GetMapping("/query_all_obj")
  57 + public void queryAllObj() {
57 58
58 // 构造请求参数 59 // 构造请求参数
59 DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken()); 60 DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
@@ -62,6 +63,7 @@ public class TestApiController { @@ -62,6 +63,7 @@ public class TestApiController {
62 paramVo.setQueryCondition("WHERE currency_code = 'USD'"); 63 paramVo.setQueryCondition("WHERE currency_code = 'USD'");
63 // 每页数据条数 dw服务端有限制 取值[1, 3000] 64 // 每页数据条数 dw服务端有限制 取值[1, 3000]
64 paramVo.setPageSize(3000); 65 paramVo.setPageSize(3000);
  66 + paramVo.setDataStructure(DwParamVo.OBJ);
65 67
66 // 调用API 68 // 调用API
67 String result = DwHelperUtil.doGet(dwDataApi, DwApi.CURRENCY_SET_API, paramVo.toMap()); 69 String result = DwHelperUtil.doGet(dwDataApi, DwApi.CURRENCY_SET_API, paramVo.toMap());
@@ -70,13 +72,46 @@ public class TestApiController { @@ -70,13 +72,46 @@ public class TestApiController {
70 throw new RuntimeException(String.format("API %s 调用失败", DwApi.CURRENCY_SET_API)); 72 throw new RuntimeException(String.format("API %s 调用失败", DwApi.CURRENCY_SET_API));
71 } 73 }
72 // json解析为对象 74 // json解析为对象
73 - DwResultVo<PageVo<CurrencySet>> resultVo = JSON.parseObject(result, new TypeReference<DwResultVo<PageVo<CurrencySet>>>() { 75 + DwResultVo<ObjVo<CurrencySet>> resultVo = JSON.parseObject(result, new TypeReference<DwResultVo<ObjVo<CurrencySet>>>() {
74 }); 76 });
75 77
76 log.info(""); 78 log.info("");
77 log.info("API请求状态:{}", resultVo.getMessage()); 79 log.info("API请求状态:{}", resultVo.getMessage());
78 log.info("API返回数据:{}", JSON.toJSONString(resultVo.getData().getData())); 80 log.info("API返回数据:{}", JSON.toJSONString(resultVo.getData().getData()));
79 - log.info("API返回数据两:{}", resultVo.getData().getData().size()); 81 + log.info("API返回数据量:{}", resultVo.getData().getTotal());
  82 + log.info("");
  83 + }
  84 +
  85 +
  86 + @ApiOperation(value = "小批量读取 SL 方式")
  87 + @GetMapping("/query_all_sl")
  88 + public void queryAllSl() {
  89 +
  90 + // 构造请求参数
  91 + DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
  92 +
  93 + // 添加查询条件
  94 + paramVo.setQueryCondition("WHERE currency_code = 'USD'");
  95 + // 每页数据条数 dw服务端有限制 取值[1, 3000]
  96 + paramVo.setPageSize(3000);
  97 + paramVo.setDataStructure(DwParamVo.SL);
  98 +
  99 + // 调用API
  100 + String result = DwHelperUtil.doGet(dwDataApi, DwApi.CURRENCY_SET_API, paramVo.toMap());
  101 +
  102 + if (StringUtils.isEmpty(result)) {
  103 + throw new RuntimeException(String.format("API %s 调用失败", DwApi.CURRENCY_SET_API));
  104 + }
  105 +
  106 + // json解析为对象
  107 + DwResultVo<SlVo> resultVo = JSON.parseObject(result, new TypeReference<DwResultVo<SlVo>>() {
  108 + });
  109 +
  110 + log.info("");
  111 + log.info("API请求状态:{}", resultVo.getMessage());
  112 + log.info("API返回数据字段:{}", JSON.toJSONString(resultVo.getData().getData().getHeadData()));
  113 + log.info("API返回数据数组:{}", JSON.toJSONString(resultVo.getData().getData().getColumnDataList()));
  114 + log.info("API返回数据量:{}", resultVo.getData().getTotal());
80 log.info(""); 115 log.info("");
81 } 116 }
82 117
@@ -85,22 +120,23 @@ public class TestApiController { @@ -85,22 +120,23 @@ public class TestApiController {
85 * 适合获取 百万级别的表,大表用分页读取会非常慢 120 * 适合获取 百万级别的表,大表用分页读取会非常慢
86 * 大表建议使用流式读取 121 * 大表建议使用流式读取
87 */ 122 */
88 - @ApiOperation(value = "分页读取 DEMO")  
89 - @GetMapping("/query_page")  
90 - public void queryPage() { 123 + @ApiOperation(value = "分页读取 OBJ 方式")
  124 + @GetMapping("/query_page_obj")
  125 + public void queryPageObj() {
91 126
92 // 构造请求参数 127 // 构造请求参数
93 DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken()); 128 DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
94 // 每页数据条数 dw服务端有限制 取值[1, 3000] 129 // 每页数据条数 dw服务端有限制 取值[1, 3000]
95 paramVo.setPageSize(1000); 130 paramVo.setPageSize(1000);
  131 + paramVo.setDataStructure(DwParamVo.OBJ);
96 // TODO 自定义查询条件 132 // TODO 自定义查询条件
97 133
98 // json字符串转实体引用类型 134 // json字符串转实体引用类型
99 - TypeReference typeReference = new TypeReference<DwResultVo<PageVo<CurrencySet>>>() { 135 + TypeReference typeReference = new TypeReference<DwResultVo<ObjVo<CurrencySet>>>() {
100 }; 136 };
101 137
102 // 回调函数 138 // 回调函数
103 - Function<DwResultVo<PageVo<CurrencySet>>, Integer> callback = (DwResultVo<PageVo<CurrencySet>> resultVo) -> { 139 + Function<DwResultVo<ObjVo<CurrencySet>>, Integer> callback = (DwResultVo<ObjVo<CurrencySet>> resultVo) -> {
104 List<CurrencySet> dataList = resultVo.getData().getData(); 140 List<CurrencySet> dataList = resultVo.getData().getData();
105 System.out.println(dataList.size()); 141 System.out.println(dataList.size());
106 // TODO 业务逻辑在这里实现 142 // TODO 业务逻辑在这里实现
@@ -121,13 +157,53 @@ public class TestApiController { @@ -121,13 +157,53 @@ public class TestApiController {
121 157
122 158
123 /** 159 /**
124 - * 流式读取适合百/千万级别的表内网数据同步,本机测试 160 + * 适合获取 百万级别的表,大表用分页读取会非常慢
  161 + * 大表建议使用流式读取
  162 + */
  163 + @ApiOperation(value = "分页读取 SL 方式")
  164 + @GetMapping("/query_page_sl")
  165 + public void queryPageSl() {
  166 +
  167 + // 构造请求参数
  168 + DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
  169 + // 每页数据条数 dw服务端有限制 取值[1, 3000]
  170 + paramVo.setPageSize(1000);
  171 + paramVo.setDataStructure(DwParamVo.SL);
  172 + // TODO 自定义查询条件
  173 +
  174 + // json字符串转实体引用类型
  175 + TypeReference typeReference = new TypeReference<DwResultVo<SlVo>>() {
  176 + };
  177 +
  178 + // 回调函数
  179 + Function<DwResultVo<SlVo>, Integer> callback = (DwResultVo<SlVo> resultVo) -> {
  180 + log.info("字段字段:{}", resultVo.getData().getData().getHeadData());
  181 + log.info("数据数组:{}", resultVo.getData().getData().getColumnDataList());
  182 + // TODO 业务逻辑在这里实现
  183 + // ... more
  184 + // mapper.insertList(dataList)
  185 +
  186 + // 需要返回总页数
  187 + return resultVo.getData().getTotal();
  188 + };
  189 +
  190 + // 使用分页API
  191 + DwHelperUtil.pageReader(callback,
  192 + dwDataApi,
  193 + DwApi.CURRENCY_SET_API,
  194 + paramVo,
  195 + typeReference);
  196 + }
  197 +
  198 +
  199 + /**
  200 + * 流式读取适合百级别的表内网数据同步,每次数据读取建议在[100000, 1000000],本机测试
125 * <p> 201 * <p>
126 * 网络环境:局域网 202 * 网络环境:局域网
127 * 数据源 :华为dws 203 * 数据源 :华为dws
128 * cpu : 4核3.2GHz 204 * cpu : 4核3.2GHz
129 * 内存 :16GB DDR3 205 * 内存 :16GB DDR3
130 - * 测试数据:1000W条 206 + * 测试数据:100W条
131 * 回调函数不做持久化操作 207 * 回调函数不做持久化操作
132 * <p> 208 * <p>
133 * <p> 209 * <p>
@@ -154,24 +230,24 @@ public class TestApiController { @@ -154,24 +230,24 @@ public class TestApiController {
154 // TODO 自定义查询条件 230 // TODO 自定义查询条件
155 231
156 // 定义实体构造函数 232 // 定义实体构造函数
157 - Supplier<FbaFulfillmentCurrentInventoryView> constructor = FbaFulfillmentCurrentInventoryView::new; 233 + Supplier<FulfillmentCurrentInventory> constructor = FulfillmentCurrentInventory::new;
158 234
159 // 流式读取回调函数 235 // 流式读取回调函数
160 - Consumer<List<FbaFulfillmentCurrentInventoryView>> callBack = (List<FbaFulfillmentCurrentInventoryView> list) -> { 236 + Consumer<List<FulfillmentCurrentInventory>> callBack = (List<FulfillmentCurrentInventory> list) -> {
161 System.out.println(list.size()); 237 System.out.println(list.size());
162 // TODO 业务逻辑在这里实现 238 // TODO 业务逻辑在这里实现
163 // ... more 239 // ... more
164 // mapper.insertList(list) 240 // mapper.insertList(list)
165 }; 241 };
166 242
167 - // 指定回调函数数据大小,取值[500, 5000]. 243 + // 指定回调函数数据大小,取值[1000, 5000]. 建议2000
168 // 取值越大,数据读取占用的堆内存越高 244 // 取值越大,数据读取占用的堆内存越高
169 - int batchSize = 5000; 245 + int batchSize = 1000;
170 246
171 // 使用 StreamAPI 247 // 使用 StreamAPI
172 DwHelperUtil.streamReader( 248 DwHelperUtil.streamReader(
173 dwDataApi, 249 dwDataApi,
174 - DwApi.FBA_FULFILLMENT_CURRENT_INVENTORY_VIEW_API, 250 + DwApi.FULFILLMENT_CURRENT_INVENTORY,
175 paramVo.toMap(), 251 paramVo.toMap(),
176 callBack, 252 callBack,
177 batchSize, 253 batchSize,