Files
smart_management_dev/src/main/resources/mybatis/information/DeviceInfoMapper.xml

157 lines
5.3 KiB
XML
Raw Normal View History

2025-05-12 08:39:57 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
2025-07-10 08:40:36 +08:00
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2025-12-15 08:19:59 +08:00
2025-05-30 16:13:27 +08:00
<mapper namespace="com.zg.project.information.mapper.DeviceInfoMapper">
2025-07-10 08:40:36 +08:00
2025-12-15 08:19:59 +08:00
<resultMap type="com.zg.project.information.domain.DeviceInfo" id="DeviceInfoResult">
<result property="deviceId" column="device_id"/>
<result property="ipAddress" column="ip_address"/>
<result property="port" column="port"/>
<result property="warehouseCode" column="warehouse_code"/>
<result property="sceneId" column="scene_id"/>
<result property="warehouseName" column="warehouse_name"/>
<result property="parentWarehouseCode" column="parent_warehouse_code"/>
<result property="parentWarehouseName" column="parent_warehouse_name"/>
<result property="sceneName" column="scene_name"/>
<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="isDelete" column="is_delete"/>
2025-05-12 08:39:57 +08:00
</resultMap>
<sql id="selectDeviceInfoVo">
2025-07-10 08:40:36 +08:00
SELECT
d.device_id,
d.ip_address,
d.port,
2025-12-15 08:19:59 +08:00
d.warehouse_code,
2025-07-10 08:40:36 +08:00
d.scene_id,
2025-12-15 08:19:59 +08:00
w.warehouse_name,
w.parent_warehouse_code,
w.parent_warehouse_name,
s.scene_name,
2025-07-10 08:40:36 +08:00
d.create_by,
d.create_time,
d.update_by,
d.update_time,
d.is_delete
FROM device_info d
2025-12-15 08:19:59 +08:00
LEFT JOIN warehouse_info w
ON d.warehouse_code = w.warehouse_code
LEFT JOIN scene_mapping_bak s
ON d.scene_id = s.scene_code
2025-05-12 08:39:57 +08:00
</sql>
2025-12-15 08:19:59 +08:00
<!-- 列表 -->
<select id="selectDeviceInfoList"
parameterType="com.zg.project.information.domain.DeviceInfo"
resultMap="DeviceInfoResult">
2025-05-12 08:39:57 +08:00
<include refid="selectDeviceInfoVo"/>
2025-12-15 08:19:59 +08:00
2025-07-10 08:40:36 +08:00
<where>
2025-12-15 08:19:59 +08:00
<!-- 默认未删除 -->
<choose>
<when test="isDelete != null and isDelete != ''">
AND d.is_delete = #{isDelete}
</when>
<otherwise>
AND d.is_delete = '0'
</otherwise>
</choose>
<if test="ipAddress != null and ipAddress != ''">
AND d.ip_address = #{ipAddress}
</if>
<if test="port != null">
AND d.port = #{port}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
AND d.warehouse_code = #{warehouseCode}
</if>
<if test="parentWarehouseCode != null and parentWarehouseCode != ''">
AND w.parent_warehouse_code = #{parentWarehouseCode}
</if>
<if test="sceneId != null and sceneId != ''">
AND d.scene_id = #{sceneId}
</if>
2025-05-12 08:39:57 +08:00
</where>
2025-12-15 08:19:59 +08:00
ORDER BY d.device_id DESC
2025-05-12 08:39:57 +08:00
</select>
2025-07-10 08:40:36 +08:00
2025-12-15 08:19:59 +08:00
<!-- 详情 -->
<select id="selectDeviceInfoByDeviceId"
parameterType="java.lang.Long"
resultMap="DeviceInfoResult">
2025-05-12 08:39:57 +08:00
<include refid="selectDeviceInfoVo"/>
2025-07-10 08:40:36 +08:00
WHERE d.device_id = #{deviceId}
2025-05-12 08:39:57 +08:00
</select>
2025-12-15 08:19:59 +08:00
<!-- 新增 -->
<insert id="insertDeviceInfo" parameterType="com.zg.project.information.domain.DeviceInfo">
INSERT INTO device_info (
ip_address,
port,
warehouse_code,
scene_id,
create_by,
create_time,
update_by,
update_time,
is_delete
) VALUES (
#{ipAddress},
#{port},
#{warehouseCode},
#{sceneId},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
<choose>
<when test="isDelete != null and isDelete != ''">#{isDelete}</when>
<otherwise>'0'</otherwise>
</choose>
)
2025-05-12 08:39:57 +08:00
</insert>
2025-12-15 08:19:59 +08:00
<!-- 修改 -->
<update id="updateDeviceInfo" parameterType="com.zg.project.information.domain.DeviceInfo">
UPDATE device_info
2025-05-12 08:39:57 +08:00
<trim prefix="SET" suffixOverrides=",">
2025-12-15 08:19:59 +08:00
<if test="ipAddress != null and ipAddress != ''">ip_address = #{ipAddress},</if>
2025-05-12 08:39:57 +08:00
<if test="port != null">port = #{port},</if>
2025-12-15 08:19:59 +08:00
<if test="warehouseCode != null and warehouseCode != ''">warehouse_code = #{warehouseCode},</if>
<if test="sceneId != null and sceneId != ''">scene_id = #{sceneId},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
2025-05-12 08:39:57 +08:00
<if test="updateTime != null">update_time = #{updateTime},</if>
2025-12-15 08:19:59 +08:00
<if test="isDelete != null and isDelete != ''">is_delete = #{isDelete},</if>
2025-05-12 08:39:57 +08:00
</trim>
2025-12-15 08:19:59 +08:00
WHERE device_id = #{deviceId}
2025-05-12 08:39:57 +08:00
</update>
2025-12-15 08:19:59 +08:00
<delete id="deleteDeviceInfoByDeviceId" parameterType="java.lang.Long">
DELETE FROM device_info WHERE device_id = #{deviceId}
2025-05-12 08:39:57 +08:00
</delete>
2025-12-15 08:19:59 +08:00
<delete id="deleteDeviceInfoByDeviceIds" parameterType="Long">
DELETE FROM device_info
WHERE device_id IN
2025-05-12 08:39:57 +08:00
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
2025-12-15 08:19:59 +08:00
2025-07-10 08:40:36 +08:00
</mapper>