ads367 / yj_portal star
박정하 박정하 07-01
240701 박정하 관리자 통계 수정
@2ab4bafd995d7f05b7a5a6454d8671625a3780da
src/main/resources/mybatis/mapper/cntnStats/cntnStats-SQL.xml
--- src/main/resources/mybatis/mapper/cntnStats/cntnStats-SQL.xml
+++ src/main/resources/mybatis/mapper/cntnStats/cntnStats-SQL.xml
@@ -237,7 +237,7 @@
         SELECT ai.dates
             , array_agg(authrt_nm) AS authrt_nm
             , array_agg(COALESCE(ucs.cntn_nope, 0)) AS cntn_nope
-        FROM (SELECT generate_series(to_date(#{startDt}, 'YYYY-MM-DD'), to_date(#{endDt}, 'YYYY-MM-DD'), '1 day'::interval)::date AS dates , authrt_cd , authrt_nm FROM authrt_info) AS ai
+        FROM (SELECT generate_series(to_date(#{startDt}, 'YYYY-MM-DD'), to_date(#{endDt}, 'YYYY-MM-DD'), '1 day'::interval)::date AS dates , authrt_cd , authrt_nm FROM authrt_info WHERE use_yn = 'Y') AS ai
         LEFT JOIN (SELECT authrt_cd, to_date(concat(cntn_yr, cntn_mm, cntn_day), 'YYYYMMDD') AS cntn_date, cntn_nope FROM user_cntn_stats) AS ucs
         ON dates = ucs.cntn_date
         AND ai.authrt_cd = ucs.authrt_cd
@@ -280,17 +280,20 @@
                AND mi.menu_nm != '메인'
         )
         select (SELECT menu_name FROM menu_tree WHERE menu_tree.menu_id = menus.menu_id) AS menu_name
-             , array_agg((SELECT authrt_nm FROM authrt_info WHERE authrt_info.authrt_cd = menus.authrt_cd)) AS authrt_nm
+             , array_agg((SELECT authrt_nm FROM authrt_info WHERE authrt_info.authrt_cd = menus.authrt_cd AND authrt_info.use_yn = 'Y')) AS authrt_nm
              , array_agg(cntn_nope) AS cntn_nope
           from (select mt.menu_id, mai.authrt_cd, SUM(COALESCE(mcs.cntn_nope, 0)) AS cntn_nope
                   from menu_tree AS mt
              LEFT JOIN menu_authrt_info AS mai
                     ON mt.menu_id = mai.menu_id
+             LEFT JOIN authrt_info AS ai
+                    ON mai.authrt_cd = ai.authrt_cd
              LEFT JOIN menu_cntn_stats AS mcs
                     ON mt.menu_id = mcs.menu_id
                    AND mai.authrt_cd = mcs.authrt_cd
                    AND TO_DATE(CONCAT(cntn_yr, cntn_mm, cntn_day), 'YYYYMMDD') >= TO_DATE(#{startDt}, 'YYYY-MM-DD')
                    AND TO_DATE(#{endDt}, 'YYYY-MM-DD') >= TO_DATE(CONCAT(cntn_yr, cntn_mm, cntn_day), 'YYYYMMDD')
+                 WHERE ai.use_yn='Y'
               group by mt.menu_id, mai.authrt_cd) as menus
       group by menu_id
       order by menu_name
@@ -314,8 +317,8 @@
         INNER JOIN menu_info mi
                 ON mt.menu_id = mi.up_menu_id
         )
-        select sum(menu.cntn_nope)
-          from menu_tree
+        SELECT sum(menu.cntn_nope)
+          FROM menu_tree
         LEFT JOIN (
             SELECT menu_id, cntn_nope
               FROM menu_cntn_stats
@@ -334,20 +337,23 @@
         내   용 : 게시판 접속 통계 목록 조회
     -->
     <select id="selectBbsCntnStats" parameterType="HashMap" resultType="HashMap">
-        select (select bbs_nm from bbs_mng where bbs_mng_id = bbs.bbs_mng_id) AS bbs_nm
-        , array_agg((SELECT authrt_nm FROM authrt_info WHERE authrt_info.authrt_cd = bbs.authrt_cd)) AS authrt_nm
+        SELECT (SELECT bbs_nm from bbs_mng where bbs_mng_id = bbs.bbs_mng_id) AS bbs_nm
+        , array_agg((SELECT authrt_nm FROM authrt_info WHERE authrt_info.authrt_cd = bbs.authrt_cd AND authrt_info.use_yn = 'Y')) AS authrt_nm
         , array_agg(coalesce(cntn_nope, 0)) AS cntn_nope
         from (
-        select bm.bbs_mng_id
+        SELECT bm.bbs_mng_id
         , ad.authrt_cd
         from bbs_mng as bm
         left join (
-        select mai.authrt_cd
+        SELECT mai.authrt_cd
         , menu_type_ctgry
         from menu_info as mi
-        left join menu_authrt_info as mai
+        LEFT JOIN menu_authrt_info as mai
         on mi.menu_id = mai.menu_id
-        where use_yn = 'Y'
+        LEFT JOIN authrt_info AS ai
+        ON mai.authrt_cd = ai.authrt_cd
+        WHERE mi.use_yn = 'Y'
+        AND ai.use_yn='Y'
         order by mi.menu_id
         ) as ad
         on bm.bbs_mng_id = ad.menu_type_ctgry
@@ -382,9 +388,12 @@
         select mai.authrt_cd
         , menu_type_ctgry
         from menu_info as mi
-        left join menu_authrt_info as mai
+        LEFT JOIN menu_authrt_info as mai
         on mi.menu_id = mai.menu_id
-        where use_yn = 'Y'
+        LEFT JOIN authrt_info AS ai
+        ON mai.authrt_cd = ai.authrt_cd
+        WHERE mi.use_yn = 'Y'
+        AND ai.use_yn='Y'
         order by mi.menu_id
         ) as ad
         on bm.bbs_mng_id = ad.menu_type_ctgry
Add a comment
List