TBoxOperationMapper.xml 7.28 KB
Newer Older
wzp's avatar
wzp committed
1 2
<?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">
liqin's avatar
liqin committed
3
<mapper namespace="cn.chnmuseum.party.mapper.TBoxOperationMapper">
wzp's avatar
wzp committed
4 5

    <!-- 通用查询映射结果 -->
liqin's avatar
liqin committed
6
    <resultMap id="BaseResultMap" type="cn.chnmuseum.party.model.TBoxOperation">
wzp's avatar
wzp committed
7 8 9 10 11
        <id column="id" property="id"/>
        <result column="organ_id" property="organId"/>
        <result column="mac" property="mac"/>
        <result column="status" property="status"/>
        <result column="area_id" property="areaId"/>
liqin's avatar
liqin committed
12 13 14
        <result column="public_key" property="publicKey"/>
        <result column="private_key" property="privateKey"/>
        <result column="request_count" property="requestCount"/>
wzp's avatar
wzp committed
15 16 17
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="organ_name" property="organName"/>
wzp's avatar
wzp committed
18
        <result column="area_name" property="areaName"/>
liqin's avatar
liqin committed
19
        <result column="user_name" property="userName"/>
wzp's avatar
wzp committed
20 21 22
        <result column="permanent" property="permanent"/>
        <result column="effective_date" property="effectiveDate"/>
        <result column="exired_date" property="exiredDate"/>
wzp's avatar
wzp committed
23 24 25
        <result column="num" property="num"/>
        <result column="begin_date" property="beginDate"/>
        <result column="end_date" property="endDate"/>
wzp's avatar
wzp committed
26 27 28 29
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
liqin's avatar
liqin committed
30
        id, organ_id, mac, status, area_id, public_key, private_key, request_count, create_time, update_time
wzp's avatar
wzp committed
31 32 33
    </sql>

    <select id="getList" resultMap="BaseResultMap">
wzp's avatar
wzp committed
34 35 36
        SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.`user_name` organ_name
        FROM t_box_operation b
        left join t_user r on r.org_id = b.organ_id and r.type = '3'
wzp's avatar
wzp committed
37 38 39 40
        where 1=1
        <if test="status!= null and status != '' ">
            and b.status =#{status}
        </if>
wzp's avatar
wzp committed
41 42 43
        <if test="areaId!= null and areaId != '' ">
            and r.area_id like concat(#{areaId}, '%')
        </if>
wzp's avatar
wzp committed
44
        order by b.create_time desc
wzp's avatar
wzp committed
45
    </select>
wzp's avatar
wzp committed
46 47

    <select id="selectBoxPage" resultMap="BaseResultMap">
liqin's avatar
liqin committed
48 49
        select b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name,a.full_name
        area_name,u.permanent permanent,
wzp's avatar
wzp committed
50
        u.effective_date effective_date,u.exired_date exired_date,count(r.mac_addr) num
wzp's avatar
wzp committed
51 52
        from t_box_operation b
        left join t_organ o on b.organ_id = o.id
liqin's avatar
liqin committed
53
        left join t_user u on u.org_id = b.organ_id and u.type = '3' and u.is_deleted = false
wzp's avatar
wzp committed
54
        left join t_area a on u.area_id = a.id
wzp's avatar
wzp committed
55
        left join run_log r on r.mac_addr = b.mac
wzp's avatar
wzp committed
56 57 58 59 60 61 62
        where 1=1
        <if test="user.orgId!= null and user.orgId != '' ">
            and b.organ_id =#{user.orgId}
        </if>
        <if test="user.areaId!= null and user.areaId != '' ">
            and b.area_id =#{user.areaId}
        </if>
wzp's avatar
wzp committed
63
        <if test="user.orgCode != null and user.orgCode != '' ">
wzp's avatar
wzp committed
64 65
            and o.code LIKE concat(#{user.orgCode}, '%')
        </if>
wzp's avatar
wzp committed
66 67 68
        <if test="user.areaName != null and user.areaName != '' ">
            and b.area_id LIKE concat(#{user.areaName}, '%')
        </if>
wzp's avatar
wzp committed
69 70 71 72 73
        <if test="user.beginDate != null and user.endDate != null ">
            and r.start_time between #{user.beginDate} and #{user.endDate}
        </if>
        group by r.mac_addr,b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name,a.full_name
        ,u.permanent,u.effective_date ,u.exired_date
wzp's avatar
wzp committed
74 75
        order by b.create_time desc
    </select>
wzp's avatar
wzp committed
76 77

    <select id="selectPageList" resultMap="BaseResultMap">
78
        SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.name organ_name ,u.user_name
79
        FROM (t_box_operation b
wzp's avatar
wzp committed
80
        left join t_organ r on r.id = b.organ_id
81
        left join t_user u on u.org_id = b.organ_id and u.type = '2')
wzp's avatar
wzp committed
82 83 84 85 86 87 88 89
        where 1=1
        <if test="tBoxOperation.organId != null and tBoxOperation.organId != '' ">
            and b.organ_id =#{tBoxOperation.organId}
        </if>
        <if test="tBoxOperation.status != null">
            and b.status =#{tBoxOperation.status}
        </if>
        <if test="tBoxOperation.areaId != null and tBoxOperation.areaId != '' ">
wzp's avatar
wzp committed
90 91 92 93
            and b.area_id = #{tBoxOperation.areaId}
        </if>
        <if test="tBoxOperation.areaName != null and tBoxOperation.areaName != '' ">
            and b.area_id LIKE concat(#{tBoxOperation.areaName}, '%')
wzp's avatar
wzp committed
94
        </if>
wzp's avatar
wzp committed
95 96
        <if test="tBoxOperation.organCode != null and tBoxOperation.organCode != '' ">
            and r.code LIKE concat(#{tBoxOperation.organCode}, '%')
wzp's avatar
wzp committed
97
        </if>
wzp's avatar
wzp committed
98
        order by b.create_time desc
wzp's avatar
wzp committed
99 100
    </select>

wzp's avatar
wzp committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
    <select id="selectBoxList" resultMap="BaseResultMap">
        select b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name,a.full_name
        area_name,u.permanent permanent,
        u.effective_date effective_date,u.exired_date exired_date,count(r.mac_addr) num
        from t_box_operation b
        left join t_organ o on b.organ_id = o.id
        left join t_user u on u.org_id = b.organ_id and u.type = '3' and u.is_deleted = false
        left join t_area a on u.area_id = a.id
        left join run_log r on r.mac_addr = b.mac
        where 1=1
        <if test="user.orgId!= null and user.orgId != '' ">
            and b.organ_id =#{user.orgId}
        </if>
        <if test="user.areaId!= null and user.areaId != '' ">
            and b.area_id =#{user.areaId}
        </if>
        <if test="user.orgCode != null and user.orgCode != '' ">
            and o.code LIKE concat(#{user.orgCode}, '%')
        </if>
        <if test="user.areaName != null and user.areaName != '' ">
            and b.area_id LIKE concat(#{user.areaName}, '%')
        </if>
        <if test="user.beginDate != null and user.endDate != null ">
            and r.start_time between #{user.beginDate} and #{user.endDate}
        </if>
        group by r.mac_addr,b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name,a.full_name
        ,u.permanent,u.effective_date ,u.exired_date
        order by b.create_time desc
    </select>

131 132 133 134
    <select id="selectListA" resultType="cn.chnmuseum.party.model.TBoxOperation">
        SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.name organ_name ,u.user_name
        FROM t_box_operation b
        left join t_organ r on r.id = b.organ_id
135
        left join t_user u on u.org_id = b.organ_id and u.type = '2'
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
        where 1=1
        <if test="tBoxOperation.organId != null and tBoxOperation.organId != '' ">
            and b.organ_id =#{tBoxOperation.organId}
        </if>
        <if test="tBoxOperation.status != null">
            and b.status =#{tBoxOperation.status}
        </if>
        <if test="tBoxOperation.areaId != null and tBoxOperation.areaId != '' ">
            and b.area_id = #{tBoxOperation.areaId}
        </if>
        <if test="tBoxOperation.areaName != null and tBoxOperation.areaName != '' ">
            and b.area_id LIKE concat(#{tBoxOperation.areaName}, '%')
        </if>
        <if test="tBoxOperation.organCode != null and tBoxOperation.organCode != '' ">
            and r.code LIKE concat(#{tBoxOperation.organCode}, '%')
        </if>
        order by b.create_time desc
    </select>

wzp's avatar
wzp committed
155
</mapper>