市北互联平台后端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

203 lines
7.3 KiB

<?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.epmet.dao.IcStatsResiWarnDao">
<resultMap type="com.epmet.entity.IcStatsResiWarnEntity" id="icStatsResiWarnMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="configId" column="CONFIG_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="agencyPids" column="AGENCY_PIDS"/>
<result property="neighborHoodId" column="NEIGHBOR_HOOD_ID"/>
<result property="buildingId" column="BUILDING_ID"/>
<result property="count" column="COUNT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="selectResiWarnByAgencyId" resultType="com.epmet.entity.IcStatsResiWarnEntity">
select * from ic_stats_resi_warn
where
DEL_FLAG='0'
<if test="agencyId != null and agencyId.trim() != ''">
AND (AGENCY_ID = #{agencyId} or CONCAT(':',AGENCY_PIDS, ':') like CONCAT('%:',#{agencyId},':%'))
</if>
and CUSTOMER_ID = #{customerId}
</select>
<select id="userWarnList" resultType="map">
select
BUILD_ID as buildingId,
GROUP_CONCAT(name) as residentNames
from ic_resi_user
where
BUILD_ID in
<foreach collection="buildingIdList" item="buildingId" open="(" separator="," close=" )">
#{buildingId}
</foreach>
<if test="tableName=='ic_resi_user'">
and ${columnName} = '1'
</if>
<if test="tableName!='ic_resi_user'">
and ID in (
select IC_RESI_USER from ${tableName} where ${columnName} = '1' and CUSTOMER_ID = #{customerId} and DEL_FLAG = '0'
)
</if>
and CUSTOMER_ID = #{customerId}
and DEL_FLAG = '0'
group by BUILD_ID
</select>
<select id="countListByLevelAndCol" resultType="int">
select count(*)
from ic_resi_user
where 1=1
AND STATUS = '0'
<if test="tableName=='ic_resi_user'">
and ${columnName} = '1'
</if>
<if test="tableName!='ic_resi_user'">
and ID in (
select IC_RESI_USER from ${tableName} where ${columnName} = '1' and CUSTOMER_ID = #{customerId} and DEL_FLAG = '0'
)
</if>
<if test="level=='agency'">
AND (AGENCY_ID = #{id} or CONCAT(':',PIDS, ':') like CONCAT('%:',#{id},':%'))
</if>
<if test="level=='grid'">
AND GRID_ID = #{id}
</if>
<if test="level=='neighborHood'">
AND VILLAGE_ID = #{id}
</if>
<if test="level=='building'">
AND BUILD_ID = #{id}
</if>
and CUSTOMER_ID = #{customerId}
and DEL_FLAG = '0'
</select>
<select id="resiWarn" resultType="com.epmet.entity.IcStatsResiWarnEntity">
SELECT
AGENCY_ID as agencyId,
PIDS as agencyPids,
GRID_ID as gridId,
VILLAGE_ID as neighborHoodId,
BUILD_ID as buildingId,
count(*) as count
from ic_resi_user
where 1=1
AND status = '0'
<if test="tableName=='ic_resi_user'">
and ${columnName} = '1'
</if>
<if test="tableName!='ic_resi_user'">
and ID in (
select IC_RESI_USER from ${tableName} where ${columnName} = '1' and CUSTOMER_ID = #{customerId} and DEL_FLAG = '0'
)
</if>
and CUSTOMER_ID = #{customerId}
and DEL_FLAG = '0'
group by AGENCY_ID,GRID_ID,VILLAGE_ID,BUILD_ID
</select>
<select id="resiWarnById" resultType="com.epmet.entity.IcStatsResiWarnEntity">
SELECT
AGENCY_ID as agencyId,
PIDS as agencyPids,
GRID_ID as gridId,
VILLAGE_ID as neighborHoodId,
BUILD_ID as buildingId,
count(*) as count
from ic_resi_user
where 1=1
<if test="tableName=='ic_resi_user'">
and ${columnName} = '1'
</if>
<if test="tableName!='ic_resi_user'">
and ID in (
select IC_RESI_USER from ${tableName} where ${columnName} = '1' and CUSTOMER_ID = #{customerId} and DEL_FLAG = '0'
)
</if>
and CUSTOMER_ID = #{customerId}
and DEL_FLAG = '0'
and AGENCY_ID = #{icStatsResiWarn.agencyId} and GRID_ID =#{icStatsResiWarn.gridId} and VILLAGE_ID=#{icStatsResiWarn.neighborHoodId} and BUILD_ID=#{icStatsResiWarn.buildingId}
group by AGENCY_ID,GRID_ID,VILLAGE_ID,BUILD_ID
</select>
<!-- 查询分类下的人数 -->
<select id="selectCategoryCount" resultType="com.epmet.dto.PersonWarnLeftPieDTO">
SELECT
CONFIG_ID,
SUM(COUNT) AS count
FROM ic_stats_resi_warn
WHERE DEL_FLAG = '0'
AND CONCAT(AGENCY_PIDS,':',AGENCY_ID) LIKE CONCAT('%',#{agencyId},'%')
AND CONFIG_ID IN (
<foreach collection="configIds" item="c" separator=",">
#{c}
</foreach>
)
GROUP BY CONFIG_ID
</select>
<select id="userWarnListDTO" resultType="com.epmet.dto.result.UserWarnNameListResultDTO">
select
BUILD_ID as buildingId,
name as residentName,
ID AS userId
from ic_resi_user
where DEL_FLAG = '0'
and CUSTOMER_ID = #{customerId}
<if test="tableName=='ic_resi_user'">
and ${columnName} = '1'
</if>
AND BUILD_ID in
<foreach collection="buildingIdList" item="buildingId" open="(" separator="," close=" )">
#{buildingId}
</foreach>
<if test="tableName!='ic_resi_user'">
and ID in (
select IC_RESI_USER from ${tableName} where ${columnName} = '1' and CUSTOMER_ID = #{customerId} and DEL_FLAG = '0'
)
</if>
group by ID
</select>
<select id="selectCategoryCountByColumn" resultType="java.util.Map">
SELECT
<foreach collection="columnNames" item="t" separator=",">
IFNULL(${t},'0') AS #{t}
</foreach>
FROM ic_resi_user
WHERE DEL_FLAG = 0
AND `STATUS` = '0'
AND CONCAT(PIDS,':',AGENCY_ID) LIKE CONCAT('%',#{agencyId},'%')
</select>
<select id="queryUserWarnNotice" parameterType="map" resultType="com.epmet.dto.result.IcUserWarnNoticeResultDTO">
SELECT
ir.BUILDING_ID,
ir.CONFIG_ID
FROM
ic_stats_resi_warn ir
WHERE
ir.CUSTOMER_ID = #{customerId}
AND (ir.AGENCY_ID=#{agencyId} or ir.AGENCY_PIDS like concat('%',#{agencyId},'%'))
AND ir.DEL_FLAG = '0'
AND (
<foreach collection="configIds" item="configId" separator=" OR ">
ir.CONFIG_ID = #{configId}
</foreach>
)
</select>
</mapper>