王佳豪
2021-06-26 718f604deb342b0bee6c588bb44e22ced3371fb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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.slcf.dao.LocationDao">
 
<!-- mapper不支持sql语句嵌套时,采用sql片段包含方式,解决xml标签问题 -->
<sql id="locationConditionSql">    
        <if test="loc_no!=null and loc_no!='' ">
            and a.loc_no like '%' + #{loc_no} + '%'
        </if>
        <if test="loc_sts!=null and loc_sts!='' ">
            and a.loc_sts like '%' + #{loc_sts} + '%'
        </if>
        <if test="crn_no!=null and crn_no!=0 ">
            and crn_no = #{crn_no}
        </if>    
        <if test="row1!=null and row1!=0 ">
            and row1 = #{row1}
        </if>
        <if test="bay1!=null and bay1!=0 ">
            and bay1 = #{bay1}
        </if>
        <if test="lev1!=null and lev1!=0 ">
            and lev1 = #{lev1}
        </if>    
</sql>
 
<select id="queryLocationList" parameterType="com.slcf.bean.LocationCondition" resultType="com.slcf.pojo.LocationBean">
select top (#{pageSize}) a.*,b.loc_desc loc_sts_name,c.whs_desc loc_type_desc
from asr_loc_mast a left join asr_bas_loc_type b  on a.loc_sts=b.loc_sts 
left join asr_bas_whs c  on a.loc_type=c.whs_type 
<where>
    loc_no not in (select top ((#{pageNumber}-1)*#{pageSize}) loc_no from asr_loc_mast a left join asr_bas_loc_type b  on a.loc_sts=b.loc_sts 
    <where>
        1=1
        <include refid="locationConditionSql"></include>        
    </where>
    order by loc_no asc)
    <include refid="locationConditionSql"></include>
    <![CDATA[
        order by loc_no asc
    ]]>
</where>
</select>
 
<select id="getLocationCount" parameterType="com.slcf.bean.LocationCondition"    resultType="Integer">
select count(1) from asr_loc_mast a left join asr_bas_loc_type b  on a.loc_sts=b.loc_sts
<where>
<![CDATA[
    1=1
]]>
<include refid="locationConditionSql"></include>
</where>
</select>
</mapper>