diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java index db2f621d7..a15734165 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java @@ -20,6 +20,7 @@ import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -137,6 +138,115 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl list = distrilbutionBillStockService.list(Wrappers.query().lambda() + .eq(DistrilbutionBillStockEntity::getBillLadingId, distrilbutionBillLading.getId()) + .apply("order_status in (1 , 2)") + ); + //查询全部包件 + List listPackage = distrilbutionBillPackageService.list(Wrappers.query().lambda() + .eq(DistrilbutionBillPackageEntity::getBillLadingId, distrilbutionBillLading.getId()) + .apply("packet_bar_status in ( 1, 3)") + ); + List orderList = new ArrayList<>(); + List packageList = new ArrayList<>(); + if(!list.isEmpty()){ + list.forEach(i ->{ + if("2".equals(i.getConditions())){ + throw new ServiceException("包含已提货的订单,不能取消全部订单"); + } + //取消订单预约信息 + orderList.add(i.getStockArticleId()); + List collect = listPackage.stream().filter(a -> a.getStockArticleId().equals(i.getStockArticleId())).map(DistrilbutionBillPackageEntity::getParceListId).collect(Collectors.toList()); + packageList.addAll(collect); + }); + try{ + //修改订单状态 + if(!orderList.isEmpty()){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.in(DistributionStockArticleEntity::getId,orderList); + updateWrapper.set(DistributionStockArticleEntity::getReservationStatus,OrderReservationStatusConstant.bufenyuyue.getValue()); + distributionStockArticleService.update(updateWrapper); + LambdaUpdateWrapper updateWrapper1 = new LambdaUpdateWrapper<>(); + updateWrapper1.in(DistrilbutionBillStockEntity::getStockArticleId,orderList); + updateWrapper1.set(DistrilbutionBillStockEntity::getOrderStatus,"3"); + distrilbutionBillStockService.update(updateWrapper1); + } + //修改包件预约状态 + if(!packageList.isEmpty()){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.in(DistributionParcelListEntity::getId,packageList); + updateWrapper.set(DistributionParcelListEntity::getOrderPackageReservationStatus,OrderPackageReservationStatusConstant.daiyuyue.getValue()); + distributionParcelListService.update(updateWrapper); + LambdaUpdateWrapper updateWrapper1 = new LambdaUpdateWrapper<>(); + updateWrapper1.in(DistrilbutionBillPackageEntity::getParceListId,packageList); + updateWrapper1.set(DistrilbutionBillPackageEntity::getPacketBarStatus,"2"); + distrilbutionBillPackageService.update(updateWrapper1); + } + }catch (Exception e){ + log.info("自提取消订单报错!{}",e.getMessage()); + throw new ServiceException("系统异常!!"); + } + + } + } + //判断有没有库存品数据 + private void updateStockBill(DistrilbutionBillLadingDTO distrilbutionBillLading){ + List list = distributionDeliveryDetailsService.list(Wrappers.query().lambda() + .eq(DistributionDeliveryDetailsEntity::getBillLadingId, distrilbutionBillLading.getId()) + .apply("inventory_status in ( 1 , 2)") + ); + List stockEntityList = new ArrayList<>(); + List dd = new ArrayList<>(); + if(!list.isEmpty()){ + list.forEach(i ->{ + if("2".equals(i.getConditions())){ + throw new ServiceException("包含已提货的库存品,无法取消!!!"); + } + if("1".equals(i.getStockStatus())){ + DistributionStockListEntity stockEntity = new DistributionStockListEntity(); + stockEntity.setId(i.getStockListId()); + stockEntity.setQuantityStock(i.getQuantity()); + stockEntityList.add(stockEntity); + dd.add(i.getId()); + }else{ + throw new ServiceException("包含已备货的库存品,无法取消!!!"); + } + }); + try { + if(!dd.isEmpty()){ + //取消预约记录 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.in(DistributionDeliveryDetailsEntity::getId,dd); + updateWrapper.set(DistributionDeliveryDetailsEntity::getInventoryStatus,"3"); + distributionDeliveryDetailsService.update(updateWrapper); + } + //修改库存品数据 + if(!stockEntityList.isEmpty()){ + stockEntityList.forEach( i ->{ + DistributionStockListEntity byId = distributionStockListService.getById(i.getId()); + DistributionStockListEntity updateWrapper = new DistributionStockListEntity(); + updateWrapper.setId(i.getId()); + updateWrapper.setQuantityStock(i.getQuantityStock()+byId.getQuantityStock()); + distributionStockListService.updateById(updateWrapper); + }); + } + }catch (Exception e){ + log.error("取消库存品报错!!{}",e.getMessage()); + throw new ServiceException("系统异常!!"); + } + } + } + + + /** * 提货单 新增或修改 * @param distrilbutionBillLading @@ -206,6 +316,15 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl