From 3585c4b63185b6e83ed6ed3a255e87c7853a3e48 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 21 七月 2026 10:02:18 +0800
Subject: [PATCH] 1.合格率统计逻辑调整;2.不合格处理:新增问题类型字段;3.对接企业微信配置调整;4.班次:新增删除排班操作
---
inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml | 269 ++++++++++++++++++++++-------------------------------
1 files changed, 114 insertions(+), 155 deletions(-)
diff --git a/inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml b/inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml
index d0b90ba..aaec27f 100644
--- a/inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml
+++ b/inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml
@@ -2,66 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.inspect.mapper.DataAnalysisMapper">
- <!-- 鑾峰彇鏈懆鐨勭墿鏂欏睘鎬т俊鎭� -->
- <select id="getRawPassRateByBarChartByWeek" resultType="java.util.Map">
- WITH RECURSIVE AllWeeks AS (
- SELECT 1 AS week
- UNION ALL
- SELECT week + 1 FROM AllWeeks WHERE week < 7
- )
- SELECT
- COALESCE(sub.qualified, 0) AS qualified,
- COALESCE(sub.unQualified, 0) AS unQualified,
- CASE am.week
- WHEN 1 THEN '鏄熸湡鏃�'
- WHEN 2 THEN '鏄熸湡涓�'
- WHEN 3 THEN '鏄熸湡浜�'
- WHEN 4 THEN '鏄熸湡涓�'
- WHEN 5 THEN '鏄熸湡鍥�'
- WHEN 6 THEN '鏄熸湡浜�'
- WHEN 7 THEN '鏄熸湡鍏�'
- END AS searchTime
- FROM AllWeeks am
- LEFT JOIN (
- SELECT
- DAYOFWEEK(io1.send_time) AS week,
- SUM(CASE WHEN iiq.inspect_status = 1 THEN 1 ELSE 0 END) AS qualified,
- SUM(CASE WHEN iiq.inspect_status = 2 or iiq.inspect_status = 4 THEN 1 ELSE 0 END) AS unQualified
- FROM ifs_inventory_quantity iiq
- INNER JOIN ins_order io1
- ON io1.ifs_inventory_id = iiq.id
- LEFT JOIN (
- SELECT ins_order_id, MAX(sample) AS sample, MAX(model) AS model
- FROM ins_sample
- GROUP BY ins_order_id
- ) ins ON ins.ins_order_id = io1.id
- WHERE
- iiq.is_finish = 1
- AND iiq.inspect_status IN (1, 2,4)
- AND io1.order_type = #{dto.orderType}
- AND io1.state != -1
- AND io1.send_time BETWEEN #{dto.beginDate} AND #{dto.endDate}
-
- <if test="dto.materialProp != null and dto.materialProp.trim() != ''">
- AND IFNULL(iiq.material_prop,'') LIKE CONCAT('%',#{dto.materialProp},'%')
- </if>
- <if test="dto.sampleName != null and dto.sampleName.trim() != ''">
- AND IFNULL(ins.sample,'') LIKE CONCAT('%',#{dto.sampleName},'%')
- </if>
- <if test="dto.modelName != null and dto.modelName.trim() != ''">
- AND IFNULL(ins.model,'') LIKE CONCAT('%',#{dto.modelName},'%')
- </if>
- <if test="dto.supplierName != null and dto.supplierName.trim() != ''">
- AND IFNULL(iiq.supplier_name,'') LIKE CONCAT('%',#{dto.supplierName},'%')
- </if>
-
- GROUP BY DAYOFWEEK(io1.send_time)
- ) sub ON am.week = sub.week
- ORDER BY am.week
-
- </select>
-
-
<!-- 鑾峰彇鏈湀鐨勭墿鏂欏睘鎬т俊鎭� -->
<!-- 鑾峰彇鏈湀鐨勭墿鏂欏睘鎬т俊鎭紙鎸夊ぉ锛岃ˉ鍏ㄦ棩鏈燂級 -->
<select id="getRawPassRateByBarChartByDay" resultType="java.util.Map">
@@ -83,23 +23,27 @@
FROM AllDays ad
LEFT JOIN (
SELECT
- DATE(io1.send_time) AS day,
+ DATE(report_time) AS day,
COUNT(*) AS total,
- SUM(CASE WHEN iiq.inspect_status = 1 and (iuh.id is null) THEN 1 ELSE 0 END) AS qualified,
- SUM(CASE WHEN iiq.inspect_status != 1 or (iuh.id is not null) THEN 1 ELSE 0 END) AS unQualified
+ SUM(CASE WHEN inspect_status = 1 and (iuh_id is null) THEN 1 ELSE 0 END) AS qualified,
+ SUM(CASE WHEN inspect_status != 1 or (iuh_id is not null) THEN 1 ELSE 0 END) AS unQualified
+ FROM (SELECT
+ IFNULL(iuh.feedback_time,io1.send_time) report_time,
+ iuh.id AS iuh_id,
+ iiq.inspect_status
FROM ifs_inventory_quantity iiq
LEFT JOIN ins_order io1
ON io1.ifs_inventory_id = iiq.id
AND io1.order_type = #{dto.orderType}
AND io1.state != -1
- AND io1.send_time BETWEEN #{dto.beginDate} AND #{dto.endDate}
LEFT JOIN (
- SELECT
- MAX(iuh.id) AS id,
- iuh.inventory_quantity_id
- FROM ins_unqualified_handler iuh
- WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
- GROUP BY iuh.inventory_quantity_id
+ SELECT
+ MAX(iuh.id) AS id,
+ iuh.inventory_quantity_id,
+ iuh.feedback_time
+ FROM ins_unqualified_handler iuh
+ WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
+ GROUP BY iuh.inventory_quantity_id
) iuh ON iiq.id = iuh.inventory_quantity_id
LEFT JOIN (
SELECT ins_order_id, MAX(sample) AS sample, MAX(model) AS model
@@ -109,9 +53,9 @@
WHERE
iiq.is_finish = 1
AND iiq.inspect_status IN (1,2,4)
-
+ AND IFNULL(iuh.feedback_time,io1.send_time) BETWEEN #{dto.beginDate} AND #{dto.endDate}
<if test="dto.materialProp != null and dto.materialProp != ''">
- AND IFNULL(iiq.material_prop,'') LIKE CONCAT('%',#{dto.materialProp},'%')
+ AND iiq.material_prop = #{dto.materialProp}
</if>
<if test="dto.sampleName != null and dto.sampleName != ''">
AND IFNULL(ins.sample,'') LIKE CONCAT('%',#{dto.sampleName},'%')
@@ -123,9 +67,9 @@
AND IFNULL(iiq.supplier_name,'') LIKE CONCAT('%',#{dto.supplierName},'%')
</if>
<if test="dto.contract != null and dto.contract != ''">
- AND IFNULL(iiq.contract,'') = #{dto.contract}
- </if>
- GROUP BY DATE(io1.send_time)
+ AND iiq.contract = #{dto.contract}
+ </if>)temp
+ GROUP BY day
) sub ON ad.day = sub.day
ORDER BY ad.day
</select>
@@ -165,23 +109,28 @@
FROM AllMonths am
LEFT JOIN (
SELECT
- MONTH(io1.send_time) AS month,
- COUNT(*) AS total,
- SUM(CASE WHEN iiq.inspect_status = 1 and (iuh.id is null) THEN 1 ELSE 0 END) AS qualified,
- SUM(CASE WHEN iiq.inspect_status != 1 or (iuh.id is not null) THEN 1 ELSE 0 END) AS unQualified
+ MONTH(report_time) AS month,
+ COUNT(*) AS total,
+ SUM(CASE WHEN inspect_status = 1 and (iuh_id is null) THEN 1 ELSE 0 END) AS qualified,
+ SUM(CASE WHEN inspect_status != 1 or (iuh_id is not null) THEN 1 ELSE 0 END) AS unQualified
+ FROM (
+ SELECT
+ IFNULL(iuh.feedback_time,io1.send_time) report_time,
+ iuh.id AS iuh_id,
+ iiq.inspect_status
FROM ifs_inventory_quantity iiq
LEFT JOIN ins_order io1
ON io1.ifs_inventory_id = iiq.id
AND io1.order_type = #{dto.orderType}
AND io1.state != -1
- AND io1.send_time BETWEEN #{dto.beginDate} AND #{dto.endDate}
LEFT JOIN (
- SELECT
- MAX(iuh.id) AS id,
- iuh.inventory_quantity_id
- FROM ins_unqualified_handler iuh
- WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
- GROUP BY iuh.inventory_quantity_id
+ SELECT
+ MAX(iuh.id) AS id,
+ iuh.inventory_quantity_id,
+ iuh.feedback_time
+ FROM ins_unqualified_handler iuh
+ WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
+ GROUP BY iuh.inventory_quantity_id
) iuh ON iiq.id = iuh.inventory_quantity_id
LEFT JOIN (
SELECT ins_order_id, MAX(sample) AS sample, MAX(model) AS model
@@ -191,9 +140,10 @@
WHERE
iiq.is_finish = 1
AND iiq.inspect_status IN (1,2,4)
+ AND IFNULL(iuh.feedback_time,io1.send_time) BETWEEN #{dto.beginDate} AND #{dto.endDate}
<if test="dto.materialProp != null and dto.materialProp != ''">
- AND IFNULL(iiq.material_prop,'') LIKE CONCAT('%',#{dto.materialProp},'%')
+ AND iiq.material_prop = #{dto.materialProp}
</if>
<if test="dto.sampleName != null and dto.sampleName != ''">
AND IFNULL(ins.sample,'') LIKE CONCAT('%',#{dto.sampleName},'%')
@@ -205,9 +155,9 @@
AND IFNULL(iiq.supplier_name,'') LIKE CONCAT('%',#{dto.supplierName},'%')
</if>
<if test="dto.contract != null and dto.contract != ''">
- AND IFNULL(iiq.contract,'') = #{dto.contract}
- </if>
- GROUP BY MONTH(io1.send_time)
+ AND iiq.contract = #{dto.contract}
+ </if>)temp
+ GROUP BY month
) sub ON am.month = sub.month
ORDER BY am.month
</select>
@@ -216,21 +166,26 @@
<!-- 鏌ョ湅鐗╂枡灞炴�чゼ鐘跺浘 -->
<select id="getRawPassRateByCake" resultType="java.util.Map">
SELECT
- COUNT(*) AS sum,
- /* 鍚堟牸 */
- SUM(CASE WHEN iiq.inspect_status = 1 and (iuh.id is null) THEN 1 ELSE 0 END) AS qualified,
- /* 涓嶅悎鏍� */
- SUM(CASE WHEN iiq.inspect_status != 1 or (iuh.id is not null) THEN 1 ELSE 0 END) AS unQualified
+ COUNT(*) AS sum,
+ /* 鍚堟牸 */
+ SUM(CASE WHEN inspect_status = 1 and (iuh_id is null) THEN 1 ELSE 0 END) AS qualified,
+ /* 涓嶅悎鏍� */
+ SUM(CASE WHEN inspect_status != 1 or (iuh_id is not null) THEN 1 ELSE 0 END) AS unQualified
+ FROM (
+ SELECT
+ iiq.inspect_status,
+ iuh.id AS iuh_id
FROM ifs_inventory_quantity iiq
INNER JOIN ins_order io1
ON io1.ifs_inventory_id = iiq.id
LEFT JOIN (
- SELECT
- MAX(iuh.id) AS id,
- iuh.inventory_quantity_id
- FROM ins_unqualified_handler iuh
- WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
- GROUP BY iuh.inventory_quantity_id
+ SELECT
+ MAX(iuh.id) AS id,
+ iuh.inventory_quantity_id,
+ iuh.feedback_time
+ FROM ins_unqualified_handler iuh
+ WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
+ GROUP BY iuh.inventory_quantity_id
) iuh ON iiq.id = iuh.inventory_quantity_id
LEFT JOIN (
SELECT
@@ -246,10 +201,9 @@
AND iiq.inspect_status IN (1, 2,4)
AND io1.order_type = #{dto.orderType}
AND io1.state != -1
- AND io1.send_time BETWEEN #{dto.beginDate} AND #{dto.endDate}
-
+ AND IFNULL(iuh.feedback_time,io1.send_time) BETWEEN #{dto.beginDate} AND #{dto.endDate}
<if test="dto.materialProp != null and dto.materialProp.trim() != ''">
- AND IFNULL(iiq.material_prop, '') LIKE CONCAT('%', #{dto.materialProp}, '%')
+ AND iiq.material_prop = #{dto.materialProp}
</if>
<if test="dto.sampleName != null and dto.sampleName.trim() != ''">
AND IFNULL(ins.sample, '') LIKE CONCAT('%', #{dto.sampleName}, '%')
@@ -261,66 +215,71 @@
AND IFNULL(iiq.supplier_name, '') LIKE CONCAT('%', #{dto.supplierName}, '%')
</if>
<if test="dto.contract != null and dto.contract != ''">
- AND IFNULL(iiq.contract,'') = #{dto.contract}
+ AND iiq.contract = #{dto.contract}
</if>
+ )temp
</select>
<select id="getMaterialPropTable" resultType="com.ruoyi.inspect.dto.MaterialPropTableDTO">
SELECT
- iiq.supplier_name AS supplierName,
- COUNT(iiq.id) AS totalBatch,
- SUM(CASE WHEN iiq.inspect_status != 1 or (iuh.id is not null) THEN 1 ELSE 0 END) AS unqualifiedBatch,
- ROUND(SUM(CASE WHEN iiq.inspect_status = 1 and iuh.id is null THEN 1 ELSE 0 END) / COUNT(*)* 100, 2 ) AS passRate
- FROM ifs_inventory_quantity iiq
- INNER JOIN ins_order io1
- ON io1.ifs_inventory_id = iiq.id
- AND io1.order_type = #{dto.orderType}
- AND io1.state != -1
- AND io1.send_time BETWEEN #{dto.beginDate} AND #{dto.endDate}
- LEFT JOIN (
+ supplier_name,
+ COUNT(id) AS totalBatch,
+ SUM(CASE WHEN inspect_status != 1 or (iuh_id is not null) THEN 1 ELSE 0 END) AS unqualifiedBatch,
+ ROUND(SUM(CASE WHEN inspect_status = 1 and iuh_id is null THEN 1 ELSE 0 END) / COUNT(*)* 100, 2 ) AS passRate
+ FROM
+ (
SELECT
- MAX(iuh.id) AS id,
- iuh.inventory_quantity_id
- FROM ins_unqualified_handler iuh
- WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
- GROUP BY iuh.inventory_quantity_id
- ) iuh ON iiq.id = iuh.inventory_quantity_id
- LEFT JOIN (
- SELECT
- ins_order_id,
- MAX(sample) AS sample,
- MAX(model) AS model
- FROM ins_sample
- GROUP BY ins_order_id
- ) ins ON ins.ins_order_id = io1.id
+ iiq.supplier_name,
+ iiq.id,
+ iuh.id AS iuh_id,
+ iiq.inspect_status
+ FROM ifs_inventory_quantity iiq
+ INNER JOIN ins_order io1
+ ON io1.ifs_inventory_id = iiq.id
+ AND io1.order_type = #{dto.orderType}
+ AND io1.state != -1
+ LEFT JOIN (
+ SELECT
+ MAX(iuh.id) AS id,
+ iuh.inventory_quantity_id,
+ iuh.feedback_time
+ FROM ins_unqualified_handler iuh
+ WHERE iuh.oa_state !=4 AND iuh.oa_state is not null
+ GROUP BY iuh.inventory_quantity_id
+ ) iuh ON iiq.id = iuh.inventory_quantity_id
+ LEFT JOIN (
+ SELECT
+ ins_order_id,
+ MAX(sample) AS sample,
+ MAX(model) AS model
+ FROM ins_sample
+ GROUP BY ins_order_id
+ ) ins ON ins.ins_order_id = io1.id
+ WHERE
+ iiq.is_finish = 1
+ AND iiq.inspect_status IN (1,2,4)
+ AND IFNULL(iuh.feedback_time,io1.send_time) between #{dto.beginDate} and #{dto.endDate}
+ <if test="dto.materialProp != null and dto.materialProp != ''">
+ AND iiq.material_prop = #{dto.materialProp}
+ </if>
- WHERE
- iiq.is_finish = 1
- AND iiq.inspect_status IN (1,2,4)
+ <if test="dto.sampleName != null and dto.sampleName != ''">
+ AND IFNULL(ins.sample,'') LIKE CONCAT('%',#{dto.sampleName},'%')
+ </if>
- <if test="dto.materialProp != null and dto.materialProp != ''">
- AND IFNULL(iiq.material_prop,'') LIKE CONCAT('%',#{dto.materialProp},'%')
- </if>
+ <if test="dto.modelName != null and dto.modelName != ''">
+ AND IFNULL(ins.model,'') LIKE CONCAT('%',#{dto.modelName},'%')
+ </if>
- <if test="dto.sampleName != null and dto.sampleName != ''">
- AND IFNULL(ins.sample,'') LIKE CONCAT('%',#{dto.sampleName},'%')
- </if>
-
- <if test="dto.modelName != null and dto.modelName != ''">
- AND IFNULL(ins.model,'') LIKE CONCAT('%',#{dto.modelName},'%')
- </if>
-
- <if test="dto.supplierName != null and dto.supplierName != ''">
- AND IFNULL(iiq.supplier_name,'') LIKE CONCAT('%',#{dto.supplierName},'%')
- </if>
- <if test="dto.contract != null and dto.contract != ''">
- AND IFNULL(iiq.contract,'') = #{dto.contract}
- </if>
- GROUP BY
- iiq.supplier_name
-
- ORDER BY
- passRate DESC;
+ <if test="dto.supplierName != null and dto.supplierName != ''">
+ AND IFNULL(iiq.supplier_name,'') LIKE CONCAT('%',#{dto.supplierName},'%')
+ </if>
+ <if test="dto.contract != null and dto.contract != ''">
+ AND iiq.contract = #{dto.contract}
+ </if>
+ )temp
+ GROUP BY supplier_name
+ ORDER BY passRate DESC;
</select>
--
Gitblit v1.9.3