count(ept.`PARTY_MEMBER` ='0' or null) as topicTotal,
count(ept.`PARTY_MEMBER` ='1' or null) as publishTopicTotal,
0 as shiftProjectTotal,
0 as publishShiftProjectTotal,
0 as resolvedProjectTotal,
0 as publishResolvedProjectTotal
from esua_epdc_analysis.epdc_dept_group_person_time ed
where COMMUNITY_ID is not null
group by ed.COMMUNITY_ID)total
from `esua_epdc_party_group`.`epdc_party_topic` ept
left join `esua_epdc_admin`.sys_dept sd on sd.`id` = ept.`GRID_ID`
where sd.`del_flag` ='0' and ept.`DEL_FLAG` ='0'
and sd.`type_key` = 'grid_party'
group by sd.id)total
group by total.GRID_ID)t on gr.id=t.GRID_ID
where gr.del_flag=0
AND gr.`id` NOT IN( SELECT t.`dept_id`
@ -1129,20 +1132,23 @@ UNION ALL
UNION ALL
select COMMUNITY_ID as GRID_ID,
select sd.id as GRID_ID,
0 as issueSum,
0 as publishIssueSum,
0 as issueTotal,
0 as publishIssueTotal,
sum(TOPIC_PUBLISH_TIMES) as topicTotal,
sum(PARTY_PUBLISH_TIMES) as publishTopicTotal,
count(ept.`PARTY_MEMBER` ='0' or null) as topicTotal,
count(ept.`PARTY_MEMBER` ='1' or null) as publishTopicTotal,
0 as shiftProjectTotal,
0 as publishShiftProjectTotal,
0 as resolvedProjectTotal,
0 as publishResolvedProjectTotal
from esua_epdc_analysis.epdc_dept_group_person_time ed
where COMMUNITY_ID is not null
group by ed.COMMUNITY_ID)total
from `esua_epdc_party_group`.`epdc_party_topic` ept
left join `esua_epdc_admin`.sys_dept sd on sd.`id` = ept.`GRID_ID`
where sd.`del_flag` ='0' and ept.`DEL_FLAG` ='0'
and sd.`type_key` = 'grid_party'
group by sd.id)total
group by total.GRID_ID)t on gr.id=t.GRID_ID
where gr.del_flag=0
and co.del_flag=0
@ -1229,20 +1235,23 @@ union all
UNION ALL
select COMMUNITY_ID as GRID_ID,
select sd.id as GRID_ID,
0 as issueSum,
0 as publishIssueSum,
0 as issueTotal,
0 as publishIssueTotal,
sum(TOPIC_PUBLISH_TIMES) as topicTotal,
sum(PARTY_PUBLISH_TIMES) as publishTopicTotal,
count(ept.`PARTY_MEMBER` ='0' or null) as topicTotal,
count(ept.`PARTY_MEMBER` ='1' or null) as publishTopicTotal,
0 as shiftProjectTotal,
0 as publishShiftProjectTotal,
0 as resolvedProjectTotal,
0 as publishResolvedProjectTotal
from esua_epdc_analysis.epdc_dept_group_person_time ed
where COMMUNITY_ID is not null
group by ed.COMMUNITY_ID)total
from `esua_epdc_party_group`.`epdc_party_topic` ept
left join `esua_epdc_admin`.sys_dept sd on sd.`id` = ept.`GRID_ID`
where sd.`del_flag` ='0' and ept.`DEL_FLAG` ='0'
and sd.`type_key` = 'grid_party'
group by sd.id)total
group by total.GRID_ID)t on gr.id=t.GRID_ID
where gr.del_flag=0
and co.del_flag=0
@ -1253,108 +1262,6 @@ union all
WHERE t.`del_flag`= 0)
GROUP BY st.id
union all
SELECT city.id as orgId,
city.name as orgName,
city.pid as parentId,
'agency' as orgType,
SUM(IFNULL(t.publishIssueSum,0)) AS publishIssueTotal, -- 党员发布的议题总数
SUM(IFNULL(t.publishIssueTotal,0)) AS issueTotal, -- 议事总数
SUM(IFNULL(t.publishTopicTotal,0)) AS topicTotal, -- 话题总数
SUM(IFNULL(t.shiftProjectTotal,0)) AS shiftProjectTotal, -- 议题转项目数
SUM(IFNULL(t.resolvedProjectTotal,0)) AS resolvedProjectTotal, -- 已解决项目总数
IFNULL(format(round(SUM(IFNULL(publishIssueTotal,0))/SUM(IFNULL(issueTotal,0)),4)*100,2),0.00) as issueRatio, -- 议事占比(党员/用户)
IFNULL(format(round(SUM(IFNULL(publishTopicTotal,0))/SUM(IFNULL(topicTotal,0)),4)*100,2),0.00) as topicRatio, -- 话题占比(党员/用户)
IFNULL(format(round(SUM(IFNULL(publishShiftProjectTotal,0))/SUM(IFNULL(shiftProjectTotal,0)),4)*100,2),0.00) as shiftProjectRatio, -- 议题转项目占比(党员/用户)
IFNULL(format(round(SUM(IFNULL(publishResolvedProjectTotal,0))/SUM(IFNULL(resolvedProjectTotal,0)),4)*100,2),0.00) as resolvedProjectRatio, -- 解决项目占比(党员/用户)
IFNULL(format(round(SUM(IFNULL(publishIssueSum,0))/SUM(IFNULL(issueSum,0)),4)*100,2),0.00) as publishIssueRatio, -- 党员发布议题占比(党员/用户)
DATE_FORMAT(date_add( now( ), INTERVAL - 1 day),'%Y%m%d') as dataEndTime,
IFNULL(publishIssueTotal,0) AS issueRatioFm,
IFNULL(publishTopicTotal,0) AS topicRatioFm,
IFNULL(publishShiftProjectTotal,0) AS shiftProjectRatioFm,
IFNULL(publishResolvedProjectTotal,0) AS resolvedProjectRatioFm,
IFNULL(publishIssueSum,0) AS publishIssueRatioFm
FROM esua_epdc_admin.sys_dept city
left join esua_epdc_admin.sys_dept st on st.pid=city.id
left join esua_epdc_admin.sys_dept co on co.pid=st.id
LEFT JOIN esua_epdc_admin.sys_dept gr on co.id=gr.pid
left join
(select total.GRID_ID,
sum(total.issueSum) as issueSum, -- 议题总数
sum(total.publishIssueSum) as publishIssueSum,-- 党员发布的议题总数
sum(total.issueTotal) as issueTotal, -- 议事总数
sum(total.publishIssueTotal) as publishIssueTotal, -- 党员发布的议事总数
sum(total.topicTotal) as topicTotal, -- 话题总数
sum(total.publishTopicTotal) as publishTopicTotal, -- 党员发布的话题总数
sum(total.shiftProjectTotal) as shiftProjectTotal, -- 议题转项目数
sum(total.publishShiftProjectTotal) as publishShiftProjectTotal, -- 党员议题转项目数
sum(total.resolvedProjectTotal) as resolvedProjectTotal, -- 已解决项目总数
sum(total.publishResolvedProjectTotal) as publishResolvedProjectTotal -- 党员已解决项目总数
from
(select GRID_ID,
sum(USER_PUBLISH_TIMES+PARTY_PUBLISH_TIMES) as issueSum,
sum(PARTY_PUBLISH_TIMES) as publishIssueSum,
sum(USER_PUBLISH_TIMES +
USER_LIKE_TIME +
USER_OPPOSE_TIMES +
USER_COMMENT_TIMES +
USER_TOITEM_TIMES +
USER_FINISH_TIMES +
USER_EVALUATE_TIMES +
USER_GOOD_TIMES +
PARTY_PUBLISH_TIMES +
PARTY_LIKE_TIME +
PARTY_OPPOSE_TIMES +
PARTY_COMMENT_TIMES +
PARTY_TOITEM_TIMES +
PARTY_FINISH_TIMES +
PARTY_EVALUATE_TIMES +
PARTY_GOOD_TIMES) as issueTotal,
sum(PARTY_PUBLISH_TIMES +
PARTY_LIKE_TIME +
PARTY_OPPOSE_TIMES +
PARTY_COMMENT_TIMES +
PARTY_TOITEM_TIMES +
PARTY_FINISH_TIMES +
PARTY_EVALUATE_TIMES +
PARTY_GOOD_TIMES) as publishIssueTotal,
0 as topicTotal,
0 as publishTopicTotal,
sum(USER_TOITEM_TIMES+PARTY_TOITEM_TIMES) as shiftProjectTotal,
sum(PARTY_TOITEM_TIMES) as publishShiftProjectTotal,
sum(USER_FINISH_TIMES+PARTY_FINISH_TIMES) as resolvedProjectTotal,
sum(PARTY_FINISH_TIMES) as publishResolvedProjectTotal
from esua_epdc_analysis.epdc_dept_event_person_time ed
where GRID_ID is not null
group by ed.GRID_ID
UNION ALL
select COMMUNITY_ID as GRID_ID,
0 as issueSum,
0 as publishIssueSum,
0 as issueTotal,
0 as publishIssueTotal,
sum(TOPIC_PUBLISH_TIMES) as topicTotal,
sum(PARTY_PUBLISH_TIMES) as publishTopicTotal,
0 as shiftProjectTotal,
0 as publishShiftProjectTotal,
0 as resolvedProjectTotal,
0 as publishResolvedProjectTotal
from esua_epdc_analysis.epdc_dept_group_person_time ed
where COMMUNITY_ID is not null
group by ed.COMMUNITY_ID)total
group by total.GRID_ID)t on gr.id=t.GRID_ID
where gr.del_flag=0
and co.del_flag=0
and st.del_flag=0
and city.DEL_FLAG=0
AND city.`id` NOT IN( SELECT t.`dept_id`
FROM `esua_epdc_admin`.`sys_dept_config` t
WHERE t.`del_flag`= 0)
and city.type_key='district_party' and city.party_code='shibei'