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 add328ff
authored
Apr 08, 2026
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:检测模版、完成检测以及事件埋点接口编写
1 parent
f828cf74
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
2096 additions
and
8 deletions
aus-admin/src/main/java/com/glsx/usedcar/web/rest/event/EventTrackingController.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionTemplateController.java
aus-core/src/main/java/com/glsx/usedcar/consts/common/CommonConsts.java
aus-core/src/main/java/com/glsx/usedcar/consts/inspect/JpaQueryConstants.java
aus-core/src/main/java/com/glsx/usedcar/enums/event/BusinessTypeEnum.java
aus-core/src/main/java/com/glsx/usedcar/enums/event/EventSourceEnum.java
aus-core/src/main/java/com/glsx/usedcar/enums/event/ParamTypeEnum.java
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTrackingBusinessKeyRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTrackingParamRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTrackingRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTypeConfigRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTracking.java
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTrackingBusinessKey.java
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTrackingParam.java
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTypeConfig.java
aus-core/src/main/java/com/glsx/usedcar/module/event/service/EventTrackingService.java
aus-core/src/main/java/com/glsx/usedcar/module/event/vo/EventTrackingBatchSaveVO.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/InspectionOpLogItemRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/InspectionOpLogRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/TemplateTagRelationRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/TemplateTagRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/InspectionOpLog.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/InspectionOpLogItem.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/InspectionTemplate.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/TemplateTag.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/TemplateTagRelation.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/vo/CompleteInspectionRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionTemplateDetailRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionTemplateRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/TemplateTagVO.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/event/EventTrackingController.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
web
.
rest
.
event
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.usedcar.enums.event.EventSourceEnum
;
import
com.glsx.usedcar.module.event.service.EventTrackingService
;
import
com.glsx.usedcar.module.event.vo.EventTrackingBatchSaveVO
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
jakarta.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.glsx.usedcar.module.security.entity.User
;
import
com.glsx.usedcar.resp.BaseResp
;
import
org.summerframework.core.exception.BusinessCodeException
;
/**
* 埋点事件控制器
*
* @author yangwei
* @version 1.0
* @since 2026/04/07 21:12
*/
@Slf4j
@RestController
@RequestMapping
(
"/rest/eventTracking"
)
@RequiredArgsConstructor
@Tag
(
name
=
"埋点事件控制器"
,
description
=
"埋点事件控制器"
)
public
class
EventTrackingController
{
private
final
EventTrackingService
eventTrackingService
;
/**
* 批量保存埋点事件
*
* @param vo 请求体(包含事件列表、业务主键、扩展参数)
* @param authentication 当前登录用户
* @return 操作结果
*/
@PostMapping
(
"/batchSave"
)
@Operation
(
summary
=
"批量保存埋点事件"
,
description
=
"前端批量上报用户行为埋点事件,支持同时携带业务主键和扩展参数"
)
public
BaseResp
<
Void
>
batchSave
(
@Valid
@RequestBody
EventTrackingBatchSaveVO
vo
,
Authentication
authentication
)
{
log
.
info
(
"【接口请求】批量保存埋点事件,操作人={},事件数量={}"
,
getUserName
(
authentication
),
vo
.
getEvents
()
==
null
?
0
:
vo
.
getEvents
().
size
());
try
{
User
user
=
(
User
)
authentication
.
getPrincipal
();
eventTrackingService
.
batchSave
(
vo
,
String
.
valueOf
(
user
.
getUserId
()),
user
.
getUserName
(),
EventSourceEnum
.
ADMIN
.
getSource
());
return
BaseResp
.
success
();
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】批量保存埋点事件失败!操作人={},业务异常!"
,
getUserName
(
authentication
),
be
);
return
BaseResp
.
fail
(
StrUtil
.
toString
(
be
.
getCode
()),
be
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
"【接口响应】批量保存埋点事件失败!操作人={},系统异常!"
,
getUserName
(
authentication
),
e
);
return
BaseResp
.
fail
(
"系统异常: "
+
e
.
getMessage
());
}
}
private
String
getUserName
(
Authentication
authentication
)
{
try
{
return
authentication
!=
null
?
((
User
)
authentication
.
getPrincipal
()).
getUserName
()
:
"未知用户"
;
}
catch
(
Exception
e
)
{
return
"未知用户"
;
}
}
}
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionTemplateController.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
web
.
rest
.
inspect
;
import
cn.hutool.core.util.StrUtil
;
import
com.glsx.usedcar.module.inspect.entity.InspectionTemplate
;
import
com.glsx.usedcar.module.inspect.service.InspectionTemplateService
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDetailRespVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateRespVO
;
import
com.glsx.usedcar.module.security.entity.User
;
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.data.domain.Page
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.web.bind.annotation.*
;
import
org.summerframework.core.exception.BusinessCodeException
;
import
org.summerframework.orm.paging.Pagination
;
/**
* 检测报告模版前端控制器
* @author yangwei
* @version 1.0
* @since 2026/04/07 19:47
*/
@Slf4j
@RestController
@RequestMapping
(
"/rest/inspectionTemplate"
)
@RequiredArgsConstructor
@Tag
(
name
=
"检测报告模版前端控制器"
,
description
=
"检测报告模版的增删改查操作"
)
public
class
InspectionTemplateController
{
private
final
InspectionTemplateService
inspectionTemplateService
;
/**
* 分页查询检测模版列表
* <p>
* 支持通过 data.keyword 模糊匹配模版名称、模版编码
*/
@Operation
(
summary
=
"分页查询检测模版"
,
description
=
"返回模版基本信息(编码、名称、类型、状态、版本、描述等),支持 data.keyword 模糊查询"
)
@PostMapping
(
"/page"
)
public
Page
<
InspectionTemplateRespVO
>
pageList
(
@RequestBody
Pagination
<
InspectionTemplate
>
pagination
,
Authentication
authentication
)
{
log
.
info
(
"【接口请求】分页查询检测模版,操作人={},页码={},条数={}"
,
getUserName
(
authentication
),
pagination
.
getOffset
(),
pagination
.
getLimit
());
try
{
return
inspectionTemplateService
.
pageList
(
pagination
);
}
catch
(
Exception
e
)
{
log
.
error
(
"【接口响应】分页查询检测模版失败!操作人={},系统异常!"
,
getUserName
(
authentication
),
e
);
return
null
;
}
}
/**
* 查询检测模版详情(含节点配置树)
*/
@Operation
(
summary
=
"检测模版详情"
,
description
=
"返回模版基本信息及完整节点配置树(不填充检测数据)"
)
@GetMapping
(
"/detail/{id}"
)
public
BaseResp
<
InspectionTemplateDetailRespVO
>
detail
(
@Parameter
(
description
=
"模版ID"
,
required
=
true
)
@PathVariable
(
"id"
)
Long
id
,
Authentication
authentication
)
{
log
.
info
(
"【接口请求】查询检测模版详情,操作人={},模版ID={}"
,
getUserName
(
authentication
),
id
);
try
{
InspectionTemplateDetailRespVO
result
=
inspectionTemplateService
.
detail
(
id
);
return
BaseResp
.
success
(
result
);
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】查询检测模版详情失败!操作人={},业务异常!"
,
getUserName
(
authentication
),
be
);
return
BaseResp
.
fail
(
StrUtil
.
toString
(
be
.
getCode
()),
be
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
"【接口响应】查询检测模版详情失败!操作人={},系统异常!"
,
getUserName
(
authentication
),
e
);
return
BaseResp
.
fail
(
"系统异常: "
+
e
.
getMessage
());
}
}
/**
* 安全获取操作人姓名(避免空指针)
*/
private
String
getUserName
(
Authentication
authentication
)
{
try
{
return
authentication
!=
null
?
((
User
)
authentication
.
getPrincipal
()).
getUserName
()
:
"未知用户"
;
}
catch
(
Exception
e
)
{
return
"未知用户"
;
}
}
}
aus-core/src/main/java/com/glsx/usedcar/consts/common/CommonConsts.java
View file @
add328f
...
@@ -14,4 +14,7 @@ public interface CommonConsts {
...
@@ -14,4 +14,7 @@ public interface CommonConsts {
/** 1 */
/** 1 */
String
ONE
=
"1"
;
String
ONE
=
"1"
;
Integer
ZERO_INT
=
0
;
Integer
ONE_INT
=
1
;
}
}
aus-core/src/main/java/com/glsx/usedcar/consts/inspect/JpaQueryConstants.java
View file @
add328f
...
@@ -8,6 +8,8 @@ package com.glsx.usedcar.consts.inspect;
...
@@ -8,6 +8,8 @@ package com.glsx.usedcar.consts.inspect;
*/
*/
public
interface
JpaQueryConstants
{
public
interface
JpaQueryConstants
{
String
KEYWORD
=
"keyword"
;
/**
/**
* 检测师
* 检测师
...
...
aus-core/src/main/java/com/glsx/usedcar/enums/event/BusinessTypeEnum.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
enums
.
event
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 埋点时间业务类型枚举
* @author yangwei
* @version 1.0
* @since 2026/04/07 21:27
*/
@Getter
@AllArgsConstructor
public
enum
BusinessTypeEnum
{
INSPECTION_MANAGEMENT
(
"INSPECTION_MANAGEMENT"
,
"检测管理"
),
REPORT
(
"REPORT"
,
"报表"
),
VEHICLE
(
"VEHICLE"
,
"车辆"
),
WORK_ORDER
(
"WORK_ORDER"
,
"工单"
);
private
final
String
value
;
private
final
String
desc
;
}
aus-core/src/main/java/com/glsx/usedcar/enums/event/EventSourceEnum.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
enums
.
event
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 事件来源,admin、api、inspector
* @author yangwei
* @version 1.0
* @since 2026/04/07 21:32
*/
@Getter
@AllArgsConstructor
public
enum
EventSourceEnum
{
// 事件来源,admin、api、inspector
ADMIN
(
"admin"
),
API
(
"api"
),
INSPECTOR
(
"inspector"
);
private
final
String
source
;
}
aus-core/src/main/java/com/glsx/usedcar/enums/event/ParamTypeEnum.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
enums
.
event
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 埋点事件参数类型
* @author yangwei
* @version 1.0
* @since 2026/04/07 21:24
*/
@Getter
@AllArgsConstructor
public
enum
ParamTypeEnum
{
// 参数类型: STRING, NUMBER, BOOLEAN, ARRAY, OBJECT
STRING
(
"STRING"
),
NUMBER
(
"NUMBER"
),
BOOLEAN
(
"BOOLEAN"
),
ARRAY
(
"ARRAY"
),
OBJECT
(
"OBJECT"
);
private
final
String
value
;
}
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTrackingBusinessKeyRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
dao
;
import
com.glsx.usedcar.module.event.entity.EventTrackingBusinessKey
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
import
org.summerframework.orm.BaseRepository
;
import
java.util.List
;
import
java.util.Optional
;
/**
* 埋点事件业务主键表数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
EventTrackingBusinessKeyRepository
extends
BaseRepository
<
EventTrackingBusinessKey
,
Long
>,
JpaSpecificationExecutor
<
EventTrackingBusinessKey
>
{
/**
* 根据事件ID和删除标识查询业务主键列表
*
* @param eventId 事件ID
* @param deleteFlag 删除标识
* @return 业务主键列表
*/
List
<
EventTrackingBusinessKey
>
findByEventIdAndDeleteFlag
(
Long
eventId
,
String
deleteFlag
);
/**
* 根据业务类型和业务主键及删除标识查询列表
*
* @param businessType 业务类型
* @param businessKey 业务主键
* @param deleteFlag 删除标识
* @return 业务主键列表
*/
List
<
EventTrackingBusinessKey
>
findByBusinessTypeAndBusinessKeyAndDeleteFlag
(
String
businessType
,
String
businessKey
,
String
deleteFlag
);
/**
* 根据事件ID、业务类型、业务主键及删除标识查询
*
* @param eventId 事件ID
* @param businessType 业务类型
* @param businessKey 业务主键
* @param deleteFlag 删除标识
* @return 业务主键信息
*/
Optional
<
EventTrackingBusinessKey
>
findByEventIdAndBusinessTypeAndBusinessKeyAndDeleteFlag
(
Long
eventId
,
String
businessType
,
String
businessKey
,
String
deleteFlag
);
/**
* 根据事件ID列表和删除标识查询业务主键列表
*
* @param eventIds 事件ID列表
* @param deleteFlag 删除标识
* @return 业务主键列表
*/
List
<
EventTrackingBusinessKey
>
findByEventIdInAndDeleteFlag
(
List
<
Long
>
eventIds
,
String
deleteFlag
);
}
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTrackingParamRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
dao
;
import
com.glsx.usedcar.module.event.entity.EventTrackingParam
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
import
org.summerframework.orm.BaseRepository
;
import
java.util.List
;
import
java.util.Optional
;
/**
* 埋点事件参数表数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
EventTrackingParamRepository
extends
BaseRepository
<
EventTrackingParam
,
Long
>,
JpaSpecificationExecutor
<
EventTrackingParam
>
{
/**
* 根据事件ID和删除标识查询参数列表
*
* @param eventId 事件ID
* @param deleteFlag 删除标识
* @return 参数列表
*/
List
<
EventTrackingParam
>
findByEventIdAndDeleteFlag
(
Long
eventId
,
String
deleteFlag
);
/**
* 根据事件ID、参数键和删除标识查询参数
*
* @param eventId 事件ID
* @param paramKey 参数键
* @param deleteFlag 删除标识
* @return 参数信息
*/
Optional
<
EventTrackingParam
>
findByEventIdAndParamKeyAndDeleteFlag
(
Long
eventId
,
String
paramKey
,
String
deleteFlag
);
/**
* 根据事件ID列表和删除标识查询参数列表
*
* @param eventIds 事件ID列表
* @param deleteFlag 删除标识
* @return 参数列表
*/
List
<
EventTrackingParam
>
findByEventIdInAndDeleteFlag
(
List
<
Long
>
eventIds
,
String
deleteFlag
);
/**
* 根据参数键和删除标识查询参数列表
*
* @param paramKey 参数键
* @param deleteFlag 删除标识
* @return 参数列表
*/
List
<
EventTrackingParam
>
findByParamKeyAndDeleteFlag
(
String
paramKey
,
String
deleteFlag
);
}
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTrackingRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
dao
;
import
com.glsx.usedcar.module.event.entity.EventTracking
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
import
org.summerframework.orm.BaseRepository
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* 埋点事件主表数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
EventTrackingRepository
extends
BaseRepository
<
EventTracking
,
Long
>,
JpaSpecificationExecutor
<
EventTracking
>
{
/**
* 根据事件代码和删除标识查询列表
*
* @param eventCode 事件代码
* @param deleteFlag 删除标识
* @return 事件列表
*/
List
<
EventTracking
>
findByEventCodeAndDeleteFlag
(
String
eventCode
,
String
deleteFlag
);
/**
* 根据账户ID和删除标识查询列表
*
* @param accountId 账户ID
* @param deleteFlag 删除标识
* @return 事件列表
*/
List
<
EventTracking
>
findByAccountIdAndDeleteFlag
(
String
accountId
,
String
deleteFlag
);
/**
* 根据账户ID、事件代码和删除标识查询列表
*
* @param accountId 账户ID
* @param eventCode 事件代码
* @param deleteFlag 删除标识
* @return 事件列表
*/
List
<
EventTracking
>
findByAccountIdAndEventCodeAndDeleteFlag
(
String
accountId
,
String
eventCode
,
String
deleteFlag
);
/**
* 根据事件时间范围和删除标识查询列表
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param deleteFlag 删除标识
* @return 事件列表
*/
List
<
EventTracking
>
findByEventTimeBetweenAndDeleteFlag
(
LocalDateTime
startTime
,
LocalDateTime
endTime
,
String
deleteFlag
);
}
aus-core/src/main/java/com/glsx/usedcar/module/event/dao/EventTypeConfigRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
dao
;
import
com.glsx.usedcar.module.event.entity.EventTypeConfig
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
import
org.summerframework.orm.BaseRepository
;
import
java.util.List
;
import
java.util.Optional
;
/**
* 事件类型配置表数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
EventTypeConfigRepository
extends
BaseRepository
<
EventTypeConfig
,
Long
>,
JpaSpecificationExecutor
<
EventTypeConfig
>
{
/**
* 根据事件名称和删除标识查询
*
* @param eventName 事件名称
* @param deleteFlag 删除标识
* @return 事件类型配置
*/
Optional
<
EventTypeConfig
>
findByEventNameAndDeleteFlag
(
String
eventName
,
String
deleteFlag
);
/**
* 根据事件代码和删除标识查询
*
* @param eventCode 事件代码
* @param deleteFlag 删除标识
* @return 事件类型配置
*/
Optional
<
EventTypeConfig
>
findByEventCodeAndDeleteFlag
(
String
eventCode
,
String
deleteFlag
);
/**
* 根据事件类型和删除标识查询列表
*
* @param eventType 事件类型
* @param deleteFlag 删除标识
* @return 事件类型配置列表
*/
List
<
EventTypeConfig
>
findByEventTypeAndDeleteFlag
(
String
eventType
,
String
deleteFlag
);
/**
* 根据所属模块和删除标识查询列表
*
* @param module 所属模块
* @param deleteFlag 删除标识
* @return 事件类型配置列表
*/
List
<
EventTypeConfig
>
findByModuleAndDeleteFlag
(
String
module
,
String
deleteFlag
);
/**
* 根据启用状态和删除标识查询列表
*
* @param isActive 是否启用
* @param deleteFlag 删除标识
* @return 事件类型配置列表
*/
List
<
EventTypeConfig
>
findByIsActiveAndDeleteFlag
(
Integer
isActive
,
String
deleteFlag
);
}
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTracking.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
entity
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 埋点事件主表(EventTracking)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"event_tracking"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
EventTracking
extends
AuditingEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
2325290238446386363L
;
/**
* 主键ID
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
name
=
"EVENT_ID"
,
unique
=
true
,
nullable
=
false
)
private
Long
eventId
;
/**
* 事件代码
*/
@Column
(
name
=
"EVENT_CODE"
,
nullable
=
false
,
length
=
128
)
private
String
eventCode
;
/**
* 事件来源,admin、api、inspector
* @see com.glsx.usedcar.enums.event.EventSourceEnum
*/
@Column
(
name
=
"SOURCE"
,
nullable
=
false
,
length
=
128
)
private
String
source
;
/**
* 操作人账户ID
*/
@Column
(
name
=
"ACCOUNT_ID"
,
nullable
=
false
,
length
=
64
)
private
String
accountId
;
/**
* 操作人账户名称
*/
@Column
(
name
=
"ACCOUNT_NAME"
,
nullable
=
false
,
length
=
64
)
private
String
accountName
;
/**
* 操作人工号
*/
@Column
(
name
=
"OPERATOR_ID"
,
length
=
64
)
private
String
operatorId
;
/**
* 时长(秒),用于页面停留事件
*/
@Column
(
name
=
"DURATION"
)
private
Integer
duration
;
/**
* 事件时间
*/
@Column
(
name
=
"EVENT_TIME"
,
nullable
=
false
)
private
LocalDateTime
eventTime
;
/**
* 删除标识 N:未删除 D:已删除
*/
@Builder
.
Default
@Column
(
name
=
"DELETE_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deleteFlag
=
"N"
;
/**
* 备注
*/
@Column
(
name
=
"REMARK"
,
length
=
256
)
private
String
remark
;
}
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTrackingBusinessKey.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
entity
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 埋点事件业务主键表(EventTrackingBusinessKey)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"event_tracking_business_key"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
EventTrackingBusinessKey
extends
AuditingEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
5710355237303945508L
;
/**
* 主键ID
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
name
=
"BIZ_ID"
,
unique
=
true
,
nullable
=
false
)
private
Long
bizId
;
/**
* 关联 event_tracking.event_id
*/
@Column
(
name
=
"EVENT_ID"
,
nullable
=
false
)
private
Long
eventId
;
/**
* 业务类型: REPORT-报告, VEHICLE-车辆, WORK_ORDER-工单...
*/
@Column
(
name
=
"BUSINESS_TYPE"
,
nullable
=
false
,
length
=
64
)
private
String
businessType
;
/**
* 业务主键
*/
@Column
(
name
=
"BUSINESS_KEY"
,
nullable
=
false
,
length
=
128
)
private
String
businessKey
;
/**
* 删除标识 N:未删除 D:已删除
*/
@Builder
.
Default
@Column
(
name
=
"DELETE_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deleteFlag
=
"N"
;
/**
* 备注
*/
@Column
(
name
=
"REMARK"
,
length
=
256
)
private
String
remark
;
}
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTrackingParam.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
entity
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 埋点事件参数表(EventTrackingParam)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"event_tracking_param"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
EventTrackingParam
extends
AuditingEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
928261531995021747L
;
/**
* 主键ID
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
name
=
"PARAM_ID"
,
unique
=
true
,
nullable
=
false
)
private
Long
paramId
;
/**
* 关联 event_tracking.event_id
*/
@Column
(
name
=
"EVENT_ID"
,
nullable
=
false
)
private
Long
eventId
;
/**
* 参数键
*/
@Column
(
name
=
"PARAM_KEY"
,
nullable
=
false
,
length
=
100
)
private
String
paramKey
;
/**
* 参数值
*/
@Column
(
name
=
"PARAM_VALUE"
,
columnDefinition
=
"TEXT"
)
private
String
paramValue
;
/**
* 参数类型: STRING, NUMBER, BOOLEAN, ARRAY, OBJECT
*/
@Builder
.
Default
@Column
(
name
=
"PARAM_TYPE"
,
length
=
32
)
private
String
paramType
=
"STRING"
;
/**
* 删除标识 N:未删除 D:已删除
*/
@Builder
.
Default
@Column
(
name
=
"DELETE_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deleteFlag
=
"N"
;
/**
* 备注
*/
@Column
(
name
=
"REMARK"
,
length
=
256
)
private
String
remark
;
}
aus-core/src/main/java/com/glsx/usedcar/module/event/entity/EventTypeConfig.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
entity
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 事件类型配置表(EventTypeConfig)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"event_type_config"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
EventTypeConfig
extends
AuditingEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
2192070012796048699L
;
/**
* 主键ID
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
name
=
"ID"
,
unique
=
true
,
nullable
=
false
)
private
Long
id
;
/**
* 事件类型: CLICK-点击事件, PAGE_VIEW-页面浏览, PAGE_DURATION-页面停留时长
*/
@Column
(
name
=
"EVENT_TYPE"
,
nullable
=
false
,
length
=
32
)
private
String
eventType
;
/**
* 事件代码
*/
@Column
(
name
=
"EVENT_CODE"
,
nullable
=
false
,
length
=
128
)
private
String
eventCode
;
/**
* 事件名称
*/
@Column
(
name
=
"EVENT_NAME"
,
nullable
=
false
,
length
=
128
)
private
String
eventName
;
/**
* 事件描述
*/
@Column
(
name
=
"EVENT_DESC"
,
length
=
512
)
private
String
eventDesc
;
/**
* 所属模块
*/
@Column
(
name
=
"MODULE"
,
length
=
64
)
private
String
module
;
/**
* 是否启用 1:启用 0:禁用
*/
@Builder
.
Default
@Column
(
name
=
"IS_ACTIVE"
,
nullable
=
false
)
private
Integer
isActive
=
1
;
/**
* 删除标识 N:未删除 D:已删除
*/
@Builder
.
Default
@Column
(
name
=
"DELETE_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deleteFlag
=
"N"
;
/**
* 备注
*/
@Column
(
name
=
"REMARK"
,
length
=
256
)
private
String
remark
;
}
aus-core/src/main/java/com/glsx/usedcar/module/event/service/EventTrackingService.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
service
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.glsx.usedcar.consts.common.CommonConsts
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.enums.event.EventSourceEnum
;
import
com.glsx.usedcar.enums.event.ParamTypeEnum
;
import
com.glsx.usedcar.module.event.dao.EventTrackingBusinessKeyRepository
;
import
com.glsx.usedcar.module.event.dao.EventTrackingParamRepository
;
import
com.glsx.usedcar.module.event.dao.EventTrackingRepository
;
import
com.glsx.usedcar.module.event.dao.EventTypeConfigRepository
;
import
com.glsx.usedcar.module.event.entity.EventTracking
;
import
com.glsx.usedcar.module.event.entity.EventTrackingBusinessKey
;
import
com.glsx.usedcar.module.event.entity.EventTrackingParam
;
import
com.glsx.usedcar.module.event.entity.EventTypeConfig
;
import
com.glsx.usedcar.module.event.vo.EventTrackingBatchSaveVO
;
import
com.glsx.usedcar.module.event.vo.EventTrackingBatchSaveVO.BusinessKeyVO
;
import
com.glsx.usedcar.module.event.vo.EventTrackingBatchSaveVO.EventTrackingItemVO
;
import
com.glsx.usedcar.module.event.vo.EventTrackingBatchSaveVO.ParamVO
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.summerframework.core.enums.ErrorCodeEnum
;
import
org.summerframework.core.exception.BusinessCodeException
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* 埋点事件服务
*
* @author yangwei
* @version 1.0
* @since 2026/04/07
*/
@Slf4j
@Service
@RequiredArgsConstructor
public
class
EventTrackingService
{
private
final
EventTrackingRepository
eventTrackingRepository
;
private
final
EventTypeConfigRepository
eventTypeConfigRepository
;
private
final
EventTrackingParamRepository
eventTrackingParamRepository
;
private
final
EventTrackingBusinessKeyRepository
eventTrackingBusinessKeyRepository
;
/**
* 批量保存埋点事件
* <p>
* 流程:
* 1. 校验 eventCode 在 event_type_config 中存在且启用
* 2. 批量插入 event_tracking 主表
* 3. 批量插入 event_tracking_business_key(若有)
* 4. 批量插入 event_tracking_param(若有)
*
* @param vo 批量请求体
* @param accountId 操作人账户ID
* @param accountName 操作人账户名称
* @param source 来源标识(admin / api / inspector)
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
batchSave
(
EventTrackingBatchSaveVO
vo
,
String
accountId
,
String
accountName
,
String
source
)
{
List
<
EventTrackingItemVO
>
items
=
vo
.
getEvents
();
// 1. 收集所有 eventCode,批量查 event_type_config 做合法性校验
Set
<
String
>
eventCodes
=
items
.
stream
()
.
map
(
EventTrackingItemVO:
:
getEventCode
)
.
collect
(
Collectors
.
toSet
());
List
<
EventTypeConfig
>
configs
=
eventTypeConfigRepository
.
findByIsActiveAndDeleteFlag
(
CommonConsts
.
ONE_INT
,
DeleteFlag
.
NOT_DELETED
.
getCode
());
Map
<
String
,
EventTypeConfig
>
configMap
=
configs
.
stream
()
.
collect
(
Collectors
.
toMap
(
EventTypeConfig:
:
getEventCode
,
Function
.
identity
(),
(
pre
,
next
)
->
pre
));
// 校验所有 eventCode 均在配置中
for
(
String
code
:
eventCodes
)
{
if
(!
configMap
.
containsKey
(
code
))
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
String
.
format
(
"事件代码 [%s] 未在 event_type_config 中配置或未启用"
,
code
));
}
}
// 2. 批量插入 event_tracking 主表
LocalDateTime
now
=
LocalDateTime
.
now
();
List
<
EventTracking
>
trackings
=
items
.
stream
()
.
map
(
item
->
EventTracking
.
builder
()
.
eventCode
(
item
.
getEventCode
())
.
accountId
(
accountId
)
.
accountName
(
accountName
)
.
source
(
StrUtil
.
blankToDefault
(
source
,
EventSourceEnum
.
ADMIN
.
getSource
()))
.
eventTime
(
item
.
getEventTime
()
!=
null
?
item
.
getEventTime
()
:
now
)
.
duration
(
item
.
getDuration
())
.
remark
(
item
.
getRemark
())
.
build
())
.
collect
(
Collectors
.
toList
());
List
<
EventTracking
>
savedTrackings
=
eventTrackingRepository
.
saveAll
(
trackings
);
log
.
info
(
"【埋点】批量保存事件主表成功,数量={}"
,
savedTrackings
.
size
());
// 3. 批量插入业务主键 & 参数(按索引对应)
List
<
EventTrackingBusinessKey
>
bizKeys
=
new
ArrayList
<>();
List
<
EventTrackingParam
>
params
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
items
.
size
();
i
++)
{
EventTrackingItemVO
item
=
items
.
get
(
i
);
Long
eventId
=
savedTrackings
.
get
(
i
).
getEventId
();
// 业务主键
if
(
CollUtil
.
isNotEmpty
(
item
.
getBusinessKeys
()))
{
for
(
BusinessKeyVO
bk
:
item
.
getBusinessKeys
())
{
bizKeys
.
add
(
EventTrackingBusinessKey
.
builder
()
.
eventId
(
eventId
)
.
businessType
(
bk
.
getBusinessType
())
.
businessKey
(
bk
.
getBusinessKey
())
.
build
());
}
}
// 扩展参数
if
(
CollUtil
.
isNotEmpty
(
item
.
getParams
()))
{
for
(
ParamVO
p
:
item
.
getParams
())
{
params
.
add
(
EventTrackingParam
.
builder
()
.
eventId
(
eventId
)
.
paramKey
(
p
.
getParamKey
())
.
paramValue
(
p
.
getParamValue
())
.
paramType
(
StrUtil
.
blankToDefault
(
p
.
getParamType
(),
ParamTypeEnum
.
STRING
.
getValue
()))
.
build
());
}
}
}
if
(
CollUtil
.
isNotEmpty
(
bizKeys
))
{
eventTrackingBusinessKeyRepository
.
saveAll
(
bizKeys
);
log
.
info
(
"【埋点】批量保存业务主键成功,数量={}"
,
bizKeys
.
size
());
}
if
(
CollUtil
.
isNotEmpty
(
params
))
{
eventTrackingParamRepository
.
saveAll
(
params
);
log
.
info
(
"【埋点】批量保存参数成功,数量={}"
,
params
.
size
());
}
}
}
aus-core/src/main/java/com/glsx/usedcar/module/event/vo/EventTrackingBatchSaveVO.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
event
.
vo
;
import
com.glsx.usedcar.enums.event.BusinessTypeEnum
;
import
com.glsx.usedcar.enums.event.ParamTypeEnum
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.Valid
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.NotEmpty
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* 埋点事件批量保存请求 VO
*
* @author yangwei
* @version 1.0
* @since 2026/04/07
*/
@Data
@Schema
(
description
=
"埋点事件批量保存请求 VO"
)
public
class
EventTrackingBatchSaveVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
6490522758631650481L
;
/**
* 事件列表,至少包含一条
*/
@Valid
@NotEmpty
(
message
=
"事件列表不能为空"
)
@Schema
(
description
=
"事件列表"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
List
<
EventTrackingItemVO
>
events
;
// ----------------------------------------------------------------
// 单条事件 VO
// ----------------------------------------------------------------
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"单条埋点事件"
)
public
static
class
EventTrackingItemVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
3543221761509804738L
;
/**
* 事件代码,需在 event_type_config 中已配置且启用
*/
@NotBlank
(
message
=
"事件代码不能为空"
)
@Schema
(
description
=
"事件代码"
,
example
=
"REPORT_DETAIL_VIEW"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
eventCode
;
/**
* 事件时间(前端传入,格式 yyyy-MM-dd HH:mm:ss)
* 为空时取服务器当前时间
*/
@Schema
(
description
=
"事件时间,为空则取服务器时间"
)
private
LocalDateTime
eventTime
;
/**
* 时长(秒),仅页面停留类事件需传
*/
@Schema
(
description
=
"时长(秒),页面停留事件使用"
)
private
Integer
duration
;
/**
* 备注
*/
@Schema
(
description
=
"备注"
)
private
String
remark
;
/**
* 业务主键列表(可选)
*/
@Valid
@Schema
(
description
=
"业务主键列表"
)
private
List
<
BusinessKeyVO
>
businessKeys
;
/**
* 扩展参数列表(可选)
*/
@Valid
@Schema
(
description
=
"扩展参数列表"
)
private
List
<
ParamVO
>
params
;
}
// ----------------------------------------------------------------
// 业务主键 VO
// ----------------------------------------------------------------
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"业务主键"
)
public
static
class
BusinessKeyVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
3401073440486276291L
;
/**
* 业务类型,如 REPORT、VEHICLE、WORK_ORDER
* @see com.glsx.usedcar.enums.event.BusinessTypeEnum
*/
@NotBlank
(
message
=
"业务类型不能为空"
)
@Schema
(
description
=
"业务类型"
,
example
=
"REPORT"
)
@Builder
.
Default
private
String
businessType
=
BusinessTypeEnum
.
INSPECTION_MANAGEMENT
.
getValue
();
/**
* 业务主键值
*/
@NotBlank
(
message
=
"业务主键不能为空"
)
@Schema
(
description
=
"业务主键"
,
example
=
"123456"
)
private
String
businessKey
;
}
// ----------------------------------------------------------------
// 扩展参数 VO
// ----------------------------------------------------------------
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"扩展参数"
)
public
static
class
ParamVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
2621909004110488768L
;
/**
* 参数键
*/
@NotBlank
(
message
=
"参数键不能为空"
)
@Schema
(
description
=
"参数键"
,
example
=
"page_name"
)
private
String
paramKey
;
/**
* 参数值
*/
@Schema
(
description
=
"参数值"
)
private
String
paramValue
;
/**
* 参数类型: STRING, NUMBER, BOOLEAN, ARRAY, OBJECT
*/
@Schema
(
description
=
"参数类型:STRING, NUMBER, BOOLEAN, ARRAY, OBJECT"
,
example
=
"STRING"
)
@Builder
.
Default
private
String
paramType
=
ParamTypeEnum
.
STRING
.
getValue
();
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/InspectionOpLogItemRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
dao
;
import
com.glsx.usedcar.module.inspect.entity.InspectionOpLogItem
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
import
org.summerframework.orm.BaseRepository
;
import
java.util.List
;
/**
* 检测报告操作日志明细表数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
InspectionOpLogItemRepository
extends
BaseRepository
<
InspectionOpLogItem
,
Long
>,
JpaSpecificationExecutor
<
InspectionOpLogItem
>
{
/**
* 根据日志ID和删除标识查询明细列表
*
* @param logId 日志ID
* @param deleteFlag 删除标识
* @return 明细列表
*/
List
<
InspectionOpLogItem
>
findByLogIdAndDeleteFlag
(
Long
logId
,
String
deleteFlag
);
/**
* 根据日志ID列表和删除标识查询明细列表
*
* @param logIds 日志ID列表
* @param deleteFlag 删除标识
* @return 明细列表
*/
List
<
InspectionOpLogItem
>
findByLogIdInAndDeleteFlag
(
List
<
Long
>
logIds
,
String
deleteFlag
);
/**
* 根据日志ID、一级模块名和删除标识查询明细列表
*
* @param logId 日志ID
* @param moduleName 一级模块名称
* @param deleteFlag 删除标识
* @return 明细列表
*/
List
<
InspectionOpLogItem
>
findByLogIdAndModuleNameAndDeleteFlag
(
Long
logId
,
String
moduleName
,
String
deleteFlag
);
/**
* 根据字段标识和删除标识查询明细列表
*
* @param fieldKey 字段标识
* @param deleteFlag 删除标识
* @return 明细列表
*/
List
<
InspectionOpLogItem
>
findByFieldKeyAndDeleteFlag
(
String
fieldKey
,
String
deleteFlag
);
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/InspectionOpLogRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
dao
;
import
com.glsx.usedcar.module.inspect.entity.InspectionOpLog
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
import
org.summerframework.orm.BaseRepository
;
import
java.util.List
;
/**
* 检测报告操作日志主表数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
InspectionOpLogRepository
extends
BaseRepository
<
InspectionOpLog
,
Long
>,
JpaSpecificationExecutor
<
InspectionOpLog
>
{
/**
* 根据检测记录ID和删除标识查询操作日志列表
*
* @param recordId 检测记录ID
* @param deleteFlag 删除标识
* @return 操作日志列表
*/
List
<
InspectionOpLog
>
findByRecordIdAndDeleteFlag
(
Long
recordId
,
String
deleteFlag
);
/**
* 根据任务ID和删除标识查询操作日志列表
*
* @param taskId 任务ID
* @param deleteFlag 删除标识
* @return 操作日志列表
*/
List
<
InspectionOpLog
>
findByTaskIdAndDeleteFlag
(
Long
taskId
,
String
deleteFlag
);
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/TemplateTagRelationRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
dao
;
import
com.glsx.usedcar.module.inspect.entity.TemplateTagRelation
;
import
com.glsx.usedcar.module.inspect.entity.TemplateTagRelation.TemplateTagRelationId
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* 模版标签关联数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
TemplateTagRelationRepository
extends
JpaRepository
<
TemplateTagRelation
,
TemplateTagRelationId
>
{
/**
* 根据模版ID查询标签关联列表
*
* @param templateId 模版ID
* @return 关联列表
*/
List
<
TemplateTagRelation
>
findByIdTemplateId
(
Long
templateId
);
/**
* 根据标签ID查询模版关联列表
*
* @param tagId 标签ID
* @return 关联列表
*/
List
<
TemplateTagRelation
>
findByIdTagId
(
Long
tagId
);
/**
* 根据模版ID删除所有关联
*
* @param templateId 模版ID
*/
@Modifying
@Query
(
"DELETE FROM TemplateTagRelation t WHERE t.id.templateId = :templateId"
)
void
deleteByTemplateId
(
@Param
(
"templateId"
)
Long
templateId
);
/**
* 根据模版ID和标签ID查询是否存在
*
* @param templateId 模版ID
* @param tagId 标签ID
* @return 是否存在
*/
boolean
existsByIdTemplateIdAndIdTagId
(
Long
templateId
,
Long
tagId
);
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/dao/TemplateTagRepository.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
dao
;
import
com.glsx.usedcar.module.inspect.entity.TemplateTag
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
org.summerframework.orm.BaseRepository
;
import
java.util.List
;
import
java.util.Optional
;
/**
* 模版标签数据访问层
*
* @author yangwei
* @since 2026/4/7
*/
@Repository
public
interface
TemplateTagRepository
extends
BaseRepository
<
TemplateTag
,
Long
>,
JpaSpecificationExecutor
<
TemplateTag
>
{
/**
* 根据标签编码和删除标识查询
*
* @param tagCode 标签编码
* @param deleteFlag 删除标识
* @return 标签信息
*/
Optional
<
TemplateTag
>
findByTagCodeAndDeleteFlag
(
String
tagCode
,
String
deleteFlag
);
/**
* 根据标签名称和删除标识查询
*
* @param tagName 标签名称
* @param deleteFlag 删除标识
* @return 标签列表
*/
List
<
TemplateTag
>
findByTagNameAndDeleteFlag
(
String
tagName
,
String
deleteFlag
);
/**
* 根据状态和删除标识查询列表
*
* @param status 状态
* @param deleteFlag 删除标识
* @return 标签列表
*/
List
<
TemplateTag
>
findByStatusAndDeleteFlag
(
Integer
status
,
String
deleteFlag
);
/**
* 根据标签类型和删除标识查询列表
*
* @param tagType 标签类型
* @param deleteFlag 删除标识
* @return 标签列表
*/
List
<
TemplateTag
>
findByTagTypeAndDeleteFlag
(
String
tagType
,
String
deleteFlag
);
/**
* 批量查询多个模版的标签,一次 JOIN 查询避免 N+1
* 返回结果包含 templateId 用于分组
*
* @param templateIds 模版ID列表
* @return [templateId, TemplateTag] 投影列表
*/
@Query
(
"SELECT r.id.templateId, t FROM TemplateTag t "
+
"JOIN TemplateTagRelation r ON r.id.tagId = t.tagId "
+
"WHERE r.id.templateId IN :templateIds "
+
"AND t.deleteFlag = 'N' "
+
"ORDER BY t.sortOrder ASC"
)
List
<
Object
[]>
findTagsByTemplateIds
(
@Param
(
"templateIds"
)
List
<
Long
>
templateIds
);
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/InspectionOpLog.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
entity
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 检测报告操作日志主表(InspectionOpLog)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"inspection_op_log"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
InspectionOpLog
extends
AuditingEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
6338051270559818393L
;
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
name
=
"LOG_ID"
,
unique
=
true
,
nullable
=
false
)
private
Long
logId
;
/**
* 关联 inspection_record.id
*/
@Column
(
name
=
"RECORD_ID"
,
nullable
=
false
)
private
Long
recordId
;
/**
* 冗余任务 ID
*/
@Column
(
name
=
"TASK_ID"
,
nullable
=
false
)
private
Long
taskId
;
/**
* 删除标识 N:未删除 D:已删除
*/
@Builder
.
Default
@Column
(
name
=
"DELETE_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deleteFlag
=
"N"
;
/**
* 备注
*/
@Column
(
name
=
"REMARK"
,
length
=
256
)
private
String
remark
;
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/InspectionOpLogItem.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
entity
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 检测报告操作日志明细表(InspectionOpLogItem)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"inspection_op_log_item"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
InspectionOpLogItem
extends
AuditingEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
7336807504388140418L
;
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
name
=
"LOG_ITEM_ID"
,
unique
=
true
,
nullable
=
false
)
private
Long
logItemId
;
/**
* 关联 inspection_op_log.id
*/
@Column
(
name
=
"LOG_ID"
,
nullable
=
false
)
private
Long
logId
;
/**
* 一级模块名称(快照),用于筛选
*/
@Column
(
name
=
"MODULE_NAME"
,
nullable
=
false
,
length
=
100
)
private
String
moduleName
;
/**
* 二级模块名称(快照),用于前端分组
*/
@Column
(
name
=
"SUB_MODULE_NAME"
,
length
=
100
)
private
String
subModuleName
;
/**
* 三级模块名称(快照)
*/
@Column
(
name
=
"TRI_MODULE_NAME"
,
nullable
=
false
,
length
=
100
)
private
String
triModuleName
;
/**
* 完整路径快照,如:外观骨架检测-车头检查-前风挡
*/
@Column
(
name
=
"FIELD_LABEL"
,
nullable
=
false
,
length
=
500
)
private
String
fieldLabel
;
/**
* 字段标识(node_id 或字段英文名)
*/
@Column
(
name
=
"FIELD_KEY"
,
length
=
100
)
private
String
fieldKey
;
/**
* 交互类型快照
*/
@Column
(
name
=
"INTERACTION_TYPE"
,
length
=
32
)
private
String
interactionType
;
/**
* 修改前内容(格式化文本)
*/
@Column
(
name
=
"BEFORE_VALUE"
,
columnDefinition
=
"TEXT"
)
private
String
beforeValue
;
/**
* 修改后内容(格式化文本)
*/
@Column
(
name
=
"AFTER_VALUE"
,
columnDefinition
=
"TEXT"
)
private
String
afterValue
;
/**
* 同一批次内展示顺序
*/
@Builder
.
Default
@Column
(
name
=
"SORT_SEQ"
,
nullable
=
false
)
private
Integer
sortSeq
=
0
;
/**
* 删除标识 N:未删除 D:已删除
*/
@Builder
.
Default
@Column
(
name
=
"DELETE_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deleteFlag
=
"N"
;
/**
* 备注
*/
@Column
(
name
=
"REMARK"
,
length
=
256
)
private
String
remark
;
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/InspectionTemplate.java
View file @
add328f
...
@@ -9,6 +9,8 @@ import org.summerframework.orm.entity.AuditingEntity;
...
@@ -9,6 +9,8 @@ import org.summerframework.orm.entity.AuditingEntity;
import
java.io.Serial
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
...
@@ -91,4 +93,11 @@ public class InspectionTemplate extends AuditingEntity implements Serializable {
...
@@ -91,4 +93,11 @@ public class InspectionTemplate extends AuditingEntity implements Serializable {
@Builder
.
Default
@Builder
.
Default
@Column
(
name
=
"DELETED_FLAG"
,
nullable
=
false
,
length
=
1
)
@Column
(
name
=
"DELETED_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deletedFlag
=
"N"
;
private
String
deletedFlag
=
"N"
;
/**
* 模版标签关系
*/
@ManyToMany
(
targetEntity
=
TemplateTag
.
class
,
cascade
=
{
CascadeType
.
MERGE
,
CascadeType
.
PERSIST
},
fetch
=
FetchType
.
LAZY
)
@JoinTable
(
name
=
"template_tag_relation"
,
joinColumns
=
{
@JoinColumn
(
name
=
"TEMPLATE_ID"
,
nullable
=
false
)},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"TAG_ID"
,
nullable
=
false
)})
private
List
<
TemplateTag
>
templateTags
=
new
ArrayList
<>();
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/TemplateTag.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
entity
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.HashSet
;
import
java.util.Set
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 模版标签(TemplateTag)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"template_tag"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
TemplateTag
extends
AuditingEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
6266796218047003775L
;
/**
* 主键ID
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
name
=
"TAG_ID"
,
unique
=
true
,
nullable
=
false
)
private
Long
tagId
;
/**
* 标签编码
*/
@Column
(
name
=
"TAG_CODE"
,
nullable
=
false
,
length
=
64
)
private
String
tagCode
;
/**
* 标签名称
*/
@Column
(
name
=
"TAG_NAME"
,
nullable
=
false
,
length
=
128
)
private
String
tagName
;
/**
* 标签类型
*/
@Column
(
name
=
"TAG_TYPE"
,
length
=
32
)
private
String
tagType
;
/**
* 标签描述
*/
@Column
(
name
=
"DESCRIPTION"
,
length
=
512
)
private
String
description
;
/**
* 排序顺序
*/
@Builder
.
Default
@Column
(
name
=
"SORT_ORDER"
)
private
Integer
sortOrder
=
0
;
/**
* 状态 1:启用 0:禁用
*/
@Builder
.
Default
@Column
(
name
=
"STATUS"
,
nullable
=
false
)
private
Integer
status
=
1
;
/**
* 删除标识 N:未删除 D:已删除
*/
@Builder
.
Default
@Column
(
name
=
"DELETE_FLAG"
,
nullable
=
false
,
length
=
1
)
private
String
deleteFlag
=
"N"
;
/**
* 备注
*/
@Column
(
name
=
"REMARK"
,
length
=
512
)
private
String
remark
;
@ManyToMany
(
fetch
=
FetchType
.
LAZY
,
targetEntity
=
InspectionTemplate
.
class
,
mappedBy
=
"templateTags"
,
cascade
=
{})
private
Set
<
InspectionTemplate
>
inspectionTemplates
=
new
HashSet
<>(
0
);
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/entity/TemplateTagRelation.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
entity
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
java.io.Serial
;
import
java.io.Serializable
;
/**
* 模版标签关联(TemplateTagRelation)实体类
*
* @author yangwei
* @since 2026/4/7
*/
@Entity
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"template_tag_relation"
)
public
class
TemplateTagRelation
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
3725492187687731721L
;
/**
* 联合主键
*/
@EmbeddedId
private
TemplateTagRelationId
id
;
/**
* 联合主键类
*/
@Embeddable
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public
static
class
TemplateTagRelationId
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
/**
* 模版ID
*/
@Column
(
name
=
"TEMPLATE_ID"
,
nullable
=
false
)
private
Long
templateId
;
/**
* 标签ID
*/
@Column
(
name
=
"TAG_ID"
,
nullable
=
false
)
private
Long
tagId
;
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionNodeService.java
View file @
add328f
...
@@ -233,7 +233,7 @@ public class InspectionNodeService {
...
@@ -233,7 +233,7 @@ public class InspectionNodeService {
* @param all 所有节点
* @param all 所有节点
* @return 子节点列表,按 sortOrder 升序
* @return 子节点列表,按 sortOrder 升序
*/
*/
public
List
<
InspectionNodeVO
>
getChildNodes
(
Long
rootNodeId
,
List
<
InspectionNodeVO
>
all
)
{
public
static
List
<
InspectionNodeVO
>
getChildNodes
(
Long
rootNodeId
,
List
<
InspectionNodeVO
>
all
)
{
return
all
.
stream
()
return
all
.
stream
()
.
filter
(
node
->
ObjectUtil
.
isNotNull
(
node
.
getParentId
())
&&
node
.
getParentId
().
equals
(
rootNodeId
))
.
filter
(
node
->
ObjectUtil
.
isNotNull
(
node
.
getParentId
())
&&
node
.
getParentId
().
equals
(
rootNodeId
))
.
peek
(
node
->
node
.
setChildrenNodes
(
getChildNodes
(
node
.
getId
(),
all
)))
.
peek
(
node
->
node
.
setChildrenNodes
(
getChildNodes
(
node
.
getId
(),
all
)))
...
...
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionRecordService.java
View file @
add328f
This diff is collapsed.
Click to expand it.
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionTemplateService.java
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
service
;
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
service
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.glsx.usedcar.consts.common.SymbolConsts
;
import
com.glsx.usedcar.consts.inspect.InspectConstants
;
import
com.glsx.usedcar.consts.inspect.JpaQueryConstants
;
import
com.glsx.usedcar.converts.InspectionTemplateConverter
;
import
com.glsx.usedcar.converts.InspectionTemplateConverter
;
import
com.glsx.usedcar.converts.InspectorConverter
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.module.inspect.dao.InspectionNodeRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionTemplateHistoryRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionTemplateHistoryRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionTemplateRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionTemplateRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderRepository
;
import
com.glsx.usedcar.module.inspect.dao.TemplateTagRepository
;
import
com.glsx.usedcar.module.inspect.dto.InspectionTemplateDTO
;
import
com.glsx.usedcar.module.inspect.dto.InspectionTemplateDTO
;
import
com.glsx.usedcar.module.inspect.entity.InspectionNode
;
import
com.glsx.usedcar.module.inspect.entity.InspectionTemplate
;
import
com.glsx.usedcar.module.inspect.entity.InspectionTemplate_
;
import
com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder
;
import
com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder
;
import
com.glsx.usedcar.module.inspect.entity.TemplateTag
;
import
com.glsx.usedcar.factories.inspect.InspectionValueStrategyRouter
;
import
com.glsx.usedcar.factories.inspect.InspectionValueStrategyRouter
;
import
com.glsx.usedcar.module.inspect.service.strategy.TemplateValueStrategy
;
import
com.glsx.usedcar.module.inspect.service.strategy.TemplateValueStrategy
;
import
com.glsx.usedcar.module.inspect.vo.InspectionNodeVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDefaultValueReqVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDefaultValueReqVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateDetailRespVO
;
import
com.glsx.usedcar.module.inspect.vo.InspectionTemplateRespVO
;
import
com.glsx.usedcar.module.inspect.vo.TemplateTagVO
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
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.util.HashMap
;
import
org.summerframework.orm.paging.Pagination
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* 检测模版服务
* 检测模版服务
...
@@ -35,6 +53,9 @@ import java.util.Optional;
...
@@ -35,6 +53,9 @@ import java.util.Optional;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
public
class
InspectionTemplateService
{
public
class
InspectionTemplateService
{
private
final
InspectorConverter
inspectorConverter
;
private
final
TemplateTagRepository
templateTagRepository
;
private
final
InspectionNodeRepository
inspectionNodeRepository
;
private
final
InspectionValueStrategyRouter
defaultValueStrategyRouter
;
private
final
InspectionValueStrategyRouter
defaultValueStrategyRouter
;
private
final
InspectionTemplateConverter
inspectionTemplateConverter
;
private
final
InspectionTemplateConverter
inspectionTemplateConverter
;
private
final
InspectionTemplateRepository
inspectionTemplateRepository
;
private
final
InspectionTemplateRepository
inspectionTemplateRepository
;
...
@@ -115,4 +136,109 @@ public class InspectionTemplateService {
...
@@ -115,4 +136,109 @@ public class InspectionTemplateService {
return
defaultValueMap
;
return
defaultValueMap
;
}
}
/**
* 分页查询检测模版列表(返回基本信息)
*
* @param pagination 分页参数,支持关键词模糊查询(模版名称、模版编码)
* @return 模版基本信息分页结果
*/
public
Page
<
InspectionTemplateRespVO
>
pageList
(
Pagination
<
InspectionTemplate
>
pagination
)
{
Object
keyword
=
pagination
.
getFilterValueOrElseNull
(
JpaQueryConstants
.
KEYWORD
);
if
(
keyword
instanceof
String
kw
&&
StrUtil
.
isNotBlank
(
kw
))
{
pagination
.
removeFilter
(
JpaQueryConstants
.
KEYWORD
);
String
like
=
SymbolConsts
.
PERCENT
+
kw
.
trim
()
+
SymbolConsts
.
PERCENT
;
pagination
.
addCondition
((
root
,
query
,
cb
)
->
cb
.
or
(
cb
.
like
(
root
.
get
(
InspectionTemplate_
.
templateName
),
like
),
cb
.
like
(
root
.
get
(
InspectionTemplate_
.
templateCode
),
like
)
));
}
pagination
.
addCondition
((
root
,
query
,
cb
)
->
cb
.
equal
(
root
.
get
(
InspectionTemplate_
.
deletedFlag
),
DeleteFlag
.
NOT_DELETED
.
getCode
()));
// 第1条 SQL:分页查模版
Page
<
InspectionTemplate
>
page
=
inspectionTemplateRepository
.
findAll
(
pagination
,
pagination
.
getPageRequest
());
List
<
InspectionTemplate
>
templates
=
page
.
getContent
();
if
(
templates
.
isEmpty
())
{
return
new
PageImpl
<>(
List
.
of
(),
page
.
getPageable
(),
page
.
getTotalElements
());
}
// 第2条 SQL:批量查所有模版的标签,避免 N+1
List
<
Long
>
templateIds
=
templates
.
stream
().
map
(
InspectionTemplate:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Object
[]>
tagRows
=
templateTagRepository
.
findTagsByTemplateIds
(
templateIds
);
// 内存分组:templateId -> List<TemplateTagVO>
Map
<
Long
,
List
<
TemplateTagVO
>>
tagMap
=
tagRows
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
row
->
(
Long
)
row
[
0
],
Collectors
.
mapping
(
row
->
{
TemplateTag
tag
=
(
TemplateTag
)
row
[
1
];
return
TemplateTagVO
.
builder
()
.
tagId
(
tag
.
getTagId
())
.
tagCode
(
tag
.
getTagCode
())
.
tagName
(
tag
.
getTagName
())
.
tagType
(
tag
.
getTagType
())
.
sortOrder
(
tag
.
getSortOrder
())
.
build
();
},
Collectors
.
toList
())
));
List
<
InspectionTemplateRespVO
>
content
=
templates
.
stream
()
.
map
(
t
->
InspectionTemplateRespVO
.
builder
()
.
id
(
t
.
getId
())
.
templateCode
(
t
.
getTemplateCode
())
.
templateName
(
t
.
getTemplateName
())
.
templateType
(
t
.
getTemplateType
())
.
status
(
t
.
getStatus
())
.
version
(
t
.
getVersion
())
.
description
(
t
.
getDescription
())
.
createTime
(
t
.
getCreateTime
())
.
updateTime
(
t
.
getUpdateTime
())
.
templateTags
(
tagMap
.
getOrDefault
(
t
.
getId
(),
List
.
of
()))
.
build
())
.
collect
(
Collectors
.
toList
());
return
new
PageImpl
<>(
content
,
page
.
getPageable
(),
page
.
getTotalElements
());
}
/**
* 查询检测模版详情(基本信息 + 节点配置树)
*
* @param id 模版ID
* @return 模版详情(含节点树,不填充检测数据)
*/
public
InspectionTemplateDetailRespVO
detail
(
Long
id
)
{
InspectionTemplate
template
=
inspectionTemplateRepository
.
findByIdAndDeletedFlag
(
id
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
String
.
format
(
"检测模版不存在,ID: %s"
,
id
)));
List
<
InspectionNode
>
nodes
=
inspectionNodeRepository
.
findByTemplateIdAndDeletedFlagOrderBySortOrderAsc
(
id
,
DeleteFlag
.
NOT_DELETED
.
getCode
());
List
<
InspectionNodeVO
>
allNodes
=
inspectorConverter
.
inspectionNodesMapRespVO
(
nodes
);
// 构建树形结构:先取根节点(parentId == 0),再递归挂载子节点
List
<
InspectionNodeVO
>
rootNodes
=
allNodes
.
stream
()
.
filter
(
node
->
ObjectUtil
.
isNotNull
(
node
.
getParentId
())
&&
node
.
getParentId
()
==
0L
)
.
peek
(
node
->
node
.
setChildrenNodes
(
InspectionNodeService
.
getChildNodes
(
node
.
getId
(),
allNodes
)))
.
sorted
(
Comparator
.
comparingInt
(
InspectionNodeVO:
:
getSortOrder
))
.
toList
();
return
InspectionTemplateDetailRespVO
.
builder
()
.
id
(
template
.
getId
())
.
templateCode
(
template
.
getTemplateCode
())
.
templateName
(
template
.
getTemplateName
())
.
templateType
(
template
.
getTemplateType
())
.
status
(
template
.
getStatus
())
.
version
(
template
.
getVersion
())
.
description
(
template
.
getDescription
())
.
configJson
(
template
.
getConfigJson
())
.
createTime
(
template
.
getCreateTime
())
.
updateTime
(
template
.
getUpdateTime
())
.
nodes
(
rootNodes
)
.
build
();
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/CompleteInspectionRespVO.java
View file @
add328f
...
@@ -25,9 +25,21 @@ public class CompleteInspectionRespVO implements Serializable {
...
@@ -25,9 +25,21 @@ public class CompleteInspectionRespVO implements Serializable {
@Serial
@Serial
private
static
final
long
serialVersionUID
=
340028291116019642L
;
private
static
final
long
serialVersionUID
=
340028291116019642L
;
@Schema
(
description
=
"第一个未完成的一级
检测项id
"
)
@Schema
(
description
=
"第一个未完成的一级
节点ID
"
)
private
Long
firstUncompletedNodeId
;
private
Long
firstUncompleted
Lv1
NodeId
;
@Schema
(
description
=
"第一个未完成的一级检测项名称"
)
@Schema
(
description
=
"第一个未完成的一级节点名称"
)
private
String
firstUncompletedNodeName
;
private
String
firstUncompletedLv1NodeName
;
@Schema
(
description
=
"第一个未完成的二级节点ID(一级下有二级时填充)"
)
private
Long
firstUncompletedLv2NodeId
;
@Schema
(
description
=
"第一个未完成的二级节点名称(一级下有二级时填充)"
)
private
String
firstUncompletedLv2NodeName
;
@Schema
(
description
=
"第一个未完成的三级节点ID(二级下有三级时填充)"
)
private
Long
firstUncompletedLv3NodeId
;
@Schema
(
description
=
"第一个未完成的三级节点名称(二级下有三级时填充)"
)
private
String
firstUncompletedLv3NodeName
;
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionTemplateDetailRespVO.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* 检测模版详情响应 VO(含节点树)
*
* @author yangwei
* @version 1.0
* @since 2026/04/07
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"检测模版详情响应 VO(含节点树)"
)
public
class
InspectionTemplateDetailRespVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
/**
* 模版ID
*/
@Schema
(
description
=
"模版ID"
)
private
Long
id
;
/**
* 模版编码
*/
@Schema
(
description
=
"模版编码"
)
private
String
templateCode
;
/**
* 模版名称
*/
@Schema
(
description
=
"模版名称"
)
private
String
templateName
;
/**
* 模版类型:1-燃油车,2-新能源车
*/
@Schema
(
description
=
"模版类型:1-燃油车,2-新能源车"
)
private
Integer
templateType
;
/**
* 状态:0-草稿,1-已发布,2-已禁用
*/
@Schema
(
description
=
"状态:0-草稿,1-已发布,2-已禁用"
)
private
Integer
status
;
/**
* 当前版本号
*/
@Schema
(
description
=
"当前版本号"
)
private
String
version
;
/**
* 模版描述
*/
@Schema
(
description
=
"模版描述"
)
private
String
description
;
/**
* 模版扩展配置(JSON格式文本)
*/
@Schema
(
description
=
"模版扩展配置(JSON格式文本)"
)
private
String
configJson
;
/**
* 创建时间
*/
@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
;
/**
* 模版节点树(根节点列表,每个根节点含子节点)
*/
@Schema
(
description
=
"模版节点树(根节点列表,每个根节点含子节点)"
)
private
List
<
InspectionNodeVO
>
nodes
;
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionTemplateRespVO.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* 检测模版列表查询响应 VO
*
* @author yangwei
* @version 1.0
* @since 2026/04/07
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"检测模版列表查询响应 VO"
)
public
class
InspectionTemplateRespVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
/**
* 模版ID
*/
@Schema
(
description
=
"模版ID"
)
private
Long
id
;
/**
* 模版编码
*/
@Schema
(
description
=
"模版编码"
)
private
String
templateCode
;
/**
* 模版名称
*/
@Schema
(
description
=
"模版名称"
)
private
String
templateName
;
/**
* 模版类型:1-燃油车,2-新能源车
*/
@Schema
(
description
=
"模版类型:1-燃油车,2-新能源车"
)
private
Integer
templateType
;
/**
* 状态:0-草稿,1-已发布,2-已禁用
*/
@Schema
(
description
=
"状态:0-草稿,1-已发布,2-已禁用"
)
private
Integer
status
;
/**
* 当前版本号
*/
@Schema
(
description
=
"当前版本号"
)
private
String
version
;
/**
* 模版描述
*/
@Schema
(
description
=
"模版描述"
)
private
String
description
;
/**
* 创建时间
*/
@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
;
/**
* 模版标签列表
*/
@Schema
(
description
=
"模版标签列表"
)
private
List
<
TemplateTagVO
>
templateTags
;
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/TemplateTagVO.java
0 → 100644
View file @
add328f
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serial
;
import
java.io.Serializable
;
/**
* 模版标签响应 VO
*
* @author yangwei
* @version 1.0
* @since 2026/04/07
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"模版标签响应 VO"
)
public
class
TemplateTagVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
/**
* 标签ID
*/
@Schema
(
description
=
"标签ID"
)
private
Long
tagId
;
/**
* 标签编码
*/
@Schema
(
description
=
"标签编码"
)
private
String
tagCode
;
/**
* 标签名称
*/
@Schema
(
description
=
"标签名称"
)
private
String
tagName
;
/**
* 标签类型
*/
@Schema
(
description
=
"标签类型"
)
private
String
tagType
;
/**
* 排序顺序
*/
@Schema
(
description
=
"排序顺序"
)
private
Integer
sortOrder
;
}
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