Commit 72648680 by 章家宝

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

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