liusuyi
2024-10-10 38f29e38fcc668171dc05c53d40a36b895c86102
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
<?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.ruoyi.sy.mapper.ArdTankLockStateMapper">
    
    <resultMap type="ArdTankLockState" id="ArdTankLockStateResult">
        <result property="id"    column="id"    />
        <result property="lockId"    column="lock_id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockState"    column="lock_state"    />
        <result property="lockPositionState"    column="lock_position_state"    />
        <result property="lockShellState"    column="lock_shell_state"    />
        <result property="restartState"    column="restart_state"    />
        <result property="batterVoltage"    column="batter_voltage"    />
        <result property="powerVoltage"    column="power_voltage"    />
        <result property="uploadTime"    column="upload_time"    />
        <result property="uniqueMark"    column="unique_mark"    />
    </resultMap>
 
    <sql id="selectArdTankLockStateVo">
        select id, lock_id, lock_num, lock_state, lock_position_state, lock_shell_state, restart_state, batter_voltage, power_voltage, upload_time, unique_mark from ard_tank_lock_state
    </sql>
 
    <select id="selectArdTankLockStateList" parameterType="ArdTankLockState" resultMap="ArdTankLockStateResult">
        <include refid="selectArdTankLockStateVo"/>
        <where>  
            <if test="lockId != null  and lockId != ''"> and lock_id = #{lockId}</if>
            <if test="lockNum != null  and lockNum != ''"> and lock_num = #{lockNum}</if>
            <if test="lockState != null  and lockState != ''"> and lock_state = #{lockState}</if>
            <if test="lockPositionState != null  and lockPositionState != ''"> and lock_position_state = #{lockPositionState}</if>
            <if test="lockShellState != null  and lockShellState != ''"> and lock_shell_state = #{lockShellState}</if>
            <if test="restartState != null  and restartState != ''"> and restart_state = #{restartState}</if>
            <if test="batterVoltage != null  and batterVoltage != ''"> and batter_voltage = #{batterVoltage}</if>
            <if test="powerVoltage != null  and powerVoltage != ''"> and power_voltage = #{powerVoltage}</if>
            <if test="uploadTime != null  and uploadTime != ''"> and upload_time = #{uploadTime}</if>
            <if test="uniqueMark != null  and uniqueMark != ''"> and unique_mark = #{uniqueMark}</if>
        </where>
    </select>
    
    <select id="selectArdTankLockStateById" parameterType="String" resultMap="ArdTankLockStateResult">
        <include refid="selectArdTankLockStateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertArdTankLockState" parameterType="ArdTankLockState">
        insert into ard_tank_lock_state
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="lockId != null">lock_id,</if>
            <if test="lockNum != null">lock_num,</if>
            <if test="lockState != null">lock_state,</if>
            <if test="lockPositionState != null">lock_position_state,</if>
            <if test="lockShellState != null">lock_shell_state,</if>
            <if test="restartState != null">restart_state,</if>
            <if test="batterVoltage != null">batter_voltage,</if>
            <if test="powerVoltage != null">power_voltage,</if>
            <if test="uploadTime != null">upload_time,</if>
            <if test="uniqueMark != null">unique_mark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="lockId != null">#{lockId},</if>
            <if test="lockNum != null">#{lockNum},</if>
            <if test="lockState != null">#{lockState},</if>
            <if test="lockPositionState != null">#{lockPositionState},</if>
            <if test="lockShellState != null">#{lockShellState},</if>
            <if test="restartState != null">#{restartState},</if>
            <if test="batterVoltage != null">#{batterVoltage},</if>
            <if test="powerVoltage != null">#{powerVoltage},</if>
            <if test="uploadTime != null">#{uploadTime},</if>
            <if test="uniqueMark != null">#{uniqueMark},</if>
         </trim>
    </insert>
 
    <update id="updateArdTankLockState" parameterType="ArdTankLockState">
        update ard_tank_lock_state
        <trim prefix="SET" suffixOverrides=",">
            <if test="lockId != null">lock_id = #{lockId},</if>
            <if test="lockNum != null">lock_num = #{lockNum},</if>
            <if test="lockState != null">lock_state = #{lockState},</if>
            <if test="lockPositionState != null">lock_position_state = #{lockPositionState},</if>
            <if test="lockShellState != null">lock_shell_state = #{lockShellState},</if>
            <if test="restartState != null">restart_state = #{restartState},</if>
            <if test="batterVoltage != null">batter_voltage = #{batterVoltage},</if>
            <if test="powerVoltage != null">power_voltage = #{powerVoltage},</if>
            <if test="uploadTime != null">upload_time = #{uploadTime},</if>
            <if test="uniqueMark != null">unique_mark = #{uniqueMark},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteArdTankLockStateById" parameterType="String">
        delete from ard_tank_lock_state where id = #{id}
    </delete>
 
    <delete id="deleteArdTankLockStateByIds" parameterType="String">
        delete from ard_tank_lock_state where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <insert id="insertOrUpdateArdTankLockState" parameterType="ArdTankLockState" >
        insert into ard_tank_lock_state (id, lock_id, lock_num, lock_state, lock_position_state, lock_shell_state,
                                         restart_state, batter_voltage, power_voltage, upload_time, unique_mark)
        values (#{id,jdbcType=VARCHAR},#{lockId,jdbcType=VARCHAR},#{lockNum,jdbcType=VARCHAR},#{lockState,jdbcType=VARCHAR},
                #{lockPositionState,jdbcType=VARCHAR},#{lockShellState,jdbcType=VARCHAR},#{restartState,jdbcType=VARCHAR},
                #{batterVoltage,jdbcType=VARCHAR},#{powerVoltage,jdbcType=VARCHAR},#{uploadTime,jdbcType=VARCHAR},
                #{uniqueMark,jdbcType=VARCHAR})
            on conflict(unique_mark) do update set upload_time=#{uploadTime,jdbcType=VARCHAR}
    </insert>
 
    <select id="selectArdTankLockStateByLockIdLimitOne" parameterType="java.lang.String" resultMap="ArdTankLockStateResult">
        select atls.id,atls.lock_id,atls.lock_num,atls.lock_state,
        atls.lock_position_state,atls.lock_shell_state,atls.restart_state,
        atls.batter_voltage,atls.power_voltage,atls.upload_time,atls.unique_mark,
        case atls.lock_state
        when '关锁状态' then false
        when '异常状态' then false
        /*when '动作状态' then false*/
        when '操控中...' then false
        when '开锁状态' then true
        end as lock_state_mark
        from ard_tank_lock_state atls
        where atls.lock_id = #{lockId} order by atls.upload_time desc
        limit 1
    </select>
 
    <update id="updateArdTankLockStateByUniqueMark" parameterType="java.lang.String">
        update ard_tank_lock_state set upload_time = #{uploadTime}
        where unique_mark = #{uniqueMark}
    </update>
</mapper>