zf
2023-08-30 9ca0dc6e7833715b875cc9b6b91d5c497b2bae8b
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?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.gk.hotwork.Mapper.SafetyInspectionItemMapper" >
  <resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.SafetyInspectionItem" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="valid_flag" property="validFlag" jdbcType="TINYINT" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="create_by" property="createBy" jdbcType="VARCHAR" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
 
    <result column="element_a" property="elementA" jdbcType="BIGINT" />
    <result column="element_b" property="elementB" jdbcType="BIGINT" />
    <result column="element_c" property="elementC" jdbcType="BIGINT" />
    <result column="standardization_requirements" property="standardizationRequirements" jdbcType="VARCHAR" />
    <result column="enterprise_standard" property="enterpriseStandard" jdbcType="VARCHAR" />
    <result column="review_method" property="reviewMethod" jdbcType="VARCHAR" />
    <result column="veto" property="veto" jdbcType="VARCHAR" />
    <result column="element_a_name" property="elementAName" jdbcType="VARCHAR" />
    <result column="element_b_name" property="elementBName" jdbcType="VARCHAR" />
    <result column="element_c_name" property="elementCName" jdbcType="VARCHAR" />
 
  </resultMap>
  <select id="selectPages" resultMap="BaseResultMap">
    select a.*,
    b.name element_a_name,
    c.name element_b_name
    from safety_inspection_item as a
    left join element_management as b on a.element_a = b.id and b.valid_flag = 1
    left join element_management as c on a.element_b = c.id and c.valid_flag = 1
    where a.valid_flag = 1 and a.element_b= #{params.elementB}
  </select>
  <select id="selectCPages" resultMap="BaseResultMap">
    select a.*,
           b.name element_a_name,
           c.name element_b_name,
           d.name element_c_name
    from safety_inspection_item as a
           left join element_management as b on a.element_a = b.id and b.valid_flag = 1
           left join element_management as c on a.element_b = c.id and c.valid_flag = 1
           left join element_management as d on a.element_c = d.id and d.valid_flag = 1
    where a.valid_flag = 1 and a.element_c= #{params.elementC}
  </select>
 
  <select id="infoElementA" resultMap="BaseResultMap">
    select a.*,
           b.name element_a_name,
           c.name element_b_name,
           d.name element_c_name
    from safety_inspection_item as a
           left join element_management as b on a.element_a = b.id and b.valid_flag = 1
           left join element_management as c on a.element_b = c.id and c.valid_flag = 1
           left join element_management as d on a.element_c = d.id and d.valid_flag = 1
    where a.valid_flag = 1 and a.element_a= #{id}
  </select>
 
 
  <select id="getById" resultMap="BaseResultMap">
    select a.*,
    b.name element_a_name,
    c.name element_b_name,
    d.name element_c_name
    from safety_inspection_item as a
    left join element_management as b on a.element_a = b.id and b.valid_flag = 1
    left join element_management as c on a.element_b = c.id and c.valid_flag = 1
    left join element_management as d on a.element_c = d.id and d.valid_flag = 1
    where a.valid_flag = 1 and a.id= #{id}
  </select>
 
    <update id="updateBatch">
        <foreach collection="itemList" item="item" index="index" open="" close="" separator=";">
            update safety_inspection_item
            set
            <trim prefix="" suffix="" suffixOverrides=",">
                <if test="item.validFlag != null">
                    valid_flag = #{item.validFlag},
                </if>
                <if test="item.createTime != null and item.createTime != '' ">
                    create_time = #{item.createTime},
                </if>
                <if test="item.createBy != null and item.createBy != '' ">
                    create_by = #{item.createBy},
                </if>
                <if test="item.updateTime != null and item.updateTime != '' ">
                    update_time = #{item.updateTime},
                </if>
                <if test="item.updateBy != null and item.updateBy != '' ">
                    update_by = #{item.updateBy},
                </if>
                <if test="item.elementA != null">
                    element_a = #{item.elementA},
                </if>
                <if test="item.elementB != null">
                    element_b = #{item.elementB},
                </if>
                <if test="item.elementC != null">
                    element_c = #{item.elementC},
                </if>
                <if test="item.standardizationRequirements != null and item.standardizationRequirements != '' ">
                    standardization_requirements = #{item.standardizationRequirements},
                </if>
                <if test="item.enterpriseStandard != null and item.enterpriseStandard != '' ">
                    enterprise_standard = #{item.enterpriseStandard},
                </if>
                <if test="item.reviewMethod != null and item.reviewMethod != '' ">
                    review_method = #{item.reviewMethod},
                </if>
                <if test="item.veto != null and item.veto != '' ">
                    veto = #{item.veto},
                </if>
            </trim>
            where id=#{item.id}
        </foreach>
 
    </update>
    <update id="updateSafetyInspectionItem">
        update safety_inspection_item
        <trim prefix="set" suffix="" suffixOverrides=",">
            <if test="item.validFlag != null">
                valid_flag = #{item.validFlag},
            </if>
            <if test="item.createTime != null">
                create_time = #{item.createTime},
            </if>
            <if test="item.createBy != null and item.createBy != '' ">
                create_by = #{item.createBy},
            </if>
            <if test="item.updateTime != null">
                update_time = #{item.updateTime},
            </if>
            <if test="item.updateBy != null and item.updateBy != '' ">
                update_by = #{item.updateBy},
            </if>
            <if test="item.elementA != null">
                element_a = #{item.elementA},
            </if>
            <if test="item.elementB != null">
                element_b = #{item.elementB},
            </if>
            <if test="item.elementC != null">
                element_c = #{item.elementC},
            </if>
            <if test="item.standardizationRequirements != null and item.standardizationRequirements != '' ">
                standardization_requirements = #{item.standardizationRequirements},
            </if>
            <if test="item.enterpriseStandard != null and item.enterpriseStandard != '' ">
                enterprise_standard = #{item.enterpriseStandard},
            </if>
            <if test="item.reviewMethod != null and item.reviewMethod != '' ">
                review_method = #{item.reviewMethod},
            </if>
            <if test="item.veto != null and item.veto != '' ">
                veto = #{item.veto},
            </if>
        </trim>
        where id=#{item.id}
 
    </update>
 
</mapper>