Merge branch 'master' of http://118.219.150.34:50501/DBNT/kcscDev
commit
f14ee3b03d
|
|
@ -48,7 +48,7 @@ const AnalyticEcommerce = ({ color, title, count, percentage, isLoss, extra }) =
|
|||
<Typography component="span" variant="caption" sx={{ color: `${color || 'primary'}.main` }}>
|
||||
{extra}
|
||||
</Typography>{' '}
|
||||
건이 추가되었습니다.
|
||||
건이 기록되었습니다.
|
||||
</Typography>
|
||||
</Box>
|
||||
</MainCard>
|
||||
|
|
@ -1,29 +1,14 @@
|
|||
import React, {useState, useEffect, useCallback} from 'react'; // PureComponent
|
||||
import {Link} from 'react-router-dom'; //useLocation
|
||||
|
||||
import {BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts';
|
||||
// import {BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts';
|
||||
|
||||
import * as EgovNet from 'api/egovFetch';
|
||||
import URL from 'constants/url';
|
||||
// import CODE from 'constants/code';
|
||||
|
||||
// material-ui
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
Box,
|
||||
Button,
|
||||
Grid,
|
||||
List,
|
||||
ListItemAvatar,
|
||||
ListItemButton,
|
||||
ListItemSecondaryAction,
|
||||
ListItemText,
|
||||
MenuItem,
|
||||
Stack,
|
||||
TextField,
|
||||
Typography
|
||||
} from '@mui/material';
|
||||
import { Box, Button, Grid, Stack, Typography } from '@mui/material';
|
||||
import MainCard from 'components/cards/MainCard';
|
||||
import BbsTable from './BbsTable';
|
||||
import IncomeAreaChart from './IncomeAreaChart';
|
||||
|
|
@ -33,7 +18,7 @@ import AnalyticEcommerce from 'components/cards/AnalyticEcommerce';
|
|||
|
||||
import {default as EgovLeftNav} from 'components/leftmenu/EgovLeftNavAdmin';
|
||||
|
||||
function EgovAdminScheduleList(props) {
|
||||
function EgovAdminDashboard(props) {
|
||||
// console.group("EgovAdminScheduleList");
|
||||
// console.log("[Start] EgovAdminScheduleList ------------------------------");
|
||||
// console.log("EgovAdminScheduleList [props] : ", props);
|
||||
|
|
@ -41,7 +26,7 @@ function EgovAdminScheduleList(props) {
|
|||
// const location = useLocation();
|
||||
// console.log("EgovAdminScheduleList [location] : ", location);
|
||||
|
||||
// const DATE = new Date();
|
||||
const DATE = new Date();
|
||||
// const TODAY = new Date(DATE.getFullYear(), DATE.getMonth(), DATE.getDate());
|
||||
//
|
||||
// const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || {schdulSe: '', year: TODAY.getFullYear(), month: TODAY.getMonth(), date: TODAY.getDate()});
|
||||
|
|
@ -53,14 +38,6 @@ function EgovAdminScheduleList(props) {
|
|||
// console.log(...args);
|
||||
// }
|
||||
|
||||
// const getLastDateOfMonth = (year, month) => {
|
||||
// const LAST_DATE_SUPPLMENT = 1;
|
||||
// return new Date(year, month + LAST_DATE_SUPPLMENT, 0);
|
||||
// }
|
||||
// const getFirstDateOfMonth = (year, month) => {
|
||||
// return new Date(year, month, 1);
|
||||
// }
|
||||
|
||||
// const changeDate = (target, amount) => {
|
||||
// let changedDate;
|
||||
//
|
||||
|
|
@ -98,125 +75,6 @@ function EgovAdminScheduleList(props) {
|
|||
// console.groupEnd("EgovAdminScheduleList.retrieveList()");
|
||||
// }, []);
|
||||
|
||||
// const drawCalendar = () => {
|
||||
// console.groupCollapsed("EgovAdminScheduleList.drawCalendar()");
|
||||
// const PREV_MONTH_ADDITION = -1;
|
||||
//
|
||||
// let lastOfLastMonth = getLastDateOfMonth(searchCondition.year, searchCondition.month + PREV_MONTH_ADDITION);
|
||||
// let firstOfThisMonth = getFirstDateOfMonth(searchCondition.year, searchCondition.month);
|
||||
// let lastOfThisMonth = getLastDateOfMonth(searchCondition.year, searchCondition.month);
|
||||
//
|
||||
// console.log("lastOfLastMonth : ", lastOfLastMonth, lastOfLastMonth.getDay());
|
||||
// console.log("firstOfThisMonth :", firstOfThisMonth, firstOfThisMonth.getDay());
|
||||
// console.log("lastOfThisMonth :", lastOfThisMonth, lastOfThisMonth.getDay());
|
||||
// console.log("scheduleList : ", scheduleList);
|
||||
//
|
||||
// let firstDayOfThisMonth = firstOfThisMonth.getDay();
|
||||
// let lastDateOfThisMonth = lastOfThisMonth.getDate();
|
||||
// console.log("firstDayOfThisMonth", firstDayOfThisMonth, "lastDateOfThisMonth", lastDateOfThisMonth)
|
||||
//
|
||||
// let monthArr = [];
|
||||
// let weekArr = [];
|
||||
//
|
||||
// // firstWeek Date Set START
|
||||
// let firstWeekDateCount = 0;
|
||||
// for (let day = 0; day < 7; day++) {
|
||||
// if (day < firstDayOfThisMonth) { //
|
||||
// weekArr.push(0);
|
||||
// firstWeekDateCount = 0;
|
||||
// } else {
|
||||
// weekArr.push(++firstWeekDateCount);
|
||||
// }
|
||||
// }
|
||||
// monthArr.push(weekArr);
|
||||
// console.log("FirstWeek monthArr : ", monthArr);
|
||||
// // firstWeek Date Set END
|
||||
//
|
||||
// // otherWeek Date Set START
|
||||
// let dayCount = 0;
|
||||
// weekArr = [];//초기화
|
||||
// for (let day = firstWeekDateCount + 1; day <= lastDateOfThisMonth; day++) {
|
||||
//
|
||||
// if (dayCount % 7 !== 6) {
|
||||
// weekArr.push(day);
|
||||
// } else {
|
||||
// weekArr.push(day);
|
||||
// monthArr.push(weekArr);
|
||||
// weekArr = [];
|
||||
// dayCount = -1;
|
||||
// }
|
||||
// dayCount++;
|
||||
// }
|
||||
// // otherWeek Date Set END
|
||||
//
|
||||
// // lastWeek Date Set START
|
||||
// if (weekArr.length > 0) {//남은 부분
|
||||
// for (let day = weekArr.length; day < 7; day++) {
|
||||
// weekArr.push(0);
|
||||
// }
|
||||
// monthArr.push(weekArr);
|
||||
// }
|
||||
// // lastWeek Date Set END
|
||||
// console.log("OtherWeek monthArr : ", monthArr);
|
||||
//
|
||||
// let mutsUseYearMonth = searchCondition.year.toString() + ((searchCondition.month + 1).toString().length === 1 ? "0" + (searchCondition.month + 1).toString() : (searchCondition.month + 1).toString());
|
||||
// console.log("mutsUseYearMonth : ", mutsUseYearMonth);
|
||||
//
|
||||
// let mutCalendarTagList = [];
|
||||
// let keyIdx = 0;
|
||||
//
|
||||
// //draw Calendar
|
||||
// monthArr.forEach((week, weekIdx) => {
|
||||
// console.log();
|
||||
// mutCalendarTagList.push(
|
||||
// <tr key={keyIdx++}>{
|
||||
// week.map((day, dayIdx) => {
|
||||
// if (day !== 0) {//당월 일별 구현
|
||||
// let sDate = day.toString().length === 1 ? "0" + day.toString() : day.toString();
|
||||
// let iUseDate = Number(mutsUseYearMonth + sDate);
|
||||
// if (scheduleList.length > 0) {//일정 있는 경우
|
||||
// return (
|
||||
// <td key={keyIdx++}>
|
||||
// <Link to={{pathname: URL.ADMIN_SCHEDULE_CREATE}} state={{iUseDate: mutsUseYearMonth + sDate + "000000"}} className="day"
|
||||
// key={keyIdx++}>{day}</Link><br/>
|
||||
// {
|
||||
// scheduleList.map((schedule, scheduleIdx) => {
|
||||
// let iBeginDate = Number(schedule.schdulBgnde.substring(0, 8));
|
||||
// let iEndDate = Number(schedule.schdulEndde.substring(0, 8));
|
||||
// innerConsole("scheduleList ", day, scheduleIdx, iBeginDate, iUseDate, iEndDate, iUseDate >= iBeginDate && iUseDate <= iEndDate);
|
||||
// innerConsole("schedule.schdulId ", schedule.schdulId);
|
||||
// if (iUseDate >= iBeginDate && iUseDate <= iEndDate) {
|
||||
// return (
|
||||
// <>
|
||||
// <Link to={{pathname: URL.ADMIN_SCHEDULE_DETAIL}}
|
||||
// state={{schdulId: schedule.schdulId}}
|
||||
// key={keyIdx++}>{schedule.schdulNm}
|
||||
// </Link>
|
||||
// <br/>
|
||||
// </>
|
||||
// );
|
||||
// } else return <></>
|
||||
// })
|
||||
// }
|
||||
// </td>
|
||||
// );
|
||||
// } else {//일정 없는 경우
|
||||
// return (
|
||||
// <td key={keyIdx++}>
|
||||
// <Link to={{pathname: URL.ADMIN_SCHEDULE_CREATE}} state={{iUseDate: mutsUseYearMonth + sDate + "000000"}} className="day"
|
||||
// key={keyIdx++}>{day}</Link><br/>
|
||||
// </td>);
|
||||
// }
|
||||
// } else if (day === 0) {// 이전달/다음달 구현
|
||||
// return (<td key={keyIdx++}></td>);
|
||||
// } else return <></>
|
||||
// })
|
||||
// }</tr>);
|
||||
// })
|
||||
// console.log("mutCalendarTagList : ", mutCalendarTagList);
|
||||
// setCalendarTag(mutCalendarTagList);
|
||||
// console.groupEnd("EgovAdminScheduleList.drawCalendar()");
|
||||
// }
|
||||
|
||||
// const Location = React.memo(function Location() {
|
||||
// return (
|
||||
|
|
@ -235,83 +93,78 @@ function EgovAdminScheduleList(props) {
|
|||
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
// }, [searchCondition]);
|
||||
|
||||
// useEffect(() => {
|
||||
// drawCalendar();
|
||||
// const [dailyUserLogList, setDailyUserLogList] = useState([]);
|
||||
// const [isDailyChart, setIsDailyChart] = useState(true);
|
||||
//
|
||||
// const getDailyUserLogList = useCallback(() => {
|
||||
// // console.groupCollapsed("EgovAdminScheduleList.getDailyUserLogList()");
|
||||
// //
|
||||
// // console.log("@@@ isDailyChart : " + isDailyChart);
|
||||
//
|
||||
// const dailyUserLogListURL = isDailyChart ? '/admin/dashboard/daily-user-log-list' : '/admin/dashboard/monthly-user-log-list';
|
||||
//
|
||||
// const requestOptions = {
|
||||
// method: "GET",
|
||||
// headers: {
|
||||
// 'Content-type': 'application/json',
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// EgovNet.requestFetch(dailyUserLogListURL,
|
||||
// requestOptions,
|
||||
// (resp) => {
|
||||
// setDailyUserLogList(resp.result.dailyUserLogList);
|
||||
// // console.log("@@@ : " + dailyUserLogList);
|
||||
// },
|
||||
// function (resp) {
|
||||
// // console.log("err response : ", resp);
|
||||
// }
|
||||
// );
|
||||
// // console.groupEnd("EgovAdminScheduleList.getDailyUserLogList()");
|
||||
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
// }, [scheduleList]);
|
||||
|
||||
const [dailyUserLogList, setDailyUserLogList] = useState([]);
|
||||
const [isDailyChart, setIsDailyChart] = useState(true);
|
||||
|
||||
const getDailyUserLogList = useCallback(() => {
|
||||
// console.groupCollapsed("EgovAdminScheduleList.getDailyUserLogList()");
|
||||
//
|
||||
// console.log("@@@ isDailyChart : " + isDailyChart);
|
||||
|
||||
const dailyUserLogListURL = isDailyChart ? '/admin/dashboard/daily-user-log-list' : '/admin/dashboard/monthly-user-log-list';
|
||||
|
||||
const requestOptions = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
}
|
||||
}
|
||||
|
||||
EgovNet.requestFetch(dailyUserLogListURL,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
setDailyUserLogList(resp.result.dailyUserLogList);
|
||||
// console.log("@@@ : " + dailyUserLogList);
|
||||
},
|
||||
function (resp) {
|
||||
// console.log("err response : ", resp);
|
||||
}
|
||||
);
|
||||
// console.groupEnd("EgovAdminScheduleList.getDailyUserLogList()");
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isDailyChart]);
|
||||
|
||||
useEffect(() => {
|
||||
getDailyUserLogList();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isDailyChart]);
|
||||
|
||||
const handleChartToggle = () => {
|
||||
setIsDailyChart(!isDailyChart);
|
||||
};
|
||||
|
||||
const ChartToggle = ({onToggle}) => {
|
||||
|
||||
const handleToggle = () => {
|
||||
onToggle(!isDailyChart);
|
||||
};
|
||||
|
||||
return (
|
||||
<button onClick={handleToggle}>
|
||||
{isDailyChart ? '월별차트보기' : '일별차트보기'}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
const data = dailyUserLogList.map(item => ({
|
||||
logDt: item.logDt,
|
||||
uv: item.mobileCnt,
|
||||
"사용자 접속현황": item.logCnt,
|
||||
amt: item.pcCnt,
|
||||
}));
|
||||
|
||||
const CustomTooltip = ({active, payload, label}) => {
|
||||
if (active && payload && payload.length) {
|
||||
return (
|
||||
<div className="custom-tooltip">
|
||||
<p className="desc">사용자 접속 현황</p>
|
||||
<p className="label">{`${label} : ${payload[0].value}`}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
// }, [isDailyChart]);
|
||||
//
|
||||
// useEffect(() => {
|
||||
// getDailyUserLogList();
|
||||
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
// }, [isDailyChart]);
|
||||
//
|
||||
// const handleChartToggle = () => {
|
||||
// setIsDailyChart(!isDailyChart);
|
||||
// };
|
||||
//
|
||||
// const ChartToggle = ({onToggle}) => {
|
||||
//
|
||||
// const handleToggle = () => {
|
||||
// onToggle(!isDailyChart);
|
||||
// };
|
||||
//
|
||||
// return (
|
||||
// <button onClick={handleToggle}>
|
||||
// {isDailyChart ? '월별차트보기' : '일별차트보기'}
|
||||
// </button>
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// const data = dailyUserLogList.map(item => ({
|
||||
// logDt: item.logDt,
|
||||
// uv: item.mobileCnt,
|
||||
// "사용자 접속현황": item.logCnt,
|
||||
// amt: item.pcCnt,
|
||||
// }));
|
||||
//
|
||||
// const CustomTooltip = ({active, payload, label}) => {
|
||||
// if (active && payload && payload.length) {
|
||||
// return (
|
||||
// <div className="custom-tooltip">
|
||||
// <p className="desc">사용자 접속 현황</p>
|
||||
// <p className="label">{`${label} : ${payload[0].value}`}</p>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// };
|
||||
|
||||
// class UserLogChart extends PureComponent {
|
||||
// render() {
|
||||
|
|
@ -342,7 +195,8 @@ function EgovAdminScheduleList(props) {
|
|||
|
||||
// console.log("------------------------------EgovAdminScheduleList [End]");
|
||||
// console.groupEnd("EgovAdminScheduleList");
|
||||
const [value, setValue] = useState('today');
|
||||
|
||||
// const [value, setValue] = useState('today');
|
||||
const [slot, setSlot] = useState('week');
|
||||
|
||||
return (
|
||||
|
|
@ -376,16 +230,16 @@ function EgovAdminScheduleList(props) {
|
|||
{/* <Typography variant="h5">Dashboard</Typography>*/}
|
||||
{/*</Grid>*/}
|
||||
<Grid item xs={12} sm={6} md={4} lg={3}>
|
||||
<AnalyticEcommerce title="총접속자수 (금월)" count="442,236" percentage={59.3} extra="35,000" />
|
||||
<AnalyticEcommerce title={`총접속자수 (${DATE.getMonth() + 1}월)`} count="442,236" percentage={59.3} extra="35,000" />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={4} lg={3}>
|
||||
<AnalyticEcommerce title="건설기준 DB구축 (금월)" count="78,250" percentage={70.5} extra="8,900" />
|
||||
<AnalyticEcommerce title={`건설기준 오류건수 (${DATE.getMonth() + 1}월)`} count="78,250" percentage={70.5} extra="8,900" />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={4} lg={3}>
|
||||
<AnalyticEcommerce title="기준코드 등록건수 (금월)" count="18,800" percentage={27.4} isLoss color="warning" extra="1,943" />
|
||||
<AnalyticEcommerce title={`기준코드 등록건수 (${DATE.getMonth() + 1}월)`} count="18,800" percentage={27.4} isLoss color="warning" extra="1,943" />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={4} lg={3}>
|
||||
<AnalyticEcommerce title="민원건수 (금월)" count="5" percentage={80} isLoss color="warning" extra="1" />
|
||||
<AnalyticEcommerce title={`민원건수 (${DATE.getMonth() + 1}월)`} count="5" percentage={80} isLoss color="warning" extra="1" />
|
||||
</Grid>
|
||||
|
||||
<Grid item md={8} sx={{ display: { sm: 'none', md: 'block', lg: 'none' } }} />
|
||||
|
|
@ -394,7 +248,7 @@ function EgovAdminScheduleList(props) {
|
|||
<Grid item xs={12} md={7} lg={8}>
|
||||
<Grid container alignItems="center" justifyContent="space-between">
|
||||
<Grid item>
|
||||
<Typography variant="h5">방문자</Typography>
|
||||
<Typography variant="h5">{ DATE.getFullYear() }년 메뉴접속 / 방문수 </Typography>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Stack direction="row" alignItems="center" spacing={0}>
|
||||
|
|
@ -426,7 +280,7 @@ function EgovAdminScheduleList(props) {
|
|||
<Grid item xs={12} md={5} lg={4}>
|
||||
<Grid container alignItems="center" justifyContent="space-between">
|
||||
<Grid item>
|
||||
<Typography variant="h5">다운로드 현황</Typography>
|
||||
<Typography variant="h5">다운로드수</Typography>
|
||||
</Grid>
|
||||
<Grid item />
|
||||
</Grid>
|
||||
|
|
@ -500,4 +354,4 @@ function EgovAdminScheduleList(props) {
|
|||
);
|
||||
}
|
||||
|
||||
export default EgovAdminScheduleList;
|
||||
export default EgovAdminDashboard;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
|
||||
// material-ui
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
|
|
@ -7,6 +7,8 @@ import { useTheme } from '@mui/material/styles';
|
|||
// third-party
|
||||
import ReactApexChart from 'react-apexcharts';
|
||||
|
||||
import * as EgovNet from 'api/egovFetch';
|
||||
|
||||
// chart options
|
||||
const areaChartOptions = {
|
||||
chart: {
|
||||
|
|
@ -37,8 +39,41 @@ const IncomeAreaChart = ({ slot }) => {
|
|||
const line = theme.palette.divider;
|
||||
|
||||
const [options, setOptions] = useState(areaChartOptions);
|
||||
const [menuMonthlyList, setMenuMonthlyList] = useState([]);
|
||||
const [menuDailyList, setMenuDailyList] = useState([]);
|
||||
const [loginMonthlyList, setLoginMonthlyList] = useState([]);
|
||||
const [loginDailyList, setLoginDailyList] = useState([]);
|
||||
|
||||
// 메뉴 접속 및 방문자 수
|
||||
const retrieveList = useCallback(() => {
|
||||
const retrieveListURL = '/admin/dashboard/menu-login'
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
// body: JSON.stringify()
|
||||
}
|
||||
|
||||
EgovNet.requestFetch(retrieveListURL,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
setMenuMonthlyList(resp.result.menuMonthlyList);
|
||||
setMenuDailyList(resp.result.menuDailyList);
|
||||
setLoginMonthlyList(resp.result.loginMonthlyList);
|
||||
setLoginDailyList(resp.result.loginDailyList);
|
||||
},
|
||||
function (resp) {
|
||||
console.log("err response : ", resp);
|
||||
}
|
||||
);
|
||||
// eslint-disable-next-lie react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
retrieveList();
|
||||
|
||||
setOptions((prevState) => ({
|
||||
...prevState,
|
||||
colors: [theme.palette.primary.main, theme.palette.primary[700]],
|
||||
|
|
@ -85,31 +120,31 @@ const IncomeAreaChart = ({ slot }) => {
|
|||
theme: 'light'
|
||||
}
|
||||
}));
|
||||
}, [primary, secondary, line, theme, slot]);
|
||||
}, [primary, secondary, line, theme, slot, retrieveList]);
|
||||
|
||||
const [series, setSeries] = useState([
|
||||
{
|
||||
name: 'Page Views',
|
||||
data: [0, 86, 28, 115, 48, 210, 136]
|
||||
name: 'Menu Views',
|
||||
data: menuDailyList
|
||||
},
|
||||
{
|
||||
name: 'Sessions',
|
||||
data: [0, 43, 14, 56, 24, 105, 68]
|
||||
name: 'Login Count',
|
||||
data: loginDailyList
|
||||
}
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
setSeries([
|
||||
{
|
||||
name: 'Page Views',
|
||||
data: slot === 'month' ? [76, 85, 101, 98, 87, 105, 91, 114, 94, 86, 115, 35] : [31, 40, 28, 51, 42, 109, 100]
|
||||
name: 'Menu Views',
|
||||
data: slot === 'month' ? menuMonthlyList : menuDailyList
|
||||
},
|
||||
{
|
||||
name: 'Sessions',
|
||||
data: slot === 'month' ? [110, 60, 150, 35, 60, 36, 26, 45, 65, 52, 53, 41] : [11, 32, 45, 32, 34, 52, 41]
|
||||
name: 'Login Count',
|
||||
data: slot === 'month' ? loginMonthlyList : loginDailyList
|
||||
}
|
||||
]);
|
||||
}, [slot]);
|
||||
}, [slot, menuMonthlyList, menuDailyList, loginMonthlyList, loginDailyList]);
|
||||
|
||||
return <ReactApexChart options={options} series={series} type="area" height={450} />;
|
||||
};
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.dbnt.kcscbackend.admin.dashboard;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.dashboard.dto.MonthlyUserLogDTO;
|
||||
//import com.dbnt.kcscbackend.admin.dashboard.dto.MonthlyUserLogDTO;
|
||||
import com.dbnt.kcscbackend.admin.dashboard.service.AdminDashboardService;
|
||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||
import com.dbnt.kcscbackend.config.common.BaseController;
|
||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
|
|
@ -10,6 +12,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -30,57 +34,93 @@ public class AdminDashboardController extends BaseController {
|
|||
private final AdminDashboardService adminDashboardService;
|
||||
|
||||
@Operation(
|
||||
summary = "일별 사용자 현황 차트 조회",
|
||||
description = "일별 사용자 현황 차트 조회",
|
||||
summary = "해당년도 메뉴/방문자수 월/요일별 조회",
|
||||
description = "해당년도 메뉴/방문자수 월/요일별 조회",
|
||||
tags = {"AdminDashboardController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/daily-user-log-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO getDailyUserLogList() throws Exception {
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/menu-login", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO getMenuVisit(@AuthenticationPrincipal LoginVO user)
|
||||
throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
// 현재 날짜
|
||||
// todo endDate 뒤에 .minus 지워야함
|
||||
LocalDate endDate = LocalDate.now().minusMonths(6);
|
||||
// 3개월 전 날짜 계산
|
||||
LocalDate startDate = endDate.minusMonths(3);
|
||||
resultMap.put("menuMonthlyList", adminDashboardService.selectMenuMonthly());
|
||||
resultMap.put("menuDailyList", adminDashboardService.selectMenuDaily());
|
||||
resultMap.put("loginMonthlyList", adminDashboardService.selectLoginMonthly());
|
||||
resultMap.put("loginDailyList", adminDashboardService.selectLoginDaily());
|
||||
|
||||
resultMap.put("dailyUserLogList", adminDashboardService.selectDailyUserLogList(startDate, endDate));
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
resultVO.setResult(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "월별 사용자 현황 차트 조회",
|
||||
description = "월별 사용자 현황 차트 조회",
|
||||
tags = {"AdminDashboardController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/monthly-user-log-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO getMonthlyUserLogList() throws Exception {
|
||||
ResultVO resultVO = new ResultVO();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
// 현재 날짜
|
||||
// todo endDate 뒤에 .minus 지워야함
|
||||
LocalDate endDate = LocalDate.now().minusMonths(6);
|
||||
// 3개월 전 날짜 계산
|
||||
LocalDate startDate = endDate.minusMonths(3);
|
||||
|
||||
List<Object[]> result = adminDashboardService.selectMonthlyUserLogList(startDate, endDate);
|
||||
List<MonthlyUserLogDTO> monthlyUserLogDTOList = result.stream()
|
||||
.map(row -> new MonthlyUserLogDTO((String) row[0], (BigInteger) row[1]))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
resultMap.put("dailyUserLogList", monthlyUserLogDTOList);
|
||||
resultVO.setResult(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @Operation(
|
||||
// summary = "일별 사용자 현황 차트 조회",
|
||||
// description = "일별 사용자 현황 차트 조회",
|
||||
// tags = {"AdminDashboardController"}
|
||||
// )
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
// @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
// })
|
||||
// @RequestMapping(method = RequestMethod.GET, value = "/daily-user-log-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public ResultVO getDailyUserLogList() throws Exception {
|
||||
// ResultVO resultVO = new ResultVO();
|
||||
// Map<String, Object> resultMap = new HashMap<>();
|
||||
//
|
||||
// // 현재 날짜
|
||||
// // todo endDate 뒤에 .minus 지워야함
|
||||
// LocalDate endDate = LocalDate.now().minusMonths(6);
|
||||
// // 3개월 전 날짜 계산
|
||||
// LocalDate startDate = endDate.minusMonths(3);
|
||||
//
|
||||
// resultMap.put("dailyUserLogList", adminDashboardService.selectDailyUserLogList(startDate, endDate));
|
||||
// resultVO.setResult(resultMap);
|
||||
// return resultVO;
|
||||
// }
|
||||
//
|
||||
// @Operation(
|
||||
// summary = "월별 사용자 현황 차트 조회",
|
||||
// description = "월별 사용자 현황 차트 조회",
|
||||
// tags = {"AdminDashboardController"}
|
||||
// )
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
// @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
// })
|
||||
// @RequestMapping(method = RequestMethod.GET, value = "/monthly-user-log-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public ResultVO getMonthlyUserLogList() throws Exception {
|
||||
// ResultVO resultVO = new ResultVO();
|
||||
// Map<String, Object> resultMap = new HashMap<>();
|
||||
//
|
||||
// // 현재 날짜
|
||||
// // todo endDate 뒤에 .minus 지워야함
|
||||
// LocalDate endDate = LocalDate.now().minusMonths(6);
|
||||
// // 3개월 전 날짜 계산
|
||||
// LocalDate startDate = endDate.minusMonths(3);
|
||||
//
|
||||
// List<Object[]> result = adminDashboardService.selectMonthlyUserLogList(startDate, endDate);
|
||||
// List<MonthlyUserLogDTO> monthlyUserLogDTOList = result.stream()
|
||||
// .map(row -> new MonthlyUserLogDTO((String) row[0], (BigInteger) row[1]))
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// resultMap.put("dailyUserLogList", monthlyUserLogDTOList);
|
||||
// resultVO.setResult(resultMap);
|
||||
// return resultVO;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
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<TnDailyMenuLog, Long> {
|
||||
|
||||
@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<Long> 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(COUNT(tn.create_dt), 0) AS log_cnt " +
|
||||
"FROM all_days ad " +
|
||||
"LEFT JOIN th_menu_log tn ON ad.day = DATE_TRUNC('day', tn.create_dt) " +
|
||||
"GROUP BY TO_CHAR(ad.day, 'Day') " +
|
||||
"ORDER BY MIN(ad.day)", nativeQuery = true)
|
||||
List<Long> 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<Long> 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<Long> LoginDailyList();
|
||||
}
|
||||
|
||||
|
|
@ -1,24 +1,38 @@
|
|||
package com.dbnt.kcscbackend.admin.dashboard.service;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.dashboard.entity.TnDailyUserLog;
|
||||
import com.dbnt.kcscbackend.admin.dashboard.repository.TnDailyUserLogRepository;
|
||||
//import com.dbnt.kcscbackend.admin.dashboard.entity.TnDailyUserLog;
|
||||
import com.dbnt.kcscbackend.admin.dashboard.repository.MenuMonthlyRepository;
|
||||
//import com.dbnt.kcscbackend.admin.dashboard.repository.TnDailyUserLogRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
//import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdminDashboardService extends EgovAbstractServiceImpl {
|
||||
private final TnDailyUserLogRepository tnDailyUserLogRepository;
|
||||
// private final TnDailyUserLogRepository tnDailyUserLogRepository;
|
||||
private final MenuMonthlyRepository menuMonthlyRepository;
|
||||
|
||||
public List<TnDailyUserLog> selectDailyUserLogList(LocalDate startDate, LocalDate endDate) {
|
||||
return tnDailyUserLogRepository.findByLogDtBetweenOrderByLogDt(startDate, endDate);
|
||||
}
|
||||
public List<Long> selectMenuMonthly() { return menuMonthlyRepository.MenuMonthlyList(); }
|
||||
|
||||
public List<Object[]> selectMonthlyUserLogList(LocalDate startDate, LocalDate endDate) {
|
||||
return tnDailyUserLogRepository.selectMonthlyUserLogStatistics(startDate, endDate);
|
||||
}
|
||||
public List<Long> selectMenuDaily() { return menuMonthlyRepository.MenuDailyList(); }
|
||||
|
||||
public List<Long> selectLoginMonthly() { return menuMonthlyRepository.LoginMonthlyList(); }
|
||||
|
||||
public List<Long> selectLoginDaily() { return menuMonthlyRepository.LoginDailyList(); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// public List<TnDailyUserLog> selectDailyUserLogList(LocalDate startDate, LocalDate endDate) {
|
||||
// return tnDailyUserLogRepository.findByLogDtBetweenOrderByLogDt(startDate, endDate);
|
||||
// }
|
||||
//
|
||||
// public List<Object[]> selectMonthlyUserLogList(LocalDate startDate, LocalDate endDate) {
|
||||
// return tnDailyUserLogRepository.selectMonthlyUserLogStatistics(startDate, endDate);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue