leutu
2024-06-03 3ef35e6cd16bbfa206b26bb3271eac40ad020bcb
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
<?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.fastbee.iot.mapper.FunctionLogMapper">
    
    <resultMap type="com.fastbee.iot.domain.FunctionLog" id="FunctionLogResult">
        <result property="id"    column="id"    />
        <result property="identify"    column="identify"    />
        <result property="funType"    column="fun_type"    />
        <result property="funValue"    column="fun_value"    />
        <result property="messageId"    column="message_id"    />
        <result property="deviceName"    column="device_name"    />
        <result property="serialNumber"    column="serial_number"    />
        <result property="mode"    column="mode"    />
        <result property="userId"    column="user_id"    />
        <result property="resultMsg"    column="result_msg"    />
        <result property="resultCode"    column="result_code"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="remark"    column="remark"    />
        <result property="showValue" column="show_value"/>
        <result property="modelName" column="model_name"/>
        <result property="replyTime" column="reply_time"/>
    </resultMap>
 
    <sql id="selectFunctionLogVo">
        select id, identify, fun_type, fun_value, message_id, device_name, serial_number, mode, user_id, result_msg, result_code, create_by,
               create_time, remark,show_value,model_name,reply_time from iot_function_log
    </sql>
 
    <select id="selectFunctionLogList" parameterType="FunctionLog" resultMap="FunctionLogResult">
        <include refid="selectFunctionLogVo"/>
        <where>
            <if test="prefixIdentify != null  and prefixIdentify != ''"> and identify like concat(#{prefixIdentify},'%')</if>
            <if test="identify != null  and identify != ''"> and identify = #{identify}</if>
            <if test="funType != null "> and fun_type = #{funType}</if>
            <if test="funValue != null  and funValue != ''"> and fun_value = #{funValue}</if>
            <if test="messageId != null  and messageId != ''"> and message_id = #{messageId}</if>
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
            <if test="serialNumber != null  and serialNumber != ''"> and serial_number = #{serialNumber}</if>
            <if test="mode != null "> and mode = #{mode}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="resultMsg != null  and resultMsg != ''"> and result_msg = #{resultMsg}</if>
            <if test="resultCode != null "> and result_code = #{resultCode}</if>
            <if test="beginTime != null and beginTime != ''">
                and date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
            </if>
            <if test="modelName != null and modelName != ''">and model_name = #{modelName}</if>
        </where>
        order by create_time DESC
    </select>
    
    <select id="selectFunctionLogById" parameterType="Long" resultMap="FunctionLogResult">
        <include refid="selectFunctionLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFunctionLog" parameterType="FunctionLog" useGeneratedKeys="true" keyProperty="id">
        insert into iot_function_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="identify != null and identify != ''">identify,</if>
            <if test="funType != null">fun_type,</if>
            <if test="funValue != null and funValue != ''">fun_value,</if>
            <if test="messageId != null">message_id,</if>
            <if test="deviceName != null">device_name,</if>
            <if test="serialNumber != null and serialNumber != ''">serial_number,</if>
            <if test="mode != null">mode,</if>
            <if test="userId != null">user_id,</if>
            <if test="resultMsg != null">result_msg,</if>
            <if test="resultCode != null">result_code,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="remark != null">remark,</if>
            <if test="showValue != null">show_value,</if>
            <if test="modelName != null and modelName !=''">model_name,</if>
            <if test="replyTime != null">reply_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="identify != null and identify != ''">#{identify},</if>
            <if test="funType != null">#{funType},</if>
            <if test="funValue != null and funValue != ''">#{funValue},</if>
            <if test="messageId != null">#{messageId},</if>
            <if test="deviceName != null">#{deviceName},</if>
            <if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
            <if test="mode != null">#{mode},</if>
            <if test="userId != null">#{userId},</if>
            <if test="resultMsg != null">#{resultMsg},</if>
            <if test="resultCode != null">#{resultCode},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="showValue != null">#{showValue},</if>
            <if test="modelName != null and modelName !=''">#{modelName},</if>
            <if test="replyTime != null">#{replyTime},</if>
         </trim>
    </insert>
 
    <insert id="insertBatch" parameterType="com.fastbee.iot.domain.FunctionLog">
        insert into iot_function_log (identify,fun_type,fun_value,message_id,device_name,serial_number,mode,user_id,
                                      result_msg,result_code,create_by,create_time,remark,show_value,model_name,reply_time)
            values
            <foreach collection="list" item="item" index="index" separator=",">
                (#{item.identify},#{item.funType},#{item.funValue},#{item.messageId},#{item.deviceName},#{item.serialNumber},#{item.mode},#{item.userId},
                #{item.resultMsg},#{item.resultCode},#{item.createBy},#{item.createTime},#{item.remark},#{item.showValue},#{item.modelName},#{item.replyTime})
            </foreach>
    </insert>
 
    <update id="updateFunctionLog" parameterType="FunctionLog">
        update iot_function_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="identify != null and identify != ''">identify = #{identify},</if>
            <if test="funType != null">fun_type = #{funType},</if>
            <if test="funValue != null and funValue != ''">fun_value = #{funValue},</if>
            <if test="messageId != null">message_id = #{messageId},</if>
            <if test="deviceName != null">device_name = #{deviceName},</if>
            <if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
            <if test="mode != null">mode = #{mode},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="resultMsg != null">result_msg = #{resultMsg},</if>
            <if test="resultCode != null">result_code = #{resultCode},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="showValue != null">show_value=#{showValue},</if>
            <if test="modelName != null and modelName !=''">model_name=#{modelName},</if>
            <if test="replyTime != null">reply_time = #{replyTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteFunctionLogById" parameterType="Long">
        delete from iot_function_log where id = #{id}
    </delete>
    <delete id="deleteFunctionLogBySerialNumber" parameterType="String">
        delete from iot_function_log where serial_number = #{serialNumber}
    </delete>
 
    <delete id="deleteFunctionLogByPreIdentify" parameterType="FunctionLog">
        delete from iot_function_log where identify like concat(#{prefixIdentify},'%') and serial_number = #{serialNumber}
    </delete>
 
    <delete id="deleteFunctionLogByIds" parameterType="String">
        delete from iot_function_log where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <update id="updateFuncLogBatch" parameterType="com.fastbee.iot.domain.FunctionLog">
        update iot_function_log l
        set l.result_msg = #{resultMsg},
            l.result_code = #{resultCode},
            l.reply_time = #{replyTime}
        where l.id in
            <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
    </update>
 
    <update id="updateByMessageId" parameterType="FunctionLog">
        update iot_function_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="identify != null and identify != ''">identify = #{identify},</if>
            <if test="funType != null">fun_type = #{funType},</if>
            <if test="funValue != null and funValue != ''">fun_value = #{funValue},</if>
            <if test="deviceName != null">device_name = #{deviceName},</if>
            <if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
            <if test="mode != null">mode = #{mode},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="resultMsg != null">result_msg = #{resultMsg},</if>
            <if test="resultCode != null">result_code = #{resultCode},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="showValue != null">show_value=#{showValue},</if>
            <if test="modelName != null and modelName !=''">model_name=#{modelName},</if>
            <if test="replyTime != null">reply_time = #{replyTime},</if>
        </trim>
        where message_id = #{messageId}
    </update>
</mapper>