nxdt-system/bonus-modules/bonus-project/src/main/resources/mapper/system/DeviceInformationMapper.xml

101 lines
4.5 KiB
XML
Raw Normal View History

2025-01-16 16:16:53 +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.bonus.project.mapper.DeviceInformationMapper">
<insert id="addDeviceType" useGeneratedKeys="true" keyProperty="deviceId">
INSERT INTO pf_device_info (device_code, device_name, device_type, device_model, device_user, device_phone,
create_id, create_user, create_time, is_active,puid,ball_index,type_code,device_status)
2025-01-16 16:16:53 +08:00
VALUES (#{deviceCode}, #{deviceName}, #{deviceType}, #{deviceModel}, #{deviceUser}, #{devicePhone},
#{createId}, #{createUser}, now(), '1',#{puid},#{ballIndex},#{typeCode},#{deviceStatus})
2025-01-16 16:16:53 +08:00
</insert>
<update id="updateDeviceInformation">
UPDATE pf_device_info SET
device_name = #{deviceName},
device_user = #{deviceUser},
device_phone = #{devicePhone},
puid = #{puid},
ball_index = #{ballIndex},
update_time = now(),
type_code=#{typeCode},
device_status=#{deviceStatus}
2025-01-16 16:16:53 +08:00
WHERE device_id = #{deviceId}
</update>
<update id="updateDeviceCode">
UPDATE pf_device_info SET device_code = #{deviceCode} WHERE device_id = #{deviceId}
</update>
<delete id="deleteDeviceInformationById">
UPDATE pf_device_info SET is_active = '0', update_time = now() WHERE device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
<select id="listDeviceInformation" resultType="com.bonus.project.domain.DeviceInformation">
SELECT
pdi.device_id AS deviceId,
pdi.device_code AS deviceCode,
pdi.device_name AS deviceName,
pdi.device_type AS deviceType,
pdt.device_name AS deviceTypeName,
pdi.device_model AS deviceModel,
pdi.device_user AS deviceUser,
pdi.device_phone AS devicePhone,
pdi.create_user AS createUser,
pdi.create_time AS createTime,
2025-02-08 14:08:20 +08:00
pdi.puid, pdi.device_status deviceStatus,
pdi.type_code typeCode,
2025-01-16 16:16:53 +08:00
pdi.ball_index as ballIndex,
if(ppi.pro_name IS NULL, '无', ppi.pro_name) AS proName
FROM
pf_device_info AS pdi
LEFT JOIN pt_device_type AS pdt ON pdi.device_type = pdt.device_type AND pdt.is_active = '1'
LEFT JOIN lk_device_pro AS ldp ON ldp.device_id = pdi.device_id AND ldp.is_active = '1'
LEFT JOIN pt_project_info AS ppi ON ppi.pro_id = ldp.pro_id AND ppi.is_active = '1'
WHERE pdi.is_active = '1'
<if test="deviceName != null and deviceName != ''">
AND pdi.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="deviceUser != null and deviceUser != ''">
AND pdi.device_user like concat('%', #{deviceUser}, '%')
</if>
<if test="createUser != null and createUser != ''">
AND pdi.create_user like concat('%', #{createUser}, '%')
</if>
<if test="deviceType != null and deviceType != ''">
AND pdi.device_type = #{deviceType}
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(pdi.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(pdi.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</select>
<select id="checkDeviceNameUnique" resultType="com.bonus.project.domain.DeviceInformation">
SELECT device_name AS deviceName
FROM pf_device_info
WHERE is_active = '1'
AND device_name = #{deviceName}
<if test="deviceId != null and deviceId != ''">
AND device_id != #{deviceId}
</if>
</select>
<select id="checkDeviceBind" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM lk_device_pro
WHERE is_active = '1'
AND device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</select>
<select id="getDeviceIdByPuid" resultType="java.lang.Integer">
select count(1)
from pf_device_info
where is_active=1 and puid=#{puid} and ball_index=#{ballIndex}
<if test="deviceId!=null and deviceId!=''">
and device_id!=#{deviceId}
</if>
</select>
2025-01-16 16:16:53 +08:00
</mapper>