donglang 3 недель назад
Родитель
Сommit
f855a4b05c

+ 3 - 0
sckw-modules-api/sckw-order-api/src/main/java/com/sckw/order/api/dubbo/TradeOrderInfoService.java

@@ -191,4 +191,7 @@ public interface TradeOrderInfoService {
     BuyDto countBuy(CountPara countPara);
 
     GoodsDto countGoods(CountPara countPara);
+
+    List<OrderUnitInfoDetailVO> queryOrderUnitByTradeOrderId(Long tradeOrderId);
+
 }

+ 20 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java

@@ -999,5 +999,25 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
                 .filter(Objects::nonNull)
                 .collect(Collectors.toSet());
     }
+    @Override
+    public List<OrderUnitInfoDetailVO> queryOrderUnitByTradeOrderId(Long tradeOrderId) {
+        List<KwoTradeOrderUnit> tradeOrderUnits = kwoTradeOrderUnitRepository.queryByOrderId(tradeOrderId);
+        if (CollectionUtils.isEmpty(tradeOrderUnits)) {
+            return Collections.emptyList();
+        }
+        return tradeOrderUnits.stream().map(unit -> {
+            OrderUnitInfoDetailVO vo = new OrderUnitInfoDetailVO();
+            vo.setId(unit.getId());
+            vo.setTOrderId(unit.getTOrderId());
+            vo.setTOrderNo(unit.getTOrderNo());
+            vo.setUnitType(unit.getUnitType());
+            vo.setEntId(unit.getEntId());
+            vo.setFirmName(unit.getFirmName());
+            vo.setContactsId(unit.getContactsId());
+            vo.setContacts(unit.getContacts());
+            vo.setPhone(unit.getPhone());
+            return vo;
+        }).collect(Collectors.toList());
+    }
 
 }

+ 31 - 12
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/handler/TakingOrderHandler.java

@@ -13,8 +13,8 @@ import com.sckw.fleet.api.model.vo.RDriverScoreVo;
 import com.sckw.fleet.api.model.vo.RDriverVo;
 import com.sckw.fleet.api.model.vo.RTruckVo;
 import com.sckw.fleet.api.model.vo.TruckDispatchCoefficientVO;
-import com.sckw.order.api.model.OrderDetailRes;
 import com.sckw.order.api.model.OrderDetailVo;
+import com.sckw.order.api.model.OrderUnitInfoDetailVO;
 import com.sckw.order.api.model.UpdateActualAmountParam;
 import com.sckw.product.api.model.KwpGoods;
 import com.sckw.transport.model.*;
@@ -172,19 +172,11 @@ public class TakingOrderHandler extends AbstractWaybillOrderHandler<OrderCircula
         log.info("开始创建门卫订单,入参参数:{}", JSON.toJSONString(waybillOrder));
         CompletableFuture.runAsync(() -> {
             try {
-//                Long entId = null;
-//                // 原矿运输山上、上下门卫企业id
-//                List<Long> mockEntIds = Arrays.asList(538039617157337089L, 538040297439891457L);
-//                if (Objects.equals(1, logOrder.getOrderType())) {
-//                    entId = mockEntIds.get(0);
-//                } else {
-//                    OrderDetailRes tradeOrderDetail = tradeOrderInfoService.
-//                }
-
-
+                // 获取企业id
+                Long entId = getEntId(logOrder);
 
                 KwtGatekeeperWaybillOrder gatekeeper = new KwtGatekeeperWaybillOrder();
-                gatekeeper.setEntId(waybillOrder.getEntId());
+                gatekeeper.setEntId(entId);
                 gatekeeper.setWOrderId(waybillOrder.getId());
                 gatekeeper.setWOrderNo(waybillOrder.getWOrderNo());
                 gatekeeper.setLOrderId(waybillOrder.getLOrderId());
@@ -223,6 +215,33 @@ public class TakingOrderHandler extends AbstractWaybillOrderHandler<OrderCircula
         });
     }
 
+    /**
+     * 获取企业id
+     * @param logOrder
+     * @return
+     */
+    private Long getEntId(KwtLogisticsOrder logOrder) {
+        log.info("[创建装货门卫]开始查询企业id,入参参数:{}", JSON.toJSONString(logOrder));
+        Long entId;
+        KwtLogisticsOrderUnit kwtLogisticsOrderUnit = logisticsOrderUnitRepository.queryByLOrderIdAndUnitType(logOrder.getId(), 1);
+        if (kwtLogisticsOrderUnit == null) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_FOUND, "[接单]物流企业信息数据不存在");
+        }
+        // 原矿运输山上、上下门卫企业id
+        List<Long> mockEntIds = Arrays.asList(538039617157337089L, 538040297439891457L);
+        if (Objects.equals(1, logOrder.getOrderType()) && mockEntIds.contains(kwtLogisticsOrderUnit.getEntId())) {
+            entId = mockEntIds.get(0);
+        } else {
+            List<OrderUnitInfoDetailVO> unitInfoDetailVOS = tradeOrderInfoService.queryOrderUnitByTradeOrderId(logOrder.getTOrderId());
+            OrderUnitInfoDetailVO unitInfoDetailVO = unitInfoDetailVOS.stream()
+                    .filter(unit -> Objects.equals(unit.getUnitType(), "2"))
+                    .findFirst().orElse(new OrderUnitInfoDetailVO());
+            entId = unitInfoDetailVO.getEntId();
+        }
+        log.info("[创建装货门卫]查询企业id完成,入参参数:{}", JSON.toJSONString(entId));
+        return entId;
+    }
+
     @Override
     protected void calculateAutoDispatchScore(OrderCirculateTakingQueryParam param, KwtWaybillOrder waybillOrder) {
 

+ 24 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/app/GatekeeperOrderService.java

@@ -71,6 +71,8 @@ public class GatekeeperOrderService {
     private final KwtLogisticsOrderGoodsRepository logisticsOrderGoodsRepository;
     private final KwtWaybillOrderNodeRepository waybillOrderNodeRepository;
     private final KwtWaybillOrderWeighbridgeRepository waybillOrderWeighbridgeRepository;
+    @Autowired
+    protected KwtLogisticsOrderUnitRepository logisticsOrderUnitRepository;
 
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteContractService remoteContractService;
@@ -1014,7 +1016,7 @@ public class GatekeeperOrderService {
 
         try {
             KwtGatekeeperWaybillOrder gatekeeper = new KwtGatekeeperWaybillOrder();
-            gatekeeper.setEntId(waybillOrder.getEntId());
+            gatekeeper.setEntId(getEntId(logisticsOrder));
             gatekeeper.setWOrderId(waybillOrder.getId());
             gatekeeper.setWOrderNo(waybillOrder.getWOrderNo());
             gatekeeper.setLOrderId(waybillOrder.getLOrderId());
@@ -1074,6 +1076,27 @@ public class GatekeeperOrderService {
         return subtask;
     }
 
+    /**
+     * 获取企业id
+     * @param logOrder
+     * @return
+     */
+    private Long getEntId(KwtLogisticsOrder logOrder) {
+        log.info("[创建卸货门卫]开始查询企业id,入参参数:{}", JSON.toJSONString(logOrder));
+        Long entId = -1L;
+        KwtLogisticsOrderUnit kwtLogisticsOrderUnit = logisticsOrderUnitRepository.queryByLOrderIdAndUnitType(logOrder.getId(), 1);
+        if (kwtLogisticsOrderUnit == null) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_FOUND, "[接单]物流企业信息数据不存在");
+        }
+        // 原矿运输山上、上下门卫企业id
+        List<Long> mockEntIds = Arrays.asList(538039617157337089L, 538040297439891457L);
+        if (Objects.equals(1, logOrder.getOrderType()) && mockEntIds.contains(kwtLogisticsOrderUnit.getEntId())) {
+            entId = mockEntIds.get(1);
+        }
+        log.info("[创建卸货门卫]查询企业id完成,入参参数:{}", JSON.toJSONString(entId));
+        return entId;
+    }
+
     /**
      * 校验是否可放行
      * @param gatekeeper