<?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.stylefeng.guns.modular.system.dao.TSiteMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TSite">
|
<id column="id" property="id" />
|
<result column="name" property="name" />
|
<result column="province" property="province" />
|
<result column="provinceCode" property="provinceCode" />
|
<result column="city" property="city" />
|
<result column="cityCode" property="cityCode" />
|
<result column="district" property="district" />
|
<result column="districtCode" property="districtCode" />
|
<result column="state" property="state" />
|
<result column="insertTime" property="insertTime" />
|
<result column="insertUserId" property="insertUserId" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, name, province, provinceCode, city, cityCode, district, districtCode, state, insertTime, insertUserId
|
</sql>
|
|
<!--根据条件查询站点列表-->
|
<select id="getSiteList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
|
SELECT * FROM (SELECT uu.`name` as insertUser,IFNULL(ls.num,0) as lineNum,ss.* FROM t_site as ss
|
LEFT JOIN sys_user as uu on uu.id = ss.insertUserId
|
LEFT JOIN (SELECT COUNT(a.id) as num,siteId FROM t_line_site a left join t_line b on (a.lineId = b.id) where b.state != 3 GROUP BY a.siteId) as ls on ls.siteId = ss.id) as o
|
<where>
|
o.state != 3
|
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
AND (o.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
|
</if>
|
<if test="name != null and name != ''">
|
and o.name LIKE CONCAT('%',#{name},'%')
|
</if>
|
<if test="insertUser != null and insertUser != ''">
|
and o.insertUser LIKE CONCAT('%',#{insertUser},'%')
|
</if>
|
<if test="city != null and city != ''">
|
and (o.province LIKE CONCAT('%',#{city},'%') or o.city LIKE CONCAT('%',#{city},'%') or o.district LIKE CONCAT('%',#{city},'%'))
|
</if>
|
<if test="state != null and state != ''">
|
and o.state = #{state}
|
</if>
|
</where>
|
order by o.id desc
|
</select>
|
|
|
<select id="query" resultType="TSite">
|
select
|
id as id,
|
name as name,
|
province as province,
|
provinceCode as provinceCode,
|
city as city,
|
cityCode as cityCode,
|
district as district,
|
districtCode as districtCode,
|
state as state,
|
insertTime as insertTime,
|
insertUserId as insertUserId
|
from t_site where state != 3
|
<choose>
|
<when test="null != provinceCode">
|
and provinceCode = #{provinceCode}
|
</when>
|
<otherwise>
|
and provinceCode is null
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="null != cityCode">
|
and cityCode = #{cityCode}
|
</when>
|
<otherwise>
|
and cityCode is null
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="null != districtCode">
|
and districtCode = #{districtCode}
|
</when>
|
<otherwise>
|
and districtCode is null
|
</otherwise>
|
</choose>
|
</select>
|
<select id="getCompanySiteList" resultType="java.util.Map">
|
SELECT * FROM (SELECT uu.`name` as insertUser,IFNULL(ls.num,0) as lineNum,ss.* FROM t_site as ss
|
RIGHT JOIN (select * from sys_user where id=#{id}) as uu on uu.id = ss.insertUserId
|
LEFT JOIN (SELECT COUNT(a.id) as num,siteId FROM t_line_site a left join t_line b on (a.lineId = b.id) where b.state != 3 GROUP BY a.siteId) as ls on ls.siteId = ss.id) as o
|
<where>
|
o.state != 3
|
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
AND (o.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
|
</if>
|
<if test="name != null and name != ''">
|
and o.name LIKE CONCAT('%',#{name},'%')
|
</if>
|
<if test="insertUser != null and insertUser != ''">
|
and o.insertUser LIKE CONCAT('%',#{insertUser},'%')
|
</if>
|
<if test="city != null and city != ''">
|
and (o.province LIKE CONCAT('%',#{city},'%') or o.city LIKE CONCAT('%',#{city},'%') or o.district LIKE CONCAT('%',#{city},'%'))
|
</if>
|
<if test="state != null and state != ''">
|
and o.state = #{state}
|
</if>
|
</where>
|
order by o.id desc
|
</select>
|
</mapper>
|