jinlin
2024-07-26 bcd950216084a6208de0c636f9430e47601acc01
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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.zt.life.modules.mainPart.taskReliability.dao.OperatConditModelDao">
    <delete id="deleteByOperatConditId">
        delete
        from operat_condit_model
        where operat_condit_id = ${operatConditId}
    </delete>
 
    <select id="getList" resultType="com.zt.life.modules.mainPart.taskReliability.model.OperatConditModel">
        SELECT b.id,
               a.id                                                                   as iid,
               a.id                                                                   as product_id,
               a.pid,
               a.`NAME`                                                               as productName,
               c.model_name,
               b.model_id,
               case when b.is_disabled is null or b.is_disabled = 1 then 1 else 0 end as is_disabled,
               ${operatConditId}                                                      as operatConditId
        FROM product_model a
                 LEFT JOIN operat_condit_model b
                           ON b.product_id = a.id
                               AND b.operat_condit_id = ${operatConditId}
                 LEFT JOIN model_rbd c ON c.id = b.model_id
        WHERE a.id in (
            SELECT DATA.id
            FROM (
                     SELECT @ids as ids,
                            (SELECT @ids := GROUP_CONCAT(id)
                             FROM product_model
                             WHERE FIND_IN_SET(pid, @ids)
                            )    as cids
                     FROM product_model
                     WHERE @ids IS NOT NULL AND @ids := ${productId}
                 ) id,
                 product_model DATA
            WHERE FIND_IN_SET(DATA.id, ID.ids)
        )
          and a.product_type in (4, 3, 2, 10)
          AND a.is_delete = 0
        ORDER BY a.product_type, a.sort
    </select>
    <select id="getModelList" resultType="com.zt.life.modules.mainPart.taskReliability.model.ModelRbd">
        select *
        from model_rbd
        where product_id = ${productId}
          and is_delete = 0
    </select>
    <select id="getModelNodes" resultType="com.zt.life.modules.mainPart.taskReliability.model.ModelNodes">
        SELECT model_id, GROUP_CONCAT(node_id) as nodeIds
        FROM `model_rbd_node`
        group by model_id
    </select>
 
    <select id="getGKModelTrees" resultType="com.zt.life.modules.mainPart.taskReliability.model.OperatConditModel">
        select
        a.*
        FROM
        operat_condit_model a
        inner join operat_condit b on b.id=a.operat_condit_id
        where
        a.is_delete = 0
        and b.is_delete = 0
        <if test="productId!=null">
            and b.product_id=${productId}
        </if>
        ORDER BY a.operat_condit_id, a.product_id
    </select>
</mapper>