|
|
|
@ -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<DistributionStockupInfoEntity> distributionStockupInfoEntities = distributionStockupInfoMapper.selectList(Wrappers.<DistributionStockupInfoEntity>query().lambda() |
|
|
|
|
.eq(DistributionStockupInfoEntity::getStockupId, stockupDTO.getStockupId()) |
|
|
|
|
); |
|
|
|
|
AtomicReference<Integer> nu = new AtomicReference<>(0); //全部
|
|
|
|
|
AtomicReference<Integer> nuy = new AtomicReference<>(0); // 以扫
|
|
|
|
|
AtomicReference<Integer> ku = new AtomicReference<>(0); // 库
|
|
|
|
|
distributionStockupInfoEntities.forEach( i ->{ |
|
|
|
|
//预约包件
|
|
|
|
|
//查询已扫描的数量
|
|
|
|
|
List<DistributionStockEntity> list = distributionStockService.selectList(Wrappers.<DistributionStockEntity>query().lambda() |
|
|
|
|
.eq(DistributionStockEntity::getReservationId, i.getReservationId()) |
|
|
|
|
.eq(DistributionStockEntity::getStockupId, stockupDTO.getStockupId()) |
|
|
|
|
); |
|
|
|
|
int size = list.size(); |
|
|
|
|
nuy.set(nuy.get() + size); |
|
|
|
|
//查询全部数量
|
|
|
|
|
List<DistributionReservationStockarticleEntity> distributionReservationStockarticleEntities = distributionReservationStockarticleMapper.selectList(Wrappers.<DistributionReservationStockarticleEntity>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<DistributionReservationStocklistEntity> distributionReservationStocklistEntities = distributionReservationStocklistMapper.selectList(Wrappers.<DistributionReservationStocklistEntity>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<DistrilbutionBillStockEntity> distrilbutionBillStockEntities = distrilbutionBillStockMapper.selectList(Wrappers.<DistrilbutionBillStockEntity>query().lambda() |
|
|
|
|
.eq(DistrilbutionBillStockEntity::getBillLadingId, stockupDTO.getReservationId()) |
|
|
|
|
.apply("order_status in (1,2)") |
|
|
|
|
); |
|
|
|
|
//查询包件数据
|
|
|
|
|
AtomicReference<Integer> nu = new AtomicReference<>(0); //全部包件数据
|
|
|
|
|
distrilbutionBillStockEntities.forEach( i -> { |
|
|
|
|
List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListMapper.selectList(Wrappers.<DistributionParcelListEntity>query().lambda() |
|
|
|
|
.eq(DistributionParcelListEntity::getStockArticleId, i.getStockArticleId()) |
|
|
|
|
); |
|
|
|
|
int size = distributionParcelListEntities.size(); |
|
|
|
|
nu.set(nu.get()+ size); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//以备数量
|
|
|
|
|
List<DistributionStockEntity> list = distributionStockService.selectList(Wrappers.<DistributionStockEntity>query().lambda() |
|
|
|
|
.eq(DistributionStockEntity::getBillLadingId, stockupDTO.getReservationId()) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
//查询库存品数据
|
|
|
|
|
List<DistributionDeliveryDetailsEntity> detailsEntities = distributionDeliveryDetailsMapper.selectList(Wrappers.<DistributionDeliveryDetailsEntity>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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|