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 f585a61c
authored
Mar 18, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:工单检测审批,开始检测工单,结束检测工单代码提交
1 parent
9be30d29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
273 additions
and
0 deletions
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionWorkOrderController.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionWorkOrderService.java
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionWorkOrderAuditVO.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/inspect/InspectionWorkOrderController.java
View file @
f585a61
...
@@ -121,4 +121,30 @@ public class InspectionWorkOrderController {
...
@@ -121,4 +121,30 @@ public class InspectionWorkOrderController {
return
BaseResp
.
fail
(
"系统异常: "
+
e
.
getMessage
());
return
BaseResp
.
fail
(
"系统异常: "
+
e
.
getMessage
());
}
}
}
}
@Operation
(
summary
=
"审批检测工单"
,
description
=
"审批检测工单(仅工单状态为已完成时可审批,同意则生成检测报告)"
)
@PostMapping
(
"/audit"
)
public
BaseResp
<
Void
>
audit
(
@Valid
@RequestBody
InspectionWorkOrderAuditVO
auditVO
,
Authentication
authentication
)
{
log
.
info
(
"审批检测工单请求: {}"
,
JSON
.
toJSONString
(
auditVO
));
try
{
if
(
authentication
==
null
||
authentication
.
getPrincipal
()
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
LOGIN_ERROR
,
"未登录,无法操作"
);
}
User
user
=
(
User
)
authentication
.
getPrincipal
();
inspectionWorkOrderService
.
auditInspectionWorkOrder
(
auditVO
,
user
.
getUserId
(),
user
.
getUserName
(),
InspectionPlatTypeEnum
.
BACKEND
);
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"审批检测工单失败!业务异常!"
,
be
);
return
BaseResp
.
fail
(
StrUtil
.
toString
(
be
.
getCode
()),
StrUtil
.
toString
(
be
.
getMessage
()));
}
catch
(
Exception
e
)
{
log
.
error
(
"审批检测工单失败!系统异常!"
,
e
);
return
BaseResp
.
fail
(
"系统异常: "
+
e
.
getMessage
());
}
return
BaseResp
.
success
();
}
}
}
aus-core/src/main/java/com/glsx/usedcar/module/inspect/service/InspectionWorkOrderService.java
View file @
f585a61
...
@@ -45,6 +45,7 @@ public class InspectionWorkOrderService {
...
@@ -45,6 +45,7 @@ public class InspectionWorkOrderService {
private
final
InspectionWorkOrderOpLogConverter
inspectionWorkOrderOpLogConverter
;
private
final
InspectionWorkOrderOpLogConverter
inspectionWorkOrderOpLogConverter
;
private
final
VehicleDao
vehicleDao
;
private
final
VehicleDao
vehicleDao
;
private
final
InspectorRepository
inspectorRepository
;
private
final
InspectorRepository
inspectorRepository
;
private
final
InspectionReportService
inspectionReportService
;
/**
/**
* 保存检测工单操作日志
* 保存检测工单操作日志
...
@@ -340,4 +341,220 @@ public class InspectionWorkOrderService {
...
@@ -340,4 +341,220 @@ public class InspectionWorkOrderService {
List
<
InspectionWOOpLogRespVo
>
inspectionWOOpLogRespVos
=
inspectionWorkOrderOpLogConverter
.
inspectionWorkOrderOpLogMapRespVO
(
logList
);
List
<
InspectionWOOpLogRespVo
>
inspectionWOOpLogRespVos
=
inspectionWorkOrderOpLogConverter
.
inspectionWorkOrderOpLogMapRespVO
(
logList
);
return
new
InspectionWODetailRespVO
(
inspectionWORespVO
,
inspectionWOOpLogRespVos
);
return
new
InspectionWODetailRespVO
(
inspectionWORespVO
,
inspectionWOOpLogRespVos
);
}
}
/**
* 审批检测工单
*
* @param auditVO 审批请求VO
* @param opId 操作人ID
* @param opName 操作人姓名
* @param platTypeEnum 平台标识枚举
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
auditInspectionWorkOrder
(
InspectionWorkOrderAuditVO
auditVO
,
Integer
opId
,
String
opName
,
InspectionPlatTypeEnum
platTypeEnum
)
{
// 1. 基础参数校验
if
(
opId
==
null
||
StrUtil
.
isBlank
(
opName
)
||
platTypeEnum
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"操作人信息/平台标识不能为空"
);
}
if
(
auditVO
==
null
||
auditVO
.
getId
()
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"工单ID不能为空"
);
}
if
(
auditVO
.
getAuditResult
()
==
null
||
(
auditVO
.
getAuditResult
()
!=
1
&&
auditVO
.
getAuditResult
()
!=
2
))
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"审批结果仅支持1=同意/2=不同意"
);
}
if
(
StrUtil
.
isBlank
(
auditVO
.
getAuditOpinion
()))
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"审批意见不能为空"
);
}
// 2. 查询工单并校验状态
InspectionWorkOrder
workOrder
=
inspectionWorkOrderRepository
.
findByIdAndDeleteFlag
(
auditVO
.
getId
(),
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
"检测工单不存在,工单ID:"
+
auditVO
.
getId
()));
// 校验工单状态是否为已完成(仅已完成状态可审批)
Integer
completedStatus
=
InspectionWorkOrderStatusEnum
.
COMPLETED
.
getCode
();
if
(!
Objects
.
equals
(
workOrder
.
getStatus
(),
completedStatus
))
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
String
.
format
(
"工单状态为[%s],仅已完成状态可审批,工单ID:%s"
,
workOrder
.
getStatus
(),
auditVO
.
getId
()));
}
// 3. 保存审批前原始状态(用于日志)
Integer
originalAuditStatus
=
workOrder
.
getAuditStatus
();
Integer
targetAuditStatus
;
String
operationContent
;
String
description
;
// 4. 处理审批结果
LocalDateTime
now
=
LocalDateTime
.
now
();
InspectionWorkOrderOperationTypeEnum
auditOperationType
;
if
(
auditVO
.
getAuditResult
()
==
1
)
{
// 4.1 同意审批:更新审批状态为通过,生成检测报告
targetAuditStatus
=
InspectionWorkOrderAuditStatusEnum
.
PASS
.
getCode
();
workOrder
.
setAuditStatus
(
targetAuditStatus
);
workOrder
.
setAuditContent
(
auditVO
.
getAuditOpinion
());
workOrder
.
setAuditTime
(
now
);
workOrder
.
setUpdateBy
(
opName
);
workOrder
.
setUpdateTime
(
now
);
inspectionWorkOrderRepository
.
save
(
workOrder
);
// 生成检测报告(调用报告服务)
inspectionReportService
.
addInspectionReport
(
workOrder
,
workOrder
.
getVehicle
(),
Long
.
valueOf
(
opId
),
opName
,
platTypeEnum
.
getCode
()
);
operationContent
=
String
.
format
(
"同意审批工单,工单ID:%s,审批意见:%s,已生成检测报告"
,
auditVO
.
getId
(),
auditVO
.
getAuditOpinion
());
description
=
String
.
format
(
"审批工单[%s]通过,状态从[%s]改为[%s],生成检测报告"
,
workOrder
.
getWoId
(),
originalAuditStatus
,
targetAuditStatus
);
auditOperationType
=
InspectionWorkOrderOperationTypeEnum
.
APPROVE_PASS
;
}
else
{
// 4.2 不同意审批:仅更新审批状态为拒绝,不生成报告
targetAuditStatus
=
InspectionWorkOrderAuditStatusEnum
.
REJECT
.
getCode
();
workOrder
.
setAuditStatus
(
targetAuditStatus
);
workOrder
.
setAuditContent
(
auditVO
.
getAuditOpinion
());
workOrder
.
setAuditTime
(
now
);
workOrder
.
setUpdateBy
(
opName
);
workOrder
.
setUpdateTime
(
now
);
inspectionWorkOrderRepository
.
save
(
workOrder
);
operationContent
=
String
.
format
(
"拒绝审批工单,工单ID:%s,审批意见:%s"
,
auditVO
.
getId
(),
auditVO
.
getAuditOpinion
());
description
=
String
.
format
(
"审批工单[%s]拒绝,状态从[%s]改为[%s],未生成检测报告"
,
workOrder
.
getWoId
(),
originalAuditStatus
,
targetAuditStatus
);
auditOperationType
=
InspectionWorkOrderOperationTypeEnum
.
APPROVE_REJECT
;
}
// 5. 保存审批操作日志
saveWorkOrderOpLog
(
workOrder
,
auditOperationType
.
getCode
(),
originalAuditStatus
,
targetAuditStatus
,
operationContent
,
description
,
Long
.
valueOf
(
opId
),
opName
,
platTypeEnum
.
getCode
()
);
log
.
info
(
"检测工单审批成功: 工单ID={}, 唯一ID={}, 审批结果={}, 操作人={}"
,
workOrder
.
getId
(),
workOrder
.
getWoId
(),
auditVO
.
getAuditResult
()
==
1
?
"同意"
:
"不同意"
,
opName
);
}
/**
* 开始检测(修改状态+记录开始时间+保存日志)
*
* @param id 工单主键ID
* @param opId 操作人ID(外部传入)
* @param opName 操作人姓名
* @param platTypeEnum 平台标识枚举
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
startInspection
(
Long
id
,
Integer
opId
,
String
opName
,
InspectionPlatTypeEnum
platTypeEnum
)
{
// 1. 基础参数校验
if
(
opId
==
null
||
StrUtil
.
isBlank
(
opName
)
||
platTypeEnum
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"操作人信息/平台标识不能为空"
);
}
if
(
id
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"工单ID不能为空"
);
}
// 2. 查询工单并校验(未删除+状态合法)
InspectionWorkOrder
workOrder
=
inspectionWorkOrderRepository
.
findByIdAndDeleteFlag
(
id
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
"检测工单不存在,工单ID:"
+
id
));
// 仅「已派单」状态可开始检测
Integer
dispatchedStatus
=
InspectionWorkOrderStatusEnum
.
DISPATCHED
.
getCode
();
if
(!
Objects
.
equals
(
workOrder
.
getStatus
(),
dispatchedStatus
))
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
String
.
format
(
"工单状态为[%s],仅已派单状态可开始检测,工单ID:"
,
workOrder
.
getStatus
()),
id
);
}
// 3. 保存原始状态(用于日志)
Integer
originalStatus
=
workOrder
.
getStatus
();
Integer
targetStatus
=
InspectionWorkOrderStatusEnum
.
IN_PROGRESS
.
getCode
();
// 开始检测状态
// 4. 修改工单状态+开始检测时间
LocalDateTime
now
=
LocalDateTime
.
now
();
workOrder
.
setStatus
(
targetStatus
);
workOrder
.
setInspectionTime
(
now
);
workOrder
.
setUpdateBy
(
opName
);
workOrder
.
setUpdateTime
(
now
);
inspectionWorkOrderRepository
.
save
(
workOrder
);
// 5. 保存操作日志
String
operationContent
=
String
.
format
(
"开始检测,工单ID:%s,原状态:已派单,新状态:检测中"
,
id
);
String
description
=
String
.
format
(
"操作人[%s]启动工单检测,开始时间:%s"
,
opName
,
now
);
saveWorkOrderOpLog
(
workOrder
,
InspectionWorkOrderOperationTypeEnum
.
START_INSPECTION
.
getCode
(),
originalStatus
,
targetStatus
,
operationContent
,
description
,
Long
.
valueOf
(
opId
),
opName
,
platTypeEnum
.
getCode
());
log
.
info
(
"检测工单开始检测成功: ID={}, 唯一ID={}, 操作人={}"
,
workOrder
.
getId
(),
workOrder
.
getWoId
(),
opName
);
}
/**
* 完成检测(修改状态+记录结束时间+保存日志)
*
* @param id 工单主键ID
* @param opId 操作人ID(外部传入)
* @param opName 操作人姓名
* @param platTypeEnum 平台标识枚举
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
completeInspection
(
Long
id
,
Integer
opId
,
String
opName
,
InspectionPlatTypeEnum
platTypeEnum
)
{
// 1. 基础参数校验
if
(
opId
==
null
||
StrUtil
.
isBlank
(
opName
)
||
platTypeEnum
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"操作人信息/平台标识不能为空"
);
}
if
(
id
==
null
)
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
"工单ID不能为空"
);
}
// 2. 查询工单并校验(未删除+状态合法)
InspectionWorkOrder
workOrder
=
inspectionWorkOrderRepository
.
findByIdAndDeleteFlag
(
id
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
DATA_NOT_EXIST
,
"检测工单不存在,工单ID:"
+
id
));
// 仅「检测中」状态可完成检测
Integer
inProgressStatus
=
InspectionWorkOrderStatusEnum
.
IN_PROGRESS
.
getCode
();
if
(!
Objects
.
equals
(
workOrder
.
getStatus
(),
inProgressStatus
))
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
PARAM_ERROR
,
String
.
format
(
"工单状态为[%s],仅检测中状态可完成检测,工单ID:%s"
,
workOrder
.
getStatus
(),
id
));
}
// 3. 保存原始状态(用于日志)
Integer
originalStatus
=
workOrder
.
getStatus
();
Integer
targetStatus
=
InspectionWorkOrderStatusEnum
.
COMPLETED
.
getCode
();
// 检测完成状态
// 4. 修改工单状态+结束检测时间
LocalDateTime
now
=
LocalDateTime
.
now
();
workOrder
.
setStatus
(
targetStatus
);
workOrder
.
setInspectionCompletedTime
(
now
);
workOrder
.
setUpdateBy
(
opName
);
workOrder
.
setUpdateTime
(
now
);
inspectionWorkOrderRepository
.
save
(
workOrder
);
// 5. 保存操作日志
String
operationContent
=
String
.
format
(
"完成检测,工单ID:%s,原状态:检测中,新状态:已完成"
,
id
);
String
description
=
String
.
format
(
"操作人[%s]完成工单检测,结束时间:%s"
,
opName
,
now
);
saveWorkOrderOpLog
(
workOrder
,
InspectionWorkOrderOperationTypeEnum
.
COMPLETE_ORDER
.
getCode
(),
originalStatus
,
targetStatus
,
operationContent
,
description
,
Long
.
valueOf
(
opId
),
opName
,
platTypeEnum
.
getCode
());
log
.
info
(
"检测工单完成检测成功: ID={}, 唯一ID={}, 操作人={}"
,
workOrder
.
getId
(),
workOrder
.
getWoId
(),
opName
);
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-core/src/main/java/com/glsx/usedcar/module/inspect/vo/InspectionWorkOrderAuditVO.java
0 → 100644
View file @
f585a61
package
com
.
glsx
.
usedcar
.
module
.
inspect
.
vo
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
/**
* 检测工单审批VO
*/
@Data
public
class
InspectionWorkOrderAuditVO
{
/**
* 工单主键ID
*/
@NotNull
(
message
=
"工单ID不能为空"
)
private
Long
id
;
/**
* 审批结果:1=同意,2=不同意
*/
@NotNull
(
message
=
"审批结果不能为空"
)
private
Integer
auditResult
;
/**
* 审批意见
*/
@NotBlank
(
message
=
"审批意见不能为空"
)
private
String
auditOpinion
;
}
\ No newline at end of file
\ No newline at end of file
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