perf(buildpackage): 优化 OFS 接口调用性能
- 在 queryOfsReturnGoods 和 queryOfsPoOrder 方法中添加同步锁,减少接口堵塞 -优化了接口调用逻辑,提高查询效率 - 调整了测试用例中的输入参数
This commit is contained in:
parent
e0f49363db
commit
2108f127fb
|
@ -83,6 +83,8 @@ public class OfsStandardUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static final Object queryOfsReturnGoodsLock = new Object();
|
||||
|
||||
/**
|
||||
* OFS入库单查询
|
||||
*
|
||||
|
@ -93,31 +95,34 @@ public class OfsStandardUtil {
|
|||
* @author liuyang
|
||||
*/
|
||||
public void queryOfsReturnGoods(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List<StockinOrderSearchResponse.StockinOrder> headerDetailsDtoList, Long pageNo, String api) throws Exception {
|
||||
Assert.notNull(queryOfsSoSaleOutVo, "queryOfsSoSaleOutVo不能为空!");
|
||||
Assert.notNull(headerDetailsDtoList, "headerDetailsDtoList不能为空");
|
||||
Assert.notNull(pageNo, "pageNo不能为空");
|
||||
Assert.notNull(api, "api不能为空");
|
||||
//减少 O 接口堵塞,临时解决办法
|
||||
synchronized (queryOfsReturnGoodsLock) {
|
||||
Assert.notNull(queryOfsSoSaleOutVo, "queryOfsSoSaleOutVo不能为空!");
|
||||
Assert.notNull(headerDetailsDtoList, "headerDetailsDtoList不能为空");
|
||||
Assert.notNull(pageNo, "pageNo不能为空");
|
||||
Assert.notNull(api, "api不能为空");
|
||||
|
||||
Long pageSize = 200L;
|
||||
queryOfsSoSaleOutVo.setPageNo(pageNo);
|
||||
queryOfsSoSaleOutVo.setPageSize(pageSize);
|
||||
Long pageSize = 200L;
|
||||
queryOfsSoSaleOutVo.setPageNo(pageNo);
|
||||
queryOfsSoSaleOutVo.setPageSize(pageSize);
|
||||
|
||||
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
|
||||
interfaceParamDto.setApi(api);
|
||||
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
|
||||
StockinOrderSearchResponse rertunGoodsRootBean = (StockinOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto);
|
||||
if (rertunGoodsRootBean != null) {
|
||||
if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) {
|
||||
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = rertunGoodsRootBean.getData();
|
||||
if (stockinOrderList != null && stockinOrderList.size() > 0) {
|
||||
headerDetailsDtoList.addAll(stockinOrderList);
|
||||
queryOfsReturnGoods(queryOfsSoSaleOutVo, headerDetailsDtoList, ++pageNo, api);
|
||||
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
|
||||
interfaceParamDto.setApi(api);
|
||||
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
|
||||
StockinOrderSearchResponse rertunGoodsRootBean = (StockinOrderSearchResponse) ofsUnifiedService.unified(interfaceParamDto);
|
||||
if (rertunGoodsRootBean != null) {
|
||||
if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) {
|
||||
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = rertunGoodsRootBean.getData();
|
||||
if (stockinOrderList != null && stockinOrderList.size() > 0) {
|
||||
headerDetailsDtoList.addAll(stockinOrderList);
|
||||
queryOfsReturnGoods(queryOfsSoSaleOutVo, headerDetailsDtoList, ++pageNo, api);
|
||||
}
|
||||
} else {
|
||||
logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto));
|
||||
}
|
||||
} else {
|
||||
logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto));
|
||||
logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto));
|
||||
}
|
||||
} else {
|
||||
logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,49 +160,54 @@ public class OfsStandardUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static final Object queryOfsPoOrderlock = new Object();
|
||||
|
||||
/**
|
||||
* 2024年8月20日 16:11:46 查询OFS采购订单
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
public OfsPoOrderData queryOfsPoOrder(String code) throws Exception {
|
||||
if (code != null && !"".equals(code)) {
|
||||
Long pageSize = 200L;
|
||||
Long pageNo = 1L;
|
||||
//减少 O 接口堵塞,临时解决办法
|
||||
synchronized (queryOfsPoOrderlock) {
|
||||
if (code != null && !"".equals(code)) {
|
||||
Long pageSize = 200L;
|
||||
Long pageNo = 1L;
|
||||
|
||||
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
queryOfsSoSaleOutVo.setPageNo(pageNo);
|
||||
queryOfsSoSaleOutVo.setPageSize(pageSize);
|
||||
queryOfsSoSaleOutVo.setCode(code);
|
||||
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
queryOfsSoSaleOutVo.setPageNo(pageNo);
|
||||
queryOfsSoSaleOutVo.setPageSize(pageSize);
|
||||
queryOfsSoSaleOutVo.setCode(code);
|
||||
|
||||
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
|
||||
interfaceParamDto.setApi("ofs.purchaseOrder.search");
|
||||
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
|
||||
OfsPoOrderBean ofsPoOrderBean = (OfsPoOrderBean) ofsUnifiedService.unified(interfaceParamDto);
|
||||
if (ofsPoOrderBean != null) {
|
||||
if ("false".equals(ofsPoOrderBean.getError()) && "0".equals(ofsPoOrderBean.getCode()) && "Success".equals(ofsPoOrderBean.getMsg())) {
|
||||
List<OfsPoOrderData> data = ofsPoOrderBean.getData();
|
||||
if (data != null && data.size() > 0) {
|
||||
OfsPoOrderData ofsPoOrderData = data.get(0);
|
||||
Assert.notNull(ofsPoOrderData, "OFS采购订单无法解析json!");
|
||||
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
|
||||
interfaceParamDto.setApi("ofs.purchaseOrder.search");
|
||||
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
|
||||
OfsPoOrderBean ofsPoOrderBean = (OfsPoOrderBean) ofsUnifiedService.unified(interfaceParamDto);
|
||||
if (ofsPoOrderBean != null) {
|
||||
if ("false".equals(ofsPoOrderBean.getError()) && "0".equals(ofsPoOrderBean.getCode()) && "Success".equals(ofsPoOrderBean.getMsg())) {
|
||||
List<OfsPoOrderData> data = ofsPoOrderBean.getData();
|
||||
if (data != null && data.size() > 0) {
|
||||
OfsPoOrderData ofsPoOrderData = data.get(0);
|
||||
Assert.notNull(ofsPoOrderData, "OFS采购订单无法解析json!");
|
||||
|
||||
OfsPoOrderHeader header = ofsPoOrderData.getHeader();
|
||||
Assert.notNull(header, "表头对象不能为空!");
|
||||
OfsPoOrderHeader header = ofsPoOrderData.getHeader();
|
||||
Assert.notNull(header, "表头对象不能为空!");
|
||||
|
||||
List<OfsPoOrderDetails> details = ofsPoOrderData.getDetails();
|
||||
Assert.notNull(details, "明细对象不能为空");
|
||||
return data.get(0);
|
||||
List<OfsPoOrderDetails> details = ofsPoOrderData.getDetails();
|
||||
Assert.notNull(details, "明细对象不能为空");
|
||||
return data.get(0);
|
||||
}
|
||||
} else {
|
||||
logger.error("查询采购订单失败,失败原因:{}", JSON.toJSON(interfaceParamDto));
|
||||
}
|
||||
} else {
|
||||
logger.error("查询采购订单失败,失败原因:{}", JSON.toJSON(interfaceParamDto));
|
||||
logger.error("ofsPoOrderBean为空!interfaceParamDto接口入参:{}", JSON.toJSON(interfaceParamDto));
|
||||
}
|
||||
} else {
|
||||
logger.error("ofsPoOrderBean为空!interfaceParamDto接口入参:{}", JSON.toJSON(interfaceParamDto));
|
||||
Assert.state(false, "采购订单编码不能为空!");
|
||||
}
|
||||
} else {
|
||||
Assert.state(false, "采购订单编码不能为空!");
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,8 @@ public class ConsignmachiningCinfurmInTest {
|
|||
try {
|
||||
// consignmachiningCinfurmIn.startImplementByTime("2024-01-02 00:00:00", "2024-01-02 23:59:59");
|
||||
|
||||
String code = "LETS-RE2024111400002771-confirm";
|
||||
// String code = "LETS-RE2024111400002771-confirm";
|
||||
String code = "LETS-RE2025022800002706-confirm";
|
||||
consignmachiningCinfurmIn.startImplementByCode(code);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue