diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java index b239ed8b..771a5968 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java @@ -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 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 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 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 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 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 details = ofsPoOrderData.getDetails(); - Assert.notNull(details, "明细对象不能为空"); - return data.get(0); + List 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; } /** diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningCinfurmInTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningCinfurmInTest.java index 50a3cf81..93ef10cf 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningCinfurmInTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningCinfurmInTest.java @@ -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();