buhuazhen
4 天以前 8512de3e8e887ad13c941e60fbb9a3b48a43e9b1
src/main/java/com/ruoyi/projectManagement/service/impl/InfoServiceImpl.java
@@ -24,6 +24,7 @@
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -103,24 +104,27 @@
        CompletableFuture<SaveInfoDto> infoFuture = CompletableFuture.supplyAsync(() -> infoHandleService.getInfoById(id));
        CompletableFuture<ContractInfoDto> contractFuture = CompletableFuture.supplyAsync(() -> contractInfoHandleService.getByInfoId(id));
        CompletableFuture<ShippingAddressDto> shippingFuture = CompletableFuture.supplyAsync(() -> shippingAddressHandleService.getByInfoId(id));
        // 商品
        CompletableFuture<List<SalesLedgerProduct>> listCompletableFuture = CompletableFuture.supplyAsync(() -> salesLedgerService.getSalesLedgerProductListByRelateId(id,SaleEnum.MANAGEMENT));
        // 商品
        // 下级项目信息
        CompletableFuture<List<SaveInfoDto>> subordinateInfoListFuture = CompletableFuture.supplyAsync(() -> infoHandleService.getSubordinateInfo(id));
        // 等待所有异步完成
        CompletableFuture.allOf(infoFuture, contractFuture, shippingFuture).join();
        CompletableFuture.allOf(infoFuture, contractFuture, shippingFuture,listCompletableFuture,subordinateInfoListFuture).join();
        SaveInfoDto info = infoFuture.get();
        ContractInfoDto contract = contractFuture.get();
        ShippingAddressDto shippingAddress = shippingFuture.get();
        List<SalesLedgerProduct> salesLedgerProductList = listCompletableFuture.get();
        List<SaveInfoDto> saveInfoDtos = subordinateInfoListFuture.get();
        InfoVo vo = new InfoVo();
        vo.setInfo(info);
        vo.setContractInfo(contract);
        vo.setShippingAddress(shippingAddress);
        vo.setSalesLedgerProductList(salesLedgerProductList);
        vo.setSubordinateInfoList(saveInfoDtos);
        return vo;
    }