|
|
@@ -210,19 +210,17 @@ public class WaybillOrderService {
|
|
|
.eq(KwtLogisticsOrderCirculate::getDelFlag, 0)
|
|
|
.orderByDesc(KwtLogisticsOrderCirculate::getCreateTime)
|
|
|
.orderByDesc(KwtLogisticsOrderCirculate::getId);//TODO donglang 运单状态
|
|
|
- //车牌映射的物流订单
|
|
|
Page<KwtLogisticsOrderCirculate> logOrderCirculateList = logisticsOrderCirculateRepository.page(new Page<>(param.getPageNum(), param.getPageSize()), queryWrapper);
|
|
|
List<KwtLogisticsOrderCirculate> records = logOrderCirculateList.getRecords();
|
|
|
if (CollectionUtils.isEmpty(records)) {
|
|
|
log.info("当前车辆无派单订单,truckNo:{}", param.getTruckNo());
|
|
|
return PageDataResult.empty(param.getPageNum(), param.getPageSize());
|
|
|
}
|
|
|
- //车牌关联物流订单
|
|
|
+ //物流派车订单
|
|
|
Map<Long, KwtLogisticsOrderCirculate> logOrderIdAndCirculateMap = records.stream().collect(Collectors.toMap(KwtLogisticsOrderCirculate::getLOrderId,
|
|
|
Function.identity(), (x, y) -> x));
|
|
|
-
|
|
|
- List<Long> logOrderIdList = records.stream().map(KwtLogisticsOrderCirculate::getLOrderId)
|
|
|
- .filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ //物流订单id
|
|
|
+ List<Long> logOrderIdList = records.stream().map(KwtLogisticsOrderCirculate::getLOrderId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
//物流订单
|
|
|
List<KwtLogisticsOrder> logOrderList = logisticsOrderRepository.queryByLogisticsOrderIds(logOrderIdList);
|
|
|
@@ -230,25 +228,25 @@ public class WaybillOrderService {
|
|
|
log.info("当前车辆无物流订单,truckNo:{}", param.getTruckNo());
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DRIVER_STATUS_ERROR, "当前车辆无物流订单");
|
|
|
}
|
|
|
+ Map<Long, List<KwtLogisticsOrder>> tradeIdAndLogOrderList = logOrderList.stream()
|
|
|
+ .collect(Collectors.groupingBy(KwtLogisticsOrder::getTOrderId));
|
|
|
|
|
|
- //商品
|
|
|
+ //物流id映射物流商品
|
|
|
List<KwtLogisticsOrderGoods> logOrderGoods = logisticsOrderGoodsRepository.queryByLogOrderIds(logOrderIdList);
|
|
|
if (CollectionUtils.isEmpty(logOrderGoods)) {
|
|
|
log.info("当前车辆的物流订单无商品信息,truckNo:{}", param.getTruckNo());
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_GOODS, "当前车辆的物流订单无商品信息");
|
|
|
}
|
|
|
-
|
|
|
- //物流id映射物流商品
|
|
|
Map<Long, KwtLogisticsOrderGoods> logOrderIdAndGoodsMap = logOrderGoods.stream().collect(Collectors.toMap(KwtLogisticsOrderGoods::getLOrderId,
|
|
|
Function.identity(), (x, y) -> x));
|
|
|
- List<Long> goodsIds = logOrderGoods.stream().map(KwtLogisticsOrderGoods::getGoodsId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
//交易商品信息
|
|
|
- Map<Long, KwpGoods> goodsIdAndGoodsMap = goodsInfoService.getGoodsByIds(goodsIds);
|
|
|
- if (MapUtil.isEmpty(goodsIdAndGoodsMap)) {
|
|
|
+ List<Long> goodsIds = logOrderGoods.stream().map(KwtLogisticsOrderGoods::getGoodsId).distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(goodsIds)) {
|
|
|
log.info("物流订单无关联商品信息,logOrderId:{}", JSON.toJSONString(logOrderIdList));
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_GOODS, "物流订单无关联商品信息");
|
|
|
}
|
|
|
+ Map<Long, KwpGoods> goodsIdAndGoodsMap = goodsInfoService.getGoodsByIds(goodsIds);
|
|
|
|
|
|
//承运托运企业
|
|
|
List<KwtLogisticsOrderUnit> logOrderUnits = logisticsOrderUnitRepository.queryByLogOrderIds(logOrderIdList);
|
|
|
@@ -256,67 +254,57 @@ public class WaybillOrderService {
|
|
|
log.info("物流订单无关联承运托运企业,logOrderId:{}", JSON.toJSONString(logOrderIdList));
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_ENT, "物流订单无关联承运托运企业");
|
|
|
}
|
|
|
- Map<String, KwtLogisticsOrderUnit> logOrderIdAndUnitMap = logOrderUnits.stream()
|
|
|
- .collect(Collectors.toMap(unit -> unit.getLOrderId() + "-" + unit.getUnitType(),
|
|
|
- Function.identity(), (x, y) -> x));
|
|
|
+ Map<String, KwtLogisticsOrderUnit> logOrderIdAndUnitMap = logOrderUnits.stream().collect(Collectors.toMap(
|
|
|
+ unit -> unit.getLOrderId() + "-" + unit.getUnitType(), Function.identity(), (x, y) -> x));
|
|
|
|
|
|
- //供应企业
|
|
|
+ //贸易订单id
|
|
|
Set<Long> tradeOrderIds = logOrderList.stream().map(KwtLogisticsOrder::getTOrderId).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ //供应企业
|
|
|
List<OrderUnitInfoDetailVO> orderUnitDetailVOS = tradeOrderInfoService.queryOrderUnitInfByTOrderId(tradeOrderIds);
|
|
|
if (CollectionUtils.isEmpty(orderUnitDetailVOS)) {
|
|
|
log.info("交易订单无关联采取/销售企业,tradeOrderIds:{}", JSON.toJSONString(tradeOrderIds));
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.TRADE_ORDER_NOT_ENT, "交易订单无关联采取/销售企业");
|
|
|
}
|
|
|
- //交易订单Map
|
|
|
- Map<String, OrderUnitInfoDetailVO> tOrderIdAndUnitMap = orderUnitDetailVOS.stream()
|
|
|
- .collect(Collectors.toMap(unit -> unit.getTOrderId() + "-" + unit.getUnitType(),
|
|
|
- Function.identity(), (x, y) -> x));
|
|
|
+ Map<String, OrderUnitInfoDetailVO> tOrderIdAndUnitMap = orderUnitDetailVOS.stream().collect(Collectors.toMap(
|
|
|
+ unit -> unit.getTOrderId() + "-" + unit.getUnitType(), Function.identity(), (x, y) -> x));
|
|
|
|
|
|
//地址
|
|
|
Map<String, KwtLogisticsOrderAddress> logOrderIdAndAddressMap = getKwtLogisticsOrderAddressMap(logOrderIdList);
|
|
|
|
|
|
-
|
|
|
- Set<Long> tradeIds = logOrderList.stream()
|
|
|
- .map(KwtLogisticsOrder::getTOrderId)
|
|
|
- .collect(Collectors.toSet());
|
|
|
- //物流订单id
|
|
|
- List<Long> logisticOrderIds = logOrderList.stream()
|
|
|
- .map(KwtLogisticsOrder::getId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- List<KwtWaybillOrderSubtask> orderSubtaskList = waybillOrderSubtaskRepository.queryByLogIds(logisticOrderIds);
|
|
|
+ //子运单
|
|
|
+ List<KwtWaybillOrderSubtask> orderSubtaskList = waybillOrderSubtaskRepository.queryByLogIds(logOrderIdList);
|
|
|
if (CollectionUtils.isEmpty(orderSubtaskList)) {
|
|
|
log.info("当前车辆辆的无物流子运单,truckNo:{}", param.getTruckNo());
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_SUB_NOT_FOUND, "当前物流子运单不存在");
|
|
|
}
|
|
|
+ Map<Long, List<KwtWaybillOrderSubtask>> logOrderIdAndSubtaskMap = orderSubtaskList.stream()
|
|
|
+ .collect(Collectors.groupingBy(KwtWaybillOrderSubtask::getLOrderId));
|
|
|
|
|
|
//获取贸易订单
|
|
|
- List<OrderDetailVo> orderDetailVos = tradeOrderInfoService.queryByTradeOrderIds(tradeIds);
|
|
|
- Map<Long, OrderDetailVo> tradeIdAndOrderDetailVoMap = Maps.newHashMap();
|
|
|
- if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(orderDetailVos)){
|
|
|
- tradeIdAndOrderDetailVoMap = orderDetailVos.stream()
|
|
|
- .collect(Collectors.toMap(OrderDetailVo::getId, Function.identity(), (x, y) -> x));
|
|
|
+ List<OrderDetailVo> orderDetailVos = tradeOrderInfoService.queryByTradeOrderIds(tradeOrderIds);
|
|
|
+ if (CollectionUtils.isEmpty(orderDetailVos)) {
|
|
|
+ log.info("当前车辆贸易订单不存在,truckNo:{}", param.getTruckNo());
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.TRADE_ORDER_NOT_FOUND, "当前车辆贸易订单不存在");
|
|
|
}
|
|
|
- Map<Long, List<KwtLogisticsOrder>> tradeIdAndLogOrderList = logOrderList.stream()
|
|
|
- .collect(Collectors.groupingBy(KwtLogisticsOrder::getTOrderId));
|
|
|
- Map<Long, List<KwtWaybillOrderSubtask>> logisticsOrderIdAndSubtaskList = orderSubtaskList.stream()
|
|
|
- .collect(Collectors.groupingBy(KwtWaybillOrderSubtask::getLOrderId));
|
|
|
+ Map<Long, OrderDetailVo> tradeIdAndOrderDetailVoMap = orderDetailVos.stream()
|
|
|
+ .collect(Collectors.toMap(OrderDetailVo::getId, Function.identity(), (x, y) -> x));
|
|
|
|
|
|
//查询字典
|
|
|
List<SysDictResDto> sysDictResDtos = remoteSystemService.queryDictByType(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
|
|
|
- Map<String, SysDictResDto> dictValueAndDictResDtoMap = new HashMap<>();
|
|
|
- if (CollectionUtils.isNotEmpty(sysDictResDtos)){
|
|
|
- //字典value映射字典
|
|
|
- dictValueAndDictResDtoMap = sysDictResDtos.stream()
|
|
|
- .collect(Collectors.toMap(SysDictResDto::getValue, Function.identity(), (x, y) -> x));
|
|
|
+ if (CollectionUtils.isEmpty(sysDictResDtos)){
|
|
|
+ log.info("品名类型字典数据不存在,truckNo:{}", param.getTruckNo());
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "品名类型字典数据不存在");
|
|
|
}
|
|
|
+ Map<String, SysDictResDto> dictValueAndDictResDtoMap = sysDictResDtos.stream()
|
|
|
+ .collect(Collectors.toMap(SysDictResDto::getValue, Function.identity(), (x, y) -> x));
|
|
|
+
|
|
|
//组装数据
|
|
|
- Map<Long, OrderDetailVo> finalTradeIdAndOrderDetailVoMap = tradeIdAndOrderDetailVoMap;
|
|
|
- Map<String, SysDictResDto> finaldictValueAndDictResDtoMap = dictValueAndDictResDtoMap;
|
|
|
List<LogisticsOrderResp> ordderList = logOrderList.stream()
|
|
|
.map(order -> {
|
|
|
return getLogisticsOrderResp(order, logOrderIdAndGoodsMap, goodsIdAndGoodsMap, logOrderIdAndUnitMap,
|
|
|
- tOrderIdAndUnitMap, logOrderIdAndAddressMap, logOrderIdAndCirculateMap, finalTradeIdAndOrderDetailVoMap,
|
|
|
- tradeIdAndLogOrderList,logisticsOrderIdAndSubtaskList,finaldictValueAndDictResDtoMap);
|
|
|
+ tOrderIdAndUnitMap, logOrderIdAndAddressMap, logOrderIdAndCirculateMap, tradeIdAndOrderDetailVoMap,
|
|
|
+ tradeIdAndLogOrderList,logOrderIdAndSubtaskMap,dictValueAndDictResDtoMap);
|
|
|
}).collect(Collectors.toList());
|
|
|
log.info("查询司机关联车辆的物流订单成功!");
|
|
|
return PageDataResult.success(param.getPageNum(), param.getPageSize(), (long) ordderList.size(), ordderList);
|