Commit 643d6e5d by 章家宝

feat(report):车辆库存分析改成从收车端获取数据

1 parent bd73019f
...@@ -20,6 +20,7 @@ import java.util.List; ...@@ -20,6 +20,7 @@ import java.util.List;
* 报表数据接口(供收车端调用) * 报表数据接口(供收车端调用)
* <p> * <p>
* 提供收车端所需的原始数据查询接口,按车辆明细返回,不做聚合计算。 * 提供收车端所需的原始数据查询接口,按车辆明细返回,不做聚合计算。
* 所有车辆维度数据统一过滤 vehicleSource IN (RECEIVE收车端推送, AUCTION拍卖端自建)。
* 所有接口均有日志记录,便于排查问题。 * 所有接口均有日志记录,便于排查问题。
* </p> * </p>
* *
...@@ -91,13 +92,12 @@ public class ReportDataController { ...@@ -91,13 +92,12 @@ public class ReportDataController {
return reportDataService.getDailyDisposalSnapshot(date); return reportDataService.getDailyDisposalSnapshot(date);
} }
@GetMapping("/inventory/summary") @GetMapping("/vehicle-sync-time")
@Operation(summary = "在库车辆汇总", description = "统计指定日期仍处于在库状态(已入库且未处置完成)的车辆台数、金额、平均在库天数、超期台数") @Operation(summary = "车辆同步时间", description = "按评估单号批量返回车辆档案生成时间(即收车端推送/同步到拍卖端的时刻),供在库周转天数计算")
public InventorySummaryVO getInventorySummary( public List<VehicleSyncTimeVO> getVehicleSyncTimes(
@Parameter(description = "快照日期(yyyy-MM-dd)", required = true) @Parameter(description = "评估单号列表(逗号分隔)", required = true)
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date, @RequestParam List<String> evalOrderNos) {
@Parameter(description = "超期天数阈值", required = true) @RequestParam int overdueDays) { log.info("【报表接口】车辆同步时间 - evalOrderNos数量={}", evalOrderNos == null ? 0 : evalOrderNos.size());
log.info("【报表接口】在库车辆汇总 - date={}, overdueDays={}", date, overdueDays); return reportDataService.getVehicleSyncTimes(evalOrderNos);
return reportDataService.getInventorySummary(date, overdueDays);
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -21,16 +21,18 @@ public interface AppraisePriceDao extends BaseRepository<AppraisePrice, Integer> ...@@ -21,16 +21,18 @@ public interface AppraisePriceDao extends BaseRepository<AppraisePrice, Integer>
List<AppraisePrice> findByVehicle_VehicleIdAndAuditStateNotOrderByCreateTimeDesc(int vehicleId, AuditState auditState); List<AppraisePrice> findByVehicle_VehicleIdAndAuditStateNotOrderByCreateTimeDesc(int vehicleId, AuditState auditState);
/** /**
* 按月查询定价完成的记录(含车辆信息) * 按月查询定价完成的记录(含车辆信息,仅限指定车辆来源)
* 用于收车端日报拉取 * 用于收车端日报拉取
* *
* @param year 年份 * @param year 年份
* @param month 月份 * @param month 月份
* @param auditState 审核状态
* @param vehicleSources 车辆来源集合
* @return 定价记录列表 * @return 定价记录列表
*/ */
@EntityGraph(attributePaths = {"vehicle"}) @EntityGraph(attributePaths = {"vehicle"})
@Query("select a from AppraisePrice a where year(a.createTime) = ?1 and month(a.createTime) = ?2 and a.auditState = ?3") @Query("select a from AppraisePrice a where year(a.createTime) = ?1 and month(a.createTime) = ?2 and a.auditState = ?3 and a.vehicle.vehicleSource in ?4")
List<AppraisePrice> findByCreateTimeYearAndMonthAndAuditState(int year, int month, AuditState auditState); List<AppraisePrice> findByCreateTimeYearAndMonthAndAuditState(int year, int month, AuditState auditState, List<Vehicle.VehicleSource> vehicleSources);
/** /**
* 批量查询车辆的审核通过定价记录(按定价时间倒序) * 批量查询车辆的审核通过定价记录(按定价时间倒序)
......
...@@ -216,27 +216,30 @@ public interface AuctionOrderDao extends BaseRepository<AuctionOrder, Integer>, ...@@ -216,27 +216,30 @@ public interface AuctionOrderDao extends BaseRepository<AuctionOrder, Integer>,
Optional<ProfitRadioProjection> calOrderProfitRadio(AuctionOrder.OrderState orderState); Optional<ProfitRadioProjection> calOrderProfitRadio(AuctionOrder.OrderState orderState);
/** /**
* 按月查询处置成交明细(含车辆和拍场信息) * 按月查询处置成交明细(含车辆和拍场信息,仅限指定车辆来源)
* 用于收车端日报拉取 * 用于收车端日报拉取
* *
* @param year 年份 * @param year 年份
* @param month 月份 * @param month 月份
* @param orderState 订单状态
* @param vehicleSources 车辆来源集合
* @return 拍卖订单列表 * @return 拍卖订单列表
*/ */
@EntityGraph(attributePaths = {"vehicle", "auction"}) @EntityGraph(attributePaths = {"vehicle", "auction"})
@Query("select o from AuctionOrder o where year(o.transferredTime) = ?1 and month(o.transferredTime) = ?2 and o.orderState = ?3") @Query("select o from AuctionOrder o where year(o.transferredTime) = ?1 and month(o.transferredTime) = ?2 and o.orderState = ?3 and o.vehicle.vehicleSource in ?4")
List<AuctionOrder> findByTransferredTimeYearAndMonth(int year, int month, AuctionOrder.OrderState orderState); List<AuctionOrder> findByTransferredTimeYearAndMonth(int year, int month, AuctionOrder.OrderState orderState, List<Vehicle.VehicleSource> vehicleSources);
/** /**
* 按日查询处置快照(含车辆信息) * 按日查询处置快照(含车辆信息,仅限指定车辆来源)
* 用于收车端每日快照拉取 * 用于收车端每日快照拉取
* *
* @param date 日期 * @param date 日期
* @param vehicleSources 车辆来源集合
* @return 拍卖订单列表 * @return 拍卖订单列表
*/ */
@EntityGraph(attributePaths = {"vehicle"}) @EntityGraph(attributePaths = {"vehicle"})
@Query("select o from AuctionOrder o where date(o.createTime) = ?1") @Query("select o from AuctionOrder o where date(o.createTime) = ?1 and o.vehicle.vehicleSource in ?2")
List<AuctionOrder> findByCreateTimeDate(java.time.LocalDate date); List<AuctionOrder> findByCreateTimeDate(java.time.LocalDate date, List<Vehicle.VehicleSource> vehicleSources);
} }
interface AuctionOrderDaoPlus { interface AuctionOrderDaoPlus {
......
...@@ -118,16 +118,17 @@ public interface AuctionVehicleDao extends BaseRepository<AuctionVehicle, Intege ...@@ -118,16 +118,17 @@ public interface AuctionVehicleDao extends BaseRepository<AuctionVehicle, Intege
List<VehicleIdCountProjection> countByVehicleIdIn(List<Integer> vehicleIds); List<VehicleIdCountProjection> countByVehicleIdIn(List<Integer> vehicleIds);
/** /**
* 按拍场名称模糊查询拍卖车辆(用于按拍场名统计) * 按拍场名称模糊查询拍卖车辆(用于按拍场名统计,仅限指定车辆来源)
* *
* @param auctionName 拍场名称模糊关键字 * @param auctionName 拍场名称模糊关键字
* @param year 年份 * @param year 年份
* @param month 月份 * @param month 月份
* @param vehicleSources 车辆来源集合
* @return 拍卖车辆列表 * @return 拍卖车辆列表
*/ */
@EntityGraph(attributePaths = {"vehicle", "auction"}) @EntityGraph(attributePaths = {"vehicle", "auction"})
@Query("select av from AuctionVehicle av where av.auction.auctionName like concat('%', ?1, '%') and year(av.auctionStartTime) = ?2 and month(av.auctionStartTime) = ?3") @Query("select av from AuctionVehicle av where av.auction.auctionName like concat('%', ?1, '%') and year(av.auctionStartTime) = ?2 and month(av.auctionStartTime) = ?3 and av.vehicle.vehicleSource in ?4")
List<AuctionVehicle> findByAuctionNameLikeAndYearMonth(String auctionName, int year, int month); List<AuctionVehicle> findByAuctionNameLikeAndYearMonth(String auctionName, int year, int month, List<Vehicle.VehicleSource> vehicleSources);
/** /**
* 按月查询某车辆的所有拍卖记录(按拍卖开始时间升序) * 按月查询某车辆的所有拍卖记录(按拍卖开始时间升序)
......
...@@ -20,7 +20,6 @@ import org.springframework.util.CollectionUtils; ...@@ -20,7 +20,6 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -32,6 +31,7 @@ import java.util.stream.Collectors; ...@@ -32,6 +31,7 @@ import java.util.stream.Collectors;
* 报表数据查询服务(拍卖端原始数据接口) * 报表数据查询服务(拍卖端原始数据接口)
* <p> * <p>
* 提供收车端所需的原始数据查询接口,按车辆明细返回,不做聚合计算。 * 提供收车端所需的原始数据查询接口,按车辆明细返回,不做聚合计算。
* 所有车辆维度数据统一过滤 vehicleSource IN (RECEIVE收车端推送, AUCTION拍卖端自建)。
* 所有接口均有日志记录,便于排查问题。 * 所有接口均有日志记录,便于排查问题。
* </p> * </p>
* *
...@@ -43,6 +43,9 @@ import java.util.stream.Collectors; ...@@ -43,6 +43,9 @@ import java.util.stream.Collectors;
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class ReportDataService { public class ReportDataService {
private static final List<Vehicle.VehicleSource> REPORT_VEHICLE_SOURCES =
List.of(Vehicle.VehicleSource.RECEIVE, Vehicle.VehicleSource.AUCTION);
@Resource @Resource
private AuctionOrderDao auctionOrderDao; private AuctionOrderDao auctionOrderDao;
...@@ -65,7 +68,7 @@ public class ReportDataService { ...@@ -65,7 +68,7 @@ public class ReportDataService {
public List<MonthlyDisposalDetailVO> getMonthlyDisposalDetail(int year, int month) { public List<MonthlyDisposalDetailVO> getMonthlyDisposalDetail(int year, int month) {
log.info("【报表数据查询】按月处置成交明细 - year={}, month={}", year, month); log.info("【报表数据查询】按月处置成交明细 - year={}, month={}", year, month);
List<AuctionOrder> orders = auctionOrderDao.findByTransferredTimeYearAndMonth(year, month, AuctionOrder.OrderState.COMPLETED); List<AuctionOrder> orders = auctionOrderDao.findByTransferredTimeYearAndMonth(year, month, AuctionOrder.OrderState.COMPLETED, REPORT_VEHICLE_SOURCES);
if (CollectionUtils.isEmpty(orders)) { if (CollectionUtils.isEmpty(orders)) {
log.info("【报表数据查询】按月处置成交明细 - 无数据, year={}, month={}", year, month); log.info("【报表数据查询】按月处置成交明细 - 无数据, year={}, month={}", year, month);
return new ArrayList<>(); return new ArrayList<>();
...@@ -114,7 +117,7 @@ public class ReportDataService { ...@@ -114,7 +117,7 @@ public class ReportDataService {
public List<MonthlyPricingDetailVO> getMonthlyPricingDetail(int year, int month) { public List<MonthlyPricingDetailVO> getMonthlyPricingDetail(int year, int month) {
log.info("【报表数据查询】按月定价明细 - year={}, month={}", year, month); log.info("【报表数据查询】按月定价明细 - year={}, month={}", year, month);
List<AppraisePrice> prices = appraisePriceDao.findByCreateTimeYearAndMonthAndAuditState(year, month, AuditState.AUDITED); List<AppraisePrice> prices = appraisePriceDao.findByCreateTimeYearAndMonthAndAuditState(year, month, AuditState.AUDITED, REPORT_VEHICLE_SOURCES);
if (CollectionUtils.isEmpty(prices)) { if (CollectionUtils.isEmpty(prices)) {
log.info("【报表数据查询】按月定价明细 - 无数据, year={}, month={}", year, month); log.info("【报表数据查询】按月定价明细 - 无数据, year={}, month={}", year, month);
return new ArrayList<>(); return new ArrayList<>();
...@@ -146,7 +149,7 @@ public class ReportDataService { ...@@ -146,7 +149,7 @@ public class ReportDataService {
public List<MonthlyVehicleArchiveVO> getMonthlyVehicleArchive(int year, int month) { public List<MonthlyVehicleArchiveVO> getMonthlyVehicleArchive(int year, int month) {
log.info("【报表数据查询】按月车辆档案 - year={}, month={}", year, month); log.info("【报表数据查询】按月车辆档案 - year={}, month={}", year, month);
List<Vehicle> vehicles = vehicleDao.findByTransferredTimeYearAndMonth(year, month); List<Vehicle> vehicles = vehicleDao.findByTransferredTimeYearAndMonth(year, month, REPORT_VEHICLE_SOURCES);
if (CollectionUtils.isEmpty(vehicles)) { if (CollectionUtils.isEmpty(vehicles)) {
log.info("【报表数据查询】按月车辆档案 - 无数据, year={}, month={}", year, month); log.info("【报表数据查询】按月车辆档案 - 无数据, year={}, month={}", year, month);
return new ArrayList<>(); return new ArrayList<>();
...@@ -180,7 +183,7 @@ public class ReportDataService { ...@@ -180,7 +183,7 @@ public class ReportDataService {
public List<AuctionNameStatVO> getAuctionNameStat(int year, int month, String auctionName) { public List<AuctionNameStatVO> getAuctionNameStat(int year, int month, String auctionName) {
log.info("【报表数据查询】按拍场名统计 - year={}, month={}, auctionName={}", year, month, auctionName); log.info("【报表数据查询】按拍场名统计 - year={}, month={}, auctionName={}", year, month, auctionName);
List<AuctionVehicle> list = auctionVehicleDao.findByAuctionNameLikeAndYearMonth(auctionName, year, month); List<AuctionVehicle> list = auctionVehicleDao.findByAuctionNameLikeAndYearMonth(auctionName, year, month, REPORT_VEHICLE_SOURCES);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
log.info("【报表数据查询】按拍场名统计 - 无数据, year={}, month={}, auctionName={}", year, month, auctionName); log.info("【报表数据查询】按拍场名统计 - 无数据, year={}, month={}, auctionName={}", year, month, auctionName);
return new ArrayList<>(); return new ArrayList<>();
...@@ -212,7 +215,7 @@ public class ReportDataService { ...@@ -212,7 +215,7 @@ public class ReportDataService {
log.info("【报表数据查询】按拍卖次数区分成交 - year={}, month={}", year, month); log.info("【报表数据查询】按拍卖次数区分成交 - year={}, month={}", year, month);
// 先获取当月所有处置完成的车辆ID // 先获取当月所有处置完成的车辆ID
List<AuctionOrder> orders = auctionOrderDao.findByTransferredTimeYearAndMonth(year, month, AuctionOrder.OrderState.COMPLETED); List<AuctionOrder> orders = auctionOrderDao.findByTransferredTimeYearAndMonth(year, month, AuctionOrder.OrderState.COMPLETED, REPORT_VEHICLE_SOURCES);
if (CollectionUtils.isEmpty(orders)) { if (CollectionUtils.isEmpty(orders)) {
log.info("【报表数据查询】按拍卖次数区分成交 - 当月无处置完成数据, year={}, month={}", year, month); log.info("【报表数据查询】按拍卖次数区分成交 - 当月无处置完成数据, year={}, month={}", year, month);
return new ArrayList<>(); return new ArrayList<>();
...@@ -275,7 +278,7 @@ public class ReportDataService { ...@@ -275,7 +278,7 @@ public class ReportDataService {
public List<DailyDisposalSnapshotVO> getDailyDisposalSnapshot(LocalDate date) { public List<DailyDisposalSnapshotVO> getDailyDisposalSnapshot(LocalDate date) {
log.info("【报表数据查询】按日处置快照 - date={}", date); log.info("【报表数据查询】按日处置快照 - date={}", date);
List<AuctionOrder> orders = auctionOrderDao.findByCreateTimeDate(date); List<AuctionOrder> orders = auctionOrderDao.findByCreateTimeDate(date, REPORT_VEHICLE_SOURCES);
if (CollectionUtils.isEmpty(orders)) { if (CollectionUtils.isEmpty(orders)) {
log.info("【报表数据查询】按日处置快照 - 无数据, date={}", date); log.info("【报表数据查询】按日处置快照 - 无数据, date={}", date);
return new ArrayList<>(); return new ArrayList<>();
...@@ -299,52 +302,31 @@ public class ReportDataService { ...@@ -299,52 +302,31 @@ public class ReportDataService {
} }
/** /**
* 统计指定日期的在库车辆汇总(已入库且未处置完成) * 按评估单号批量查询车辆同步时间
* <p>在库口径:入库时间早于快照日期次日零点,且无早于快照日期次日零点的处置完成时间(transferredTime),
* 排除待入库/已取消状态。在库天数=快照日期-入库日期,均值四舍五入取整;
* 超期=在库天数超过 overdueDays 阈值;金额为收购价合计。</p>
* *
* @param date 快照日期(yyyy-MM-dd) * @param evalOrderNos 评估单号列表
* @param overdueDays 超期天数阈值(由调用方传入) * @return 同步时间列表(仅返回拍卖端存在的车辆档案)
* @return 在库车辆汇总
*/ */
public InventorySummaryVO getInventorySummary(LocalDate date, int overdueDays) { public List<VehicleSyncTimeVO> getVehicleSyncTimes(List<String> evalOrderNos) {
log.info("【报表数据查询】在库车辆汇总 - date={}, overdueDays={}", date, overdueDays); log.info("【报表数据查询】车辆同步时间 - evalOrderNos数量={}", CollectionUtils.isEmpty(evalOrderNos) ? 0 : evalOrderNos.size());
if (CollectionUtils.isEmpty(evalOrderNos)) {
LocalDateTime snapshotEnd = date.plusDays(1).atStartOfDay(); return new ArrayList<>();
List<Vehicle> vehicles = vehicleDao.findInStockBefore(snapshotEnd, }
List.of(Vehicle.VehicleState.INVENTORY, Vehicle.VehicleState.CANCELED));
List<String> distinctOrderNos = evalOrderNos.stream().filter(Objects::nonNull).distinct().toList();
int totalQuantity = vehicles.size(); if (distinctOrderNos.isEmpty()) {
BigDecimal totalAmount = BigDecimal.ZERO; return new ArrayList<>();
long daySum = 0;
int overdueQuantity = 0;
for (Vehicle vehicle : vehicles) {
if (vehicle.getEvaluationTransaction() != null) {
totalAmount = totalAmount.add(BigDecimal.valueOf(
vehicle.getEvaluationTransaction().getPurchasePrice()));
}
if (vehicle.getWarehousingTime() != null) {
long days = Math.max(0, ChronoUnit.DAYS.between(
vehicle.getWarehousingTime().toLocalDate(), date));
daySum += days;
if (days > overdueDays) {
overdueQuantity++;
}
}
} }
InventorySummaryVO result = InventorySummaryVO.builder() List<Vehicle> vehicles = vehicleDao.findByEvaluationTransaction_EvalOrderNoInAndVehicleSourceIn(distinctOrderNos, REPORT_VEHICLE_SOURCES);
.totalQuantity(totalQuantity) List<VehicleSyncTimeVO> result = vehicles.stream().map(vehicle -> VehicleSyncTimeVO.builder()
.totalAmount(totalAmount) .evalOrderNo(vehicle.getEvaluationTransaction() != null
.avgInStockDays(vehicles.isEmpty() ? 0 ? vehicle.getEvaluationTransaction().getEvalOrderNo() : null)
: (int) Math.round((double) daySum / vehicles.size())) .syncTime(vehicle.getCreateTime())
.overdueQuantity(overdueQuantity) .build()
.build(); ).toList();
log.info("【报表数据查询】在库车辆汇总 - date={}, 在库{}台, 金额{}, 均值{}天, 超期{}台", log.info("【报表数据查询】车辆同步时间 - 返回 {} 条记录", result.size());
date, result.getTotalQuantity(), result.getTotalAmount(),
result.getAvgInStockDays(), result.getOverdueQuantity());
return result; return result;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -6,33 +6,26 @@ import lombok.Builder; ...@@ -6,33 +6,26 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.math.BigDecimal; import java.time.LocalDateTime;
/** /**
* 在库车辆汇总 VO * 车辆同步时间VO
* *
* <p>统计指定日期仍处于"在库"状态(已入库且未处置完成)的车辆: * <p>车辆档案由收车端推送时创建,createTime 即同步时刻,供收车端在库周转天数计算。</p>
* 台数、收购金额合计、平均在库天数(周转天数)、超期台数。</p>
* *
* @author Claude * @author Claude
* @since 2026-09-03 * @since 2026-09-11
*/ */
@Data @Data
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Schema(description = "在库车辆汇总") @Schema(description = "车辆同步时间VO")
public class InventorySummaryVO { public class VehicleSyncTimeVO {
@Schema(description = "在库合计车辆数(台)") @Schema(description = "评估单号")
private Integer totalQuantity; private String evalOrderNo;
@Schema(description = "在库合计金额(元,收购价合计)") @Schema(description = "同步时间(车辆档案生成时间)")
private BigDecimal totalAmount; private LocalDateTime syncTime;
@Schema(description = "平均在库天数(快照日期-入库日期的均值,四舍五入取整)")
private Integer avgInStockDays;
@Schema(description = "超期台数(在库天数超过调用方传入的overdueDays阈值)")
private Integer overdueQuantity;
} }
...@@ -10,7 +10,6 @@ import org.summerframework.orm.BaseRepository; ...@@ -10,7 +10,6 @@ import org.summerframework.orm.BaseRepository;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -63,27 +62,24 @@ public interface VehicleDao extends BaseRepository<Vehicle, Integer>, JpaSpecifi ...@@ -63,27 +62,24 @@ public interface VehicleDao extends BaseRepository<Vehicle, Integer>, JpaSpecifi
List<String> findBySourceNoVehicleStateNot(List<Integer> vehicleIds, Vehicle.VehicleState vehicleState); List<String> findBySourceNoVehicleStateNot(List<Integer> vehicleIds, Vehicle.VehicleState vehicleState);
/** /**
* 按月查询车辆档案(含已完成的车辆) * 按月查询车辆档案(含已完成的车辆,仅限指定车辆来源)
* 用于收车端日报拉取 * 用于收车端日报拉取
* *
* @param year 年份 * @param year 年份
* @param month 月份 * @param month 月份
* @param vehicleSources 车辆来源集合
* @return 车辆列表 * @return 车辆列表
*/ */
@Query("select v from Vehicle v where year(v.transferredTime) = ?1 and month(v.transferredTime) = ?2") @Query("select v from Vehicle v where year(v.transferredTime) = ?1 and month(v.transferredTime) = ?2 and v.vehicleSource in ?3")
List<Vehicle> findByTransferredTimeYearAndMonth(int year, int month); List<Vehicle> findByTransferredTimeYearAndMonth(int year, int month, List<Vehicle.VehicleSource> vehicleSources);
/** /**
* 查询指定时刻的在库车辆(已入库、未处置完成) * 按评估单号批量查询车辆档案(车辆档案由收车端推送时创建,createTime 即同步时刻,仅限指定车辆来源)
* 用于收车端日报在库车辆分析:入库时间早于快照时刻,且无早于快照时刻的处置完成时间
* *
* @param snapshotEnd 快照时刻(开区间上界,通常取快照日期次日零点) * @param evalOrderNos 评估单号列表
* @param excludedStates 排除的车辆状态(待入库/已取消) * @param vehicleSources 车辆来源集合
* @return 在库车辆列表 * @return 车辆列表
*/ */
@Query("select v from Vehicle v where v.warehousingTime is not null and v.warehousingTime < ?1" List<Vehicle> findByEvaluationTransaction_EvalOrderNoInAndVehicleSourceIn(List<String> evalOrderNos, List<Vehicle.VehicleSource> vehicleSources);
+ " and (v.transferredTime is null or v.transferredTime >= ?1)"
+ " and v.vehicleState not in ?2")
List<Vehicle> findInStockBefore(LocalDateTime snapshotEnd, Collection<Vehicle.VehicleState> excludedStates);
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!