|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.sckw.contract.api.RemoteContractService;
|
|
|
import com.sckw.core.common.enums.enums.ErrorCodeEnum;
|
|
|
import com.sckw.core.exception.BusinessPlatfromException;
|
|
|
@@ -21,7 +22,9 @@ import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.transport.model.*;
|
|
|
import com.sckw.transport.model.param.forklift.reponse.GatekeeperOrderResp;
|
|
|
+import com.sckw.transport.model.param.forklift.request.GatekeeperOrderIsPassParam;
|
|
|
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderPassParam;
|
|
|
+import com.sckw.transport.model.param.forklift.request.GatekeeperOrderPassReasonParam;
|
|
|
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderQueryParam;
|
|
|
import com.sckw.transport.model.vo.StatisticsWaybillResp;
|
|
|
import com.sckw.transport.repository.*;
|
|
|
@@ -30,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
@@ -668,6 +672,124 @@ public class GatekeeperOrderService {
|
|
|
log.info("[门卫放行]记录节点轨迹成功,节点ID:{}", node.getId());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验是否可放行
|
|
|
+ * @param gatekeeper
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ * 保存放行原因并执行门卫放行操作
|
|
|
+ * <p>
|
|
|
+ * 业务流程:
|
|
|
+ * 1. 校验并保存门卫放行的具体原因及凭证图片到运单表
|
|
|
+ * 2. 构建放行参数,调用核心放行逻辑,更新门卫订单状态及运单状态,并记录轨迹
|
|
|
+ *
|
|
|
+ * @param gatekeeper 包含订单ID、放行原因、放行凭证URL及操作人信息的参数对象
|
|
|
+ */
|
|
|
+ public void savePassReason(GatekeeperOrderPassReasonParam gatekeeper) {
|
|
|
+
|
|
|
+ // 1. 保存放行原因及凭证至运单表
|
|
|
+ saveGatePassReason(gatekeeper);
|
|
|
+
|
|
|
+ // 2. 执行门卫放行核心逻辑
|
|
|
+ // 构建放行参数,传递必要的身份标识
|
|
|
+ GatekeeperOrderPassParam passParam = new GatekeeperOrderPassParam();
|
|
|
+ passParam.setId(gatekeeper.getId());
|
|
|
+ passParam.setGatekeeperUserId(gatekeeper.getGatekeeperUserId());
|
|
|
+ passParam.setGatekeeperName(gatekeeper.getGatekeeperName());
|
|
|
+
|
|
|
+ // 调用放行方法,该方法内部会更新门卫订单状态、运单状态、子任务状态并创建节点轨迹
|
|
|
+ pass(passParam);
|
|
|
+
|
|
|
+ log.info("[门卫放行]带原因放行处理完成,订单ID:{}", gatekeeper.getId());
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 保存放行原因
|
|
|
+ * @param gatekeeper
|
|
|
+ */
|
|
|
+ private void saveGatePassReason(GatekeeperOrderPassReasonParam gatekeeper) {
|
|
|
+ log.info("[门卫放行原因]保存放行原因, param:{}", JSON.toJSONString(gatekeeper));
|
|
|
+ KwtGatekeeperWaybillOrder gatekeeperWaybillOrder = gatekeeperWaybillOrderRepository.getById(gatekeeper.getId());
|
|
|
+ if (gatekeeperWaybillOrder == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.GATEKEEPER_ORDER_NOT_FOUND, "[门卫放行原因]门卫订单不存在!");
|
|
|
+ }
|
|
|
+ KwtWaybillOrder waybillOrder = waybillOrderRepository.getById(gatekeeperWaybillOrder.getWOrderId());
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "[门卫放行原因]运单不存在!");
|
|
|
+ }
|
|
|
+ waybillOrder.setPassReason(gatekeeper.getPassReason());
|
|
|
+ waybillOrder.setPassUrl(gatekeeper.getPassUrl());
|
|
|
+ waybillOrderRepository.updateById(waybillOrder);
|
|
|
+ log.info("[门卫放行原因]保存放行原因完成!");
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验车辆是否允许放行
|
|
|
+ * <p>
|
|
|
+ * 业务逻辑:
|
|
|
+ * 1. 校验车牌号非空
|
|
|
+ * 2. 根据车牌号查询最新的运单记录
|
|
|
+ * 3. 根据运单ID查询对应的门卫订单记录
|
|
|
+ * 4. 判断门卫订单状态是否在允许的放行状态列表中
|
|
|
+ *
|
|
|
+ * @param gatekeeper 包含车牌号的校验参数
|
|
|
+ * @return true-允许放行, false-不允许放行
|
|
|
+ */
|
|
|
+ public Boolean checkIsPass(GatekeeperOrderIsPassParam gatekeeper) {
|
|
|
+ log.info("[门卫校验]开始校验车辆是否可放行,入参:{}", JSON.toJSONString(gatekeeper));
|
|
|
+
|
|
|
+ // 1. 参数校验:车牌号不能为空
|
|
|
+ if (StringUtils.isBlank(gatekeeper.getTruckNo())) {
|
|
|
+ log.warn("[门卫校验]校验失败,车牌号为空");
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR, "车牌号不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 根据车牌号查询运单列表
|
|
|
+ List<KwtWaybillOrder> wbOrderByTruckNo = waybillOrderRepository.findWbOrderByTruckNo(gatekeeper.getTruckNo());
|
|
|
+ if (CollectionUtils.isEmpty(wbOrderByTruckNo)) {
|
|
|
+ log.info("[门卫校验]校验结果:未找到该车牌[{}]对应的运单记录,禁止放行", gatekeeper.getTruckNo());
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取最新的一条运单数据(假设列表已按时间倒序排列或取第一条为最新)
|
|
|
+ KwtWaybillOrder waybillOrder = wbOrderByTruckNo.get(0);
|
|
|
+ log.debug("[门卫校验]找到对应运单,运单ID:{},运单号:{}", waybillOrder.getId(), waybillOrder.getWOrderNo());
|
|
|
+
|
|
|
+ // 3. 根据运单ID查询门卫订单
|
|
|
+ List<KwtGatekeeperWaybillOrder> gatekeeperWaybillOrders = gatekeeperWaybillOrderRepository
|
|
|
+ .queryGatekeeperWaybillOrderByWOrderIds(Lists.newArrayList(waybillOrder.getId()));
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(gatekeeperWaybillOrders)) {
|
|
|
+ log.info("[门卫校验]校验结果:运单ID[{}]未关联门卫订单,禁止放行", waybillOrder.getId());
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取对应的门卫订单
|
|
|
+ KwtGatekeeperWaybillOrder gatekeeperWaybillOrder = gatekeeperWaybillOrders.get(0);
|
|
|
+ Integer currentStatus = gatekeeperWaybillOrder.getStatus();
|
|
|
+ log.debug("[门卫校验]找到对应门卫订单,订单ID:{},当前状态:{}", gatekeeperWaybillOrder.getId(), currentStatus);
|
|
|
+
|
|
|
+ // 4. 定义允许放行的状态集合
|
|
|
+ // PENDING_ENTRY: 待进场 (可能用于重新入场或特殊流程)
|
|
|
+ // READY_RELEASE: 已放行/待离场 (正常放行流程)
|
|
|
+ // EXITED: 已离场 (可能用于补录或异常处理)
|
|
|
+ // EMPTY_EXITED: 空车离场
|
|
|
+ List<Integer> PASS_STATUSES = Arrays.asList(
|
|
|
+ GatekeeperStatusEnum.PENDING_ENTRY.getCode(),
|
|
|
+ GatekeeperStatusEnum.READY_RELEASE.getCode(),
|
|
|
+ GatekeeperStatusEnum.EXITED.getCode(),
|
|
|
+ GatekeeperStatusEnum.EMPTY_EXITED.getCode()
|
|
|
+ );
|
|
|
+
|
|
|
+ // 5. 判断当前状态是否允许放行
|
|
|
+ boolean isAllowed = PASS_STATUSES.contains(currentStatus);
|
|
|
+
|
|
|
+ if (isAllowed) {
|
|
|
+ log.info("[门卫校验]校验通过,车牌[{}]当前状态[{}]在允许放行列表中", gatekeeper.getTruckNo(), currentStatus);
|
|
|
+ } else {
|
|
|
+ log.info("[门卫校验]校验拒绝,车牌[{}]当前状态[{}]不在允许放行列表中", gatekeeper.getTruckNo(), currentStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ return isAllowed;
|
|
|
+ }
|
|
|
|
|
|
}
|