...
|
...
|
@@ -2,9 +2,9 @@ package com.aukey.example.web; |
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.aukey.example.constant.DwApi;
|
|
|
import com.aukey.example.entity.CurrencySet;
|
|
|
import com.aukey.example.constant.ServiceCodeEnum;
|
|
|
import com.aukey.example.entity.FulfillmentCurrentInventory;
|
|
|
import com.aukey.example.entity.LogisticsStockIdMapping;
|
|
|
import com.aukey.example.util.DwHelperUtil;
|
|
|
import com.aukey.example.vo.DwParamVo;
|
|
|
import com.aukey.example.vo.DwResultVo;
|
...
|
...
|
@@ -60,19 +60,19 @@ public class TestApiController { |
|
|
DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
|
|
|
|
|
|
// 添加查询条件
|
|
|
paramVo.setQueryCondition("WHERE currency_code = 'USD'");
|
|
|
paramVo.setQueryCondition("WHERE id = 1");
|
|
|
// 每页数据条数 dw服务端有限制 取值[1, 3000]
|
|
|
paramVo.setPageSize(3000);
|
|
|
paramVo.setDataStructure(DwParamVo.OBJ);
|
|
|
|
|
|
// 调用API
|
|
|
String result = DwHelperUtil.doGet(dwDataApi, DwApi.CURRENCY_SET_API, paramVo.toMap());
|
|
|
String result = DwHelperUtil.doGet(dwDataApi, ServiceCodeEnum.logistics_stock_id_mapping, paramVo.toMap());
|
|
|
|
|
|
if (StringUtils.isEmpty(result)) {
|
|
|
throw new RuntimeException(String.format("API %s 调用失败", DwApi.CURRENCY_SET_API));
|
|
|
throw new RuntimeException(String.format("API %s 调用失败", ServiceCodeEnum.logistics_stock_id_mapping.getServiceCode()));
|
|
|
}
|
|
|
// json解析为对象
|
|
|
DwResultVo<ObjVo<CurrencySet>> resultVo = JSON.parseObject(result, new TypeReference<DwResultVo<ObjVo<CurrencySet>>>() {
|
|
|
DwResultVo<ObjVo<LogisticsStockIdMapping>> resultVo = JSON.parseObject(result, new TypeReference<DwResultVo<ObjVo<LogisticsStockIdMapping>>>() {
|
|
|
});
|
|
|
|
|
|
log.info("");
|
...
|
...
|
@@ -91,16 +91,16 @@ public class TestApiController { |
|
|
DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
|
|
|
|
|
|
// 添加查询条件
|
|
|
paramVo.setQueryCondition("WHERE currency_code = 'USD'");
|
|
|
paramVo.setQueryCondition("WHERE id < 1000");
|
|
|
// 每页数据条数 dw服务端有限制 取值[1, 3000]
|
|
|
paramVo.setPageSize(3000);
|
|
|
paramVo.setDataStructure(DwParamVo.SL);
|
|
|
|
|
|
// 调用API
|
|
|
String result = DwHelperUtil.doGet(dwDataApi, DwApi.CURRENCY_SET_API, paramVo.toMap());
|
|
|
String result = DwHelperUtil.doGet(dwDataApi, ServiceCodeEnum.logistics_stock_id_mapping, paramVo.toMap());
|
|
|
|
|
|
if (StringUtils.isEmpty(result)) {
|
|
|
throw new RuntimeException(String.format("API %s 调用失败", DwApi.CURRENCY_SET_API));
|
|
|
throw new RuntimeException(String.format("API %s 调用失败", ServiceCodeEnum.logistics_stock_id_mapping.getServiceCode()));
|
|
|
}
|
|
|
|
|
|
// json解析为对象
|
...
|
...
|
@@ -127,17 +127,17 @@ public class TestApiController { |
|
|
// 构造请求参数
|
|
|
DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
|
|
|
// 每页数据条数 dw服务端有限制 取值[1, 3000]
|
|
|
paramVo.setPageSize(1000);
|
|
|
paramVo.setPageSize(100);
|
|
|
paramVo.setDataStructure(DwParamVo.OBJ);
|
|
|
// TODO 自定义查询条件
|
|
|
|
|
|
// json字符串转实体引用类型
|
|
|
TypeReference typeReference = new TypeReference<DwResultVo<ObjVo<CurrencySet>>>() {
|
|
|
TypeReference typeReference = new TypeReference<DwResultVo<ObjVo<LogisticsStockIdMapping>>>() {
|
|
|
};
|
|
|
|
|
|
// 回调函数
|
|
|
Function<DwResultVo<ObjVo<CurrencySet>>, Integer> callback = (DwResultVo<ObjVo<CurrencySet>> resultVo) -> {
|
|
|
List<CurrencySet> dataList = resultVo.getData().getData();
|
|
|
Function<DwResultVo<ObjVo<LogisticsStockIdMapping>>, Integer> callback = (DwResultVo<ObjVo<LogisticsStockIdMapping>> resultVo) -> {
|
|
|
List<LogisticsStockIdMapping> dataList = resultVo.getData().getData();
|
|
|
System.out.println(dataList.size());
|
|
|
// TODO 业务逻辑在这里实现
|
|
|
// ... more
|
...
|
...
|
@@ -150,7 +150,7 @@ public class TestApiController { |
|
|
// 使用分页API
|
|
|
DwHelperUtil.pageReader(callback,
|
|
|
dwDataApi,
|
|
|
DwApi.CURRENCY_SET_API,
|
|
|
ServiceCodeEnum.logistics_stock_id_mapping,
|
|
|
paramVo,
|
|
|
typeReference);
|
|
|
}
|
...
|
...
|
@@ -167,7 +167,7 @@ public class TestApiController { |
|
|
// 构造请求参数
|
|
|
DwParamVo paramVo = new DwParamVo(this.appId, TokenController.getCurrentToken());
|
|
|
// 每页数据条数 dw服务端有限制 取值[1, 3000]
|
|
|
paramVo.setPageSize(1000);
|
|
|
paramVo.setPageSize(100);
|
|
|
paramVo.setDataStructure(DwParamVo.SL);
|
|
|
// TODO 自定义查询条件
|
|
|
|
...
|
...
|
@@ -190,7 +190,7 @@ public class TestApiController { |
|
|
// 使用分页API
|
|
|
DwHelperUtil.pageReader(callback,
|
|
|
dwDataApi,
|
|
|
DwApi.CURRENCY_SET_API,
|
|
|
ServiceCodeEnum.logistics_stock_id_mapping,
|
|
|
paramVo,
|
|
|
typeReference);
|
|
|
}
|
...
|
...
|
@@ -231,10 +231,10 @@ public class TestApiController { |
|
|
// TODO 自定义查询条件
|
|
|
|
|
|
// 定义实体构造函数
|
|
|
Supplier<FulfillmentCurrentInventory> constructor = FulfillmentCurrentInventory::new;
|
|
|
Supplier<LogisticsStockIdMapping> constructor = LogisticsStockIdMapping::new;
|
|
|
|
|
|
// 流式读取回调函数
|
|
|
Consumer<List<FulfillmentCurrentInventory>> callBack = (List<FulfillmentCurrentInventory> list) -> {
|
|
|
Consumer<List<LogisticsStockIdMapping>> callBack = (List<LogisticsStockIdMapping> list) -> {
|
|
|
System.out.println(list.size());
|
|
|
// TODO 业务逻辑在这里实现
|
|
|
// ... more
|
...
|
...
|
@@ -243,12 +243,12 @@ public class TestApiController { |
|
|
|
|
|
// 指定回调函数数据大小,取值[1000, 3000]. 建议1000最为稳定
|
|
|
// 取值越大,数据读取占用的堆内存越高
|
|
|
int batchSize = 1000;
|
|
|
int batchSize = 100;
|
|
|
|
|
|
// 使用 StreamAPI
|
|
|
DwHelperUtil.streamReader(
|
|
|
dwDataApi,
|
|
|
DwApi.FULFILLMENT_CURRENT_INVENTORY,
|
|
|
ServiceCodeEnum.logistics_stock_id_mapping,
|
|
|
paramVo.toMap(),
|
|
|
callBack,
|
|
|
batchSize,
|
...
|
...
|
|