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.
 
 
 
 
 

229 lines
8.7 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="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,
'join' AS actionCode
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>
<select id="selectTopicAttachments" resultType="com.epmet.entity.evaluationindex.screen.ScreenDifficultyImgDataEntity">
SELECT
ATTACHMENT_URL AS eventImgUrl,
SORT
FROM
resi_topic_attachment
WHERE
DEL_FLAG = '0'
</select>
</mapper>