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 f0abe891
authored
Mar 23, 2026
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:检测详情默认值
1 parent
76c4f397
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
558 additions
and
50 deletions
aus-core/src/main/java/com/glsx/usedcar/consts/common/BigDecimalConsts.java
aus-core/src/main/java/com/glsx/usedcar/converts/InspectionTemplateConverter.java
aus-core/src/main/java/com/glsx/usedcar/enums/inspect/InspectionBaseInfoFieldEnum.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dto/InspectionTemplateDTO.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionNodeService.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionRecordService.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionTemplateService.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/DefaultTemplateStrategy.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/InspectionValueStrategyRouter.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/RyInspectionTemplateCode001.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/TemplateValueStrategy.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionDetailRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionTemplateDefaultValueReqVO.java
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionTemplateController.java
aus-core/src/main/java/com/glsx/usedcar/consts/common/BigDecimalConsts.java
0 → 100644
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
consts
.
common
;
import
java.math.BigDecimal
;
/**
* @author yangwei
* @version 1.0
* @since 2026/03/23 16:41
*/
public
interface
BigDecimalConsts
{
/**
* 10000
*/
BigDecimal
TEN_THOUSAND
=
new
BigDecimal
(
"10000"
);
}
aus-core/src/main/java/com/glsx/usedcar/converts/InspectionTemplateConverter.java
0 → 100644
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
converts
;
import
com.glsx.usedcar.module.inspect.dto.InspectionTemplateDTO
;
import
com.glsx.usedcar.module.inspect.entity.InspectionTemplate
;
import
com.glsx.usedcar.module.inspect.entity.InspectionTemplateHistory
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
/**
* 检查模版转换
* @author yangwei
* @version 1.0
* @since 2026/03/23 14:20
*/
@Mapper
(
componentModel
=
"spring"
)
public
interface
InspectionTemplateConverter
{
/**
* entity 转 dto
* @param inspectionTemplate entity
* @return dto
*/
InspectionTemplateDTO
entity2DTO
(
InspectionTemplate
inspectionTemplate
);
/**
* entity 转 dto
* @param inspectionTemplateHistory entity
* @return dto
*/
@Mapping
(
source
=
"templateId"
,
target
=
"id"
)
InspectionTemplateDTO
entityHistory2DTO
(
InspectionTemplateHistory
inspectionTemplateHistory
);
}
aus-core/src/main/java/com/glsx/usedcar/enums/inspect/InspectionBaseInfoFieldEnum.java
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
enums
.
inspect
;
import
com.github.benmanes.caffeine.cache.Expiry
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.persistence.Column
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.Size
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
org.summerframework.orm.validator.CreateValidGroup
;
import
org.summerframework.orm.validator.UpdateValidGroup
;
import
java.time.LocalDate
;
/**
* 检测项基础信息字段枚举
...
...
@@ -30,8 +39,8 @@ public enum InspectionBaseInfoFieldEnum {
/** 车牌号 */
LICENSE_PLATE
(
"licensePlate"
,
"车牌号"
),
/** 首次上牌 */
FIRST_PLATE
(
"firstPl
ate"
,
"首次上牌"
),
/** 首次上牌
时间
*/
REGISTRATION_DATE
(
"registrationD
ate"
,
"首次上牌"
),
/** 排放标准 */
EMISSION_STANDARD
(
"emissionStandard"
,
"排放标准"
),
...
...
@@ -39,6 +48,68 @@ public enum InspectionBaseInfoFieldEnum {
/** 排量 */
DISPLACEMENT
(
"displacement"
,
"排量"
),
/** VIN码 */
VIN
(
"vin"
,
"VIN码"
),
/** 车源号 */
SOURCE_NO
(
"sourceNo"
,
"车源号"
),
/** 表显里程,检测报告中单位为 万公里 */
MILEAGE
(
"mileage"
,
"表显里程"
),
/** 发动机号 */
ENGINE_NUMBER
(
"engineNumber"
,
"发动机号"
),
/** 所有人性质:1-个人/2-单位 */
OWNER_TYPE
(
"ownerType"
,
"所有人性质:1-个人/2-单位"
),
/**
* 使用性质:1-非营运/2-营运/3-营转非
*/
USAGE_TYPE
(
"usageType"
,
"使用性质:1-非营运/2-营运/3-营转非"
),
/**
* 座位数
*/
SEAT
(
"seat"
,
"座位数"
),
/**
* 年检到期
*/
ANNUAL_INSPECTION_EXPIRY
(
"annualInspectionExpiry"
,
"年检到期日"
),
/**
* 车辆停放地址信息
*/
HANDOVER_ADDRESS
(
"handoverAddress"
,
"车辆停放地址信息"
),
/**
* 出厂日期
*/
PRODUCTION_DATE
(
"productionDate"
,
"出厂日期"
),
/**
* 交强险到期
*/
COMPULSORY_INSURANCE_EXPIRY
(
"compulsoryInsuranceExpiry"
,
"出厂日期"
),
/**
* 车辆品牌名称 示例值:
* 奔驰
*/
CAR_BRAND
(
"carBrand"
,
"品牌"
),
/**
* 车身颜色,外观颜色
*/
EXTERIOR_COLOR
(
"exteriorColor"
,
"车身颜色"
),
/**
* 钥匙数
*/
KEY_COUNT
(
"keyCount"
,
"钥匙数"
),
;
private
final
String
code
;
...
...
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dto/InspectionTemplateDTO.java
0 → 100644
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author yangwei
* @version 1.0
* @since 2026/03/23 14:18
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
InspectionTemplateDTO
implements
Serializable
{
/**
* 模版ID
*/
private
Long
id
;
/**
* 模版编码,如TPL001
*/
private
String
templateCode
;
/**
* 模版名称
*/
private
String
templateName
;
/**
* 模版类型:1-燃油车,2-新能源车
*/
private
Integer
templateType
;
/**
* 状态:0-草稿,1-已发布,2-已禁用
*/
private
Integer
status
=
1
;
/**
* 当前版本号
*/
private
String
version
;
/**
* 模版描述
*/
private
String
description
;
/**
* 模版扩展配置(JSON格式文本)
*/
private
String
configJson
;
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionNodeService.java
View file @
f0abe89
...
...
@@ -209,4 +209,5 @@ public class InspectionNodeService {
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionRecordService.java
View file @
f0abe89
...
...
@@ -2,6 +2,7 @@ package com.glsx.usedcar.module.inspect.service;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.BooleanUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
...
...
@@ -21,7 +22,11 @@ import com.glsx.usedcar.module.inspect.dao.InspectionRecordRepository;
import
com.glsx.usedcar.module.inspect.dao.InspectionResultRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionValueRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderRepository
;
import
com.glsx.usedcar.module.inspect.dto.InspectionResultDTO
;
import
com.glsx.usedcar.module.inspect.dto.InspectionTemplateDTO
;
import
com.glsx.usedcar.module.inspect.entity.*
;
import
com.glsx.usedcar.module.inspect.service.strategy.InspectionValueStrategyRouter
;
import
com.glsx.usedcar.module.inspect.service.strategy.TemplateValueStrategy
;
import
com.glsx.usedcar.module.inspect.vo.*
;
import
com.glsx.usedcar.module.vehicle.entity.Vehicle
;
import
com.glsx.usedcar.util.RedisCacheUtil
;
...
...
@@ -59,10 +64,12 @@ public class InspectionRecordService extends AbstractAuctionService {
private
final
InspectorConverter
inspectorConverter
;
private
final
NodeValidationManager
nodeValidationManager
;
private
final
InspectionNodeService
inspectionNodeService
;
private
final
InspectionTemplateService
inspectionTemplateService
;
private
final
InspectionValueRepository
inspectionValueRepository
;
private
final
InspectionRecordRepository
inspectionRecordRepository
;
private
final
InspectionResultRepository
inspectionResultRepository
;
private
final
InspectionWorkOrderService
inspectionWorkOrderService
;
private
final
InspectionValueStrategyRouter
inspectionValueStrategyRouter
;
private
final
InspectionWorkOrderRepository
inspectionWorkOrderRepository
;
/**
...
...
@@ -74,7 +81,6 @@ public class InspectionRecordService extends AbstractAuctionService {
* 3. 对比提交的节点数据以及节点配置,
* 4. 如果是下一步,则需要提交的节点和节点配置一致,如果是非必填,且没有填写,默认给一个正常的数据,其他都是需要前端传入,
* 使用校验器校验本次提交的叶子节点数据,校验不通过直接报错提醒,报错的枚举 ErrorCodeEnum
*
* 5. 如果是保存,则需要对比叶子节点必填是否都已填,如果都已填,则按照下一步处理,如果还有未填写,则通过校验器校验提交的节点之后保存
* 6. 遍历叶子节点,查找或创建 InspectionResult,这里也需要创建本次保存对应的根节点,有二级节点也需要保存二级节点
* 7. 删除旧的 InspectionValue,批量保存新值
...
...
@@ -109,7 +115,7 @@ public class InspectionRecordService extends AbstractAuctionService {
// 1. 查询或创建检测记录
InspectionRecord
record
=
inspectionRecordRepository
.
findByTaskIdAndDeletedFlag
(
taskId
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
orElseGet
(()
->
createRecord
(
req
));
.
orElseGet
(()
->
createRecord
(
req
,
inspectionWorkOrder
.
getTemplateId
(),
inspectionWorkOrder
.
getTemplateVersion
()
));
Long
recordId
=
record
.
getId
();
// 2. 获取所有节点配置,构建 nodeId -> InspectionNodeVO 映射
...
...
@@ -190,9 +196,19 @@ public class InspectionRecordService extends AbstractAuctionService {
* @param req 请求参数
* @return InspectionRecord
*/
private
InspectionRecord
createRecord
(
InspectionSaveVO
req
)
{
private
InspectionRecord
createRecord
(
InspectionSaveVO
req
,
Long
templateId
,
String
templateVersion
)
{
Long
taskId
=
req
.
getTaskId
();
InspectionTemplateDTO
inspectionTemplateDTO
=
inspectionTemplateService
.
getTemplateByIdAndVersion
(
templateId
,
templateVersion
);
String
templateCode
=
Optional
.
ofNullable
(
inspectionTemplateDTO
)
.
map
(
InspectionTemplateDTO:
:
getTemplateCode
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_INCOMPLETE
,
"检测模版未配置模版代码"
));
InspectionRecord
record
=
InspectionRecord
.
builder
()
.
taskId
(
req
.
getTaskId
())
.
taskId
(
taskId
)
.
templateId
(
templateId
)
.
templateVersion
(
templateVersion
)
.
templateCode
(
templateCode
)
.
progress
(
0
)
.
completedModules
(
0
)
.
locationModule
(
req
.
getLocationModule
())
...
...
@@ -604,10 +620,6 @@ public class InspectionRecordService extends AbstractAuctionService {
return
true
;
}
public
InspectionRecordDetailVO
getDetail
(
Long
recordId
)
{
return
null
;
}
/**
* <pre>
* 查询检测详情
...
...
@@ -639,7 +651,7 @@ public class InspectionRecordService extends AbstractAuctionService {
.
collect
(
Collectors
.
toMap
(
InspectionResult:
:
getNodeId
,
r
->
r
,
(
a
,
b
)
->
a
));
// 5. 从检测项结果中获取车辆基础信息
Map
<
String
,
String
>
baseInfoMap
=
extractBaseInfoFromResults
(
allNodes
,
resultMap
);
Map
<
String
,
String
>
baseInfoMap
=
extractBaseInfoFromResults
(
record
,
allNodes
,
resultMap
);
// 6. 构建树形结构并填充结果
List
<
InspectionNodeVO
>
rootNodes
=
inspectionNodeService
.
getChildNodes
(
0L
,
allNodes
);
...
...
@@ -658,7 +670,7 @@ public class InspectionRecordService extends AbstractAuctionService {
.
carTypeId
(
parseInteger
(
baseInfoMap
.
get
(
InspectionBaseInfoFieldEnum
.
CAR_TYPE_ID
.
getCode
())))
.
licensePlate
(
baseInfoMap
.
get
(
InspectionBaseInfoFieldEnum
.
LICENSE_PLATE
.
getCode
()))
.
carTypeName
(
baseInfoMap
.
get
(
InspectionBaseInfoFieldEnum
.
CAR_TYPE_NAME
.
getCode
()))
.
firstPlate
(
baseInfoMap
.
get
(
InspectionBaseInfoFieldEnum
.
FIRST_PL
ATE
.
getCode
()))
.
registrationDate
(
baseInfoMap
.
get
(
InspectionBaseInfoFieldEnum
.
REGISTRATION_D
ATE
.
getCode
()))
.
emissionStandard
(
baseInfoMap
.
get
(
InspectionBaseInfoFieldEnum
.
EMISSION_STANDARD
.
getCode
()))
.
displacement
(
baseInfoMap
.
get
(
InspectionBaseInfoFieldEnum
.
DISPLACEMENT
.
getCode
()))
.
inspectionScoreVO
(
scoreVO
)
...
...
@@ -674,39 +686,20 @@ public class InspectionRecordService extends AbstractAuctionService {
* @param resultMap 检测结果映射
* @return 车辆基础信息映射(field -> value)
*/
private
Map
<
String
,
String
>
extractBaseInfoFromResults
(
List
<
InspectionNodeVO
>
allNodes
,
Map
<
Long
,
InspectionResult
>
resultMap
)
{
Map
<
String
,
String
>
baseInfoMap
=
new
HashMap
<>();
// 遍历所有叶子节点,提取基础信息
for
(
InspectionNodeVO
node
:
allNodes
)
{
if
(
node
.
getNodeType
()
==
null
||
node
.
getNodeType
()
!=
InspectConstants
.
NODE_TYPE_LEAF
)
{
continue
;
}
// 检查是否是基础信息节点(通过 nodeCode 判断是否在基础信息字段列表中)
String
nodeCode
=
node
.
getNodeCode
();
if
(
StrUtil
.
isBlank
(
nodeCode
))
{
continue
;
}
if
(!
InspectionBaseInfoFieldEnum
.
isBaseInfoField
(
nodeCode
))
{
continue
;
}
// 从检测结果中获取值
InspectionResult
result
=
resultMap
.
get
(
node
.
getId
());
if
(
result
==
null
||
CollUtil
.
isEmpty
(
result
.
getInspectionValues
()))
{
continue
;
}
// 获取第一个值
String
value
=
result
.
getInspectionValues
().
get
(
0
).
getValueText
();
if
(
StrUtil
.
isNotBlank
(
value
))
{
baseInfoMap
.
put
(
nodeCode
,
value
);
}
}
return
baseInfoMap
;
private
Map
<
String
,
String
>
extractBaseInfoFromResults
(
InspectionRecord
record
,
List
<
InspectionNodeVO
>
allNodes
,
Map
<
Long
,
InspectionResult
>
resultMap
)
{
Map
<
Long
,
String
>
nodeIdMapCode
=
Optional
.
ofNullable
(
allNodes
)
.
orElseGet
(
List:
:
of
)
.
stream
()
.
filter
(
el
->
StrUtil
.
isNotBlank
(
el
.
getNodeCode
()))
.
collect
(
Collectors
.
toMap
(
InspectionNodeVO:
:
getId
,
InspectionNodeVO:
:
getNodeCode
,
(
pre
,
next
)
->
next
));
Map
<
String
,
InspectionResult
>
nodeCodeMapResult
=
MapUtil
.<
String
,
InspectionResult
>
builder
().
build
();
nodeIdMapCode
.
forEach
((
nodeId
,
nodeCode
)
->
{
InspectionResult
inspectionResult
=
resultMap
.
get
(
nodeId
);
nodeCodeMapResult
.
put
(
nodeCode
,
inspectionResult
);
});
TemplateValueStrategy
strategy
=
inspectionValueStrategyRouter
.
getStrategy
(
record
.
getTemplateCode
());
return
strategy
.
reportAssignValue
(
record
.
getId
(),
nodeCodeMapResult
);
}
/**
...
...
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionTemplateService.java
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
service
;
import
cn.hutool.core.util.StrUtil
;
import
com.glsx.usedcar.converts.InspectionTemplateConverter
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.module.inspect.dao.InspectionTemplateHistoryRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionTemplateRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderRepository
;
import
com.glsx.usedcar.module.inspect.dto.InspectionTemplateDTO
;
import
com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder
;
import
com.glsx.usedcar.module.inspect.service.strategy.InspectionValueStrategyRouter
;
import
com.glsx.usedcar.module.inspect.service.strategy.TemplateValueStrategy
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDefaultValueReqVO
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.summerframework.core.enums.ErrorCodeEnum
;
import
org.summerframework.core.exception.BusinessCodeException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
/**
* 检测模版服务
...
...
@@ -21,7 +35,84 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
public
class
InspectionTemplateService
{
private
final
InspectionValueStrategyRouter
defaultValueStrategyRouter
;
private
final
InspectionTemplateConverter
inspectionTemplateConverter
;
private
final
InspectionTemplateRepository
inspectionTemplateRepository
;
private
final
InspectionWorkOrderRepository
inspectionWorkOrderRepository
;
private
final
InspectionTemplateHistoryRepository
inspectionTemplateHistoryRepository
;
/**
* 根据模板ID和版本号获取模板信息
* 优先查询主表,不存在时再查询历史表
* @author yangwei
* @since 2026/3/23 14:27
* @param templateId 模板ID
* @param templateVersion 模板版本
* @return com.glsx.usedcar.module.inspect.dto.InspectionTemplateDTO 模板DTO,查不到时抛出异常
* @throws BusinessCodeException 参数为空或模板不存在时抛出
*/
public
InspectionTemplateDTO
getTemplateByIdAndVersion
(
Long
templateId
,
String
templateVersion
)
{
// 获取模版 ID
templateId
=
Optional
.
ofNullable
(
templateId
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_INCOMPLETE
,
"检测工单未配置模版"
));
templateVersion
=
Optional
.
ofNullable
(
templateVersion
)
.
filter
(
StrUtil:
:
isNotBlank
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_INCOMPLETE
,
"检测工单未配置模版版本"
));
Long
finalTemplateId
=
templateId
;
String
finalTemplateVersion
=
templateVersion
;
return
inspectionTemplateRepository
.
findByIdAndVersionAndDeletedFlag
(
templateId
,
templateVersion
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
map
(
inspectionTemplateConverter:
:
entity2DTO
)
.
orElseGet
(()
->
inspectionTemplateHistoryRepository
.
findByTemplateIdAndVersionAndDeletedFlag
(
finalTemplateId
,
finalTemplateVersion
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
map
(
inspectionTemplateConverter:
:
entityHistory2DTO
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
String
.
format
(
"未找到模板(ID: %s, 版本: %s)"
,
finalTemplateId
,
finalTemplateVersion
)))
);
}
/**
* 模版默认值获取通用接口
* - 不同模版可能获取的默认值方式不一致,这里统一使用 Map 返回
* - 入参根据模版代码区分模版,key templateCode
* - 传入主键 taskId 获取模版默认值
* - 不同模版调用不同方法,使用策略模式进行编写
* @author yangwei
* @since 2026/3/23 9:44
* @param reqVO 请求参数对象,包含 templateCode(模版编码)、taskId(检测工单 ID)等
* @return java.util.Map<java.lang.String,java.lang.String> 默认值集合,key 为字段名,value 为默认值
*/
public
Map
<
String
,
String
>
getTemplateDefaultValue
(
InspectionTemplateDefaultValueReqVO
reqVO
)
{
if
(
reqVO
==
null
)
{
log
.
warn
(
"请求参数为空,无法获取模版默认值"
);
return
new
HashMap
<>();
}
// 从参数中获取模版编码和任务 ID
Long
taskId
=
reqVO
.
getTaskId
();
log
.
info
(
"获取模版默认值,taskId: {}"
,
taskId
);
// 查询检测工单
InspectionWorkOrder
workOrder
=
inspectionWorkOrderRepository
.
findByIdAndDeleteFlag
(
taskId
,
DeleteFlag
.
NOT_DELETED
.
getCode
()).
orElse
(
null
);
if
(
workOrder
==
null
)
{
log
.
warn
(
"检测工单不存在,taskId: {}"
,
taskId
);
return
new
HashMap
<>();
}
InspectionTemplateDTO
inspectionTemplateDTO
=
getTemplateByIdAndVersion
(
workOrder
.
getTemplateId
(),
workOrder
.
getTemplateVersion
());
String
templateCode
=
Optional
.
ofNullable
(
inspectionTemplateDTO
)
.
map
(
InspectionTemplateDTO:
:
getTemplateCode
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_INCOMPLETE
,
"检测模版未配置模版代码"
));
TemplateValueStrategy
strategy
=
defaultValueStrategyRouter
.
getStrategy
(
templateCode
);
Map
<
String
,
String
>
defaultValueMap
=
Optional
.
ofNullable
(
strategy
.
getDefaultValue
(
reqVO
,
workOrder
)).
orElseGet
(
HashMap:
:
new
);
log
.
info
(
"获取模版默认值成功,templateCode: {}, taskId: {}, 默认值数量:{}"
,
templateCode
,
taskId
,
defaultValueMap
.
size
());
return
defaultValueMap
;
}
}
\ No newline at end of file
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/DefaultTemplateStrategy.java
0 → 100644
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
service
.
strategy
;
import
com.glsx.usedcar.enums.inspect.InspectionBaseInfoFieldEnum
;
import
com.glsx.usedcar.module.inspect.entity.InspectionResult
;
import
com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDefaultValueReqVO
;
import
com.glsx.usedcar.module.vehicle.entity.BaseInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 默认模版策略实现类
* <p>
* 适用于大多数普通模板,从车辆基础信息中获取默认值
* </p>
*
* @author yangwei
* @since 2026/3/23
*/
@Slf4j
@Component
public
class
DefaultTemplateStrategy
implements
TemplateValueStrategy
{
/**
* 默认策略支持的模版编码
*/
private
static
final
String
DEFAULT_TEMPLATE_CODE
=
"DEFAULT"
;
@Override
public
Map
<
String
,
String
>
getDefaultValue
(
InspectionTemplateDefaultValueReqVO
reqVO
,
InspectionWorkOrder
workOrder
)
{
log
.
debug
(
"执行默认模版策略,templateCode: {}"
,
DEFAULT_TEMPLATE_CODE
);
Map
<
String
,
String
>
defaultValueMap
=
new
HashMap
<>();
if
(
workOrder
==
null
||
workOrder
.
getVehicle
()
==
null
||
workOrder
.
getVehicle
().
getBaseInfo
()
==
null
)
{
return
defaultValueMap
;
}
// 从车辆基础信息中获取默认值
BaseInfo
baseInfo
=
workOrder
.
getVehicle
().
getBaseInfo
();
// 车系信息
if
(
StringUtils
.
hasText
(
baseInfo
.
getCarSeriesName
()))
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
CAR_SERIES_NAME
.
getCode
(),
baseInfo
.
getCarSeriesName
());
}
if
(
baseInfo
.
getCarSeriesId
()
>
0
)
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
CAR_SERIES_ID
.
getCode
(),
String
.
valueOf
(
baseInfo
.
getCarSeriesId
()));
}
// 车型信息
if
(
StringUtils
.
hasText
(
baseInfo
.
getCarTypeName
()))
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
CAR_TYPE_NAME
.
getCode
(),
baseInfo
.
getCarTypeName
());
}
if
(
baseInfo
.
getCarTypeId
()
>
0
)
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
CAR_TYPE_ID
.
getCode
(),
String
.
valueOf
(
baseInfo
.
getCarTypeId
()));
}
// 车架号
if
(
StringUtils
.
hasText
(
baseInfo
.
getVin
()))
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
VIN
.
getCode
(),
baseInfo
.
getVin
());
}
// 车牌号
if
(
StringUtils
.
hasText
(
baseInfo
.
getLicensePlate
()))
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
LICENSE_PLATE
.
getCode
(),
baseInfo
.
getLicensePlate
());
}
// 车源号
if
(
StringUtils
.
hasText
(
baseInfo
.
getSourceNo
()))
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
SOURCE_NO
.
getCode
(),
baseInfo
.
getSourceNo
());
}
// 表显里程
if
(
baseInfo
.
getMileage
()
>
0
)
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
MILEAGE
.
getCode
(),
String
.
valueOf
(
baseInfo
.
getMileage
()));
}
// 发动机号
if
(
StringUtils
.
hasText
(
baseInfo
.
getEngineNumber
()))
{
defaultValueMap
.
put
(
InspectionBaseInfoFieldEnum
.
ENGINE_NUMBER
.
getCode
(),
baseInfo
.
getEngineNumber
());
}
log
.
debug
(
"默认策略执行完成,返回{}个默认值"
,
defaultValueMap
.
size
());
return
defaultValueMap
;
}
@Override
public
Map
<
String
,
String
>
reportAssignValue
(
Long
recordId
,
Map
<
String
,
InspectionResult
>
inspectionResultMap
)
{
return
Map
.
of
();
}
@Override
public
String
getSupportedTemplateCode
()
{
return
DEFAULT_TEMPLATE_CODE
;
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/InspectionValueStrategyRouter.java
0 → 100644
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
service
.
strategy
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author yangwei
* @version 1.0
* @since 2026/03/23 10:35
*/
@Slf4j
@Component
public
class
InspectionValueStrategyRouter
{
/**
* 策略注册表:templateCode -> 策略
*/
private
final
Map
<
String
,
TemplateValueStrategy
>
STRATEGY_MAP
=
new
ConcurrentHashMap
<>();
/**
* 通过 Spring 自动注入所有策略实现类
*/
@Autowired
(
required
=
false
)
public
void
setStrategies
(
List
<
TemplateValueStrategy
>
strategies
)
{
if
(
strategies
!=
null
&&
!
strategies
.
isEmpty
())
{
for
(
TemplateValueStrategy
strategy
:
strategies
)
{
String
templateCode
=
strategy
.
getSupportedTemplateCode
();
if
(
StringUtils
.
hasText
(
templateCode
))
{
STRATEGY_MAP
.
put
(
templateCode
,
strategy
);
log
.
info
(
"自动注册模版策略:templateCode={}"
,
templateCode
);
}
}
}
}
/**
* 获取策略
* @author yangwei
* @since 2026/3/23 10:37
* @param templateCode 模版代码,模版都需要取一个唯一的编码,当然也有id
* @return com.glsx.usedcar.module.inspect.service.strategy.TemplateDefaultValueStrategy
*/
public
TemplateValueStrategy
getStrategy
(
String
templateCode
)
{
TemplateValueStrategy
strategy
=
STRATEGY_MAP
.
get
(
templateCode
);
if
(
strategy
==
null
)
{
log
.
info
(
"未找到模版 [{}] 的特定策略,使用默认策略"
,
templateCode
);
strategy
=
STRATEGY_MAP
.
get
(
"DEFAULT"
);
}
return
strategy
;
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/RyInspectionTemplateCode001.java
0 → 100644
View file @
f0abe89
This diff is collapsed.
Click to expand it.
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/strategy/TemplateValueStrategy.java
0 → 100644
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
service
.
strategy
;
import
com.glsx.usedcar.module.inspect.entity.InspectionResult
;
import
com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDefaultValueReqVO
;
import
java.util.Map
;
/**
* <pre>
* 检测值获取策略,功能如下:
* 1. 获取模版默认值
* @see TemplateValueStrategy#getDefaultValue(InspectionTemplateDefaultValueReqVO, InspectionWorkOrder)
* 2. 检测报告展示检测值获取
* @see TemplateValueStrategy#reportAssignValue(InspectionTemplateDefaultValueReqVO, Map)
*
* <b>注:模版值处理都为特殊处理,需要给模版以及节点添加确定的唯一标识</b>
* </pre>
* @author yangwei
* @version 1.0
* @since 2026/03/23 10:34
*/
public
interface
TemplateValueStrategy
{
/**
* 获取模版默认值
* @param reqVO 请求参数对象
* @param workOrder 检测工单
* @return 默认值 Map,key 为字段名,value 为默认值
*/
Map
<
String
,
String
>
getDefaultValue
(
InspectionTemplateDefaultValueReqVO
reqVO
,
InspectionWorkOrder
workOrder
);
/**
* 检测报告展示检测值获取
* @param recordId 请求参数对象
* @param inspectionResultMap key 检测节点nodeCode, value 检测结果
* @return 默认值 Map,key 为字段名,value 为检测值
*/
Map
<
String
,
String
>
reportAssignValue
(
Long
recordId
,
Map
<
String
,
InspectionResult
>
inspectionResultMap
);
/**
* 获取该策略支持的模版编码
* @return 模版编码
*/
String
getSupportedTemplateCode
();
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionDetailRespVO.java
View file @
f0abe89
...
...
@@ -53,7 +53,7 @@ public class InspectionDetailRespVO implements Serializable {
private
String
carTypeName
;
@Schema
(
description
=
"首次上牌"
)
private
String
firstPl
ate
;
private
String
registrationD
ate
;
@Schema
(
description
=
"排放标准"
)
private
String
emissionStandard
;
...
...
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionTemplateDefaultValueReqVO.java
0 → 100644
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
import
java.io.Serial
;
import
java.io.Serializable
;
/**
* 模版默认值获取请求参数
*
* @author yangwei
* @since 2026/3/23
*/
@Data
@Schema
(
description
=
"模版默认值获取请求参数"
)
public
class
InspectionTemplateDefaultValueReqVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
8374920183746502931L
;
/**
* 检测工单 ID(任务 ID)
*/
@Schema
(
description
=
"检测工单 ID"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1"
)
@NotNull
(
message
=
"任务 ID 不能为空"
)
private
Long
taskId
;
}
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionTemplateController.java
View file @
f0abe89
package
com
.
glsx
.
usedcar
.
controller
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.map.MapUtil
;
import
com.glsx.usedcar.module.inspect.service.InspectionNodeService
;
import
com.glsx.usedcar.module.inspect.service.InspectionTemplateService
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.module.inspect.vo.InspectionRootNodeVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDefaultValueReqVO
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
...
...
@@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
jakarta.validation.Valid
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -29,6 +30,7 @@ import java.util.Map;
public
class
InspectionTemplateController
{
private
final
InspectionNodeService
inspectionNodeService
;
private
final
InspectionTemplateService
inspectionTemplateService
;
/**
* 查询检测模版根节点列表
...
...
@@ -48,8 +50,8 @@ public class InspectionTemplateController {
@PostMapping
(
"/default"
)
@Operation
(
summary
=
"获取模版默认值"
,
description
=
"获取模版默认值"
)
public
BaseResp
<
Map
<
String
,
String
>>
getTemplateDefaultValue
(
@RequestBody
@
Parameter
(
description
=
"参数"
,
required
=
true
)
Map
<
String
,
Object
>
params
)
{
return
BaseResp
.
success
(
MapUtil
.<
String
,
String
>
builder
().
build
(),
"模版默认值"
);
@RequestBody
@
Valid
@Parameter
(
description
=
"请求参数"
,
required
=
true
)
InspectionTemplateDefaultValueReqVO
reqVO
)
{
return
BaseResp
.
success
(
inspectionTemplateService
.
getTemplateDefaultValue
(
reqVO
)
);
}
}
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