<?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.panzhihua.service_community.dao.ComPropertyDao">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComProperty" id="ComPropertyBaseResultMap">
|
<result property="id" column="id"/>
|
<result property="name" column="name"/>
|
<result property="introduction" column="introduction"/>
|
<result property="contactName" column="contact_name"/>
|
<result property="phone" column="phone"/>
|
<result property="address" column="address"/>
|
<result property="userId" column="user_id"/>
|
<result property="communityId" column="community_id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="areaId" column="area_id"/>
|
</resultMap>
|
|
<select id="pageList" resultType="com.panzhihua.common.model.vos.community.ComPropertyVO">
|
select t.*,t1.account,t1.password,t2.name as areaName,t3.role_id as roleId from com_property t
|
left join sys_user t1 on t.user_id = t1.user_id
|
left join com_mng_village t2 on t.area_id = t2.village_id
|
left join sys_user_role t3 on t.user_id = t3.user_id
|
<where>
|
1=1
|
<if test="commonPage.name !=null and commonPage.name !=''">
|
and t.name like concat(#{commonPage.name},'%')
|
</if>
|
<if test="commonPage.username !=null and commonPage.username !=''">
|
and t.contact_name like concat(#{commonPage.username},'%')
|
</if>
|
<if test="commonPage.phone !=null and commonPage.phone !=''">
|
and t.phone like concat(#{commonPage.phone},'%')
|
</if>
|
<if test="commonPage.paramId !=null">
|
and t.community_id = ${commonPage.paramId}
|
</if>
|
<if test="commonPage.areaId !=null">
|
and t.area_id =#{commonPage.areaId}
|
</if>
|
</where>
|
order by t.create_time desc
|
</select>
|
<select id="getRepairPolylineDate" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( p1.create_time, '%Y-%m' ) AS filed, COUNT(1) AS num FROM com_property_repair p1
|
LEFT JOIN com_property p2 ON p1.property_id = p2.id
|
WHERE p2.community_id = ${communityId} AND DATE_FORMAT( p1.create_time, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
|
UNION ALL SELECT * FROM
|
(
|
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
|
) temT
|
) temp GROUP BY filed ORDER BY filed ASC
|
</select>
|
<select id="getRepairTotalPolylineDate"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT COUNT(1) AS num FROM com_property_repair p1
|
LEFT JOIN com_property p2 ON p1.property_id = p2.id
|
WHERE p2.community_id = ${communityId} AND DATE_FORMAT( p1.create_time, '%Y-%m' ) <= #{date}
|
</select>
|
<select id="getEventAddPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( e.create_at, '%Y-%m' ) AS filed, COUNT(e.id) AS num
|
FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_type IN ( 1, 2, 3, 5, 6 ) AND e.event_status = 2 AND egd.grid_community_id = ${communityId}
|
AND DATE_FORMAT( e.create_at, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
|
UNION ALL SELECT
|
DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(id) AS num
|
FROM com_act_easy_photo WHERE community_id = ${communityId} AND `status` IN (1,2,4) AND del_tag = 0 AND classify_id IN (1,3,4,5,6,7,8)
|
AND DATE_FORMAT( create_at, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
|
UNION ALL SELECT * FROM
|
(
|
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
|
) temT
|
) temp GROUP BY filed ORDER BY filed ASC
|
</select>
|
<select id="getEventTotalPolylineDate"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT SUM(num) AS num FROM (
|
SELECT COUNT(e.id) AS num
|
FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_type IN ( 1, 2, 3, 5, 6 ) AND e.event_status = 2 AND egd.grid_community_id = ${communityId}
|
AND DATE_FORMAT( e.create_at, '%Y-%m' ) <= #{date}
|
UNION ALL SELECT
|
COUNT(id) AS num
|
FROM com_act_easy_photo WHERE community_id = ${communityId} AND `status` IN (1,2,4) AND del_tag = 0 AND classify_id IN (1,3,4,5,6,7,8) AND DATE_FORMAT( create_at, '%Y-%m' ) <= #{date}
|
) temp
|
</select>
|
<select id="getAlarmBaseData"
|
resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenAlarmStatisticsInfo">
|
SELECT
|
(SELECT COUNT(id) FROM com_property_equipment WHERE community_id = #{communityId} AND `type` = 2) AS abnormalAlarmTotal,
|
(SELECT COUNT(id) FROM com_property_equipment WHERE community_id = #{communityId} AND `type` = 1) AS oneKeyAlarmTotal,
|
(SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t2.`type` = 2) AS abnormalTotal,
|
(SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t2.`type` = 1) AS oneKeyTotal,
|
(SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t1.`status` = 0 AND t1.`type` = 2) AS pendingAbnormalTotal,
|
(SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t1.`status` = 1 AND t1.`type` = 2) AS completeAbnormalTotal,
|
(SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t1.`status` = 0 AND t1.`type` = 1 and t1.serial_no not like '70%') AS pendingServiceTotal,
|
(SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t1.`status` = 1 AND t1.`type` = 1 and t1.serial_no not like '70%') AS completeServiceTotal
|
</select>
|
<select id="retrieveAbnormalAddPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( t.create_time, '%Y-%m' ) AS filed, COUNT(1) AS num
|
FROM com_property_alarm t
|
LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
|
WHERE t1.community_id = #{communityId} AND t1.`type` = 2 AND DATE_FORMAT( t.create_time, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m'
|
) GROUP BY filed
|
UNION ALL SELECT * FROM
|
(
|
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
|
) temT
|
) temp GROUP BY filed ORDER BY filed ASC
|
</select>
|
<select id="retrieveAbnormalTotalPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT COUNT( 1 ) AS num
|
FROM com_property_alarm t
|
LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
|
WHERE t1.community_id = #{communityId} AND t1.`type` = 2 AND DATE_FORMAT( t.create_time, '%Y-%m' ) <= #{date}
|
</select>
|
<select id="retrieveServiceAddPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( t.create_time, '%Y-%m' ) AS filed, COUNT(1) AS num
|
FROM com_property_alarm t
|
LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
|
WHERE t1.community_id = #{communityId} AND t1.`type` = 1 AND DATE_FORMAT( t.create_time, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m'
|
) GROUP BY filed
|
UNION ALL SELECT * FROM
|
(
|
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
|
) temT
|
) temp GROUP BY filed ORDER BY filed ASC
|
</select>
|
<select id="retrieveServiceTotalPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT COUNT( 1 ) AS num
|
FROM com_property_alarm t
|
LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
|
WHERE t1.community_id = #{communityId} AND t1.`type` = 1 AND DATE_FORMAT( t.create_time, '%Y-%m' ) <= #{date}
|
</select>
|
<select id="getAbnormalList" resultType="com.panzhihua.common.model.vos.property.ComPropertyAlarmVO">
|
SELECT
|
t.id,
|
t.create_time,
|
t1.phone,
|
t1.username AS name,
|
t1.position
|
FROM
|
com_property_alarm t
|
LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
|
WHERE t1.community_id = #{communityId} AND t.`type` = #{type} AND t.`status` = #{status} and t.serial_no not like '70%'
|
ORDER BY t.create_time DESC
|
</select>
|
<select id="getAlarmPointMapData"
|
resultType="com.panzhihua.common.model.vos.property.ComPropertyEquipmentVO">
|
SELECT
|
id,
|
phone,
|
username,
|
latitude,
|
longitude,
|
`type`,
|
`position`,
|
`type` AS equipmentStatus
|
FROM com_property_equipment
|
WHERE serial_no IN(
|
SELECT DISTINCT(t1.serial_no)
|
FROM com_property_alarm t1
|
LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t1.`status` = 0 and t1.serial_no not like '70%'
|
)
|
UNION ALL
|
SELECT
|
id,
|
phone,
|
username,
|
latitude,
|
longitude,
|
`type`,
|
`position`,
|
3 AS equipmentStatus
|
FROM com_property_equipment
|
WHERE community_id = #{communityId} AND serial_no NOT IN(
|
SELECT DISTINCT(t1.serial_no)
|
FROM com_property_alarm t1
|
LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
|
WHERE t2.community_id = #{communityId} AND t1.`status` = 0
|
) and serial_no not like '70%'
|
</select>
|
|
<select id="noticeList" resultType="com.panzhihua.common.model.vos.community.ComActAnnouncementVO">
|
select * from com_act_announcement where property_id=#{propertyId}
|
</select>
|
|
</mapper>
|