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.
255 lines
10 KiB
255 lines
10 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.group.GroupDataDao">
|
|
|
|
<!-- 查询网格下的小组总数,状态为 “approved” -->
|
|
<select id="selectGridGroupTotal" resultType="com.epmet.dto.group.result.GridGroupTotalResultDTO" parameterType="com.epmet.dto.group.form.GridGroupTotalFormDTO">
|
|
SELECT
|
|
grid_id AS gridId,
|
|
COUNT(*) AS gridGroupTotal
|
|
FROM
|
|
resi_group
|
|
WHERE
|
|
DEL_FLAG = 0
|
|
AND state = #{state}
|
|
AND customer_id = #{customerId}
|
|
AND DATE_FORMAT(created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
|
|
GROUP BY
|
|
grid_id
|
|
</select>
|
|
|
|
<!-- 查询网格下的小组成员总数 , 人员状态不为 “removed” -->
|
|
<select id="selectGridGroupPeopleTotal" parameterType="com.epmet.dto.group.form.GridGroupPeopleTotalFormDTO" resultType="com.epmet.dto.group.result.GridGroupPeopleTotalResultDTO">
|
|
SELECT
|
|
rg.grid_id AS gridId,
|
|
COUNT(rgm.id) AS gridGroupPeopleTotal
|
|
FROM
|
|
resi_group rg
|
|
LEFT JOIN resi_group_member rgm ON rgm.resi_group_id = rg.id
|
|
WHERE
|
|
rg.DEL_FLAG = 0
|
|
AND rg.state = #{state}
|
|
AND rg.customer_id = #{customerId}
|
|
AND rgm.status != #{status}
|
|
AND DATE_FORMAT(rgm.created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
|
|
GROUP BY rg.grid_id
|
|
</select>
|
|
|
|
<!-- 查询每个小组的人数 -->
|
|
<select id="selectEveryGroupPeopleCount" parameterType="com.epmet.dto.group.form.GridGroupPeopleFormDTO" resultType="com.epmet.dto.group.result.GridGroupPeopleResultDTO">
|
|
SELECT
|
|
rg.grid_id AS gridId,
|
|
rg.id AS groupId,
|
|
rg.group_name AS groupName,
|
|
COUNT( rgm.id ) AS groupCount
|
|
FROM
|
|
resi_group rg
|
|
LEFT JOIN resi_group_member rgm ON rgm.resi_group_id = rg.id
|
|
WHERE
|
|
rg.DEL_FLAG = 0
|
|
AND rg.state = #{state}
|
|
AND rg.customer_id = #{customerId}
|
|
AND rgm.STATUS != #{status}
|
|
AND DATE_FORMAT(rgm.created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
|
|
GROUP BY
|
|
rgm.resi_group_id
|
|
</select>
|
|
|
|
<!-- 查询网格下的小组日增数 -->
|
|
<select id="selectGroupIncr" resultType="com.epmet.dto.group.result.GroupIncrResultDTO" parameterType="com.epmet.dto.group.form.GroupIncrFormDTO">
|
|
SELECT
|
|
COUNT(*) AS groupIncr,
|
|
grid_id AS gridId
|
|
FROM
|
|
resi_group
|
|
WHERE
|
|
state = #{state}
|
|
AND customer_id = #{customerId}
|
|
AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) = #{dateId}
|
|
GROUP BY
|
|
grid_id
|
|
</select>
|
|
|
|
<!-- 机关下——所有网格内的小组数量 -->
|
|
<select id="getAgencyGroupTotalCount" resultType="com.epmet.dto.group.result.AgencyGroupTotalCountResultDTO">
|
|
SELECT
|
|
grid_id AS gridId,
|
|
COUNT(*) AS gridGroupCount
|
|
FROM
|
|
resi_group
|
|
WHERE
|
|
DEL_FLAG = 0
|
|
AND state = 'approved'
|
|
AND customer_id = #{customerId}
|
|
AND DATE_FORMAT(created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
|
|
GROUP BY
|
|
grid_id
|
|
</select>
|
|
|
|
<!-- 查询机关下的网格内小组成员总数 , 人员状态不为 “removed” -->
|
|
<select id="selectAgencyGridGroupPeopleTotal" resultType="com.epmet.dto.group.result.AgencyGridGroupPeopleTotalResultDTO">
|
|
SELECT
|
|
rg.grid_id AS gridId,
|
|
COUNT(rgm.id) AS gridGroupPeopleTotal
|
|
FROM
|
|
resi_group rg
|
|
LEFT JOIN resi_group_member rgm ON rgm.resi_group_id = rg.id
|
|
WHERE
|
|
rg.DEL_FLAG = 0
|
|
AND rg.state = 'approved'
|
|
AND rg.customer_id = #{customerId}
|
|
AND rgm.status != 'removed'
|
|
AND DATE_FORMAT(rgm.created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
|
|
GROUP BY rg.grid_id
|
|
</select>
|
|
|
|
<!-- 查询机关下每个小组的人数 -->
|
|
<select id="selectAgencyEveryGroupPeopleCount" resultType="com.epmet.dto.group.result.AgencyGridGroupPeopleResultDTO">
|
|
SELECT
|
|
rg.grid_id AS gridId,
|
|
rg.id AS groupId,
|
|
COUNT( rgm.id ) AS groupCount
|
|
FROM
|
|
resi_group rg
|
|
LEFT JOIN resi_group_member rgm ON rgm.resi_group_id = rg.id
|
|
WHERE
|
|
rg.DEL_FLAG = 0
|
|
AND rg.state = 'approved'
|
|
AND rg.customer_id = #{customerId}
|
|
AND rgm.STATUS != 'removed'
|
|
AND DATE_FORMAT(rgm.created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
|
|
GROUP BY
|
|
rgm.resi_group_id
|
|
</select>
|
|
|
|
<!-- 查询机关下的小组日增数 -->
|
|
<select id="selectAgencyGroupIncr" resultType="com.epmet.dto.group.result.AgencyGroupIncrResultDTO">
|
|
SELECT
|
|
COUNT(*) AS groupIncr,
|
|
grid_id AS gridId
|
|
FROM
|
|
resi_group
|
|
WHERE
|
|
state = 'approved'
|
|
AND customer_id = #{customerId}
|
|
AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) = #{dateId}
|
|
GROUP BY
|
|
grid_id
|
|
</select>
|
|
|
|
<select id="getAgencyGrid" resultType="com.epmet.dto.group.result.GroupPeopleCountResultDTO">
|
|
<foreach collection="gridIds" item="gridId" separator=" UNION ALL ">
|
|
SELECT
|
|
rg.id AS groupId,
|
|
COUNT( rgm.id ) AS groupCount
|
|
FROM
|
|
resi_group rg
|
|
LEFT JOIN resi_group_member rgm ON rgm.resi_group_id = rg.id
|
|
WHERE
|
|
rg.DEL_FLAG = 0
|
|
AND rg.state = 'approved'
|
|
AND rg.grid_id = #{gridId}
|
|
AND rgm.STATUS != 'removed'
|
|
GROUP BY
|
|
rgm.resi_group_id
|
|
</foreach>
|
|
</select>
|
|
|
|
|
|
<resultMap id="groupExtracting" type="com.epmet.dto.extract.FactOriginGroupMainDailyDTO">
|
|
<id column="ID" property="id"></id>
|
|
<result column="CUSTOMER_ID" property="customerId"/>
|
|
<result column="groupState" property="groupState"/>
|
|
<result column="GRID_ID" property="gridId"/>
|
|
<result column="groupType" property="groupType"/>
|
|
<result column="createdTime" property="createdTime" />
|
|
<result column="groupOwnerId" property="groupOwnerId"/>
|
|
<collection property="members" ofType="com.epmet.dto.group.result.ExtractGroupMemberActionRecordResultDTO">
|
|
<result property="customerId" column="CUSTOMER_ID"/>
|
|
<result property="gridId" column="GRID_ID" />
|
|
<result property="joinDate" column="joinDate" />
|
|
<result property="actionCode" column="actionCode" />
|
|
<result property="memberId" column="memberId" />
|
|
<result property="leaderFlag" column="leaderFlag" />
|
|
<result property="groupId" column="ID" />
|
|
</collection>
|
|
</resultMap>
|
|
<!-- 抽取小组数据 -->
|
|
<select id="groupExtracting" resultMap="groupExtracting">
|
|
SELECT
|
|
groupp.ID ,
|
|
groupp.CUSTOMER_ID,
|
|
groupp.STATE AS groupState,
|
|
groupp.GRID_ID,
|
|
oper.CUSTOMER_USER_ID AS memberId,
|
|
groupoper.UPDATED_TIME AS createdTime,
|
|
oper.UPDATED_TIME AS joinDate,
|
|
IF(groupp.CREATED_BY = oper.CUSTOMER_USER_ID,'leader','member') AS leaderFlag,
|
|
groupp.CREATED_BY AS groupOwnerId,
|
|
IF(groupp.CREATED_BY = oper.CUSTOMER_USER_ID,'join','create') AS actionCode,
|
|
groupp.group_type AS groupType
|
|
|
|
FROM
|
|
RESI_GROUP groupp
|
|
LEFT JOIN
|
|
GROUP_MEMEBER_OPERATION oper
|
|
ON groupp.ID = oper.GROUP_ID AND oper.DEL_FLAG = '0'
|
|
AND oper.OPERATE_STATUS = 'approved'
|
|
LEFT JOIN
|
|
RESI_GROUP_OPERATION groupoper
|
|
ON groupp.ID = groupoper.RESI_GROUP_ID AND groupoper.DEL_FLAG = '0' AND groupoper.STATE = 'approved'
|
|
WHERE
|
|
groupp.DEL_FLAG = '0'
|
|
AND
|
|
groupp.CUSTOMER_ID = #{customerId}
|
|
AND
|
|
groupp.STATE = 'approved'
|
|
<if test='null != dateId and "" != dateId'>
|
|
AND(
|
|
DATE_FORMAT(groupoper.UPDATED_TIME, '%Y%m%d') = #{dateId}
|
|
OR
|
|
DATE_FORMAT(oper.UPDATED_TIME, '%Y%m%d') = #{dateId}
|
|
)
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 查询小组活动签到表,计算用户在本月内签到的活动次数 限制活动分类编码100001 三会一课 -->
|
|
<select id="selectUserSignedCount" parameterType="map" resultType="com.epmet.dto.indexcollect.result.CpcIndexCommonDTO">
|
|
SELECT
|
|
m.SIGN_USER_ID AS userId,
|
|
count( DISTINCT m.GROUP_ACT_ID ) AS indexValue
|
|
FROM
|
|
act_sign_in_record m
|
|
inner join group_act_info a
|
|
on(m.GROUP_ACT_ID=a.id and a.DEL_FLAG='0'
|
|
)
|
|
WHERE
|
|
m.DEL_FLAG = '0'
|
|
AND m.CUSTOMER_ID = #{customerId}
|
|
AND DATE_FORMAT( m.CREATED_TIME, '%Y%m' )= #{monthId}
|
|
and a.CUSTOMER_ID=#{customerId}
|
|
and a.`STATUS`!='canceled'
|
|
and a.CATEGORY_CODE='100001'
|
|
GROUP BY
|
|
m.SIGN_USER_ID
|
|
</select>
|
|
|
|
<!-- 网格相关:组织三会一课次数 -->
|
|
<select id="selectCountGridCreateThreeMeets" parameterType="map" resultType="com.epmet.dto.indexcollect.result.GridIndexCommonDTO">
|
|
SELECT
|
|
ga.GRID_ID as gridId,
|
|
count( 1 ) as indexValue
|
|
FROM
|
|
group_act_info ga
|
|
WHERE
|
|
ga.DEL_FLAG = '0'
|
|
AND ga.`STATUS` != 'canceled'
|
|
AND ga.CUSTOMER_ID = #{customerId}
|
|
AND DATE_FORMAT( ga.START_TIME, '%Y%m' )= #{monthId}
|
|
AND ga.SIGNED_IN_NUM > 0
|
|
AND ga.CATEGORY_CODE = '100001'
|
|
GROUP BY
|
|
ga.GRID_ID
|
|
</select>
|
|
</mapper>
|