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 1de1f9eb
authored
Mar 19, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:根据车辆ID查询检测评分/评级
1 parent
0f7212f2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
157 additions
and
4 deletions
aus-api/src/main/java/com/glsx/usedcar/web/api/inspect/InspectionReportController.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionReportService.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionWORespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/VehicleInspectScoreRespVO.java
aus-framework/src/main/java/org/summerframework/core/enums/ErrorCodeEnum.java
aus-api/src/main/java/com/glsx/usedcar/web/api/inspect/InspectionReportController.java
0 → 100644
View file @
1de1f9e
package
com
.
glsx
.
usedcar
.
web
.
api
.
inspect
;
import
com.glsx.usedcar.module.inspect.service.InspectionReportService
;
import
com.glsx.usedcar.module.inspect.vo.VehicleInspectScoreRespVO
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.summerframework.core.exception.BusinessCodeException
;
/**
* 检测报告接口
*/
@Slf4j
@Tag
(
name
=
"检测报告接口"
,
description
=
"检测报告的增删改查、绑定解绑、车辆评分查询"
)
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/api/inspect/report"
)
public
class
InspectionReportController
{
private
final
InspectionReportService
inspectionReportService
;
// ========== 原有接口(省略,保持不变) ==========
/**
* 根据车辆ID查询绑定检测报告的评分/评级
*/
@Operation
(
summary
=
"根据车辆ID查询检测评分/评级"
,
description
=
"查询车辆绑定的检测报告对应的综合分数、外观分数、骨架评级、内饰评级"
)
@GetMapping
(
"/vehicle/score/{vehicleId}"
)
public
BaseResp
<
VehicleInspectScoreRespVO
>
getVehicleInspectScore
(
@Parameter
(
description
=
"车辆ID"
,
required
=
true
,
example
=
"100001"
)
@PathVariable
(
"vehicleId"
)
Integer
vehicleId
)
{
log
.
info
(
"【接口请求】根据车辆ID查询检测评分/评级,vehicleId={}"
,
vehicleId
);
try
{
VehicleInspectScoreRespVO
result
=
inspectionReportService
.
getVehicleInspectScoreByVehicleId
(
vehicleId
);
return
BaseResp
.
success
(
result
);
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】查询车辆检测评分失败,vehicleId={}"
,
vehicleId
,
be
);
return
BaseResp
.
fail
(
be
.
getCode
().
toString
(),
be
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
"【接口响应】查询车辆检测评分异常,vehicleId={}"
,
vehicleId
,
e
);
return
BaseResp
.
fail
(
"系统异常:查询车辆检测评分失败"
);
}
}
}
\ No newline at end of file
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionReportService.java
View file @
1de1f9e
...
...
@@ -9,8 +9,7 @@ import com.glsx.usedcar.converts.InspectionReportConverter;
import
com.glsx.usedcar.converts.InspectionReportOpLogConverter
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.enums.inspect.InspectionReportOperationTypeEnum
;
import
com.glsx.usedcar.module.inspect.dao.InspectionReportOpLogRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionReportRepository
;
import
com.glsx.usedcar.module.inspect.dao.*
;
import
com.glsx.usedcar.module.inspect.entity.*
;
import
com.glsx.usedcar.module.inspect.vo.*
;
import
com.glsx.usedcar.module.vehicle.dao.VehicleDao
;
...
...
@@ -49,7 +48,7 @@ public class InspectionReportService {
private
final
InspectionReportConverter
inspectionReportConverter
;
private
final
InspectionReportOpLogConverter
inspectionReportOpLogConverter
;
private
final
VehicleDao
vehicleDao
;
private
final
InspectionRecordRepository
inspectionRecordRepository
;
// ======================== 日志保存方法(核心,接收真实操作人) ========================
/**
...
...
@@ -485,4 +484,64 @@ public class InspectionReportService {
log
.
info
(
"【报告详情】查询成功: ID={}, 报告编号={}"
,
id
,
report
.
getReportNo
());
return
new
InspectionReportDetailRespVO
(
reportRespVO
,
reportOpLogRespVos
);
}
/**
* 根据车辆ID查询绑定检测报告的评分/评级
* @param vehicleId 车辆ID
* @return 评分/评级VO
*/
public
VehicleInspectScoreRespVO
getVehicleInspectScoreByVehicleId
(
Integer
vehicleId
)
{
// 1. 校验车辆ID合法性
if
(
vehicleId
==
null
||
vehicleId
<=
0
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"车辆ID不能为空且为正整数"
);
}
// 2. 查询车辆是否存在(复用现有VehicleDao)
Vehicle
vehicle
=
vehicleDao
.
findById
(
vehicleId
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_FOUND
,
"车辆不存在,vehicleId="
+
vehicleId
));
// 3. 查询该车辆绑定的未删除检测报告(复用现有Repository方法)
List
<
InspectionReport
>
bindReportList
=
inspectionReportRepository
.
findByVehicleAndDeleteFlag
(
vehicle
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
// 复用枚举:N=未删除
);
if
(
bindReportList
==
null
||
bindReportList
.
isEmpty
())
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_FOUND
,
"该车辆未绑定任何检测报告,vehicleId="
+
vehicleId
);
}
// 4. 取第一条绑定报告(业务规则:同一车辆仅绑定一个报告)
InspectionReport
bindReport
=
bindReportList
.
get
(
0
);
if
(
bindReport
.
getWorkOrder
()
==
null
||
bindReport
.
getWorkOrder
().
getId
()
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"检测报告关联的工单为空,reportNo="
,
bindReport
.
getReportNo
());
}
// 5. 获取工单的taskId(从InspectionWorkOrder实体取taskId,需确保WorkOrder关联正确)
Long
taskId
=
bindReport
.
getWorkOrder
().
getId
();
// 6. 根据taskId查询检测记录(复用现有InspectionRecordRepository方法)
Optional
<
InspectionRecord
>
recordOpt
=
inspectionRecordRepository
.
findByTaskIdAndDeletedFlag
(
taskId
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
// N=未删除
);
if
(
recordOpt
.
isEmpty
())
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_FOUND
,
"未查询到检测记录,taskId="
+
taskId
);
}
// 7. 封装返回VO(字段完全对齐InspectionRecord实体)
InspectionRecord
record
=
recordOpt
.
get
();
VehicleInspectScoreRespVO
respVO
=
new
VehicleInspectScoreRespVO
();
respVO
.
setOverallScore
(
record
.
getOverallScore
());
// 综合分数
respVO
.
setExteriorScore
(
record
.
getExteriorScore
());
// 外观分数
respVO
.
setSkeletonLevel
(
record
.
getSkeletonLevel
());
// 骨架评级
respVO
.
setInteriorLevel
(
record
.
getInteriorLevel
());
// 内饰评级
log
.
info
(
"【查询成功】vehicleId={},综合分数={},外观分数={},骨架评级={},内饰评级={}"
,
vehicleId
,
respVO
.
getOverallScore
(),
respVO
.
getExteriorScore
(),
respVO
.
getSkeletonLevel
(),
respVO
.
getInteriorLevel
());
// TODO 需要加上无事故无火烧无水泡
return
respVO
;
}
}
\ No newline at end of file
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionWORespVO.java
View file @
1de1f9e
...
...
@@ -66,4 +66,20 @@ public class InspectionWORespVO {
@Schema
(
description
=
"检测完成时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
inspectionCompletedTime
;
/**
* 创建时间
*/
@Schema
(
description
=
"创建时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
createTime
;
/**
* 更新时间
*/
@Schema
(
description
=
"更新时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
updateTime
;
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/VehicleInspectScoreRespVO.java
0 → 100644
View file @
1de1f9e
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* 车辆检测评分/评级返回VO
*/
@Data
@Schema
(
description
=
"车辆检测评分/评级返回VO"
)
public
class
VehicleInspectScoreRespVO
{
@Schema
(
description
=
"综合分数"
,
example
=
"95.50"
)
private
BigDecimal
overallScore
;
@Schema
(
description
=
"外观分数"
,
example
=
"96.00"
)
private
BigDecimal
exteriorScore
;
@Schema
(
description
=
"骨架评级(A/B/C/D)"
,
example
=
"A"
)
private
String
skeletonLevel
;
@Schema
(
description
=
"内饰评级(A/B/C/D)"
,
example
=
"B"
)
private
String
interiorLevel
;
}
\ No newline at end of file
aus-framework/src/main/java/org/summerframework/core/enums/ErrorCodeEnum.java
View file @
1de1f9e
...
...
@@ -31,6 +31,8 @@ public enum ErrorCodeEnum {
DATA_ALREADY_EXISTS
(
1001004
,
"工单唯一ID已存在:{0}"
),
PHONE_ALREADY_EXISTS
(
1001005
,
"手机号[{0}]已存在"
),
VEHICLE_ALREADY_INSPECTED
(
1001006
,
"车辆已经创建检测工单"
),
OPERATION_ERROR
(
1001007
,
"已绑定的检测报告不允许删除"
),
DATA_NOT_FOUND
(
1001008
,
"{0}"
),
/* 检测模版 */
...
...
@@ -38,7 +40,6 @@ public enum ErrorCodeEnum {
NODE_NOT_LEAF
(
1001102
,
"[{0}-{1}]不是叶子节点,无法保存检测值"
),
NODE_CHECK_ERROR
(
1001103
,
"数据校验失败:[]"
),
OPERATION_ERROR
(
1001006
,
"已绑定的检测报告不允许删除"
),
;
private
final
Integer
code
;
private
final
String
message
;
...
...
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