|
@@ -6,19 +6,22 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.sckw.contract.api.RemoteContractService;
|
|
import com.sckw.contract.api.RemoteContractService;
|
|
|
-import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
|
|
import com.sckw.core.common.enums.enums.ErrorCodeEnum;
|
|
import com.sckw.core.common.enums.enums.ErrorCodeEnum;
|
|
|
import com.sckw.core.exception.BusinessPlatfromException;
|
|
import com.sckw.core.exception.BusinessPlatfromException;
|
|
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.GatekeeperStatusEnum;
|
|
import com.sckw.core.model.enums.GatekeeperStatusEnum;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.DateUtils;
|
|
import com.sckw.core.utils.DateUtils;
|
|
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.response.result.PageDataResult;
|
|
import com.sckw.core.web.response.result.PageDataResult;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
import com.sckw.order.api.model.OrderUnitInfoDetailVO;
|
|
import com.sckw.order.api.model.OrderUnitInfoDetailVO;
|
|
|
import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
-import com.sckw.product.api.model.KwpGoods;
|
|
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
-import com.sckw.transport.model.*;
|
|
|
|
|
|
|
+import com.sckw.transport.model.KwtGatekeeperWaybillOrder;
|
|
|
|
|
+import com.sckw.transport.model.KwtLogisticsOrder;
|
|
|
|
|
+import com.sckw.transport.model.KwtWaybillOrder;
|
|
|
|
|
+import com.sckw.transport.model.KwtWaybillOrderTicket;
|
|
|
import com.sckw.transport.model.param.forklift.reponse.GatekeeperOrderResp;
|
|
import com.sckw.transport.model.param.forklift.reponse.GatekeeperOrderResp;
|
|
|
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderPassParam;
|
|
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderPassParam;
|
|
|
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderQueryParam;
|
|
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderQueryParam;
|
|
@@ -31,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -78,6 +82,44 @@ public class GatekeeperOrderService {
|
|
|
*/
|
|
*/
|
|
|
public PageDataResult<GatekeeperOrderResp> pageQueryGatekeeperOrder(GatekeeperOrderQueryParam param) {
|
|
public PageDataResult<GatekeeperOrderResp> pageQueryGatekeeperOrder(GatekeeperOrderQueryParam param) {
|
|
|
log.info("查询门卫订单:{}", JSON.toJSONString(param));
|
|
log.info("查询门卫订单:{}", JSON.toJSONString(param));
|
|
|
|
|
+ //构建查询条件
|
|
|
|
|
+ LambdaQueryWrapper<KwtGatekeeperWaybillOrder> wrapper = buildAndExecuteQuery(param);
|
|
|
|
|
+
|
|
|
|
|
+ //查询门卫订单
|
|
|
|
|
+ Page<KwtGatekeeperWaybillOrder> pageByStatus = gatekeeperWaybillOrderRepository.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
|
|
+ List<KwtGatekeeperWaybillOrder> records = pageByStatus.getRecords();
|
|
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
|
|
+ log.info("当前无运单订单信息");
|
|
|
|
|
+ return PageDataResult.empty(param.getPageNum(), param.getPageSize());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<GatekeeperOrderResp> gatekeeperOrderPageResult = getGatekeeperOrderPageResult(records);
|
|
|
|
|
+ //处理异常车辆数据
|
|
|
|
|
+ gatekeeperOrderPageResult = filterGatekeeperOrderResp(param, gatekeeperOrderPageResult);
|
|
|
|
|
+
|
|
|
|
|
+ //排序
|
|
|
|
|
+ sort(param, gatekeeperOrderPageResult);
|
|
|
|
|
+ return PageDataResult.success(param.getPageNum(), param.getPageSize(), pageByStatus.getTotal(), gatekeeperOrderPageResult);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建查询条件并执行分页查询
|
|
|
|
|
+ */
|
|
|
|
|
+ private LambdaQueryWrapper<KwtGatekeeperWaybillOrder> buildAndExecuteQuery(GatekeeperOrderQueryParam param) {
|
|
|
|
|
+ //基础查询条件
|
|
|
|
|
+ LambdaQueryWrapper<KwtGatekeeperWaybillOrder> queryWrapper = buildBaseQueryWrapper(param);
|
|
|
|
|
+
|
|
|
|
|
+ //模糊查询条件
|
|
|
|
|
+ handleSearchKeyword(param, queryWrapper);
|
|
|
|
|
+ return queryWrapper;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建基础查询条件
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private LambdaQueryWrapper<KwtGatekeeperWaybillOrder> buildBaseQueryWrapper(GatekeeperOrderQueryParam param) {
|
|
|
LambdaQueryWrapper<KwtGatekeeperWaybillOrder> wrapper = Wrappers.<KwtGatekeeperWaybillOrder>lambdaQuery()
|
|
LambdaQueryWrapper<KwtGatekeeperWaybillOrder> wrapper = Wrappers.<KwtGatekeeperWaybillOrder>lambdaQuery()
|
|
|
.orderByDesc(KwtGatekeeperWaybillOrder::getCreateTime)
|
|
.orderByDesc(KwtGatekeeperWaybillOrder::getCreateTime)
|
|
|
.orderByDesc(KwtGatekeeperWaybillOrder::getId);
|
|
.orderByDesc(KwtGatekeeperWaybillOrder::getId);
|
|
@@ -103,23 +145,122 @@ public class GatekeeperOrderService {
|
|
|
GatekeeperStatusEnum.EXITED.getCode(),
|
|
GatekeeperStatusEnum.EXITED.getCode(),
|
|
|
GatekeeperStatusEnum.EMPTY_EXITED.getCode());
|
|
GatekeeperStatusEnum.EMPTY_EXITED.getCode());
|
|
|
}
|
|
}
|
|
|
- //查询门卫订单
|
|
|
|
|
- Page<KwtGatekeeperWaybillOrder> pageByStatus = gatekeeperWaybillOrderRepository.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
|
|
- List<KwtGatekeeperWaybillOrder> records = pageByStatus.getRecords();
|
|
|
|
|
- if (CollectionUtils.isEmpty(records)) {
|
|
|
|
|
- log.info("当前无运单订单信息");
|
|
|
|
|
- return PageDataResult.empty(param.getPageNum(), param.getPageSize());
|
|
|
|
|
|
|
+ return wrapper;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 关键词模糊查询
|
|
|
|
|
+ */
|
|
|
|
|
+ private void handleSearchKeyword(GatekeeperOrderQueryParam param, LambdaQueryWrapper<KwtGatekeeperWaybillOrder> wrapper) {
|
|
|
|
|
+ if (StringUtils.isBlank(param.getKeyWords())) {
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- List<GatekeeperOrderResp> gatekeeperOrderPageResult = getGatekeeperOrderPageResult(records);
|
|
|
|
|
- //处理异常车辆数据
|
|
|
|
|
- gatekeeperOrderPageResult = filterGatekeeperOrderResp(param, gatekeeperOrderPageResult);
|
|
|
|
|
|
|
+ Set<Long> matchedWaybillOrderIds = findMatchedGatekeeperOrderIds(param);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(matchedWaybillOrderIds)) {
|
|
|
|
|
+ log.info("模糊查询无匹配结果,关键词:{}", param.getKeyWords());
|
|
|
|
|
+ // 设置一个不可能的条件,确保返回空结果
|
|
|
|
|
+ wrapper.eq(KwtGatekeeperWaybillOrder::getId, Global.MINUS_ONE);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.in(KwtGatekeeperWaybillOrder::getId, matchedWaybillOrderIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- //排序
|
|
|
|
|
- sort(param, gatekeeperOrderPageResult);
|
|
|
|
|
- return PageDataResult.success(param.getPageNum(), param.getPageSize(), pageByStatus.getTotal(), gatekeeperOrderPageResult);
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询匹配的运单ID(以铲车ID为主键)
|
|
|
|
|
+ */
|
|
|
|
|
+ private Set<Long> findMatchedGatekeeperOrderIds(GatekeeperOrderQueryParam param) {
|
|
|
|
|
+ Set<Long> gatekeeperOrderIds = ConcurrentHashMap.newKeySet();;
|
|
|
|
|
+ List<Runnable> searchTasks = Arrays.asList(
|
|
|
|
|
+ //1. 运单编号查询(主表字段,直接匹配)
|
|
|
|
|
+ () -> addMatchedIds(gatekeeperOrderIds, param),
|
|
|
|
|
+
|
|
|
|
|
+ //2. 车牌号、司机姓名查询
|
|
|
|
|
+ () -> addMatchedIdsFromWaybillNo(gatekeeperOrderIds, param),
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 客户名称查询
|
|
|
|
|
+ () -> addMatchedIdsFromLogisticsOrderNo(gatekeeperOrderIds, param)
|
|
|
|
|
+ );
|
|
|
|
|
+ // 使用并行流执行查询任务
|
|
|
|
|
+ searchTasks.parallelStream().forEach(Runnable::run);
|
|
|
|
|
+ return gatekeeperOrderIds;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 运单编号查询
|
|
|
|
|
+ * @param gatekeeperOrderIds
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ */
|
|
|
|
|
+ private void addMatchedIds(Set<Long> gatekeeperOrderIds, GatekeeperOrderQueryParam param) {
|
|
|
|
|
+ // 1. 运单编号查询(主表字段,直接匹配)
|
|
|
|
|
+ List<KwtGatekeeperWaybillOrder> gatekeeperWaybillOrder = gatekeeperWaybillOrderRepository.list(
|
|
|
|
|
+ Wrappers.<KwtGatekeeperWaybillOrder>lambdaQuery()
|
|
|
|
|
+ .like(KwtGatekeeperWaybillOrder::getWOrderNo, param.getKeyWords())
|
|
|
|
|
+ );
|
|
|
|
|
+ gatekeeperOrderIds.addAll(gatekeeperWaybillOrder.stream()
|
|
|
|
|
+ .map(KwtGatekeeperWaybillOrder::getId)
|
|
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车牌号、司机姓名查询
|
|
|
|
|
+ * @param gatekeeperOrderIds
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ */
|
|
|
|
|
+ private void addMatchedIdsFromWaybillNo(Set<Long> gatekeeperOrderIds, GatekeeperOrderQueryParam param) {
|
|
|
|
|
+ List<KwtWaybillOrder> waybillOrders = waybillOrderRepository.list(
|
|
|
|
|
+ Wrappers.<KwtWaybillOrder>lambdaQuery()
|
|
|
|
|
+ .like(KwtWaybillOrder::getTruckNo, param.getKeyWords())
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .like(KwtWaybillOrder::getDriverName, param.getKeyWords())
|
|
|
|
|
+ .eq(KwtWaybillOrder::getDelFlag, 0)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(waybillOrders)) {
|
|
|
|
|
+ List<Long> matchedWaybillOrderIds = waybillOrders.stream()
|
|
|
|
|
+ .map(KwtWaybillOrder::getId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 查询这些物流运单对应的铲车订单
|
|
|
|
|
+ List<KwtGatekeeperWaybillOrder> gatekeeperOrderList = gatekeeperWaybillOrderRepository
|
|
|
|
|
+ .queryGatekeeperWaybillOrderByWOrderIds(matchedWaybillOrderIds);
|
|
|
|
|
+
|
|
|
|
|
+ gatekeeperOrderIds.addAll(gatekeeperOrderList.stream()
|
|
|
|
|
+ .map(KwtGatekeeperWaybillOrder::getId)
|
|
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 从企业名称查询贸易订单关联的铲车订单
|
|
|
|
|
+ */
|
|
|
|
|
+ private void addMatchedIdsFromLogisticsOrderNo(Set<Long> gatekeeperOrderIds, GatekeeperOrderQueryParam param) {
|
|
|
|
|
+ // 从企业名称查询贸易订单
|
|
|
|
|
+ List<OrderUnitInfoDetailVO> orderUnitInfoDetailVOS = tradeOrderInfoService.queryOrderUnitInfByEntName(param.getKeyWords());
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isEmpty(orderUnitInfoDetailVOS)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<Long> tOrderIds = orderUnitInfoDetailVOS.stream()
|
|
|
|
|
+ .map(OrderUnitInfoDetailVO::getTOrderId)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ // 通过贸易订单查询关联的物流订单
|
|
|
|
|
+ List<KwtLogisticsOrder> logisticsOrders = logisticsOrderRepository.queryByTradeOrderIds(tOrderIds);
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(logisticsOrders)) {
|
|
|
|
|
+ List<Long> logOrderIds = logisticsOrders.stream()
|
|
|
|
|
+ .map(KwtLogisticsOrder::getId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 查询这些物流订单对应的铲车订单
|
|
|
|
|
+ List<KwtGatekeeperWaybillOrder> gatekeeperOrderList = gatekeeperWaybillOrderRepository
|
|
|
|
|
+ .queryGatekeeperWaybillOrderByLogOrderIds(logOrderIds);
|
|
|
|
|
+
|
|
|
|
|
+ gatekeeperOrderIds.addAll(gatekeeperOrderList.stream()
|
|
|
|
|
+ .map(KwtGatekeeperWaybillOrder::getId)
|
|
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取门卫订单数据
|
|
* 获取门卫订单数据
|