<?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="org.springblade.modules.grid.mapper.GridmanMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="gridmanResultMap" type="org.springblade.modules.grid.entity.GridmanEntity">
|
<result column="id" property="id"/>
|
<result column="grid_id" property="gridId"/>
|
<result column="user_id" property="userId"/>
|
<result column="gridman_name" property="gridmanName"/>
|
<result column="mobile" property="mobile"/>
|
<result column="remark" property="remark"/>
|
<result column="create_time" property="createTime"/>
|
<result column="create_user" property="createUser"/>
|
<result column="update_time" property="updateTime"/>
|
<result column="update_user" property="updateUser"/>
|
<result column="is_deleted" property="isDeleted"/>
|
</resultMap>
|
|
<!--自定义分页查询-->
|
<select id="selectGridmanPage" resultType="org.springblade.modules.grid.vo.GridmanVO">
|
select
|
jgm.*,
|
jg.grid_name gridName,jg.community_code communityCode,
|
br.name as communityName,
|
br.town_name as townName
|
from jczz_gridman jgm
|
left join jczz_grid jg on jg.grid_code = jgm.grid_code and jg.is_deleted = 0
|
left join blade_region br on br.code = jg.community_code
|
where jgm.is_deleted = 0
|
<if test="gridman.gridmanName!=null and gridman.gridmanName!=''">
|
and jgm.gridman_name like concat('%',#{gridman.gridmanName},'%')
|
</if>
|
<if test="gridman.mobile!=null and gridman.mobile!=''">
|
and jgm.mobile like concat('%',#{gridman.mobile},'%')
|
</if>
|
<if test="gridman.gridId!=null">
|
and jg.id = #{gridman.gridId}
|
</if>
|
<if test="gridman.communityCode!=null and gridman.communityCode!=''">
|
and jg.community_code like concat('%',#{gridman.communityCode},'%')
|
</if>
|
<if test="gridman.communityName!=null and gridman.communityName!=''">
|
and br.name like concat('%',#{gridman.communityName},'%')
|
</if>
|
<if test="gridman.townName!=null and gridman.townName!=''">
|
and br.town_name like concat('%',#{gridman.townName},'%')
|
</if>
|
<if test="isAdministrator==2">
|
<choose>
|
<when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
|
and jg.community_code in
|
<foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
|
#{code}
|
</foreach>
|
</when>
|
<otherwise>
|
and jg.community_code in ('')
|
</otherwise>
|
</choose>
|
</if>
|
</select>
|
|
<!--自定义分页查询-->
|
<select id="getGridmanList" resultType="org.springblade.modules.grid.vo.GridmanVO">
|
select
|
jgm.*
|
from jczz_gridman jgm
|
where jgm.is_deleted = 0
|
<if test="gridman.gridmanName!=null and gridman.gridmanName!=''">
|
and jgm.gridman_name like concat('%',#{gridman.gridmanName},'%')
|
</if>
|
<if test="gridman.mobile!=null and gridman.mobile!=''">
|
and jgm.mobile like concat('%',#{gridman.mobile},'%')
|
</if>
|
</select>
|
|
<select id="getGridStatistics" resultType="java.lang.Integer">
|
SELECT count(1) number
|
FROM jczz_gridman jgm
|
LEFT JOIN jczz_grid jg ON jg.grid_code = jgm.grid_code
|
<where>
|
<if test="communityCodeList !=null and communityCodeList.size() >0">
|
jg.community_code in
|
<foreach collection="communityCodeList" item="code" open="(" close=")" separator=",">
|
#{code}
|
</foreach>
|
</if>
|
AND jg.is_deleted = 0
|
<if test="userId!=null and roleType == '1'">
|
and jgm.user_id= #{userId}
|
</if>
|
</where>
|
</select>
|
|
<select id="getCompanyStatistics" resultType="java.lang.Integer">
|
SELECT
|
count(1)
|
FROM
|
jczz_property_company_district jpcd
|
LEFT JOIN jczz_district jd ON jd.id = jpcd.district_id
|
<where>
|
jd.community_code in
|
<foreach collection="communityCodeList" item="code" open="(" close=")" separator=",">
|
#{code}
|
</foreach>
|
and jpcd.is_deleted= 0
|
<if test="userId!=null and roleType == '1'">
|
AND jd.aoi_code in (
|
SELECT distinct
|
jda.aoi_code
|
FROM
|
jczz_grid jg
|
LEFT JOIN jczz_gridman jgm ON jg.grid_code = jgm.grid_code
|
LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jg.house_code
|
WHERE
|
jgm.user_id = #{userId}
|
AND jg.is_deleted = 0
|
AND jda.aoi_code IS NOT NULL
|
)
|
</if>
|
</where>
|
</select>
|
|
<select id="getOwnersCommitteeStatistics" resultType="java.lang.Integer">
|
SELECT
|
count(1)
|
FROM jczz_owners_committee joc LEFT JOIN
|
jczz_district jd ON jd.id = joc.area_id
|
<where>
|
jd.community_code in
|
<foreach collection="communityCodeList" item="code" open="(" close=")" separator=",">
|
#{code}
|
</foreach>
|
and joc.delete_flag= 0
|
<if test="userId!=null and roleType == '1'">
|
AND jd.aoi_code in (
|
SELECT distinct
|
jda.aoi_code
|
FROM
|
jczz_grid jg
|
LEFT JOIN jczz_gridman jgm ON jg.grid_code = jgm.grid_code
|
LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jg.house_code
|
WHERE
|
jgm.user_id = #{userId}
|
AND jg.is_deleted = 0
|
AND jda.aoi_code IS NOT NULL
|
)
|
</if>
|
</where>
|
</select>
|
|
|
<!--网格员表 自定义详情-->
|
<select id="getDetail" resultType="org.springblade.modules.grid.vo.GridmanVO">
|
select
|
jgm.*,jg.community_code communityCode
|
from jczz_gridman jgm
|
left join jczz_grid jg on jg.grid_code = jgm.grid_code and jg.is_deleted = 0
|
where jgm.is_deleted = 0
|
and jgm.id = #{gridman.id}
|
</select>
|
|
<!--查询网格id-->
|
<select id="getGridIdByUserId" resultType="java.lang.Integer">
|
select
|
jgm.grid_id
|
from jczz_gridman jgm
|
where jgm.is_deleted = 0
|
and jgm.user_id = #{userId}
|
limit 1
|
</select>
|
|
<select id="getGridManByCode" resultType="org.springblade.modules.system.entity.User">
|
SELECT
|
bu.*
|
FROM
|
blade_user bu
|
LEFT JOIN jczz_gridman jgm ON bu.id = jgm.user_id
|
LEFT JOIN jczz_grid jg ON jgm.grid_code = jg.grid_code
|
WHERE
|
jg.community_code IN
|
(
|
SELECT jg.community_code FROM jczz_grid jg LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
|
WHERE jgr.house_code = #{houseCode}
|
)
|
AND bu.is_deleted = 0
|
</select>
|
</mapper>
|