状态处理逻辑,支持无工单时返回待流转状态
- 统计接口新增待流转数量字段和返回值支持feat(inspection): 添加质检状态“待流转”及基于状态的不合格处理逻辑 - 在质检结果提交接口中根据整体判定和检测项结果新增质检状态3“待流转” - 工单创建者查询PDI工单详情时返回全部处理记录,非创建者仅返回相关处理记录和措施 - 新增不合格项返回逻辑,确保不合格项列表正确反馈 - 扩展数据库映射、VO和查询条件,支持质检状态3“待流转” - 调整SQL查询和状态判断逻辑,兼容“待流转”状态的工单流程处理 - 细化工单流程状态和质检状态对应关系,提升系统状态表达准确性
This commit is contained in:
parent
38668e137c
commit
ce7b990813
|
|
@ -508,8 +508,8 @@ public class QmsIssueTicketControllerService {
|
|||
|
||||
/**
|
||||
* 查询本人的PDI工单详情
|
||||
* 校验当前登录人在 qms_issue_ticket_process 中为处理人/审批人/上级领导
|
||||
* 仅返回当前登录人相关的处理记录及其措施
|
||||
* 校验当前登录人为工单创建者,或在处理记录中为处理人/审批人/上级领导
|
||||
* 工单创建者返回全部处理记录,其他人仅返回自己相关的处理记录及措施
|
||||
*/
|
||||
public QmsPdiTicketMyDetailVO getMyPdiTicketDetail(Long id) {
|
||||
Long currentUserId = UserUtil.getUserId();
|
||||
|
|
@ -517,8 +517,18 @@ public class QmsIssueTicketControllerService {
|
|||
// 查询工单基本信息
|
||||
QmsIssueTicket ticket = issueTicketService.getById(id);
|
||||
|
||||
// 查询当前登录人相关的处理记录(处理人ID/审批人ID/上级领导ID = 当前用户)
|
||||
List<QmsIssueTicketProcess> processes = issueTicketProcessService.lambdaQuery()
|
||||
// 判断是否为工单创建者
|
||||
boolean isCreator = ticket.getCreateUserId() != null && ticket.getCreateUserId().equals(currentUserId);
|
||||
|
||||
List<QmsIssueTicketProcess> processes;
|
||||
if (isCreator) {
|
||||
// 工单创建者:返回全部处理记录
|
||||
processes = issueTicketProcessService.lambdaQuery()
|
||||
.eq(QmsIssueTicketProcess::getIssueTicketId, id)
|
||||
.list();
|
||||
} else {
|
||||
// 非创建者:仅返回自己相关的处理记录
|
||||
processes = issueTicketProcessService.lambdaQuery()
|
||||
.eq(QmsIssueTicketProcess::getIssueTicketId, id)
|
||||
.and(w -> w
|
||||
.eq(QmsIssueTicketProcess::getHandlerUserId, currentUserId)
|
||||
|
|
@ -526,6 +536,7 @@ public class QmsIssueTicketControllerService {
|
|||
.or().eq(QmsIssueTicketProcess::getLeaderUserId, currentUserId)
|
||||
)
|
||||
.list();
|
||||
}
|
||||
|
||||
// 构建返回VO
|
||||
QmsPdiTicketMyDetailVO vo = new QmsPdiTicketMyDetailVO();
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ public class QmsPdiInspectionResultsControllerService {
|
|||
* 3. 检查 type=0/1/3 是否都有结果
|
||||
* 4. 检查 type=2 是否都传了图片
|
||||
* 5. 设置 detection_completion_time,将 overallResult 存入 task_record
|
||||
* 6. 若有不合格项则以 list 返回(仅 type=0/1/3),无则返回 null
|
||||
* 6. 根据整体判定+检测项结果设置状态:合格=2(已完成),不合格=3(待流转)
|
||||
* 7. 若有不合格项则以 list 返回(仅 type=0/1/3),无则返回 null
|
||||
*/
|
||||
@Transactional
|
||||
public List<QmsPdiInspectionResults> submit(QmsPdiInspectionResultsSubmitQO request) {
|
||||
|
|
@ -200,28 +201,31 @@ public class QmsPdiInspectionResultsControllerService {
|
|||
}
|
||||
|
||||
// 4. 将整体判定结果存入 task_record
|
||||
boolean overallResult = request.getOverallResult() != null && request.getOverallResult();
|
||||
taskRecordService.lambdaUpdate()
|
||||
.eq(QmsPdiTaskRecord::getId, taskRecord.getId())
|
||||
.set(QmsPdiTaskRecord::getInspectionInspection,
|
||||
request.getOverallResult() != null && request.getOverallResult())
|
||||
.set(QmsPdiTaskRecord::getInspectionInspection, overallResult)
|
||||
.update();
|
||||
|
||||
// 5. 设置检测完成时间、是否延期、状态改为已完成
|
||||
// 5. 查询不合格检测项(type=0/1/3)
|
||||
List<QmsPdiInspectionResults> failedItems = inspectionResultsService.lambdaQuery()
|
||||
.eq(QmsPdiInspectionResults::getTaskId, request.getTaskId())
|
||||
.ne(QmsPdiInspectionResults::getInspectionItemType, 2)
|
||||
.eq(QmsPdiInspectionResults::getInspectionItemResults, false)
|
||||
.list();
|
||||
|
||||
// 6. 根据整体判定+检测项结果设置状态:有不合格则=3(待流转),全合格则=2(已完成)
|
||||
boolean hasDefect = !overallResult || !failedItems.isEmpty();
|
||||
boolean overdue = taskRecord.getRequiredCompletionTime() != null
|
||||
&& now.isAfter(taskRecord.getRequiredCompletionTime());
|
||||
taskRecordService.lambdaUpdate()
|
||||
.eq(QmsPdiTaskRecord::getId, taskRecord.getId())
|
||||
.set(QmsPdiTaskRecord::getDetectionCompletionTime, now)
|
||||
.set(QmsPdiTaskRecord::getOverdue, overdue)
|
||||
.set(QmsPdiTaskRecord::getInspectionEnable, 2)
|
||||
.set(QmsPdiTaskRecord::getInspectionEnable, hasDefect ? 3 : 2)
|
||||
.update();
|
||||
|
||||
// 6. 返回不合格项(只查 type=0/1/3)
|
||||
List<QmsPdiInspectionResults> failedItems = inspectionResultsService.lambdaQuery()
|
||||
.eq(QmsPdiInspectionResults::getTaskId, request.getTaskId())
|
||||
.ne(QmsPdiInspectionResults::getInspectionItemType, 2)
|
||||
.eq(QmsPdiInspectionResults::getInspectionItemResults, false)
|
||||
.list();
|
||||
// 7. 返回不合格项
|
||||
return failedItems.isEmpty() ? null : failedItems;
|
||||
}
|
||||
|
||||
|
|
@ -248,6 +252,7 @@ public class QmsPdiInspectionResultsControllerService {
|
|||
vo.setInProgressCount(toInt(countMap.get("inProgressCount")));
|
||||
vo.setOverdueCount(toInt(countMap.get("overdueCount")));
|
||||
vo.setCompletedCount(toInt(countMap.get("completedCount")));
|
||||
vo.setPendingTransferCount(toInt(countMap.get("pendingTransferCount")));
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class QmsPdiTaskRecordSearchQO {
|
|||
private String inspectorName;
|
||||
|
||||
/**
|
||||
* 质检状态(可选):0待检查,1检验中,2已完成
|
||||
* 质检状态(可选):0待检查,1检验中,2已完成,3待流转
|
||||
*/
|
||||
private Integer inspectionEnable;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class QmsPdiInspectionResultsPageVO {
|
|||
private LocalDateTime requiredCompletionTime;
|
||||
|
||||
/**
|
||||
* 质检状态:0=待检查,1=检验中,2=已完成
|
||||
* 质检状态:0=待检查,1=检验中,2=已完成,3=待流转
|
||||
*/
|
||||
private Integer inspectionEnable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,4 +39,9 @@ public class QmsPdiTaskListVO {
|
|||
* 已完成数量(inspection_enable=2)
|
||||
*/
|
||||
private int completedCount;
|
||||
|
||||
/**
|
||||
* 待流转数量(inspection_enable=3)
|
||||
*/
|
||||
private int pendingTransferCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class QmsPdiTaskRecordDefectPageVO {
|
|||
private Boolean overdue;
|
||||
|
||||
/**
|
||||
* 工单流程状态(来自qms_issue_ticket.status):0=待流转,1=处理中,2=已完成;null=未创建工单
|
||||
* 流程状态:有工单时取工单状态(0=待流转,1=处理中,2=已完成),无工单时取任务状态(2=已完成,3=待流转)
|
||||
*/
|
||||
private Short status;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class QmsPdiTaskRecordSummaryVO {
|
|||
private Integer specialItemCount;
|
||||
|
||||
/**
|
||||
* 质检状态:0=待检查,1=检验中,2=已完成
|
||||
* 质检状态:0=待检查,1=检验中,2=已完成,3=待流转
|
||||
*/
|
||||
private Integer inspectionEnable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class QmsPdiTaskRecord implements Serializable {
|
|||
private Long detectionRulesId;
|
||||
|
||||
/**
|
||||
* 质检状态:0为待检查,1为检验中,2为已完成
|
||||
* 质检状态:0为待检查,1为检验中,2为已完成,3为待流转
|
||||
*/
|
||||
private Integer inspectionEnable;
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@
|
|||
COUNT(CASE WHEN t.inspection_enable = 0 THEN 1 END) AS "pendingCount",
|
||||
COUNT(CASE WHEN t.inspection_enable = 1 THEN 1 END) AS "inProgressCount",
|
||||
COUNT(CASE WHEN t.overdue = true THEN 1 END) AS "overdueCount",
|
||||
COUNT(CASE WHEN t.inspection_enable = 2 THEN 1 END) AS "completedCount"
|
||||
COUNT(CASE WHEN t.inspection_enable = 2 THEN 1 END) AS "completedCount",
|
||||
COUNT(CASE WHEN t.inspection_enable = 3 THEN 1 END) AS "pendingTransferCount"
|
||||
FROM qms_pdi_task_record t
|
||||
LEFT JOIN qms_pdi_detection_rules r ON r.id = t.detection_rules_id
|
||||
<where>
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@
|
|||
<if test="request.warehouseNo != null and request.warehouseNo != ''">
|
||||
AND t.warehouse_no = #{request.warehouseNo}
|
||||
</if>
|
||||
<!-- 合格物料过滤:inspection_enable=0/1不校验;inspection_enable=2校验自身结果+检测项结果(type=2除外) -->
|
||||
<!-- 合格物料过滤:inspection_enable=0/1/3不校验;inspection_enable=2校验自身结果+检测项结果(type=2除外) -->
|
||||
AND (
|
||||
t.inspection_enable IN (0, 1)
|
||||
t.inspection_enable IN (0, 1, 3)
|
||||
OR (
|
||||
t.inspection_enable = 2
|
||||
AND t.inspection_inspection = true
|
||||
|
|
@ -92,7 +92,7 @@
|
|||
t.required_completion_time AS requiredCompletionTime,
|
||||
t.detection_completion_time AS detectionCompletionTime,
|
||||
t.overdue,
|
||||
it.status AS status,
|
||||
COALESCE(it.status, t.inspection_enable) AS status,
|
||||
it.ticket_no AS ticketNo,
|
||||
it.ticket_title AS ticketTitle
|
||||
FROM qms_pdi_task_record t
|
||||
|
|
@ -101,8 +101,8 @@
|
|||
LEFT JOIN "user" ua ON ua.id = t.assistant_id
|
||||
LEFT JOIN qms_issue_ticket it ON it.source_type = 1 AND it.source_id = t.id
|
||||
<where>
|
||||
<!-- 固定条件:已完成 + 不合格 + 存在不合格检测项 -->
|
||||
AND t.inspection_enable = 2
|
||||
<!-- 固定条件:已完成/待流转 + 不合格 + 存在不合格检测项 -->
|
||||
AND t.inspection_enable IN (2, 3)
|
||||
AND t.inspection_inspection = false
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
AND t.warehouse_no = #{request.warehouseNo}
|
||||
</if>
|
||||
<if test="request.status != null">
|
||||
AND it.status = #{request.status}
|
||||
AND COALESCE(it.status, t.inspection_enable) = #{request.status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.id DESC
|
||||
|
|
|
|||
Loading…
Reference in New Issue