张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?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.steelproduce.mapper.SteelProduceMapper">
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        t.steel_produce_id as steelProduceId,
        t.block_num as blockNum,
        t.create_user as createUser,
        t.is_model as isModel,
        t.is_qualified as isQualified,
        t.is_use as isUse,
        t.pro_id as proId,
        t.produce_number as produceNumber,
        t.quality_time as qualityTime,
        t.quality_user as qualityUser,
        t.reinforcement_id as reinforcementId,
        t.size_id as sizeId
    </sql>
 
    <sql id="condition_query">
        <where>
            <trim suffixOverrides=" AND ">
                <if test="blockNum!=null and blockNum!=''">
                    t.block_num = #{blockNum} AND
                </if>
                <if test="createUser!=null and createUser!=''">
                    t.create_user = #{createUser} AND
                </if>
                <if test="isModel!=null">
                    t.is_model = #{isModel} AND
                </if>
                <if test="isQualified!=null">
                    t.is_qualified = #{isQualified} AND
                </if>
                <if test="isUse!=null">
                    t.is_use = #{isUse} AND
                </if>
                <if test="proId!=null and proId!=''">
                    t.pro_id = #{proId} AND
                </if>
                <if test="produceNumber!=null and produceNumber!=''">
                    t.produce_number = #{produceNumber} AND
                </if>
                <if test="qualityTime!=null">
                    t.quality_time = #{qualityTime} AND
                </if>
                <if test="qualityUser!=null and qualityUser!=''">
                    t.quality_user = #{qualityUser} AND
                </if>
                <if test="reinforcementId!=null and reinforcementId!=''">
                    t.reinforcement_id = #{reinforcementId} AND
                </if>
                <if test="sizeId!=null and sizeId!=''">
                    t.size_id = #{sizeId} AND
                </if>
            </trim>
        </where>
    </sql>
 
    <select id="queryById" resultType="com.thhy.mobile.modules.biz.steelproduce.entity.SteelProduce">
        select <include refid="Base_Column_List" />
        from t_steel_produce t
        where t.steel_produce_id=#{steelProduceId}
    </select>
 
    <select id="queryByProduceNum" resultType="com.thhy.mobile.modules.biz.steelproduce.entity.SteelProduce">
        select <include refid="Base_Column_List" />
        from t_steel_produce t
        where t.produce_number = #{produceNumber}
    </select>
 
    <select id="queryVersionById" resultType="integer">
        select version from t_steel_produce
        where steel_produce_id=#{steelProduceId}
    </select>
 
    <!--查询列表-->
    <select id="findList" resultType="com.thhy.mobile.modules.biz.steelproduce.entity.SteelProduce">
        SELECT
        <include refid="Base_Column_List" />
        from t_steel_produce t
        <include refid="condition_query" />
    </select>
 
    <!--查询列表-->
    <select id="findAll" resultType="com.thhy.mobile.modules.biz.steelproduce.entity.SteelProduce">
        SELECT
        <include refid="Base_Column_List" />
        from t_steel_produce t
    </select>
 
    <!--插入操作-->
    <insert id="insert" useGeneratedKeys="true" keyProperty="steelProduceId">
        insert into t_steel_produce
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="blockNum != null">
                block_num,
            </if>
            <if test="createUser != null">
                create_user,
            </if>
            <if test="isModel != null">
                is_model,
            </if>
            <if test="isQualified != null">
                is_qualified,
            </if>
            <if test="isUse != null">
                is_use,
            </if>
            <if test="proId != null">
                pro_id,
            </if>
            <if test="produceNumber != null">
                produce_number,
            </if>
            <if test="qualityTime != null">
                quality_time,
            </if>
            <if test="qualityUser != null">
                quality_user,
            </if>
            <if test="reinforcementId != null">
                reinforcement_id,
            </if>
            <if test="sizeId != null">
                size_id,
            </if>
            <if test="steelProduceId != null">
                steel_produce_id,
            </if>
            <if test="createFlag != null">
                create_flag,
            </if>
        </trim>
 
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="blockNum != null">
                #{blockNum},
            </if>
            <if test="createUser != null">
                #{createUser},
            </if>
            <if test="isModel != null">
                #{isModel},
            </if>
            <if test="isQualified != null">
                #{isQualified},
            </if>
            <if test="isUse != null">
                #{isUse},
            </if>
            <if test="proId != null">
                #{proId},
            </if>
            <if test="produceNumber != null">
                #{produceNumber},
            </if>
            <if test="qualityTime != null">
                #{qualityTime},
            </if>
            <if test="qualityUser != null">
                #{qualityUser},
            </if>
            <if test="reinforcementId != null">
                #{reinforcementId},
            </if>
            <if test="sizeId != null">
                #{sizeId},
            </if>
            <if test="steelProduceId != null">
                #{steelProduceId},
            </if>
            <if test="createFlag != null">
                #{createFlag},
            </if>
        </trim>
    </insert>
 
 
    <!--更新操作-->
    <update id="update">
        update t_steel_produce
        <set>
            <if test="blockNum != null">
                block_num=#{blockNum},
            </if>
            <if test="createUser != null">
                create_user=#{createUser},
            </if>
            <if test="isModel != null">
                is_model=#{isModel},
            </if>
            <if test="isQualified != null">
                is_qualified=#{isQualified},
            </if>
            <if test="isUser != null">
                is_user=#{isUser},
            </if>
            <if test="proId != null">
                pro_id=#{proId},
            </if>
            <if test="produceNumber != null">
                produce_number=#{produceNumber},
            </if>
            <if test="qualityTime != null">
                quality_time=#{qualityTime},
            </if>
            <if test="qualityUser != null">
                quality_user=#{qualityUser},
            </if>
            <if test="reinforcementId != null">
                reinforcement_id=#{reinforcementId},
            </if>
            <if test="sizeId != null">
                size_id=#{sizeId},
            </if>
        </set>
        where steel_produce_id=#{steelProduceId}
    </update>
 
    <!--逻辑删除-->
    <update id="deletelogic">
        update t_steel_produce
        SET is_use = 0
        where steel_produce_id=#{steelProduceId}
    </update>
 
    <!--根据ID删除-->
    <delete id="deleteById">
        delete from t_steel_produce
        where steel_produce_id=#{steelProduceId}
    </delete>
    
    <update id="updateQualified">
        update t_steel_produce set is_qualified = #{isQualified},quality_user=#{qualityUser},is_check=1,quality_time = sysdate() where produce_number =#{produceNumber}
    </update>
 
    <select id="queryCheckList" resultType="com.thhy.mobile.modules.biz.steelcheck.entity.SteelCheckListVo">
        select sp.pro_id as proId,sp.pro_name as proName,tsp.produce_number as produceNumber,tsp.is_qualified as isQualified
                ,sd.dict_name as sizeName,sd1.dict_name as  reinforcementName,sd2.dict_name as blockNumName,
               su.real_name as opUserName,sg.group_name as groupName,tsp.quality_time as qualityTime,tsp.quality_user as qualityUser,
                su1.real_name as qualityUserName
        from t_steel_produce tsp
                 left join sys_project sp on tsp.pro_id = sp.pro_id
                 left join sys_dict sd on sd.dict_id = tsp.size_id
                 left join sys_dict sd1 on sd1.dict_id = tsp.reinforcement_id
                 left join sys_dict sd2 on sd2.dict_id = tsp.block_num
                 left join sys_users su on su.user_id = tsp.create_user
                 left join sys_plat_user spu on su.plat_id = spu.user_id
                 left join sys_group_user sgu on spu.user_id = sgu.user_id
                 left join sys_group sg on sg.group_id = sgu.group_id
                 left join sys_users su1 on tsp.quality_user = su1.user_id
 
        <where>
            <trim suffixOverrides=" AND ">
                tsp.is_check = 1 and sp.company_id = #{companyId} and
                <if test="isQualified !=null and isQualified!=''">
                    tsp.is_qualified = #{isQualified} AND
                </if>
                <if test="produceNumber !=null and produceNumber!=''">
                    tsp.produce_number LIKE concat('%',#{produceNumber},'%') AND
                </if>
            </trim>
 
        </where>
 
 
        order by tsp.quality_time desc
    </select>
 
    <select id="queryQualifiedSteel" resultType="com.thhy.mobile.modules.biz.steelcheck.entity.SteelCheckListVo">
        select sp.pro_id as proId,sp.pro_name as proName,tsp.produce_number as produceNumber,tsp.is_qualified as isQualified
        ,sd.dict_name as sizeName,sd1.dict_name as  reinforcementName,sd2.dict_name as blockNumName,
        su.real_name as opUserName,sg.group_name as groupName,tsp.quality_time as qualityTime,tsp.quality_user as qualityUser,
        su1.real_name as qualityUserName
        from t_steel_produce tsp
        left join sys_project sp on tsp.pro_id = sp.pro_id
        left join sys_dict sd on sd.dict_id = tsp.size_id
        left join sys_dict sd1 on sd1.dict_id = tsp.reinforcement_id
        left join sys_dict sd2 on sd2.dict_id = tsp.block_num
        left join sys_users su on su.user_id = tsp.create_user
        left join sys_plat_user spu on su.plat_id = spu.user_id
        left join sys_group_user sgu on spu.user_id = sgu.user_id
        left join sys_group sg on sg.group_id = sgu.group_id
        left join sys_users su1 on tsp.quality_user = su1.user_id
 
        <where>
            <trim suffixOverrides=" AND ">
                tsp.is_check = 1 and sp.company_id = #{companyId} and
                <if test="isQualified !=null and isQualified!=''">
                    tsp.is_qualified = #{isQualified} AND
                </if>
                <if test="produceNumber !=null and produceNumber!=''">
                    tsp.produce_number LIKE concat('%',#{produceNumber},'%') AND
                </if>
            </trim>
 
        </where>
 
 
        order by tsp.quality_time desc
    </select>
 
    <select id="SteelPullDown" resultType="hashmap">
        select tsp.produce_number as produceNumber,tsp.is_qualified as isQualified
        from t_steel_produce tsp
                 left join sys_project sp on tsp.pro_id = sp.pro_id
        where tsp.is_check = 1 and tsp.is_use = 1 and sp.pro_id = #{proId} and sp.company_id = #{companyId}
    </select>
 
    <select id="queryFreeMould" resultType="hashmap">
        SELECT sm.mould_id as mouldId,CONCAT('编号:[',mould_num,']-型号:[',mould_code,']') as mouldName
        from sys_mould sm
                 left join sys_project sp on sp.pro_id = sm.pro_id
        where sm.free = 1 and sm.is_use = 1 and sp.pro_id = #{proId} and sp.company_id = #{companyId}
    </select>
 
    <select id="queryProNumByProduce" resultType="string">
        select sp.pro_number
        from t_steel_produce tsp
        left join sys_project sp on sp.pro_id = tsp.pro_id
        where tsp.produce_number = #{produceNumber}
    </select>
 
    <select id="queryProNumByProject" resultType="string">
        select tsp.pro_number
        from sys_project tsp
        where tsp.pro_id = #{proId}
    </select>
 
    <select id="monthProduce" resultType="com.thhy.mobile.modules.biz.steelproduce.entity.ProduceMonthVo">
        select DATE_FORMAT(a.`month`,'%Y-%m') as `month`, case when b.count is NULL then 0 else b.count end as count from
        (SELECT @s := DATE_ADD(@s,INTERVAL 1 MONTH) as `month` FROM mysql.help_topic,(SELECT @s := DATE_ADD(#{startTime},INTERVAL -2 MONTH)) temp WHERE @s &lt; #{endTime}) a
        left join
        (select a.ym,count(a.steel_produce_id) as count from
        (select DATE_FORMAT(sp.quality_time,'%Y-%m') as ym,sp.steel_produce_id from t_steel_produce sp
            left join sys_project pro on sp.pro_id = pro.pro_id
            where sp.is_check = 1 and sp.is_qualified = 1 and pro.company_id = #{companyId}) a
        group by a.ym) b on DATE_FORMAT(a.`month`,'%Y-%m') = b.ym
        order by DATE_FORMAT(a.`month`,'%Y-%m')
    </select>
 
    <update id="updateisModel">
        update t_steel_produce set is_model = #{isModel} where produce_number = #{produceNumber}
    </update>
 
    <select id="getH5SteelProduce" resultType="java.util.Map">
        SELECT
                tsp.produce_number AS produceNumber,
                sp.pro_name AS proName,
                sd5.dict_name AS sizeName,
                sd2.dict_name AS reinforcementName,
                sd4.dict_name AS blockNumName,
                su1.real_name AS createUserName,
                su2.real_name AS steelCheckUserName,
 
                tsp.quality_time AS pipeCheckTime,
                tsp.print_time AS printTime,
                tpi.into_mod_time AS intoModTime,
                su.real_name AS pipeCheckUserName
        FROM
                t_steel_produce tsp
                        LEFT JOIN t_pipe_info tpi ON tsp.produce_number = tpi.produce_number
                        LEFT JOIN sys_dict sd2 ON sd2.dict_id = tsp.reinforcement_id
                        LEFT JOIN sys_dict sd4 ON sd4.dict_id = tsp.block_num
                        LEFT JOIN sys_dict sd5 ON sd5.dict_id = tsp.size_id
                        LEFT JOIN sys_project sp ON sp.pro_id = tsp.pro_id
                        LEFT JOIN sys_users su ON su.user_id = tpi.check_user
                        LEFT JOIN sys_users su1 ON su1.user_id = tsp.create_user
                        LEFT JOIN sys_users su2 ON su2.user_id = tsp.quality_user
 
        where tsp.produce_number =#{num}
    </select>
</mapper>