From 4f45f29e6b53f4c01b414409c5000ff4e212b3d9 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 05 六月 2026 13:36:54 +0800
Subject: [PATCH] 增加eip

---
 report-server/src/main/resources/mapper/PassRateMapper.xml |  126 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 126 insertions(+), 0 deletions(-)

diff --git a/report-server/src/main/resources/mapper/PassRateMapper.xml b/report-server/src/main/resources/mapper/PassRateMapper.xml
new file mode 100644
index 0000000..b41c4e8
--- /dev/null
+++ b/report-server/src/main/resources/mapper/PassRateMapper.xml
@@ -0,0 +1,126 @@
+<?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.report.mapper.PassRateMapper">
+
+    <!-- 鍘熸潗鏂欏悎鏍肩巼 -->
+    <select id="getRawMaterialPassRate" resultType="java.util.Map">
+        SELECT
+            s.sample AS sampleName,
+            o.entrust_code AS batchNo,
+            COUNT(*) AS totalCount,
+            SUM(CASE WHEN p.ins_result = 1 THEN 1 ELSE 0 END) AS qualifiedCount,
+            SUM(CASE WHEN p.ins_result = 0 THEN 1 ELSE 0 END) AS unqualifiedCount,
+            ROUND(SUM(CASE WHEN p.ins_result = 1 THEN 1 ELSE 0 END) * 100.0 / COUNT(*), 2) AS passRate
+        FROM ins_product p
+        LEFT JOIN ins_sample s ON p.ins_sample_id = s.id
+        LEFT JOIN ins_order o ON s.ins_order_id = o.id
+        WHERE p.ins_result IS NOT NULL AND o.order_type = '1'
+        <if test="dto.startTime != null and dto.startTime != ''">
+            AND o.ins_time >= #{dto.startTime}
+        </if>
+        <if test="dto.endTime != null and dto.endTime != ''">
+            AND o.ins_time &lt;= #{dto.endTime}
+        </if>
+        <if test="dto.sampleName != null and dto.sampleName != ''">
+            AND s.sample LIKE CONCAT('%', #{dto.sampleName}, '%')
+        </if>
+        <if test="dto.supplierName != null and dto.supplierName != ''">
+            AND o.custom LIKE CONCAT('%', #{dto.supplierName}, '%')
+        </if>
+        GROUP BY s.sample, o.entrust_code
+        ORDER BY passRate ASC
+    </select>
+
+    <!-- 渚涘簲鍟嗕笉鍚堟牸缁熻 -->
+    <select id="getSupplierUnqualified" resultType="java.util.Map">
+        SELECT
+            o.custom AS supplierName,
+            COUNT(*) AS totalCount,
+            SUM(CASE WHEN p.ins_result = 0 THEN 1 ELSE 0 END) AS unqualifiedCount
+        FROM ins_product p
+        LEFT JOIN ins_sample s ON p.ins_sample_id = s.id
+        LEFT JOIN ins_order o ON s.ins_order_id = o.id
+        WHERE p.ins_result IS NOT NULL AND o.order_type = '1'
+        <if test="dto.startTime != null and dto.startTime != ''">
+            AND o.ins_time >= #{dto.startTime}
+        </if>
+        <if test="dto.endTime != null and dto.endTime != ''">
+            AND o.ins_time &lt;= #{dto.endTime}
+        </if>
+        GROUP BY o.custom
+        HAVING unqualifiedCount > 0
+        ORDER BY unqualifiedCount DESC
+    </select>
+
+    <!-- 涓嶅悎鏍奸」鐩粺璁�(鐢ㄤ簬甯曠疮鎵樺浘) -->
+    <select id="getUnqualifiedItemStats" resultType="java.util.Map">
+        SELECT
+            p.inspection_item AS itemName,
+            COUNT(*) AS unqualifiedCount
+        FROM ins_product p
+        LEFT JOIN ins_sample s ON p.ins_sample_id = s.id
+        LEFT JOIN ins_order o ON s.ins_order_id = o.id
+        WHERE p.ins_result = 0
+        <if test="dto.startTime != null and dto.startTime != ''">
+            AND o.ins_time >= #{dto.startTime}
+        </if>
+        <if test="dto.endTime != null and dto.endTime != ''">
+            AND o.ins_time &lt;= #{dto.endTime}
+        </if>
+        <if test="dto.orderType != null and dto.orderType != ''">
+            AND o.order_type = #{dto.orderType}
+        </if>
+        GROUP BY p.inspection_item
+        ORDER BY unqualifiedCount DESC
+    </select>
+
+    <!-- 宸ュ簭鍚堟牸鐜� -->
+    <select id="getProcessPassRate" resultType="java.util.Map">
+        SELECT
+            o.laboratory AS processName,
+            COUNT(*) AS totalCount,
+            SUM(CASE WHEN p.ins_result = 1 THEN 1 ELSE 0 END) AS qualifiedCount,
+            SUM(CASE WHEN p.ins_result = 0 THEN 1 ELSE 0 END) AS unqualifiedCount,
+            ROUND(SUM(CASE WHEN p.ins_result = 1 THEN 1 ELSE 0 END) * 100.0 / COUNT(*), 2) AS passRate
+        FROM ins_product p
+        LEFT JOIN ins_sample s ON p.ins_sample_id = s.id
+        LEFT JOIN ins_order o ON s.ins_order_id = o.id
+        WHERE p.ins_result IS NOT NULL
+        <if test="dto.startTime != null and dto.startTime != ''">
+            AND o.ins_time >= #{dto.startTime}
+        </if>
+        <if test="dto.endTime != null and dto.endTime != ''">
+            AND o.ins_time &lt;= #{dto.endTime}
+        </if>
+        <if test="dto.orderType != null and dto.orderType != ''">
+            AND o.order_type = #{dto.orderType}
+        </if>
+        GROUP BY o.laboratory
+        ORDER BY passRate ASC
+    </select>
+
+    <!-- 鏈哄彴涓嶅悎鏍肩粺璁� -->
+    <select id="getMachineUnqualified" resultType="java.util.Map">
+        SELECT
+            p.factory AS machineNo,
+            COUNT(*) AS totalCount,
+            SUM(CASE WHEN p.ins_result = 0 THEN 1 ELSE 0 END) AS unqualifiedCount
+        FROM ins_product p
+        LEFT JOIN ins_sample s ON p.ins_sample_id = s.id
+        LEFT JOIN ins_order o ON s.ins_order_id = o.id
+        WHERE p.ins_result IS NOT NULL
+        <if test="dto.startTime != null and dto.startTime != ''">
+            AND o.ins_time >= #{dto.startTime}
+        </if>
+        <if test="dto.endTime != null and dto.endTime != ''">
+            AND o.ins_time &lt;= #{dto.endTime}
+        </if>
+        <if test="dto.orderType != null and dto.orderType != ''">
+            AND o.order_type = #{dto.orderType}
+        </if>
+        GROUP BY p.factory
+        HAVING unqualifiedCount > 0
+        ORDER BY unqualifiedCount DESC
+    </select>
+
+</mapper>

--
Gitblit v1.9.3