| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.enums.IsDeleteEnum; |
| | | import com.ruoyi.common.enums.SaleEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.projectManagement.dto.ContractInfoDto; |
| | | import com.ruoyi.projectManagement.dto.SaveInfoDto; |
| | | import com.ruoyi.projectManagement.dto.ShippingAddressDto; |
| | |
| | | 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; |
| | |
| | | @Override |
| | | @Transactional |
| | | public void deleteInfo(Long id) { |
| | | Info current = infoMapper.selectById(id); |
| | | if (current == null || Integer.valueOf(IsDeleteEnum.DELETED.getCode()).equals(current.getIsDelete())) { |
| | | throw new ServiceException("项目不存在"); |
| | | } |
| | | if (!"未开始".equals(current.getCurrentPhase())) { |
| | | throw new ServiceException("项目已开始,不能删除"); |
| | | } |
| | | LambdaUpdateWrapper<Info> updateWrapper = new LambdaUpdateWrapper<Info>(); |
| | | updateWrapper.eq(Info::getId, id); |
| | | updateWrapper.set(Info::getIsDelete, IsDeleteEnum.DELETED.getCode()); |
| | | infoMapper.update(null, updateWrapper); |
| | | |
| | | // 对应附表信息是否删除待确定(因为后续可能会进行引用所以先不删除 |
| | | } |
| | |
| | | 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(); |