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 affff088
authored
Mar 20, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:检测工单 绑定改为批量绑定,解绑也是
1 parent
c17f48a5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
35 deletions
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionReportController.java
aus-core/src/main/java/com/glsx/usedcar/consts/inspect/JpaQueryConstants.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionReportService.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionWorkOrderService.java
aus-core/src/main/java/com/glsx/usedcar/req/CommonLongIdListReq.java
aus-core/src/main/java/com/glsx/usedcar/req/CommonLongIdReq.java
aus-framework/src/main/java/org/summerframework/core/enums/ErrorCodeEnum.java
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionWorkOrderController.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionReportController.java
View file @
affff08
...
@@ -9,6 +9,7 @@ import com.glsx.usedcar.module.inspect.entity.InspectionReport;
...
@@ -9,6 +9,7 @@ import com.glsx.usedcar.module.inspect.entity.InspectionReport;
import
com.glsx.usedcar.module.inspect.service.InspectionReportService
;
import
com.glsx.usedcar.module.inspect.service.InspectionReportService
;
import
com.glsx.usedcar.module.inspect.vo.*
;
import
com.glsx.usedcar.module.inspect.vo.*
;
import
com.glsx.usedcar.module.security.entity.User
;
import
com.glsx.usedcar.module.security.entity.User
;
import
com.glsx.usedcar.req.CommonLongIdListReq
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameter
;
...
@@ -86,14 +87,14 @@ public class InspectionReportController {
...
@@ -86,14 +87,14 @@ public class InspectionReportController {
}
}
@Operation
(
summary
=
"检测报告绑定"
,
description
=
"绑定报告到车辆(同一车辆仅允许绑定一个报告)"
)
@Operation
(
summary
=
"检测报告绑定"
,
description
=
"绑定报告到车辆(同一车辆仅允许绑定一个报告)"
)
@
GetMapping
(
"/bind/{id}
"
)
@
PostMapping
(
"/bind
"
)
public
BaseResp
<
Void
>
bind
(
public
BaseResp
<
Void
>
bind
(
@
Parameter
(
description
=
"检测报告ID"
,
required
=
true
)
@PathVariable
(
"id"
)
Long
id
,
@
Valid
@RequestBody
CommonLongIdListReq
req
,
Authentication
authentication
)
{
Authentication
authentication
)
{
log
.
info
(
"【接口请求】检测报告绑定,操作人={},报告ID={}"
,
getUserName
(
authentication
),
id
);
log
.
info
(
"【接口请求】检测报告绑定,操作人={},报告ID={}"
,
getUserName
(
authentication
),
req
.
getIdList
()
);
try
{
try
{
User
user
=
(
User
)
authentication
.
getPrincipal
();
User
user
=
(
User
)
authentication
.
getPrincipal
();
inspectionReportService
.
bindInspectionReport
(
id
,
(
long
)
user
.
getUserId
(),
user
.
getUserName
(),
InspectionPlatTypeEnum
.
BACKEND
.
getCode
());
inspectionReportService
.
bindInspectionReport
(
req
.
getIdList
()
,
(
long
)
user
.
getUserId
(),
user
.
getUserName
(),
InspectionPlatTypeEnum
.
BACKEND
.
getCode
());
return
BaseResp
.
success
();
return
BaseResp
.
success
();
}
catch
(
BusinessCodeException
be
)
{
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】检测报告绑定失败!操作人={},业务异常!"
,
getUserName
(
authentication
),
be
);
log
.
error
(
"【接口响应】检测报告绑定失败!操作人={},业务异常!"
,
getUserName
(
authentication
),
be
);
...
@@ -105,14 +106,14 @@ public class InspectionReportController {
...
@@ -105,14 +106,14 @@ public class InspectionReportController {
}
}
@Operation
(
summary
=
"检测报告解绑"
,
description
=
"解除报告与车辆的绑定关系"
)
@Operation
(
summary
=
"检测报告解绑"
,
description
=
"解除报告与车辆的绑定关系"
)
@
GetMapping
(
"/unbind/{id}
"
)
@
PostMapping
(
"/unbind
"
)
public
BaseResp
<
Void
>
unbind
(
public
BaseResp
<
Void
>
unbind
(
@
Parameter
(
description
=
"检测报告ID"
,
required
=
true
)
@PathVariable
(
"id"
)
Long
id
,
@
Valid
@RequestBody
CommonLongIdListReq
req
,
Authentication
authentication
)
{
Authentication
authentication
)
{
log
.
info
(
"【接口请求】检测报告解绑,操作人={},报告ID={}"
,
getUserName
(
authentication
),
id
);
log
.
info
(
"【接口请求】检测报告解绑,操作人={},报告ID={}"
,
getUserName
(
authentication
),
req
.
getIdList
()
);
try
{
try
{
User
user
=
(
User
)
authentication
.
getPrincipal
();
User
user
=
(
User
)
authentication
.
getPrincipal
();
inspectionReportService
.
unbindInspectionReport
(
id
,
(
long
)
user
.
getUserId
(),
user
.
getUserName
(),
InspectionPlatTypeEnum
.
BACKEND
.
getCode
());
inspectionReportService
.
unbindInspectionReport
(
req
.
getIdList
()
,
(
long
)
user
.
getUserId
(),
user
.
getUserName
(),
InspectionPlatTypeEnum
.
BACKEND
.
getCode
());
return
BaseResp
.
success
();
return
BaseResp
.
success
();
}
catch
(
BusinessCodeException
be
)
{
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】检测报告解绑失败!操作人={},业务异常!"
,
getUserName
(
authentication
),
be
);
log
.
error
(
"【接口响应】检测报告解绑失败!操作人={},业务异常!"
,
getUserName
(
authentication
),
be
);
...
...
aus-core/src/main/java/com/glsx/usedcar/consts/inspect/JpaQueryConstants.java
View file @
affff08
...
@@ -53,9 +53,13 @@ public interface JpaQueryConstants {
...
@@ -53,9 +53,13 @@ public interface JpaQueryConstants {
* 关键字,检测师名称或手机号,模糊查询
* 关键字,检测师名称或手机号,模糊查询
*/
*/
String
KEYWORD
=
"keyword"
;
String
KEYWORD
=
"keyword"
;
/**
* 关键字,检测师名称或手机号,模糊查询
*/
String
INSPECTOR_ID
=
"inspectorId"
;
/**
/**
*
账号状态,
精确匹配
* 精确匹配
*/
*/
String
STATUS
=
"status"
;
String
STATUS
=
"status"
;
...
...
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionReportService.java
View file @
affff08
...
@@ -269,30 +269,33 @@ public class InspectionReportService {
...
@@ -269,30 +269,33 @@ public class InspectionReportService {
* 绑定检测报告(接收操作人参数,核心规则:同一车辆仅绑定一个报告)
* 绑定检测报告(接收操作人参数,核心规则:同一车辆仅绑定一个报告)
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
bindInspectionReport
(
Long
id
,
Long
operatorId
,
String
operatorName
,
Integer
platType
)
{
public
void
bindInspectionReport
(
List
<
Long
>
idList
,
Long
operatorId
,
String
operatorName
,
Integer
platType
)
{
log
.
info
(
"【报告绑定】操作人={},开始处理,报告ID={}"
,
operatorName
,
id
);
List
<
String
>
bindSourceNoList
=
new
ArrayList
<>();
for
(
Long
id
:
idList
)
{
// 1. 查找报告并校验
// 1. 查找报告并校验
InspectionReport
report
=
inspectionReportRepository
.
findById
(
id
)
InspectionReport
report
=
inspectionReportRepository
.
findById
(
id
)
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
"检测报告不存在,ID:"
+
id
));
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
"检测报告不存在,ID:"
+
id
));
// 已绑定则直接返回
// 已绑定则直接返回
if
(
Objects
.
equals
(
report
.
getBindStatus
(),
1
))
{
if
(
Objects
.
equals
(
report
.
getBindStatus
(),
1
))
{
log
.
info
(
"【报告绑定】操作人={},报告已绑定,无需重复操作,报告编号={}"
,
operatorName
,
report
.
getReportNo
());
log
.
info
(
"【报告绑定】操作人={},报告已绑定,无需重复操作,报告编号={}"
,
operatorName
,
report
.
getReportNo
());
return
;
continue
;
}
// 2. 检查该车辆是否已绑定其他报告
Vehicle
vehicle
=
report
.
getVehicle
();
List
<
InspectionReport
>
bindedReports
=
inspectionReportRepository
.
findByVehicleAndBindStatusAndDeleteFlag
(
vehicle
,
1
,
DeleteFlag
.
NOT_DELETED
.
getCode
());
if
(!
bindedReports
.
isEmpty
())
{
bindSourceNoList
.
add
(
vehicle
.
getBaseInfo
().
getSourceNo
());
continue
;
}
bindInspectionReport
(
report
,
vehicle
,
operatorId
,
operatorName
,
platType
);
}
}
if
(!
bindSourceNoList
.
isEmpty
())
{
// 2. 检查该车辆是否已绑定其他报告
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
VEHICLE_ALREADY_BIND
,
String
.
join
(
","
,
bindSourceNoList
));
Vehicle
vehicle
=
report
.
getVehicle
();
List
<
InspectionReport
>
bindedReports
=
inspectionReportRepository
.
findByVehicleAndBindStatusAndDeleteFlag
(
vehicle
,
1
,
DeleteFlag
.
NOT_DELETED
.
getCode
()
);
if
(!
bindedReports
.
isEmpty
())
{
String
bindedReportNos
=
bindedReports
.
stream
().
map
(
InspectionReport:
:
getReportNo
).
reduce
((
a
,
b
)
->
a
+
","
+
b
).
get
();
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
OPERATION_ERROR
,
String
.
format
(
"该车辆已绑定其他检测报告(报告编号:%s),不允许重复绑定"
,
bindedReportNos
));
}
}
}
private
void
bindInspectionReport
(
InspectionReport
report
,
Vehicle
vehicle
,
Long
operatorId
,
String
operatorName
,
Integer
platType
)
{
log
.
info
(
"【报告绑定】操作人={},开始处理,报告ID={}"
,
operatorName
,
report
.
getId
());
// 3. 保存绑定前的原始数据
// 3. 保存绑定前的原始数据
String
originalData
=
""
;
String
originalData
=
""
;
try
{
try
{
...
@@ -325,7 +328,12 @@ public class InspectionReportService {
...
@@ -325,7 +328,12 @@ public class InspectionReportService {
* 解绑检测报告(接收操作人参数)
* 解绑检测报告(接收操作人参数)
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
unbindInspectionReport
(
Long
id
,
Long
operatorId
,
String
operatorName
,
Integer
platType
)
{
public
void
unbindInspectionReport
(
List
<
Long
>
idList
,
Long
operatorId
,
String
operatorName
,
Integer
platType
)
{
idList
.
forEach
(
reportId
->
{
unbindInspectionReport
(
reportId
,
operatorId
,
operatorName
,
platType
);
});
}
private
void
unbindInspectionReport
(
Long
id
,
Long
operatorId
,
String
operatorName
,
Integer
platType
)
{
log
.
info
(
"【报告解绑】操作人={},开始处理,报告ID={}"
,
operatorName
,
id
);
log
.
info
(
"【报告解绑】操作人={},开始处理,报告ID={}"
,
operatorName
,
id
);
// 1. 查找报告并校验
// 1. 查找报告并校验
...
...
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionWorkOrderService.java
View file @
affff08
...
@@ -281,9 +281,9 @@ public class InspectionWorkOrderService {
...
@@ -281,9 +281,9 @@ public class InspectionWorkOrderService {
}
}
public
Page
<
InspectionWORespVO
>
pageList
(
Pagination
<
InspectionWorkOrder
>
pagination
)
{
public
Page
<
InspectionWORespVO
>
pageList
(
Pagination
<
InspectionWorkOrder
>
pagination
)
{
Object
keyword
=
pagination
.
getFilterValueOrElseNull
(
JpaQueryConstants
.
Inspect
o
r
.
KEYWORD
);
Object
keyword
=
pagination
.
getFilterValueOrElseNull
(
JpaQueryConstants
.
Inspect
ionWorkOrde
r
.
KEYWORD
);
if
(
keyword
instanceof
String
kw
&&
StrUtil
.
isNotBlank
(
kw
))
{
if
(
keyword
instanceof
String
kw
&&
StrUtil
.
isNotBlank
(
kw
))
{
pagination
.
removeFilter
(
JpaQueryConstants
.
Inspect
o
r
.
KEYWORD
);
pagination
.
removeFilter
(
JpaQueryConstants
.
Inspect
ionWorkOrde
r
.
KEYWORD
);
String
likePattern
=
SymbolConsts
.
PERCENT
+
kw
+
SymbolConsts
.
PERCENT
;
String
likePattern
=
SymbolConsts
.
PERCENT
+
kw
+
SymbolConsts
.
PERCENT
;
pagination
.
addCondition
((
root
,
query
,
builder
)
->
builder
.
or
(
pagination
.
addCondition
((
root
,
query
,
builder
)
->
builder
.
or
(
// 工单表:woId
// 工单表:woId
...
@@ -295,6 +295,11 @@ public class InspectionWorkOrderService {
...
@@ -295,6 +295,11 @@ public class InspectionWorkOrderService {
// 车辆表:baseInfo.vin
// 车辆表:baseInfo.vin
builder
.
like
(
root
.
get
(
InspectionWorkOrder_
.
vehicle
).
get
(
Vehicle_
.
baseInfo
).
get
(
BaseInfo_
.
vin
),
likePattern
)));
builder
.
like
(
root
.
get
(
InspectionWorkOrder_
.
vehicle
).
get
(
Vehicle_
.
baseInfo
).
get
(
BaseInfo_
.
vin
),
likePattern
)));
}
}
Object
inspectorId
=
pagination
.
getFilterValueOrElseNull
(
JpaQueryConstants
.
InspectionWorkOrder
.
INSPECTOR_ID
);
if
(
inspectorId
!=
null
)
{
pagination
.
removeFilter
(
JpaQueryConstants
.
InspectionWorkOrder
.
INSPECTOR_ID
);
pagination
.
addCondition
((
root
,
query
,
builder
)
->
builder
.
equal
(
root
.
get
(
InspectionWorkOrder_
.
inspector
).
get
(
Inspector_
.
id
),
inspectorId
));
}
Page
<
InspectionWorkOrder
>
resultPage
=
inspectionWorkOrderRepository
.
findAll
(
pagination
,
pagination
.
getPageRequest
());
Page
<
InspectionWorkOrder
>
resultPage
=
inspectionWorkOrderRepository
.
findAll
(
pagination
,
pagination
.
getPageRequest
());
return
resultPage
.
map
(
inspectionWorkOrderConverter:
:
inspectorMapRespVO
);
return
resultPage
.
map
(
inspectionWorkOrderConverter:
:
inspectorMapRespVO
);
}
}
...
...
aus-core/src/main/java/com/glsx/usedcar/req/CommonLongIdListReq.java
0 → 100644
View file @
affff08
package
com
.
glsx
.
usedcar
.
req
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.Size
;
import
lombok.Data
;
import
java.util.List
;
/**
* 通用的id列表请求参数
*/
@Data
public
class
CommonLongIdListReq
{
@Size
(
min
=
1
)
@Schema
(
description
=
"id列表"
,
example
=
"[1,2,3]"
)
private
List
<
Long
>
idList
;
}
aus-core/src/main/java/com/glsx/usedcar/req/CommonLongIdReq.java
0 → 100644
View file @
affff08
package
com
.
glsx
.
usedcar
.
req
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
/**
* 通用的id列表请求参数
*/
@Data
public
class
CommonLongIdReq
{
@Schema
(
description
=
"id"
,
example
=
"3"
)
private
Long
id
;
}
aus-framework/src/main/java/org/summerframework/core/enums/ErrorCodeEnum.java
View file @
affff08
...
@@ -33,6 +33,7 @@ public enum ErrorCodeEnum {
...
@@ -33,6 +33,7 @@ public enum ErrorCodeEnum {
VEHICLE_ALREADY_INSPECTED
(
1001006
,
"车辆已经创建检测工单"
),
VEHICLE_ALREADY_INSPECTED
(
1001006
,
"车辆已经创建检测工单"
),
OPERATION_ERROR
(
1001007
,
"已绑定的检测报告不允许删除"
),
OPERATION_ERROR
(
1001007
,
"已绑定的检测报告不允许删除"
),
DATA_NOT_FOUND
(
1001008
,
"{0}"
),
DATA_NOT_FOUND
(
1001008
,
"{0}"
),
VEHICLE_ALREADY_BIND
(
1001009
,
"{0}"
),
/* 检测模版 */
/* 检测模版 */
...
...
aus-inspector/src/main/java/com/glsx/usedcar/controller/InspectionWorkOrderController.java
View file @
affff08
...
@@ -48,7 +48,8 @@ public class InspectionWorkOrderController {
...
@@ -48,7 +48,8 @@ public class InspectionWorkOrderController {
int
page
=
req
.
getPage
()
==
null
||
req
.
getPage
()
<
1
?
1
:
req
.
getPage
();
int
page
=
req
.
getPage
()
==
null
||
req
.
getPage
()
<
1
?
1
:
req
.
getPage
();
int
size
=
req
.
getSize
()
==
null
||
req
.
getSize
()
<
1
?
20
:
req
.
getSize
();
int
size
=
req
.
getSize
()
==
null
||
req
.
getSize
()
<
1
?
20
:
req
.
getSize
();
Pagination
<
InspectionWorkOrder
>
pagination
=
new
Pagination
<>((
page
-
1
)
*
size
,
size
);
Pagination
<
InspectionWorkOrder
>
pagination
=
new
Pagination
<>((
page
-
1
)
*
size
,
size
);
pagination
.
addFilter
(
"status"
,
req
.
getStatus
(),
Operator
.
eq
);
pagination
.
addFilter
(
JpaQueryConstants
.
InspectionWorkOrder
.
STATUS
,
req
.
getStatus
(),
Operator
.
eq
);
pagination
.
addFilter
(
JpaQueryConstants
.
InspectionWorkOrder
.
INSPECTOR_ID
,
InspectorContext
.
getInspectorId
(),
Operator
.
eq
);
if
(
StringUtils
.
isNotBlank
(
req
.
getKeyword
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getKeyword
()))
{
pagination
.
addFilter
(
JpaQueryConstants
.
InspectionWorkOrder
.
KEYWORD
,
req
.
getKeyword
(),
Operator
.
eq
);
pagination
.
addFilter
(
JpaQueryConstants
.
InspectionWorkOrder
.
KEYWORD
,
req
.
getKeyword
(),
Operator
.
eq
);
}
}
...
...
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