张磊磊
2023-11-01 7dcbd445ad33d7abc0689f80ba56f5b3f7e21e4d
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
<?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.SysSteelMapper">
  <resultMap id="BaseResultMap" type="com.thhy.materials.modules.biz.concret.entity.SysSteel">
    <id column="steel_id" jdbcType="VARCHAR" property="steelId" />
    <result column="steel_name" jdbcType="VARCHAR" property="steelName" />
    <result column="steel_model" jdbcType="VARCHAR" property="steelModel" />
    <result column="unit" jdbcType="VARCHAR" property="unit" />
    <result column="stock" jdbcType="DOUBLE" property="stock" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
    <result column="is_use" jdbcType="INTEGER" property="isUse" />
    <result column="alarm_count" jdbcType="DOUBLE" property="alarmCount" />
  </resultMap>
 
  <select id="steelNameAndModelByOne" resultType="java.lang.String">
    select steel_id from sys_steel where  is_use=1
    and steel_name=#{steelName} and steel_model=#{steelModel} and company_id=#{companyId}
  </select>
 
  <insert id="steelInsert" >
    insert into sys_steel
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="steelId != null">
        steel_id,
      </if>
      <if test="steelName != null">
        steel_name,
      </if>
      <if test="steelModel != null">
        steel_model,
      </if>
      <if test="unit != null">
        unit,
      </if>
      <if test="stock != null">
        stock,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
      <if test="isUse != null">
        is_use,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="steelId != null">
        #{steelId,jdbcType=VARCHAR},
      </if>
      <if test="steelName != null">
        #{steelName,jdbcType=VARCHAR},
      </if>
      <if test="steelModel != null">
        #{steelModel,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        #{unit,jdbcType=VARCHAR},
      </if>
      <if test="stock != null">
        #{stock,jdbcType=DOUBLE},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="isUse != null">
        #{isUse,jdbcType=INTEGER},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="steelList" 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,
      alarm_count as alarmCount
     from sys_steel where is_use=1
    <if test="steelName!=null and steelName!='' ">
        and steel_name like concat('%',#{steelName},'%')
    </if>
    <if test="steelModel!=null and steelModel!='' ">
        and steel_model like concat('%',#{steelModel},'%')
    </if>
    <if test="companyId!=null and companyId!='' ">
      and company_id=#{companyId}
    </if>
    order by create_time desc
  </select>
  <select id="steelThingJsList" 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
    <if test="companyId!=null and companyId!='' ">
      and company_id=#{companyId}
    </if>
    order by create_time desc
  </select>
  <update id="steelDel">
    update sys_steel set
    is_use=2
    where steel_id=#{steelId}
  </update>
 
  <select id="steelInfo" parameterType="java.lang.String" 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_id=#{steelId}
  </select>
  
  <update id="steelUpdate">
    update sys_steel
    <set>
      <if test="steelName != null">
        steel_name = #{steelName,jdbcType=VARCHAR},
      </if>
      <if test="steelModel != null">
        steel_model = #{steelModel,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        unit = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="stock != null">
        stock = #{stock,jdbcType=DOUBLE},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        create_user = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="isUse != null">
        is_use = #{isUse,jdbcType=INTEGER},
      </if>
    </set>
    where steel_id = #{steelId,jdbcType=VARCHAR}
  </update>
  <update id="steelStockUp" >
    update sys_steel set
    stock=#{correctionAfter}
    where steel_id=#{steelId}
  </update>
 
  <insert id="steelCheckInsert" >
    insert into sys_steel_correction
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="ids != null">
        id,
      </if>
      <if test="steelId != null">
        steel_id,
      </if>
      <if test="correctionBefore != null">
        correction_before,
      </if>
      <if test="correctionNum != null">
        correction_num,
      </if>
      <if test="correctionAfter != null">
        correction_after,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="ids != null">
        #{ids,jdbcType=VARCHAR},
      </if>
      <if test="steelId != null">
        #{steelId,jdbcType=VARCHAR},
      </if>
      <if test="correctionBefore != null">
        #{correctionBefore,jdbcType=VARCHAR},
      </if>
      <if test="correctionNum != null">
        #{correctionNum,jdbcType=VARCHAR},
      </if>
      <if test="correctionAfter != null">
        #{correctionAfter,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="steelCheckList" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteelCorrection">
        select
        ssc.id,
        ssc.steel_id as  steelId,
        ssc.correction_before as  correctionBefore,
        ssc.correction_num as  correctionNum,
        ssc.correction_after as  correctionAfter,
        ssc.remark as  remark,
        ssc.create_time as  createTime,
        ss.steel_name as steelName,
        ss.steel_model as steelModel,
        su.real_name as realName,
        ss.unit from sys_steel_correction ssc
        left join sys_steel ss  on ssc.steel_id=ss.steel_id
        left join sys_users  su on ssc.create_user=su.user_id
        where 1=1
        <if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
            and ssc.create_time between #{strTime} and #{endTime}
        </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="steelId!=null and steelId!='' ">
          and ssc.steel_id=#{steelId}
        </if>
        <if test="companyId!=null and companyId!='' ">
          and ss.company_id=#{companyId}
        </if>
        order by ssc.create_time desc
  </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>
  </select>
  <select id="steelCorrection" parameterType="java.lang.String" resultType="java.lang.String">
    select id from sys_steel_record where steel_id=#{steelId} and is_use=1
  </select>
 
  <update id="steelAlertSettings">
    update sys_steel set
            alarm_count=#{alarmCount}
    where steel_id=#{steelId}
  </update>
 
  <select id="selectsteelAlert" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteel">
    SELECT
            concat(steel_name,'-',steel_model) steelName
    FROM sys_steel WHERE alarm_count > stock
  </select>
 
  <select id="restDataByOne" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.concret.entity.dto.RestDataByOneDto">
        select
         id,
         device_id as deviceId,
         tem,
         hum,
         check_time as checkTime
         from  t_rest_data where
        device_id=#{deviceId}
        order by  check_time desc
  </select>
 
</mapper>