邱宇豪
2023-11-03 2896d6fa447cf6a678ba27ba2e19224379f14dd4
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?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.thhy.mobile.modules.biz.pipecheckrecord.mapper.PipeCheckRecordMapper">
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        t.pipe_check_id as pipeCheckId,
        t.check_reason as checkReason,
        t.check_result as checkResult,
        t.check_time as checkTime,
        t.check_user as checkUser,
        t.pipe_id as pipeId,
        t.remark as remark
    </sql>
 
    <sql id="condition_query">
        <where>
            <trim suffixOverrides=" AND ">
                <if test="checkReason!=null and checkReason!=''">
                    t.check_reason = #{checkReason} AND
                </if>
                <if test="checkResult!=null">
                    t.check_result = #{checkResult} AND
                </if>
                <if test="checkTime!=null">
                    t.check_time = #{checkTime} AND
                </if>
                <if test="checkUser!=null and checkUser!=''">
                    t.check_user = #{checkUser} AND
                </if>
                <if test="pipeId!=null and pipeId!=''">
                    t.pipe_id = #{pipeId} AND
                </if>
                <if test="remark!=null and remark!=''">
                    t.remark = #{remark} AND
                </if>
            </trim>
        </where>
    </sql>
 
    <select id="queryById" resultType="com.thhy.mobile.modules.biz.pipecheckrecord.entity.PipeCheckRecord">
        select <include refid="Base_Column_List" />
        from t_pipe_check_record t
        where t.pipe_check_id=#{pipeCheckId}
    </select>
 
    <select id="queryVersionById" resultType="integer">
        select version from t_pipe_check_record
        where pipe_check_id=#{pipeCheckId}
    </select>
 
    <!--查询列表-->
    <select id="findList" resultType="com.thhy.mobile.modules.biz.pipecheckrecord.entity.PipeCheckRecord">
        SELECT
        <include refid="Base_Column_List" />
        from t_pipe_check_record t
        <include refid="condition_query" />
    </select>
 
    <select id="pipeCheckList" resultType="com.thhy.mobile.modules.biz.pipecheckrecord.entity.PipeCheckListVo">
        select pi.pipe_id as pipeId,pi.check_result as checkResult,
        sp.pro_name as proName,pi.ring_num as ringNum,pi.pipe_num as pipeNum,sd.dict_name as sizeName,sd4.dict_name as groutingHolesName,sd1.dict_name as reinforcementName,
        sd2.dict_name as turnName,sd3.dict_name as blockNumName,sm.mould_num as mouldNum,pi.into_mod_time as intoModTime,pi.pouring_time as pouringTime,su.real_name as checkUserName,pi.check_time as checkTime,pi.produce_number as produceNumber
        from t_pipe_info pi
        -- left join t_pipe_check_record pcr on pcr.pipe_id = pi.pipe_id
        left join sys_project sp on pi.pro_id = sp.pro_id
        left join sys_dict sd on sd.dict_id = pi.size
        left join sys_dict sd1 on sd1.dict_id = pi.reinforcement
        left join sys_dict sd2 on sd2.dict_id = pi.turn
        left join sys_dict sd3 on sd3.dict_id = pi.block_num
        left join sys_dict sd4 on sd4.dict_id = pi.grouting_holes
        left join sys_mould sm on sm.mould_id = pi.mod_id
        left join sys_users su on su.user_id = pi.check_user
        <where>
            <trim suffixOverrides=" AND ">
                pi.check_result != 0 AND sp.company_id = #{companyId} AND
                <if test="checkResult!=null">
                    pi.check_result = #{checkResult} AND
                </if>
                <if test="pipeNum!=null and pipeNum!=''">
                    pi.pipe_num LIKE CONCAT('%',#{pipeNum},'%')  AND
                </if>
            </trim>
        </where>
        order by pi.check_time desc
    </select>
 
    <!--查询列表-->
    <select id="findAll" resultType="com.thhy.mobile.modules.biz.pipecheckrecord.entity.PipeCheckRecord">
        SELECT
        <include refid="Base_Column_List" />
        from t_pipe_check_record t
    </select>
 
    <!--插入操作-->
    <insert id="insert">
        insert into t_pipe_check_record
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="checkReason != null">
                check_reason,
            </if>
            <if test="checkResult != null">
                check_result,
            </if>
            <if test="checkTime != null">
                check_time,
            </if>
            <if test="checkUser != null">
                check_user,
            </if>
            <if test="pipeCheckId != null">
                pipe_check_id,
            </if>
            <if test="pipeId != null">
                pipe_id,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="existProblem != null">
                exist_problem,
            </if>
            <if test="exeProResult != null">
                exe_pro_result,
            </if>
        </trim>
 
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="checkReason != null">
                #{checkReason},
            </if>
            <if test="checkResult != null">
                #{checkResult},
            </if>
            <if test="checkTime != null">
                #{checkTime},
            </if>
            <if test="checkUser != null">
                #{checkUser},
            </if>
            <if test="pipeCheckId != null">
                #{pipeCheckId},
            </if>
            <if test="pipeId != null">
                #{pipeId},
            </if>
            <if test="remark != null">
                #{remark},
            </if>
            <if test="existProblem != null">
                #{existProblem},
            </if>
            <if test="exeProResult != null">
                #{exeProResult},
            </if>
        </trim>
    </insert>
 
    <insert id="insertCheckFile">
        insert into t_pipe_check_record
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="id != null">
                id,
            </if>
            <if test="pipeCheckId != null">
                pipe_check_id,
            </if>
            <if test="checkFile != null">
                check_file,
            </if>
        </trim>
 
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="id != null">
                #{id},
            </if>
            <if test="pipeCheckId != null">
                #{pipeCheckId},
            </if>
            <if test="checkFile != null">
                #{checkFile},
            </if>
        </trim>
    </insert>
 
 
    <!--更新操作-->
    <update id="update">
        update t_pipe_check_record
        <set>
            <if test="checkReason != null">
                check_reason=#{checkReason},
            </if>
            <if test="checkResult != null">
                check_result=#{checkResult},
            </if>
            <if test="checkTime != null">
                check_time=#{checkTime},
            </if>
            <if test="checkUser != null">
                check_user=#{checkUser},
            </if>
            <if test="pipeId != null">
                pipe_id=#{pipeId},
            </if>
            <if test="remark != null">
                remark=#{remark},
            </if>
        </set>
        where pipe_check_id=#{pipeCheckId}
    </update>
 
    <!--逻辑删除-->
    <update id="deletelogic">
        update t_pipe_check_record
        SET is_use = 0
        where pipe_check_id=#{pipeCheckId}
    </update>
 
    <!--根据ID删除-->
    <delete id="deleteById">
        delete from t_pipe_check_record
        where pipe_check_id=#{pipeCheckId}
    </delete>
 
</mapper>