2026-04-24 08:52:54 +08:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
|
<mapper namespace="com.nflg.wms.repository.mapper.QmsPdiInspectionResultsMapper">
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 分页查询:以任务单为主体,关联规则表取机型、版本等 -->
|
|
|
|
|
|
<select id="search" resultType="com.nflg.wms.common.pojo.vo.QmsPdiInspectionResultsPageVO">
|
|
|
|
|
|
SELECT DISTINCT
|
|
|
|
|
|
t.id AS taskId,
|
2026-05-20 15:46:41 +08:00
|
|
|
|
r.model_no AS machineNo,
|
2026-04-24 08:52:54 +08:00
|
|
|
|
t.order_no AS orderNo,
|
|
|
|
|
|
t.device_no AS deviceNo,
|
|
|
|
|
|
t.task_no AS taskNo,
|
|
|
|
|
|
r.inspection_version AS inspectionVersion,
|
|
|
|
|
|
t.submission_time AS submissionTime,
|
2026-05-08 08:17:46 +08:00
|
|
|
|
t.required_completion_time AS requiredCompletionTime,
|
2026-05-08 14:06:31 +08:00
|
|
|
|
t.inspection_enable AS inspectionEnable,
|
2026-06-24 14:49:48 +08:00
|
|
|
|
t.assignee_id AS assigneeId,
|
|
|
|
|
|
uass.user_name AS assigneeName,
|
2026-06-14 17:50:57 +08:00
|
|
|
|
CASE
|
2026-06-24 14:49:48 +08:00
|
|
|
|
WHEN uass.user_name IS NOT NULL THEN uass.user_name
|
2026-06-14 17:50:57 +08:00
|
|
|
|
WHEN ua.user_name IS NOT NULL AND ui.user_name IS NOT NULL AND ua.user_name != ui.user_name
|
|
|
|
|
|
THEN ua.user_name || ';' || ui.user_name
|
|
|
|
|
|
ELSE COALESCE(ua.user_name, ui.user_name)
|
|
|
|
|
|
END AS currentHandlerName,
|
2026-05-08 14:06:31 +08:00
|
|
|
|
t.overdue
|
2026-04-24 08:52:54 +08:00
|
|
|
|
FROM qms_pdi_task_record t
|
|
|
|
|
|
LEFT JOIN qms_pdi_detection_rules r ON r.id = t.detection_rules_id
|
2026-06-14 17:50:57 +08:00
|
|
|
|
LEFT JOIN "user" ui ON ui.id = r.inspector_id
|
|
|
|
|
|
LEFT JOIN "user" ua ON ua.id = t.assistant_id
|
2026-06-24 14:49:48 +08:00
|
|
|
|
LEFT JOIN "user" uass ON uass.id = t.assignee_id
|
2026-04-24 08:52:54 +08:00
|
|
|
|
<where>
|
|
|
|
|
|
<!-- 权限过滤:只能看自己是帮办人或质检负责人的任务单 -->
|
|
|
|
|
|
<if test="request.userId != null">
|
2026-06-24 14:49:48 +08:00
|
|
|
|
AND (t.assistant_id = #{request.userId} OR r.inspector_id = #{request.userId} OR t.assignee_id = #{request.userId})
|
2026-04-24 08:52:54 +08:00
|
|
|
|
</if>
|
2026-05-12 11:51:00 +08:00
|
|
|
|
<!-- 关键字模糊匹配:机型编号、订单编号、机台编号、任务单号 -->
|
|
|
|
|
|
<if test="request.key != null and request.key != ''">
|
|
|
|
|
|
AND (
|
2026-05-20 15:46:41 +08:00
|
|
|
|
r.model_no ILIKE CONCAT('%', #{request.key}, '%')
|
2026-05-12 11:51:00 +08:00
|
|
|
|
OR t.order_no ILIKE CONCAT('%', #{request.key}, '%')
|
|
|
|
|
|
OR t.device_no ILIKE CONCAT('%', #{request.key}, '%')
|
|
|
|
|
|
OR t.task_no ILIKE CONCAT('%', #{request.key}, '%')
|
|
|
|
|
|
)
|
2026-04-24 08:52:54 +08:00
|
|
|
|
</if>
|
2026-05-12 10:32:02 +08:00
|
|
|
|
<!-- 任务状态筛选 -->
|
2026-05-20 15:46:41 +08:00
|
|
|
|
<if test="request.inspectionEnable != null and request.inspectionEnable != 9">
|
2026-05-12 10:49:59 +08:00
|
|
|
|
AND t.inspection_enable = #{request.inspectionEnable}
|
2026-05-12 10:32:02 +08:00
|
|
|
|
</if>
|
2026-05-20 15:46:41 +08:00
|
|
|
|
<if test="request.inspectionEnable != null and request.inspectionEnable == 9">
|
2026-05-14 11:23:07 +08:00
|
|
|
|
AND t.overdue = true
|
|
|
|
|
|
</if>
|
2026-04-24 08:52:54 +08:00
|
|
|
|
</where>
|
|
|
|
|
|
ORDER BY t.id DESC
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2026-04-29 11:17:13 +08:00
|
|
|
|
<!-- 平板:检查任务列表分页查询(仅 taskStatus 筛选) -->
|
|
|
|
|
|
<select id="searchTaskList" resultType="com.nflg.wms.common.pojo.vo.QmsPdiInspectionResultsPageVO">
|
|
|
|
|
|
SELECT DISTINCT
|
|
|
|
|
|
t.id AS taskId,
|
2026-05-20 15:46:41 +08:00
|
|
|
|
r.model_no AS machineNo,
|
2026-04-29 11:17:13 +08:00
|
|
|
|
t.order_no AS orderNo,
|
|
|
|
|
|
t.device_no AS deviceNo,
|
|
|
|
|
|
t.task_no AS taskNo,
|
|
|
|
|
|
r.inspection_version AS inspectionVersion,
|
|
|
|
|
|
t.submission_time AS submissionTime,
|
2026-05-07 16:55:17 +08:00
|
|
|
|
t.required_completion_time AS requiredCompletionTime,
|
2026-05-08 14:06:31 +08:00
|
|
|
|
t.inspection_enable AS inspectionEnable,
|
2026-06-24 14:49:48 +08:00
|
|
|
|
t.assignee_id AS assigneeId,
|
|
|
|
|
|
uass.user_name AS assigneeName,
|
2026-06-14 17:50:57 +08:00
|
|
|
|
CASE
|
2026-06-24 14:49:48 +08:00
|
|
|
|
WHEN uass.user_name IS NOT NULL THEN uass.user_name
|
2026-06-14 17:50:57 +08:00
|
|
|
|
WHEN ua.user_name IS NOT NULL AND ui.user_name IS NOT NULL AND ua.user_name != ui.user_name
|
|
|
|
|
|
THEN ua.user_name || ';' || ui.user_name
|
|
|
|
|
|
ELSE COALESCE(ua.user_name, ui.user_name)
|
|
|
|
|
|
END AS currentHandlerName,
|
2026-05-08 14:06:31 +08:00
|
|
|
|
t.overdue
|
2026-04-29 11:17:13 +08:00
|
|
|
|
FROM qms_pdi_task_record t
|
|
|
|
|
|
LEFT JOIN qms_pdi_detection_rules r ON r.id = t.detection_rules_id
|
2026-06-14 17:50:57 +08:00
|
|
|
|
LEFT JOIN "user" ui ON ui.id = r.inspector_id
|
|
|
|
|
|
LEFT JOIN "user" ua ON ua.id = t.assistant_id
|
2026-06-24 14:49:48 +08:00
|
|
|
|
LEFT JOIN "user" uass ON uass.id = t.assignee_id
|
2026-04-29 11:17:13 +08:00
|
|
|
|
<where>
|
|
|
|
|
|
<if test="request.userId != null">
|
2026-06-24 14:49:48 +08:00
|
|
|
|
AND (t.assistant_id = #{request.userId} OR r.inspector_id = #{request.userId} OR t.assignee_id = #{request.userId})
|
2026-04-29 11:17:13 +08:00
|
|
|
|
</if>
|
2026-05-20 15:46:41 +08:00
|
|
|
|
<if test="request.taskStatus != null and request.taskStatus != 9">
|
2026-04-29 11:17:13 +08:00
|
|
|
|
AND t.inspection_enable = #{request.taskStatus}
|
|
|
|
|
|
</if>
|
2026-05-20 15:46:41 +08:00
|
|
|
|
<if test="request.taskStatus != null and request.taskStatus == 9">
|
2026-04-29 11:17:13 +08:00
|
|
|
|
AND t.overdue = true
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
ORDER BY t.id DESC
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 平板:统计各状态数量(不受筛选条件影响,只受权限过滤) -->
|
|
|
|
|
|
<select id="countByStatus" resultType="map">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
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",
|
2026-05-08 09:27:02 +08:00
|
|
|
|
COUNT(CASE WHEN t.inspection_enable = 2 THEN 1 END) AS "completedCount",
|
|
|
|
|
|
COUNT(CASE WHEN t.inspection_enable = 3 THEN 1 END) AS "pendingTransferCount"
|
2026-04-29 11:17:13 +08:00
|
|
|
|
FROM qms_pdi_task_record t
|
|
|
|
|
|
LEFT JOIN qms_pdi_detection_rules r ON r.id = t.detection_rules_id
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<if test="userId != null">
|
2026-06-24 14:49:48 +08:00
|
|
|
|
AND (t.assistant_id = #{userId} OR r.inspector_id = #{userId} OR t.assignee_id = #{userId})
|
2026-04-29 11:17:13 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2026-06-15 14:19:55 +08:00
|
|
|
|
<!-- 根据任务ID查询检验结果详情(联查检测项和部件信息) -->
|
|
|
|
|
|
<select id="listByTaskId" resultType="com.nflg.wms.common.pojo.vo.QmsPdiTaskInspectionResultVO">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
b.id,
|
|
|
|
|
|
c.component_name AS componentName,
|
|
|
|
|
|
a.inspection_content AS inspectionContent,
|
|
|
|
|
|
d.url AS inspectionImage,
|
|
|
|
|
|
a.status,
|
|
|
|
|
|
b.inspection_item_image AS inspectionItemImage,
|
|
|
|
|
|
b.inspection_item_results AS inspectionItemResults,
|
|
|
|
|
|
b.inspection_time AS inspectionTime,
|
|
|
|
|
|
b.inspection_by AS inspectionBy,
|
|
|
|
|
|
b.remark
|
|
|
|
|
|
FROM qms_pdi_inspection_results b
|
|
|
|
|
|
LEFT JOIN qms_pdi_detection_rules_status_item a ON a.id = b.inspection_item_id
|
|
|
|
|
|
LEFT JOIN qms_pdi_component_anagement c ON a.components_id = c.id
|
|
|
|
|
|
LEFT JOIN file_upload_record d ON a.inspection_image::bigint = d.id
|
|
|
|
|
|
WHERE b.task_id = #{request.taskId}
|
|
|
|
|
|
AND a.status = #{request.status}
|
|
|
|
|
|
AND c.component_name = #{request.componentName}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2026-04-24 08:52:54 +08:00
|
|
|
|
</mapper>
|