2025-06-28 17:18:05 +08:00
|
|
|
<?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.fuyuanshen.equipment.mapper.DeviceMapper">
|
|
|
|
<resultMap id="BaseResultMap" type="com.fuyuanshen.equipment.domain.Device">
|
|
|
|
<id column="id" property="id"/>
|
|
|
|
<result column="device_type" property="deviceType"/>
|
|
|
|
<result column="customer_id" property="customerId"/>
|
|
|
|
<!--<result column="device_no" property="deviceNo"/>-->
|
|
|
|
<result column="device_name" property="deviceName"/>
|
|
|
|
<result column="device_pic" property="devicePic"/>
|
|
|
|
<result column="device_mac" property="deviceMac"/>
|
|
|
|
<result column="device_sn" property="deviceSn"/>
|
|
|
|
<result column="device_status" property="deviceStatus"/>
|
|
|
|
<result column="remark" property="remark"/>
|
|
|
|
<result column="create_by" property="createBy"/>
|
|
|
|
<result column="update_by" property="updateBy"/>
|
|
|
|
<result column="create_time" property="createTime"/>
|
|
|
|
<result column="update_time" property="updateTime"/>
|
|
|
|
<result column="binding_status" property="bindingStatus"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
id
|
|
|
|
, device_type, customer_id, device_name, device_pic, device_mac, device_sn,
|
|
|
|
remark, create_by, update_by, create_time, update_time
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<sql id="device_Column_List">
|
|
|
|
d
|
|
|
|
.
|
|
|
|
id
|
|
|
|
,d.device_type,
|
|
|
|
d.customer_id, d.device_name, d.device_pic, d.device_mac,
|
|
|
|
d.device_sn, d.remark, d.create_by, d.update_by, d.create_time, d.update_time,
|
|
|
|
d.binding_status, d.device_status, d.current_owner_id, d.original_owner_id, d.customer_name,
|
|
|
|
d.device_imei, d.longitude, d.latitude, d.tenant_id
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<!-- 分页查询设备 -->
|
2025-07-08 14:46:05 +08:00
|
|
|
<select id="findAll1" resultType="com.fuyuanshen.equipment.domain.Device">
|
2025-07-04 15:42:10 +08:00
|
|
|
select d.* , t.type_name
|
2025-07-02 15:29:09 +08:00
|
|
|
FROM device d
|
2025-06-28 17:18:05 +08:00
|
|
|
LEFT JOIN device_type t ON d.device_type = t.id
|
|
|
|
<where>
|
|
|
|
<!-- 时间范围等其他条件保持原样 -->
|
|
|
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
|
|
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceMac != null">
|
|
|
|
and d.device_mac = #{criteria.deviceMac}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceImei != null">
|
|
|
|
and d.device_imei = #{criteria.deviceImei}
|
|
|
|
</if>
|
2025-07-04 15:42:10 +08:00
|
|
|
<if test="criteria.deviceType != null">
|
|
|
|
and d.device_type = #{criteria.deviceType}
|
2025-06-28 17:18:05 +08:00
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceStatus != null">
|
2025-07-04 15:42:10 +08:00
|
|
|
and d.device_status = #{criteria.deviceStatus}
|
2025-07-02 15:29:09 +08:00
|
|
|
</if>
|
|
|
|
<if test="criteria.currentOwnerId != null">
|
2025-07-04 15:42:10 +08:00
|
|
|
and d.current_owner_id = #{criteria.currentOwnerId}
|
2025-06-28 17:18:05 +08:00
|
|
|
</if>
|
2025-07-04 15:42:10 +08:00
|
|
|
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
|
|
|
and d.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
2025-06-28 17:18:05 +08:00
|
|
|
</if>
|
|
|
|
<if test="criteria.tenantId != null">
|
|
|
|
AND tenant_id = #{criteria.tenantId}
|
|
|
|
</if>
|
|
|
|
</where>
|
2025-07-04 15:42:10 +08:00
|
|
|
order by d.create_time desc
|
2025-06-28 17:18:05 +08:00
|
|
|
</select>
|
|
|
|
|
2025-07-08 14:46:05 +08:00
|
|
|
|
|
|
|
<!-- 分页查询设备 -->
|
|
|
|
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
|
|
|
select
|
|
|
|
da.id AS id,d.device_name,
|
|
|
|
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
2025-07-09 13:41:03 +08:00
|
|
|
d.update_time, dg.id AS device_type, d.remark, d.binding_status,d.type_name AS typeName,
|
2025-07-08 14:46:05 +08:00
|
|
|
da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus,
|
|
|
|
da.create_time AS create_time , da.assigner_name AS createByName , da.id AS assignId
|
|
|
|
from device d
|
|
|
|
LEFT JOIN device_type t ON d.device_type = t.id
|
2025-07-09 13:41:03 +08:00
|
|
|
LEFT JOIN device_type_grants dg ON dg.device_type_id = t.id
|
2025-07-08 14:46:05 +08:00
|
|
|
LEFT JOIN device_assignments da ON da.device_id = d.id
|
|
|
|
<where>
|
|
|
|
<!-- 时间范围等其他条件保持原样 -->
|
|
|
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
|
|
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceMac != null">
|
|
|
|
and d.device_mac = #{criteria.deviceMac}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceImei != null">
|
|
|
|
and d.device_imei = #{criteria.deviceImei}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceType != null">
|
|
|
|
and d.device_type = #{criteria.deviceType}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceStatus != null">
|
|
|
|
and da.active = #{criteria.deviceStatus}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
|
|
|
and da.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
|
|
|
</if>
|
|
|
|
AND da.assignee_id = #{criteria.currentOwnerId}
|
2025-07-09 16:29:25 +08:00
|
|
|
AND dg.customer_id = #{criteria.currentOwnerId}
|
2025-07-08 14:46:05 +08:00
|
|
|
</where>
|
|
|
|
ORDER BY da.create_time DESC
|
|
|
|
</select>
|
|
|
|
|
2025-06-28 17:18:05 +08:00
|
|
|
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
|
|
|
select
|
|
|
|
d.id, d.customer_id, d.device_name,
|
|
|
|
d.device_pic, d.device_mac, d.device_sn, d.create_by, d.update_by,
|
|
|
|
d.create_time, d.update_time, d.longitude, d.latitude, d.remark
|
|
|
|
from device d
|
|
|
|
<where>
|
|
|
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
|
|
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceMac != null">
|
|
|
|
and d.device_mac = #{criteria.deviceMac}
|
|
|
|
</if>
|
2025-07-02 17:53:53 +08:00
|
|
|
<if test="criteria.deviceTypeId != null">
|
|
|
|
and d.device_type = #{criteria.deviceTypeId}
|
2025-06-28 17:18:05 +08:00
|
|
|
</if>
|
|
|
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
|
|
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
order by d.id desc
|
|
|
|
</select>
|
2025-07-08 14:46:05 +08:00
|
|
|
|
2025-07-09 16:59:54 +08:00
|
|
|
<!-- 根据条件查询 -->
|
|
|
|
<select id="findDevices" resultType="com.fuyuanshen.equipment.domain.Device"
|
|
|
|
parameterType="com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria">
|
|
|
|
SELECT d.*
|
|
|
|
FROM device d
|
|
|
|
<where>
|
|
|
|
<!-- 时间范围等其他条件保持原样 -->
|
|
|
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
|
|
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceMac != null">
|
|
|
|
and d.device_mac = #{criteria.deviceMac}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceImei != null">
|
|
|
|
and d.device_imei = #{criteria.deviceImei}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceType != null">
|
|
|
|
and d.device_type = #{criteria.deviceType}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.deviceStatus != null">
|
|
|
|
and d.device_status = #{criteria.deviceStatus}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.currentOwnerId != null">
|
|
|
|
and d.current_owner_id = #{criteria.currentOwnerId}
|
|
|
|
</if>
|
|
|
|
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
|
|
|
and d.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
2025-07-08 09:00:14 +08:00
|
|
|
<select id="queryAppDeviceList" resultType="com.fuyuanshen.equipment.domain.vo.AppDeviceVo">
|
2025-07-08 14:46:05 +08:00
|
|
|
select d.id,
|
|
|
|
d.device_name,
|
|
|
|
d.device_mac,
|
|
|
|
d.device_sn,
|
|
|
|
d.device_imei,
|
|
|
|
d.device_mac,
|
|
|
|
dt.communication_mode
|
|
|
|
from device d
|
|
|
|
inner join device_type dt on d.device_type = dt.id
|
|
|
|
where d.binding_user_id = #{criteria.bindingUserId}
|
2025-07-08 09:00:14 +08:00
|
|
|
</select>
|
2025-06-28 17:18:05 +08:00
|
|
|
|
2025-07-04 15:42:10 +08:00
|
|
|
<!-- 获取分配设备的客户 -->
|
|
|
|
<select id="getAssignCustomer" resultType="com.fuyuanshen.equipment.domain.Device">
|
|
|
|
SELECT *
|
|
|
|
FROM device
|
2025-07-05 15:55:46 +08:00
|
|
|
WHERE original_device_id = #{customerId}
|
2025-07-04 15:42:10 +08:00
|
|
|
AND device_status = 1
|
|
|
|
</select>
|
|
|
|
|
2025-07-05 15:55:46 +08:00
|
|
|
<!-- 获取设备链 -->
|
|
|
|
<select id="findByOriginalDeviceId" resultType="com.fuyuanshen.equipment.domain.Device"
|
|
|
|
parameterType="java.lang.Long">
|
|
|
|
SELECT id, original_device_id
|
|
|
|
FROM device
|
|
|
|
WHERE original_device_id = #{originalDeviceId}
|
|
|
|
</select>
|
|
|
|
|
2025-06-28 17:18:05 +08:00
|
|
|
</mapper>
|