diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.java index a5d498ec7..04b922a7b 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.java @@ -141,4 +141,6 @@ public interface DistributionReservationPackageMapper extends BaseMapper listPackage(@Param("reservationId") Long reservationId); List listPackageTray(@Param("reservationId") Long reservationId); + +// void selectStockUpList(@Param("reservationId")Long reservationId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.xml index 6d78f984d..6708cf3b9 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationPackageMapper.xml @@ -292,6 +292,9 @@ WHERE GROUP BY lwtg.tray_id, lwtg.tray_code; + + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java index ab33d8d4b..f63287a3e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java @@ -2,6 +2,7 @@ package com.logpm.distribution.service; import com.logpm.distribution.dto.DistributionStockArticleDTO; import com.logpm.distribution.dto.app.DistrilbutionloadingscanDTO; +import com.logpm.distribution.dto.app.StockupDTO; import com.logpm.distribution.entity.DistributionParcelListEntity; /** @@ -102,4 +103,16 @@ public interface IDistributionAsyncService { * @param parcelListEntity */ void checkStockArticleLoadingStatus(DistributionParcelListEntity parcelListEntity); + + /** + * 商 市的扫描修改 部分状态 + * @param stockupDTO + */ + void stockupUpdateState(StockupDTO stockupDTO); + + /** + * 自提的扫描修改 部分状态 + * @param stockupDTO + */ + void stockupSelfUpdateState(StockupDTO stockupDTO); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java index 1dd21b201..f435486cb 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java @@ -1,12 +1,11 @@ package com.logpm.distribution.service.impl; -import com.alibaba.druid.sql.visitor.functions.If; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.distribution.dto.DistributionStockArticleDTO; import com.logpm.distribution.dto.app.DistrilbutionloadingscanDTO; +import com.logpm.distribution.dto.app.StockupDTO; import com.logpm.distribution.entity.*; import com.logpm.distribution.mapper.*; import com.logpm.distribution.service.*; @@ -22,6 +21,7 @@ import org.springblade.common.constant.orderpackage.OrderPackageStatusConstant; import org.springblade.common.constant.order.OrderStatusConstant; import org.springblade.common.constant.reservation.ReservationLoadingStatusConstant; import org.springblade.common.constant.reservation.ReservationSigningStatusConstant; +import org.springblade.common.constant.stockup.StockupStatusConstant; import org.springblade.core.tool.utils.Func; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -29,7 +29,7 @@ import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; import java.util.List; -import java.util.stream.Collectors; +import java.util.concurrent.atomic.AtomicReference; @Log4j2 @@ -47,8 +47,14 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { private final DistributionDeliveryListMapper distributionDeliveryListMapper; private final DistributionSignforMapper distributionSignforMapper; private final DistributionReservationMapper distributionReservationMapper; + private final DistributionReservationPackageMapper distributionReservationPackageMapper; private final DistributionParcelListServiceImpl distributionParcelListService; - + private final DistributionStockupMapper distributionStockupService; + private final DistributionStockupInfoMapper distributionStockupInfoMapper; + private final DistributionReservationStockarticleMapper distributionReservationStockarticleMapper; + private final DistributionReservationStocklistMapper distributionReservationStocklistMapper; + private final DistrilbutionBillStockMapper distrilbutionBillStockMapper; + private final DistributionDeliveryDetailsMapper distributionDeliveryDetailsMapper; private final DistributionParcelListMapper distributionParcelListMapper; @@ -404,6 +410,150 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } } distributionStockArticleService.updateById(stockArticleEntity); + } + + /** + *商 市的扫描修改 部分状态 + * @param stockupDTO + */ + @Override + public void stockupUpdateState(StockupDTO stockupDTO) { + //查询备货状态 + DistributionStockupEntity distributionStockupEntity = distributionStockupService.selectById(stockupDTO.getStockupId()); + if(distributionStockupEntity.getStockupStatus().equals(StockupStatusConstant.beihuozhong.getValue())){ + //备货中 + //判断有几个预约 + List distributionStockupInfoEntities = distributionStockupInfoMapper.selectList(Wrappers.query().lambda() + .eq(DistributionStockupInfoEntity::getStockupId, stockupDTO.getStockupId()) + ); + AtomicReference nu = new AtomicReference<>(0); //全部 + AtomicReference nuy = new AtomicReference<>(0); // 以扫 + AtomicReference ku = new AtomicReference<>(0); // 库 + distributionStockupInfoEntities.forEach( i ->{ + //预约包件 + //查询已扫描的数量 + List list = distributionStockService.selectList(Wrappers.query().lambda() + .eq(DistributionStockEntity::getReservationId, i.getReservationId()) + .eq(DistributionStockEntity::getStockupId, stockupDTO.getStockupId()) + ); + int size = list.size(); + nuy.set(nuy.get() + size); + //查询全部数量 + List distributionReservationStockarticleEntities = distributionReservationStockarticleMapper.selectList(Wrappers.query().lambda() + .eq(DistributionReservationStockarticleEntity::getReservationId, i.getReservationId()) + .apply("stock_article_status in (1,3)") + ); + if(distributionReservationStockarticleEntities.size() > 0 ){ + int sum = distributionReservationStockarticleEntities.stream().mapToInt(DistributionReservationStockarticleEntity::getReservationNum).sum(); + nu.set(nu.get() + sum); + } + + //查询数量库存品 + List distributionReservationStocklistEntities = distributionReservationStocklistMapper.selectList(Wrappers.query().lambda() + .eq(DistributionReservationStocklistEntity::getReservationId, i.getReservationId()) + .apply("stock_list_status in (1,3)") + ); + if(distributionReservationStocklistEntities.size() > 0){ + int sum = distributionReservationStocklistEntities.stream().mapToInt(DistributionReservationStocklistEntity::getReservationNum).sum(); + ku.set(ku.get()+ sum); + } + + }); + + //判断数量 + int i = (nu.get()+ ku.get()) - nuy.get(); + if(i > 0){ + // 有数量 + + }else if (i== 0){ + //修改完成状态 + //修改备货状态 + DistributionStockupEntity distributionStockup = new DistributionStockupEntity(); + distributionStockup.setId(stockupDTO.getStockupId()); + distributionStockup.setStockupStatus(StockupStatusConstant.yibeihuo.getValue()); + distributionStockupService.updateById(distributionStockup); + DistributionReservationEntity reservationEntity = new DistributionReservationEntity(); + reservationEntity.setId(stockupDTO.getReservationId()); + reservationEntity.setStockupStatus(StockupStatusConstant.yibeihuo.getValue()); + distributionReservationMapper.updateById(reservationEntity); + } + + }else { + //没有 + //修改备货状态 + DistributionStockupEntity distributionStockup = new DistributionStockupEntity(); + distributionStockup.setId(stockupDTO.getStockupId()); + distributionStockup.setStockupStatus(StockupStatusConstant.beihuozhong.getValue()); + distributionStockupService.updateById(distributionStockup); + //修改预约状态 + DistributionReservationEntity reservationEntity = new DistributionReservationEntity(); + reservationEntity.setId(stockupDTO.getReservationId()); + reservationEntity.setStockupStatus(StockupStatusConstant.beihuozhong.getValue()); + distributionReservationMapper.updateById(reservationEntity); + } + + } + + /** + * 自提的扫描修改 部分状态 + * @param stockupDTO + */ + @Override + public void stockupSelfUpdateState(StockupDTO stockupDTO) { + DistributionStockupEntity distributionStockupEntity = distributionStockupService.selectById(stockupDTO.getStockupId()); + if(distributionStockupEntity.getStockupStatus().equals(StockupStatusConstant.yibeihuo)){ + //查询全部订单数据 + List distrilbutionBillStockEntities = distrilbutionBillStockMapper.selectList(Wrappers.query().lambda() + .eq(DistrilbutionBillStockEntity::getBillLadingId, stockupDTO.getReservationId()) + .apply("order_status in (1,2)") + ); + //查询包件数据 + AtomicReference nu = new AtomicReference<>(0); //全部包件数据 + distrilbutionBillStockEntities.forEach( i -> { + List distributionParcelListEntities = distributionParcelListMapper.selectList(Wrappers.query().lambda() + .eq(DistributionParcelListEntity::getStockArticleId, i.getStockArticleId()) + ); + int size = distributionParcelListEntities.size(); + nu.set(nu.get()+ size); + }); + + //以备数量 + List list = distributionStockService.selectList(Wrappers.query().lambda() + .eq(DistributionStockEntity::getBillLadingId, stockupDTO.getReservationId()) + ); + + //查询库存品数据 + List detailsEntities = distributionDeliveryDetailsMapper.selectList(Wrappers.query().lambda() + .eq(DistributionDeliveryDetailsEntity::getBillLadingId, stockupDTO.getReservationId()) + .apply("inventory_status in (1,2)") + ); + int sum = detailsEntities.stream().mapToInt(DistributionDeliveryDetailsEntity::getQuantity).sum(); + int i = (sum + nu.get()) - list.size(); + if(i > 0){ + //有数据 + }else if( i == 0){ + //改为已完成 + //修改备货状态 + DistributionStockupEntity distributionStockup = new DistributionStockupEntity(); + distributionStockup.setId(stockupDTO.getStockupId()); + distributionStockup.setStockupStatus(StockupStatusConstant.yibeihuo.getValue()); + distributionStockupService.updateById(distributionStockup); + + + } + }else{ + //修改备货状态 + DistributionStockupEntity distributionStockup = new DistributionStockupEntity(); + distributionStockup.setId(stockupDTO.getStockupId()); + distributionStockup.setStockupStatus(StockupStatusConstant.beihuozhong.getValue()); + distributionStockupService.updateById(distributionStockup); + } + + + + + + } } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java index d91722f46..3fbd9b025 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java @@ -1541,6 +1541,10 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl parcelListOwn = baseMapper.getParcelListOwn(page, Long.parseLong((String) o)); parcelListOwn.getRecords().forEach(i ->{ - i.setStockupStatusName(DictBizCache.getValue(DictBizConstant.STOCKUP_STATUS,i.getStockupStatus())); + if(ObjectUtils.isNotNull(i) && ObjectUtils.isNotNull(i.getStockupStatus())){ + i.setStockupStatusName(DictBizCache.getValue(DictBizConstant.STOCKUP_STATUS,i.getStockupStatus())); + } }); return parcelListOwn; } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java index aa0c6d84f..b1a600eb3 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java @@ -254,6 +254,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl initTotal = new AtomicReference<>(BigDecimal.ZERO); //存在订单构建预约订单关联信息 if (!Func.isEmpty(stockArticleList)) { + boolean flag = stockArticleList.stream().anyMatch(s -> s.getReservationStatus().equals(OrderReservationStatusConstant.yiyueyue.getValue())); + if (flag){ + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + log.error("预约选择订单被多次预约"); + return R.fail("订单已预约!!!"); + } //存在订单的情况下才会对预约和包件的关系进行维护 //选择了订单但是未进行包件的选择,默认选择了订单下的所有在库包件 stockArticleList.forEach(s -> { @@ -542,6 +549,11 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl warehouseNames = new HashSet<>(); @@ -1220,6 +1235,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl stockArticle = allocationDTO.getStockArticle(); - - //根据运单号进行分组 //TODO 这里先根据运单号进行运单信息查询,后期根据运单进行 Map> mallClient = stockArticle.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getWaybillNumber)); @@ -1279,6 +1294,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl s.getReservationStatus().equals(OrderReservationStatusConstant.yiyueyue.getValue())); + if (flag){ + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + log.error("预约选择订单被多次预约"); + return R.fail("订单已预约!!!"); + } stockArticleList.forEach(s -> { // storeName.add(s.getStoreName()); // mallName.add(s.getMallName()); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java index fb07de143..607f02a36 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java @@ -127,6 +127,9 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl selectDistributionStockupPage(IPage page, DistributionStockupVO distributionStockup) { @@ -584,8 +587,10 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl detailOrderOwn(IPage page, Long id) { IPage distributionStockupVOIPage = baseMapper.detailOrderOwn(page, id); distributionStockupVOIPage.getRecords().forEach(o -> { - Integer integer = distributionStockService.selectCount(Long.parseLong(o.getStockArticleId())); - o.setNumber(integer); + if(ObjectUtils.isNotNull(o.getStockArticleId())){ + Integer integer = distributionStockService.selectCount(Long.parseLong(o.getStockArticleId())); + o.setNumber(integer); + } }); return distributionStockupVOIPage; } @@ -844,11 +849,10 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl