叶松
2023-11-29 cdca588a565c7ba3cc22bf45c0701f5f0562783b
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<?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.materials.modules.biz.rebarprint.mapper.TSteelProduceMapper">
  <resultMap id="BaseResultMap" type="com.thhy.materials.modules.biz.rebarprint.entity.TSteelProduce">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sat May 06 09:52:00 CST 2023.
    -->
    <id column="steel_produce_id" jdbcType="VARCHAR" property="steelProduceId" />
    <result column="produce_number" jdbcType="VARCHAR" property="produceNumber" />
    <result column="pro_id" jdbcType="VARCHAR" property="proId" />
    <result column="size_id" jdbcType="VARCHAR" property="sizeId" />
    <result column="reinforcement_id" jdbcType="VARCHAR" property="reinforcementId" />
    <result column="block_num" jdbcType="VARCHAR" property="blockNum" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
    <result column="quality_time" jdbcType="TIMESTAMP" property="qualityTime" />
    <result column="quality_user" jdbcType="VARCHAR" property="qualityUser" />
    <result column="is_qualified" jdbcType="INTEGER" property="isQualified" />
    <result column="is_model" jdbcType="INTEGER" property="isModel" />
    <result column="is_user" jdbcType="INTEGER" property="isUser" />
  </resultMap>
  <select id="steelProduceList" resultType="com.thhy.materials.modules.biz.rebarprint.entity.dto.ProduceDto">
      select
      DISTINCT tsp.steel_produce_id as steelProduceId,
              tsp.size_id as sizeId,
              tsp.reinforcement_id reinforcementId,
              tsp.block_num blockNum,
              tsp.produce_number as produceNumber,
              tsp.pro_id as proId,
              sp.pro_name as proName,
              sd.dict_name as sizeName,
              sd1.dict_name as reinforcementName,
              sd2.dict_name as blockName,
              su.real_name as realName,
              sg.group_name as groupName,
              su1.real_name as qualityUserName,
              tsp.quality_time as qualityTime,
              tsp.is_qualified as isQualified,
              tsp.is_model as isModel,
              tsp.print_time as printTime,
              spu.real_name as platUserName
      from t_steel_produce tsp
      left join sys_project sp  on tsp.pro_id=sp.pro_id
      left join sys_dict  sd on tsp.size_id=sd.dict_id
      left join sys_dict  sd1 on tsp.reinforcement_id=sd1.dict_id
      left join sys_dict  sd2 on tsp.block_num=sd2.dict_id
      left join sys_users su  on tsp.create_user=su.user_id
      left join sys_users su1 on tsp.quality_user=su1.user_id
      left join t_steel_print stp on stp.steel_print_id = tsp.steel_print_id
      left join sys_plat_user spu on spu.user_id = stp.plat_user_id
      left join sys_group_user sgu on spu.user_id=sgu.user_id
      left join sys_group sg on sgu.group_id=sg.group_id
      where tsp.is_use=1
        <if test="produceNumber!=null and produceNumber!='' ">
           and  tsp.produce_number like concat('%',#{produceNumber},'%')
        </if>
        <if test="companyId!=null and companyId!='' ">
           and sp.company_id=#{companyId}
        </if>
        <if test="proId!=null and proId!='' ">
           and tsp.pro_id=#{proId}
        </if>
        <if test="blockNum!=null and blockNum!='' ">
           and tsp.block_num=#{blockNum}
        </if>
        <if test="realName!=null and realName!='' ">
            and  su.real_name like concat('%',#{realName},'%')
        </if>
        <if test="groupId!=null and groupId!='' ">
         and  sgu.group_id=#{groupId}
        </if>
        <if test="isQualified!=null and isQualified!='' ">
          and tsp.is_qualified=#{isQualified}
        </if>
        <if test="reinforcementId!=null and reinforcementId!='' ">
          and tsp.reinforcement_id=#{reinforcementId}
        </if>
        <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
            and tsp.print_time between #{strTime} and #{endTime}
        </if>
        <if test="strTimes!=null and strTimes!='' and endTimes!=null and endTimes!='' ">
          and tsp.quality_time between #{strTimes} and #{endTimes}
        </if>
        <if test="steelPrintId!=null and steelPrintId!='' ">
            and tsp.steel_print_id=#{steelPrintId}
        </if>
        <if test="isModel!=null and isModel!='' ">
            and tsp.is_model=#{isModel}
        </if>
      <if test="sizeId!=null and sizeId!='' ">
          and tsp.size_id=#{sizeId}
      </if>
      <if test="platUserName!=null and platUserName!='' ">
          and spu.real_name regexp #{platUserName}
      </if>
 
        order by tsp.produce_number desc
  </select>
    <select id="steelProduceInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.rebarprint.entity.dto.ProduceDto">
        select
                DISTINCT tsp.steel_produce_id as steelProduceId,
                         tsp.produce_number as produceNumber,
                         tsp.pro_id as proId,sp.pro_name as proName,
                         sd.dict_name as sizeName,sd1.dict_name as reinforcementName,
                         sd2.dict_name as blockName,su.real_name as realName,
                         sg.group_name as groupName,su1.real_name as qualityUserName,
                         tsp.quality_time as qualityTime,tsp.is_qualified as isQualified,
                         tsp.is_model as isModel,tsp.print_time as printTime,
                         spu.real_name as platUserName
        from t_steel_produce tsp
                     left join sys_project sp  on tsp.pro_id=sp.pro_id
                     left join sys_dict  sd on tsp.size_id=sd.dict_id
                     left join sys_dict  sd1 on tsp.reinforcement_id=sd1.dict_id
                     left join sys_dict  sd2 on tsp.block_num=sd2.dict_id
                     left join sys_users su  on tsp.create_user=su.user_id
                     left join sys_users su1 on tsp.quality_user=su1.user_id
                     left join t_steel_print stp on stp.steel_print_id = tsp.steel_print_id
                     left join sys_plat_user spu on spu.user_id = stp.plat_user_id
                     left join sys_group_user sgu on spu.user_id=sgu.user_id
                     left join sys_group sg on sgu.group_id=sg.group_id
        where tsp.is_use=1 and tsp.steel_produce_id=#{steelProduceId}
    </select>
    <select id="produceInventory" resultType="com.thhy.materials.modules.biz.rebarprint.entity.dto.ProduceInventoryDto">
        SELECT
            sp.pro_name AS proName,
            sd.dict_name AS sizeName,
            sd1.dict_name AS reinforcementName,
            sd2.dict_name AS blockName,
            COUNT( tsp.steel_produce_id ) as inventory,
            tsp.pro_id as proId,
            tsp.size_id as sizeId,
            tsp.reinforcement_id as reinforcementId,
            tsp.block_num as blockNum
        FROM
            t_steel_produce tsp
            LEFT JOIN sys_project sp ON tsp.pro_id = sp.pro_id
            LEFT JOIN sys_dict sd ON tsp.size_id = sd.dict_id
            LEFT JOIN sys_dict sd1 ON tsp.reinforcement_id = sd1.dict_id
            LEFT JOIN sys_dict sd2 ON tsp.block_num = sd2.dict_id
            where tsp.is_use=1 and tsp.is_qualified=1 and tsp.is_model!=1
        <if test="proId!=null and proId!='' ">
            and tsp.pro_id=#{proId}
        </if>
        <if test="companyId!=null and companyId!='' ">
            and sp.company_id=#{companyId}
        </if>
        <if test="sizeId!=null and sizeId!='' ">
            and tsp.size_id=#{sizeId}
        </if>
        <if test="reinforcementId!=null and reinforcementId!='' ">
            and tsp.reinforcement_id=#{reinforcementId}
        </if>
        <if test="blockNum!=null and blockNum!='' ">
            and tsp.block_num=#{blockNum}
        </if>
        GROUP BY
            tsp.pro_id,
            tsp.size_id,
            tsp.reinforcement_id,
            tsp.block_num
    </select>
    <select id="produceInventoryReinforcementId" resultType="com.thhy.materials.modules.biz.rebarprint.entity.dto.ProduceInventoryDto">
        SELECT
        sp.pro_name AS proName,
        sd.dict_name AS sizeName,
        sd1.dict_name AS reinforcementName,
        COUNT( tsp.steel_produce_id ) as inventory,
        tsp.pro_id as proId,
        tsp.size_id as sizeId,
        tsp.reinforcement_id as reinforcementId
        FROM
            t_steel_produce tsp
            LEFT JOIN sys_project sp ON tsp.pro_id = sp.pro_id
            LEFT JOIN sys_dict sd ON tsp.size_id = sd.dict_id
            LEFT JOIN sys_dict sd1 ON tsp.reinforcement_id = sd1.dict_id
            LEFT JOIN sys_dict sd2 ON tsp.block_num = sd2.dict_id
            where tsp.is_use=1 and tsp.is_qualified=1 and tsp.is_model!=1
        <if test="proId!=null and proId!='' ">
            and tsp.pro_id=#{proId}
        </if>
        <if test="companyId!=null and companyId!='' ">
            and sp.company_id=#{companyId}
        </if>
        <if test="sizeId!=null and sizeId!='' ">
            and tsp.size_id=#{sizeId}
        </if>
        <if test="reinforcementId!=null and reinforcementId!='' ">
            and tsp.reinforcement_id=#{reinforcementId}
        </if>
        <if test="blockNum!=null and blockNum!='' ">
            and tsp.block_num=#{blockNum}
        </if>
        GROUP BY
        tsp.pro_id,
        tsp.size_id,
        tsp.reinforcement_id
    </select>
    <select id="blockNumSelectAll" parameterType="java.lang.String" resultType="java.lang.String">
        select block_num from sys_pro_blok where  pro_id=#{proId}
    </select>
 
    <select id="steelProduceCheck" resultType="com.thhy.materials.modules.biz.rebarprint.entity.TSteelCheckRecord">
        select
         tscr.check_id as checkId,
         tscr.steel_produce_id as steelProduceId,
         tscr.steel_produce_num as steelProduceNum,
         tscr.check_result as checkResult,
         tscr.create_time as createTime,
         tscr.create_user as createUser,
         tscr.check_faild_reason as checkFaildReason,
         tscr.remark as remark,
         tscr.exec_result as execResult,
         tscr.exec_flag as execFlag,
         su.real_name as realName
         from t_steel_check_record tscr
        left join  sys_users su on tscr.create_user=su.user_id
        where
         tscr.steel_produce_num=#{steelProduceNum}
        ORDER BY tscr.create_time desc
         limit 0,1
    </select>
    <select id="checkInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.rebarprint.entity.dto.CheckDto">
        select reason_type as reasonType,
        reason_name as reasonName,
        reason_kind as reasonKind
         from t_check_reason
        where id=#{sId}
    </select>
    <update id="steelProduceFeedback">
        update t_steel_check_record
        <set>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="execResult != null">
                exec_result = #{execResult,jdbcType=VARCHAR},
            </if>
            <if test="execFlag != null">
                exec_flag = #{execFlag,jdbcType=INTEGER},
            </if>
        </set>
        where check_id = #{checkId,jdbcType=VARCHAR}
    </update>
 
    <select id="checkFile" parameterType="java.lang.String" resultType="java.lang.String">
        select check_file as checkFile from  t_steel_check_file where steel_check_id=#{checkId}
    </select>
 
    <select id="appProduceLooping" resultType="java.util.Map">
<!--        SELECT proName,SUM(inventory) inventory FROM (SELECT-->
<!--                                                              proName,-->
<!--                                                              COUNT(inventory) num,-->
<!--                                                              MIN(inventory) inventory-->
<!--                                                      FROM (-->
<!--                                                                   SELECT-->
<!--                                                                           sp.pro_name AS proName,-->
<!--                                                                           sd1.dict_name AS reinforcementName,-->
<!--                                                                           COUNT( tsp.steel_produce_id ) as inventory-->
<!--                                                                   FROM-->
<!--                                                                           sys_project sp-->
<!--                                                                                   LEFT JOIN t_steel_produce  tsp ON tsp.pro_id = sp.pro_id-->
<!--                                                                                   LEFT JOIN sys_dict sd ON tsp.size_id = sd.dict_id-->
<!--                                                                                   LEFT JOIN sys_dict sd1 ON tsp.reinforcement_id = sd1.dict_id-->
<!--                                                                                   LEFT JOIN sys_dict sd2 ON tsp.block_num = sd2.dict_id-->
<!--                                                                   where tsp.is_use=1 and tsp.is_qualified=1 and sp.pro_id =#{proId} and tsp.size_id = #{sizeId}-->
<!--                                                                   GROUP BY-->
<!--                                                                           tsp.pro_id,-->
<!--                                                                           tsp.size_id,-->
<!--                                                                           tsp.reinforcement_id,-->
<!--                                                                           tsp.block_num-->
<!--                                                                   ) a-->
<!--                                                      GROUP BY reinforcementName-->
<!--                                                             ) c-->
<!--        WHERE c.num=(SELECT count(id) FROM sys_pro_blok WHERE pro_id =#{proId})-->
<!--        GROUP BY proName-->
                SELECT proName,SUM(inventory) inventory FROM (SELECT
                                                                      proName,
                                                                      COUNT(inventory) num,
                                                                      MIN(inventory) inventory
                                                              FROM (
                                                                           SELECT
                                                                                   sp.pro_name AS proName,
                                                                                   sd1.dict_name AS reinforcementName,
                                                                                   COUNT( tsp.reinforcement ) as inventory
                                                                           FROM
                                                                                   sys_project sp
                                                                                           LEFT JOIN t_pipe_info  tsp ON tsp.pro_id = sp.pro_id
                                                                                           LEFT JOIN sys_dict sd ON tsp.size = sd.dict_id
                                                                                           LEFT JOIN sys_dict sd1 ON tsp.reinforcement = sd1.dict_id
                                                                                           LEFT JOIN sys_dict sd2 ON tsp.block_num = sd2.dict_id
                                                                           where tsp.check_result=1 and sp.pro_id =#{proId} and tsp.size = #{sizeId}
                                                                           GROUP BY
                                                                                   tsp.pro_id,
                                                                                   tsp.size,
                                                                                   tsp.reinforcement,
                                                                                   tsp.block_num
                                                                           ) a
                                                              GROUP BY reinforcementName
                                                                     ) c
                WHERE c.num=(SELECT count(id) FROM sys_pro_blok WHERE pro_id =#{proId})
                GROUP BY proName
    </select>
    <select id="getProName" resultType="java.lang.String">
        SELECT pro_name FROM sys_project WHERE pro_id =#{proId}
    </select>
 
    <select id="allproduceInventory" resultType="com.thhy.materials.modules.biz.rebarprint.entity.dto.ProduceInventoryDto">
        SELECT
        sp.pro_name AS proName,
        sd.dict_name AS sizeName,
        sd1.dict_name AS reinforcementName,
        sd2.dict_name AS blockName,
        COUNT( tsp.steel_produce_id ) as inventory,
        tsp.pro_id as proId,
        tsp.size_id as sizeId,
        tsp.reinforcement_id as reinforcementId,
        tsp.block_num as blockNum
        FROM
        t_steel_produce tsp
        LEFT JOIN sys_project sp ON tsp.pro_id = sp.pro_id
        LEFT JOIN sys_dict sd ON tsp.size_id = sd.dict_id
        LEFT JOIN sys_dict sd1 ON tsp.reinforcement_id = sd1.dict_id
        LEFT JOIN sys_dict sd2 ON tsp.block_num = sd2.dict_id
        where tsp.is_use=1 and tsp.is_qualified=1
        <if test="proId!=null and proId!='' ">
            and tsp.pro_id=#{proId}
        </if>
        <if test="companyId!=null and companyId!='' ">
            and sp.company_id=#{companyId}
        </if>
        <if test="sizeId!=null and sizeId!='' ">
            and tsp.size_id=#{sizeId}
        </if>
        <if test="reinforcementId!=null and reinforcementId!='' ">
            and tsp.reinforcement_id=#{reinforcementId}
        </if>
        <if test="blockNum!=null and blockNum!='' ">
            and tsp.block_num=#{blockNum}
        </if>
        GROUP BY
        tsp.pro_id,
        tsp.size_id,
        tsp.reinforcement_id,
        tsp.block_num
    </select>
 
 
 
    <select id="allProduceInventoryReinforcementId" resultType="com.thhy.materials.modules.biz.rebarprint.entity.dto.ProduceInventoryDto">
        SELECT
        sp.pro_name AS proName,
        sd.dict_name AS sizeName,
        sd1.dict_name AS reinforcementName,
        COUNT( tsp.steel_produce_id ) as inventory,
        tsp.pro_id as proId,
        tsp.size_id as sizeId,
        tsp.reinforcement_id as reinforcementId
        FROM
        t_steel_produce tsp
        LEFT JOIN sys_project sp ON tsp.pro_id = sp.pro_id
        LEFT JOIN sys_dict sd ON tsp.size_id = sd.dict_id
        LEFT JOIN sys_dict sd1 ON tsp.reinforcement_id = sd1.dict_id
        LEFT JOIN sys_dict sd2 ON tsp.block_num = sd2.dict_id
        where tsp.is_use=1 and tsp.is_qualified=1
        <if test="proId!=null and proId!='' ">
            and tsp.pro_id=#{proId}
        </if>
        <if test="companyId!=null and companyId!='' ">
            and sp.company_id=#{companyId}
        </if>
        <if test="sizeId!=null and sizeId!='' ">
            and tsp.size_id=#{sizeId}
        </if>
        <if test="reinforcementId!=null and reinforcementId!='' ">
            and tsp.reinforcement_id=#{reinforcementId}
        </if>
        <if test="blockNum!=null and blockNum!='' ">
            and tsp.block_num=#{blockNum}
        </if>
        GROUP BY
        tsp.pro_id,
        tsp.size_id,
        tsp.reinforcement_id
    </select>
 
 
 
 
 
</mapper>