<?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_dangjian.dao.ComPbCheckUnitMapper">
|
|
<resultMap type="com.panzhihua.service_dangjian.entity.ComPbCheckUnit" id="ComPbCheckUnitMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="communityId" column="community_id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="type" column="type" jdbcType="INTEGER"/>
|
<result property="contacts" column="contacts" jdbcType="VARCHAR"/>
|
<result property="phone" column="phone" jdbcType="VARCHAR"/>
|
<result property="createAt" column="create_at" jdbcType="TIMESTAMP"/>
|
<result property="createBy" column="create_by" jdbcType="INTEGER"/>
|
<result property="updateAt" column="update_at" jdbcType="TIMESTAMP"/>
|
<result property="updateBy" column="update_by" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!--查询单个-->
|
<select id="queryById" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
|
select
|
cpcu.*
|
,(select count(id) from com_pb_member where audit_result = 1 and check_unit_id = cpcu.id) as count
|
from com_pb_check_unit as cpcu
|
where cpcu.id = #{id}
|
</select>
|
|
<!--查询指定行数据-->
|
<select id="queryAllByLimit" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
|
select
|
cpcu.*
|
from com_pb_check_unit as cpcu
|
<where>
|
<if test="dto.id != null">
|
and cpcu.id = #{dto.id}
|
</if>
|
<if test="dto.type != null">
|
and cpcu.`type` = #{dto.type}
|
</if>
|
<if test="dto.communityIds != null and dto.communityIds.size()>0">
|
AND cpcu.community_id IN
|
<foreach collection="dto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="dto.ids != null and dto.ids.length != 0">
|
AND cpcu.id IN
|
<foreach collection="dto.ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="dto.keyWord != null and dto.keyWord != ''">
|
and (cpcu.contacts like concat(#{dto.keyWord},'%') or cpcu.`name` like concat('%',#{dto.keyWord},'%') or cpcu.phone like concat(#{dto.keyWord},'%'))
|
</if>
|
<if test="dto.name != null and dto.name != ''">
|
and cpcu.`name` like concat('%',#{dto.name},'%')
|
</if>
|
<if test="dto.contacts != null and dto.contacts != ''">
|
and cpcu.`contacts` like concat(#{dto.contacts},'%')
|
</if>
|
<if test="dto.specialtyName != null and dto.specialtyName != ''">
|
and cpcu.specialty_name like concat('%',#{dto.specialtyName},'%')
|
</if>
|
<if test="dto.belongTo != null and dto.belongTo != ''">
|
and cpcu.belong_to =#{dto.belongTo}
|
</if>
|
<if test="dto.natureName != null and dto.natureName != ''">
|
and cpcu.nature_name = #{dto.natureName}
|
</if>
|
<if test="dto.orgName != null and dto.orgName !=''">
|
and cpcu.org_name like concat('%',#{dto.orgName},'%')
|
</if>
|
</where>
|
order by cpcu.create_at desc
|
</select>
|
|
<!--查询所有数据-->
|
<select id="queryAllByList" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
|
select
|
cpcu.id, cpcu.`name`, cpcu.`type`, cpcu.contacts, cpcu.phone, cpcu.create_at, cpcu.create_by, cpcu.update_at, cpcu.update_by
|
, cpcu.community_id, cpcu.org_name, ca.`name` as communityName, cpcu.`logo`
|
from com_pb_check_unit as cpcu
|
left join com_act as ca on ca.community_id = cpcu.community_id
|
<where>
|
<if test="dto.id != null">
|
and cpcu.id = #{dto.id}
|
</if>
|
<if test="dto.name != null and dto.name != ''">
|
and cpcu.`name` = #{dto.name}
|
</if>
|
<if test="dto.type != null">
|
and cpcu.`type` = #{dto.type}
|
</if>
|
<if test="dto.contacts != null and dto.contacts != ''">
|
and cpcu.contacts = #{dto.contacts}
|
</if>
|
<if test="dto.phone != null and dto.phone != ''">
|
and cpcu.phone = #{dto.phone}
|
</if>
|
<if test="dto.communityId != null and dto.communityId !=0">
|
and cpcu.community_id = #{dto.communityId}
|
</if>
|
</where>
|
order by cpcu.create_at desc
|
</select>
|
|
<select id="selectCommunityId" resultType="Long">
|
select community_id from com_area_town_community where area=#{area} and town=#{town} and community=#{community}
|
</select>
|
<select id="unitStatisticsTop"
|
resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
|
SELECT
|
(SELECT COUNT( id ) FROM com_pb_check_unit WHERE 1=1
|
<if test="communityIds != null and communityIds.size() >0">
|
AND community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="unitIds != null and unitIds.length != 0 ">
|
AND id IN
|
<foreach collection="unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
|
<if test="belongTo != null and belongTo != ''">
|
AND belong_to = #{belongTo}
|
</if>
|
<if test="choice != null and choice != ''">
|
AND belong_to = #{choice}
|
</if>
|
|
<if test=" null != yearTime and '' != yearTime">
|
AND `create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
|
) AS unitTotal,
|
(SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '机关单位'
|
<if test="communityIds != null and communityIds.size() >0">
|
AND community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="unitIds != null and unitIds.length != 0 ">
|
AND id IN
|
<foreach collection="unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
AND belong_to = #{belongTo}
|
</if>
|
<if test="choice != null and choice != ''">
|
AND belong_to = #{choice}
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND `create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
|
) AS organTotal,
|
(SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '企事业单位'
|
<if test="communityIds != null and communityIds.size() >0">
|
AND community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="unitIds != null and unitIds.length != 0 ">
|
AND id IN
|
<foreach collection="unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
AND belong_to = #{belongTo}
|
</if>
|
<if test="choice != null and choice != ''">
|
AND belong_to = #{choice}
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND `create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
) AS businessTotal,
|
(SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
<if test="communityIds != null and communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="unitIds != null and unitIds.length != 0 ">
|
AND cpcu.id IN
|
<foreach collection="unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
AND cpcu.belong_to = #{belongTo}
|
</if>
|
<if test="choice != null and choice != ''">
|
AND cpcu.belong_to = #{choice}
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND cpcu.`create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
) AS partyMemberTotal
|
</select>
|
<select id="unitStatistics" resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
|
SELECT temp.*,
|
(SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '机关单位'
|
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
AND belong_to = temp.belong_to
|
<if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
|
AND `create_at` <= concat(#{commonDto.yearTime},'-12-31 59:59:59')
|
</if>
|
) AS organTotal,
|
(SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '企事业单位'
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
AND belong_to = temp.belong_to
|
<if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
|
AND `create_at` <= concat(#{commonDto.yearTime},'-12-31 59:59:59')
|
</if>
|
) AS businessTotal,
|
(SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND m.id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
AND cpcu.belong_to = temp.belong_to
|
<if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
|
AND cpcu.`create_at` <= concat(#{commonDto.yearTime},'-12-31 59:59:59')
|
</if>
|
) AS partyMemberTotal
|
FROM (SELECT belong_to,COUNT( id ) AS unitTotal FROM com_pb_check_unit WHERE 1=1
|
<if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
|
AND `create_at` <= concat(#{commonDto.yearTime},'-12-31 59:59:59')
|
</if>
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.belongTo != null and commonDto.belongTo != ''">
|
AND belong_to = #{commonDto.belongTo}
|
</if>
|
GROUP BY belong_to) temp
|
</select>
|
<select id="pbStatisticsTop" resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
|
SELECT
|
(SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
AND cpcu.nature_name = '机关单位'
|
<if test="communityIds != null and communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="unitIds != null and unitIds.length !=0">
|
AND cpcu.id IN
|
<foreach collection="unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
AND cpcu.belong_to = #{belongTo}
|
</if>
|
<if test="choice != null and choice != ''">
|
AND cpcu.belong_to = #{choice}
|
</if>
|
<if test="checkUnitId != null">
|
AND m.check_unit_id = #{checkUnitId}
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND cpcu.`create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
) AS organTotal,
|
(SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
AND cpcu.nature_name = '企事业单位'
|
<if test="communityIds != null and communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="unitIds != null and unitIds.length !=0">
|
AND cpcu.id IN
|
<foreach collection="unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
AND cpcu.belong_to = #{belongTo}
|
</if>
|
<if test="choice != null and choice != ''">
|
AND cpcu.belong_to = #{choice}
|
</if>
|
<if test="checkUnitId != null">
|
AND m.check_unit_id = #{checkUnitId}
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND cpcu.`create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
) AS businessTotal,
|
(SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
<if test="communityIds != null and communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="unitIds != null and unitIds.length !=0">
|
AND cpcu.id IN
|
<foreach collection="unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
AND cpcu.belong_to = #{belongTo}
|
</if>
|
<if test="choice != null and choice != ''">
|
AND cpcu.belong_to = #{choice}
|
</if>
|
<if test="checkUnitId != null">
|
AND m.check_unit_id = #{checkUnitId}
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND cpcu.`create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
) AS partyMemberTotal
|
</select>
|
<select id="pbStatisticsBelong" resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
|
SELECT temp.*,
|
(SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND cpcu.id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
|
and m.`create_at` <= concat(#{commonDto.yearTime},'-12-31 59:59:59')
|
</if>
|
AND m.check_unit_id is not null AND cpcu.nature_name = '机关单位' AND cpcu.belong_to = temp.belong_to) AS organTotal,
|
(SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND cpcu.id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
|
and m.`create_at` <= concat(#{commonDto.yearTime},'-12-31 59:59:59')
|
</if>
|
AND cpcu.nature_name = '企事业单位' AND cpcu.belong_to = temp.belong_to) AS businessTotal
|
FROM (SELECT cpcu.belong_to,COUNT( m.id ) AS partyMemberTotal FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND cpcu.id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.belongTo != null and commonDto.belongTo != ''">
|
AND cpcu.belong_to = #{commonDto.belongTo}
|
</if>
|
<if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
|
and m.`create_at` <= concat(#{commonDto.yearTime},'-12-31 59:59:59')
|
</if>
|
GROUP BY belong_to) temp
|
</select>
|
<select id="pbStatisticsUnit" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
|
SELECT
|
cpcu.id,
|
cpcu.`name`,
|
cpcu.nature_name,
|
cpcu.belong_to,
|
cpcu.help_community_name,
|
cpcu.village_name,
|
COUNT( m.id ) AS count
|
FROM
|
com_pb_member m
|
LEFT JOIN com_pb_check_unit AS cpcu ON m.check_unit_id = cpcu.id
|
WHERE
|
m.audit_result = 1
|
<if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
|
AND m.community_id IN
|
<foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
|
AND cpcu.id IN
|
<foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="commonDto.belongTo != null and commonDto.belongTo != ''">
|
AND cpcu.belong_to = #{commonDto.belongTo}
|
</if>
|
GROUP BY
|
cpcu.`name`
|
</select>
|
|
<select id="organSumIntegral" resultType="java.lang.Integer">
|
SELECT sum(csr.pb_reward_integral) as organSumIntegral from (
|
SELECT cm.user_id , cu.community_id FROM com_pb_check_unit cu inner JOIN com_pb_member cm on cm.check_unit_id = cu.id
|
where
|
cm.user_id is not null
|
and cu.community_id is not null
|
<if test="communityIds != null and communityIds.size() >0">
|
AND cu.community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND cu.`create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
GROUP BY cm.user_id , cu.community_id
|
) as cum INNER JOIN (
|
SELECT ccc.* FROM com_act_act_regist as cr INNER JOIN (
|
select ca.community_id ,cs.user_id,cs.activity_id,ca.pb_reward_integral
|
FROM com_act_activity ca LEFT JOIN com_act_act_sign cs on cs.activity_id = ca.id WHERE cs.`status` = '1' and ca.have_integral_reward = '1'
|
ORDER BY cs.user_id DESC
|
) as ccc on cr.activity_id = ccc.activity_id and cr.user_id = ccc.user_id
|
) as csr on csr.community_id = cum.community_id and csr.user_id = cum.user_id
|
|
</select>
|
<select id="pbOrganSumIntegral" resultType="java.lang.Integer">
|
SELECT sum(csr.pb_reward_integral) as organSumIntegral from (
|
SELECT cm.user_id , cu.community_id FROM com_pb_check_unit cu inner JOIN com_pb_member cm on cm.check_unit_id = cu.id
|
where
|
cm.user_id is not null
|
and cu.community_id is not null
|
<if test="communityIds != null and communityIds.size() >0">
|
AND cu.community_id IN
|
<foreach collection="communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test=" null != yearTime and '' != yearTime">
|
AND cm.`create_at` <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
GROUP BY cm.user_id , cu.community_id
|
) as cum INNER JOIN (
|
SELECT ccc.* FROM com_act_act_regist as cr INNER JOIN (
|
select ca.community_id ,cs.user_id,cs.activity_id,ca.pb_reward_integral
|
FROM com_act_activity ca LEFT JOIN com_act_act_sign cs on cs.activity_id = ca.id WHERE cs.`status` = '1' and ca.have_integral_reward = '1'
|
ORDER BY cs.user_id DESC
|
) as ccc on cr.activity_id = ccc.activity_id and cr.user_id = ccc.user_id
|
) as csr on csr.community_id = cum.community_id and csr.user_id = cum.user_id
|
|
</select>
|
|
|
<select id="selectOrgAdmin" resultType="Integer">
|
select count(*) from com_pb_check_unit where admin_phone like concat('%',#{phone},'%')
|
</select>
|
|
|
|
</mapper>
|