From cbadfa371df97fc26e800bef29c3829b2ce304d3 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期日, 24 五月 2026 14:47:10 +0800
Subject: [PATCH] git排除test文件
---
src/main/resources/mapper/quality/QualityInspectMapper.xml | 402 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 390 insertions(+), 12 deletions(-)
diff --git a/src/main/resources/mapper/quality/QualityInspectMapper.xml b/src/main/resources/mapper/quality/QualityInspectMapper.xml
index 4e8a057..897138e 100644
--- a/src/main/resources/mapper/quality/QualityInspectMapper.xml
+++ b/src/main/resources/mapper/quality/QualityInspectMapper.xml
@@ -1,35 +1,73 @@
<?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.ruoyi.quality.mapper.QualityInspectMapper">
- <select id="qualityInspectListPage" resultType="com.ruoyi.quality.pojo.QualityInspect">
+ <select id="qualityInspectListPage" resultType="com.ruoyi.quality.dto.QualityInspectDto">
SELECT
- *
- FROM quality_inspect
- where
+ qi.*,
+ CASE
+ WHEN (IFNULL(qi.qualified_quantity, 0) + IFNULL(qi.unqualified_quantity, 0)) = 0 THEN 0
+ ELSE ROUND(IFNULL(qi.qualified_quantity, 0) / (IFNULL(qi.qualified_quantity, 0) + IFNULL(qi.unqualified_quantity, 0)) * 100, 2)
+ END AS passRate,
+ <choose>
+ <when test="qualityInspect.inspectType == 0">
+ pl.purchase_contract_number as purchase_contract_no
+ </when>
+ <otherwise>
+ pot.work_order_no,
+ po_sales.sales_contract_no
+ </otherwise>
+ </choose>
+ FROM
+ quality_inspect qi
+ <choose>
+ <when test="qualityInspect.inspectType == 0 ">
+ LEFT JOIN purchase_ledger pl ON pl.id = qi.purchase_ledger_id
+ </when>
+ <otherwise>
+ LEFT JOIN production_product_main ppm ON qi.product_main_id = ppm.id
+ LEFT JOIN production_operation_task pot ON ppm.production_operation_task_id = pot.id
+ left join production_order po ON po.id = pot.production_order_id
+ left join (
+ select po2.id as order_id,
+ group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no
+ from production_order po2
+ left join production_plan pp2
+ on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
+ left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
+ group by po2.id
+ ) po_sales ON po_sales.order_id = po.id
+ </otherwise>
+ </choose>
+ WHERE
inspect_type=#{qualityInspect.inspectType}
<if test="qualityInspect.supplier != null and qualityInspect.supplier != '' ">
- AND supplier like concat('%',#{qualityInspect.supplier},'%')
+ AND qi.supplier like concat('%',#{qualityInspect.supplier},'%')
</if>
<if test="qualityInspect.customer != null and qualityInspect.customer != '' ">
- AND customer like concat('%',#{qualityInspect.customer},'%')
+ AND qi.customer like concat('%',#{qualityInspect.customer},'%')
</if>
<if test="qualityInspect.process != null and qualityInspect.process != '' ">
- AND process like concat('%',#{qualityInspect.process},'%')
+ AND qi.process like concat('%',#{qualityInspect.process},'%')
</if>
<if test="qualityInspect.productName != null and qualityInspect.productName != '' ">
- AND product_name like concat('%',#{qualityInspect.productName},'%')
+ AND qi.product_name like concat('%',#{qualityInspect.productName},'%')
</if>
<if test="qualityInspect.entryDateStart != null and qualityInspect.entryDateStart != '' ">
- AND check_time >= DATE_FORMAT(#{qualityInspect.entryDateStart},'%Y-%m-%d')
+ AND qi.check_time >= DATE_FORMAT(#{qualityInspect.entryDateStart},'%Y-%m-%d')
</if>
<if test="qualityInspect.entryDateEnd != null and qualityInspect.entryDateEnd != '' ">
- AND check_time <= DATE_FORMAT(#{qualityInspect.entryDateEnd},'%Y-%m-%d')
+ AND qi.check_time <= DATE_FORMAT(#{qualityInspect.entryDateEnd},'%Y-%m-%d')
</if>
- ORDER BY check_time DESC
+ ORDER BY qi.check_time DESC
</select>
+
<select id="qualityInspectExport" resultType="com.ruoyi.quality.pojo.QualityInspect">
SELECT
- *
+ qi.*,
+ CASE
+ WHEN (IFNULL(qi.qualified_quantity, 0) + IFNULL(qi.unqualified_quantity, 0)) = 0 THEN 0
+ ELSE ROUND(IFNULL(qi.qualified_quantity, 0) / (IFNULL(qi.qualified_quantity, 0) + IFNULL(qi.unqualified_quantity, 0)) * 100, 2)
+ END AS passRate
FROM quality_inspect
where
inspect_type=#{qualityInspect.inspectType}
@@ -55,4 +93,344 @@
</foreach>
</delete>
+ <select id="getInspectStatistics" resultType="com.ruoyi.quality.dto.QualityInspectStatDto">
+ SELECT qi.inspect_type AS modelType,
+
+ IFNULL(SUM(qi.quantity), 0) AS totalCount,
+
+ IFNULL(SUM(CASE
+ WHEN qi.inspect_state = 1 THEN qi.quantity
+ ELSE 0
+ END), 0) AS completedCount
+
+ FROM quality_inspect qi
+
+ GROUP BY qi.inspect_type
+
+ </select>
+
+ <select id="getPassRateStatistics" resultType="com.ruoyi.quality.dto.QualityPassRateDto">
+ SELECT qi.inspect_type AS modelType,
+
+ COALESCE(SUM(qi.quantity), 0) AS totalCount,
+
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1 THEN qi.quantity
+ ELSE 0
+ END
+ ), 0) AS completedCount,
+
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1
+ THEN qi.qualified_quantity
+ ELSE 0
+ END
+ ), 0) AS qualifiedCount,
+
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1
+ THEN qi.unqualified_quantity
+ ELSE 0
+ END
+ ), 0) AS unqualifiedCount,
+
+ /* 瀹屾垚鐜� */
+ IF(COALESCE(SUM(qi.quantity), 0) = 0, 0,
+ ROUND(
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1 THEN qi.quantity
+ ELSE 0
+ END
+ ), 0)
+ / SUM(qi.quantity) * 100, 2)
+ ) AS completionRate,
+
+ /* 鍚堟牸鐜� */
+ IF(COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1 THEN qi.quantity
+ ELSE 0
+ END
+ ), 0) = 0, 0,
+ ROUND(
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1
+ THEN qi.qualified_quantity
+ ELSE 0
+ END
+ ), 0)
+ /
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1 THEN qi.quantity
+ ELSE 0
+ END
+ ), 0) * 100, 2)
+ ) AS passRate
+
+ FROM quality_inspect qi
+
+ GROUP BY qi.inspect_type
+ ORDER BY qi.inspect_type;
+ </select>
+
+
+ <select id="getMonthlyPassRateStatistics" resultType="com.ruoyi.quality.dto.QualityMonthlyPassRateDto">
+ WITH RECURSIVE
+ months AS (SELECT 1 AS month_num
+ UNION ALL
+ SELECT month_num + 1
+ FROM months
+ WHERE month_num < 12),
+ types AS (SELECT 0 AS modelType
+ UNION ALL
+ SELECT 1
+ UNION ALL
+ SELECT 2),
+ base AS (SELECT m.month_num, t.modelType
+ FROM months m
+ CROSS JOIN types t)
+
+ SELECT CASE b.month_num
+ WHEN 1 THEN '涓�鏈�'
+ WHEN 2 THEN '浜屾湀'
+ WHEN 3 THEN '涓夋湀'
+ WHEN 4 THEN '鍥涙湀'
+ WHEN 5 THEN '浜旀湀'
+ WHEN 6 THEN '鍏湀'
+ WHEN 7 THEN '涓冩湀'
+ WHEN 8 THEN '鍏湀'
+ WHEN 9 THEN '涔濇湀'
+ WHEN 10 THEN '鍗佹湀'
+ WHEN 11 THEN '鍗佷竴鏈�'
+ WHEN 12 THEN '鍗佷簩鏈�'
+ END AS month,
+
+ b.modelType,
+
+ /* 鎬绘暟閲� */
+ COALESCE(SUM(qi.quantity), 0) AS totalCount,
+
+ /* 宸插畬鎴� */
+ COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.quantity ELSE 0 END
+ ), 0) AS completedCount,
+
+ /* 鍚堟牸 */
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1
+ THEN qi.qualified_quantity
+ ELSE 0
+ END
+ ), 0) AS qualifiedCount,
+
+ /* 涓嶅悎鏍� */
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1
+ THEN qi.unqualified_quantity
+ ELSE 0
+ END
+ ), 0) AS unqualifiedCount,
+
+ /* 瀹屾垚鐜� */
+ IF(COALESCE(SUM(qi.quantity), 0) = 0, 0,
+ ROUND(
+ COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.quantity ELSE 0 END
+ ), 0) / SUM(qi.quantity) * 100, 2
+ )
+ ) AS completionRate,
+
+ /* 鍚堟牸鐜� */
+ IF(COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.quantity ELSE 0 END
+ ), 0) = 0, 0,
+ ROUND(
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1
+ THEN qi.qualified_quantity
+ ELSE 0
+ END
+ ), 0)
+ /
+ COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.quantity ELSE 0 END
+ ), 0) * 100, 2
+ )
+ ) AS passRate
+
+ FROM base b
+ LEFT JOIN quality_inspect qi
+ ON qi.inspect_type = b.modelType
+ AND YEAR(qi.check_time) = #{year}
+ AND MONTH(qi.check_time) = b.month_num
+
+ GROUP BY b.month_num, b.modelType
+ ORDER BY b.month_num, b.modelType;
+
+ </select>
+
+ <select id="getYearlyPassRateStatistics" resultType="com.ruoyi.quality.dto.QualityPassRateDto">
+ SELECT qi.inspect_type AS modelType,
+
+ COALESCE(SUM(qi.quantity), 0) AS totalCount,
+
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1 THEN qi.quantity
+ ELSE 0
+ END
+ ), 0) AS completedCount,
+
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1 THEN qi.qualified_quantity
+ ELSE 0
+ END
+ ), 0) AS qualifiedCount,
+
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_state = 1 THEN qi.unqualified_quantity
+ ELSE 0
+ END
+ ), 0) AS unqualifiedCount,
+
+ /* 瀹屾垚鐜� */
+ IF(COALESCE(SUM(qi.quantity), 0) = 0, 0,
+ ROUND(
+ COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.quantity ELSE 0 END
+ ), 0)
+ / SUM(qi.quantity) * 100, 2)
+ ) AS completionRate,
+
+ /* 鍚堟牸鐜� */
+ IF(COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.quantity ELSE 0 END
+ ), 0) = 0, 0,
+ ROUND(
+ COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.qualified_quantity ELSE 0 END
+ ), 0)
+ /
+ COALESCE(SUM(
+ CASE WHEN qi.inspect_state = 1 THEN qi.quantity ELSE 0 END
+ ), 0) * 100, 2)
+ ) AS passRate
+
+ FROM quality_inspect qi
+ WHERE YEAR(qi.check_time) = #{year}
+ GROUP BY qi.inspect_type
+ ORDER BY qi.inspect_type;
+ </select>
+
+
+
+ <select id="getMonthlyCompletionDetails" resultType="com.ruoyi.quality.dto.QualityMonthlyDetailDto">
+ WITH RECURSIVE months AS (SELECT 1 AS month_num
+ UNION ALL
+ SELECT month_num + 1
+ FROM months
+ WHERE month_num < 12)
+ SELECT CASE m.month_num
+ WHEN 1 THEN '涓�鏈�'
+ WHEN 2 THEN '浜屾湀'
+ WHEN 3 THEN '涓夋湀'
+ WHEN 4 THEN '鍥涙湀'
+ WHEN 5 THEN '浜旀湀'
+ WHEN 6 THEN '鍏湀'
+ WHEN 7 THEN '涓冩湀'
+ WHEN 8 THEN '鍏湀'
+ WHEN 9 THEN '涔濇湀'
+ WHEN 10 THEN '鍗佹湀'
+ WHEN 11 THEN '鍗佷竴鏈�'
+ WHEN 12 THEN '鍗佷簩鏈�'
+ END AS month,
+
+ /* 鍘熸潗鏂� */
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_type = 0
+ THEN qi.quantity
+ ELSE 0
+ END
+ ), 0) AS rawMaterialCount,
+
+ /* 鍗婃垚鍝� */
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_type = 1
+ THEN qi.quantity
+ ELSE 0
+ END
+ ), 0) AS processCount,
+
+ /* 鎴愬搧 */
+ COALESCE(SUM(
+ CASE
+ WHEN qi.inspect_type = 2
+ THEN qi.quantity
+ ELSE 0
+ END
+ ), 0) AS outgoingCount
+
+ FROM months m
+ LEFT JOIN quality_inspect qi
+ ON qi.inspect_state = 1
+ AND YEAR(qi.check_time) = #{year}
+ AND MONTH(qi.check_time) = m.month_num
+
+ GROUP BY m.month_num
+ ORDER BY m.month_num;
+
+ </select>
+
+ <select id="getTopParameters" resultType="com.ruoyi.quality.dto.QualityParameterStatDto">
+ WITH parameter_counts AS (SELECT qip.parameter_item AS name,
+ COUNT(*) AS count
+ FROM quality_inspect_param qip
+ JOIN quality_inspect qi
+ ON qip.inspect_id = qi.id
+ WHERE qi.inspect_state = 1
+ AND qi.inspect_type = #{modelType} - 1
+ GROUP BY qip.parameter_item),
+ ranked AS (SELECT name,
+ count,
+ ROW_NUMBER() OVER (ORDER BY count DESC) AS rn
+ FROM parameter_counts),
+ total AS (SELECT SUM(count) AS total_count
+ FROM parameter_counts)
+
+ SELECT name,
+ count,
+ CASE
+ WHEN (SELECT total_count FROM total) = 0 THEN 0
+ ELSE ROUND(count / (SELECT total_count FROM total) * 100, 2)
+ END AS percentage
+ FROM (SELECT name, count, rn
+ FROM ranked
+ WHERE rn <= 4
+
+ UNION ALL
+
+ SELECT '鍏朵粬妫�娴�' AS name,
+ SUM(count) AS count,
+ 5 AS rn
+ FROM ranked
+ WHERE rn > 4
+ HAVING SUM(count) > 0) t
+ ORDER BY rn;
+
+ </select>
+
+
</mapper>
--
Gitblit v1.9.3