From 211d2887af4608fbdfd40af1e16e4f58131dfaa2 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期五, 28 八月 2026 23:08:54 +0800
Subject: [PATCH] feat: 添加清除当前用户的所有消息接口
---
src/main/resources/mapper/quality/QualityInspectMapper.xml | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 101 insertions(+), 17 deletions(-)
diff --git a/src/main/resources/mapper/quality/QualityInspectMapper.xml b/src/main/resources/mapper/quality/QualityInspectMapper.xml
index f252881..7e0bd51 100644
--- a/src/main/resources/mapper/quality/QualityInspectMapper.xml
+++ b/src/main/resources/mapper/quality/QualityInspectMapper.xml
@@ -54,6 +54,15 @@
<if test="qualityInspect.entryDateEnd != null and qualityInspect.entryDateEnd != '' ">
AND qi.check_time <= DATE_FORMAT(#{qualityInspect.entryDateEnd},'%Y-%m-%d')
</if>
+ <if test="qualityInspect.purchaseContractNo != null and qualityInspect.purchaseContractNo != '' ">
+ AND pl.purchase_contract_number like concat('%',#{qualityInspect.purchaseContractNo},'%')
+ </if>
+ <if test="qualityInspect.workOrderNo != null and qualityInspect.workOrderNo != '' ">
+ AND pot.work_order_no like concat('%',#{qualityInspect.workOrderNo},'%')
+ </if>
+ <if test="qualityInspect.salesContractNo != null and qualityInspect.salesContractNo != '' ">
+ AND po_sales.sales_contract_no like concat('%',#{qualityInspect.salesContractNo},'%')
+ </if>
ORDER BY qi.check_time DESC
</select>
@@ -128,8 +137,7 @@
COALESCE(SUM(
CASE
WHEN qi.inspect_state = 1
- AND qi.check_result = '鍚堟牸'
- THEN qi.quantity
+ THEN qi.qualified_quantity
ELSE 0
END
), 0) AS qualifiedCount,
@@ -137,8 +145,7 @@
COALESCE(SUM(
CASE
WHEN qi.inspect_state = 1
- AND qi.check_result = '涓嶅悎鏍�'
- THEN qi.quantity
+ THEN qi.unqualified_quantity
ELSE 0
END
), 0) AS unqualifiedCount,
@@ -166,8 +173,7 @@
COALESCE(SUM(
CASE
WHEN qi.inspect_state = 1
- AND qi.check_result = '鍚堟牸'
- THEN qi.quantity
+ THEN qi.qualified_quantity
ELSE 0
END
), 0)
@@ -248,8 +254,8 @@
/* 鍚堟牸 */
COALESCE(SUM(
CASE
- WHEN qi.inspect_state = 1 AND qi.check_result = '鍚堟牸'
- THEN qi.quantity
+ WHEN qi.inspect_state = 1
+ THEN qi.qualified_quantity
ELSE 0
END
), 0) AS qualifiedCount,
@@ -257,8 +263,8 @@
/* 涓嶅悎鏍� */
COALESCE(SUM(
CASE
- WHEN qi.inspect_state = 1 AND qi.check_result = '涓嶅悎鏍�'
- THEN qi.quantity
+ WHEN qi.inspect_state = 1
+ THEN qi.unqualified_quantity
ELSE 0
END
), 0) AS unqualifiedCount,
@@ -279,8 +285,8 @@
ROUND(
COALESCE(SUM(
CASE
- WHEN qi.inspect_state = 1 AND qi.check_result = '鍚堟牸'
- THEN qi.quantity
+ WHEN qi.inspect_state = 1
+ THEN qi.qualified_quantity
ELSE 0
END
), 0)
@@ -312,7 +318,6 @@
<select id="getYearlyPassRateStatistics" resultType="com.ruoyi.quality.dto.QualityPassRateDto">
SELECT t.modelType,
-
COALESCE(SUM(
CASE
WHEN pp.product_name = '鍘熸潗鏂�' AND t.modelType = 0 THEN qi.quantity
@@ -320,8 +325,23 @@
WHEN pp.product_name = '鎴愬搧' AND t.modelType = 2 THEN qi.quantity
ELSE 0
END
- ), 0) AS totalCount
-
+ ), 0) AS totalCount,
+ COALESCE(SUM(
+ CASE
+ WHEN pp.product_name = '鍘熸潗鏂�' AND t.modelType = 0 THEN qi.qualified_quantity
+ WHEN pp.product_name = '鍗婃垚鍝�' AND t.modelType = 1 THEN qi.qualified_quantity
+ WHEN pp.product_name = '鎴愬搧' AND t.modelType = 2 THEN qi.qualified_quantity
+ ELSE 0
+ END
+ ), 0) AS qualifiedCount,
+ COALESCE(SUM(
+ CASE
+ WHEN pp.product_name = '鍘熸潗鏂�' AND t.modelType = 0 THEN qi.unqualified_quantity
+ WHEN pp.product_name = '鍗婃垚鍝�' AND t.modelType = 1 THEN qi.unqualified_quantity
+ WHEN pp.product_name = '鎴愬搧' AND t.modelType = 2 THEN qi.unqualified_quantity
+ ELSE 0
+ END
+ ), 0) AS unqualifiedCount
FROM (SELECT 0 AS modelType
UNION ALL
SELECT 1
@@ -334,8 +354,6 @@
ON qi.product_model_id = pm.id
AND YEAR(qi.check_time) = #{year}
AND qi.inspect_state = 1
- AND qi.check_result = '鍚堟牸'
-
GROUP BY t.modelType
ORDER BY t.modelType;
</select>
@@ -451,5 +469,71 @@
</select>
+ <sql id="personGroupRateJoin">
+ FROM quality_inspect qi
+ INNER JOIN production_product_main ppm ON qi.product_main_id = ppm.id
+ LEFT JOIN (
+ SELECT production_product_main_id,
+ CAST(SUM(IFNULL(scrap_qty, 0)) AS DECIMAL(18,4)) AS scrapCount
+ FROM production_product_output
+ GROUP BY production_product_main_id
+ ) ppo ON ppo.production_product_main_id = ppm.id
+ LEFT JOIN (
+ SELECT inspect_id,
+ CAST(SUM(CASE WHEN deal_type IN (0, 1) THEN IFNULL(quantity, 0) ELSE 0 END) AS DECIMAL(18,4)) AS reworkCount
+ FROM quality_unqualified
+ WHERE inspect_state = 1
+ GROUP BY inspect_id
+ ) qu ON qu.inspect_id = qi.id
+ </sql>
+
+ <sql id="personGroupRateWhere">
+ WHERE qi.inspect_type IN (1, 2)
+ AND qi.inspect_state = 1
+ AND qi.product_main_id IS NOT NULL
+ </sql>
+
+ <select id="getPersonRateStatistics" resultType="com.ruoyi.quality.dto.QualityPersonGroupRateDto">
+ SELECT ppm.user_id AS dimensionId,
+ COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('鐢ㄦ埛', ppm.user_id)) AS dimensionName,
+ CAST(SUM(IFNULL(qi.quantity, 0)) AS DECIMAL(18,4)) AS totalCount,
+ CAST(SUM(IFNULL(qi.qualified_quantity, 0)) AS DECIMAL(18,4)) AS qualifiedCount,
+ CAST(SUM(IFNULL(qi.unqualified_quantity, 0)) AS DECIMAL(18,4)) AS unqualifiedCount,
+ CAST(SUM(IFNULL(qu.reworkCount, 0)) AS DECIMAL(18,4)) AS reworkCount,
+ CAST(SUM(IFNULL(ppo.scrapCount, 0)) AS DECIMAL(18,4)) AS scrapCount,
+ CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0,
+ ROUND(SUM(IFNULL(qi.qualified_quantity, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS passRate,
+ CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0,
+ ROUND(SUM(IFNULL(qu.reworkCount, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS reworkRate,
+ CAST(IF(SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0)) = 0, 0,
+ ROUND(SUM(IFNULL(ppo.scrapCount, 0)) / (SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0))) * 100, 2)) AS DECIMAL(18,2)) AS scrapRate
+ <include refid="personGroupRateJoin"/>
+ LEFT JOIN sys_user su ON su.user_id = ppm.user_id
+ <include refid="personGroupRateWhere"/>
+ GROUP BY ppm.user_id, COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('鐢ㄦ埛', ppm.user_id))
+ ORDER BY passRate DESC, totalCount DESC, dimensionId ASC
+ </select>
+
+ <select id="getGroupRateStatistics" resultType="com.ruoyi.quality.dto.QualityPersonGroupRateDto">
+ SELECT ppm.user_id AS dimensionId,
+ COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('鐝粍浜哄憳', ppm.user_id)) AS dimensionName,
+ CAST(SUM(IFNULL(qi.quantity, 0)) AS DECIMAL(18,4)) AS totalCount,
+ CAST(SUM(IFNULL(qi.qualified_quantity, 0)) AS DECIMAL(18,4)) AS qualifiedCount,
+ CAST(SUM(IFNULL(qi.unqualified_quantity, 0)) AS DECIMAL(18,4)) AS unqualifiedCount,
+ CAST(SUM(IFNULL(qu.reworkCount, 0)) AS DECIMAL(18,4)) AS reworkCount,
+ CAST(SUM(IFNULL(ppo.scrapCount, 0)) AS DECIMAL(18,4)) AS scrapCount,
+ CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0,
+ ROUND(SUM(IFNULL(qi.qualified_quantity, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS passRate,
+ CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0,
+ ROUND(SUM(IFNULL(qu.reworkCount, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS reworkRate,
+ CAST(IF(SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0)) = 0, 0,
+ ROUND(SUM(IFNULL(ppo.scrapCount, 0)) / (SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0))) * 100, 2)) AS DECIMAL(18,2)) AS scrapRate
+ <include refid="personGroupRateJoin"/>
+ LEFT JOIN sys_user su ON su.user_id = ppm.user_id
+ <include refid="personGroupRateWhere"/>
+ GROUP BY ppm.user_id, COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('鐝粍浜哄憳', ppm.user_id))
+ ORDER BY passRate DESC, totalCount DESC, dimensionId ASC
+ </select>
+
</mapper>
--
Gitblit v1.9.3