|
|
|
@ -35,6 +35,8 @@ import com.logpm.distribution.wrapper.DistributionParcelListWrapper;
|
|
|
|
|
import com.logpm.distribution.wrapper.DistributionReservationWrapper; |
|
|
|
|
import com.logpm.distribution.wrapper.DistributionStockArticleWrapper; |
|
|
|
|
import com.logpm.distribution.wrapper.DistributionStockListWrapper; |
|
|
|
|
import com.logpm.warehouse.entity.WarehouseWaybillEntity; |
|
|
|
|
import com.logpm.warehouse.feign.IWarehouseWaybillClient; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.common.constant.DistributionTypeConstant; |
|
|
|
|
import org.springblade.common.constant.delivery.DeliveryStatusConstant; |
|
|
|
@ -151,6 +153,14 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
@Autowired |
|
|
|
|
private BladeRedis bladeRedis; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IDistributionAsyncService distributionAsyncService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IWarehouseWaybillClient warehouseWaybillClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<DistributionReservationVO> selectDistrbutionReservationPage(IPage<DistributionReservationVO> page, DistributionReservationVO distrbutionReservation) { |
|
|
|
@ -959,10 +969,10 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
distributionReservationStockarticleService.updateById(reservationStockarticleEntity); |
|
|
|
|
packTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); |
|
|
|
|
oldStockArticle.remove(k); |
|
|
|
|
String status = distributionReservationPackageService.judgmentStatus(distributionStockArticleDTO); |
|
|
|
|
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionStockArticleDTO.getId()); |
|
|
|
|
stockArticleEntity.setReservationStatus(status); |
|
|
|
|
distributionStockArticleService.updateById(stockArticleEntity); |
|
|
|
|
distributionAsyncService.changeOrderReservationStatus(distributionStockArticleDTO); |
|
|
|
|
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionStockArticleDTO.getId());
|
|
|
|
|
// stockArticleEntity.setReservationStatus(status);
|
|
|
|
|
// distributionStockArticleService.updateById(stockArticleEntity);
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
oldStockArticle.forEach((i, j) -> { |
|
|
|
@ -978,11 +988,15 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue()); |
|
|
|
|
distributionParcelListService.updateById(parcelListEntity); |
|
|
|
|
}); |
|
|
|
|
//需要修改订单的状态
|
|
|
|
|
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(i); |
|
|
|
|
DistributionStockArticleDTO stockArticleDTO = Func.copy(stockArticleEntity, DistributionStockArticleDTO.class); |
|
|
|
|
String status = distributionReservationPackageService.judgmentStatus(stockArticleDTO); |
|
|
|
|
stockArticleEntity.setReservationStatus(status); |
|
|
|
|
reservationStockarticleEntity.setStockArticleStatus(ReservationOrderStatusConstant.quxiao.getValue()); |
|
|
|
|
//这里需要根据包件状态进行订单状态的修改
|
|
|
|
|
//这里异步查看该订单下的包件信息是否都处于预约状态,如果不是那么为订单预约装填,部分那么订单为部分预约,没有那么订单处于待预约状态
|
|
|
|
|
distributionAsyncService.changeOrderReservationStatus(stockArticleDTO); |
|
|
|
|
// String status = distributionReservationPackageService.judgmentStatus(stockArticleDTO);
|
|
|
|
|
// stockArticleEntity.setReservationStatus(status);
|
|
|
|
|
// reservationStockarticleEntity.setStockArticleStatus(ReservationOrderStatusConstant.quxiao.getValue());
|
|
|
|
|
distributionReservationStockarticleService.updateById(reservationStockarticleEntity); |
|
|
|
|
}); |
|
|
|
|
//库存品修改
|
|
|
|
@ -1113,136 +1127,128 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
distributionDeliveryListService.save(distributionDeliveryListEntity); |
|
|
|
|
//获取所有订单
|
|
|
|
|
List<DistributionStockArticleDTO> stockArticle = allocationDTO.getStockArticle(); |
|
|
|
|
//根据门店进行分组
|
|
|
|
|
Map<String, List<DistributionStockArticleDTO>> storeClient = stockArticle.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getStoreName)); |
|
|
|
|
List<DistributionStockArticleDTO> distributionStockArticleDTOS = storeClient.get(""); |
|
|
|
|
Map<String, List<DistributionStockArticleDTO>> mallClient = null; |
|
|
|
|
if (!Func.isEmpty(distributionStockArticleDTOS)) { |
|
|
|
|
mallClient = distributionStockArticleDTOS.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getMallName)); |
|
|
|
|
//3、维护订单和客户
|
|
|
|
|
Map<String, List<DistributionStockArticleDTO>> finalMallClient = mallClient; |
|
|
|
|
storeClient.forEach((k, v) -> finalMallClient.merge(k, v, (v1, v2) -> v2)); |
|
|
|
|
} else { |
|
|
|
|
mallClient = storeClient; |
|
|
|
|
} |
|
|
|
|
//统计客户数.
|
|
|
|
|
AtomicInteger clientNum = new AtomicInteger(); |
|
|
|
|
// ////统计包件总数
|
|
|
|
|
// AtomicInteger packageTotal = new AtomicInteger();
|
|
|
|
|
////统计包件总数
|
|
|
|
|
AtomicInteger orderTotal = new AtomicInteger(); |
|
|
|
|
//订单拼接
|
|
|
|
|
// StringBuilder orderSelfNumbering = new StringBuilder();
|
|
|
|
|
HashSet<String> orderNumber = new HashSet<>(); |
|
|
|
|
HashSet<String> orderIds = new HashSet<>(); |
|
|
|
|
HashSet<String> serviceNumber = new HashSet<>(); |
|
|
|
|
HashSet<String> warehouseName = new HashSet<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据运单号进行分组
|
|
|
|
|
//TODO 这里先根据运单号进行运单信息查询,后期根据运单进行
|
|
|
|
|
Map<String, List<DistributionStockArticleDTO>> mallClient = stockArticle.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getWaybillNumber)); |
|
|
|
|
//配送任务仓库名称
|
|
|
|
|
HashSet<String> deliveryWarehouseName = new HashSet<>(); |
|
|
|
|
HashSet<String> mallName = new HashSet<>(); |
|
|
|
|
HashSet<String> storeName = new HashSet<>(); |
|
|
|
|
mallClient.forEach((k, v) -> { |
|
|
|
|
if (!Func.isBlank(k)) { |
|
|
|
|
////统计客户数
|
|
|
|
|
//预约任务是在客户的维度上进行数据维护
|
|
|
|
|
//TODO 这里需要将运单上的收货人、联系电话、收获地址进行查询后进行数据冗余
|
|
|
|
|
DistributionReservationDTO reservation = allocationDTO.getReservation(); |
|
|
|
|
DistributionReservationEntity reservationEntity = Func.copy(reservation, DistributionReservationEntity.class); |
|
|
|
|
Date date = new Date(); |
|
|
|
|
reservationEntity.setReservationDate(date); |
|
|
|
|
reservationEntity.setConsignee(k); |
|
|
|
|
reservationEntity.setDeliveryAddress(v.get(0).getCustomerAddress()); |
|
|
|
|
reservationEntity.setDeliveryPhone(v.get(0).getCustomerTelephone()); |
|
|
|
|
reservationEntity.setDeliveryType(DistributionTypeConstant.shangpei.getValue()); |
|
|
|
|
reservationEntity.setReservationStatus(ReservationStatusConstant.daipeisong.getValue()); |
|
|
|
|
reservationEntity.setStockupStatus(ReservationStockupStatusConstant.daibeihuo.getValue()); |
|
|
|
|
reservationEntity.setReservationCode(Func.random(13, RandomType.INT)); |
|
|
|
|
//默认配送时间为全天
|
|
|
|
|
reservationEntity.setPeriodOfTime(ServiceConstant.RESERVATION_PERIOED_TIME_DAY); |
|
|
|
|
this.save(reservationEntity); |
|
|
|
|
clientNum.getAndIncrement(); |
|
|
|
|
//维护预约和备货的关系
|
|
|
|
|
DistributionStockupInfoEntity stockupInfoEntity = new DistributionStockupInfoEntity(); |
|
|
|
|
stockupInfoEntity.setStockUpType(StockupTypeConstant.shangpei.getValue()); |
|
|
|
|
stockupInfoEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
stockupInfoEntity.setStockupId(stockupEntity.getId()); |
|
|
|
|
distributionStockupInfoService.save(stockupInfoEntity); |
|
|
|
|
// TODO 计算总费用
|
|
|
|
|
// AtomicReference<BigDecimal> initTotal = new AtomicReference<>(BigDecimal.ZERO);
|
|
|
|
|
//统计包件数量
|
|
|
|
|
AtomicInteger packageTotal = new AtomicInteger(); |
|
|
|
|
v.forEach(a -> { |
|
|
|
|
orderTotal.getAndIncrement(); |
|
|
|
|
DistributionStockArticleDTO stockArticleEntity = Func.copy(a, DistributionStockArticleDTO.class); |
|
|
|
|
// if (stockArticleEntity.getMallId() == -1) {
|
|
|
|
|
// stockArticleEntity.setMallId(null);
|
|
|
|
|
// }
|
|
|
|
|
// if (stockArticleEntity.getStoreId() == -1) {
|
|
|
|
|
// stockArticleEntity.setStoreId(null);
|
|
|
|
|
// }
|
|
|
|
|
warehouseName.add(stockArticleEntity.getWarehouse()); |
|
|
|
|
mallName.add(stockArticleEntity.getMallName()); |
|
|
|
|
storeName.add(stockArticleEntity.getStoreName()); |
|
|
|
|
//维护订单数据,订单状态直接变更未待配送
|
|
|
|
|
// stockArticleEntity.setOrderStatus();
|
|
|
|
|
// distributionStockArticleService.updateById(stockArticleEntity);
|
|
|
|
|
orderNumber.add(stockArticleEntity.getOrderCode()); |
|
|
|
|
serviceNumber.add(stockArticleEntity.getServiceNumber()); |
|
|
|
|
// orderSelfNumbering.append().append(",");
|
|
|
|
|
//订单数量累加
|
|
|
|
|
AtomicInteger packageNum = new AtomicInteger(); |
|
|
|
|
//订单存在数据源,维护订单包件信息
|
|
|
|
|
//维护预约和订单关系
|
|
|
|
|
DistributionReservationStockarticleEntity reservationStockarticleEntity = new DistributionReservationStockarticleEntity(); |
|
|
|
|
List<DistributionParcelListEntity> packageList = a.getPackageListInfo(); |
|
|
|
|
if (Func.isNotEmpty(packageList) || packageList.size() > 0) { |
|
|
|
|
packageList.forEach(p -> { |
|
|
|
|
packageNum.getAndAdd(p.getQuantity()); |
|
|
|
|
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity(); |
|
|
|
|
reservationPackageEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
reservationPackageEntity.setPacketBarCode(p.getOrderPackageCode()); |
|
|
|
|
reservationPackageEntity.setStockArticleId(stockArticleEntity.getId()); |
|
|
|
|
reservationPackageEntity.setParceListId(p.getId()); |
|
|
|
|
distributionReservationPackageService.save(reservationPackageEntity); |
|
|
|
|
p.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); |
|
|
|
|
distributionParcelListService.updateById(p); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
log.error("packageList包件参数有误+{" + packageList + "}"); |
|
|
|
|
} |
|
|
|
|
String status = distributionReservationPackageService.judgmentStatus(stockArticleEntity); |
|
|
|
|
stockArticleEntity.setReservationStatus(status); |
|
|
|
|
distributionStockArticleService.updateById(stockArticleEntity); |
|
|
|
|
//查询出这个预约单下订单所备选取的包件数量
|
|
|
|
|
// List<DistributionParcelListEntity> parcelListEntityList = distributionReservationStocklistMapper.selectReservationPackageNum(reservationEntity.getId(), stockArticleEntity.getId());
|
|
|
|
|
// if (packageList.size() != parcelListEntityList.size()) {
|
|
|
|
|
// stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue());
|
|
|
|
|
// } else {
|
|
|
|
|
// stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue());
|
|
|
|
|
// }
|
|
|
|
|
reservationStockarticleEntity.setReservationNum(packageNum.get()); |
|
|
|
|
reservationStockarticleEntity.setIsHaveData(ServiceConstant.ORDER_HAVE_DATA); |
|
|
|
|
//对订单下的包件进行累加
|
|
|
|
|
reservationStockarticleEntity.setStockArticleId(stockArticleEntity.getId()); |
|
|
|
|
reservationStockarticleEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
distributionReservationStockarticleService.save(reservationStockarticleEntity); |
|
|
|
|
packageTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); |
|
|
|
|
}); |
|
|
|
|
//这里将预约信息进行完善
|
|
|
|
|
reservationEntity.setStockArticleId(String.join(",", orderNumber)); |
|
|
|
|
reservationEntity.setServiceNumber(String.join(",", serviceNumber)); |
|
|
|
|
reservationEntity.setWarehouseName(String.join(",", warehouseName)); |
|
|
|
|
reservationEntity.setMallName(String.join(",", mallName)); |
|
|
|
|
reservationEntity.setStoreName(String.join(",", storeName)); |
|
|
|
|
//预约添加订单数量
|
|
|
|
|
reservationEntity.setReservationNum(packageTotal.get()); |
|
|
|
|
this.updateById(reservationEntity); |
|
|
|
|
DistributionSignforEntity distributionSignforEntity = new DistributionSignforEntity(); |
|
|
|
|
distributionSignforEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
distributionSignforEntity.setTrainNumber(str); |
|
|
|
|
distributionSignforEntity.setDeliveryId(distributionDeliveryListEntity.getId()); |
|
|
|
|
distributionSignforService.save(distributionSignforEntity); |
|
|
|
|
deliveryWarehouseName.add(reservationEntity.getWarehouseName()); |
|
|
|
|
} |
|
|
|
|
//订单总数量
|
|
|
|
|
AtomicInteger orderTotal = new AtomicInteger(); |
|
|
|
|
//客户数量
|
|
|
|
|
AtomicInteger clientTotal = new AtomicInteger(); |
|
|
|
|
|
|
|
|
|
//查询运单信息
|
|
|
|
|
//收货单位
|
|
|
|
|
mallClient.forEach((k,v)->{ |
|
|
|
|
clientTotal.getAndIncrement(); |
|
|
|
|
// AtomicInteger receivingUnit = new AtomicInteger();
|
|
|
|
|
WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(k); |
|
|
|
|
DistributionReservationDTO reservation = allocationDTO.getReservation(); |
|
|
|
|
DistributionReservationEntity reservationEntity = Func.copy(reservation, DistributionReservationEntity.class); |
|
|
|
|
reservationEntity.setReservationStatus(ReservationStatusConstant.daipeisong.getValue()); |
|
|
|
|
reservationEntity.setConsignee(warehouseWaybillEntity.getConsigneeName()); |
|
|
|
|
reservationEntity.setDeliveryPhone(warehouseWaybillEntity.getConsigneeMobile()); |
|
|
|
|
reservationEntity.setDeliveryAddress(warehouseWaybillEntity.getConsigneeAddress()); |
|
|
|
|
reservationEntity.setReceivingUnit(warehouseWaybillEntity.getConsignee()); |
|
|
|
|
this.save(reservationEntity); |
|
|
|
|
//预约单信息构建
|
|
|
|
|
//订单号
|
|
|
|
|
HashSet<String> orderNumber = new HashSet<>(); |
|
|
|
|
//运单号
|
|
|
|
|
HashSet<String> waybillNo = new HashSet<>(); |
|
|
|
|
//运单ID
|
|
|
|
|
HashSet<Long> waybillId = new HashSet<>(); |
|
|
|
|
//订单服务号
|
|
|
|
|
HashSet<String> serviceNumber = new HashSet<>(); |
|
|
|
|
//仓库名称
|
|
|
|
|
HashSet<String> warehouseName = new HashSet<>(); |
|
|
|
|
//经销商名称
|
|
|
|
|
HashSet<String> mallName = new HashSet<>(); |
|
|
|
|
//门店名称
|
|
|
|
|
HashSet<String> storeName = new HashSet<>(); |
|
|
|
|
//包件总数量
|
|
|
|
|
AtomicInteger packageTotal = new AtomicInteger(); |
|
|
|
|
v.forEach(s->{ |
|
|
|
|
//预约单数据填充
|
|
|
|
|
if (Func.isNotEmpty(s.getMallName())){ |
|
|
|
|
mallName.add(s.getMallName()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(s.getStoreName())){ |
|
|
|
|
storeName.add(s.getStoreName()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(s.getOrderCode())){ |
|
|
|
|
orderNumber.add(s.getOrderCode()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(s.getWaybillNumber())){ |
|
|
|
|
waybillNo.add(s.getWaybillNumber()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(s.getWarehouse())){ |
|
|
|
|
warehouseName.add(s.getWarehouse()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(s.getWaybillId())){ |
|
|
|
|
waybillId.add(s.getWaybillId()); |
|
|
|
|
} |
|
|
|
|
DistributionReservationStockarticleEntity reservationStockarticleEntity = new DistributionReservationStockarticleEntity(); |
|
|
|
|
//现在前端进行订单提交必然会携带包件信息
|
|
|
|
|
List<DistributionParcelListEntity> packageListInfo = s.getPackageListInfo(); |
|
|
|
|
AtomicInteger orderPackageNum = new AtomicInteger(); |
|
|
|
|
if (packageListInfo.size()>0){ |
|
|
|
|
packageListInfo.forEach(p->{ |
|
|
|
|
orderPackageNum.getAndAdd(p.getQuantity()); |
|
|
|
|
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity(); |
|
|
|
|
reservationPackageEntity.setPacketBarStatus(ReservationPackageStatusConstant.zhengchang.getValue()); |
|
|
|
|
reservationPackageEntity.setPacketBarCode(p.getOrderPackageCode()); |
|
|
|
|
reservationPackageEntity.setStockArticleId(s.getId()); |
|
|
|
|
reservationPackageEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
reservationPackageEntity.setParceListId(p.getId()); |
|
|
|
|
distributionReservationPackageService.save(reservationPackageEntity); |
|
|
|
|
p.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); |
|
|
|
|
distributionParcelListService.updateById(p); |
|
|
|
|
//这里根据包件进行订单状态的改变
|
|
|
|
|
distributionAsyncService.checkStockArticleReservationStatus(p); |
|
|
|
|
}); |
|
|
|
|
}else { |
|
|
|
|
log.error("订单包件参数有误+{"+packageListInfo+"}"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
reservationStockarticleEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
reservationStockarticleEntity.setReservationNum(orderPackageNum.get()); |
|
|
|
|
reservationStockarticleEntity.setStockArticleStatus(ReservationOrderStatusConstant.zhengchang.getValue()); |
|
|
|
|
reservationStockarticleEntity.setStockArticleCode(s.getStockArticleCode()); |
|
|
|
|
reservationStockarticleEntity.setStockArticleId(s.getId()); |
|
|
|
|
reservationStockarticleEntity.setIsHaveData(s.getIsHaveData()); |
|
|
|
|
distributionReservationStockarticleService.save(reservationStockarticleEntity); |
|
|
|
|
packageTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); |
|
|
|
|
orderTotal.getAndDecrement(); |
|
|
|
|
}); |
|
|
|
|
//维护备货任务
|
|
|
|
|
DistributionStockupInfoEntity stockupInfoEntity = new DistributionStockupInfoEntity(); |
|
|
|
|
stockupInfoEntity.setStockUpType(StockupTypeConstant.shangpei.getValue()); |
|
|
|
|
stockupInfoEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
stockupInfoEntity.setStockupId(stockupEntity.getId()); |
|
|
|
|
distributionStockupInfoService.save(stockupInfoEntity); |
|
|
|
|
|
|
|
|
|
//这里将预约信息进行完善
|
|
|
|
|
reservationEntity.setDeliveryType(DistributionTypeConstant.shangpei.getValue()); |
|
|
|
|
reservationEntity.setStockupStatus(ReservationStockupStatusConstant.daibeihuo.getValue()); |
|
|
|
|
reservationEntity.setPeriodOfTime(ServiceConstant.RESERVATION_PERIOED_TIME_DAY); |
|
|
|
|
reservationEntity.setStockArticleId(String.join(",", orderNumber)); |
|
|
|
|
reservationEntity.setServiceNumber(String.join(",", serviceNumber)); |
|
|
|
|
reservationEntity.setWarehouseName(String.join(",", warehouseName)); |
|
|
|
|
reservationEntity.setMallName(String.join(",", mallName)); |
|
|
|
|
reservationEntity.setStoreName(String.join(",", storeName)); |
|
|
|
|
//预约添加订单数量
|
|
|
|
|
reservationEntity.setReservationNum(packageTotal.get()); |
|
|
|
|
this.updateById(reservationEntity); |
|
|
|
|
|
|
|
|
|
DistributionSignforEntity distributionSignforEntity = new DistributionSignforEntity(); |
|
|
|
|
distributionSignforEntity.setReservationId(reservationEntity.getId()); |
|
|
|
|
distributionSignforEntity.setTrainNumber(str); |
|
|
|
|
distributionSignforEntity.setDeliveryId(distributionDeliveryListEntity.getId()); |
|
|
|
|
distributionSignforService.save(distributionSignforEntity); |
|
|
|
|
deliveryWarehouseName.add(reservationEntity.getWarehouseName()); |
|
|
|
|
}); |
|
|
|
|
//判断是否为自主配送
|
|
|
|
|
//车牌号拼接
|
|
|
|
@ -1295,27 +1301,189 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String taskTime = allocationDTO.getTaskTime(); |
|
|
|
|
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// Date parse = null;
|
|
|
|
|
// try {
|
|
|
|
|
// parse = format.parse(taskTime);
|
|
|
|
|
// } catch (ParseException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// distributionDeliveryListEntity.setTaskTime(taskTime);
|
|
|
|
|
//完善配送信息
|
|
|
|
|
if (!Func.isEmpty(taskTime)) { |
|
|
|
|
distributionDeliveryListEntity.setTaskTime(taskTime); |
|
|
|
|
} |
|
|
|
|
distributionDeliveryListEntity.setWarehouseName(String.join(",", deliveryWarehouseName)); |
|
|
|
|
distributionDeliveryListEntity.setOrderCode(String.join(",", orderNumber)); |
|
|
|
|
// distributionDeliveryListEntity.setOrderCode(String.join(",", orderNumber));
|
|
|
|
|
distributionDeliveryListEntity.setOrderNumber(orderTotal.get()); |
|
|
|
|
distributionDeliveryListEntity.setNoteNumber(Func.random(13, RandomType.INT)); |
|
|
|
|
distributionDeliveryListEntity.setCustomersNumber(clientNum.get()); |
|
|
|
|
distributionDeliveryListEntity.setCustomersNumber(clientTotal.get()); |
|
|
|
|
distributionDeliveryListService.updateById(distributionDeliveryListEntity); |
|
|
|
|
return R.status(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //根据门店进行分组
|
|
|
|
|
// Map<String, List<DistributionStockArticleDTO>> storeClient = stockArticle.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getStoreName));
|
|
|
|
|
// List<DistributionStockArticleDTO> distributionStockArticleDTOS = storeClient.get("");
|
|
|
|
|
// Map<String, List<DistributionStockArticleDTO>> mallClient = null;
|
|
|
|
|
// if (!Func.isEmpty(distributionStockArticleDTOS)) {
|
|
|
|
|
// mallClient = distributionStockArticleDTOS.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getMallName));
|
|
|
|
|
// //3、维护订单和客户
|
|
|
|
|
// Map<String, List<DistributionStockArticleDTO>> finalMallClient = mallClient;
|
|
|
|
|
// storeClient.forEach((k, v) -> finalMallClient.merge(k, v, (v1, v2) -> v2));
|
|
|
|
|
// } else {
|
|
|
|
|
// mallClient = storeClient;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //统计客户数.
|
|
|
|
|
// AtomicInteger clientNum = new AtomicInteger();
|
|
|
|
|
//// ////统计包件总数
|
|
|
|
|
//// AtomicInteger packageTotal = new AtomicInteger();
|
|
|
|
|
// ////统计包件总数
|
|
|
|
|
// AtomicInteger orderTotal = new AtomicInteger();
|
|
|
|
|
// //订单拼接
|
|
|
|
|
//// StringBuilder orderSelfNumbering = new StringBuilder();
|
|
|
|
|
// HashSet<String> orderNumber = new HashSet<>();
|
|
|
|
|
// HashSet<String> orderIds = new HashSet<>();
|
|
|
|
|
// HashSet<String> serviceNumber = new HashSet<>();
|
|
|
|
|
// HashSet<String> warehouseName = new HashSet<>();
|
|
|
|
|
// HashSet<String> deliveryWarehouseName = new HashSet<>();
|
|
|
|
|
// HashSet<String> mallName = new HashSet<>();
|
|
|
|
|
// HashSet<String> storeName = new HashSet<>();
|
|
|
|
|
// mallClient.forEach((k, v) -> {
|
|
|
|
|
// if (!Func.isBlank(k)) {
|
|
|
|
|
// ////统计客户数
|
|
|
|
|
// //预约任务是在客户的维度上进行数据维护
|
|
|
|
|
// //TODO 这里需要将运单上的收货人、联系电话、收获地址进行查询后进行数据冗余
|
|
|
|
|
// DistributionReservationDTO reservation = allocationDTO.getReservation();
|
|
|
|
|
// DistributionReservationEntity reservationEntity = Func.copy(reservation, DistributionReservationEntity.class);
|
|
|
|
|
// Date date = new Date();
|
|
|
|
|
// reservationEntity.setReservationDate(date);
|
|
|
|
|
// reservationEntity.setConsignee(k);
|
|
|
|
|
// reservationEntity.setDeliveryAddress(v.get(0).getCustomerAddress());
|
|
|
|
|
// reservationEntity.setDeliveryPhone(v.get(0).getCustomerTelephone());
|
|
|
|
|
// reservationEntity.setDeliveryType(DistributionTypeConstant.shangpei.getValue());
|
|
|
|
|
// reservationEntity.setReservationStatus(ReservationStatusConstant.daipeisong.getValue());
|
|
|
|
|
// reservationEntity.setStockupStatus(ReservationStockupStatusConstant.daibeihuo.getValue());
|
|
|
|
|
// reservationEntity.setReservationCode(Func.random(13, RandomType.INT));
|
|
|
|
|
// //默认配送时间为全天
|
|
|
|
|
// reservationEntity.setPeriodOfTime(ServiceConstant.RESERVATION_PERIOED_TIME_DAY);
|
|
|
|
|
// this.save(reservationEntity);
|
|
|
|
|
// clientNum.getAndIncrement();
|
|
|
|
|
// //维护预约和备货的关系
|
|
|
|
|
// DistributionStockupInfoEntity stockupInfoEntity = new DistributionStockupInfoEntity();
|
|
|
|
|
// stockupInfoEntity.setStockUpType(StockupTypeConstant.shangpei.getValue());
|
|
|
|
|
// stockupInfoEntity.setReservationId(reservationEntity.getId());
|
|
|
|
|
// stockupInfoEntity.setStockupId(stockupEntity.getId());
|
|
|
|
|
// distributionStockupInfoService.save(stockupInfoEntity);
|
|
|
|
|
// // TODO 计算总费用
|
|
|
|
|
//// AtomicReference<BigDecimal> initTotal = new AtomicReference<>(BigDecimal.ZERO);
|
|
|
|
|
// //统计包件数量
|
|
|
|
|
// AtomicInteger packageTotal = new AtomicInteger();
|
|
|
|
|
// v.forEach(a -> {
|
|
|
|
|
// orderTotal.getAndIncrement();
|
|
|
|
|
// DistributionStockArticleDTO stockArticleEntity = Func.copy(a, DistributionStockArticleDTO.class);
|
|
|
|
|
//// if (stockArticleEntity.getMallId() == -1) {
|
|
|
|
|
//// stockArticleEntity.setMallId(null);
|
|
|
|
|
//// }
|
|
|
|
|
//// if (stockArticleEntity.getStoreId() == -1) {
|
|
|
|
|
//// stockArticleEntity.setStoreId(null);
|
|
|
|
|
//// }
|
|
|
|
|
// warehouseName.add(stockArticleEntity.getWarehouse());
|
|
|
|
|
// mallName.add(stockArticleEntity.getMallName());
|
|
|
|
|
// storeName.add(stockArticleEntity.getStoreName());
|
|
|
|
|
// //维护订单数据,订单状态直接变更未待配送
|
|
|
|
|
//// stockArticleEntity.setOrderStatus();
|
|
|
|
|
//// distributionStockArticleService.updateById(stockArticleEntity);
|
|
|
|
|
// orderNumber.add(stockArticleEntity.getOrderCode());
|
|
|
|
|
// serviceNumber.add(stockArticleEntity.getServiceNumber());
|
|
|
|
|
//// orderSelfNumbering.append().append(",");
|
|
|
|
|
// //订单数量累加
|
|
|
|
|
// AtomicInteger packageNum = new AtomicInteger();
|
|
|
|
|
// //订单存在数据源,维护订单包件信息
|
|
|
|
|
// //维护预约和订单关系
|
|
|
|
|
// DistributionReservationStockarticleEntity reservationStockarticleEntity = new DistributionReservationStockarticleEntity();
|
|
|
|
|
// List<DistributionParcelListEntity> packageList = a.getPackageListInfo();
|
|
|
|
|
// if (Func.isNotEmpty(packageList) || packageList.size() > 0) {
|
|
|
|
|
// packageList.forEach(p -> {
|
|
|
|
|
// packageNum.getAndAdd(p.getQuantity());
|
|
|
|
|
// DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity();
|
|
|
|
|
// reservationPackageEntity.setReservationId(reservationEntity.getId());
|
|
|
|
|
// reservationPackageEntity.setPacketBarCode(p.getOrderPackageCode());
|
|
|
|
|
// reservationPackageEntity.setStockArticleId(stockArticleEntity.getId());
|
|
|
|
|
// reservationPackageEntity.setParceListId(p.getId());
|
|
|
|
|
// distributionReservationPackageService.save(reservationPackageEntity);
|
|
|
|
|
// p.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue());
|
|
|
|
|
// distributionParcelListService.updateById(p);
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// log.error("packageList包件参数有误+{" + packageList + "}");
|
|
|
|
|
// }
|
|
|
|
|
// String status = distributionReservationPackageService.judgmentStatus(stockArticleEntity);
|
|
|
|
|
// stockArticleEntity.setReservationStatus(status);
|
|
|
|
|
// distributionStockArticleService.updateById(stockArticleEntity);
|
|
|
|
|
// //查询出这个预约单下订单所备选取的包件数量
|
|
|
|
|
//// List<DistributionParcelListEntity> parcelListEntityList = distributionReservationStocklistMapper.selectReservationPackageNum(reservationEntity.getId(), stockArticleEntity.getId());
|
|
|
|
|
//// if (packageList.size() != parcelListEntityList.size()) {
|
|
|
|
|
//// stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue());
|
|
|
|
|
//// } else {
|
|
|
|
|
//// stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue());
|
|
|
|
|
//// }
|
|
|
|
|
// reservationStockarticleEntity.setReservationNum(packageNum.get());
|
|
|
|
|
// reservationStockarticleEntity.setIsHaveData(ServiceConstant.ORDER_HAVE_DATA);
|
|
|
|
|
// //对订单下的包件进行累加
|
|
|
|
|
// reservationStockarticleEntity.setStockArticleId(stockArticleEntity.getId());
|
|
|
|
|
// reservationStockarticleEntity.setReservationId(reservationEntity.getId());
|
|
|
|
|
// distributionReservationStockarticleService.save(reservationStockarticleEntity);
|
|
|
|
|
// packageTotal.getAndAdd(reservationStockarticleEntity.getReservationNum());
|
|
|
|
|
// });
|
|
|
|
|
// //这里将预约信息进行完善
|
|
|
|
|
// reservationEntity.setStockArticleId(String.join(",", orderNumber));
|
|
|
|
|
// reservationEntity.setServiceNumber(String.join(",", serviceNumber));
|
|
|
|
|
// reservationEntity.setWarehouseName(String.join(",", warehouseName));
|
|
|
|
|
// reservationEntity.setMallName(String.join(",", mallName));
|
|
|
|
|
// reservationEntity.setStoreName(String.join(",", storeName));
|
|
|
|
|
// //预约添加订单数量
|
|
|
|
|
// reservationEntity.setReservationNum(packageTotal.get());
|
|
|
|
|
// this.updateById(reservationEntity);
|
|
|
|
|
// DistributionSignforEntity distributionSignforEntity = new DistributionSignforEntity();
|
|
|
|
|
// distributionSignforEntity.setReservationId(reservationEntity.getId());
|
|
|
|
|
// distributionSignforEntity.setTrainNumber(str);
|
|
|
|
|
// distributionSignforEntity.setDeliveryId(distributionDeliveryListEntity.getId());
|
|
|
|
|
// distributionSignforService.save(distributionSignforEntity);
|
|
|
|
|
// deliveryWarehouseName.add(reservationEntity.getWarehouseName());
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// Date parse = null;
|
|
|
|
|
// try {
|
|
|
|
|
// parse = format.parse(taskTime);
|
|
|
|
|
// } catch (ParseException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// distributionDeliveryListEntity.setTaskTime(taskTime);
|
|
|
|
|
//完善配送信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public boolean cancelReservation(DistributionReservationDTO reservationDTO) { |
|
|
|
|