<?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.sandu.ximon.dao.mapper.PlcMapper">
|
|
<resultMap type="com.sandu.ximon.dao.domain.Plc" id="BaseResultMap">
|
<result property="plcId" column="plc_light_id" jdbcType="INTEGER"/>
|
<result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
|
<result property="plcRemark" column="plc_remark" jdbcType="VARCHAR"/>
|
<result property="plcCount" column="plc_light_count" jdbcType="INTEGER"/>
|
<result property="plcLight1" column="plc_light1" jdbcType="INTEGER"/>
|
<result property="plcLight2" column="plc_light2" jdbcType="INTEGER"/>
|
<result property="plcLight3" column="plc_light3" jdbcType="INTEGER"/>
|
<result property="plcTimingControl" column="plc_timing_control" jdbcType="INTEGER"/>
|
<result property="plcSensorControl" column="plc_sensor_control" jdbcType="INTEGER"/>
|
<result property="plcSoftwareVersion" column="plc_software_version" jdbcType="VARCHAR"/>
|
<result property="plcHardwareVersion" column="plc_hardware_version" jdbcType="VARCHAR"/>
|
<result property="plcIemi" column="plc_IEMI" jdbcType="VARCHAR"/>
|
<result property="plcIccid" column="plc_ICCID" jdbcType="VARCHAR"/>
|
<result property="plcCreateTime" column="plc_create_time" jdbcType="TIMESTAMP"/>
|
<result property="plcUpdateTime" column="plc_update_time" jdbcType="TIMESTAMP"/>
|
</resultMap>
|
|
<select id="listPlc" resultType="com.sandu.ximon.dao.bo.PlcBo">
|
SELECT
|
t1.*,
|
t2.id AS pole_id,
|
t2.pole_code,
|
t2.pole_name,
|
t4.task_id AS task_id,
|
t4.task_name AS task_name,
|
t3.plc_address AS plc_address
|
FROM
|
plc t1
|
LEFT JOIN pole_binding t5 ON t1.device_code = t5.device_code
|
LEFT JOIN pole t2 ON t2.id=t5.pole_id AND t5.device_type=13
|
LEFT JOIN plc_task_pole_relation t3 ON t3.pole_id = t2.id
|
LEFT JOIN plc_task t4 ON t3.task_id = t4.task_id
|
<where>
|
<if test="clientId != null">
|
AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId})
|
</if>
|
<if test="keyword != null and keyword != ''">
|
AND (
|
t1.device_code LIKE CONCAT('%', #{keyword},'%')
|
OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
|
)
|
</if>
|
</where>
|
|
</select>
|
|
<select id="listCode" resultType="java.lang.String">
|
SELECT
|
t1.device_code
|
FROM
|
plc t1
|
LEFT JOIN pole t2 ON t1.device_code = t2.device_code
|
<where>
|
<if test="userId != null">
|
AND (t2.user_id = #{userId} OR t2.client_id = #{userId})
|
</if>
|
<if test="keyword != null and keyword != ''">
|
AND (
|
t1.device_code LIKE CONCAT('%', #{keyword},'%')
|
OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
|
)
|
</if>
|
<if test="deviceCode != null and deviceCode!= ''">
|
AND t1.device_code = #{deviceCode}
|
</if>
|
</where>
|
|
</select>
|
|
</mapper>
|