electripper/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml
2024-07-22 17:17:58 +08:00

359 lines
20 KiB
XML

<?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.system.mapper.AsDeviceMapper">
<resultMap type="AsDevice" id="AsDeviceResult">
<result property="deviceId" column="device_id" />
<result property="picture" column="picture" />
<result property="deviceName" column="device_name" />
<result property="mac" column="mac" />
<result property="sn" column="sn" />
<result property="modelId" column="model_id" />
<result property="hardwareVersionId" column="hardware_version_id" />
<result property="vehicleNum" column="vehicle_num" />
<result property="version" column="version" />
<result property="areaId" column="area_id" />
<result property="activationTime" column="activation_time" />
<result property="onlineStatus" column="online_status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="lastTime" column="last_time" />
<result property="lastLocationTime" column="last_location_time" />
<result property="gps" column="gps" />
<result property="remark" column="remark" />
<result property="status" column="status" />
<result property="lockStatus" column="lock_status" />
<result property="location" column="location" />
<result property="remainingPower" column="remaining_power" />
<result property="voltage" column="voltage" />
<result property="qrcode" column="qrcode" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="isAreaOutOutage" column="is_area_out_outage" />
<result property="isAdminUnlocking" column="is_admin_unlocking" />
</resultMap>
<sql id="selectAsDeviceVo">
select device_id, picture, device_name, mac, sn, model_id, hardware_version_id, vehicle_num, area_id, activation_time, online_status, create_by, create_time, update_by, update_time, last_time, last_location_time, gps, remark, status, lock_status, location, remaining_power, voltage, qrcode, longitude, latitude, is_area_out_outage, is_admin_unlocking from et_device
</sql>
<select id="selectAsDeviceList" parameterType="AsDevice" resultMap="AsDeviceResult">
select de.device_id, de.picture, de.device_name, de.mac, de.sn, de.model_id, de.hardware_version_id, de.vehicle_num, de.area_id,
de.activation_time, de.online_status, de.create_by, de.create_time, de.update_by,
de.update_time, de.last_time, de.last_location_time, de.gps, de.remark, de.status, de.lock_status, de.location,
de.remaining_power, de.voltage, de.qrcode, de.longitude, de.latitude, de.is_area_out_outage, de.is_admin_unlocking from et_device de
left join et_area_dept ad on ad.area_id = de.area_id
left join sys_dept d on d.dept_id = ad.dept_id
where 1 = 1
<if test="deviceName != null and deviceName != ''"> and de.device_name like concat('%', #{deviceName}, '%')</if>
<if test="mac != null and mac != ''"> and de.mac = #{mac}</if>
<if test="sn != null and sn != ''"> and de.sn = #{sn}</if>
<if test="vehicleNum != null and vehicleNum != ''"> and de.vehicle_num = #{vehicleNum}</if>
<if test="areaId != null and areaId != ''"> and de.area_id = #{areaId}</if>
<if test="modelId != null and modelId != ''"> and de.model_id = #{modelId}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and de.online_status = #{onlineStatus}</if>
<if test="status != null and status != ''"> and de.status = #{status}</if>
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by de.sn
</select>
<select id="selectAsDeviceListWithIsolate" parameterType="AsDevice" resultMap="AsDeviceResult">
select de.device_id, de.picture, de.device_name, de.mac, de.sn, de.model_id, de.hardware_version_id, de.vehicle_num, de.area_id,
de.activation_time, de.online_status, de.create_by, de.create_time, de.update_by,
de.update_time, de.last_time, de.last_location_time, de.gps, de.remark, de.status, de.lock_status, de.location,
de.remaining_power, de.voltage, de.version, de.qrcode, de.longitude, de.latitude, de.is_area_out_outage, de.is_admin_unlocking, de.signal_strength, de.satellites, de.quality from et_device de
left join et_area_dept ad on ad.area_id = de.area_id
left join sys_dept d on d.dept_id = ad.dept_id
where 1 = 1
<if test="deviceName != null and deviceName != ''"> and de.device_name like concat('%', #{deviceName}, '%')</if>
<if test="mac != null and mac != ''"> and de.mac like concat('%', #{mac}, '%')</if>
<if test="sn != null and sn != ''"> and de.sn like concat('%', #{sn}, '%')</if>
<if test="vehicleNum != null and vehicleNum != ''"> and de.vehicle_num like concat('%', #{vehicleNum}, '%')</if>
<if test="areaId != null "> and de.area_id = #{areaId}</if>
<if test="deptId != null "> and d.dept_id = #{deptId}</if>
<if test="modelId != null and modelId != ''"> and de.model_id = #{modelId}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and de.online_status = #{onlineStatus}</if>
<!-- <if test="status != null and status != ''"> and de.status = #{status}</if>-->
<choose>
<when test="status == '34'">
and (de.status = '3' or de.status = '4')
</when>
<otherwise>
<if test="status != null and status != ''">
and de.status = #{status}
</if>
</otherwise>
</choose>
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
<!-- 查询areaId是null -->
<if test="unBand != null">
and de.area_id is null
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by de.sn
</select>
<select id="selectAsDeviceByDeviceId" parameterType="Long" resultMap="AsDeviceResult">
<include refid="selectAsDeviceVo"/>
where device_id = #{deviceId}
</select>
<select id="selectAsDeviceByMac" parameterType="string" resultMap="AsDeviceResult">
<include refid="selectAsDeviceVo"/>
where mac = #{mac}
</select>
<select id="selectAsDeviceBySn" parameterType="string" resultMap="AsDeviceResult">
<include refid="selectAsDeviceVo"/>
where sn = #{sn}
</select>
<!--有订单车辆-->
<select id="getInOrderDevice" resultType="java.lang.String">
SELECT
count( 1 )
FROM
(
SELECT
o.sn
FROM
et_order o
LEFT JOIN et_device d ON o.sn = d.sn
WHERE
date_format( o.create_time, '%y%m%d' ) &gt;= date_format( #{timeStart}, '%y%m%d' )
AND date_format( o.create_time, '%y%m%d' ) &lt;= date_format( #{timeEnd}, '%y%m%d' ) and o.sn IS NOT NULL and o.area_id = #{areaId}
GROUP BY
o.sn
) a
</select>
<select id="getNoOrderDevice" resultType="java.lang.String">
SELECT count( 1 ) from et_device de where de.sn not in (
SELECT
o.sn
FROM
et_order o
LEFT JOIN et_device d ON o.sn = d.sn
WHERE
date_format( o.create_time, '%y%m%d' ) &gt;= date_format( #{timeStart}, '%y%m%d' )
AND date_format( o.create_time, '%y%m%d' ) &lt;= date_format( #{timeEnd}, '%y%m%d' ) and o.sn IS NOT NULL and o.area_id = #{areaId}
GROUP BY
o.sn
)
</select>
<select id="checkSNUnique" resultMap="AsDeviceResult">
select device_id, sn, device_name from et_device where sn = #{sn} limit 1
</select>
<select id="checkMACUnique" resultMap="AsDeviceResult">
select device_id, sn, device_name from et_device where mac = #{mac} limit 1
</select>
<insert id="insertAsDevice" parameterType="AsDevice" useGeneratedKeys="true" keyProperty="deviceId">
insert into et_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="picture != null">picture,</if>
<if test="deviceName != null">device_name,</if>
<if test="mac != null">mac,</if>
<if test="sn != null">sn,</if>
<if test="modelId != null">model_id,</if>
<if test="hardwareVersionId != null">hardware_version_id,</if>
<if test="vehicleNum != null">vehicle_num,</if>
<if test="version != null">version,</if>
<if test="areaId != null">area_id,</if>
<if test="activationTime != null">activation_time,</if>
<if test="onlineStatus != null">online_status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="lastTime != null">last_time,</if>
<if test="lastLocationTime != null">last_location_time,</if>
<if test="gps != null">gps,</if>
<if test="remark != null">remark,</if>
<if test="status != null">status,</if>
<if test="lockStatus != null">lock_status,</if>
<if test="location != null">location,</if>
<if test="remainingPower != null">remaining_power,</if>
<if test="voltage != null">voltage,</if>
<if test="qrcode != null">qrcode,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="isAreaOutOutage != null">is_area_out_outage,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="picture != null">#{picture},</if>
<if test="deviceName != null">#{deviceName},</if>
<if test="mac != null">#{mac},</if>
<if test="sn != null">#{sn},</if>
<if test="modelId != null">#{modelId},</if>
<if test="hardwareVersionId != null">#{hardwareVersionId},</if>
<if test="vehicleNum != null">#{vehicleNum},</if>
<if test="version != null">#{version},</if>
<if test="areaId != null">#{areaId},</if>
<if test="activationTime != null">#{activationTime},</if>
<if test="onlineStatus != null">#{onlineStatus},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="lastTime != null">#{lastTime},</if>
<if test="lastLocationTime != null">#{lastLocationTime},</if>
<if test="gps != null">#{gps},</if>
<if test="remark != null">#{remark},</if>
<if test="status != null">#{status},</if>
<if test="lockStatus != null">#{lockStatus},</if>
<if test="location != null">#{location},</if>
<if test="remainingPower != null">#{remainingPower},</if>
<if test="voltage != null">#{voltage},</if>
<if test="qrcode != null">#{qrcode},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="isAreaOutOutage != null">#{isAreaOutOutage},</if>
</trim>
</insert>
<update id="updateAsDevice" parameterType="AsDevice">
update et_device
<trim prefix="SET" suffixOverrides=",">
<if test="picture != null">picture = #{picture},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="mac != null">mac = #{mac},</if>
<if test="sn != null">sn = #{sn},</if>
<if test="modelId != null">model_id = #{modelId},</if>
<if test="hardwareVersionId != null">hardware_version_id = #{hardwareVersionId},</if>
<if test="vehicleNum != null">vehicle_num = #{vehicleNum},</if>
<if test="version != null">version = #{version},</if>
<if test="areaId != null">area_id = #{areaId},</if>
<if test="activationTime != null">activation_time = #{activationTime},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="lastTime != null">last_time = #{lastTime},</if>
<if test="lastLocationTime != null">last_location_time = #{lastLocationTime},</if>
<if test="gps != null">gps = #{gps},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="status != null">status = #{status},</if>
<if test="lockStatus != null">lock_status = #{lockStatus},</if>
<if test="location != null">location = #{location},</if>
<if test="remainingPower != null">remaining_power = #{remainingPower},</if>
<if test="voltage != null">voltage = #{voltage},</if>
<if test="qrcode != null">qrcode = #{qrcode},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="isAreaOutOutage != null">is_area_out_outage = #{isAreaOutOutage},</if>
<if test="isAdminUnlocking != null">is_admin_unlocking = #{isAdminUnlocking},</if>
</trim>
where device_id = #{deviceId}
</update>
<update id="updateAsDevice2" parameterType="AsDevice">
update et_device
<trim prefix="SET" suffixOverrides=",">
<if test="picture != null">picture = #{picture},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="mac != null">mac = #{mac},</if>
<if test="sn != null">sn = #{sn},</if>
model_id = #{modelId},
hardware_version_id = #{hardwareVersionId},
<if test="vehicleNum != null">vehicle_num = #{vehicleNum},</if>
<if test="version != null">version = #{version},</if>
area_id = #{areaId},
<if test="activationTime != null">activation_time = #{activationTime},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="lastTime != null">last_time = #{lastTime},</if>
<if test="lastLocationTime != null">last_location_time = #{lastLocationTime},</if>
<if test="gps != null">gps = #{gps},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="status != null">status = #{status},</if>
<if test="lockStatus != null">lock_status = #{lockStatus},</if>
<if test="location != null">location = #{location},</if>
<if test="remainingPower != null">remaining_power = #{remainingPower},</if>
<if test="voltage != null">voltage = #{voltage},</if>
<if test="qrcode != null">qrcode = #{qrcode},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="isAreaOutOutage != null">is_area_out_outage = #{isAreaOutOutage},</if>
<if test="isAdminUnlocking != null">is_admin_unlocking = #{isAdminUnlocking},</if>
</trim>
where device_id = #{deviceId}
</update>
<update id="updateAsDeviceBySn" parameterType="AsDevice">
update et_device
<trim prefix="SET" suffixOverrides=",">
<if test="picture != null">picture = #{picture},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="mac != null">mac = #{mac},</if>
<if test="modelId != null">model_id = #{modelId},</if>
<if test="hardwareVersionId != null">hardware_version_id = #{hardwareVersionId},</if>
<if test="vehicleNum != null">vehicle_num = #{vehicleNum},</if>
<if test="version != null">version = #{version},</if>
<if test="areaId != null">area_id = #{areaId},</if>
<if test="activationTime != null">activation_time = #{activationTime},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="lastTime != null">last_time = #{lastTime},</if>
<if test="lastLocationTime != null">last_location_time = #{lastLocationTime},</if>
<if test="gps != null">gps = #{gps},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="status != null">status = #{status},</if>
<if test="lockStatus != null">lock_status = #{lockStatus},</if>
<if test="location != null">location = #{location},</if>
<if test="remainingPower != null">remaining_power = #{remainingPower},</if>
<if test="voltage != null">voltage = #{voltage},</if>
<if test="qrcode != null">qrcode = #{qrcode},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="isAreaOutOutage != null">is_area_out_outage = #{isAreaOutOutage},</if>
<if test="isAdminUnlocking != null">is_admin_unlocking = #{isAdminUnlocking},</if>
</trim>
where sn = #{sn}
</update>
<update id="batchDisable">
update
</update>
<delete id="deleteAsDeviceByDeviceId" parameterType="Long">
delete from et_device where device_id = #{deviceId}
</delete>
<delete id="deleteAsDeviceByDeviceIds" parameterType="String">
delete from et_device where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
<delete id="oneClickOnline" parameterType="String">
update et_device d set d.status = '1' where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
<delete id="oneClickOffline" parameterType="String">
update et_device d set d.status = '8' where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
</mapper>