Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b0325226
authored
Apr 17, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:【发拍小程序】保存/编辑发拍单
1 parent
0cacdfe3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
224 additions
and
0 deletions
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrAuditService.java
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrAuditService.java
View file @
b032522
package
com
.
glsx
.
usedcar
.
module
.
vrsystem
.
service
;
package
com
.
glsx
.
usedcar
.
module
.
vrsystem
.
service
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
com.glsx.usedcar.module.vehicle.dao.VehicleDao
;
import
com.glsx.usedcar.module.vehicle.domain.CarImage
;
import
com.glsx.usedcar.module.vehicle.entity.*
;
import
com.glsx.usedcar.module.vrsystem.dao.VrAuditRepository
;
import
com.glsx.usedcar.module.vrsystem.dao.VrAuditRepository
;
import
com.glsx.usedcar.module.vrsystem.entity.VrAudit
;
import
com.glsx.usedcar.module.vrsystem.entity.VrAudit
;
import
com.glsx.usedcar.module.vrsystem.vo.VrAuditSaveReqVO
;
import
com.glsx.usedcar.module.vrsystem.vo.VrAuditSaveReqVO
;
...
@@ -13,8 +16,12 @@ import org.springframework.util.StringUtils;
...
@@ -13,8 +16,12 @@ import org.springframework.util.StringUtils;
import
org.summerframework.core.enums.ErrorCodeEnum
;
import
org.summerframework.core.enums.ErrorCodeEnum
;
import
org.summerframework.core.exception.BusinessCodeException
;
import
org.summerframework.core.exception.BusinessCodeException
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* 发拍表(车辆发拍申请)(VehicleRelease) 服务实现类
* 发拍表(车辆发拍申请)(VehicleRelease) 服务实现类
...
@@ -29,6 +36,9 @@ public class VrAuditService {
...
@@ -29,6 +36,9 @@ public class VrAuditService {
@Resource
@Resource
private
VrAuditRepository
vrAuditRepository
;
private
VrAuditRepository
vrAuditRepository
;
@Resource
private
VehicleDao
vehicleDao
;
/**
/**
* 保存/编辑发拍单(支持分步草稿保存及最终提交)
* 保存/编辑发拍单(支持分步草稿保存及最终提交)
*
*
...
@@ -64,6 +74,13 @@ public class VrAuditService {
...
@@ -64,6 +74,13 @@ public class VrAuditService {
if
(
Boolean
.
TRUE
.
equals
(
req
.
getSubmit
()))
{
if
(
Boolean
.
TRUE
.
equals
(
req
.
getSubmit
()))
{
// 最终提交:执行全量必填项校验
// 最终提交:执行全量必填项校验
validateForSubmit
(
entity
,
req
);
validateForSubmit
(
entity
,
req
);
// 第四步提交时,创建待入库状态的Vehicle
if
(
req
.
getStep
()
==
4
)
{
Vehicle
vehicle
=
createVehicleFromVrAudit
(
entity
);
entity
.
setVehicleId
(
vehicle
.
getVehicleId
());
}
entity
.
setStatus
(
VrAudit
.
PublishStatus
.
WAIT_AUCTION
.
getValue
());
entity
.
setStatus
(
VrAudit
.
PublishStatus
.
WAIT_AUCTION
.
getValue
());
entity
.
setSubmitTime
(
LocalDateTime
.
now
());
entity
.
setSubmitTime
(
LocalDateTime
.
now
());
entity
.
setDraftStep
(
4
);
entity
.
setDraftStep
(
4
);
...
@@ -179,4 +196,211 @@ public class VrAuditService {
...
@@ -179,4 +196,211 @@ public class VrAuditService {
String
random
=
RandomUtil
.
randomNumbers
(
4
);
String
random
=
RandomUtil
.
randomNumbers
(
4
);
return
"FP"
+
timestamp
+
random
;
return
"FP"
+
timestamp
+
random
;
}
}
/**
* 根据发拍单创建Vehicle实体
*/
private
Vehicle
createVehicleFromVrAudit
(
VrAudit
vrAudit
)
{
Vehicle
vehicle
=
new
Vehicle
();
// 设置基础信息 BaseInfo
BaseInfo
baseInfo
=
new
BaseInfo
();
baseInfo
.
setVin
(
vrAudit
.
getVin
());
baseInfo
.
setLicensePlate
(
vrAudit
.
getLicensePlate
()
!=
null
?
vrAudit
.
getLicensePlate
()
:
""
);
baseInfo
.
setCarBrandId
(
parseIntOrZero
(
vrAudit
.
getCarBrandId
()));
baseInfo
.
setCarBrand
(
vrAudit
.
getCarBrandName
());
baseInfo
.
setCarSeriesId
(
parseIntOrZero
(
vrAudit
.
getCarSeriesId
()));
baseInfo
.
setCarSeriesName
(
vrAudit
.
getCarSeriesName
());
baseInfo
.
setCarTypeId
(
parseIntOrZero
(
vrAudit
.
getCarTypeId
()));
baseInfo
.
setCarTypeName
(
vrAudit
.
getCarTypeName
());
baseInfo
.
setMileage
(
vrAudit
.
getMileage
()
!=
null
?
vrAudit
.
getMileage
().
multiply
(
BigDecimal
.
valueOf
(
10000
)).
intValue
()
:
0
);
baseInfo
.
setEngineNumber
(
""
);
// 发动机号,默认空
baseInfo
.
setSourceNo
(
vrAudit
.
getPublishNo
());
// 使用发拍单号作为车源号
baseInfo
.
setGuidePrice
(
0
);
// 新车指导价,默认0
vehicle
.
setBaseInfo
(
baseInfo
);
// 设置核心参数 CoreSpecs
CoreSpecs
coreSpecs
=
new
CoreSpecs
();
coreSpecs
.
setProductionDate
(
LocalDate
.
of
(
1970
,
1
,
1
));
// 生产日期默认1970-01-01
coreSpecs
.
setEmissionStandard
(
5
);
// 排放标准默认国5
coreSpecs
.
setDisplacement
(
vrAudit
.
getDisplacement
());
coreSpecs
.
setJqxs
(
""
);
coreSpecs
.
setRlxs
(
getFuelTypeName
(
vrAudit
.
getFuelType
()));
coreSpecs
.
setBxslx
(
getTransmissionTypeName
(
vrAudit
.
getTransmissionType
()));
coreSpecs
.
setQdfs
(
""
);
coreSpecs
.
setVehicleClass
(
""
);
coreSpecs
.
setExteriorColor
(
vrAudit
.
getBodyColor
());
coreSpecs
.
setInteriorColor
(
vrAudit
.
getInteriorColor
());
coreSpecs
.
setSeat
(
""
);
coreSpecs
.
setSunroof
(
1
);
// 天窗默认1
vehicle
.
setCoreSpecs
(
coreSpecs
);
// 设置权属与状态 Ownership
Ownership
ownership
=
new
Ownership
();
ownership
.
setCarProvinceId
(
parseIntOrZero
(
vrAudit
.
getProvinceCode
()));
ownership
.
setCarProvinceName
(
vrAudit
.
getProvinceName
());
ownership
.
setCarCityId
(
parseIntOrZero
(
vrAudit
.
getCityCode
()));
ownership
.
setCarCityName
(
vrAudit
.
getCityName
());
ownership
.
setRegistrationDate
(
parseDateOrDefault
(
vrAudit
.
getRegisterDate
()));
ownership
.
setTransferCount
(
vrAudit
.
getTransferCount
()
!=
null
?
vrAudit
.
getTransferCount
()
:
0
);
ownership
.
setUsageType
(
vrAudit
.
getVehicleNature
()
!=
null
?
vrAudit
.
getVehicleNature
()
:
1
);
ownership
.
setOwnerType
(
1
);
// 车主类型默认个人
ownership
.
setHasMortgage
(
false
);
// 是否有抵押默认0
vehicle
.
setOwnership
(
ownership
);
// 设置牌证信息 LicenseInfo
LicenseInfo
licenseInfo
=
new
LicenseInfo
();
licenseInfo
.
setAnnualInspectionExpiry
(
LocalDate
.
of
(
1970
,
1
,
1
));
// 年检到期日默认1970-01-01
licenseInfo
.
setCompulsoryInsuranceExpiry
(
LocalDate
.
of
(
1970
,
1
,
1
));
// 交强险到期日默认1970-01-01
licenseInfo
.
setCommercialInsuranceExpiry
(
LocalDate
.
of
(
1970
,
1
,
1
));
// 商业险到期日默认1970-01-01
licenseInfo
.
setKeyCount
(
1
);
// 钥匙数量默认1
vehicle
.
setLicenseInfo
(
licenseInfo
);
// 设置历史与车况 HistoryCondition
HistoryCondition
historyCondition
=
new
HistoryCondition
();
historyCondition
.
setHasAccident
(
0
);
// 是否有事故默认0
historyCondition
.
setFireCheck
(
0
);
// 是否火烧车默认0
vehicle
.
setHistoryCondition
(
historyCondition
);
// 设置评估与交易 EvaluationTransaction
EvaluationTransaction
evaluationTransaction
=
new
EvaluationTransaction
();
evaluationTransaction
.
setOverallRating
(
1
);
// 车辆整体评级默认1-优
vehicle
.
setEvaluationTransaction
(
evaluationTransaction
);
// 设置车辆图片 carImages
List
<
CarImage
>
carImages
=
buildCarImages
(
vrAudit
);
vehicle
.
setCarImages
(
carImages
);
// 设置车辆状态为待入库
vehicle
.
setVehicleState
(
Vehicle
.
VehicleState
.
INVENTORY
);
// 设置保留价(万元转元)
if
(
vrAudit
.
getReservePrice
()
!=
null
)
{
vehicle
.
setReservePrice
(
vrAudit
.
getReservePrice
().
multiply
(
BigDecimal
.
valueOf
(
10000
)).
doubleValue
());
}
// 设置VR审核单ID
vehicle
.
setVrAuditId
(
vrAudit
.
getId
());
// 设置车辆来源为拍卖端
vehicle
.
setVehicleSource
(
Vehicle
.
VehicleSource
.
AUCTION
);
// 设置是否有行驶证
vehicle
.
setVehicleLicense
(
true
);
// 保存Vehicle
vehicle
=
vehicleDao
.
save
(
vehicle
);
log
.
info
(
"根据发拍单创建Vehicle成功,vrAuditId={}, vehicleId={}"
,
vrAudit
.
getId
(),
vehicle
.
getVehicleId
());
return
vehicle
;
}
/**
* 构建车辆图片列表
*/
private
List
<
CarImage
>
buildCarImages
(
VrAudit
vrAudit
)
{
List
<
CarImage
>
carImages
=
new
ArrayList
<>();
// 11-左前45度
if
(
StringUtils
.
hasText
(
vrAudit
.
getPhotoLeftFront
()))
{
carImages
.
add
(
createCarImage
(
11
,
vrAudit
.
getPhotoLeftFront
()));
}
// 16-右后45度
if
(
StringUtils
.
hasText
(
vrAudit
.
getPhotoRightRear
()))
{
carImages
.
add
(
createCarImage
(
16
,
vrAudit
.
getPhotoRightRear
()));
}
// 13-仪表盘
if
(
StringUtils
.
hasText
(
vrAudit
.
getPhotoDashboard
()))
{
carImages
.
add
(
createCarImage
(
13
,
vrAudit
.
getPhotoDashboard
()));
}
// 12-主驾驶全景(用内饰照片)
if
(
StringUtils
.
hasText
(
vrAudit
.
getPhotoInterior
()))
{
carImages
.
add
(
createCarImage
(
12
,
vrAudit
.
getPhotoInterior
()));
}
// 31-发动机概况
if
(
StringUtils
.
hasText
(
vrAudit
.
getPhotoEngine
()))
{
carImages
.
add
(
createCarImage
(
31
,
vrAudit
.
getPhotoEngine
()));
}
// 41-其他图片(前脸、后备箱)
if
(
StringUtils
.
hasText
(
vrAudit
.
getPhotoFront
()))
{
carImages
.
add
(
createCarImage
(
41
,
vrAudit
.
getPhotoFront
()));
}
if
(
StringUtils
.
hasText
(
vrAudit
.
getPhotoTrunk
()))
{
carImages
.
add
(
createCarImage
(
41
,
vrAudit
.
getPhotoTrunk
()));
}
return
carImages
;
}
/**
* 创建CarImage对象
*/
private
CarImage
createCarImage
(
int
fileSubtype
,
String
fileUrl
)
{
CarImage
carImage
=
new
CarImage
();
carImage
.
setFileSubtype
(
fileSubtype
);
carImage
.
setFileUrl
(
fileUrl
);
return
carImage
;
}
/**
* 解析整数,失败返回0
*/
private
int
parseIntOrZero
(
String
value
)
{
if
(!
StringUtils
.
hasText
(
value
))
{
return
0
;
}
try
{
return
Integer
.
parseInt
(
value
);
}
catch
(
NumberFormatException
e
)
{
return
0
;
}
}
/**
* 解析日期字符串,失败返回默认日期1970-01-01
*/
private
LocalDate
parseDateOrDefault
(
String
dateStr
)
{
if
(!
StringUtils
.
hasText
(
dateStr
))
{
return
LocalDate
.
of
(
1970
,
1
,
1
);
}
try
{
// 支持 YYYY-MM 或 YYYY-MM-DD 格式
if
(
dateStr
.
length
()
==
7
)
{
dateStr
=
dateStr
+
"-01"
;
}
return
LocalDate
.
parse
(
dateStr
);
}
catch
(
Exception
e
)
{
return
LocalDate
.
of
(
1970
,
1
,
1
);
}
}
/**
* 获取燃料类型名称
*/
private
String
getFuelTypeName
(
Integer
fuelType
)
{
if
(
fuelType
==
null
)
{
return
"汽油"
;
}
return
switch
(
fuelType
)
{
case
1
->
"汽油"
;
case
2
->
"柴油"
;
case
3
->
"电动"
;
case
4
->
"混动"
;
default
->
"汽油"
;
};
}
/**
* 获取变速箱类型名称
*/
private
String
getTransmissionTypeName
(
Integer
transmissionType
)
{
if
(
transmissionType
==
null
)
{
return
"自动"
;
}
return
switch
(
transmissionType
)
{
case
1
->
"手动"
;
case
2
->
"自动"
;
default
->
"自动"
;
};
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment