zhangnaisong
2024-07-26 b468cde8bfd9d6e1d7ae7ccc535fc7e8ffb9f818
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
<?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.ArdTankLockAlarmMapper">
    
    <resultMap type="ArdTankLockAlarm" id="ArdTankLockAlarmResult">
        <result property="lockNum"    column="lock_num"    />
        <result property="alarmInfo"    column="alarm_info"    />
        <result property="id"    column="id"    />
        <result property="lockId"    column="lock_id"    />
        <result property="alarmTime"    column="alarm_time"    />
    </resultMap>
 
    <sql id="selectArdTankLockAlarmVo">
        select lock_num, alarm_info, id, lock_id, alarm_time from ard_tank_lock_alarm
    </sql>
 
    <select id="selectArdTankLockAlarmList" parameterType="ArdTankLockAlarm" resultMap="ArdTankLockAlarmResult">
        <include refid="selectArdTankLockAlarmVo"/>
        <where>  
            <if test="lockNum != null  and lockNum != ''"> and lock_num = #{lockNum}</if>
            <if test="alarmInfo != null  and alarmInfo != ''"> and alarm_info = #{alarmInfo}</if>
            <if test="lockId != null  and lockId != ''"> and lock_id = #{lockId}</if>
            <if test="alarmTime != null  and alarmTime != ''"> and alarm_time = #{alarmTime}</if>
        </where>
    </select>
    
    <select id="selectArdTankLockAlarmByLockNum" parameterType="String" resultMap="ArdTankLockAlarmResult">
        <include refid="selectArdTankLockAlarmVo"/>
        where lock_num = #{lockNum}
    </select>
        
    <insert id="insertArdTankLockAlarm" parameterType="ArdTankLockAlarm">
        insert into ard_tank_lock_alarm
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="lockNum != null">lock_num,</if>
            <if test="alarmInfo != null">alarm_info,</if>
            <if test="id != null">id,</if>
            <if test="lockId != null">lock_id,</if>
            <if test="alarmTime != null">alarm_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="lockNum != null">#{lockNum},</if>
            <if test="alarmInfo != null">#{alarmInfo},</if>
            <if test="id != null">#{id},</if>
            <if test="lockId != null">#{lockId},</if>
            <if test="alarmTime != null">#{alarmTime},</if>
         </trim>
    </insert>
 
    <update id="updateArdTankLockAlarm" parameterType="ArdTankLockAlarm">
        update ard_tank_lock_alarm
        <trim prefix="SET" suffixOverrides=",">
            <if test="alarmInfo != null">alarm_info = #{alarmInfo},</if>
            <if test="id != null">id = #{id},</if>
            <if test="lockId != null">lock_id = #{lockId},</if>
            <if test="alarmTime != null">alarm_time = #{alarmTime},</if>
        </trim>
        where lock_num = #{lockNum}
    </update>
 
    <delete id="deleteArdTankLockAlarmByLockNum" parameterType="String">
        delete from ard_tank_lock_alarm where lock_num = #{lockNum}
    </delete>
 
    <delete id="deleteArdTankLockAlarmByLockNums" parameterType="String">
        delete from ard_tank_lock_alarm where lock_num in 
        <foreach item="lockNum" collection="array" open="(" separator="," close=")">
            #{lockNum}
        </foreach>
    </delete>
 
    <select id="selectArdTankLockAlarmBylockIdAndTime" parameterType="java.lang.String" resultType="java.util.Map">
        select atlm.id,atlm.lock_id as "lockId",atlm.lock_num as "lockNum",
        atlm.alarm_info as "alarmInfo",atlm.alarm_time as "alarmTime",
        atl.lock_name as "lockName",atl.car_id as "carId"
        from ard_tank_lock_alarm atlm
        inner join ard_tank_lock atl on atlm.lock_id = atl."id"
        <where>
            <if test="carId != null  and carId != ''"> and car_id = #{carId}</if>
            <if test="lockId != null  and lockId != ''"> and lock_id = #{lockId}</if>
            <if test="beginTime != null  and beginTime != ''"> and alarm_time &gt;= #{beginTime}</if>
            <if test="endTime != null  and endTime != ''"> and alarm_time &lt;= #{endTime}</if>
        </where>
        order by atlm.alarm_time desc
    </select>
 
    <select id="selectArdTankLockAlarmTotalBylockIdAndTime" parameterType="java.lang.String" resultType="java.lang.Long">
        select count(*)
        from ard_tank_lock_alarm atlm
        inner join ard_tank_lock atl on atlm.lock_id = atl."id"
        <where>
            <if test="carId != null  and carId != ''"> and car_id = #{carId}</if>
            <if test="lockId != null  and lockId != ''"> and lock_id = #{lockId}</if>
            <if test="beginTime != null  and beginTime != ''"> and alarm_time &gt;= #{beginTime}</if>
            <if test="endTime != null  and endTime != ''"> and alarm_time &lt;= #{endTime}</if>
        </where>
    </select>
 
    <select id="selectArdTankLockAlarmByDeptIdAndTime" resultType="java.util.Map">
        select atlm.id,atlm.lock_id as "lockId",atlm.lock_num as "lockNum",
        atlm.alarm_info as "alarmInfo",atlm.alarm_time as "alarmTime",
        atl.lock_name as "lockName",atl.car_id as "carId"
        from ard_tank_lock_alarm atlm
        inner join ard_tank_lock atl on atlm.lock_id = atl."id"
        <where>
            <if test="beginTime != null  and beginTime != ''"> and alarm_time &gt;= #{beginTime}</if>
            <if test="endTime != null  and endTime != ''"> and alarm_time &lt;= #{endTime}</if>
            <if test="deptId != null">
                and atl.car_id in (select car_id from ard_sy_car "asc" where "asc".dept_id in (
                with recursive rsd as (
                select sd.dept_id from sys_dept sd where sd.dept_id = #{deptId}
                union
                select csd.dept_id from sys_dept csd inner join rsd on rsd.dept_id = csd.parent_id
                )
                select * from rsd))
            </if>
        </where>
        order by atlm.alarm_time desc
    </select>
 
    <select id="selectArdTankLockAlarmTotalByDeptIdAndTime" resultType="java.lang.Long">
        select count(*)
        from ard_tank_lock_alarm atlm
        inner join ard_tank_lock atl on atlm.lock_id = atl."id"
        <where>
            <if test="beginTime != null  and beginTime != ''"> and alarm_time &gt;= #{beginTime}</if>
            <if test="endTime != null  and endTime != ''"> and alarm_time &lt;= #{endTime}</if>
            <if test="deptId != null">
                and atl.car_id in (select car_id from ard_sy_car "asc" where "asc".dept_id in (
                with recursive rsd as (
                select sd.dept_id from sys_dept sd where sd.dept_id =  #{deptId}
                union
                select csd.dept_id from sys_dept csd inner join rsd on rsd.dept_id = csd.parent_id
                )
                select * from rsd))
            </if>
        </where>
    </select>
</mapper>