张磊磊
2023-10-27 cc9957409fb0001f332b6847e7ff4e834f3fdba9
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
<?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.concret.mapper.SysSteelRecordMapper">
  <resultMap id="BaseResultMap" type="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Apr 06 09:40:33 CST 2023.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="steel_id" jdbcType="VARCHAR" property="steelId" />
    <result column="stock_type" jdbcType="INTEGER" property="stockType" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="change_stock" jdbcType="DOUBLE" property="changeStock" />
    <result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
    <result column="factory_name" jdbcType="VARCHAR" property="factoryName" />
    <result column="brand" jdbcType="VARCHAR" property="brand" />
    <result column="line_code" jdbcType="VARCHAR" property="lineCode" />
    <result column="pro_id" jdbcType="VARCHAR" property="proId" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
  </resultMap>
 
  <select id="steelSelectStock" parameterType="java.lang.String" resultType="java.lang.Double">
    select stock from sys_steel where steel_id=#{steelId}
  </select>
 
  <update id="steelStockUpdate">
    update sys_steel set
    stock=#{stock}
    where steel_id=#{steelId}
  </update>
 
  <insert id="recordInsert">
    insert into sys_steel_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="steelId != null">
        steel_id,
      </if>
      <if test="stockType != null">
        stock_type,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="changeStock != null">
        change_stock,
      </if>
      <if test="supplierId != null">
        supplier_id,
      </if>
      <if test="factoryName != null">
        factory_name,
      </if>
      <if test="brand != null">
        brand,
      </if>
      <if test="lineCode != null">
        line_code,
      </if>
      <if test="proId != null">
        pro_id,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
        <if test="companyId != null">
            company_id,
        </if>
        <if test="carName != null">
            car_name,
        </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="steelId != null">
        #{steelId,jdbcType=VARCHAR},
      </if>
      <if test="stockType != null">
        #{stockType,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="changeStock != null">
        #{changeStock,jdbcType=DOUBLE},
      </if>
      <if test="supplierId != null">
        #{supplierId,jdbcType=VARCHAR},
      </if>
      <if test="factoryName != null">
        #{factoryName,jdbcType=VARCHAR},
      </if>
      <if test="brand != null">
        #{brand,jdbcType=VARCHAR},
      </if>
      <if test="lineCode != null">
        #{lineCode,jdbcType=VARCHAR},
      </if>
      <if test="proId != null">
        #{proId,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="carName != null">
        #{carName,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="recordList" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
        select ssr.id,
        ssr.steel_id as steelId,
        ssr.stock_type as stockType,
        ssr.create_time as createTime,
        ssr.change_stock as changeStock,
        ssr.supplier_id as supplierId,
        ssr.factory_name as factoryName,
        ssr.brand as brand,
        ssr.line_code as lineCode,
        ssr.pro_id as proId,
        ss.steel_name as steelName,
        ss.steel_model steelModel,
        ss.unit,
        s2.supplier_name as supplierName,
        su.real_name as realName,
        sp.pro_name as proName,
        ssr.car_name as carName
        from sys_steel_record ssr
        left join sys_steel ss on ssr.steel_id=ss.steel_id
        left join sys_supplier s2 on ssr.supplier_id=s2.id
        left join sys_users su on ssr.create_user=su.user_id
        left join sys_project sp on ssr.pro_id=sp.pro_id
        where  ssr.is_use=1
        <if test="stockType!=null and stockType!='' ">
          and ssr.stock_type=#{stockType}
        </if>
        <if test="steelId!=null and steelId!='' ">
            and ssr.steel_id=#{steelId}
        </if>
        <if test="steelName!=null and steelName!='' ">
          and ss.steel_name  like concat('%',#{steelName},'%')
        </if>
        <if test="steelModel!=null and steelModel!='' ">
          and ss.steel_model  like concat('%',#{steelModel},'%')
        </if>
        <if test="supplierId!=null and supplierId!='' ">
            and ssr.supplier_id=#{supplierId}
        </if>
        <if test="factoryName!=null and factoryName!='' ">
          and ssr.factory_name like concat('%',#{factoryName},'%')
        </if>
        <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
          and ssr.create_time between #{strTime} and #{endTime}
        </if>
        <if test="companyId!=null and companyId!='' ">
            and ss.company_id=#{companyId}
        </if>
        order by ssr.create_time desc
  </select>
  <select id="recordThingJsList" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
        select ssr.id,
        ssr.steel_id as steelId,
        ssr.stock_type as stockType,
        ssr.create_time as createTime,
        ssr.change_stock as changeStock,
        ssr.supplier_id as supplierId,
        ssr.factory_name as factoryName,
        ssr.brand as brand,
        ssr.line_code as lineCode,
        ssr.pro_id as proId,
        ss.steel_name as steelName,
        ss.steel_model steelModel,
        ss.unit,
        s2.supplier_name as supplierName,
        su.real_name as realName,
      sp.pro_name as proName
        from sys_steel_record ssr
        left join sys_steel ss on ssr.steel_id=ss.steel_id
        left join sys_supplier s2 on ssr.supplier_id=s2.id
        left join sys_users su on ssr.create_user=su.user_id
        left join sys_project sp on ssr.pro_id=sp.pro_id
        where  ssr.is_use=1
          and ssr.stock_type=2
            and ss.company_id=#{companyId}
        order by ssr.create_time desc
  </select>
  <select id="recordInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
        select
         ssr.id,
        ssr.steel_id as steelId,
        ssr.stock_type as stockType,
        ssr.create_time as createTime,
        ssr.change_stock as changeStock,
        ssr.supplier_id as supplierId,
        ssr.factory_name as factoryName,
        ssr.brand as brand,
        ssr.line_code as lineCode,
        ssr.pro_id as proId,
        ss.steel_name as steelName,
        ss.steel_model steelModel,
        ss.unit,
        s2.supplier_name as supplierName,
        su.real_name as realName
         from sys_steel_record ssr
        left join sys_steel ss on ssr.steel_id=ss.steel_id
        left join sys_supplier s2 on ssr.supplier_id=s2.id
        left join sys_users su on ssr.create_user=su.user_id
        where  ssr.is_use=1 and ssr.id=#{id}
  </select>
 
  <update id="recordDel" >
    update  sys_steel_record set
        is_use=2
    where id=#{id}
  </update>
  <update id="updateStockSteelId" >
    update sys_steel set
    stock=#{stocks}
    where steel_id=#{steelId}
  </update>
  <select id="supplierPull" parameterType="java.lang.String" resultType="java.lang.String">
        select ss.supplier_name from sys_supplier ss
        left join sys_supplier_pro  ssp on ss.id=ssp.supplier_id
        left join sys_project sp on sp.pro_id=ssp.pro_id
        where ss.is_use=1
        <if test="companyId!=null and companyId!='' ">
            and sp.company_id=#{companyId}
        </if>
        group by ssp.supplier_id,ss.supplier_name
  </select>
 
 
    <select id="supplierIdSelect" parameterType="java.lang.String" resultType="java.lang.String">
        select id from sys_supplier where is_use=1
        and supplier_name=#{supplierName}
    </select>
    <select id="steelNameAndSteelModelSelectSteelId"
            resultType="com.thhy.materials.modules.biz.concret.entity.SysSteel">
        select
         steel_id as steelId,
         steel_name as steelName,
         steel_model as steelModel,
         unit as unit,
         stock as stock,
         create_time as createTime,
         create_user as createUser,
         is_use as isUse
         from sys_steel where is_use=1
        and steel_name=#{steelName} and steel_model=#{steelModel}
    </select>
 
    <select id="recordStatisticsDay" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
        SELECT
            ss.steel_id as steelId,
            ss.steel_name as steelName,
            ss.steel_model as steelModel,
            DATE( ssr.create_time ) as getDate,
            sum( ssr.change_stock ) as changeStock
        FROM
            sys_steel_record ssr
            LEFT JOIN sys_steel ss ON ssr.steel_id = ss.steel_id
        WHERE
            ssr.stock_type = 2 and ssr.is_use=1
            <if test="steelId!=null and steelId!='' ">
                and  ssr.steel_id=#{steelId}
            </if>
            <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
                and  DATE( ssr.create_time ) between #{strTime} and #{endTime}
            </if>
            <if test="companyId!=null and companyId!='' ">
                and ss.company_id=#{companyId}
            </if>
        GROUP BY
            DATE( ssr.create_time ),
            ssr.steel_id
    </select>
    <select id="recordStatisticsMonth" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
        SELECT
    ssr.steel_id AS steelId,
    ss.steel_name AS steelName,
    ss.steel_model AS steelModel,
    CONCAT(
        CONCAT( YEAR ( ssr.create_time ), '-' ),
    IF
    ( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) )) AS getDate,
    SUM( ssr.change_stock ) AS changeStock
FROM
    sys_steel_record ssr
    LEFT JOIN sys_steel ss ON ssr.steel_id = ss.steel_id
WHERE
    ssr.stock_type = 2 and ssr.is_use=1
    <if test="steelId!=null and steelId!='' ">
        and  ssr.steel_id=#{steelId}
    </if>
        <if test="companyId!=null and companyId!='' ">
            and ss.company_id=#{companyId}
        </if>
    <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
        AND CONCAT(
        CONCAT( YEAR ( ssr.create_time ), '-' ),
        IF
        ( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) )) BETWEEN #{strTime}
        AND #{endTime}
    </if>
GROUP BY
    ssr.steel_id,
    CONCAT(
        CONCAT( YEAR ( ssr.create_time ), '-' ),
IF
    ( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) ))
    </select>
    <select id="recordSumDay" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
            SELECT
        ss.steel_id as steelId,
        ss.steel_name as steelName,
        ss.steel_model as steelModel,
        SUM( ssr.change_stock ) as changeStock
    FROM
        sys_steel ss
        JOIN sys_steel_record ssr ON ss.steel_id = ssr.steel_id
    WHERE
        ssr.stock_type = 2
        AND ssr.is_use = 1
        <if test="companyId!=null and companyId!='' ">
            and ss.company_id=#{companyId}
        </if>
        <if test="steelId!=null and steelId!='' ">
            and  ss.steel_id=#{steelId}
        </if>
        <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
            and  DATE( ssr.create_time ) between #{strTime} and #{endTime}
        </if>
    GROUP BY
        ss.steel_id
    </select>
    <select id="recordSumMonth" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
            SELECT
        ss.steel_id as steelId,
        ss.steel_name as steelName,
        ss.steel_model as steelModel,
        SUM( ssr.change_stock ) as changeStock
    FROM
        sys_steel ss
        JOIN sys_steel_record ssr ON ss.steel_id = ssr.steel_id
    WHERE
        ssr.stock_type = 2
        AND ssr.is_use = 1
        <if test="companyId!=null and companyId!='' ">
            and ss.company_id=#{companyId}
        </if>
        <if test="steelId!=null and steelId!='' ">
            and  ss.steel_id=#{steelId}
        </if>
        <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
            AND CONCAT(
            CONCAT( YEAR ( ssr.create_time ), '-' ),
            IF
            ( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) )) BETWEEN #{strTime}
            AND #{endTime}
        </if>
    GROUP BY
        ss.steel_id
    </select>
    <select id="steelPull" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteel">
        select steel_id as steelId,steel_name as steelName,
        steel_model as steelModel,unit
        from sys_steel where is_use=1
        <if test="companyId!=null and companyId!='' ">
            and company_id=#{companyId}
        </if>
        <if test="steelId!=null and steelId!='' ">
            and steel_id=#{steelId}
        </if>
    </select>
 
</mapper>