
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
<?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">
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.29
내 용 : 메인 통계 관련
-->
<mapper namespace="com.takensoft.portal.main.dao.GovernmentMainDAO">
<!-- 공무원 메인페이지 통계정보 관련 -->
<!-- SELECT SQL -->
<sql id="selectItem">
<if test="searchKeyword != null and searchText != ''">
<if test="searchKeyword == 'day'">
, stats_date::DATE AS stats_date
</if>
<if test="searchKeyword == 'month'">
, to_char(DATE_TRUNC('month', stats_date), 'YYYY-MM') AS stats_date
</if>
<if test="searchKeyword == 'year'">
, to_char(DATE_TRUNC('year', stats_date), 'YYYY') AS stats_date
</if>
</if>
</sql>
<sql id="groupItem">
<if test="searchKeyword != null and searchText != ''">
GROUP BY true::boolean
<if test="searchKeyword == 'day'">
, stats_date::DATE
</if>
<if test="searchKeyword == 'month'">
, to_char(DATE_TRUNC('month', stats_date), 'YYYY-MM')
</if>
<if test="searchKeyword == 'year'">
, to_char(DATE_TRUNC('year', stats_date), 'YYYY')
</if>
</if>
</sql>
<!--
작 성 자 : 박정하
작 성 일 : 2024.06.03
내 용 : 공무원 메인페이지 통계정보 조회 : 분류별 통계
-->
<select id="selectCategoryStats" parameterType="HashMap">
SELECT sum(ei_cnt) AS "새 기업정보 수"
, sum(eda_cnt) AS "새 기업상담신청 수"
, sum(rm_cnt) AS "새 검토사항 수"
, sum(id_cnt) AS "새 투자상담 수"
<include refid="selectItem" />
FROM (
SELECT generate_series AS stats_date
, COALESCE(ei.count, 0) AS ei_cnt
, COALESCE(eda.count, 0) AS eda_cnt
, COALESCE(rm.count, 0) AS rm_cnt
, COALESCE(id.count, 0) AS id_cnt
FROM (SELECT GENERATE_SERIES(
<if test="searchKeyword != null and searchText != ''">
<if test="searchKeyword == 'day'">
(now() + '-30 days')::DATE
</if>
<if test="searchKeyword == 'month'">
(now() + '-1 year')::DATE
</if>
<if test="searchKeyword == 'year'">(
select MIN(min)
from (
(select MIN(reg_dt)::DATE FROM ent_info WHERE use_yn = 'Y') union all
(select MIN(reg_dt)::DATE FROM ent_dscsn_aply WHERE use_yn = 'Y') union all
(select MIN(reg_dt)::DATE FROM rvw_mttr WHERE use_yn = 'Y') union all
(select MIN(reg_dt)::DATE FROM ivst_dscsn WHERE use_yn = 'Y')
) as since
)
</if>
</if>
, NOW(), '1 day'::INTERVAL)::date) AS date
LEFT JOIN (SELECT reg_dt::DATE, COUNT(ent_id) FROM ent_info WHERE use_yn = 'Y' GROUP BY reg_dt::DATE) AS ei
ON date.generate_series = ei.reg_dt
LEFT JOIN (SELECT reg_dt::DATE, COUNT(ent_dscsn_aply_id) FROM ent_dscsn_aply WHERE use_yn = 'Y' GROUP BY reg_dt::DATE) AS eda
ON date.generate_series = eda.reg_dt
LEFT JOIN (SELECT reg_dt::DATE, COUNT(rvw_mttr_id) FROM rvw_mttr WHERE use_yn = 'Y' GROUP BY reg_dt::DATE) AS rm
ON date.generate_series = rm.reg_dt
LEFT JOIN (SELECT reg_dt::DATE, COUNT(ivst_dscsn_id) FROM ivst_dscsn WHERE use_yn = 'Y' GROUP BY reg_dt::DATE) AS id
ON date.generate_series = id.reg_dt
ORDER BY date.generate_series
) AS datas
<include refid="groupItem" />
ORDER BY stats_date
</select>
<!--
작 성 자 : 박정하
작 성 일 : 2024.06.03
내 용 : 공무원 메인페이지 통계정보 조회 : 상담신청 통계
-->
<select id="selectEntDscsnAplyStats" parameterType="HashMap">
SELECT SUM(coalesce) AS "새 상담신청 수"
<include refid="selectItem" />
FROM (
SELECT stats_date
, COALESCE(eda.count, 0)
FROM (SELECT GENERATE_SERIES::DATE AS stats_date
FROM GENERATE_SERIES(
<if test="searchKeyword != null and searchText != ''">
<if test="searchKeyword == 'day'">
(now() + '-30 days')::DATE
</if>
<if test="searchKeyword == 'month'">
(now() + '-1 year')::DATE
</if>
<if test="searchKeyword == 'year'">
(select MIN(reg_dt) FROM ent_dscsn_aply WHERE use_yn = 'Y')
</if>
</if>
, NOW()::DATE, '1 day'::INTERVAL)) as date
LEFT JOIN (
SELECT COUNT(ent_dscsn_aply_id)
, reg_dt::DATE AS reg_dt
FROM ent_dscsn_aply
WHERE use_yn = 'Y'
GROUP BY reg_dt::DATE
) AS eda
ON date.stats_date = eda.reg_dt
ORDER BY stats_date) AS datas
<include refid="groupItem" />
ORDER BY stats_date
</select>
<!--
작 성 자 : 박정하
작 성 일 : 2024.06.03
내 용 : 공무원 메인페이지 통계정보 조회 : 검토사항 통계
-->
<select id="selectRvwMttrStats" parameterType="HashMap">
SELECT SUM(coalesce) AS "새 검토사항 수"
<include refid="selectItem" />
FROM (
SELECT stats_date
, COALESCE(eda.count, 0)
FROM (SELECT GENERATE_SERIES::DATE AS stats_date
FROM GENERATE_SERIES(
<if test="searchKeyword != null and searchText != ''">
<if test="searchKeyword == 'day'">
(now() + '-30 days')::DATE
</if>
<if test="searchKeyword == 'month'">
(now() + '-1 year')::DATE
</if>
<if test="searchKeyword == 'year'">
(select MIN(reg_dt) FROM ent_dscsn_aply WHERE use_yn = 'Y')
</if>
</if>
, NOW()::DATE, '1 day'::INTERVAL)) as date
LEFT JOIN (
SELECT COUNT(rvw_mttr_id)
, reg_dt::DATE AS reg_dt
FROM rvw_mttr
WHERE use_yn = 'Y'
GROUP BY reg_dt::DATE
) AS eda
ON date.stats_date = eda.reg_dt
ORDER BY stats_date) AS datas
<include refid="groupItem" />
ORDER BY stats_date
</select>
<!-- // 공무원 메인페이지 통계정보 관련 -->
</mapper>