邱宇豪
2023-10-26 a12423474cd5384898fb91dba49dea23931f7b9a
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
<?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.engineering.modules.biz.device.mapper.SysDeviceMapper">
  <resultMap id="BaseResultMap" type="com.thhy.engineering.modules.biz.device.entity.SysDevice">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 11 13:19:52 CST 2023.
    -->
    <id column="device_id" jdbcType="VARCHAR" property="deviceId" />
    <result column="device_name" jdbcType="VARCHAR" property="deviceName" />
    <result column="sn_code" jdbcType="VARCHAR" property="snCode" />
    <result column="produce_order" jdbcType="VARCHAR" property="produceOrder" />
    <result column="company_id" jdbcType="VARCHAR" property="companyId" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
  </resultMap>
 
 
  <select id="deviceNameOrSNByOne" resultType="com.thhy.engineering.modules.biz.device.entity.SysDevice">
        select device_id as deviceId,
            device_name as deviceName,
            sn_code as snCode
        from sys_device where is_use=1 and
        company_id=#{companyId} and
        (device_name=#{deviceName} or sn_code=#{snCode})
  </select>
 
  <insert id="deviceInsert">
    insert into sys_device
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="deviceId != null">
        device_id,
      </if>
      <if test="deviceName != null">
        device_name,
      </if>
      <if test="snCode != null">
        sn_code,
      </if>
      <if test="produceOrder != null">
        produce_order,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
      <if test="deviceType != null">
          device_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="deviceId != null">
        #{deviceId,jdbcType=VARCHAR},
      </if>
      <if test="deviceName != null">
        #{deviceName,jdbcType=VARCHAR},
      </if>
      <if test="snCode != null">
        #{snCode,jdbcType=VARCHAR},
      </if>
      <if test="produceOrder != null">
        #{produceOrder,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="deviceType != null">
        #{deviceType,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
 
  <select id="deviceList" resultType="com.thhy.engineering.modules.biz.device.entity.SysDevice">
        select
      sd.device_id as deviceId,
      sd.device_name as deviceName,
      sd.sn_code as snCode,
      sd.produce_order as produceOrder,
      sd.device_type as deviceType,
      sd2.dict_name as deviceTypeName
         from sys_device sd
         left join sys_dict sd2 on sd.device_type=sd2.dict_id
         where sd.is_use=1
        <if test="deviceName!=null and deviceName!='' ">
            and sd.device_name like concat('%',#{deviceName},'%')
        </if>
        <if test="companyId!=null and companyId!='' ">
            and sd.company_id=#{companyId}
        </if>
        order by sd.create_time desc
  </select>
  <select id="deviceInfo" parameterType="java.lang.String" resultType="com.thhy.engineering.modules.biz.device.entity.SysDevice">
        select
          sd.device_id as deviceId,
          sd.device_name as deviceName,
          sd.sn_code as snCode,
          sd.produce_order as produceOrder,
          sd.device_type as deviceType,
          sd2.dict_name as deviceTypeName
         from sys_device sd
         left join sys_dict sd2 on sd.device_type=sd2.dict_id
         where sd.is_use=1
         and sd.device_id=#{deviceId}
  </select>
 
  <update id="deviceUpdate">
      update sys_device
      <set>
        <if test="deviceName != null">
          device_name = #{deviceName,jdbcType=VARCHAR},
        </if>
        <if test="snCode != null">
          sn_code = #{snCode,jdbcType=VARCHAR},
        </if>
        <if test="produceOrder != null">
          produce_order = #{produceOrder,jdbcType=VARCHAR},
        </if>
        <if test="companyId != null">
          company_id = #{companyId,jdbcType=VARCHAR},
        </if>
        <if test="createTime != null">
          create_time = #{createTime,jdbcType=TIMESTAMP},
        </if>
        <if test="createUser != null">
          create_user = #{createUser,jdbcType=VARCHAR},
        </if>
        <if test="deviceType != null">
            device_type = #{deviceType,jdbcType=VARCHAR},
        </if>
      </set>
      where device_id = #{deviceId,jdbcType=VARCHAR}
  </update>
  <update id="deviceDel" parameterType="java.lang.String" >
    update sys_device
    set
    is_use=2
    where device_id=#{deviceId}
  </update>
 
  <select id="selectBySteamIds" parameterType="java.lang.String" resultType="java.lang.String">
        select steam_id from t_steam where device_id=#{deviceId}
  </select>
  <select id="steamList" resultType="com.thhy.engineering.modules.biz.device.entity.TSteam">
        select
        ts.steam_id as steamId,
        ts.device_id as deviceId,
        ts.temperature as temperature,
        ts.humidity as humidity,
        ts.gather_time as gatherTime,
        sd.device_name as deviceName
        from t_steam ts left join
        sys_device sd  on ts.device_id=sd.device_id
        where 1=1
        <if test="companyId!=null and companyId!='' ">
          and sd.company_id=#{companyId}
        </if>
        <if test="strTime!=null and strTime!='' and  endTime!=null and endTime!='' ">
          and ts.gather_time between #{strTime} and #{endTime}
        </if>
        order by ts.gather_time desc
  </select>
 
    <select id="devicePull" resultType="com.thhy.engineering.modules.biz.device.entity.SysDevice">
        select device_id as deviceId,
        device_name as deviceName
         from sys_device where is_use=1
        and device_type=#{deviceType}
        <if test="companyId!=null and companyId!='' ">
            and company_id=#{companyId}
        </if>
    </select>
    <select id="mouldList" resultType="com.thhy.engineering.modules.biz.device.entity.TMouldRecord">
        SELECT
    tmr.mould_record_id as mouldRecordId,
    tmr.mould_id as mouldId,
    tmr.scan_num as scanNum,
    tmr.create_time as createTime,
    tmr.length_time as lengthTime,
    sm.mould_num as mouldNum,
    sm.mould_code as mouldCode,
    sd.dict_name AS mouldTypes,
    sd1.dict_name AS sizeName,
    sd2.dict_name AS turn,
    sd3.dict_name AS holes
FROM
    t_mould_record tmr
    LEFT JOIN sys_mould sm ON tmr.mould_id = sm.mould_id
    LEFT JOIN sys_dict sd ON sm.mould_type = sd.dict_id
    LEFT JOIN sys_dict sd1 ON sm.mould_size = sd1.dict_id
    LEFT JOIN sys_dict sd2 ON sm.mould_turn = sd2.dict_id
    LEFT JOIN sys_dict sd3 ON sm.grouting_holes = sd3.dict_id
    where 1=1
    <if test="companyId!=null and companyId!='' ">
        and tmr.company_id=#{companyId}
    </if>
    <if test="mouldNum!=null and mouldNum!='' ">
        and sm.mould_num  like concat('%',#{mouldNum},'%')
    </if>
    <if test="mouldCode!=null and mouldCode!='' ">
        and sm.mould_code=#{mouldCode}
    </if>
    order by tmr.create_time desc
    </select>
    <insert id="moldDataInsert">
        insert into t_mold_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dataId != null">
                data_id,
            </if>
            <if test="dataTime != null">
                data_time,
            </if>
            <if test="worksId != null">
                works_id,
            </if>
            <if test="types != null">
                types,
            </if>
            <if test="moldId != null">
                mold_id,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dataId != null">
                #{dataId,jdbcType=VARCHAR},
            </if>
            <if test="dataTime != null">
                #{dataTime,jdbcType=TIMESTAMP},
            </if>
            <if test="worksId != null">
                #{worksId,jdbcType=VARCHAR},
            </if>
            <if test="types != null">
                #{types,jdbcType=VARCHAR},
            </if>
            <if test="moldId != null">
                #{moldId,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <insert id="moldUseInsert">
        insert into t_mold_use
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="useId != null">
                use_id,
            </if>
            <if test="moldId != null">
                mold_id,
            </if>
            <if test="seconds != null">
                seconds,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="useId != null">
                #{useId,jdbcType=VARCHAR},
            </if>
            <if test="moldId != null">
                #{moldId,jdbcType=VARCHAR},
            </if>
            <if test="seconds != null">
                #{seconds,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
 
 
    <select id="moldIdSelectPipeId" parameterType="java.lang.String" resultType="java.lang.String">
        select tpi.pipe_id from t_pipe_info tpi left join
        sys_mould sm on sm.mould_id=tpi.mod_id
        where sm.mould_mn=#{rfid}
        order by tpi.into_mod_time desc
        limit 0,1
    </select>
 
    <update id="pipeInfoUpdate" >
        update  t_pipe_info
        set  out_mod=#{outMod},
        out_mod_time=#{outModTime}
        where pipe_id=#{pipeId}
    </update>
    <update id="pipeIdUpdate" >
        update  t_pipe_info
        set  placing_type=#{placingType},
        placing_in_time=#{placingInTime}
        where pipe_id=#{pipeId}
    </update>
    <select id="mouldMouldMn" parameterType="java.lang.String" resultType="java.lang.Integer">
        select current_cycle_time from sys_mould where mould_mn=#{rfid}
    </select>
 
    <update id="mouldUpdate" >
        update  sys_mould set
        current_cycle_time=#{nums}
        where mould_mn=#{rfid}
    </update>
 
    <update id="pipeIdOutUpdate">
        update  t_pipe_info
        set  placing_type=#{placingType},
        placing_out_time=#{placingOutTime}
        where pipe_id=#{pipeId}
    </update>
 
    <update id="mouldFreeUpdate" >
        update sys_mould set free=1
        where mould_mn=#{rfid}
    </update>
 
    <select id="dataInTime" parameterType="java.lang.String" resultType="java.lang.String">
        select data_time from  t_mold_data where  mold_id=#{rfid} and  types='upper'
        order by data_time desc limit 0,1
    </select>
    <select id="selectMouldId" parameterType="java.lang.String" resultType="java.lang.String">
        select mould_id from  sys_mould where mould_mn=#{rfid}
    </select>
    <select id="selectMouldCheck" parameterType="java.lang.String" resultType="java.lang.String">
        select mod_check_id from t_mould_check where mod_id=#{modId} order by check_time desc limit 0,1
    </select>
    <update id="updateMouldCheck" >
         update t_mould_check set status=2
        where mod_check_id=#{modCheckId}
    </update>
</mapper>