zhangnaisong
2024-08-06 4dbd2e0a473ef33ecf8a7200f62b61d4dbd87f25
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
<?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.ArdSyCarMapper">
    
    <resultMap type="ArdSyCar" id="ArdSyCarResult">
        <result property="id"    column="id"    />
        <result property="carId"    column="car_id"    />
        <result property="carModel"    column="car_model"    />
        <result property="carType"    column="car_type"    />
        <result property="carBrand"    column="car_brand"    />
        <result property="deptId"    column="dept_id"    />
        <result property="carPicture"    column="car_picture"    />
        <result property="reserved1"    column="reserved_1"    />
        <result property="reserved2"    column="reserved_2"    />
        <result property="reserved3"    column="reserved_3"    />
    </resultMap>
 
    <resultMap type="ArdSyCar" id="ArdSyCarLockResult">
        <result property="id"    column="id"    />
        <result property="carId"    column="car_id"    />
        <result property="carModel"    column="car_model"    />
        <result property="carType"    column="car_type"    />
        <result property="carBrand"    column="car_brand"    />
        <result property="deptId"    column="dept_id"    />
        <result property="carPicture"    column="car_picture"    />
        <result property="reserved1"    column="reserved_1"    />
        <result property="reserved2"    column="reserved_2"    />
        <result property="reserved3"    column="reserved_3"    />
        <collection property="ardTankLockList" ofType="com.ruoyi.sy.domain.ArdTankLock">
            <result property="id"    column="lid"    />
            <result property="lockNum"    column="lock_num"    />
            <result property="lockName"    column="lock_name"    />
            <result property="imgPositionTop"    column="img_position_top"    />
            <result property="imgPositionLeft"    column="img_position_left"    />
            <result property="carId"    column="lcar_id"    />
            <result property="enable"    column="enable"    />
            <result property="restartState"    column="restart_state"    />
            <result property="onlineTime"    column="online_time"    />
        </collection>
    </resultMap>
 
    <sql id="selectArdSyCarVo">
        select id, car_id, car_model, car_type, car_brand, dept_id, car_picture, reserved_1, reserved_2, reserved_3 from ard_sy_car
    </sql>
 
    <select id="selectArdSyCarList" parameterType="ArdSyCar" resultMap="ArdSyCarResult">
        <include refid="selectArdSyCarVo"/>
        <where>  
            <if test="carId != null  and carId != ''"> and car_id = #{carId}</if>
            <if test="carModel != null  and carModel != ''"> and car_model = #{carModel}</if>
            <if test="carType != null  and carType != ''"> and car_type = #{carType}</if>
            <if test="carBrand != null  and carBrand != ''"> and car_brand = #{carBrand}</if>
            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
            <if test="carPicture != null  and carPicture != ''"> and car_picture = #{carPicture}</if>
            <if test="reserved1 != null  and reserved1 != ''"> and reserved_1 = #{reserved1}</if>
            <if test="reserved2 != null  and reserved2 != ''"> and reserved_2 = #{reserved2}</if>
            <if test="reserved3 != null  and reserved3 != ''"> and reserved_3 = #{reserved3}</if>
        </where>
    </select>
    
    <select id="selectArdSyCarById" parameterType="String" resultMap="ArdSyCarResult">
        <include refid="selectArdSyCarVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertArdSyCar" parameterType="ArdSyCar">
        insert into ard_sy_car
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="carId != null">car_id,</if>
            <if test="carModel != null">car_model,</if>
            <if test="carType != null">car_type,</if>
            <if test="carBrand != null">car_brand,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="carPicture != null">car_picture,</if>
            <if test="reserved1 != null">reserved_1,</if>
            <if test="reserved2 != null">reserved_2,</if>
            <if test="reserved3 != null">reserved_3,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="carId != null">#{carId},</if>
            <if test="carModel != null">#{carModel},</if>
            <if test="carType != null">#{carType},</if>
            <if test="carBrand != null">#{carBrand},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="carPicture != null">#{carPicture},</if>
            <if test="reserved1 != null">#{reserved1},</if>
            <if test="reserved2 != null">#{reserved2},</if>
            <if test="reserved3 != null">#{reserved3},</if>
         </trim>
    </insert>
 
    <update id="updateArdSyCar" parameterType="ArdSyCar">
        update ard_sy_car
        <trim prefix="SET" suffixOverrides=",">
            <if test="carId != null">car_id = #{carId},</if>
            <if test="carModel != null">car_model = #{carModel},</if>
            <if test="carType != null">car_type = #{carType},</if>
            <if test="carBrand != null">car_brand = #{carBrand},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="carPicture != null">car_picture = #{carPicture},</if>
            <if test="reserved1 != null">reserved_1 = #{reserved1},</if>
            <if test="reserved2 != null">reserved_2 = #{reserved2},</if>
            <if test="reserved3 != null">reserved_3 = #{reserved3},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteArdSyCarById" parameterType="String">
        delete from ard_sy_car where id = #{id}
    </delete>
 
    <delete id="deleteArdSyCarByIds" parameterType="String">
        delete from ard_sy_car where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="selectArdSyCarByIds" parameterType="String" resultMap="ArdSyCarResult">
        select * from ard_sy_car where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
 
    <select id="carListById" parameterType="String" resultMap="ArdSyCarResult">
        select * from ard_sy_car where id = #{id}
    </select>
    <select id="getArdSyCarAndDeptByCarId" parameterType="String" resultType="java.util.Map">
        select asc0.id,asc0.car_id as "carId",coalesce(asc0.car_model,'') as "carModel",
        coalesce(asc0.car_type,'') as "carType",coalesce(asc0.car_brand,'') as "carBrand",
        asc0.dept_id as "deptId",asc0.car_picture as "carPicture",sd.ancestors,
        sd.dept_name as "deptName" from ard_sy_car asc0
        inner join sys_dept sd on asc0.dept_id = sd.dept_id
        where asc0.car_id = #{carId}
    </select>
    <select id="selectArdSyCarByDeptIds" parameterType="java.lang.Long" resultType="java.lang.String">
        select asy.car_id from ard_sy_car asy
        where asy.dept_id in
        <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
            #{deptId}
        </foreach>
    </select>
    <select id="getArdSyTankCarByCarId" parameterType="java.lang.String" resultMap="ArdSyCarResult">
        select distinct "asc".* from ard_sy_car "asc"
        inner join ard_tank_lock atl on "asc".car_id = atl.car_id
        where "asc".car_id = #{carId}
    </select>
    <select id="getCountByCarIdList" resultType="java.lang.Long">
        select count(*) from ard_sy_car "asc"
        where "asc".car_id in
        <foreach item="carId" collection="carIdList" open="(" separator="," close=")">
            #{carId}
        </foreach>
    </select>
    <select id="getCarListByDeptIdList" resultMap="ArdSyCarResult">
        select * from ard_sy_car where dept_id in
        <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
            #{deptId}
        </foreach>
    </select>
    <select id="selectArdSyCarAndTankLockByUserId" resultMap="ArdSyCarLockResult" parameterType="java.lang.String">
        select "asc".id,"asc".car_id,"asc".car_model,"asc".car_type,
        "asc".car_brand,"asc".dept_id,"asc".car_picture,atl.id as lid,
        atl.lock_num,atl.lock_name,atl.img_position_top,atl.img_position_left,
        atl.car_id as lcar_id,atl.enable,coalesce(atl.restart_state,'') as restart_state,
        coalesce(atl.online_time,'') as online_time
        from ard_sy_car "asc"
        inner join ard_tank_lock atl on "asc".car_id = atl.car_id
        where "asc".dept_id in (
        with recursive rsd as (
            select sd.dept_id from sys_dept sd where sd.dept_id =
            (select dept_id from sys_user su where su.user_id = #{userId})
            union
            select csd.dept_id from sys_dept csd inner join rsd on rsd.dept_id = csd.parent_id
        )
        select dept_id from rsd) order by "asc".car_id desc,atl.lock_num
    </select>
    <select id="selectByBrandAndType" resultMap="ArdSyCarResult" parameterType="java.lang.String">
        select * from ard_sy_car
        <where>
            <if test="carType != null  and carType != ''"> and car_type = #{carType}</if>
            <if test="carBrand != null  and carBrand != ''"> and car_brand = #{carBrand}</if>
        </where>
    </select>
    <select id="selectArdSyCarAndTankLock" resultMap="ArdSyCarLockResult" >
       select "asc".id,"asc".car_id,"asc".car_model,"asc".car_type,
       "asc".car_brand,"asc".dept_id,"asc".car_picture,atl.id as lid,
       atl.lock_num,atl.lock_name,atl.img_position_top,atl.img_position_left,
       atl.car_id as lcar_id,atl.enable,coalesce(atl.restart_state,'') as restart_state,
       coalesce(atl.online_time,'') as online_time
       from ard_sy_car "asc"
       inner join ard_tank_lock atl on "asc".car_id = atl.car_id
       order by "asc".car_id desc,atl.lock_num
    </select>
</mapper>