提交 1c7ca1b4 authored 作者: huyufan's avatar huyufan

优化相关代码

上级 ca797b3e
...@@ -30,6 +30,7 @@ public abstract class GoodsOrderStrategy { ...@@ -30,6 +30,7 @@ public abstract class GoodsOrderStrategy {
/** /**
* 不同的用车需求执行不同的策略 1:one 2:two 3:three * 不同的用车需求执行不同的策略 1:one 2:two 3:three
* 用车需求: 1平台车辆 2部分平台车辆 3自有车辆 * 用车需求: 1平台车辆 2部分平台车辆 3自有车辆
*
* @param orderGoodsParams * @param orderGoodsParams
* @param orderInfo * @param orderInfo
* @param now * @param now
...@@ -40,29 +41,29 @@ public abstract class GoodsOrderStrategy { ...@@ -40,29 +41,29 @@ public abstract class GoodsOrderStrategy {
public void saveGoodsOrder(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo, LocalDateTime now, RabbitTemplate rabbitTemplate) { public void saveGoodsOrder(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo, LocalDateTime now, RabbitTemplate rabbitTemplate) {
String orderNo = orderGoodsParams.getOrderNo(); String orderNo = orderGoodsParams.getOrderNo();
if(Objects.equals(orderInfo.getStopFlag(), OrderStopEnum.Status.YES.getCode())){ if (Objects.equals(orderInfo.getStopFlag(), OrderStopEnum.Status.YES.getCode())) {
throw new ServiceSystemException(ResultEnum.DATA_ERROR,"订单已暂停,无法进行提量"); throw new ServiceSystemException(ResultEnum.DATA_ERROR, "订单已暂停,无法进行提量");
} }
//多个定向单不允许车辆重复 //多个定向单不允许车辆重复
List<OrderGoodsChildParams> orderGoodsChildParams = orderGoodsParams.getOrderGoodsChildParams(); List<OrderGoodsChildParams> orderGoodsChildParams = orderGoodsParams.getOrderGoodsChildParams();
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
for (OrderGoodsChildParams item : orderGoodsChildParams) { for (OrderGoodsChildParams item : orderGoodsChildParams) {
if(CollectionUtils.isNotEmpty(item.getTruckList())){ if (CollectionUtils.isNotEmpty(item.getTruckList())) {
int lastSize = set.size() + item.getTruckList().size(); int lastSize = set.size() + item.getTruckList().size();
set.addAll(item.getTruckList()); set.addAll(item.getTruckList());
if (!Objects.equals(lastSize,set.size() +item.getTruckList().size())) { if (!Objects.equals(lastSize, set.size())) {
throw new ServiceSystemException(ResultEnum.DATA_ERROR,"定向单选择车辆重复"); throw new ServiceSystemException(ResultEnum.DATA_ERROR, "定向单选择车辆重复");
} }
} }
} }
if(CollectionUtils.isNotEmpty(set)){ if (CollectionUtils.isNotEmpty(set)) {
OrderGoodsTruckBindDao orderGoodsTruckBindDao = SpringContextUtils.getBeanByClass(OrderGoodsTruckBindDao.class); OrderGoodsTruckBindDao orderGoodsTruckBindDao = SpringContextUtils.getBeanByClass(OrderGoodsTruckBindDao.class);
List<OrderGoodsTruckBind> binds = orderGoodsTruckBindDao.judgeTruckIsBindDxOrder(set); List<OrderGoodsTruckBind> binds = orderGoodsTruckBindDao.judgeTruckIsBindDxOrder(set);
if(CollectionUtils.isNotEmpty(binds)){ if (CollectionUtils.isNotEmpty(binds)) {
List<String> repeatBind = binds.stream().map(OrderGoodsTruckBind::getTruckNo).collect(Collectors.toList()); List<String> repeatBind = binds.stream().map(OrderGoodsTruckBind::getTruckNo).collect(Collectors.toList());
String trucks = String.join(", ", repeatBind); String trucks = String.join(", ", repeatBind);
throw new ServiceSystemException(ResultEnum.DATA_ERROR,"已被定向单绑定车辆:"+ trucks); throw new ServiceSystemException(ResultEnum.DATA_ERROR, "已被定向单绑定车辆:" + trucks);
} }
} }
//根据不同的订单类型创建不同的货单 //根据不同的订单类型创建不同的货单
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论