gongchunyi
3 天以前 d546e42089177442c5e43f9944052fcf3611b08d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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.QualityTestStandardMapper">
    <select id="qualityTestStandardListPage" resultType="com.ruoyi.quality.pojo.QualityTestStandard">
        SELECT
        *
        FROM quality_test_standard
        where
        1=1
        <if test="c.standardNo != null and c.standardNo != '' ">
            AND standard_no like concat('%',#{c.standardNo},'%')
        </if>
        <if test="c.standardName != null and c.standardName != '' ">
            AND standard_name like concat('%',#{c.standardName},'%')
        </if>
        <if test="c.state != null ">
            AND state =#{c.state}
        </if>
        <if test="c.inspectType != null ">
            AND inspect_type =#{c.inspectType}
        </if>
    </select>
    <select id="getQualityTestStandardByProductId" resultType="com.ruoyi.quality.dto.QualityTestStandardDto">
        SELECT DISTINCT qts.*, pm.model as product_model
        FROM quality_test_standard qts
                 left join quality_test_standard_binding qtsb on qtsb.test_standard_id = qts.id
                 left join technology_operation toper on qts.process_id = toper.id
                 left join product_model pm on qtsb.product_model_id = pm.id
        WHERE qts.inspect_type = #{inspectType}
          AND (
              qtsb.product_id = #{productId}
              or qtsb.product_id in (
                  WITH RECURSIVE product_parent AS (
                      SELECT parent_id
                      FROM product
                      WHERE id = #{productId} AND parent_id IS NOT NULL
                      UNION ALL
                      SELECT p.parent_id
                      FROM product p
                      INNER JOIN product_parent pp ON p.id = pp.parent_id
                      WHERE p.parent_id IS NOT NULL
                  )
                  SELECT parent_id FROM product_parent
              )
          )
        <if test="productModelId != null">
            and (qtsb.product_model_id is null or qtsb.product_model_id = #{productModelId})
        </if>
        <if test="process!='' and process!=null">
            and toper.name = #{process}
        </if>
        order by qtsb.product_model_id is not null, qts.id desc
    </select>
</mapper>