From 4f3a98f19143865cdc1de4791e8a95d96bd40c65 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 01 八月 2025 13:27:59 +0800
Subject: [PATCH] yys 密码已重置

---
 inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml |  315 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 315 insertions(+), 0 deletions(-)

diff --git a/inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml b/inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml
new file mode 100644
index 0000000..6e4e410
--- /dev/null
+++ b/inspect-server/src/main/resources/mapper/DataAnalysisMapper.xml
@@ -0,0 +1,315 @@
+<?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.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 &lt; 7)
+        SELECT COALESCE(sub.sum, 0)      AS sum,
+               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,
+               COALESCE(sub.passRate, 0) AS passRate
+        FROM AllWeeks am
+                 LEFT JOIN (select COUNT(*)                 sum,
+                                   DAYOFWEEK(io1.send_time) searchTime,
+                                   ROUND((COUNT(*) - SUM(CASE WHEN inspect_status in (2, 4) THEN 1 ELSE 0 END)) / COUNT(*) *
+                                         100,
+                                         2)                 passRate
+                            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
+                                     left join (select is2.ins_order_id,
+                                                       is2.sample_type,
+                                                       is2.model,
+                                                       is2.sample
+                                                from ins_sample is2
+                                                group by is2.ins_order_id) ins on ins.ins_order_id = io1.id
+                            where iiq.is_finish = 1
+                              and iiq.inspect_status not in (0, 3)
+                              and (io1.send_time between #{dto.beginDate} and #{dto.endDate})
+        <if test="dto.sampleName != null and dto.sampleName != ''">
+            and ins.sample like concat('%', #{dto.sampleName}, '%')
+        </if>
+        <if test="dto.modelName != null and dto.modelName != ''">
+            and ins.model like concat('%', #{dto.modelName}, '%')
+        </if>
+        <if test="dto.supplierName != null and dto.supplierName != ''">
+            and iiq.supplier_name like concat('%', #{dto.supplierName}, '%')
+        </if>
+                            GROUP BY DAYOFWEEK(io1.send_time)
+                            having searchTime is not null) sub ON am.week = sub.searchTime
+        WHERE am.week BETWEEN 1 AND 7
+        ORDER BY am.week
+    </select>
+
+    <!-- 鑾峰彇鏈湀鐨勫師鏉愭枡淇℃伅 -->
+    <select id="getRawPassRateByBarChartByDay" resultType="java.util.Map">
+        select COUNT(*)                         sum,
+               DATE_FORMAT(io1.send_time, '%Y-%m-%d') searchTime,
+               ROUND((COUNT(*) - SUM(CASE WHEN inspect_status in (2, 4) THEN 1 ELSE 0 END)) / COUNT(*) * 100,
+                     2)                         passRate
+        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
+                 left join (select is2.ins_order_id,
+                                   is2.sample_type,
+                                   is2.model,
+                                   is2.sample
+                            from ins_sample is2
+                            group by is2.ins_order_id) ins on ins.ins_order_id = io1.id
+        where iiq.is_finish = 1
+          and iiq.inspect_status not in (0, 3)
+        and (io1.send_time between #{dto.beginDate} and #{dto.endDate})
+        <if test="dto.sampleName != null and dto.sampleName != ''">
+            and ins.sample like concat('%', #{dto.sampleName}, '%')
+        </if>
+        <if test="dto.modelName != null and dto.modelName != ''">
+            and ins.model like concat('%', #{dto.modelName}, '%')
+        </if>
+        <if test="dto.supplierName != null and dto.supplierName != ''">
+            and iiq.supplier_name like concat('%', #{dto.supplierName}, '%')
+        </if>
+        GROUP BY DATE_FORMAT(io1.send_time, '%Y-%m-%d')
+        having searchTime is not null
+        order by searchTime
+    </select>
+
+    <!-- 鑾峰彇鏈勾鐨勫師鏉愭枡淇℃伅 -->
+    <select id="getRawPassRateByBarChartByYear" resultType="java.util.Map">
+        WITH RECURSIVE AllMonths AS (SELECT 1 AS month
+                                     UNION ALL
+                                     SELECT month + 1
+                                     FROM AllMonths
+                                     WHERE month &lt; 12)
+        SELECT COALESCE(sub.sum, 0)      AS sum,
+               CASE am.month
+                   WHEN 1 THEN '1鏈�'
+                   WHEN 2 THEN '2鏈�'
+                   WHEN 3 THEN '3鏈�'
+                   WHEN 4 THEN '4鏈�'
+                   WHEN 5 THEN '5鏈�'
+                   WHEN 6 THEN '6鏈�'
+                   WHEN 7 THEN '7鏈�'
+                   WHEN 8 THEN '8鏈�'
+                   WHEN 9 THEN '9鏈�'
+                   WHEN 10 THEN '10鏈�'
+                   WHEN 11 THEN '11鏈�'
+                   WHEN 12 THEN '12鏈�'
+                END                   AS searchTime,
+               COALESCE(sub.passRate, 0) AS passRate
+        FROM AllMonths am
+                 LEFT JOIN (select COUNT(*)                         sum,
+                                   DATE_FORMAT(io1.send_time, '%m') searchTime,
+                                   ROUND((COUNT(*) - SUM(CASE WHEN inspect_status in (2, 4) THEN 1 ELSE 0 END)) /
+                                         COUNT(*) * 100,
+                                         2)                         passRate
+                            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
+                                     left join (select is2.ins_order_id,
+                                                       is2.sample_type,
+                                                       is2.model,
+                                                       is2.sample
+                                                from ins_sample is2
+                                                group by is2.ins_order_id) ins on ins.ins_order_id = io1.id
+                            where iiq.is_finish = 1
+                              and iiq.inspect_status not in (0, 3)
+                              and (io1.send_time between #{dto.beginDate} and #{dto.endDate})
+        <if test="dto.sampleName != null and dto.sampleName != ''">
+            and ins.sample like concat('%', #{dto.sampleName}, '%')
+        </if>
+        <if test="dto.modelName != null and dto.modelName != ''">
+            and ins.model like concat('%', #{dto.modelName}, '%')
+        </if>
+        <if test="dto.supplierName != null and dto.supplierName != ''">
+            and iiq.supplier_name like concat('%', #{dto.supplierName}, '%')
+        </if>
+                            GROUP BY DATE_FORMAT(io1.send_time, '%Y-%m')
+                            having searchTime is not null) sub ON am.month = sub.searchTime
+        WHERE am.month BETWEEN 1 AND 12
+        ORDER BY am.month
+    </select>
+
+    <!-- 鏌ョ湅鍘熸潗鏂欓ゼ鐘跺浘 -->
+    <select id="getRawPassRateByCake" resultType="java.util.Map">
+        select COUNT(*)                                                                                             sum,
+               (COUNT(*) - SUM(CASE WHEN inspect_status in (2, 4) THEN 1 ELSE 0 END))                               qualified,
+               (COUNT(*) - SUM(CASE WHEN inspect_status = 1 THEN 1 ELSE 0 END))                                     unQualified,
+               ROUND((COUNT(*) - SUM(CASE WHEN inspect_status in (2, 4) THEN 1 ELSE 0 END)) / COUNT(*) * 100,
+                     2) AS passRate
+        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
+                 left join (select is2.ins_order_id,
+                                   is2.sample_type,
+                                   is2.model,
+                                   is2.sample
+                            from ins_sample is2
+                            group by is2.ins_order_id) ins on ins.ins_order_id = io1.id
+        where iiq.is_finish = 1
+          and iiq.inspect_status not in (0, 3)
+          and (io1.send_time between #{dto.beginDate} and #{dto.endDate})
+        <if test="dto.sampleName != null and dto.sampleName != ''">
+            and ins.sample like concat('%', #{dto.sampleName}, '%')
+        </if>
+        <if test="dto.modelName != null and dto.modelName != ''">
+            and ins.model like concat('%', #{dto.modelName}, '%')
+        </if>
+        <if test="dto.supplierName != null and dto.supplierName != ''">
+            and iiq.supplier_name like concat('%', #{dto.supplierName}, '%')
+        </if>
+    </select>
+
+    <select id="getRawProductAnalysisAllSample" resultType="com.ruoyi.basic.dto.IfsInventoryQuantitySupplierDto">
+        select iiq.*,
+               io1.entrust_code,
+               io1.id     enter_order_id,
+               ins.id     sample_id,
+               ins.sample_type,
+               ins.sample sample_name,
+               ins.model  sample_model,
+               io1.send_time
+        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
+                 left join ins_sample  ins on ins.ins_order_id = io1.id
+        where iiq.is_finish = 1
+          and iiq.inspect_status not in (0, 3)
+        <if test="dto.beginDate != null and dto.beginDate != '' and dto.endDate != null and dto.endDate != ''">
+            and (io1.send_time between #{dto.beginDate} and #{dto.endDate})
+        </if>
+        <if test="dto.sampleName != null and dto.sampleName != ''">
+            and ins.sample like concat('%', #{dto.sampleName}, '%')
+        </if>
+        <if test="dto.modelName != null and dto.modelName != ''">
+            and ins.model like concat('%', #{dto.modelName}, '%')
+        </if>
+        <if test="dto.supplierName != null and dto.supplierName != ''">
+            and iiq.supplier_name like concat('%', #{dto.supplierName}, '%')
+        </if>
+    </select>
+
+    <!-- 鏌ヨ妫�娴嬮」闆嗗悎 -->
+    <select id="getRawProductAnalysisList" resultType="com.ruoyi.basic.dto.IfsInventoryQuantitySupplierDto">
+        select iiq.*,
+               io1.entrust_code,
+               io1.id     enter_order_id,
+               ins.id     sample_id,
+               ins.sample_type,
+               ins.sample sample_name,
+               ins.model  sample_model,
+               u.name     user_name,
+               io1.send_time
+        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
+                 left join user u on io1.create_user = u.id
+                 left join (select is2.ins_order_id,
+                                   is2.sample_type,
+                                   is2.sample_code,
+                                   is2.model,
+                                   is2.sample,
+                                   is2.id
+                            from ins_sample is2
+                            group by is2.ins_order_id) ins on ins.ins_order_id = io1.id
+        where iiq.is_finish = 1
+          and iiq.inspect_status not in (0, 3)
+        <if test="dto.beginDate != null and dto.beginDate != '' and dto.endDate != null and dto.endDate != ''">
+            and (io1.send_time between #{dto.beginDate} and #{dto.endDate})
+        </if>
+        <if test="dto.sampleName != null and dto.sampleName != ''">
+            and ins.sample like concat('%', #{dto.sampleName}, '%')
+        </if>
+        <if test="dto.modelName != null and dto.modelName != ''">
+            and ins.model like concat('%', #{dto.modelName}, '%')
+        </if>
+        <if test="dto.supplierName != null and dto.supplierName != ''">
+            and iiq.supplier_name like concat('%', #{dto.supplierName}, '%')
+        </if>
+    </select>
+    <select id="getItemValueByOrderIds" resultType="com.ruoyi.inspect.vo.RawMaterialSupplierVo">
+        select io2.id                   orderId,
+               io2.entrust_code,
+               ins.sample,
+               ins.model,
+               iiq.supplier_name,
+               (select ip.`last_value`
+                from ins_product ip
+                where concat(ip.inspection_item, ip.inspection_item_subclass) = #{itemName}
+                  and ip.ins_sample_id = ins.id
+                limit 1) lastValue
+        from ins_order io2
+                 left join ifs_inventory_quantity iiq on io2.ifs_inventory_id = iiq.id
+                 left join (select is2.ins_order_id,
+                                   is2.sample_type,
+                                   is2.sample_code,
+                                   is2.model,
+                                   is2.sample,
+                                   is2.id
+                            from ins_sample is2
+                            group by is2.ins_order_id) ins on ins.ins_order_id = io2.id
+        where io2.id in
+        <foreach collection="insOrderIds" index="index" open="(" separator="," close=")" item="val">
+            #{val}
+        </foreach>
+    </select>
+
+    <!-- 鏌ヨ鏈湀涓庝笂鏈堝悎鏍肩巼瀵规瘮 -->
+    <select id="getRawUpMonth" resultType="java.util.Map">
+        select DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') as month,
+               (select ROUND((COUNT(*) - SUM(CASE WHEN inspect_status in (2, 4) THEN 1 ELSE 0 END)) / COUNT(*) *
+                             100,
+                             2) passRate
+                from ifs_inventory_quantity iiq
+                         LEFT JOIN ins_order io1 on io1.ifs_inventory_id = iiq.id
+                    and io1.order_type = '杩涘巶妫�楠�'
+                    and io1.state != -1
+                where iiq.is_finish = 1
+                  and iiq.inspect_status not in (0, 3)
+                  and (io1.send_time between DATE_FORMAT(DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01'), INTERVAL 1 MONTH), '%Y-%m-%d %H:%i:%s')
+                    and DATE_FORMAT(LAST_DAY(DATE_SUB(NOW(), INTERVAL 1 MONTH)), '%Y-%m-%d 23:59:59'))) passRate
+        UNION ALL
+        select DATE_FORMAT(CURRENT_DATE, '%Y-%m') as month,
+               (select ROUND((COUNT(*) - SUM(CASE WHEN inspect_status in (2, 4) THEN 1 ELSE 0 END)) / COUNT(*) *
+                             100,
+                             2) passRate
+                from ifs_inventory_quantity iiq
+                         LEFT JOIN ins_order io1 on io1.ifs_inventory_id = iiq.id
+                    and io1.order_type = '杩涘巶妫�楠�'
+                    and io1.state != -1
+                where iiq.is_finish = 1
+                  and iiq.inspect_status not in (0, 3)
+                  and (io1.send_time between
+                    DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -DAY(CURDATE()) + 1 DAY), '%Y-%m-%d 00:00:00')
+                    and DATE_FORMAT(LAST_DAY(CURDATE()), '%Y-%m-%d 23:59:59'))) passRate
+    </select>
+
+    <!-- 鏌ヨ鏈湀妫�楠岀被鍨� -->
+    <select id="getOrderTypeCookie" resultType="java.util.Map">
+        select sum(order_type = '鎶芥')                  spotCheck,
+               sum(order_type = 'Customer-ordered test') customer,
+               sum(order_type = '杩涘巶妫�楠�')              enter,
+               sum(order_type = 'Quarterly inspection')  quarterly
+        from ins_order
+        where state != -1
+          and (send_time between DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 1 MONTH) + INTERVAL 1 DAY,
+                                             '%Y-%m-%d 00:00:00') and DATE_FORMAT(LAST_DAY(NOW()), '%Y-%m-%d 23:59:59'))
+
+    </select>
+</mapper>

--
Gitblit v1.9.3