Kaynağa Gözat

运单列表返回对应的门卫id数据

donglang 2 gün önce
ebeveyn
işleme
e390142adf

+ 21 - 10
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderV1Service.java

@@ -3220,14 +3220,13 @@ public class KwtWaybillOrderV1Service {
 
         //查询门卫订单
         log.debug("开始查询门卫订单");
-        Map<Long, KwtGatekeeperWaybillOrder> gatekeeperMap = new HashMap<>();
+        Map<Long, List<KwtGatekeeperWaybillOrder>> gatekeeperMap = new HashMap<>();
                 Set<Long> wOrderId = records.stream().map(KwtWaybillOrderSubtask::getWOrderId).collect(Collectors.toSet());
         List<KwtGatekeeperWaybillOrder> gatekeeperList = gatekeeperWaybillOrderRepository.queryGatekeeperWaybillOrderByWOrderIds(wOrderId);
 
         if (CollectionUtils.isNotEmpty(gatekeeperList)) {
             gatekeeperMap = gatekeeperList.stream()
-                    .collect(Collectors.toMap(KwtGatekeeperWaybillOrder::getWOrderId,
-                            Function.identity(), (x, y) -> y));
+                    .collect(Collectors.groupingBy(KwtGatekeeperWaybillOrder::getWOrderId));
         }
 
         // 转换为响应对象
@@ -3476,7 +3475,7 @@ public class KwtWaybillOrderV1Service {
             Map<Long, KwtLogisticsOrder> logisticsOrderMap,
             Map<Long, TradeOrderContractVo> tradeOrderContractVoMap,
             Map<String, TradeContractGoodsDto> orderContracGoodstoMap,
-            Map<Long, KwtGatekeeperWaybillOrder> gatekeeperMap) {
+            Map<Long, List<KwtGatekeeperWaybillOrder>> gatekeeperMap) {
 
         return records.stream()
                 .map(record -> buildWaybillOrderResp(record, orderData, dictValueAndDictResDtoMap,logisticsOrderMap, tradeOrderContractVoMap,orderContracGoodstoMap, gatekeeperMap))
@@ -3493,7 +3492,7 @@ public class KwtWaybillOrderV1Service {
             Map<Long, KwtLogisticsOrder> logisticsOrderMap,
             Map<Long, TradeOrderContractVo> tradeOrderContractVoMap,
             Map<String, TradeContractGoodsDto> orderContracGoodstoMap,
-            Map<Long, KwtGatekeeperWaybillOrder> gatekeeperMap) {
+            Map<Long, List<KwtGatekeeperWaybillOrder>> gatekeeperMap) {
 
         return getWaybillOrderResp(
                 record,
@@ -4156,7 +4155,7 @@ public class KwtWaybillOrderV1Service {
                                                         Map<Long, KwtLogisticsOrder> logisticsOrderMap,
                                                         Map<Long, TradeOrderContractVo> tradeOrderContractVoMap,
                                                         Map<String, TradeContractGoodsDto> orderContracGoodstoMap,
-                                                        Map<Long, KwtGatekeeperWaybillOrder> gatekeeperMap) {
+                                                        Map<Long, List<KwtGatekeeperWaybillOrder>> gatekeeperMap) {
         WaybillOrderResp waybillOrderResp = new WaybillOrderResp();
         KwtWaybillOrder billOrder = finalWaybillOrderIdAndBillOrderMap.getOrDefault(record.getWOrderId(),
                 new KwtWaybillOrder());
@@ -4274,9 +4273,8 @@ public class KwtWaybillOrderV1Service {
                 waybillOrderResp.setActualGoodsPrice(actualGoodsPrice.setScale(2, RoundingMode.HALF_UP).toPlainString());
             }
         }
-
-        KwtGatekeeperWaybillOrder gatekeeper = gatekeeperMap.getOrDefault(billOrder.getId(), new KwtGatekeeperWaybillOrder());
-        if (Objects.equals(logOrder.getOrderType(), 1) && Objects.equals(gatekeeper.getType(), 2)){
+        // 如果原矿订单,会有两条门卫订单。门卫放行,只能山上放行山上的,山下只能放行山下的
+        if (Objects.equals(logOrder.getOrderType(), 1)) {
             // 装货重量
             BigDecimal loadAmount = tareAmountTicket.getAmount();
 
@@ -4289,8 +4287,21 @@ public class KwtWaybillOrderV1Service {
             waybillOrderResp.setLossRate(lossRate);
             waybillOrderResp.setIsPassReason(isLossRateExceeded(logOrder, lossRate));
         }
-        waybillOrderResp.setGatekeeperId(gatekeeper.getId());
 
+        // 原矿运输山上、上下门卫企业id
+        List<String> mockEntIds = Arrays.asList("538039617157337089", "538040297439891457");
+        List<KwtGatekeeperWaybillOrder> gatekeeperList = gatekeeperMap.getOrDefault(billOrder.getId(), new ArrayList<>());
+        if (Objects.equals(waybillOrderResp.getConsignUnitId(), mockEntIds.get(0))) {
+            KwtGatekeeperWaybillOrder gatekeeper = gatekeeperList.stream()
+                    .filter(gate -> gate.getType() != null && Objects.equals(gate.getEntId(), mockEntIds.get(0)))
+                    .findFirst().orElse(new KwtGatekeeperWaybillOrder());
+            waybillOrderResp.setGatekeeperId(gatekeeper.getId());
+        } else {
+            KwtGatekeeperWaybillOrder gatekeeper = gatekeeperList.stream()
+                    .filter(gate -> gate.getType() != null && Objects.equals(gate.getEntId(), mockEntIds.get(1)))
+                    .findFirst().orElse(new KwtGatekeeperWaybillOrder());
+            waybillOrderResp.setGatekeeperId(gatekeeper.getId());
+        }
         return waybillOrderResp;
     }