Browse Source

Merge branch 'dev' into pre-production

dev-pushdata-important
pref_mail@163.com 1 year ago
parent
commit
f44a35302b
  1. 128
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java

128
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<Distrilb
return distrilbutionBillLadingList;
}
//修改自提单订单数据
@Transactional
public void updateOrder(DistrilbutionBillLadingDTO distrilbutionBillLading){
DistrilbutionBillLadingEntity billLadingEntity = baseMapper.selectById(distrilbutionBillLading.getId());
if(ObjectUtils.isNotNull(billLadingEntity) && "20".equals(billLadingEntity.getConditions())){
throw new ServiceException("已提货,暂不支持取消订单!!");
}
//查询全部订单
List<DistrilbutionBillStockEntity> list = distrilbutionBillStockService.list(Wrappers.<DistrilbutionBillStockEntity>query().lambda()
.eq(DistrilbutionBillStockEntity::getBillLadingId, distrilbutionBillLading.getId())
.apply("order_status in (1 , 2)")
);
//查询全部包件
List<DistrilbutionBillPackageEntity> listPackage = distrilbutionBillPackageService.list(Wrappers.<DistrilbutionBillPackageEntity>query().lambda()
.eq(DistrilbutionBillPackageEntity::getBillLadingId, distrilbutionBillLading.getId())
.apply("packet_bar_status in ( 1, 3)")
);
List<Long> orderList = new ArrayList<>();
List<Long> packageList = new ArrayList<>();
if(!list.isEmpty()){
list.forEach(i ->{
if("2".equals(i.getConditions())){
throw new ServiceException("包含已提货的订单,不能取消全部订单");
}
//取消订单预约信息
orderList.add(i.getStockArticleId());
List<Long> collect = listPackage.stream().filter(a -> a.getStockArticleId().equals(i.getStockArticleId())).map(DistrilbutionBillPackageEntity::getParceListId).collect(Collectors.toList());
packageList.addAll(collect);
});
try{
//修改订单状态
if(!orderList.isEmpty()){
LambdaUpdateWrapper<DistributionStockArticleEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(DistributionStockArticleEntity::getId,orderList);
updateWrapper.set(DistributionStockArticleEntity::getReservationStatus,OrderReservationStatusConstant.bufenyuyue.getValue());
distributionStockArticleService.update(updateWrapper);
LambdaUpdateWrapper<DistrilbutionBillStockEntity> updateWrapper1 = new LambdaUpdateWrapper<>();
updateWrapper1.in(DistrilbutionBillStockEntity::getStockArticleId,orderList);
updateWrapper1.set(DistrilbutionBillStockEntity::getOrderStatus,"3");
distrilbutionBillStockService.update(updateWrapper1);
}
//修改包件预约状态
if(!packageList.isEmpty()){
LambdaUpdateWrapper<DistributionParcelListEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(DistributionParcelListEntity::getId,packageList);
updateWrapper.set(DistributionParcelListEntity::getOrderPackageReservationStatus,OrderPackageReservationStatusConstant.daiyuyue.getValue());
distributionParcelListService.update(updateWrapper);
LambdaUpdateWrapper<DistrilbutionBillPackageEntity> 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<DistributionDeliveryDetailsEntity> list = distributionDeliveryDetailsService.list(Wrappers.<DistributionDeliveryDetailsEntity>query().lambda()
.eq(DistributionDeliveryDetailsEntity::getBillLadingId, distrilbutionBillLading.getId())
.apply("inventory_status in ( 1 , 2)")
);
List<DistributionStockListEntity> stockEntityList = new ArrayList<>();
List<Long> 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<DistributionDeliveryDetailsEntity> 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<Distrilb
if (!order) {
throw new ServiceException("修改失败!!");
}
}else{
updateOrder(distrilbutionBillLading);
}
if(distrilbutionBillLading.getStockArticleList().isEmpty() && distrilbutionBillLading.getStockDTOList().isEmpty()){
//取消全部订单
updateOrder(distrilbutionBillLading);
updateStockBill(distrilbutionBillLading);
//取消自提任务
baseMapper.deleteById(billLadingEntity.getId());
}
//修改库存品
if (!distrilbutionBillLading.getStockDTOList().isEmpty()) {
@ -304,6 +423,8 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
});
}
}
}else{
updateStockBill(distrilbutionBillLading);
}
} else {
//设置lockey
@ -573,14 +694,9 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
if(i.getParceListId().equals(next.getParceListId())){
//存在
iterator.remove();
// cz = true;
// continue;
}
}
// if(!cz){
// //删除
// sc.add(i.getId());
// }
});
//新增包件

Loading…
Cancel
Save