Commit f0974e0c authored by Maofei94's avatar Maofei94

Merge branch 'master' of g.civnet.cn:ReactWeb5/maintenance

parents c4e83ae5 0affa87a
Pipeline #22845 skipped with stages
...@@ -35,15 +35,9 @@ const ServiceLog = () => { ...@@ -35,15 +35,9 @@ const ServiceLog = () => {
const [searchWord, setSearchWord] = useState(''); // 关键字 const [searchWord, setSearchWord] = useState(''); // 关键字
// 计算时间间隔(分钟) // 计算时间间隔(分钟)
const start = new Date(startTime.format('YYYY-MM-DD HH:mm:ss')).getTime(); const start = new Date(startTime).getTime();
const end = new Date(endTime.format('YYYY-MM-DD HH:mm:ss')).getTime(); const end = new Date(endTime).getTime();
const minuteInterval = (end - start) / (60 * 1000); // 相隔多少分钟 const minuteInterval = (end - start) / (60 * 1000); // 相隔多少分钟
if (minuteInterval <= 0) {
notification.error({
message: '时间设置有误',
description: '起始时间应该早于结束时间',
});
}
const countInterval = () => { const countInterval = () => {
if (minuteInterval > 0 && minuteInterval <= 30) { if (minuteInterval > 0 && minuteInterval <= 30) {
setTimeInterval('1'); setTimeInterval('1');
...@@ -55,6 +49,25 @@ const ServiceLog = () => { ...@@ -55,6 +49,25 @@ const ServiceLog = () => {
setTimeInterval('4'); setTimeInterval('4');
} }
}; };
// 计算时间间隔(月份),禁止跨月份查询
const startMonth = new Date(startTime).getMonth();
const endMonth = new Date(endTime).getMonth();
const startYear = new Date(startTime).getYear();
const endYear = new Date(endTime).getYear();
if (minuteInterval <= 0) {
notification.error({
message: '时间设置有误',
description: '起始时间应该早于结束时间',
});
} else if (
(startMonth !== endMonth && startYear === endYear) ||
startYear !== endYear
) {
notification.info({
message: '时间设置提示',
description: '不允许跨月份查询',
});
}
const columns = [ const columns = [
{ {
...@@ -119,20 +132,38 @@ const ServiceLog = () => { ...@@ -119,20 +132,38 @@ const ServiceLog = () => {
sorter: (a, b) => a.ResponseSize - b.ResponseSize, sorter: (a, b) => a.ResponseSize - b.ResponseSize,
}, },
]; ];
// 在起止时间任意一个变化后获取数据,且起止时间应该早于结束时间 // 在起止时间任意一个变化后获取数据,且起止时间应该早于结束时间,且不允许跨月查询
useEffect(() => { useEffect(() => {
if (startTime && endTime && end - start > 0) { if (
startTime &&
endTime &&
end - start > 0 &&
startMonth === endMonth &&
startYear === endYear
) {
countInterval(); // 根据起止时间计算时间间隔 countInterval(); // 根据起止时间计算时间间隔
} }
}, [startTime, endTime]); }, [startTime, endTime]);
useEffect(() => { useEffect(() => {
if (startTime && endTime && end - start > 0) { if (
startTime &&
endTime &&
end - start > 0 &&
startMonth === endMonth &&
startYear === endYear
) {
setLoading(true); setLoading(true);
getData('/TrafficStatistics', setVisitedCount); // 访问量统计 getData('/TrafficStatistics', setVisitedCount); // 访问量统计
} }
}, [startTime, endTime, logType, timeInterval]); }, [startTime, endTime, logType, timeInterval]);
useEffect(() => { useEffect(() => {
if (startTime && endTime && end - start > 0) { if (
startTime &&
endTime &&
end - start > 0 &&
startMonth === endMonth &&
startYear === endYear
) {
setLoading(true); setLoading(true);
getData('/TopCountList', setPathCount); // 接口调用频次统计 getData('/TopCountList', setPathCount); // 接口调用频次统计
getData('/TopConsumeList', setReponseTime); // 接口平均耗时统计 getData('/TopConsumeList', setReponseTime); // 接口平均耗时统计
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment