refactor(purchase): 优化采购入库确认单查询性能
- 新增批量查询 O 采购入库单 和 OFS 采购订单 的方法 - 在查询基本档案中集成批量查询逻辑,减少接口调用次数 - 优化代码结构,提高可读性和维护性
This commit is contained in:
parent
65b91a4d93
commit
8fca910ddc
|
@ -588,10 +588,19 @@ public class ConsignmachiningCinfurmIn extends PluginBaseEntity {
|
||||||
*
|
*
|
||||||
* @author liuyang
|
* @author liuyang
|
||||||
*/
|
*/
|
||||||
private List<PurchaseReceiptConfirmationSonDto> queryBasicArchives(List<OFSReceiptConfirmSearchResponse.Order> returnGoodHeaderDetailsDataDtoList) {
|
private List<PurchaseReceiptConfirmationSonDto> queryBasicArchives(List<OFSReceiptConfirmSearchResponse.Order> returnGoodHeaderDetailsDataDtoList) throws Exception {
|
||||||
List<PurchaseReceiptConfirmationSonDto> consignmachiningInSonDtoArrayList = new ArrayList<>();
|
List<PurchaseReceiptConfirmationSonDto> consignmachiningInSonDtoArrayList = new ArrayList<>();
|
||||||
|
|
||||||
if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
|
if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
|
||||||
|
try {
|
||||||
|
//批量查询O采购入库单
|
||||||
|
queryBatchOfsPoOrderIn(returnGoodHeaderDetailsDataDtoList);
|
||||||
|
//批量查询O采购订单
|
||||||
|
queryBatchOfsPoOrder(returnGoodHeaderDetailsDataDtoList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("方法queryBasicArchives抛出异常", e);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) {
|
for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) {
|
||||||
OFSReceiptConfirmSearchResponse.Order ofsWareConfirmaData = returnGoodHeaderDetailsDataDtoList.get(i);
|
OFSReceiptConfirmSearchResponse.Order ofsWareConfirmaData = returnGoodHeaderDetailsDataDtoList.get(i);
|
||||||
OFSReceiptConfirmSearchResponse.Header header = ofsWareConfirmaData.getHeader();
|
OFSReceiptConfirmSearchResponse.Header header = ofsWareConfirmaData.getHeader();
|
||||||
|
@ -608,24 +617,33 @@ public class ConsignmachiningCinfurmIn extends PluginBaseEntity {
|
||||||
Assert.state(!"".equals(outBizCode), "采购入库确定单对应的采购入库单号不能为空 outBizCode字段;{}", outBizCode);
|
Assert.state(!"".equals(outBizCode), "采购入库确定单对应的采购入库单号不能为空 outBizCode字段;{}", outBizCode);
|
||||||
outBizCode = outBizCode.replace("-confirm", "");
|
outBizCode = outBizCode.replace("-confirm", "");
|
||||||
|
|
||||||
List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>();
|
// List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>();
|
||||||
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||||
queryOfsSoSaleOutVo.setClientCode("LETS");
|
// queryOfsSoSaleOutVo.setClientCode("LETS");
|
||||||
queryOfsSoSaleOutVo.setPageNo(1L);
|
// queryOfsSoSaleOutVo.setPageNo(1L);
|
||||||
queryOfsSoSaleOutVo.setPageSize(50L);
|
// queryOfsSoSaleOutVo.setPageSize(50L);
|
||||||
queryOfsSoSaleOutVo.setCode(outBizCode);
|
// queryOfsSoSaleOutVo.setCode(outBizCode);
|
||||||
queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE");
|
// queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE");
|
||||||
ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
|
// ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
|
||||||
if (returnGoodHeaderDetailsDataDtoArrayList == null || returnGoodHeaderDetailsDataDtoArrayList.size() == 0) {
|
// if (returnGoodHeaderDetailsDataDtoArrayList == null || returnGoodHeaderDetailsDataDtoArrayList.size() == 0) {
|
||||||
Assert.state(false, "根据采购入库单号:{}无法查询到数据", outBizCode);
|
// Assert.state(false, "根据采购入库单号:{}无法查询到数据", outBizCode);
|
||||||
}
|
// }
|
||||||
StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoArrayList.get(0);
|
// StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoArrayList.get(0);
|
||||||
|
// StockinOrderSearchResponse.StockinOrder.StockinH header1 = stockinOrder.getHeader();
|
||||||
|
// List<StockinOrderSearchResponse.StockinOrder.StockinB> details1 = stockinOrder.getDetails();
|
||||||
|
|
||||||
|
Assert.notNull(header.getOfsStockinOrder(), "无法查询到对应的O采购入库单!");
|
||||||
|
StockinOrderSearchResponse.StockinOrder stockinOrder = header.getOfsStockinOrder();
|
||||||
StockinOrderSearchResponse.StockinOrder.StockinH header1 = stockinOrder.getHeader();
|
StockinOrderSearchResponse.StockinOrder.StockinH header1 = stockinOrder.getHeader();
|
||||||
List<StockinOrderSearchResponse.StockinOrder.StockinB> details1 = stockinOrder.getDetails();
|
List<StockinOrderSearchResponse.StockinOrder.StockinB> details1 = stockinOrder.getDetails();
|
||||||
|
|
||||||
//2024年8月25日 09:54:31 查询OFS采购订单
|
//2024年8月25日 09:54:31 查询OFS采购订单
|
||||||
OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(header1.getRefOrderCode());
|
// OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(header1.getRefOrderCode());
|
||||||
Assert.notNull(ofsPoOrderData, "无法查询到委外订单(OFS采购入库单->OSF采购订单->OFS采购订单主键->U8C委外订单自定义项20)");
|
// Assert.notNull(ofsPoOrderData, "无法查询到委外订单(OFS采购入库单->OSF采购订单->OFS采购订单主键->U8C委外订单自定义项20)");
|
||||||
|
// OfsPoOrderHeader ofsPoOrderDataHeader = ofsPoOrderData.getHeader();
|
||||||
|
// List<OfsPoOrderDetails> ofsPoOrderDataDetails = ofsPoOrderData.getDetails();
|
||||||
|
Assert.notNull(header.getOfsOrderData(), "没有查询到对应的O采购订单!");
|
||||||
|
OfsPoOrderData ofsPoOrderData = header.getOfsOrderData();
|
||||||
OfsPoOrderHeader ofsPoOrderDataHeader = ofsPoOrderData.getHeader();
|
OfsPoOrderHeader ofsPoOrderDataHeader = ofsPoOrderData.getHeader();
|
||||||
List<OfsPoOrderDetails> ofsPoOrderDataDetails = ofsPoOrderData.getDetails();
|
List<OfsPoOrderDetails> ofsPoOrderDataDetails = ofsPoOrderData.getDetails();
|
||||||
|
|
||||||
|
@ -1400,4 +1418,86 @@ public class ConsignmachiningCinfurmIn extends PluginBaseEntity {
|
||||||
}
|
}
|
||||||
return icGeneralHResultDto;
|
return icGeneralHResultDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询O 采购入库单
|
||||||
|
*
|
||||||
|
* @author liuyang
|
||||||
|
*/
|
||||||
|
private void queryBatchOfsPoOrderIn(List<OFSReceiptConfirmSearchResponse.Order> purchaseReceiptConfirmationSonDtoList) throws Exception {
|
||||||
|
Set<String> codeSet = null;
|
||||||
|
if (purchaseReceiptConfirmationSonDtoList != null && purchaseReceiptConfirmationSonDtoList.size() > 0) {
|
||||||
|
codeSet = purchaseReceiptConfirmationSonDtoList.stream().filter(dto -> dto.getHeader() != null).filter(dto -> dto.getHeader().getCode() != null).map(dto -> dto.getHeader().getCode().replace("-confirm", "")).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
if (codeSet != null && codeSet.size() > 0) {
|
||||||
|
for (String element : codeSet) {
|
||||||
|
List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>();
|
||||||
|
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||||
|
queryOfsSoSaleOutVo.setClientCode("LETS");
|
||||||
|
queryOfsSoSaleOutVo.setPageNo(1L);
|
||||||
|
queryOfsSoSaleOutVo.setPageSize(50L);
|
||||||
|
queryOfsSoSaleOutVo.setCode(element);
|
||||||
|
queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE");
|
||||||
|
ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
|
||||||
|
if (returnGoodHeaderDetailsDataDtoArrayList.size() == 0) {
|
||||||
|
Assert.state(false, "根据采购入库单号:{}无法查询到数据", element);
|
||||||
|
}
|
||||||
|
//「O采购入库确认单」关联「O采购入库单」
|
||||||
|
StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoArrayList.get(0);
|
||||||
|
for (OFSReceiptConfirmSearchResponse.Order order : purchaseReceiptConfirmationSonDtoList) {
|
||||||
|
OFSReceiptConfirmSearchResponse.Header header = order.getHeader();
|
||||||
|
if (header.getCode() != null) {
|
||||||
|
String replace = header.getCode().replace("-confirm", "");
|
||||||
|
if (element.equals(replace)) {
|
||||||
|
header.setOfsStockinOrder(stockinOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询 OFS 采购订单
|
||||||
|
*
|
||||||
|
* @param purchaseReceiptConfirmationSonDtoList O采购入库确认单
|
||||||
|
* @author liuyang
|
||||||
|
*/
|
||||||
|
private void queryBatchOfsPoOrder(List<OFSReceiptConfirmSearchResponse.Order> purchaseReceiptConfirmationSonDtoList) throws Exception {
|
||||||
|
Set<String> refOrderCodeSet = null;
|
||||||
|
if (purchaseReceiptConfirmationSonDtoList != null && purchaseReceiptConfirmationSonDtoList.size() > 0) {
|
||||||
|
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = new ArrayList<>();
|
||||||
|
for (OFSReceiptConfirmSearchResponse.Order purchaseReceiptConfirmationSonDto : purchaseReceiptConfirmationSonDtoList) {
|
||||||
|
OFSReceiptConfirmSearchResponse.Header header = purchaseReceiptConfirmationSonDto.getHeader();
|
||||||
|
if (header != null && header.getOfsStockinOrder() != null) {
|
||||||
|
stockinOrderList.add(header.getOfsStockinOrder());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (stockinOrderList.size() > 0) {
|
||||||
|
refOrderCodeSet = Optional.ofNullable(stockinOrderList).orElseGet(Collections::emptyList).stream().filter(Objects::nonNull).map(StockinOrderSearchResponse.StockinOrder::getHeader).filter(Objects::nonNull).map(StockinOrderSearchResponse.StockinOrder.StockinH::getRefOrderCode).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (refOrderCodeSet != null && refOrderCodeSet.size() > 0) {
|
||||||
|
for (String refOrderCode : refOrderCodeSet) {
|
||||||
|
OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(refOrderCode);
|
||||||
|
Assert.notNull(ofsPoOrderData, "无法查询到O采购订单 编码:{}", refOrderCode);
|
||||||
|
|
||||||
|
for (OFSReceiptConfirmSearchResponse.Order purchaseReceiptConfirmationSonDto : purchaseReceiptConfirmationSonDtoList) {
|
||||||
|
if (purchaseReceiptConfirmationSonDto.getHeader() != null) {
|
||||||
|
OFSReceiptConfirmSearchResponse.Header header2 = purchaseReceiptConfirmationSonDto.getHeader();
|
||||||
|
|
||||||
|
//O采购入库单
|
||||||
|
Assert.notNull(header2.getOfsStockinOrder(), "O采购入库单不能为空");
|
||||||
|
StockinOrderSearchResponse.StockinOrder ofsStockinOrder = header2.getOfsStockinOrder();
|
||||||
|
StockinOrderSearchResponse.StockinOrder.StockinH header3 = ofsStockinOrder.getHeader();
|
||||||
|
|
||||||
|
if (header3.getRefOrderCode().equals(refOrderCode)) {
|
||||||
|
header2.setOfsOrderData(ofsPoOrderData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -653,6 +653,9 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
|
||||||
|
|
||||||
if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
|
if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
|
||||||
try {
|
try {
|
||||||
|
//批量查询O采购订单
|
||||||
|
queryBatchOfsPoOrder(returnGoodHeaderDetailsDataDtoList);
|
||||||
|
|
||||||
for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) {
|
for (int i = 0; i < returnGoodHeaderDetailsDataDtoList.size(); i++) {
|
||||||
OFSReceiptConfirmSearchResponse.Order order = returnGoodHeaderDetailsDataDtoList.get(i);
|
OFSReceiptConfirmSearchResponse.Order order = returnGoodHeaderDetailsDataDtoList.get(i);
|
||||||
OFSReceiptConfirmSearchResponse.Header header = order.getHeader();
|
OFSReceiptConfirmSearchResponse.Header header = order.getHeader();
|
||||||
|
@ -664,8 +667,10 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
|
||||||
generateBusinessDate = createGenerateBusinessDate(header);
|
generateBusinessDate = createGenerateBusinessDate(header);
|
||||||
|
|
||||||
//查询OFS采购订单
|
//查询OFS采购订单
|
||||||
OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(header.getRefOrderCode());
|
// OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(header.getRefOrderCode());
|
||||||
Assert.notNull(ofsPoOrderData, "根据O表头编码{},无法匹配到OFS采购订单", header.getRefOrderCode());
|
// Assert.notNull(ofsPoOrderData, "根据O表头编码{},无法匹配到OFS采购订单", header.getRefOrderCode());
|
||||||
|
Assert.notNull(header.getOfsOrderData(), "确认单对应的采购订单不能为空!");
|
||||||
|
OfsPoOrderData ofsPoOrderData = header.getOfsOrderData();
|
||||||
boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(ofsPoOrderData, "DLCG,CPCG");
|
boolean checkResult = onlyImplementProxyOrder.onlyImplementProxyOrder(ofsPoOrderData, "DLCG,CPCG");
|
||||||
if (!checkResult) {
|
if (!checkResult) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1146,4 +1151,41 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
|
||||||
logger.error("插件:{},打印拉取到的单据号出错", getPluginName(), e);
|
logger.error("插件:{},打印拉取到的单据号出错", getPluginName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询 OFS 采购订单
|
||||||
|
*
|
||||||
|
* @param returnGoodHeaderDetailsDataDtoList O采购入库确认单
|
||||||
|
* @author liuyang
|
||||||
|
*/
|
||||||
|
private void queryBatchOfsPoOrder(List<OFSReceiptConfirmSearchResponse.Order> returnGoodHeaderDetailsDataDtoList) throws Exception {
|
||||||
|
Set<String> refOrderCodeSet = new HashSet<>();
|
||||||
|
if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
|
||||||
|
for (OFSReceiptConfirmSearchResponse.Order purchaseReceiptConfirmationSonDto : returnGoodHeaderDetailsDataDtoList) {
|
||||||
|
if (purchaseReceiptConfirmationSonDto.getHeader() != null && purchaseReceiptConfirmationSonDto.getHeader().getRefOrderCode() != null) {
|
||||||
|
OFSReceiptConfirmSearchResponse.Header header = purchaseReceiptConfirmationSonDto.getHeader();
|
||||||
|
String refOrderCode = header.getRefOrderCode();
|
||||||
|
if (refOrderCode != null && !"".equals(refOrderCode)) {
|
||||||
|
refOrderCodeSet.add(refOrderCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (refOrderCodeSet != null && refOrderCodeSet.size() > 0) {
|
||||||
|
for (String refOrderCode : refOrderCodeSet) {
|
||||||
|
OfsPoOrderData ofsPoOrderData = ofsStandardUtil.queryOfsPoOrder(refOrderCode);
|
||||||
|
Assert.notNull(ofsPoOrderData, "无法查询到O采购订单 编码:{}", refOrderCode);
|
||||||
|
|
||||||
|
for (OFSReceiptConfirmSearchResponse.Order purchaseReceiptConfirmationSonDto : returnGoodHeaderDetailsDataDtoList) {
|
||||||
|
if (purchaseReceiptConfirmationSonDto.getHeader() != null) {
|
||||||
|
OFSReceiptConfirmSearchResponse.Header header2 = purchaseReceiptConfirmationSonDto.getHeader();
|
||||||
|
if (header2.getRefOrderCode() != null && header2.getRefOrderCode().equals(refOrderCode)) {
|
||||||
|
header2.setOfsOrderData(ofsPoOrderData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,9 @@ public class ProxyPurchaseWarehousWarehouseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void startImplementByCode() {
|
public void startImplementByCode() {
|
||||||
proxyPurchaseWarehousWarehouse.startImplementByCode("LETS-RE2025030400002125-confirm");
|
// proxyPurchaseWarehousWarehouse.startImplementByCode("LETS-RE2025030400002125-confirm");
|
||||||
|
|
||||||
|
String code = "LETS-RE2025022800002706-confirm";
|
||||||
|
proxyPurchaseWarehousWarehouse.startImplementByCode(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,8 @@ package com.hzya.frame.ttxofs.dto.ofsReceiptConfirmSearch;
|
||||||
|
|
||||||
import com.hzya.frame.ttxofs.basics.ReturnMessageBasics;
|
import com.hzya.frame.ttxofs.basics.ReturnMessageBasics;
|
||||||
import com.hzya.frame.ttxofs.dto.ofsTransferOrderSearch.OFSAdjustOrderSearchResponse;
|
import com.hzya.frame.ttxofs.dto.ofsTransferOrderSearch.OFSAdjustOrderSearchResponse;
|
||||||
|
import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderData;
|
||||||
|
import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -167,6 +169,14 @@ public class OFSReceiptConfirmSearchResponse extends ReturnMessageBasics {
|
||||||
* 推送状态:0-未推送、1-已推送、2-推送失败
|
* 推送状态:0-未推送、1-已推送、2-推送失败
|
||||||
*/
|
*/
|
||||||
private String pushU8Status;
|
private String pushU8Status;
|
||||||
|
/**
|
||||||
|
* O采购入库单
|
||||||
|
*/
|
||||||
|
private StockinOrderSearchResponse.StockinOrder ofsStockinOrder;
|
||||||
|
/**
|
||||||
|
* O采购订单
|
||||||
|
*/
|
||||||
|
private OfsPoOrderData ofsOrderData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|
Loading…
Reference in New Issue