<?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.nantian.cloud.jly.mapper.ConfigureDeviceMapper">

    <sql id="Base_Column_List">
        a.id, a.enterprise_code,e.cmp_name as enterprise_name,  a.device_name, a.device_no, a.model, a.location,a.dept,a.device_type,
        a.using_date,a.current_state, a.manufacturer, a.energy_code, a.energy_value,
        a.process_unit_code, a.state, a.remark,a.userid, a.update_time, a.del_flag, a.dept_id
    </sql>
    <select id="getDevPage" resultType="com.nantian.cloud.jly.entity.ConfigureDevice">
        select
        <include refid="Base_Column_List"></include>
        from configure_device a
        left join enterprise_info e on a.enterprise_code = e.enterprise_code
        <trim prefix="where" prefixOverrides="and">
            <if test="query.enterpriseCode != null and query.enterpriseCode != ''">
                and a.enterprise_code = #{query.enterpriseCode}
            </if>
            <if test="query.enterpriseName != null and query.enterpriseName != ''">
                and e.cmp_name LIKE CONCAT('%',#{query.enterpriseName},'%')
            </if>
            <if test="query.deviceName != null and query.deviceName != ''">
                and a.device_name LIKE CONCAT('%',#{query.deviceName},'%')
            </if>
        </trim>
    </select>



</mapper>
