|
|
|
@ -76,8 +76,6 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
private final IDistributionReservationStocklistService distributionReservationStocklistService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<DistributionReservationVO> selectDistrbutionReservationPage(IPage<DistributionReservationVO> page, DistributionReservationVO distrbutionReservation) { |
|
|
|
|
return page.setRecords(baseMapper.selectDistrbutionReservationPage(page, distrbutionReservation)); |
|
|
|
@ -122,14 +120,16 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public boolean insertReservation(DistributionReservationDTO distributionReservationDTO) { |
|
|
|
|
if (Func.isEmpty(distributionReservationDTO)){ |
|
|
|
|
if (Func.isEmpty(distributionReservationDTO)) { |
|
|
|
|
log.error("参数错误+{" + distributionReservationDTO + "}"); |
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//构建预约单
|
|
|
|
|
DistributionReservationEntity reservationEntity = new DistributionReservationEntity(); |
|
|
|
|
Func.copy(distributionReservationDTO,reservationEntity); |
|
|
|
|
Func.copy(distributionReservationDTO, reservationEntity); |
|
|
|
|
//新建预约单为待确认状态
|
|
|
|
|
reservationEntity.setReservationStatus("1"); |
|
|
|
|
//新建预约单订单处于未备货状态
|
|
|
|
|
reservationEntity.setStockupStatus("1"); |
|
|
|
|
this.save(reservationEntity); |
|
|
|
|
//获取新增预约信息的编号
|
|
|
|
@ -141,15 +141,22 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
List<String> arrayList = new ArrayList<>(); |
|
|
|
|
AtomicReference<BigDecimal> initTotal = new AtomicReference<>(BigDecimal.ZERO); |
|
|
|
|
//存在订单构建预约订单关联信息
|
|
|
|
|
if (!Func.isEmpty(stockArticleList)){ |
|
|
|
|
stockArticleList.forEach(s->{ |
|
|
|
|
if (!Func.isEmpty(stockArticleList)) { |
|
|
|
|
stockArticleList.forEach(s -> { |
|
|
|
|
//修改订单状态为已预约
|
|
|
|
|
s.setState(2); |
|
|
|
|
stockArticleCount.getAndAdd(s.getReservationNum()); |
|
|
|
|
distributionStockArticleService.updateById(s); |
|
|
|
|
//拼接订单自编号
|
|
|
|
|
arrayList.add(s.getOrderSelfNumbering()); |
|
|
|
|
initTotal.accumulateAndGet(new BigDecimal(s.getFee().toString()),BigDecimal::add); |
|
|
|
|
initTotal.accumulateAndGet(new BigDecimal(s.getRate().toString()),BigDecimal::add); |
|
|
|
|
//订单增值服务费
|
|
|
|
|
initTotal.accumulateAndGet(new BigDecimal(s.getFee().toString()), BigDecimal::add); |
|
|
|
|
//订单协商费用
|
|
|
|
|
initTotal.accumulateAndGet(new BigDecimal(s.getRate().toString()), BigDecimal::add); |
|
|
|
|
//订单到付费用
|
|
|
|
|
initTotal.accumulateAndGet(new BigDecimal(s.getCollectFee().toString()), BigDecimal::add); |
|
|
|
|
//仓储费用
|
|
|
|
|
initTotal.accumulateAndGet(new BigDecimal(s.getStorageFee().toString()), BigDecimal::add); |
|
|
|
|
Long stockArticleId = s.getId(); |
|
|
|
|
DistributionReservationStockarticleEntity distributionReservationStockarticleEntity = new DistributionReservationStockarticleEntity(); |
|
|
|
|
distributionReservationStockarticleEntity.setReservationId(reservationId); |
|
|
|
@ -159,8 +166,8 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
//存在库存品构建预约库存品关联信息
|
|
|
|
|
if (!Func.isEmpty(inventoryList)){ |
|
|
|
|
inventoryList.forEach(i->{ |
|
|
|
|
if (!Func.isEmpty(inventoryList)) { |
|
|
|
|
inventoryList.forEach(i -> { |
|
|
|
|
distributionStockListService.updateById(i); |
|
|
|
|
Long stocklistId = i.getId(); |
|
|
|
|
stockListCount.getAndAdd(i.getReservationNum()); |
|
|
|
@ -182,6 +189,8 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
//统计数量
|
|
|
|
|
BigDecimal fee = initTotal.get().add(reservationEntity.getOtherFee()); |
|
|
|
|
reservationEntity.setFee(fee); |
|
|
|
|
int count = stockArticleCount.get() + stockListCount.get(); |
|
|
|
|
reservationEntity.setReservationNum(count); |
|
|
|
|
distributionReservationMapper.updateById(reservationEntity); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -273,9 +282,6 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
log.error("预约参数错误+{" + ids + "}"); |
|
|
|
|
return R.fail("预约信息错误!!!"); |
|
|
|
|
} |
|
|
|
|
String text = "4564654654"; |
|
|
|
|
String[] split = text.split(","); |
|
|
|
|
|
|
|
|
|
//判断是自主配送还是三方配送
|
|
|
|
|
String tripartiteSource = (String) deliveryInfo.get("tripartiteSource"); |
|
|
|
|
boolean result = false; |
|
|
|
@ -297,7 +303,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
distributionTripartiteDeliveryEntity.setDriverPhone((String) deliveryInfo.get("driverPhone")); |
|
|
|
|
distributionTripartiteDeliveryEntity.setDriverName((String) deliveryInfo.get("driverName")); |
|
|
|
|
distributionTripartiteDeliveryEntity.setVehicleNum((String) deliveryInfo.get("vehicleNum")); |
|
|
|
|
distributionTripartiteDeliveryEntity.setDeliveryFee(new BigDecimal((String) deliveryInfo.get("deliveryFee")) ); |
|
|
|
|
distributionTripartiteDeliveryEntity.setDeliveryFee(new BigDecimal((String) deliveryInfo.get("deliveryFee"))); |
|
|
|
|
distributionTripartiteDeliveryEntity.setReservationIds(idsStr); |
|
|
|
|
result = distributionTripartiteDeliveryService.save(distributionTripartiteDeliveryEntity); |
|
|
|
|
Long distributionTripartiteDeliveryEntityId = distributionTripartiteDeliveryEntity.getId(); |
|
|
|
@ -308,7 +314,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
stockupEntity.setStockupStatus("2"); |
|
|
|
|
stockupEntity.setStockupArea((String) deliveryInfo.get("goodsAreaId")); |
|
|
|
|
stockupEntity.setStockupUser(AuthUtil.getUser().getUserId().toString()); |
|
|
|
|
stockupEntity.setLoader(Long.parseLong((String) deliveryInfo.get("loader")) ); |
|
|
|
|
stockupEntity.setLoader(Long.parseLong((String) deliveryInfo.get("loader"))); |
|
|
|
|
stockupEntity.setAssignStatus("2"); |
|
|
|
|
stockupEntity.setAssignTime(new Date()); |
|
|
|
|
String stockUpdate = (String) deliveryInfo.get("stockupDate"); |
|
|
|
@ -326,7 +332,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
//对预约信息进行备货状态修改
|
|
|
|
|
DistributionReservationEntity reservationEntity = this.getBaseMapper().selectById(id); |
|
|
|
|
String stockupStatus = reservationEntity.getStockupStatus(); |
|
|
|
|
if (!stockupStatus.equals("1")){ |
|
|
|
|
if (!stockupStatus.equals("1")) { |
|
|
|
|
//预约任务处于未备货状态
|
|
|
|
|
//预约信息编号拼接
|
|
|
|
|
reservationIdBuffer.append(reservationEntity.getId()).append(","); |
|
|
|
@ -367,16 +373,16 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
distributionDeliveryListEntity.setWarehouseId(warehouseName.get()); |
|
|
|
|
String masterDriverName = (String) deliveryInfo.get("masterDriverName"); |
|
|
|
|
String slaveDriverNames = (String) deliveryInfo.get("slaveDriverNames"); |
|
|
|
|
if (Func.isBlank(masterDriverName)){ |
|
|
|
|
if (Func.isBlank(masterDriverName)) { |
|
|
|
|
//这里就是外协配送的方式
|
|
|
|
|
distributionDeliveryListEntity.setDriverName((String) deliveryInfo.get("driverName")); |
|
|
|
|
distributionDeliveryListEntity.setKind("2"); |
|
|
|
|
distributionDeliveryListEntity.setVehicleName((String) deliveryInfo.get("vehicleNum")); |
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
distributionDeliveryListEntity.setVehicleName((String) deliveryInfo.get("vehicleNums")); |
|
|
|
|
distributionDeliveryListEntity.setVehicleId((String) deliveryInfo.get("vehicleIds")); |
|
|
|
|
distributionDeliveryListEntity.setDriverName(masterDriverName+","+slaveDriverNames); |
|
|
|
|
distributionDeliveryListEntity.setDriverName(masterDriverName + "," + slaveDriverNames); |
|
|
|
|
distributionDeliveryListEntity.setDriverId((String) deliveryInfo.get("driverIds")); |
|
|
|
|
distributionDeliveryListEntity.setKind("1"); |
|
|
|
|
} |
|
|
|
@ -388,7 +394,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
log.error("异常错误+{"+e.getMessage()+"}"); |
|
|
|
|
log.error("异常错误+{" + e.getMessage() + "}"); |
|
|
|
|
return R.fail("操作失败!!!"); |
|
|
|
|
} |
|
|
|
|
return R.status(result); |
|
|
|
@ -399,34 +405,112 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
//查询出预约信息
|
|
|
|
|
DistributionReservationEntity reservationEntity = this.getBaseMapper().selectById(reservationId); |
|
|
|
|
DistributionReservationVO reservationVO = new DistributionReservationVO(); |
|
|
|
|
Func.copy(reservationEntity,reservationVO); |
|
|
|
|
Func.copy(reservationEntity, reservationVO); |
|
|
|
|
//查询出订单信息
|
|
|
|
|
QueryWrapper<DistributionReservationStockarticleEntity> q = Condition.getQueryWrapper(new HashMap<String, Object>(),DistributionReservationStockarticleEntity.class); |
|
|
|
|
q.lambda().eq(DistributionReservationStockarticleEntity::getReservationId,reservationEntity.getId()); |
|
|
|
|
QueryWrapper<DistributionReservationStockarticleEntity> q = Condition.getQueryWrapper(new HashMap<String, Object>(), DistributionReservationStockarticleEntity.class); |
|
|
|
|
q.lambda().eq(DistributionReservationStockarticleEntity::getReservationId, reservationEntity.getId()); |
|
|
|
|
List<DistributionReservationStockarticleEntity> reservationStockarticleEntityList = distributionReservationStockarticleService.getBaseMapper().selectList(q); |
|
|
|
|
QueryWrapper<DistributionReservationStocklistEntity> w = Condition.getQueryWrapper(new HashMap<String, Object>(),DistributionReservationStocklistEntity.class); |
|
|
|
|
w.lambda().eq(DistributionReservationStocklistEntity::getReservationId,reservationEntity.getId()); |
|
|
|
|
QueryWrapper<DistributionReservationStocklistEntity> w = Condition.getQueryWrapper(new HashMap<String, Object>(), DistributionReservationStocklistEntity.class); |
|
|
|
|
w.lambda().eq(DistributionReservationStocklistEntity::getReservationId, reservationEntity.getId()); |
|
|
|
|
List<DistributionReservationStocklistEntity> reservationStocklistEntityList = distributionReservationStocklistService.getBaseMapper().selectList(w); |
|
|
|
|
if (!Func.isEmpty(reservationStockarticleEntityList)){ |
|
|
|
|
if (!Func.isEmpty(reservationStockarticleEntityList)) { |
|
|
|
|
List<DistributionStockArticleEntity> stockArticleEntityList = new ArrayList<>(); |
|
|
|
|
reservationStockarticleEntityList.forEach(a->{ |
|
|
|
|
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(a.getStockarticleId()); |
|
|
|
|
stockArticleEntity.setReservationNum(a.getReservationNum()); |
|
|
|
|
reservationStockarticleEntityList.forEach(a1 -> { |
|
|
|
|
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(a1.getStockarticleId()); |
|
|
|
|
stockArticleEntity.setReservationNum(a1.getReservationNum()); |
|
|
|
|
stockArticleEntityList.add(stockArticleEntity); |
|
|
|
|
}); |
|
|
|
|
//查询出库存信息
|
|
|
|
|
//查询出 库存信息
|
|
|
|
|
reservationVO.setStockArticleList(stockArticleEntityList); |
|
|
|
|
} |
|
|
|
|
if (!Func.isEmpty(reservationStocklistEntityList)){ |
|
|
|
|
if (!Func.isEmpty(reservationStocklistEntityList)) { |
|
|
|
|
List<DistributionStockListEntity> stockArticleEntityList = new ArrayList<>(); |
|
|
|
|
reservationStocklistEntityList.forEach(a->{ |
|
|
|
|
DistributionStockListEntity stockListEntity = distributionStockListService.getById(a.getStocklistId()); |
|
|
|
|
stockListEntity.setReservationNum(a.getReservationNum()); |
|
|
|
|
reservationStocklistEntityList.forEach(a2 -> { |
|
|
|
|
DistributionStockListEntity stockListEntity = distributionStockListService.getById(a2.getStocklistId()); |
|
|
|
|
stockListEntity.setReservationNum(a2.getReservationNum()); |
|
|
|
|
stockArticleEntityList.add(stockListEntity); |
|
|
|
|
}); |
|
|
|
|
//查询出库存信息
|
|
|
|
|
//查询出 库存信息
|
|
|
|
|
reservationVO.setInventoryList(stockArticleEntityList); |
|
|
|
|
} |
|
|
|
|
return R.data(reservationVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public boolean updateReservation(DistributionReservationDTO distributionReservationDTO) { |
|
|
|
|
//修改预约信息
|
|
|
|
|
if (Func.isEmpty(distributionReservationDTO)) { |
|
|
|
|
log.error("参数异常+{" + distributionReservationDTO + "}"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//删除原有
|
|
|
|
|
DistributionReservationEntity distributionReservationEntity = this.getById(distributionReservationDTO.getId()); |
|
|
|
|
Func.copy(distributionReservationDTO, distributionReservationEntity); |
|
|
|
|
QueryWrapper<DistributionReservationStockarticleEntity> q = Condition.getQueryWrapper(new HashMap<String, Object>(), DistributionReservationStockarticleEntity.class); |
|
|
|
|
q.lambda().eq(DistributionReservationStockarticleEntity::getReservationId, distributionReservationEntity.getId()); |
|
|
|
|
QueryWrapper<DistributionReservationStocklistEntity> w = Condition.getQueryWrapper(new HashMap<String, Object>(), DistributionReservationStocklistEntity.class); |
|
|
|
|
q.lambda().eq(DistributionReservationStockarticleEntity::getReservationId, distributionReservationEntity.getId()); |
|
|
|
|
//查询已有的中间表信息
|
|
|
|
|
List<DistributionReservationStockarticleEntity> reservationStockarticleEntityList = distributionReservationStockarticleService.getBaseMapper().selectList(q); |
|
|
|
|
List<DistributionReservationStocklistEntity> reservationStocklistEntityList = distributionReservationStocklistService.getBaseMapper().selectList(w); |
|
|
|
|
if (!Func.isEmpty(reservationStockarticleEntityList)) { |
|
|
|
|
//对已有预约信息的订单包件数量进行清理
|
|
|
|
|
reservationStockarticleEntityList.forEach(s1 -> { |
|
|
|
|
int delete = distributionReservationStockarticleService.getBaseMapper().delete(q); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (!Func.isEmpty(reservationStocklistEntityList)) { |
|
|
|
|
//对已有预约信息的订单包件数量进行清理
|
|
|
|
|
reservationStocklistEntityList.forEach(r1 -> { |
|
|
|
|
int delete = distributionReservationStocklistService.getBaseMapper().delete(w); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
//包件数量累加
|
|
|
|
|
AtomicInteger count = new AtomicInteger(); |
|
|
|
|
//计算总费用
|
|
|
|
|
AtomicReference<BigDecimal> initTotal = new AtomicReference<>(BigDecimal.ZERO); |
|
|
|
|
//订单自编号拼接
|
|
|
|
|
HashSet<String> hashSet = new HashSet<>(); |
|
|
|
|
List<DistributionStockArticleEntity> stockArticleList = distributionReservationDTO.getStockArticleList(); |
|
|
|
|
if (!Func.isEmpty(stockArticleList)) { |
|
|
|
|
//这里判断修改内容是否存在订单信息,如果存在则进行中间表数据的重新插入
|
|
|
|
|
stockArticleList.forEach(s -> { |
|
|
|
|
DistributionReservationStockarticleEntity distributionReservationStockarticleEntity = new DistributionReservationStockarticleEntity(); |
|
|
|
|
//构建预约订单中间表信息
|
|
|
|
|
distributionReservationStockarticleEntity.setReservationNum(s.getReservationNum()); |
|
|
|
|
distributionReservationStockarticleEntity.setStockarticleId(s.getId()); |
|
|
|
|
distributionReservationStockarticleEntity.setReservationId(distributionReservationEntity.getId()); |
|
|
|
|
distributionReservationStockarticleService.save(distributionReservationStockarticleEntity); |
|
|
|
|
//统计订单包件数量
|
|
|
|
|
count.getAndAdd(s.getReservationNum()); |
|
|
|
|
//订单到付费用
|
|
|
|
|
initTotal.getAndAccumulate(new BigDecimal(s.getCollectFee().toString()), BigDecimal::add); |
|
|
|
|
//订单仓储费
|
|
|
|
|
initTotal.getAndAccumulate(new BigDecimal(s.getStorageFee().toString()), BigDecimal::add); |
|
|
|
|
//协商费用
|
|
|
|
|
initTotal.getAndAccumulate(new BigDecimal(s.getRate().toString()), BigDecimal::add); |
|
|
|
|
hashSet.add(s.getOrderSelfNumbering()); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
List<DistributionStockListEntity> inventoryList = distributionReservationDTO.getInventoryList(); |
|
|
|
|
if (!Func.isEmpty(inventoryList)) { |
|
|
|
|
//重新构建备货信息
|
|
|
|
|
inventoryList.forEach(i -> { |
|
|
|
|
DistributionReservationStocklistEntity distributionReservationStocklistEntity = new DistributionReservationStocklistEntity(); |
|
|
|
|
distributionReservationStocklistEntity.setReservationId(distributionReservationEntity.getId()); |
|
|
|
|
distributionReservationStocklistEntity.setReservationNum(i.getReservationNum()); |
|
|
|
|
distributionReservationStocklistEntity.setStocklistId(i.getId()); |
|
|
|
|
distributionReservationStocklistService.save(distributionReservationStocklistEntity); |
|
|
|
|
count.getAndAdd(i.getReservationNum()); |
|
|
|
|
hashSet.add(i.getOrderSelfNumbering()); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
String orderId = String.join(",", hashSet); |
|
|
|
|
distributionReservationEntity.setFee(initTotal.get()); |
|
|
|
|
distributionReservationEntity.setReservationNum(count.get()); |
|
|
|
|
distributionReservationEntity.setStockArticleId(orderId); |
|
|
|
|
distributionReservationMapper.updateById(distributionReservationEntity); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|