<?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.shkj.wms.mapper.BaseLocationPlcMapper">

    <select id="selectBaseLocationPlcList" resultType="com.shkj.wms.vo.BaseLocationPlcVo"
            parameterType="com.shkj.wms.bo.BaseLocationQueryPageBo">

        select * from base_location_plc
        <where>
        <if test="locationCode != null">
            and location_code like concat('%', #{locationCode}, '%')
        </if>

        <if test="locationPlc != null">
            and location_plc like concat('%', #{locationPlc}, '%')
        </if>
        </where>
    </select>


    <select id="selectBasePointByGroupno" parameterType="com.shkj.wms.bo.BasePointDeviceQueryBo" resultType="com.shkj.wms.vo.BasePointDeviceVo">

        SELECT
        point.id as pointId,
        point_no,
        point_name,
        point.tunnel,
        dev_code,
        pointGroup.is_down
        FROM
        base_point point
        INNER JOIN base_point_group pointGroup ON point.point_group = pointGroup.id
        left join wcs_device on point.dev_code=wcs_device.id
        WHERE point.is_active = '1'
        AND ifnull( point.is_occupy, '0' ) = '0'

        <if test="groupNo != null ">
            and pointGroup.group_no =#{groupNo}
        </if>

        <if test="tunnel != null ">
            and point.tunnel =#{tunnel}
        </if>
        <if test="devCode !=null ">
            and point.dev_code=#{devCode}
        </if>

        <if test="direction !=null ">
            and wcs_device.dev_direction=#{direction}
        </if>
    </select>

</mapper>
