diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductDemandServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductDemandServiceImpl.java index fcc1ff558..0d803a608 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductDemandServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductDemandServiceImpl.java @@ -450,6 +450,21 @@ public class StoreProductDemandServiceImpl implements IStoreProductDemandService if (CollectionUtils.isEmpty(demandDetailList)) { throw new ServiceException("需求单明细不存在!", HttpStatus.ERROR); } + // 已完成的需求明细有哪些 + List finishedDemandDetailList = demandDetailList.stream().filter(x -> DemandStatus.PRODUCTION_COMPLETE.getValue().equals(x.getDetailStatus())) + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(finishedDemandDetailList)) { + List finishDemandList = this.storeProdDemandMapper.selectList(new LambdaQueryWrapper() + .in(StoreProductDemand::getId, finishedDemandDetailList.stream().map(StoreProductDemandDetail::getStoreProdDemandId).collect(Collectors.toList()))); + Map demandMap = finishDemandList.stream().collect(Collectors.toMap(StoreProductDemand::getId, x -> x)); + Map> demandDetailMap = finishedDemandDetailList.stream().collect(Collectors.groupingBy(StoreProductDemandDetail::getStoreProdDemandId)); + List errorList = new ArrayList<>(); + demandDetailMap.forEach((demandId, tempDetailList) -> { + final String demandCode = demandMap.containsKey(demandId) ? demandMap.get(demandId).getCode() : ""; + errorList.add(demandCode + ":" + tempDetailList.stream().map(StoreProductDemandDetail::getProdArtNum).collect(Collectors.joining(","))); + }); + throw new ServiceException(errorList + " 等需求明细已完成,不可删除!", HttpStatus.ERROR); + } // 根据需求明细ID能否找到对应的入库与需求抵扣关系数据 List deductList = this.storageDemandDeductMapper.selectList(new LambdaQueryWrapper() .in(StoreProductStorageDemandDeduct::getStoreProdDemandDetailId, deleteDTO.getStoreProdDemandDetailIdList())