<?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.zy.asrs.mapper.NodeMapper"> 
 | 
  
 | 
    <!-- 通用查询映射结果 --> 
 | 
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.Node"> 
 | 
        <id column="id" property="id" /> 
 | 
        <result column="host_id" property="hostId" /> 
 | 
        <result column="uuid" property="uuid" /> 
 | 
        <result column="name" property="name" /> 
 | 
        <result column="parent_id" property="parentId" /> 
 | 
        <result column="parent_name" property="parentName" /> 
 | 
        <result column="type" property="type" /> 
 | 
        <result column="path" property="path" /> 
 | 
        <result column="name_path" property="namePath" /> 
 | 
        <result column="level" property="level" /> 
 | 
        <result column="leading" property="leading" /> 
 | 
        <result column="sort" property="sort" /> 
 | 
        <result column="barcode" property="barcode" /> 
 | 
        <result column="major" property="major" /> 
 | 
        <result column="status" property="status" /> 
 | 
        <result column="create_time" property="createTime" /> 
 | 
        <result column="create_by" property="createBy" /> 
 | 
        <result column="update_time" property="updateTime" /> 
 | 
        <result column="update_by" property="updateBy" /> 
 | 
        <result column="memo" property="memo" /> 
 | 
        <result column="row1" property="row1" /> 
 | 
        <result column="bay1" property="bay1" /> 
 | 
        <result column="lev1" property="lev1" /> 
 | 
  
 | 
    </resultMap> 
 | 
    <sql id="nodeCondition"> 
 | 
        <if test="host_id != null and host_id != ''"> 
 | 
            and mld.host_id = #{host_id} 
 | 
        </if> 
 | 
        <if test="loc_no != null and loc_no != ''"> 
 | 
            and mld.loc_no like concat('%',#{loc_no},'%') 
 | 
        </if> 
 | 
        <if test="locNo != null and locNo != ''"> 
 | 
            and mld.loc_no like concat('%',#{loc_no},'%') 
 | 
        </if> 
 | 
        <if test="matnr != null and matnr != ''"> 
 | 
            and mld.matnr like concat('%',#{matnr},'%') 
 | 
        </if> 
 | 
        <if test="maktx != null and maktx != ''"> 
 | 
            and mld.maktx like concat('%',#{maktx},'%') 
 | 
        </if> 
 | 
        <if test="startTime!=null and endTime!=null"> 
 | 
            and mld.update_time between #{startTime} and #{endTime} 
 | 
        </if> 
 | 
    </sql> 
 | 
    <update id="updateStockFreeze"> 
 | 
        update man_node 
 | 
        set status = #{status} 
 | 
          , update_time = getdate() 
 | 
        where 1=1 
 | 
          and name = #{name} 
 | 
    </update> 
 | 
  
 | 
    <select id="selectByUuid" resultMap="BaseResultMap"> 
 | 
        select * from man_node where 1=1 and uuid=#{uuid} and host_id = #{hostId} and status = 1 
 | 
    </select> 
 | 
    <select id="listByPage" resultMap="BaseResultMap"> 
 | 
        select * from 
 | 
        ( 
 | 
        SELECT 
 | 
        ROW_NUMBER() over (order by mld.create_time desc) as row, 
 | 
        mld.* 
 | 
        FROM man_loc_detl mld 
 | 
        LEFT JOIN man_node mn ON mld.node_id = mn.id 
 | 
        LEFT JOIN man_mat mm ON mld.matnr = mm.matnr 
 | 
        LEFT JOIN man_tag mt ON mm.tag_id = mt.id 
 | 
        WHERE 1=1 
 | 
        AND (CHARINDEX(','+#{node_id}+',', ','+mn.path+',') > 0 OR mn.id = #{node_id}) 
 | 
        AND (CHARINDEX(','+#{tag_id}+',', ','+mt.path+',') > 0 OR mt.id = #{tag_id}) 
 | 
        <include refid="nodeCondition"></include> 
 | 
        ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize}) 
 | 
    </select> 
 | 
  
 | 
    <select id="listByPageCount" parameterType="java.util.Map" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(1) 
 | 
        FROM man_loc_detl mld 
 | 
        LEFT JOIN man_node mn ON mld.node_id = mn.id 
 | 
        LEFT JOIN man_mat mm ON mld.matnr = mm.matnr 
 | 
        LEFT JOIN man_tag mt ON mm.tag_id = mt.id 
 | 
        WHERE 1=1 
 | 
        AND (CHARINDEX(','+#{node_id}+',', ','+mn.path+',') > 0 OR mn.id = #{node_id}) 
 | 
        AND (CHARINDEX(','+#{tag_id}+',', ','+mt.path+',') > 0 OR mt.id = #{tag_id}) 
 | 
        <include refid="nodeCondition"></include> 
 | 
    </select> 
 | 
    <select id="getRommendLoc" resultType="java.lang.String"> 
 | 
        select name from man_node 
 | 
        where level = 3 
 | 
        and (row1 >=#{rowBeg}  and row1 <= #{rowEnd}) 
 | 
        and (bay1 >=#{bayBeg}  and bay1 <= #{bayEnd}) 
 | 
        and (lev1 >=#{levBeg}  and lev1 <= #{levEnd}) 
 | 
  
 | 
    </select> 
 | 
  
 | 
</mapper> 
 |