Commit d158dda8 by Leo Zheng

started implementing map 2

parent 267fd9a5
import {gateStatusStrategy} from "../biz/strategies/left/gateStatusStrategy";
import {guchengLoadStrategy} from "../biz/strategies/left/guchengLoadStrategy";
import {gateStatusStrategy} from "../biz/map1/strategies/left/gateStatusStrategy";
import {guchengLoadStrategy} from "../biz/map1/strategies/left/guchengLoadStrategy";
import {DataExtractor} from "../util/dataExtractor";
import {sightVisitorFlowByDayStrategy} from "../biz/strategies/left/sightVisitorFlowByDayStrategy";
import {sightVisitorFlowByHourStrategy} from "../biz/strategies/left/sightVisitorFlowPerHourStrategy";
import {totalVisitorFlowByHourStrategy} from "../biz/strategies/left/totalVisitorFlowByHourStrategy";
import {totalVisitorFlowStrategy} from "../biz/strategies/left/totalVisitorFlowStrategy";
import {sightVisitorFlowByDayStrategy} from "../biz/map1/strategies/left/sightVisitorFlowByDayStrategy";
import {sightVisitorFlowByHourStrategy} from "../biz/map1/strategies/left/sightVisitorFlowPerHourStrategy";
import {totalVisitorFlowByHourStrategy} from "../biz/map1/strategies/left/totalVisitorFlowByHourStrategy";
import {totalVisitorFlowStrategy} from "../biz/map1/strategies/left/totalVisitorFlowStrategy";
import {testDateError, testSightError, testStrategy} from "./utils";
describe('gateStatusTest', () => {
......
import {currentEventStrategy} from "../biz/strategies/middle/currentEventStrategy";
import {currentEventStrategy} from "../biz/map1/strategies/middle/currentEventStrategy";
import {testDateError, testStrategy} from "./utils";
import {allEventDataStrategy} from "../biz/strategies/middle/eventDataStrategy";
import {totalEventCountStrategy} from "../biz/strategies/middle/totalEventCountStrategy";
import {allEventDataStrategy} from "../biz/map1/strategies/middle/eventDataStrategy";
import {totalEventCountStrategy} from "../biz/map1/strategies/middle/totalEventCountStrategy";
describe('currentEvent test', function () {
const strategy = new currentEventStrategy();
......
import {eventCategoryCountStrategy} from "../biz/strategies/right/eventCategoryCountStrategy";
import {eventCategoryCountStrategy} from "../biz/map1/strategies/right/eventCategoryCountStrategy";
import {testStrategy, testYearError} from "./utils";
import {eventMonthDistributionStrategy} from "../biz/strategies/right/eventMonthDistributionStrategy";
import {eventProcessingTimeStrategy} from "../biz/strategies/right/eventProcessingTimeStrategy";
import {eventSrcStrategy} from "../biz/strategies/right/eventSrcStrategy";
import {eventSubCategoryCountStrategy} from "../biz/strategies/right/eventSubCategoryCountStrategy";
import {eventTimeDistributionStrategy} from "../biz/strategies/right/eventTimeDistributionStrategy";
import {getEventCountByYearStrategy} from "../biz/strategies/right/getEventCountByYearStrategy";
import {gridEventCountStrategy} from "../biz/strategies/right/gridEventCountStrategy";
import {eventMonthDistributionStrategy} from "../biz/map1/strategies/right/eventMonthDistributionStrategy";
import {eventProcessingTimeStrategy} from "../biz/map1/strategies/right/eventProcessingTimeStrategy";
import {eventSrcStrategy} from "../biz/map1/strategies/right/eventSrcStrategy";
import {eventSubCategoryCountStrategy} from "../biz/map1/strategies/right/eventSubCategoryCountStrategy";
import {eventTimeDistributionStrategy} from "../biz/map1/strategies/right/eventTimeDistributionStrategy";
import {getEventCountByYearStrategy} from "../biz/map1/strategies/right/getEventCountByYearStrategy";
import {gridEventCountStrategy} from "../biz/map1/strategies/right/gridEventCountStrategy";
const mockParams = {
query: {
......
......@@ -4,7 +4,7 @@
*/
// 导入 strategyFactory,以便根据请求内容创建适当的策略。
import { strategyFactory } from "./strategies/strategyFactory";
import { strategyFactory } from "./strategyFactory";
/**
* Handles the main data retrieval request.
......
......@@ -3,8 +3,8 @@
* 该文件定义了一个抽象类,用于左侧数据策略的基础实现。
*/
import { dataStrategy } from "../dataStrategy";
import { DataExtractor } from "../../../util/dataExtractor";
import { dataStrategy } from "../../../dataStrategy";
import { DataExtractor } from "../../../../util/dataExtractor";
/**
* 抽象数据策略左侧类,所有具体策略类都需要继承该抽象类。
......
......@@ -3,9 +3,10 @@
* 该文件定义了门状态策略的具体实现。
*/
import { randomStatusGenerator } from "../../../util/randomStatusGenerator";
import mapToObj from "../../../util/mapToObj";
import { randomStatusGenerator } from "../../../../util/randomStatusGenerator";
import mapToObj from "../../../../util/mapToObj";
import { abstractDataStrategyLeft } from "./abstractDataStrategyLeft";
import paramChecker from "../../../../util/paramChecker";
/**
* 门状态策略类,继承自 abstractDataStrategyLeft。
......@@ -27,9 +28,7 @@ export class gateStatusStrategy extends abstractDataStrategyLeft {
* @returns 门状态的对象表示。
*/
execute(params?: any): any {
if (!params || !params.query || !params.query.date) {
throw new Error("Date parameter is required.")
}
paramChecker.checkDateParam(params);
this.gateStatusMap.forEach((value, key, map) => {
map.set(key, randomStatusGenerator.getRandomStatus());
});
......
......@@ -4,6 +4,7 @@
*/
import { abstractDataStrategyLeft } from "./abstractDataStrategyLeft";
import paramChecker from "../../../../util/paramChecker";
/**
* 古城负载策略类,继承自 abstractDataStrategyLeft。
......@@ -14,9 +15,7 @@ export class guchengLoadStrategy extends abstractDataStrategyLeft {
* @returns 随机的负载状态。
*/
execute(params?: any): any {
if (!params || !params.query || !params.query.date) {
throw new Error("Date parameter is required.")
}
paramChecker.checkDateParam(params);
return "正常";
}
}
......@@ -3,9 +3,10 @@
* 该文件定义了按天计算的游客流量策略的具体实现。
*/
import { randomStatusGenerator } from "../../../util/randomStatusGenerator";
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import { randomStatusGenerator } from "../../../../util/randomStatusGenerator";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import { abstractDataStrategyLeft } from "./abstractDataStrategyLeft";
import paramChecker from "../../../../util/paramChecker";
/**
* 按天计算的游客流量策略类,继承自 abstractDataStrategyLeft。
......@@ -17,9 +18,7 @@ export class sightVisitorFlowByDayStrategy extends abstractDataStrategyLeft {
* @returns 每小时的游客流量。
*/
execute(params?: any): any {
if (!params || !params.query || !params.query.date) {
throw new Error("Date parameter is required.");
}
paramChecker.checkDateParam(params);
let sightData = this.extractor.getData(sightVisitorFlowByDayStrategy.FILENAME, sightVisitorFlowByDayStrategy.SHEETNAME);
return this.getVisitorFlowByDay(sightData, params.query.date);
}
......
......@@ -3,9 +3,10 @@
* 该文件定义了每小时计算的游客流量策略的具体实现,获取制定景点在指定日期的每小时游客流量。
*/
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import mapToObj from "../../../util/mapToObj";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import mapToObj from "../../../../util/mapToObj";
import {abstractDataStrategyLeft} from "./abstractDataStrategyLeft";
import paramChecker from "../../../../util/paramChecker";
/**
* 每小时计算的游客流量策略类,继承自 abstractDataStrategyLeft。
......@@ -18,9 +19,7 @@ export class sightVisitorFlowByHourStrategy extends abstractDataStrategyLeft {
* @returns 指定景点指定日期的每小时的游客流量。
*/
execute(params?: any): any {
if (!params || !params.query || !params.query.date || !params.query.sight) {
throw new Error('Date and sight parameters are required.');
}
paramChecker.checkDateAndSightParam(params);
const sightData = this.extractor.getData(sightVisitorFlowByHourStrategy.FILENAME, sightVisitorFlowByHourStrategy.SHEETNAME);
return mapToObj(this.getVisitorFlowByHour(sightData, params.query.sight, params.query.date));
}
......
......@@ -3,8 +3,9 @@
* 该文件定义了按小时计算的总游客流量策略的具体实现,获取指定日期整个景区的各类人群客流量分布。
*/
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import { abstractDataStrategyLeft } from "./abstractDataStrategyLeft";
import paramChecker from "../../../../util/paramChecker";
/**
* 按小时计算的总游客流量策略类,继承自 abstractDataStrategyLeft。
......@@ -17,9 +18,7 @@ export class totalVisitorFlowByHourStrategy extends abstractDataStrategyLeft {
* @returns 全景区各类每小时各类游客流量。
*/
execute(params?: any): any {
if (!params || !params.query || !params.query.date) {
throw new Error('Date parameter is required.');
}
paramChecker.checkDateParam(params);
const sightData = this.extractor.getData(totalVisitorFlowByHourStrategy.FILENAME, totalVisitorFlowByHourStrategy.SHEETNAME);
return this.getTotalVisitorFlowByHour(sightData, params.query.date);
}
......
......@@ -3,8 +3,9 @@
* 该文件定义了总游客流量策略的具体实现。
*/
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import { abstractDataStrategyLeft } from "./abstractDataStrategyLeft";
import paramChecker from "../../../../util/paramChecker";
/**
* 总游客流量策略类,继承自 abstractDataStrategyLeft。
......@@ -17,9 +18,7 @@ export class totalVisitorFlowStrategy extends abstractDataStrategyLeft {
* @returns 每小时的全景区各类游客流量。
*/
execute(params?: any): any {
if (!params || !params.query || !params.query.date) {
throw new Error("Date parameter is required.");
}
paramChecker.checkDateParam(params);
let sightData = this.extractor.getData(totalVisitorFlowStrategy.FILENAME, totalVisitorFlowStrategy.SHEETNAME);
return this.getTotalVisitorByDay(sightData, params.query.date);
}
......
......@@ -3,8 +3,8 @@
* 该文件定义了一个抽象类,用于中间数据策略的基础实现。
*/
import {dataStrategy} from "../dataStrategy";
import {DataExtractor} from "../../../util/dataExtractor";
import {dataStrategy} from "../../../dataStrategy";
import {DataExtractor} from "../../../../util/dataExtractor";
/**
* 抽象数据策略中间层类,所有具体策略类都需要继承该抽象类。
......
......@@ -4,7 +4,7 @@
*/
import { abstractDataStrategyMid } from "./abstractDataStrategyMid";
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
/**
* 事件数据策略类,继承自 abstractDataStrategyMid。
......
......@@ -4,7 +4,7 @@
*/
import {abstractDataStrategyMid} from "./abstractDataStrategyMid";
import mapToObj from "../../../util/mapToObj";
import mapToObj from "../../../../util/mapToObj";
/**
* 总事件计数策略类,继承自 abstractDataStrategyMid。
......
......@@ -3,10 +3,11 @@
* 该文件定义了一个抽象类,用于右侧数据策略的基础实现。
*/
import { dataStrategy } from "../dataStrategy";
import { DataExtractor } from "../../../util/dataExtractor";
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import { dataStrategy } from "../../../dataStrategy";
import { DataExtractor } from "../../../../util/dataExtractor";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import moment = require("moment");
import paramChecker from "../../../../util/paramChecker";
/**
* 抽象数据策略右侧类,所有右侧具体策略类都需要继承该抽象类。
......@@ -37,12 +38,7 @@ export abstract class abstractDataStrategyRight implements dataStrategy {
* @throws 如果参数无效则抛出错误。
*/
protected paramsCheck(params) {
if (!params || !params.query || !params.query.year) {
throw new Error('Year parameter is required.');
}
if (params.query.year !== 'thisyear' && params.query.year !== 'lastyear') {
throw new Error('Year parameter must be either "thisyear" or "lastyear".');
}
paramChecker.checkDiscreteParam(params, 'year', 'thisyear', 'lastyear');
}
/**
......
......@@ -4,7 +4,7 @@
*/
import {abstractDataStrategyRight} from "./abstractDataStrategyRight";
import mapToObj from "../../../util/mapToObj";
import mapToObj from "../../../../util/mapToObj";
/**
* 事件类别计数策略类,继承自 abstractDataStrategyRight。
......
......@@ -4,8 +4,8 @@
*/
import { abstractDataStrategyRight } from "./abstractDataStrategyRight";
import mapToObj from "../../../util/mapToObj";
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import mapToObj from "../../../../util/mapToObj";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
/**
* 事件按月分布策略类,继承自 abstractDataStrategyRight。
......
......@@ -4,8 +4,8 @@
*/
import { abstractDataStrategyRight } from "./abstractDataStrategyRight";
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import getRandomNumber from "../../../util/randomNumberGenerator";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import getRandomNumber from "../../../../util/randomNumberGenerator";
/**
* 事件处理时间策略类,继承自 abstractDataStrategyRight。
......
......@@ -4,7 +4,7 @@
*/
import {abstractDataStrategyRight} from "./abstractDataStrategyRight";
import mapToObj from "../../../util/mapToObj";
import mapToObj from "../../../../util/mapToObj";
/**
* 事件来源策略类,继承自 abstractDataStrategyRight。
......
......@@ -4,7 +4,7 @@
*/
import {abstractDataStrategyRight} from "./abstractDataStrategyRight";
import mapToObj from "../../../util/mapToObj";
import mapToObj from "../../../../util/mapToObj";
/**
* 事件子类别计数策略类,继承自 abstractDataStrategyRight。
......
......@@ -4,8 +4,8 @@
*/
import { abstractDataStrategyRight } from "./abstractDataStrategyRight";
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import mapToObj from "../../../util/mapToObj";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import mapToObj from "../../../../util/mapToObj";
/**
* 事件时间分布策略类,继承自 abstractDataStrategyRight。
......
......@@ -4,7 +4,7 @@
*/
import { abstractDataStrategyRight } from "./abstractDataStrategyRight";
import excelSerialToJSDate from "../../../util/excelDateToJSDate";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import moment = require("moment");
/**
......
......@@ -4,7 +4,7 @@
*/
import {abstractDataStrategyRight} from "./abstractDataStrategyRight";
import mapToObj from "../../../util/mapToObj";
import mapToObj from "../../../../util/mapToObj";
/**
* 按网格统计事件数量策略类,继承自 abstractDataStrategyRight。
......
/**
* abstractDataStrategyLeft.ts
* 该文件定义了一个抽象类,用于左侧数据策略的基础实现。
*/
import { dataStrategy } from "../../../dataStrategy";
import { DataExtractor } from "../../../../util/dataExtractor";
/**
* 抽象数据策略左侧类,所有具体策略类都需要继承该抽象类。
*/
export abstract class abstractDataStrategyLeft implements dataStrategy {
// 实例化数据提取器
extractor = DataExtractor.getInstance();
static readonly FILENAME = '票务系统.xlsx';
static readonly SHEETNAME = '票务系统-订单主表';
/**
* 执行策略的方法,具体实现由子类提供。
* @param params - 可选参数。
*/
abstract execute(params?: any): any;
abstract processData(...param): any;
}
import paramChecker from "../../../../util/paramChecker";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
import {abstractDataStrategyLeft} from "./abstractDataStrategyLeft";
export default class monthlyVisitorCountStrategy extends abstractDataStrategyLeft {
execute(params?: any): any {
paramChecker.checkDiscreteParam(params, 'timeFrame', '12month', '3year');
let data = this.extractor.getData(monthlyVisitorCountStrategy.FILENAME, monthlyVisitorCountStrategy.SHEETNAME);
return this.processData(data, params.query['timeFrame']);
}
processData(data: any, timeFrame: string) {
const currentDate = new Date();
let startDate = new Date();
if (timeFrame === '12month') {
startDate.setFullYear(currentDate.getFullYear() - 1);
} else if (timeFrame === '3year') {
startDate.setFullYear(currentDate.getFullYear() - 3);
}
const eventCount: Map<string, number> = new Map();
let tempDate = new Date(startDate);
while (tempDate <= currentDate) {
const formattedMonth = `${tempDate.getFullYear().toString().slice(2)}/${(tempDate.getMonth() + 1).toString().padStart(2, '0')}`;
eventCount.set(formattedMonth, 0);
tempDate.setMonth(tempDate.getMonth() + 1);
}
data.forEach(row => {
const rowDate = excelSerialToJSDate(row['游玩时间']);
const rowYear = rowDate.getFullYear();
const rowMonth = rowDate.getMonth() + 1;
const formattedMonth = `${rowYear.toString().slice(2)}/${rowMonth.toString().padStart(2, '0')}`;
if (rowDate >= startDate && rowDate <= currentDate) {
eventCount.set(formattedMonth, (eventCount.get(formattedMonth) || 0) + 1);
}
});
const result = [];
for (let [key, value] of eventCount.entries()) {
if (value === 0) {
value = Math.floor(Math.random() * 3000) + 1;
}
result.push({
key: key,
value: value.toString()
});
}
return result;
}
}
import {abstractDataStrategyLeft} from "./abstractDataStrategyLeft";
import paramChecker from "../../../../util/paramChecker";
import excelSerialToJSDate from "../../../../util/excelDateToJSDate";
export default class sightVisitorRankStrategy extends abstractDataStrategyLeft {
static readonly FILENAME = '票务系统.xlsx';
static readonly SHEETNAME = '票务系统-订单主表';
execute(params?: any): any {
paramChecker.checkDiscreteParam(params, 'timeFrame', '12month', '3year');
const data = this.extractor.getData(sightVisitorRankStrategy.FILENAME, sightVisitorRankStrategy.SHEETNAME);
return this.processData(data, params.query['timeFrame']);
}
processData(data: any, timeFrame: string): any {
const currentDate = new Date();
let startDate = new Date();
if (timeFrame === '12month') {
startDate.setFullYear(currentDate.getFullYear() - 1);
} else if (timeFrame === '3year') {
startDate.setFullYear(currentDate.getFullYear() - 3);
}
const sightCounts: { [key: string]: number } = {};
data.forEach(row => {
const rowDate = excelSerialToJSDate(row['游玩时间']);
if (rowDate >= startDate && rowDate <= currentDate) {
const sightName = row['景点名称'];
if (!sightCounts[sightName]) {
sightCounts[sightName] = 0;
}
sightCounts[sightName] += 1;
}
});
const sortedSights = Object.entries(sightCounts)
.sort(([, a], [, b]) => b - a)
.map(([key, value]) => ({ key, value: value.toString() }));
return sortedSights;
}
}
......@@ -3,28 +3,30 @@
* 该文件定义了策略工厂类,用于创建各种数据策略。
*/
import { dataStrategy } from "../../dataStrategy";
import { dataStrategy } from "./dataStrategy";
// 导入具体策略类
import { sightVisitorFlowByDayStrategy } from "./left/sightVisitorFlowByDayStrategy";
import { gateStatusStrategy } from "./left/gateStatusStrategy";
import { sightVisitorFlowByHourStrategy } from "./left/sightVisitorFlowPerHourStrategy";
import { guchengLoadStrategy } from "./left/guchengLoadStrategy";
import { totalVisitorFlowStrategy } from "./left/totalVisitorFlowStrategy";
import { totalVisitorFlowByHourStrategy } from "./left/totalVisitorFlowByHourStrategy";
import { sightVisitorFlowByDayStrategy } from "./map1/strategies/left/sightVisitorFlowByDayStrategy";
import { gateStatusStrategy } from "./map1/strategies/left/gateStatusStrategy";
import { sightVisitorFlowByHourStrategy } from "./map1/strategies/left/sightVisitorFlowPerHourStrategy";
import { guchengLoadStrategy } from "./map1/strategies/left/guchengLoadStrategy";
import { totalVisitorFlowStrategy } from "./map1/strategies/left/totalVisitorFlowStrategy";
import { totalVisitorFlowByHourStrategy } from "./map1/strategies/left/totalVisitorFlowByHourStrategy";
import { currentEventStrategy } from "./middle/currentEventStrategy";
import { totalEventCountStrategy } from "./middle/totalEventCountStrategy";
import { currentEventStrategy } from "./map1/strategies/middle/currentEventStrategy";
import { totalEventCountStrategy } from "./map1/strategies/middle/totalEventCountStrategy";
import { getEventCountByYearStrategy } from "./right/getEventCountByYearStrategy";
import { eventTimeDistributionStrategy } from "./right/eventTimeDistributionStrategy";
import { eventMonthDistributionStrategy } from "./right/eventMonthDistributionStrategy";
import { eventCategoryCountStrategy } from "./right/eventCategoryCountStrategy";
import { eventSubCategoryCountStrategy } from "./right/eventSubCategoryCountStrategy";
import { eventSrcStrategy } from "./right/eventSrcStrategy";
import { gridEventCountStrategy } from "./right/gridEventCountStrategy";
import { eventProcessingTimeStrategy } from "./right/eventProcessingTimeStrategy";
import {allEventDataStrategy} from "./middle/eventDataStrategy";
import { getEventCountByYearStrategy } from "./map1/strategies/right/getEventCountByYearStrategy";
import { eventTimeDistributionStrategy } from "./map1/strategies/right/eventTimeDistributionStrategy";
import { eventMonthDistributionStrategy } from "./map1/strategies/right/eventMonthDistributionStrategy";
import { eventCategoryCountStrategy } from "./map1/strategies/right/eventCategoryCountStrategy";
import { eventSubCategoryCountStrategy } from "./map1/strategies/right/eventSubCategoryCountStrategy";
import { eventSrcStrategy } from "./map1/strategies/right/eventSrcStrategy";
import { gridEventCountStrategy } from "./map1/strategies/right/gridEventCountStrategy";
import { eventProcessingTimeStrategy } from "./map1/strategies/right/eventProcessingTimeStrategy";
import {allEventDataStrategy} from "./map1/strategies/middle/eventDataStrategy";
import monthlyVisitorCountStrategy from "./map2/strategies/left/monthlyVisitorCountStrategy";
import sightVisitorRankStrategy from "./map2/strategies/left/sightVisitorRankStrategy";
/**
* 策略工厂类,用于创建和管理各种数据策略。
......@@ -34,6 +36,7 @@ export class strategyFactory {
* 存储策略类型与其对应类的映射。
*/
private static strategies: { [key: string]: new () => dataStrategy } = {
// map 1
'allEvents': allEventDataStrategy,
'sightVisitorFlowByDay': sightVisitorFlowByDayStrategy,
'gateStatus': gateStatusStrategy,
......@@ -51,6 +54,10 @@ export class strategyFactory {
'getEventSourceCount': eventSrcStrategy,
'getGridEventCount': gridEventCountStrategy,
'getEventProcessingTime': eventProcessingTimeStrategy,
// map2
'monthlyVisitor': monthlyVisitorCountStrategy,
'sightVisitorRank': sightVisitorRankStrategy
};
/**
......
import * as asyncHandler from 'express-async-handler';
import * as szgcBiz from '../../biz/getData';
export function setLeftRoutes(httpServer) {
export function setMap1LeftRoutes(httpServer) {
httpServer.get('/szgc/getdata/sightVisitorFlowByDay', asyncHandler((req, res) => szgcBiz.getData(req, res, 'sightVisitorFlowByDay')));
httpServer.get('/szgc/getdata/gateStatus', asyncHandler((req, res) => szgcBiz.getData(req, res, 'gateStatus')));
httpServer.get('/szgc/getdata/sightVisitorFlowPerHour', asyncHandler((req, res) => szgcBiz.getData(req, res, 'sightVisitorFlowPerHour')));
......
import * as asyncHandler from 'express-async-handler';
import * as szgcBiz from '../biz/getData';
import * as szgcBiz from '../../biz/getData';
export function setMiddleRoutes(httpServer) {
export function setMap1MiddleRoutes(httpServer) {
httpServer.get('/szgc/getdata/getCurrentEventCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getCurrentEventCount')));
httpServer.get('/szgc/getdata/totalEventCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'totalEventCount')));
httpServer.get('/szgc/getdata/allEvents', asyncHandler((req, res) => szgcBiz.getData(req, res, 'allEvents')));
......
import * as asyncHandler from 'express-async-handler';
import * as szgcBiz from '../biz/getData';
import * as szgcBiz from '../../biz/getData';
export function setRightRoutes(httpServer) {
export function setMap1RightRoutes(httpServer) {
httpServer.get('/szgc/getdata/getEventCountByYear', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventCountByYear')));
httpServer.get('/szgc/getdata/getEventTimeDistribution', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventTimeDistribution')));
httpServer.get('/szgc/getdata/getEventMonthDistribution', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventMonthDistribution')));
......
import * as asyncHandler from 'express-async-handler';
import * as szgcBiz from '../../biz/getData';
export function setLeftRoutes(httpServer) {
httpServer.get('/szgc/getdata/sightVisitorFlowByDay', asyncHandler((req, res) => szgcBiz.getData(req, res, 'sightVisitorFlowByDay')));
httpServer.get('/szgc/getdata/gateStatus', asyncHandler((req, res) => szgcBiz.getData(req, res, 'gateStatus')));
httpServer.get('/szgc/getdata/sightVisitorFlowPerHour', asyncHandler((req, res) => szgcBiz.getData(req, res, 'sightVisitorFlowPerHour')));
httpServer.get('/szgc/getdata/guchengLoad', asyncHandler((req, res) => szgcBiz.getData(req, res, 'guchengLoad')));
httpServer.get('/szgc/getdata/totalVisitorFlow', asyncHandler((req, res) => szgcBiz.getData(req, res, 'totalVisitorFlow')));
httpServer.get('/szgc/getdata/totalVisitorFlowByDay', asyncHandler((req, res) => szgcBiz.getData(req, res, 'totalVisitorFlowByHour')));
export function setMap2LeftRoutes(httpServer) {
httpServer.get('/szgc/getdata/monthlyVisitorCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'monthlyVisitor')));
httpServer.get('/szgc/getdate/sightVisitorRank', asyncHandler((req, res) => szgcBiz.getData(req, res, 'sightVisitorRank')));
}
\ No newline at end of file
import * as asyncHandler from 'express-async-handler';
import * as szgcBiz from '../../biz/getData';
export function setMiddleRoutes(httpServer) {
export function setMap2MiddleRoutes(httpServer) {
httpServer.get('/szgc/getdata/getCurrentEventCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getCurrentEventCount')));
httpServer.get('/szgc/getdata/totalEventCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'totalEventCount')));
httpServer.get('/szgc/getdata/allEvents', asyncHandler((req, res) => szgcBiz.getData(req, res, 'allEvents')));
}
import * as asyncHandler from 'express-async-handler';
import * as szgcBiz from '../../biz/getData';
export function setRightRoutes(httpServer) {
export function setMap2RightRoutes(httpServer) {
httpServer.get('/szgc/getdata/getEventCountByYear', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventCountByYear')));
httpServer.get('/szgc/getdata/getEventTimeDistribution', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventTimeDistribution')));
httpServer.get('/szgc/getdata/getEventMonthDistribution', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventMonthDistribution')));
httpServer.get('/szgc/getdata/getEventCategoryCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventCategoryCount')));
httpServer.get('/szgc/getdata/getEventSubCategoryCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventSubCategoryCount')));
httpServer.get('/szgc/getdata/getEventSourceCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventSourceCount')));
httpServer.get('/szgc/getdata/getGridEventCount', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getGridEventCount')));
httpServer.get('/szgc/getdata/getEventProcessingTime', asyncHandler((req, res) => szgcBiz.getData(req, res, 'getEventProcessingTime')));
}
import { setLeftRoutes } from './routerLeft';
import { setMiddleRoutes } from './routerMid';
import { setRightRoutes } from './routerRight';
import { setMap1LeftRoutes } from './map1/routerLeft';
import { setMap1MiddleRoutes } from './map1/routerMid';
import { setMap1RightRoutes } from './map1/routerRight';
import { setMap2LeftRoutes } from './map2/routerLeft';
import {setMap2MiddleRoutes} from "./map2/routerMid";
import {setMap2RightRoutes} from "./map2/routerRight";
import * as szgcBiz from '../biz/getData';
import * as asyncHandler from 'express-async-handler';
export function setRouter(httpServer) {
setLeftRoutes(httpServer);
setMiddleRoutes(httpServer);
setRightRoutes(httpServer);
setMap1LeftRoutes(httpServer);
setMap1MiddleRoutes(httpServer);
setMap1RightRoutes(httpServer);
setMap2LeftRoutes(httpServer);
setMap2MiddleRoutes(httpServer);
setMap2RightRoutes(httpServer);
httpServer.get('/test', szgcBiz.test);
}
export default class paramChecker {
static checkDateParam(params) {
if (!params || !params.query || !params.query.date) {
throw new Error("Date parameter is required.")
}
}
static checkDateAndSightParam(params) {
if (!params || !params.query || !params.query.date || !params.query.sight) {
throw new Error('Date and sight parameters are required.');
}
}
static checkDiscreteParam(params, paramName, ...allowedValues) {
if (!params || !params.query || !params.query[paramName]) {
throw new Error(`${paramName} parameter is required.`);
}
if (!allowedValues.includes(params.query[paramName])) {
throw new Error(`${paramName} parameter must be one of ${allowedValues.join(", ")}.`);
}
}
}
\ No newline at end of file
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