Commit 72648680 by 章家宝

feat:将查博士查询到的数据传入到车辆档案表中

1 parent 22828269
......@@ -2,7 +2,10 @@ package com.glsx.usedcar.module.vrsystem.service;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.glsx.usedcar.annotation.DataPermission;
import com.glsx.usedcar.chaboshi.dto.VinAnalysisDTO;
import com.glsx.usedcar.chaboshi.service.ChaboshiService;
import com.glsx.usedcar.consts.common.SymbolConsts;
import com.glsx.usedcar.consts.inspect.JpaQueryConstants;
import com.glsx.usedcar.converts.VrAuditConverter;
......@@ -67,6 +70,8 @@ public class VrAuditService {
private final VrOrgRepository vrOrgRepository;
private final ChaboshiService chaboshiService;
/**
* 拍卖中相关的车辆状态集合,对应发拍单状态为"拍卖中"
*/
......@@ -692,24 +697,25 @@ public class VrAuditService {
* 查找或创建Vehicle:如果车辆档案中已存在同VIN的记录则回填更新,否则创建新记录
*/
private Vehicle findOrCreateVehicle(VrAudit vrAudit) {
Vehicle existingVehicle = vehicleDao.findTopByBaseInfo_Vin(vrAudit.getVin());
if (existingVehicle != null) {
// 车辆档案已存在,回填更新发拍信息
updateVehicleFromVrAudit(existingVehicle, vrAudit);
existingVehicle = vehicleDao.save(existingVehicle);
log.info("根据发拍单回填更新Vehicle成功,vrAuditId={}, vehicleId={}", vrAudit.getId(), existingVehicle.getVehicleId());
return existingVehicle;
// 查询查博士VIN数据
VinAnalysisDTO vinAnalysisDTO = chaboshiService.vinAnalysis(vrAudit.getVin());
if (vinAnalysisDTO != null) {
log.info("查博士VIN查询成功,vin={}", vrAudit.getVin());
} else {
// 不存在,创建新的Vehicle
return createVehicleFromVrAudit(vrAudit);
log.warn("查博士VIN查询无结果,vin={}", vrAudit.getVin());
}
return createVehicleFromVrAudit(vrAudit, vinAnalysisDTO);
}
/**
* 将发拍单信息回填到已存在的车辆档案中,确保车辆档案中的发拍信息保持最新
*/
private void updateVehicleFromVrAudit(Vehicle vehicle, VrAudit vrAudit) {
private void updateVehicleFromVrAudit(Vehicle vehicle, VrAudit vrAudit, VinAnalysisDTO vinAnalysisDTO) {
// 更新车型数据(查博士返回数据转为JSON)
if (vinAnalysisDTO != null) {
vehicle.setCarModelData(JSONUtil.toJsonStr(vinAnalysisDTO));
}
// 更新基础信息
BaseInfo baseInfo = vehicle.getBaseInfo();
if (baseInfo == null) {
......@@ -774,9 +780,14 @@ public class VrAuditService {
/**
* 根据发拍单创建Vehicle实体
*/
private Vehicle createVehicleFromVrAudit(VrAudit vrAudit) {
private Vehicle createVehicleFromVrAudit(VrAudit vrAudit, VinAnalysisDTO vinAnalysisDTO) {
Vehicle vehicle = new Vehicle();
vehicle.setCarModelData("{}");
// 设置车型数据(查博士返回数据转为JSON)
if (vinAnalysisDTO != null) {
vehicle.setCarModelData(JSONUtil.toJsonStr(vinAnalysisDTO));
}
// 设置基础信息 BaseInfo
BaseInfo baseInfo = new BaseInfo();
baseInfo.setVin(vrAudit.getVin());
......@@ -861,7 +872,7 @@ public class VrAuditService {
vehicle.setVrOrgName(vrAudit.getOrgName());
// 设置车辆来源为拍卖端
vehicle.setVehicleSource(Vehicle.VehicleSource.AUCTION);
vehicle.setVehicleSource(Vehicle.VehicleSource.VR);
// 设置是否有行驶证
vehicle.setVehicleLicense(true);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!