diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/schedule/EgovAdminScheduleList.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/schedule/EgovAdminScheduleList.jsx index 643ae36..7c68238 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/schedule/EgovAdminScheduleList.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/schedule/EgovAdminScheduleList.jsx @@ -31,8 +31,6 @@ function EgovAdminDashboard(props) { // // const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || {schdulSe: '', year: TODAY.getFullYear(), month: TODAY.getMonth(), date: TODAY.getDate()}); // const [calendarTag, setCalendarTag] = useState([]); - // - // const [scheduleList, setScheduleList] = useState([]); // const innerConsole = (...args) => { // console.log(...args); @@ -51,29 +49,45 @@ function EgovAdminDashboard(props) { // setSearchCondition({...searchCondition, year: changedDate.getFullYear(), month: changedDate.getMonth(), date: changedDate.getDate()}); // } - // const retrieveList = useCallback((srchcnd) => { - // console.groupCollapsed("EgovAdminScheduleList.retrieveList()"); - // - // const retrieveListURL = '/schedule/month' + EgovNet.getQueryString(srchcnd); - // - // const requestOptions = { - // method: "GET", - // headers: { - // 'Content-type': 'application/json', - // } - // } - // - // EgovNet.requestFetch(retrieveListURL, - // requestOptions, - // (resp) => { - // setScheduleList(resp.result.resultList); - // }, - // function (resp) { - // console.log("err response : ", resp); - // } - // ); - // console.groupEnd("EgovAdminScheduleList.retrieveList()"); - // }, []); + // const [countTag, setCountTag] = useState([]); + const [dashboardCnt, setDashboardCnt] = useState({ ConnMonthlyCount: [[0, 0.0, 0]] }); + // const [item0, setItem0] = useState([]); + + const retrieveList = useCallback(() => { + const retrieveListURL = '/admin/dashboard/dash-count'; + + const requestOptions = { + method: "POST", + headers: { + 'Content-type': 'application/json', + } + } + + EgovNet.requestFetch(retrieveListURL, + requestOptions, + (resp) => { + // let mutCountTag = []; + setDashboardCnt(resp.result); + console.log(resp.result.ConnMonthlyCount); + + // mutCountTag.push( + //
+ //
{listIdx}
+ //
{item.userId}
+ //
{item.targetUserId}
+ //
{item.accessType === "PRV_LIST" ? "사용자현황 조회" : item.accessType === "PRV_VIEW" ? "User 상세조회" : "User 수정"}
+ //
{item.ipAddress}
+ //
{item.accessDt}
+ //
+ // ); + // setCountTag(mutCountTag); + }, + function (resp) { + console.log("err response : ", resp); + } + ); + // eslint-disable-next-lie react-hooks/exhaustive-deps + }, []); // const Location = React.memo(function Location() { @@ -88,10 +102,9 @@ function EgovAdminDashboard(props) { // ) // }); - // useEffect(() => { - // //retrieveList(searchCondition); disabled by thkim - // // eslint-disable-next-line react-hooks/exhaustive-deps - // }, [searchCondition]); + useEffect(() => { + retrieveList(); + }, [retrieveList]); // const [dailyUserLogList, setDailyUserLogList] = useState([]); // const [isDailyChart, setIsDailyChart] = useState(true); @@ -236,16 +249,16 @@ function EgovAdminDashboard(props) { {/* Dashboard*/} {/**/} - + - + - + diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/schedule/ReportAreaChart.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/schedule/ReportAreaChart.jsx index ca4b95c..1a5aa6b 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/schedule/ReportAreaChart.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/schedule/ReportAreaChart.jsx @@ -1,10 +1,11 @@ -import { useEffect, useState } from 'react'; +import {useCallback, useEffect, useState} from 'react'; // material-ui import { useTheme } from '@mui/material/styles'; // third-party import ReactApexChart from 'react-apexcharts'; +import * as EgovNet from 'api/egovFetch'; // chart options const areaChartOptions = { @@ -23,7 +24,7 @@ const areaChartOptions = { enabled: true }, title: { - text: '2024년 2월', + text: `${new Date().getFullYear()}년 ${new Date().getMonth() + 1}월`, align: 'center' }, responsive: [{ @@ -53,8 +54,35 @@ const ReportAreaChart = () => { const line = theme.palette.divider; const [options, setOptions] = useState(areaChartOptions); + const [connectMethod, setConnectMethod] = useState([]); + + // 메뉴 접속 및 방문자 수 + const retrieveList = useCallback(() => { + const retrieveListURL = '/admin/dashboard/connect-method' + + const requestOptions = { + method: "POST", + headers: { + 'Content-type': 'application/json', + }, + // body: JSON.stringify() + } + + EgovNet.requestFetch(retrieveListURL, + requestOptions, + (resp) => { + setConnectMethod(resp.result.connectMethod[0]); + }, + function (resp) { + console.log("err response : ", resp); + } + ); + // eslint-disable-next-lie react-hooks/exhaustive-deps + }, []); useEffect(() => { + retrieveList(); + setOptions((prevState) => ({ ...prevState, labels: ['PC', 'Mobile'], @@ -73,9 +101,13 @@ const ReportAreaChart = () => { } } })); - }, [primary, secondary, line, theme]); + }, [primary, secondary, line, theme, retrieveList]); - const [series] = useState([90, 10]); + const [series, setSeries] = useState([]); + + useEffect(() => { + setSeries(connectMethod); + }, [connectMethod]); return ; }; diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/AdminDashboardController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/AdminDashboardController.java index 5ee6130..4f29c2f 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/AdminDashboardController.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/AdminDashboardController.java @@ -27,6 +27,34 @@ public class AdminDashboardController extends BaseController { private final AdminDashboardService adminDashboardService; + @Operation( + summary = "Dashboard 상단 총접속자수 ~ 민원건수 카운트", + description = "상단 카운트 조회", + tags = {"AdminDashboardController"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "조회 성공"), + @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님") + }) + @RequestMapping(method = RequestMethod.POST, value = "/dash-count", consumes = MediaType.APPLICATION_JSON_VALUE) + public ResultVO getDashCount(@AuthenticationPrincipal LoginVO user) + throws Exception { + + ResultVO resultVO = new ResultVO(); + Map resultMap = new HashMap<>(); + + resultMap.put("ConnMonthlyCount", adminDashboardService.selectConnMonthly()); + resultMap.put("DocuMonthlyCount", adminDashboardService.selectDocuMonthly()); +// resultMap.put("loginMonthlyList", adminDashboardService.selectLoginMonthly()); +// resultMap.put("loginDailyList", adminDashboardService.selectLoginDaily()); + + resultVO.setResultCode(ResponseCode.SUCCESS.getCode()); + resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); + resultVO.setResult(resultMap); + return resultVO; + } + + @Operation( summary = "해당년도 메뉴/방문자수 월/요일별 조회", description = "해당년도 메뉴/방문자수 월/요일별 조회", @@ -80,6 +108,29 @@ public class AdminDashboardController extends BaseController { } + @Operation( + summary = "해당월 접속방법 조회", + description = "해당월 PC/MOBILE 조회", + tags = {"AdminDashboardController"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "조회 성공"), + @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님") + }) + @RequestMapping(method = RequestMethod.POST, value = "/connect-method", consumes = MediaType.APPLICATION_JSON_VALUE) + public ResultVO getConnectMethod(@AuthenticationPrincipal LoginVO user) + throws Exception { + + ResultVO resultVO = new ResultVO(); + Map resultMap = new HashMap<>(); + + resultMap.put("connectMethod", adminDashboardService.selectConnectMonthly()); + + resultVO.setResultCode(ResponseCode.SUCCESS.getCode()); + resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); + resultVO.setResult(resultMap); + return resultVO; + } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/repository/DashboardRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/repository/DashboardRepository.java new file mode 100644 index 0000000..0bc1274 --- /dev/null +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/repository/DashboardRepository.java @@ -0,0 +1,131 @@ +package com.dbnt.kcscbackend.admin.dashboard.repository; + +import com.dbnt.kcscbackend.admin.logs.entity.TnDailyMenuLog; +import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +public interface DashboardRepository extends JpaRepository { + + @Query(value = "WITH this_month_logs AS ( " + + " SELECT sum(log_cnt) AS this_month_cnt " + + " FROM tn_daily_user_log " + + " WHERE log_dt >= DATE_TRUNC('month', CURRENT_DATE) " + + " AND log_dt < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month' " + + "), " + + "last_month_logs AS ( " + + " SELECT sum(log_cnt) AS last_month_cnt " + + " FROM tn_daily_user_log " + + " WHERE log_dt >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') " + + " AND log_dt < DATE_TRUNC('month', CURRENT_DATE) " + + ") " + + "SELECT " + + " this_month_cnt, " + + " ROUND(((CAST(this_month_cnt AS NUMERIC) - last_month_cnt) / last_month_cnt * 100), 1) AS ratio, " + + " last_month_cnt " + + "FROM this_month_logs, last_month_logs", nativeQuery = true) + List ConnMonthlyCount(); + + @Query(value = "WITH this_month_logs AS ( " + + " SELECT count(*) AS this_month_cnt " + + " FROM tn_document_info " + + " WHERE last_yn = 'Y' AND use_yn = 'Y' " + + " AND frst_crt_dt >= DATE_TRUNC('month', CURRENT_DATE) " + + " AND frst_crt_dt < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month' " + + "), " + + "last_month_logs AS ( " + + " SELECT count(*) AS last_month_cnt " + + " FROM tn_document_info " + + " WHERE last_yn = 'Y' AND use_yn = 'Y' " + + " AND frst_crt_dt >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') " + + " AND frst_crt_dt < DATE_TRUNC('month', CURRENT_DATE) " + + ") " + + "SELECT " + + " this_month_cnt, " + + " ROUND(((CAST(this_month_cnt AS NUMERIC) - last_month_cnt) / last_month_cnt * 100), 1) AS ratio, " + + " last_month_cnt " + + "FROM this_month_logs, last_month_logs", nativeQuery = true) + List DocuMonthlyCount(); + + @Query(value = "WITH all_months AS (" + + " SELECT generate_series(DATE_TRUNC('year', CURRENT_DATE), DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '11 month', INTERVAL '1 month') AS month_start" + + ")" + + "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + + "FROM all_months " + + "LEFT JOIN tn_daily_menu_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " + + "GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " + + "ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true) + List MenuMonthlyList(); + + @Query(value = "WITH all_days AS (" + + " SELECT generate_series(" + + " DATE_TRUNC('year', now())," + + " DATE_TRUNC('year', now()) + INTERVAL '1 year' - INTERVAL '1 day'," + + " INTERVAL '1 day'" + + " ) AS day" + + ")" + + "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + + "FROM all_days ad " + + "LEFT JOIN tn_daily_menu_log tn ON ad.day = DATE_TRUNC('day', tn.log_dt) " + + "GROUP BY TO_CHAR(ad.day, 'Day') " + + "ORDER BY MIN(ad.day)", nativeQuery = true) + List MenuDailyList(); + + + @Query(value = "WITH all_months AS (" + + " SELECT generate_series(" + + " DATE_TRUNC('year', now())," + + " DATE_TRUNC('year', now()) + INTERVAL '11 month'," + + " INTERVAL '1 month'" + + " ) AS month_start" + + ")" + + "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + + "FROM all_months " + + "LEFT JOIN tn_daily_user_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " + + "GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " + + "ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true) + List LoginMonthlyList(); + + + + @Query(value = "WITH all_days AS (" + + " SELECT generate_series(" + + " DATE_TRUNC('year', CURRENT_DATE)," + + " DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," + + " INTERVAL '1 day'" + + " ) AS day" + + ")" + + "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + + "FROM all_days ad " + + "LEFT JOIN tn_daily_user_log tn ON ad.day = tn.log_dt " + + "GROUP BY TO_CHAR(ad.day, 'Day') " + + "ORDER BY MIN(ad.day)", nativeQuery = true) + List LoginDailyList(); + + + + @Query(value = "WITH all_days AS (" + + " SELECT generate_series(" + + " DATE_TRUNC('year', CURRENT_DATE)," + + " DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," + + " INTERVAL '1 day'" + + " ) AS day" + + ")" + + "SELECT COALESCE(COUNT(tn.access_dt), 0) AS log_cnt " + + "FROM all_days ad " + + "LEFT JOIN (SELECT access_dt FROM public.th_attach_file_log WHERE\n" + + " access_dt >= CURRENT_DATE - INTERVAL '6 day') tn ON ad.day = DATE_TRUNC('day', tn.access_dt) " + + "GROUP BY TO_CHAR(ad.day, 'Day') " + + "ORDER BY MIN(ad.day)", nativeQuery = true) + List FileDailyList(); + + + + @Query(value = "SELECT sum(pc_cnt) AS p_cnt, sum(mobile_cnt) AS m_cnt " + + "FROM tn_daily_user_log " + + "WHERE log_dt >= DATE_TRUNC('month', CURRENT_DATE) " + + "AND log_dt < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month'", nativeQuery = true) + List findConnMonthly(); +} diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/repository/MenuMonthlyRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/repository/MenuMonthlyRepository.java deleted file mode 100644 index 0000955..0000000 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/repository/MenuMonthlyRepository.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.dbnt.kcscbackend.admin.dashboard.repository; - -import com.dbnt.kcscbackend.admin.logs.entity.TnDailyMenuLog; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; - -import java.util.List; - -public interface MenuMonthlyRepository extends JpaRepository { - - @Query(value = "WITH all_months AS (" + - " SELECT generate_series(DATE_TRUNC('year', CURRENT_DATE), DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '11 month', INTERVAL '1 month') AS month_start" + - ")" + - "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + - "FROM all_months " + - "LEFT JOIN tn_daily_menu_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " + - "GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " + - "ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true) - List MenuMonthlyList(); - - @Query(value = "WITH all_days AS (" + - " SELECT generate_series(" + - " DATE_TRUNC('year', now())," + - " DATE_TRUNC('year', now()) + INTERVAL '1 year' - INTERVAL '1 day'," + - " INTERVAL '1 day'" + - " ) AS day" + - ")" + - "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + - "FROM all_days ad " + - "LEFT JOIN tn_daily_menu_log tn ON ad.day = DATE_TRUNC('day', tn.log_dt) " + - "GROUP BY TO_CHAR(ad.day, 'Day') " + - "ORDER BY MIN(ad.day)", nativeQuery = true) - List MenuDailyList(); - - - @Query(value = "WITH all_months AS (" + - " SELECT generate_series(" + - " DATE_TRUNC('year', now())," + - " DATE_TRUNC('year', now()) + INTERVAL '11 month'," + - " INTERVAL '1 month'" + - " ) AS month_start" + - ")" + - "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + - "FROM all_months " + - "LEFT JOIN tn_daily_user_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " + - "GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " + - "ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true) - List LoginMonthlyList(); - - - - @Query(value = "WITH all_days AS (" + - " SELECT generate_series(" + - " DATE_TRUNC('year', CURRENT_DATE)," + - " DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," + - " INTERVAL '1 day'" + - " ) AS day" + - ")" + - "SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " + - "FROM all_days ad " + - "LEFT JOIN tn_daily_user_log tn ON ad.day = tn.log_dt " + - "GROUP BY TO_CHAR(ad.day, 'Day') " + - "ORDER BY MIN(ad.day)", nativeQuery = true) - List LoginDailyList(); - - - - @Query(value = "WITH all_days AS (" + - " SELECT generate_series(" + - " DATE_TRUNC('year', CURRENT_DATE)," + - " DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," + - " INTERVAL '1 day'" + - " ) AS day" + - ")" + - "SELECT COALESCE(COUNT(tn.access_dt), 0) AS log_cnt " + - "FROM all_days ad " + - "LEFT JOIN (SELECT access_dt FROM public.th_attach_file_log WHERE\n" + - " access_dt >= CURRENT_DATE - INTERVAL '6 day') tn ON ad.day = DATE_TRUNC('day', tn.access_dt) " + - "GROUP BY TO_CHAR(ad.day, 'Day') " + - "ORDER BY MIN(ad.day)", nativeQuery = true) - List FileDailyList(); -} - diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/service/AdminDashboardService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/service/AdminDashboardService.java index 29a93dc..bee8ac1 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/service/AdminDashboardService.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/dashboard/service/AdminDashboardService.java @@ -1,8 +1,9 @@ package com.dbnt.kcscbackend.admin.dashboard.service; -//import com.dbnt.kcscbackend.admin.dashboard.entity.TnDailyUserLog; -import com.dbnt.kcscbackend.admin.dashboard.repository.MenuMonthlyRepository; +//import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog; //import com.dbnt.kcscbackend.admin.dashboard.repository.TnDailyUserLogRepository; +import com.dbnt.kcscbackend.admin.dashboard.repository.DashboardRepository; +import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog; import lombok.RequiredArgsConstructor; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.springframework.stereotype.Service; @@ -14,19 +15,23 @@ import java.util.List; @RequiredArgsConstructor public class AdminDashboardService extends EgovAbstractServiceImpl { // private final TnDailyUserLogRepository tnDailyUserLogRepository; - private final MenuMonthlyRepository menuMonthlyRepository; + private final DashboardRepository dashboardRepository; - public List selectMenuMonthly() { return menuMonthlyRepository.MenuMonthlyList(); } + public List selectConnMonthly() { return dashboardRepository.ConnMonthlyCount(); } - public List selectMenuDaily() { return menuMonthlyRepository.MenuDailyList(); } + public List selectDocuMonthly() { return dashboardRepository.DocuMonthlyCount(); } - public List selectLoginMonthly() { return menuMonthlyRepository.LoginMonthlyList(); } + public List selectMenuMonthly() { return dashboardRepository.MenuMonthlyList(); } - public List selectLoginDaily() { return menuMonthlyRepository.LoginDailyList(); } + public List selectMenuDaily() { return dashboardRepository.MenuDailyList(); } - public List selectFileDaily() { return menuMonthlyRepository.FileDailyList(); } + public List selectLoginMonthly() { return dashboardRepository.LoginMonthlyList(); } + public List selectLoginDaily() { return dashboardRepository.LoginDailyList(); } + public List selectFileDaily() { return dashboardRepository.FileDailyList(); } + + public List selectConnectMonthly() { return dashboardRepository.findConnMonthly(); } // public List selectDailyUserLogList(LocalDate startDate, LocalDate endDate) { // return tnDailyUserLogRepository.findByLogDtBetweenOrderByLogDt(startDate, endDate);