Parcourir la source

友盛报表修复

donglang il y a 14 heures
Parent
commit
b2ac707720

+ 16 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/repository/KwtGatekeeperWaybillOrderRepository.java

@@ -7,6 +7,7 @@ import com.sckw.transport.dao.KwtGatekeeperWaybillOrderMapper;
 import com.sckw.transport.model.KwtGatekeeperWaybillOrder;
 import org.springframework.stereotype.Repository;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Set;
 
@@ -52,11 +53,24 @@ public class KwtGatekeeperWaybillOrderRepository extends ServiceImpl<KwtGatekeep
                         .orderByDesc(KwtGatekeeperWaybillOrder::getId));
     }
 
-    public List<KwtGatekeeperWaybillOrder> queryGatekeeperByWaybillOrders(List<Long> waybillOrderIds, Integer type) {
+    public List<KwtGatekeeperWaybillOrder> queryGatekeeperByWaybillOrders(Long entId, Set<Long> lOrderIds, Integer type, Date startOfDay, Date endOfDay) {
         return list(
                 Wrappers.<KwtGatekeeperWaybillOrder>lambdaQuery()
-                        .in(CollectionUtils.isNotEmpty(waybillOrderIds), KwtGatekeeperWaybillOrder::getWOrderId, waybillOrderIds)
+                        .eq(KwtGatekeeperWaybillOrder::getEntId, entId)
+                        .in(KwtGatekeeperWaybillOrder::getLOrderId, lOrderIds)
                         .eq(KwtGatekeeperWaybillOrder::getType, type)
+                        .ge(KwtGatekeeperWaybillOrder::getLeaveTime, startOfDay)
+                        .le(KwtGatekeeperWaybillOrder::getLeaveTime, endOfDay)
+                        .orderByDesc(KwtGatekeeperWaybillOrder::getId));
+    }
+
+    public List<KwtGatekeeperWaybillOrder> queryGatekeeperByWaybillOrders(List<Long> entIds, Set<Long> lOrderIds, Date startOfDay, Date endOfDay) {
+        return list(
+                Wrappers.<KwtGatekeeperWaybillOrder>lambdaQuery()
+                        .in(KwtGatekeeperWaybillOrder::getEntId, entIds)
+                        .in(KwtGatekeeperWaybillOrder::getLOrderId, lOrderIds)
+                        .ge(KwtGatekeeperWaybillOrder::getLeaveTime, startOfDay)
+                        .le(KwtGatekeeperWaybillOrder::getLeaveTime, endOfDay)
                         .orderByDesc(KwtGatekeeperWaybillOrder::getId));
     }
 

+ 42 - 36
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/app/WaybillOrderService.java

@@ -2047,15 +2047,29 @@ public class WaybillOrderService {
         Map<Long, KwtLogisticsOrderAddress> addressMap = lOrderAddresseList.stream()
                 .collect(Collectors.toMap(KwtLogisticsOrderAddress::getLOrderId, Function.identity(), (x, y) -> x));
 
-        // 6.运单
-        List<KwtWaybillOrder> waybillOrderList = queryWaybillOrders(param, lOrderIds);
+        // 6.门卫
+        //当天开始时间
+        Date startOfDay = DateUtils.getStartOfDay(param.getOneDayTime(), DateUtils.DATE_TIME_PATTERN);
+        //当天结算时间
+        Date endOfDay = DateUtils.getEndOfDay(param.getOneDayTime());
+        List<KwtGatekeeperWaybillOrder> gatekeepers = gatekeeperWaybillOrderRepository.queryGatekeeperByWaybillOrders(param.getEntId(), lOrderIds, Global.ADDRESS_LOAD, startOfDay, endOfDay);
+        if (CollectionUtils.isEmpty(gatekeepers)) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "门卫运单不存在,entId:" + JSON.toJSONString(param.getEntId()));
+        }
+        log.info("门卫,size:{}", gatekeepers.size());
+        Set<Long> gateWorderIds = gatekeepers.stream().map(KwtGatekeeperWaybillOrder::getWOrderId).collect(Collectors.toSet());
+        Map<Long, KwtGatekeeperWaybillOrder> gatekeeperMap = gatekeepers.stream()
+                .collect(Collectors.toMap(KwtGatekeeperWaybillOrder::getWOrderId, Function.identity(), (x, y) -> x));
+
+        // 7.运单
+        List<KwtWaybillOrder> waybillOrderList = queryWaybillOrders(gateWorderIds);
         if (CollectionUtils.isEmpty(waybillOrderList)) {
             return new ArrayList<>();
         }
         List<Long> wOrderIds = waybillOrderList.stream().map(KwtWaybillOrder::getId).collect(Collectors.toList());
         log.info("运单,size:{}", wOrderIds.size());
 
-        // 7. 运单装货单
+        // 8. 运单装货单
         List<KwtWaybillOrderTicket> ticketList = waybillOrderTicketRepository.queryByWOrderIdsAndType(wOrderIds, Global.ADDRESS_LOAD);
         if (CollectionUtils.isEmpty(ticketList)) {
             throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "运单装货单不存在,wOrderIds:" + JSON.toJSONString(wOrderIds));
@@ -2064,16 +2078,7 @@ public class WaybillOrderService {
         Map<Long, KwtWaybillOrderTicket> ticketMap = ticketList.stream()
                 .collect(Collectors.toMap(KwtWaybillOrderTicket::getWOrderId, Function.identity(), (x, y) -> x));
 
-        // 8.门卫
-        List<KwtGatekeeperWaybillOrder> gatekeepers = gatekeeperWaybillOrderRepository.queryGatekeeperByWaybillOrders(wOrderIds, Global.ADDRESS_LOAD);
-        if (CollectionUtils.isEmpty(gatekeepers)) {
-            throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "门卫运单不存在,wOrderIds:" + JSON.toJSONString(wOrderIds));
-        }
-        log.info("门卫,size:{}", gatekeepers.size());
-        Map<Long, KwtGatekeeperWaybillOrder> gatekeeperMap = gatekeepers.stream()
-                .collect(Collectors.toMap(KwtGatekeeperWaybillOrder::getWOrderId, Function.identity(), (x, y) -> x));
-
-        //铲车
+        // 9.铲车
         List<KwtForkliftWaybillOrder> forklifts = forkliftWaybillOrderRepository.queryForkliftByWOrderIdsAndType(wOrderIds, Global.NUMERICAL_ZERO);
         if (CollectionUtils.isEmpty(forklifts)) {
             throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "铲车订单不存在,wOrderIds:" + JSON.toJSONString(wOrderIds));
@@ -2091,17 +2096,14 @@ public class WaybillOrderService {
     }
 
 
-
-    private List<KwtWaybillOrder> queryWaybillOrders(WaybillOrderReportQueryParam param, Set<Long> lOrderIds) {
-        //当天开始时间
-        Date startOfDay = DateUtils.getStartOfDay(param.getOneDayTime(), DateUtils.DATE_TIME_PATTERN);
-        //当天结算时间
-        Date endOfDay = DateUtils.getEndOfDay(param.getOneDayTime());
-
+    /**
+     * 查询运单
+     * @param wOrderIds
+     * @return
+     */
+    private List<KwtWaybillOrder> queryWaybillOrders(Set<Long> wOrderIds) {
         LambdaQueryWrapper<KwtWaybillOrder> queryWrapper = Wrappers.<KwtWaybillOrder>lambdaQuery()
-                .in(KwtWaybillOrder::getLOrderId, lOrderIds)
-                .ge(KwtWaybillOrder::getUpdateTime, startOfDay)
-                .le(KwtWaybillOrder::getUpdateTime, endOfDay)
+                .in(KwtWaybillOrder::getId, wOrderIds)
                 .eq(KwtWaybillOrder::getStatus,25)
                 .isNull(KwtWaybillOrder::getRemark)
                 .eq(KwtWaybillOrder::getDelFlag, 0)
@@ -2109,7 +2111,7 @@ public class WaybillOrderService {
 
         List<KwtWaybillOrder> waybillOrderList = waybillOrderRepository.list(queryWrapper);
         if (CollectionUtils.isEmpty(waybillOrderList)) {
-            log.info("物流运单不存在!,lOrderIds:{}", JSON.toJSONString(lOrderIds));
+            log.info("物流运单不存在!,wOrderIds:{}", JSON.toJSONString(wOrderIds));
             return new ArrayList<>();
         }
         return waybillOrderList;
@@ -2354,16 +2356,29 @@ public class WaybillOrderService {
         Map<Long, KwtLogisticsOrder> logOrderMap = logisticsOrders.stream()
                 .collect(Collectors.toMap(KwtLogisticsOrder::getId, Function.identity(), (x, y) -> x));
 
+        // 3.门卫
+        //当天开始时间
+        Date startOfDay = DateUtils.getStartOfDay(param.getOneDayTime(), DateUtils.DATE_TIME_PATTERN);
+        //当天结算时间
+        Date endOfDay = DateUtils.getEndOfDay(param.getOneDayTime());
+        List<KwtGatekeeperWaybillOrder> gatekeepers = gatekeeperWaybillOrderRepository.queryGatekeeperByWaybillOrders(mockEntIds, lOrderIds, startOfDay, endOfDay);
+        if (CollectionUtils.isEmpty(gatekeepers)) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "门卫运单不存在,lOrderIds:" + JSON.toJSONString(lOrderIds));
+        }
+        log.info("门卫,size:{}", gatekeepers.size());
+        Set<Long> gateWorderIds = gatekeepers.stream().map(KwtGatekeeperWaybillOrder::getLOrderId).collect(Collectors.toSet());
+        Map<String, KwtGatekeeperWaybillOrder> gatekeeperMap = gatekeepers.stream().collect(Collectors
+                .toMap(gate -> gate.getWOrderId() + "-" + gate.getType(), Function.identity(), (x, y) -> x));
 
-        // 3.运单
-        List<KwtWaybillOrder> waybillOrderList = queryWaybillOrders(param, lOrderIds);
+        // 4.运单
+        List<KwtWaybillOrder> waybillOrderList = queryWaybillOrders(gateWorderIds);
         if (CollectionUtils.isEmpty(waybillOrderList)) {
             return new ArrayList<>();
         }
         List<Long> wOrderIds = waybillOrderList.stream().map(KwtWaybillOrder::getId).collect(Collectors.toList());
         log.info("运单,size:{}", wOrderIds.size());
 
-        // 4. 运单装货单
+        // 5. 运单装货单
         List<KwtWaybillOrderTicket> ticketList = waybillOrderTicketRepository.queryByWOrderIds(wOrderIds);
         if (CollectionUtils.isEmpty(ticketList)) {
             throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "运单装货单不存在,wOrderIds:" + JSON.toJSONString(wOrderIds));
@@ -2372,15 +2387,6 @@ public class WaybillOrderService {
         Map<String, KwtWaybillOrderTicket> ticketMap = ticketList.stream().collect(Collectors
                 .toMap(ticket -> ticket.getWOrderId() + "-" + ticket.getType(), Function.identity(), (x, y) -> x));
 
-        // 5.门卫
-        List<KwtGatekeeperWaybillOrder> gatekeepers = gatekeeperWaybillOrderRepository.queryGatekeeperWaybillOrderByWOrderIds(wOrderIds);
-        if (CollectionUtils.isEmpty(gatekeepers)) {
-            throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_NOT_FOUND, "门卫运单不存在,wOrderIds:" + JSON.toJSONString(wOrderIds));
-        }
-        log.info("门卫,size:{}", gatekeepers.size());
-        Map<String, KwtGatekeeperWaybillOrder> gatekeeperMap = gatekeepers.stream().collect(Collectors
-                .toMap(gate -> gate.getWOrderId() + "-" + gate.getType(), Function.identity(), (x, y) -> x));
-
         //6.铲车
         List<KwtForkliftWaybillOrder> forklifts = forkliftWaybillOrderRepository.queryForkliftByWOrderIdsAndType(wOrderIds, Global.NUMERICAL_ZERO);
         if (CollectionUtils.isEmpty(forklifts)) {