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 2b7f1393
authored
Apr 20, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:新增茶博士接口
1 parent
6b541632
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
192 additions
and
18 deletions
aus-config/src/main/resources/config/common-dev.yaml
aus-core/pom.xml
aus-core/src/main/java/com/glsx/usedcar/chaboshi/dto/VinAnalysisDTO.java
aus-core/src/main/java/com/glsx/usedcar/chaboshi/service/ChaboshiService.java
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/entity/VrAudit.java
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrAuditService.java
aus-config/src/main/resources/config/common-dev.yaml
View file @
2b7f139
...
...
@@ -202,3 +202,7 @@ application:
inspector
:
inspection-audit-url
:
http://192.168.1.125:5173/#/detection/order
inspection-record-h5-url
:
http://192.168.1.178:8082/inspect-report?recordId=%s
chaboshi
:
userId
:
4131172
key
:
1ea63a3c73eb4fa8ce9ad36ce45d0293
online
:
false
\ No newline at end of file
aus-core/pom.xml
View file @
2b7f139
...
...
@@ -186,6 +186,13 @@
<version>
1.5.5.Final
</version>
<scope>
provided
</scope>
<!-- 只在编译时使用,不打包 -->
</dependency>
<!-- 查博士车况检测-->
<dependency>
<groupId>
com.chaboshi
</groupId>
<artifactId>
api-sign
</artifactId>
<version>
0.0.3
</version>
</dependency>
</dependencies>
<build>
...
...
aus-core/src/main/java/com/glsx/usedcar/chaboshi/dto/VinAnalysisDTO.java
0 → 100644
View file @
2b7f139
This diff is collapsed.
Click to expand it.
aus-core/src/main/java/com/glsx/usedcar/chaboshi/service/ChaboshiService.java
0 → 100644
View file @
2b7f139
package
com
.
glsx
.
usedcar
.
chaboshi
.
service
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.chaboshi.builder.CBSBuilder
;
import
com.glsx.usedcar.chaboshi.dto.VinAnalysisDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
/**
* 查博士服务
* 1. 提供根据车架号查询车型功能
*/
@Slf4j
@Service
public
class
ChaboshiService
{
@Value
(
"${chaboshi.userId}"
)
private
String
userId
;
@Value
(
"${chaboshi.key}"
)
private
String
key
;
@Value
(
"${chaboshi.online}"
)
private
Boolean
isOnline
;
/**
* 据车架号查询车型信息
* @param vin 车架号
* @return 车型信息
*/
public
VinAnalysisDTO
vinAnalysis
(
String
vin
)
{
CBSBuilder
newBuilder
=
CBSBuilder
.
newCBSBuilder
(
userId
,
key
,
isOnline
);
HashMap
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"vin"
,
vin
);
log
.
info
(
"请求查博士获取查询信息,入参:{}"
,
params
);
String
res
=
newBuilder
.
sendPost
(
"/vinAnalysis/ordinary"
,
params
);
log
.
info
(
"请求查博士获取查询信息,返回:{}"
,
res
);
if
(
res
==
null
||
res
.
isEmpty
())
{
return
null
;
}
JSONObject
root
=
JSONUtil
.
parseObj
(
res
);
Integer
code
=
root
.
getInt
(
"Code"
);
if
(
code
==
null
||
code
!=
0
)
{
return
null
;
}
JSONObject
data
=
root
.
getJSONObject
(
"data"
);
if
(
data
==
null
)
{
return
null
;
}
VinAnalysisDTO
dto
=
new
VinAnalysisDTO
();
dto
.
setVin
(
data
.
getStr
(
"vin"
));
JSONObject
baseObj
=
data
.
getJSONObject
(
"base"
);
if
(
baseObj
!=
null
)
{
dto
.
setBase
(
JSONUtil
.
toBean
(
baseObj
,
VinAnalysisDTO
.
Base
.
class
));
}
JSONObject
bodyObj
=
data
.
getJSONObject
(
"body"
);
if
(
bodyObj
!=
null
)
{
dto
.
setBody
(
JSONUtil
.
toBean
(
bodyObj
,
VinAnalysisDTO
.
Body
.
class
));
}
JSONObject
controlObj
=
data
.
getJSONObject
(
"control"
);
if
(
controlObj
!=
null
)
{
dto
.
setControl
(
JSONUtil
.
toBean
(
controlObj
,
VinAnalysisDTO
.
Control
.
class
));
}
JSONObject
engineObj
=
data
.
getJSONObject
(
"engine"
);
if
(
engineObj
!=
null
)
{
dto
.
setEngine
(
JSONUtil
.
toBean
(
engineObj
,
VinAnalysisDTO
.
Engine
.
class
));
}
JSONObject
internalObj
=
data
.
getJSONObject
(
"internal"
);
if
(
internalObj
!=
null
)
{
dto
.
setInternal
(
JSONUtil
.
toBean
(
internalObj
,
VinAnalysisDTO
.
Internal
.
class
));
}
JSONObject
gearboxObj
=
data
.
getJSONObject
(
"gearbox"
);
if
(
gearboxObj
!=
null
)
{
dto
.
setGearbox
(
JSONUtil
.
toBean
(
gearboxObj
,
VinAnalysisDTO
.
Gearbox
.
class
));
}
JSONObject
lightObj
=
data
.
getJSONObject
(
"light"
);
if
(
lightObj
!=
null
)
{
dto
.
setLight
(
JSONUtil
.
toBean
(
lightObj
,
VinAnalysisDTO
.
Light
.
class
));
}
JSONObject
mediaObj
=
data
.
getJSONObject
(
"media"
);
if
(
mediaObj
!=
null
)
{
dto
.
setMedia
(
JSONUtil
.
toBean
(
mediaObj
,
VinAnalysisDTO
.
Media
.
class
));
}
JSONObject
safetyObj
=
data
.
getJSONObject
(
"safety"
);
if
(
safetyObj
!=
null
)
{
dto
.
setSafety
(
JSONUtil
.
toBean
(
safetyObj
,
VinAnalysisDTO
.
Safety
.
class
));
}
return
dto
;
}
}
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/entity/VrAudit.java
View file @
2b7f139
...
...
@@ -263,49 +263,42 @@ public class VrAudit extends AuditingEntity {
/**
* 前脸照片
*/
@Lob
@Column
(
columnDefinition
=
"text"
)
private
String
photoFront
;
/**
* 左前45°照片
*/
@Lob
@Column
(
columnDefinition
=
"text"
)
private
String
photoLeftFront
;
/**
* 右后45°照片
*/
@Lob
@Column
(
columnDefinition
=
"text"
)
private
String
photoRightRear
;
/**
* 内饰照片
*/
@Lob
@Column
(
columnDefinition
=
"text"
)
private
String
photoInterior
;
/**
* 仪表盘照片
*/
@Lob
@Column
(
columnDefinition
=
"text"
)
private
String
photoDashboard
;
/**
* 发动机舱照片
*/
@Lob
@Column
(
columnDefinition
=
"text"
)
private
String
photoEngine
;
/**
* 后备箱照片
*/
@Lob
@Column
(
columnDefinition
=
"text"
)
private
String
photoTrunk
;
...
...
@@ -368,7 +361,6 @@ public class VrAudit extends AuditingEntity {
/**
* 草稿完整数据缓存(JSON格式)
*/
@Lob
@Column
(
columnDefinition
=
"json"
)
private
String
draftData
;
...
...
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrAuditService.java
View file @
2b7f139
...
...
@@ -6,6 +6,7 @@ import com.glsx.usedcar.annotation.DataPermission;
import
com.glsx.usedcar.consts.common.SymbolConsts
;
import
com.glsx.usedcar.consts.inspect.JpaQueryConstants
;
import
com.glsx.usedcar.converts.VrAuditConverter
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.module.auction.dao.AuctionVehicleDao
;
import
com.glsx.usedcar.module.auction.entity.Auction
;
import
com.glsx.usedcar.module.auction.entity.AuctionVehicle
;
...
...
@@ -14,9 +15,15 @@ import com.glsx.usedcar.module.vehicle.domain.CarImage;
import
com.glsx.usedcar.module.vehicle.entity.*
;
import
com.glsx.usedcar.module.vehicle.entity.Vehicle.VehicleState
;
import
com.glsx.usedcar.module.vrsystem.dao.VrAuditRepository
;
import
com.glsx.usedcar.module.vrsystem.dao.VrOrgRepository
;
import
com.glsx.usedcar.module.vrsystem.dao.VrUserOrgRepository
;
import
com.glsx.usedcar.module.vrsystem.entity.VrAudit
;
import
com.glsx.usedcar.module.vrsystem.entity.VrAudit_
;
import
com.glsx.usedcar.module.vrsystem.entity.VrOrg
;
import
com.glsx.usedcar.module.vrsystem.entity.VrUserOrg
;
import
com.glsx.usedcar.module.vrsystem.vo.*
;
import
com.glsx.usedcar.module.vrsystem.dto.LoginUserDTO
;
import
com.glsx.usedcar.util.UserContext
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
...
...
@@ -55,6 +62,10 @@ public class VrAuditService {
private
final
VrAuditConverter
vrAuditConverter
;
private
final
VrUserOrgRepository
vrUserOrgRepository
;
private
final
VrOrgRepository
vrOrgRepository
;
/**
* 拍卖中相关的车辆状态集合,对应发拍单状态为"拍卖中"
*/
...
...
@@ -76,7 +87,7 @@ public class VrAuditService {
*/
@DataPermission
(
key
=
"vrUserId"
)
public
Page
<
VrAuditRespVO
>
pageList
(
Pagination
<
VrAudit
>
pagination
)
{
pagination
.
addFilter
(
JpaQueryConstants
.
VrAudit
.
DELETE_FLAG
,
"N"
,
Operator
.
eq
);
pagination
.
addFilter
(
JpaQueryConstants
.
VrAudit
.
DELETE_FLAG
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
,
Operator
.
eq
);
Object
keyword
=
pagination
.
getFilterValueOrElseNull
(
JpaQueryConstants
.
VrAudit
.
KEYWORD
);
if
(
keyword
instanceof
String
kw
&&
StrUtil
.
isNotBlank
(
kw
))
{
String
likePattern
=
SymbolConsts
.
PERCENT
+
keyword
+
SymbolConsts
.
PERCENT
;
...
...
@@ -112,10 +123,11 @@ public class VrAuditService {
entity
.
setVehicleId
(
0
);
entity
.
setStatus
(
VrAudit
.
PublishStatus
.
DRAFT
.
getValue
());
entity
.
setDraftStep
(
req
.
getStep
());
entity
.
setDeleteFlag
(
"N"
);
entity
.
setDeleteFlag
(
DeleteFlag
.
NOT_DELETED
.
getCode
());
fillUserAndOrgInfo
(
entity
);
}
else
{
// 编辑:查找并校验状态
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
req
.
getId
(),
"N"
)
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
req
.
getId
(),
DeleteFlag
.
NOT_DELETED
.
getCode
()
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
));
// 只有草稿和已下架状态允许编辑
if
(
entity
.
getStatus
()
!=
null
...
...
@@ -157,6 +169,61 @@ public class VrAuditService {
}
/**
* 填充用户和门店信息(新增时调用)
* <p>从当前登录用户上下文获取用户信息,并查找关联的门店信息</p>
*
* @param entity 发拍单实体
*/
private
void
fillUserAndOrgInfo
(
VrAudit
entity
)
{
LoginUserDTO
currentUser
=
UserContext
.
getUser
();
if
(
currentUser
==
null
)
{
log
.
warn
(
"当前登录用户为空,无法填充用户和门店信息"
);
return
;
}
// 填充发拍申请人信息
entity
.
setVrUserId
(
currentUser
.
getUserId
());
entity
.
setVrUserName
(
currentUser
.
getUserName
());
entity
.
setVrUserPhone
(
currentUser
.
getPhone
());
// 查找用户关联的组织
List
<
VrUserOrg
>
userOrgs
=
vrUserOrgRepository
.
findByUserId
(
currentUser
.
getUserId
());
if
(
userOrgs
.
isEmpty
())
{
log
.
warn
(
"当前用户未关联组织,userId={}"
,
currentUser
.
getUserId
());
return
;
}
// 获取用户关联的组织ID
Long
orgId
=
userOrgs
.
get
(
0
).
getOrgId
();
VrOrg
org
=
vrOrgRepository
.
findByIdAndDeleteFlag
(
orgId
,
DeleteFlag
.
NOT_DELETED
.
getCode
()).
orElse
(
null
);
if
(
org
==
null
)
{
log
.
warn
(
"未找到用户关联的组织,orgId={}"
,
orgId
);
return
;
}
// 判断组织类型:1=集团,2=门店
if
(
org
.
getOrgType
()
==
2
)
{
// 用户直接关联门店,直接使用
entity
.
setOrgId
(
org
.
getId
());
entity
.
setOrgName
(
org
.
getOrgName
());
}
else
if
(
org
.
getOrgType
()
==
1
)
{
// 用户关联集团,需要查找该集团下的门店
List
<
VrOrg
>
stores
=
vrOrgRepository
.
findByParentIdAndDeleteFlagOrderBySortOrderAsc
(
org
.
getId
(),
DeleteFlag
.
NOT_DELETED
.
getCode
());
if
(
stores
.
isEmpty
())
{
log
.
warn
(
"用户关联的集团下没有门店,groupId={}"
,
org
.
getId
());
return
;
}
// 取第一个门店
VrOrg
store
=
stores
.
get
(
0
);
entity
.
setOrgId
(
store
.
getId
());
entity
.
setOrgName
(
store
.
getOrgName
());
}
log
.
info
(
"填充用户和门店信息完成,vrUserId={}, orgId={}, orgName={}"
,
entity
.
getVrUserId
(),
entity
.
getOrgId
(),
entity
.
getOrgName
());
}
/**
* 根据当前步骤将VO中的字段填充到实体
*/
private
void
fillStepFields
(
VrAudit
entity
,
VrAuditSaveReqVO
req
)
{
...
...
@@ -312,7 +379,7 @@ public class VrAuditService {
* @return 保留价(万元)
*/
public
BigDecimal
getReservePriceByVehicleId
(
Integer
vehicleId
)
{
VrAudit
vrAudit
=
vrAuditRepository
.
findTopByVehicleIdAndDeleteFlag
(
vehicleId
,
"N"
)
VrAudit
vrAudit
=
vrAuditRepository
.
findTopByVehicleIdAndDeleteFlag
(
vehicleId
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
VR_AUDIT_RESERVE_PRICE_NOT_FOUND
,
vehicleId
));
if
(
vrAudit
.
getReservePrice
()
==
null
)
{
log
.
warn
(
"发拍单保留价为空,vrAuditId={}, vehicleId={}"
,
vrAudit
.
getId
(),
vehicleId
);
...
...
@@ -328,7 +395,7 @@ public class VrAuditService {
* @return 发拍单响应VO
*/
public
VrAuditRespVO
getById
(
Long
id
)
{
VrAudit
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
id
,
"N"
)
VrAudit
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
id
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
));
return
vrAuditConverter
.
vrAuditMapRespVO
(
entity
);
}
...
...
@@ -342,10 +409,10 @@ public class VrAuditService {
public
VrAuditStatRespVO
getStatistics
(
Long
vrUserId
)
{
// 发拍总数:排除草稿状态(DRAFT=1)
long
publishCount
=
vrAuditRepository
.
countByVrUserIdAndStatusNotAndDeleteFlag
(
vrUserId
,
VrAudit
.
PublishStatus
.
DRAFT
.
getValue
(),
"N"
);
vrUserId
,
VrAudit
.
PublishStatus
.
DRAFT
.
getValue
(),
DeleteFlag
.
NOT_DELETED
.
getCode
()
);
// 成交数量:已成交状态(SOLD=4)
long
soldCount
=
vrAuditRepository
.
countByVrUserIdAndStatusAndDeleteFlag
(
vrUserId
,
VrAudit
.
PublishStatus
.
SOLD
.
getValue
(),
"N"
);
vrUserId
,
VrAudit
.
PublishStatus
.
SOLD
.
getValue
(),
DeleteFlag
.
NOT_DELETED
.
getCode
()
);
// 成交率 = 成交数量 / 发拍总数 * 100%,保留2位小数
BigDecimal
transactionRate
=
BigDecimal
.
ZERO
;
if
(
publishCount
>
0
)
{
...
...
@@ -369,7 +436,7 @@ public class VrAuditService {
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
offShelf
(
Long
id
,
String
operator
)
{
VrAudit
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
id
,
"N"
)
VrAudit
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
id
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
));
Integer
currentStatus
=
entity
.
getStatus
();
...
...
@@ -396,7 +463,7 @@ public class VrAuditService {
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
rePublish
(
Long
id
,
String
operator
)
{
VrAudit
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
id
,
"N"
)
VrAudit
entity
=
vrAuditRepository
.
findByIdAndDeleteFlag
(
id
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
));
// 校验:必须已同步到车辆档案
...
...
@@ -466,7 +533,7 @@ public class VrAuditService {
return
;
}
VrAudit
vrAudit
=
vrAuditRepository
.
findTopByVehicleIdAndDeleteFlag
(
vehicle
.
getVehicleId
(),
"N"
)
VrAudit
vrAudit
=
vrAuditRepository
.
findTopByVehicleIdAndDeleteFlag
(
vehicle
.
getVehicleId
(),
DeleteFlag
.
NOT_DELETED
.
getCode
()
)
.
orElse
(
null
);
if
(
vrAudit
==
null
)
{
log
.
debug
(
"未找到关联的发拍单,vehicleId={}"
,
vehicle
.
getVehicleId
());
...
...
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