<?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.ComActSocialOrgHatchDAO">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComActSocialOrgHatch" id="ComActSocialOrgHatchMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="responsibility" column="responsibility" jdbcType="VARCHAR"/>
|
<result property="phone" column="phone" jdbcType="VARCHAR"/>
|
<result property="hatchUnit" column="hatch_unit" jdbcType="INTEGER"/>
|
<result property="hatchUnitType" column="hatch_unit_type" jdbcType="INTEGER"/>
|
<result property="hatchUnitName" column="hatch_unit_name" jdbcType="VARCHAR"/>
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
<result property="introduction" column="introduction" jdbcType="VARCHAR"/>
|
<result property="logo" column="logo" jdbcType="VARCHAR"/>
|
<result property="applyReason" column="apply_reason" jdbcType="VARCHAR"/>
|
<result property="serviceScope" column="service_scope" jdbcType="VARCHAR"/>
|
</resultMap>
|
|
<!-- 批量插入 -->
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_act_social_org_hatch(name, responsibility, phone, hatch_unit, hatch_unit_type,
|
hatch_unit_name, status, created_at, updated_at, introduction, logo, apply_reason, service_scope)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.responsibility}, #{entity.phone}, #{entity.hatchUnit}, #{entity.hatchUnitType},
|
#{entity.hatchUnitName}, #{entity.status}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.introduction},
|
#{entity.logo}, #{entity.applyReason}, #{entity.serviceScope})
|
</foreach>
|
</insert>
|
<!-- 批量插入或按主键更新 -->
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_act_social_org_hatch(name, responsibility, phone, hatch_unit, hatch_unit_type,
|
hatch_unit_name, status, created_at, updated_at, introduction, logo, apply_reason, service_scope)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.responsibility}, #{entity.phone}, #{entity.hatchUnit}, #{entity.hatchUnitType},
|
#{entity.hatchUnitName}, #{entity.status}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.introduction},
|
#{entity.logo}, #{entity.applyReason}, #{entity.serviceScope})
|
</foreach>
|
on duplicate key update
|
name = values(name) , responsibility = values(responsibility) , phone = values(phone) , hatch_unit =
|
values(hatch_unit) , hatch_unit_type = values(hatch_unit_type) , hatch_unit_name = values(hatch_unit_name) ,
|
status = values(status) , created_at = values(created_at) , updated_at = values(updated_at) , introduction =
|
values(introduction) , logo = values(logo) , apply_reason = values(apply_reason) , service_scope =
|
values(service_scope)
|
</insert>
|
<select id="pageOrgHatch" resultType="com.panzhihua.common.model.vos.community.social.SocialOrgHatchVO">
|
SELECT id, `name`, responsibility, phone, hatch_unit_name, created_at, `status`
|
FROM com_act_social_org_hatch
|
<where>
|
<if test="pageHatchDTO.keyword != null and pageHatchDTO.keyword != """>
|
AND (`name` LIKE CONCAT(#{pageHatchDTO.keyword}, '%')
|
OR responsibility LIKE CONCAT(#{pageHatchDTO.keyword}, '%')
|
OR phone LIKE CONCAT(#{pageHatchDTO.keyword}, '%'))
|
</if>
|
<if test="pageHatchDTO.hatchUnit != null and pageHatchDTO.hatchUnitType != null">
|
AND hatch_unit = #{pageHatchDTO.hatchUnit} AND hatch_unit_type = #{pageHatchDTO.hatchUnitType}
|
</if>
|
<if test="pageHatchDTO.status != null">
|
AND `status` = #{pageHatchDTO.status}
|
</if>
|
</where>
|
ORDER BY created_at DESC
|
</select>
|
<select id="detailOrgHatch" resultType="com.panzhihua.common.model.vos.community.social.SocialOrgHatchVO">
|
SELECT a.*, GROUP_CONCAT(c.`name`) AS serviceScopeName
|
FROM com_act_social_org_hatch a
|
JOIN mysql.help_topic b ON b.help_topic_id < ( length( a.service_scope ) - length( REPLACE ( a.service_scope, ',', '' ))+ 1 )
|
LEFT JOIN com_act_column c ON substring_index( substring_index( a.service_scope, ',', b.help_topic_id + 1 ), ',',- 1 ) = c.id
|
WHERE a.id = #{id}
|
</select>
|
<select id="getHatchBaseData"
|
resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenHatchStatisticsInfo">
|
SELECT
|
(SELECT COUNT(id) FROM (SELECT id
|
FROM com_act_social_org_hatch_audit t
|
LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
|
WHERE t.hatch_unit_type = 2 AND t.`status` IN(1,2) AND t1.street_id = #{streetId}
|
UNION ALl
|
SELECT id
|
FROM com_act_social_org_hatch_audit
|
WHERE hatch_unit_type = 1 AND `status` IN(1,2) AND hatch_unit = #{streetId}
|
UNION ALL
|
SELECT id
|
FROM com_act_social_org t
|
LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
|
WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
|
UNION ALl
|
SELECT id
|
FROM com_act_social_org
|
WHERE build_type = 1 AND is_society = 1 AND affiliated_unit_type = 1 AND `status` = 1 AND affiliated_unit = #{streetId}
|
) temp) AS hatchCenterTotal,
|
(SELECT COUNT(id) FROM (SELECT id
|
FROM com_act_social_org t
|
LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
|
WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
|
UNION ALl
|
SELECT id
|
FROM com_act_social_org
|
WHERE build_type = 1 AND is_society = 1 AND affiliated_unit_type = 1 AND `status` = 1 AND affiliated_unit = #{streetId}) temp) AS hatchResultTotal,
|
(SELECT COUNT(id) FROM (SELECT id
|
FROM com_act_social_org t
|
LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
|
WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.area_code = '510423'
|
UNION ALL
|
SELECT id
|
FROM com_act_social_org t
|
LEFT JOIN com_street t1 ON t.affiliated_unit = t1.street_id
|
WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 1 AND t.`status` = 1 AND t1.area_code = '510423') temp) AS westAreaOrgTotal
|
</select>
|
<select id="getHatchScheduleCircleData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, COUNT(filed) AS num FROM (
|
SELECT
|
CASE
|
WHEN t.`status` = 1 THEN '孵化中'
|
WHEN t.`status` = 2 THEN '孵化完成'
|
END filed
|
FROM com_act_social_org_hatch t
|
LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
|
WHERE t.hatch_unit_type = 2 AND t1.street_id = #{streetId}
|
UNION ALl
|
SELECT
|
CASE
|
WHEN `status` = 1 THEN '孵化中'
|
WHEN `status` = 2 THEN '孵化完成'
|
END filed
|
FROM com_act_social_org_hatch
|
WHERE hatch_unit_type = 1 AND hatch_unit = #{streetId}
|
) temp GROUP BY filed
|
</select>
|
<select id="getHatchStatusColumnData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT '已进驻' AS filed, COUNT(id) AS num
|
FROM com_act_social_org_hatch_audit t
|
LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
|
WHERE t.hatch_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
|
UNION ALl
|
SELECT '已进驻' AS filed, COUNT(id) AS num
|
FROM com_act_social_org_hatch_audit
|
WHERE hatch_unit_type = 1 AND `status` = 1 AND hatch_unit = #{streetId}
|
UNION ALl
|
SELECT '孵化中' AS filed, COUNT(id) AS num
|
FROM com_act_social_org_hatch t
|
LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
|
WHERE t.hatch_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
|
UNION ALL
|
SELECT '孵化中' AS filed, COUNT(id) AS num
|
FROM com_act_social_org_hatch
|
WHERE hatch_unit_type = 1 AND `status` = 1 AND hatch_unit = #{streetId}
|
UNION ALl
|
SELECT '通过评估' AS filed, COUNT(id) AS num
|
FROM com_act_social_org_hatch t
|
LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
|
WHERE t.hatch_unit_type = 2 AND t.`status` = 2 AND t1.street_id = #{streetId}
|
UNION ALL
|
SELECT '通过评估' AS filed, COUNT(id) AS num
|
FROM com_act_social_org_hatch
|
WHERE hatch_unit_type = 1 AND `status` = 2 AND hatch_unit = #{streetId}
|
UNION ALL
|
SELECT '出壳' AS filed, COUNT(id) AS num
|
FROM com_act_social_org t
|
LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
|
WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
|
UNION ALL
|
SELECT '出壳' AS filed, COUNT(id) AS num
|
FROM com_act_social_org
|
WHERE build_type = 1 AND is_society = 1 AND affiliated_unit_type = 1 AND `status` = 1 AND affiliated_unit = #{streetId}
|
) temp GROUP BY filed
|
</select>
|
<select id="getStreetOrgColumnData" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT t2.`name` AS filed, COUNT(t2.`name`) AS num
|
FROM com_act_social_org t
|
JOIN com_street t2 ON t.street_id = t2.street_id
|
WHERE t2.area_code = '510423' AND t.is_society = 1
|
GROUP BY filed
|
</select>
|
<select id="getStreetOrgChildData" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, COUNT(filed) AS num FROM(
|
SELECT substring_index( substring_index( t.service_type, ',', b.help_topic_id + 1 ), ',',- 1 ) AS filed
|
FROM com_act_social_org t
|
JOIN com_street t2 ON t.street_id = t2.street_id
|
JOIN mysql.help_topic b ON b.help_topic_id < ( length( t.service_type ) - length( REPLACE ( t.service_type, ',', '' ))+ 1 )
|
WHERE t2.area_code = '510423' AND t.is_society = 1 AND t2.`name` = #{streetName}) temp
|
GROUP BY filed
|
</select>
|
|
</mapper>
|