refactor(controller): 重构质量问题工单删除逻辑
- 将控制器中的直接删除操作移至专用服务类 - 添加批量删除质量问题工单的业务逻辑 - 实现删除条件校验:仅允许删除来源类型为PQC且状态为待流转的工单 - 对不满足删除条件的工单进行拦截并返回错误提示 - 使用事务注解确保删除操作的数据一致性
This commit is contained in:
parent
3199b8731c
commit
025cc24877
|
|
@ -192,7 +192,7 @@ public class QmsIssueTicketController extends BaseController {
|
|||
*/
|
||||
@PostMapping("delete")
|
||||
public ApiResult<Void> delete(@RequestBody @NotEmpty(message = "ID列表不能为空") List<Long> ids) {
|
||||
issueTicketService.removeByIds(ids);
|
||||
issueTicketControllerService.delete(ids);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,30 @@ public class QmsIssueTicketControllerService {
|
|||
@Resource
|
||||
private IQmsPqcInspectionPointItemsService pqcInspectionPointItemsService;
|
||||
|
||||
/**
|
||||
* 批量删除质量问题工单
|
||||
* 仅允许删除来源类型为PQC(sourceType=3)且状态为待流转(status=0)的工单,
|
||||
* 否则提示不允许删除的工单编号
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(List<Long> ids) {
|
||||
List<QmsIssueTicket> tickets = issueTicketService.listByIds(ids);
|
||||
|
||||
// 校验工单是否均满足删除条件:来源类型为PQC(3)且状态为待流转(0)
|
||||
List<String> notAllowedTicketNos = tickets.stream()
|
||||
.filter(ticket -> !Objects.equals(ticket.getSourceType(), (short) 3)
|
||||
|| !Objects.equals(ticket.getStatus(), (short) 0))
|
||||
.map(QmsIssueTicket::getTicketNo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtil.isNotEmpty(notAllowedTicketNos)) {
|
||||
throw new NflgException(STATE.BusinessError,
|
||||
"以下工单不允许删除:" + String.join(",", notAllowedTicketNos));
|
||||
}
|
||||
|
||||
issueTicketService.removeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起巡检工单
|
||||
* 1. 校验工单存在且来源类型为巡检(sourceType=2)
|
||||
|
|
|
|||
Loading…
Reference in New Issue