| | |
| | | import com.ruoyi.projectManagement.vo.ListInfoVo; |
| | | import com.ruoyi.projectManagement.vo.SaveInfoVo; |
| | | import com.ruoyi.projectManagement.vo.SearchInfoVo; |
| | | import com.ruoyi.projectManagement.vo.AttachmentGroupVo; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.baomidou.mybatisplus.extension.toolkit.Db; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.basic.dto.StorageAttachmentDTO; |
| | | import com.ruoyi.basic.dto.StorageBlobVO; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import com.ruoyi.sales.pojo.SalesLawsuit; |
| | | import com.ruoyi.sales.service.ISalesLawsuitService; |
| | | import lombok.RequiredArgsConstructor; |
| | | 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; |
| | |
| | | private final ContractInfoHandleService contractInfoHandleService; |
| | | private final ShippingAddressHandleService shippingAddressHandleService; |
| | | private final ISalesLedgerService salesLedgerService; |
| | | private final StorageAttachmentService storageAttachmentService; |
| | | private final ISalesLawsuitService salesLawsuitService; |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | 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; |
| | | } |
| | | |
| | | @Override |
| | | public List<AttachmentGroupVo> getProjectAttachments(Long id) { |
| | | List<AttachmentGroupVo> result = new java.util.ArrayList<>(); |
| | | |
| | | // 项目管理附件 |
| | | StorageAttachmentDTO infoDto = new StorageAttachmentDTO(); |
| | | infoDto.setRecordType(RecordTypeEnum.INFO.getType()); |
| | | infoDto.setRecordId(id); |
| | | List<StorageBlobVO> infoFiles = storageAttachmentService.list(infoDto); |
| | | if (infoFiles != null && !infoFiles.isEmpty()) { |
| | | result.add(new AttachmentGroupVo("项目管理", infoFiles)); |
| | | } |
| | | |
| | | // 销售台账附件 |
| | | List<SalesLedger> ledgers = salesLedgerService.list(Wrappers.<SalesLedger>lambdaQuery().eq(SalesLedger::getProjectId, id)); |
| | | if (ledgers != null && !ledgers.isEmpty()) { |
| | | List<StorageBlobVO> ledgerFiles = new java.util.ArrayList<>(); |
| | | for (SalesLedger ledger : ledgers) { |
| | | StorageAttachmentDTO dto = new StorageAttachmentDTO(); |
| | | dto.setRecordType(RecordTypeEnum.SALES_LEDGER.getType()); |
| | | dto.setRecordId(ledger.getId()); |
| | | List<StorageBlobVO> files = storageAttachmentService.list(dto); |
| | | if (files != null && !files.isEmpty()) { |
| | | ledgerFiles.addAll(files); |
| | | } |
| | | } |
| | | if (!ledgerFiles.isEmpty()) { |
| | | result.add(new AttachmentGroupVo("销售台账", ledgerFiles)); |
| | | } |
| | | } |
| | | |
| | | // 诉讼管理附件 |
| | | List<SalesLawsuit> lawsuits = salesLawsuitService.list(Wrappers.<SalesLawsuit>lambdaQuery().eq(SalesLawsuit::getProjectId, id)); |
| | | if (lawsuits != null && !lawsuits.isEmpty()) { |
| | | List<StorageBlobVO> lawsuitFiles = new java.util.ArrayList<>(); |
| | | for (SalesLawsuit lawsuit : lawsuits) { |
| | | StorageAttachmentDTO dto = new StorageAttachmentDTO(); |
| | | dto.setRecordType(RecordTypeEnum.SALES_LAWSUIT.getType()); |
| | | dto.setRecordId(lawsuit.getId()); |
| | | List<StorageBlobVO> files = storageAttachmentService.list(dto); |
| | | if (files != null && !files.isEmpty()) { |
| | | lawsuitFiles.addAll(files); |
| | | } |
| | | } |
| | | if (!lawsuitFiles.isEmpty()) { |
| | | result.add(new AttachmentGroupVo("诉讼管理", lawsuitFiles)); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | } |