Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shouzhouServer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjinjing
shouzhouServer
Commits
d158dda8
Commit
d158dda8
authored
Jul 22, 2024
by
Leo Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started implementing map 2
parent
267fd9a5
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
256 additions
and
118 deletions
+256
-118
leftStrategies.test.ts
src/__test__/leftStrategies.test.ts
+6
-6
midStrategies.test.ts
src/__test__/midStrategies.test.ts
+3
-3
rightStrategies.test.ts
src/__test__/rightStrategies.test.ts
+8
-8
getData.ts
src/biz/getData.ts
+1
-1
abstractDataStrategyLeft.ts
src/biz/map1/strategies/left/abstractDataStrategyLeft.ts
+2
-2
gateStatusStrategy.ts
src/biz/map1/strategies/left/gateStatusStrategy.ts
+4
-5
guchengLoadStrategy.ts
src/biz/map1/strategies/left/guchengLoadStrategy.ts
+2
-3
sightVisitorFlowByDayStrategy.ts
...biz/map1/strategies/left/sightVisitorFlowByDayStrategy.ts
+4
-5
sightVisitorFlowPerHourStrategy.ts
...z/map1/strategies/left/sightVisitorFlowPerHourStrategy.ts
+4
-5
totalVisitorFlowByHourStrategy.ts
...iz/map1/strategies/left/totalVisitorFlowByHourStrategy.ts
+3
-4
totalVisitorFlowStrategy.ts
src/biz/map1/strategies/left/totalVisitorFlowStrategy.ts
+3
-4
abstractDataStrategyMid.ts
src/biz/map1/strategies/middle/abstractDataStrategyMid.ts
+2
-2
eventDataStrategy.ts
src/biz/map1/strategies/middle/eventDataStrategy.ts
+1
-1
totalEventCountStrategy.ts
src/biz/map1/strategies/middle/totalEventCountStrategy.ts
+1
-1
abstractDataStrategyRight.ts
src/biz/map1/strategies/right/abstractDataStrategyRight.ts
+5
-9
eventCategoryCountStrategy.ts
src/biz/map1/strategies/right/eventCategoryCountStrategy.ts
+1
-1
eventMonthDistributionStrategy.ts
...z/map1/strategies/right/eventMonthDistributionStrategy.ts
+2
-2
eventProcessingTimeStrategy.ts
src/biz/map1/strategies/right/eventProcessingTimeStrategy.ts
+2
-2
eventSrcStrategy.ts
src/biz/map1/strategies/right/eventSrcStrategy.ts
+1
-1
eventSubCategoryCountStrategy.ts
...iz/map1/strategies/right/eventSubCategoryCountStrategy.ts
+1
-1
eventTimeDistributionStrategy.ts
...iz/map1/strategies/right/eventTimeDistributionStrategy.ts
+2
-2
getEventCountByYearStrategy.ts
src/biz/map1/strategies/right/getEventCountByYearStrategy.ts
+1
-1
gridEventCountStrategy.ts
src/biz/map1/strategies/right/gridEventCountStrategy.ts
+1
-1
abstractDataStrategyLeft.ts
src/biz/map2/strategies/left/abstractDataStrategyLeft.ts
+24
-0
monthlyVisitorCountStrategy.ts
src/biz/map2/strategies/left/monthlyVisitorCountStrategy.ts
+53
-0
sightVisitorRankStrategy.ts
src/biz/map2/strategies/left/sightVisitorRankStrategy.ts
+43
-0
strategyFactory.ts
src/biz/strategyFactory.ts
+25
-18
routerLeft.ts
src/routers/map1/routerLeft.ts
+1
-1
routerMid.ts
src/routers/map1/routerMid.ts
+2
-2
routerRight.ts
src/routers/map1/routerRight.ts
+2
-2
routerLeft.ts
src/routers/map2/routerLeft.ts
+5
-7
routerMid.ts
src/routers/map2/routerMid.ts
+3
-3
routerRight.ts
src/routers/map2/routerRight.ts
+2
-8
router.ts
src/routers/router.ts
+12
-7
paramChecker.ts
src/util/paramChecker.ts
+24
-0
No files found.
src/__test__/leftStrategies.test.ts
View file @
d158dda8
import
{
gateStatusStrategy
}
from
"../biz/strategies/left/gateStatusStrategy"
;
import
{
gateStatusStrategy
}
from
"../biz/
map1/
strategies/left/gateStatusStrategy"
;
import
{
guchengLoadStrategy
}
from
"../biz/strategies/left/guchengLoadStrategy"
;
import
{
guchengLoadStrategy
}
from
"../biz/
map1/
strategies/left/guchengLoadStrategy"
;
import
{
DataExtractor
}
from
"../util/dataExtractor"
;
import
{
DataExtractor
}
from
"../util/dataExtractor"
;
import
{
sightVisitorFlowByDayStrategy
}
from
"../biz/strategies/left/sightVisitorFlowByDayStrategy"
;
import
{
sightVisitorFlowByDayStrategy
}
from
"../biz/
map1/
strategies/left/sightVisitorFlowByDayStrategy"
;
import
{
sightVisitorFlowByHourStrategy
}
from
"../biz/strategies/left/sightVisitorFlowPerHourStrategy"
;
import
{
sightVisitorFlowByHourStrategy
}
from
"../biz/
map1/
strategies/left/sightVisitorFlowPerHourStrategy"
;
import
{
totalVisitorFlowByHourStrategy
}
from
"../biz/strategies/left/totalVisitorFlowByHourStrategy"
;
import
{
totalVisitorFlowByHourStrategy
}
from
"../biz/
map1/
strategies/left/totalVisitorFlowByHourStrategy"
;
import
{
totalVisitorFlowStrategy
}
from
"../biz/strategies/left/totalVisitorFlowStrategy"
;
import
{
totalVisitorFlowStrategy
}
from
"../biz/
map1/
strategies/left/totalVisitorFlowStrategy"
;
import
{
testDateError
,
testSightError
,
testStrategy
}
from
"./utils"
;
import
{
testDateError
,
testSightError
,
testStrategy
}
from
"./utils"
;
describe
(
'gateStatusTest'
,
()
=>
{
describe
(
'gateStatusTest'
,
()
=>
{
...
...
src/__test__/midStrategies.test.ts
View file @
d158dda8
import
{
currentEventStrategy
}
from
"../biz/strategies/middle/currentEventStrategy"
;
import
{
currentEventStrategy
}
from
"../biz/
map1/
strategies/middle/currentEventStrategy"
;
import
{
testDateError
,
testStrategy
}
from
"./utils"
;
import
{
testDateError
,
testStrategy
}
from
"./utils"
;
import
{
allEventDataStrategy
}
from
"../biz/strategies/middle/eventDataStrategy"
;
import
{
allEventDataStrategy
}
from
"../biz/
map1/
strategies/middle/eventDataStrategy"
;
import
{
totalEventCountStrategy
}
from
"../biz/strategies/middle/totalEventCountStrategy"
;
import
{
totalEventCountStrategy
}
from
"../biz/
map1/
strategies/middle/totalEventCountStrategy"
;
describe
(
'currentEvent test'
,
function
()
{
describe
(
'currentEvent test'
,
function
()
{
const
strategy
=
new
currentEventStrategy
();
const
strategy
=
new
currentEventStrategy
();
...
...
src/__test__/rightStrategies.test.ts
View file @
d158dda8
import
{
eventCategoryCountStrategy
}
from
"../biz/strategies/right/eventCategoryCountStrategy"
;
import
{
eventCategoryCountStrategy
}
from
"../biz/
map1/
strategies/right/eventCategoryCountStrategy"
;
import
{
testStrategy
,
testYearError
}
from
"./utils"
;
import
{
testStrategy
,
testYearError
}
from
"./utils"
;
import
{
eventMonthDistributionStrategy
}
from
"../biz/strategies/right/eventMonthDistributionStrategy"
;
import
{
eventMonthDistributionStrategy
}
from
"../biz/
map1/
strategies/right/eventMonthDistributionStrategy"
;
import
{
eventProcessingTimeStrategy
}
from
"../biz/strategies/right/eventProcessingTimeStrategy"
;
import
{
eventProcessingTimeStrategy
}
from
"../biz/
map1/
strategies/right/eventProcessingTimeStrategy"
;
import
{
eventSrcStrategy
}
from
"../biz/strategies/right/eventSrcStrategy"
;
import
{
eventSrcStrategy
}
from
"../biz/
map1/
strategies/right/eventSrcStrategy"
;
import
{
eventSubCategoryCountStrategy
}
from
"../biz/strategies/right/eventSubCategoryCountStrategy"
;
import
{
eventSubCategoryCountStrategy
}
from
"../biz/
map1/
strategies/right/eventSubCategoryCountStrategy"
;
import
{
eventTimeDistributionStrategy
}
from
"../biz/strategies/right/eventTimeDistributionStrategy"
;
import
{
eventTimeDistributionStrategy
}
from
"../biz/
map1/
strategies/right/eventTimeDistributionStrategy"
;
import
{
getEventCountByYearStrategy
}
from
"../biz/strategies/right/getEventCountByYearStrategy"
;
import
{
getEventCountByYearStrategy
}
from
"../biz/
map1/
strategies/right/getEventCountByYearStrategy"
;
import
{
gridEventCountStrategy
}
from
"../biz/strategies/right/gridEventCountStrategy"
;
import
{
gridEventCountStrategy
}
from
"../biz/
map1/
strategies/right/gridEventCountStrategy"
;
const
mockParams
=
{
const
mockParams
=
{
query
:
{
query
:
{
...
...
src/biz/getData.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
// 导入 strategyFactory,以便根据请求内容创建适当的策略。
// 导入 strategyFactory,以便根据请求内容创建适当的策略。
import
{
strategyFactory
}
from
"./strateg
ies/strateg
yFactory"
;
import
{
strategyFactory
}
from
"./strategyFactory"
;
/**
/**
* Handles the main data retrieval request.
* Handles the main data retrieval request.
...
...
src/biz/map1/strategies/left/abstractDataStrategyLeft.ts
View file @
d158dda8
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
* 该文件定义了一个抽象类,用于左侧数据策略的基础实现。
* 该文件定义了一个抽象类,用于左侧数据策略的基础实现。
*/
*/
import
{
dataStrategy
}
from
"../dataStrategy"
;
import
{
dataStrategy
}
from
"../
../../
dataStrategy"
;
import
{
DataExtractor
}
from
"../../../util/dataExtractor"
;
import
{
DataExtractor
}
from
"../../../
../
util/dataExtractor"
;
/**
/**
* 抽象数据策略左侧类,所有具体策略类都需要继承该抽象类。
* 抽象数据策略左侧类,所有具体策略类都需要继承该抽象类。
...
...
src/biz/map1/strategies/left/gateStatusStrategy.ts
View file @
d158dda8
...
@@ -3,9 +3,10 @@
...
@@ -3,9 +3,10 @@
* 该文件定义了门状态策略的具体实现。
* 该文件定义了门状态策略的具体实现。
*/
*/
import
{
randomStatusGenerator
}
from
"../../../util/randomStatusGenerator"
;
import
{
randomStatusGenerator
}
from
"../../../
../
util/randomStatusGenerator"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
paramChecker
from
"../../../../util/paramChecker"
;
/**
/**
* 门状态策略类,继承自 abstractDataStrategyLeft。
* 门状态策略类,继承自 abstractDataStrategyLeft。
...
@@ -27,9 +28,7 @@ export class gateStatusStrategy extends abstractDataStrategyLeft {
...
@@ -27,9 +28,7 @@ export class gateStatusStrategy extends abstractDataStrategyLeft {
* @returns 门状态的对象表示。
* @returns 门状态的对象表示。
*/
*/
execute
(
params
?:
any
):
any
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
paramChecker
.
checkDateParam
(
params
);
throw
new
Error
(
"Date parameter is required."
)
}
this
.
gateStatusMap
.
forEach
((
value
,
key
,
map
)
=>
{
this
.
gateStatusMap
.
forEach
((
value
,
key
,
map
)
=>
{
map
.
set
(
key
,
randomStatusGenerator
.
getRandomStatus
());
map
.
set
(
key
,
randomStatusGenerator
.
getRandomStatus
());
});
});
...
...
src/biz/map1/strategies/left/guchengLoadStrategy.ts
View file @
d158dda8
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
*/
*/
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
paramChecker
from
"../../../../util/paramChecker"
;
/**
/**
* 古城负载策略类,继承自 abstractDataStrategyLeft。
* 古城负载策略类,继承自 abstractDataStrategyLeft。
...
@@ -14,9 +15,7 @@ export class guchengLoadStrategy extends abstractDataStrategyLeft {
...
@@ -14,9 +15,7 @@ export class guchengLoadStrategy extends abstractDataStrategyLeft {
* @returns 随机的负载状态。
* @returns 随机的负载状态。
*/
*/
execute
(
params
?:
any
):
any
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
paramChecker
.
checkDateParam
(
params
);
throw
new
Error
(
"Date parameter is required."
)
}
return
"正常"
;
return
"正常"
;
}
}
}
}
src/biz/map1/strategies/left/sightVisitorFlowByDayStrategy.ts
View file @
d158dda8
...
@@ -3,9 +3,10 @@
...
@@ -3,9 +3,10 @@
* 该文件定义了按天计算的游客流量策略的具体实现。
* 该文件定义了按天计算的游客流量策略的具体实现。
*/
*/
import
{
randomStatusGenerator
}
from
"../../../util/randomStatusGenerator"
;
import
{
randomStatusGenerator
}
from
"../../../
../
util/randomStatusGenerator"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
paramChecker
from
"../../../../util/paramChecker"
;
/**
/**
* 按天计算的游客流量策略类,继承自 abstractDataStrategyLeft。
* 按天计算的游客流量策略类,继承自 abstractDataStrategyLeft。
...
@@ -17,9 +18,7 @@ export class sightVisitorFlowByDayStrategy extends abstractDataStrategyLeft {
...
@@ -17,9 +18,7 @@ export class sightVisitorFlowByDayStrategy extends abstractDataStrategyLeft {
* @returns 每小时的游客流量。
* @returns 每小时的游客流量。
*/
*/
execute
(
params
?:
any
):
any
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
paramChecker
.
checkDateParam
(
params
);
throw
new
Error
(
"Date parameter is required."
);
}
let
sightData
=
this
.
extractor
.
getData
(
sightVisitorFlowByDayStrategy
.
FILENAME
,
sightVisitorFlowByDayStrategy
.
SHEETNAME
);
let
sightData
=
this
.
extractor
.
getData
(
sightVisitorFlowByDayStrategy
.
FILENAME
,
sightVisitorFlowByDayStrategy
.
SHEETNAME
);
return
this
.
getVisitorFlowByDay
(
sightData
,
params
.
query
.
date
);
return
this
.
getVisitorFlowByDay
(
sightData
,
params
.
query
.
date
);
}
}
...
...
src/biz/map1/strategies/left/sightVisitorFlowPerHourStrategy.ts
View file @
d158dda8
...
@@ -3,9 +3,10 @@
...
@@ -3,9 +3,10 @@
* 该文件定义了每小时计算的游客流量策略的具体实现,获取制定景点在指定日期的每小时游客流量。
* 该文件定义了每小时计算的游客流量策略的具体实现,获取制定景点在指定日期的每小时游客流量。
*/
*/
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
paramChecker
from
"../../../../util/paramChecker"
;
/**
/**
* 每小时计算的游客流量策略类,继承自 abstractDataStrategyLeft。
* 每小时计算的游客流量策略类,继承自 abstractDataStrategyLeft。
...
@@ -18,9 +19,7 @@ export class sightVisitorFlowByHourStrategy extends abstractDataStrategyLeft {
...
@@ -18,9 +19,7 @@ export class sightVisitorFlowByHourStrategy extends abstractDataStrategyLeft {
* @returns 指定景点指定日期的每小时的游客流量。
* @returns 指定景点指定日期的每小时的游客流量。
*/
*/
execute
(
params
?:
any
):
any
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
||
!
params
.
query
.
sight
)
{
paramChecker
.
checkDateAndSightParam
(
params
);
throw
new
Error
(
'Date and sight parameters are required.'
);
}
const
sightData
=
this
.
extractor
.
getData
(
sightVisitorFlowByHourStrategy
.
FILENAME
,
sightVisitorFlowByHourStrategy
.
SHEETNAME
);
const
sightData
=
this
.
extractor
.
getData
(
sightVisitorFlowByHourStrategy
.
FILENAME
,
sightVisitorFlowByHourStrategy
.
SHEETNAME
);
return
mapToObj
(
this
.
getVisitorFlowByHour
(
sightData
,
params
.
query
.
sight
,
params
.
query
.
date
));
return
mapToObj
(
this
.
getVisitorFlowByHour
(
sightData
,
params
.
query
.
sight
,
params
.
query
.
date
));
}
}
...
...
src/biz/map1/strategies/left/totalVisitorFlowByHourStrategy.ts
View file @
d158dda8
...
@@ -3,8 +3,9 @@
...
@@ -3,8 +3,9 @@
* 该文件定义了按小时计算的总游客流量策略的具体实现,获取指定日期整个景区的各类人群客流量分布。
* 该文件定义了按小时计算的总游客流量策略的具体实现,获取指定日期整个景区的各类人群客流量分布。
*/
*/
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
paramChecker
from
"../../../../util/paramChecker"
;
/**
/**
* 按小时计算的总游客流量策略类,继承自 abstractDataStrategyLeft。
* 按小时计算的总游客流量策略类,继承自 abstractDataStrategyLeft。
...
@@ -17,9 +18,7 @@ export class totalVisitorFlowByHourStrategy extends abstractDataStrategyLeft {
...
@@ -17,9 +18,7 @@ export class totalVisitorFlowByHourStrategy extends abstractDataStrategyLeft {
* @returns 全景区各类每小时各类游客流量。
* @returns 全景区各类每小时各类游客流量。
*/
*/
execute
(
params
?:
any
):
any
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
paramChecker
.
checkDateParam
(
params
);
throw
new
Error
(
'Date parameter is required.'
);
}
const
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowByHourStrategy
.
FILENAME
,
totalVisitorFlowByHourStrategy
.
SHEETNAME
);
const
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowByHourStrategy
.
FILENAME
,
totalVisitorFlowByHourStrategy
.
SHEETNAME
);
return
this
.
getTotalVisitorFlowByHour
(
sightData
,
params
.
query
.
date
);
return
this
.
getTotalVisitorFlowByHour
(
sightData
,
params
.
query
.
date
);
}
}
...
...
src/biz/map1/strategies/left/totalVisitorFlowStrategy.ts
View file @
d158dda8
...
@@ -3,8 +3,9 @@
...
@@ -3,8 +3,9 @@
* 该文件定义了总游客流量策略的具体实现。
* 该文件定义了总游客流量策略的具体实现。
*/
*/
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
paramChecker
from
"../../../../util/paramChecker"
;
/**
/**
* 总游客流量策略类,继承自 abstractDataStrategyLeft。
* 总游客流量策略类,继承自 abstractDataStrategyLeft。
...
@@ -17,9 +18,7 @@ export class totalVisitorFlowStrategy extends abstractDataStrategyLeft {
...
@@ -17,9 +18,7 @@ export class totalVisitorFlowStrategy extends abstractDataStrategyLeft {
* @returns 每小时的全景区各类游客流量。
* @returns 每小时的全景区各类游客流量。
*/
*/
execute
(
params
?:
any
):
any
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
paramChecker
.
checkDateParam
(
params
);
throw
new
Error
(
"Date parameter is required."
);
}
let
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowStrategy
.
FILENAME
,
totalVisitorFlowStrategy
.
SHEETNAME
);
let
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowStrategy
.
FILENAME
,
totalVisitorFlowStrategy
.
SHEETNAME
);
return
this
.
getTotalVisitorByDay
(
sightData
,
params
.
query
.
date
);
return
this
.
getTotalVisitorByDay
(
sightData
,
params
.
query
.
date
);
}
}
...
...
src/biz/map1/strategies/middle/abstractDataStrategyMid.ts
View file @
d158dda8
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
* 该文件定义了一个抽象类,用于中间数据策略的基础实现。
* 该文件定义了一个抽象类,用于中间数据策略的基础实现。
*/
*/
import
{
dataStrategy
}
from
"../dataStrategy"
;
import
{
dataStrategy
}
from
"../
../../
dataStrategy"
;
import
{
DataExtractor
}
from
"../../../util/dataExtractor"
;
import
{
DataExtractor
}
from
"../../../
../
util/dataExtractor"
;
/**
/**
* 抽象数据策略中间层类,所有具体策略类都需要继承该抽象类。
* 抽象数据策略中间层类,所有具体策略类都需要继承该抽象类。
...
...
src/biz/map1/strategies/middle/eventDataStrategy.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
import
{
abstractDataStrategyMid
}
from
"./abstractDataStrategyMid"
;
import
{
abstractDataStrategyMid
}
from
"./abstractDataStrategyMid"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
/**
/**
* 事件数据策略类,继承自 abstractDataStrategyMid。
* 事件数据策略类,继承自 abstractDataStrategyMid。
...
...
src/biz/map1/strategies/middle/totalEventCountStrategy.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
import
{
abstractDataStrategyMid
}
from
"./abstractDataStrategyMid"
;
import
{
abstractDataStrategyMid
}
from
"./abstractDataStrategyMid"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
/**
/**
* 总事件计数策略类,继承自 abstractDataStrategyMid。
* 总事件计数策略类,继承自 abstractDataStrategyMid。
...
...
src/biz/map1/strategies/right/abstractDataStrategyRight.ts
View file @
d158dda8
...
@@ -3,10 +3,11 @@
...
@@ -3,10 +3,11 @@
* 该文件定义了一个抽象类,用于右侧数据策略的基础实现。
* 该文件定义了一个抽象类,用于右侧数据策略的基础实现。
*/
*/
import
{
dataStrategy
}
from
"../dataStrategy"
;
import
{
dataStrategy
}
from
"../
../../
dataStrategy"
;
import
{
DataExtractor
}
from
"../../../util/dataExtractor"
;
import
{
DataExtractor
}
from
"../../../
../
util/dataExtractor"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
moment
=
require
(
"moment"
);
import
moment
=
require
(
"moment"
);
import
paramChecker
from
"../../../../util/paramChecker"
;
/**
/**
* 抽象数据策略右侧类,所有右侧具体策略类都需要继承该抽象类。
* 抽象数据策略右侧类,所有右侧具体策略类都需要继承该抽象类。
...
@@ -37,12 +38,7 @@ export abstract class abstractDataStrategyRight implements dataStrategy {
...
@@ -37,12 +38,7 @@ export abstract class abstractDataStrategyRight implements dataStrategy {
* @throws 如果参数无效则抛出错误。
* @throws 如果参数无效则抛出错误。
*/
*/
protected
paramsCheck
(
params
)
{
protected
paramsCheck
(
params
)
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
year
)
{
paramChecker
.
checkDiscreteParam
(
params
,
'year'
,
'thisyear'
,
'lastyear'
);
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".'
);
}
}
}
/**
/**
...
...
src/biz/map1/strategies/right/eventCategoryCountStrategy.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
/**
/**
* 事件类别计数策略类,继承自 abstractDataStrategyRight。
* 事件类别计数策略类,继承自 abstractDataStrategyRight。
...
...
src/biz/map1/strategies/right/eventMonthDistributionStrategy.ts
View file @
d158dda8
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
/**
/**
* 事件按月分布策略类,继承自 abstractDataStrategyRight。
* 事件按月分布策略类,继承自 abstractDataStrategyRight。
...
...
src/biz/map1/strategies/right/eventProcessingTimeStrategy.ts
View file @
d158dda8
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
getRandomNumber
from
"../../../util/randomNumberGenerator"
;
import
getRandomNumber
from
"../../../
../
util/randomNumberGenerator"
;
/**
/**
* 事件处理时间策略类,继承自 abstractDataStrategyRight。
* 事件处理时间策略类,继承自 abstractDataStrategyRight。
...
...
src/biz/map1/strategies/right/eventSrcStrategy.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
/**
/**
* 事件来源策略类,继承自 abstractDataStrategyRight。
* 事件来源策略类,继承自 abstractDataStrategyRight。
...
...
src/biz/map1/strategies/right/eventSubCategoryCountStrategy.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
/**
/**
* 事件子类别计数策略类,继承自 abstractDataStrategyRight。
* 事件子类别计数策略类,继承自 abstractDataStrategyRight。
...
...
src/biz/map1/strategies/right/eventTimeDistributionStrategy.ts
View file @
d158dda8
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
/**
/**
* 事件时间分布策略类,继承自 abstractDataStrategyRight。
* 事件时间分布策略类,继承自 abstractDataStrategyRight。
...
...
src/biz/map1/strategies/right/getEventCountByYearStrategy.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../../
../
util/excelDateToJSDate"
;
import
moment
=
require
(
"moment"
);
import
moment
=
require
(
"moment"
);
/**
/**
...
...
src/biz/map1/strategies/right/gridEventCountStrategy.ts
View file @
d158dda8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*/
*/
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
{
abstractDataStrategyRight
}
from
"./abstractDataStrategyRight"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
mapToObj
from
"../../../
../
util/mapToObj"
;
/**
/**
* 按网格统计事件数量策略类,继承自 abstractDataStrategyRight。
* 按网格统计事件数量策略类,继承自 abstractDataStrategyRight。
...
...
src/biz/map2/strategies/left/abstractDataStrategyLeft.ts
View file @
d158dda8
/**
* 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
;
}
src/biz/map2/strategies/left/monthlyVisitorCountStrategy.ts
View file @
d158dda8
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
;
}
}
src/biz/map2/strategies/left/sightVisitorRankStrategy.ts
View file @
d158dda8
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
;
}
}
src/biz/strategyFactory.ts
View file @
d158dda8
...
@@ -3,28 +3,30 @@
...
@@ -3,28 +3,30 @@
* 该文件定义了策略工厂类,用于创建各种数据策略。
* 该文件定义了策略工厂类,用于创建各种数据策略。
*/
*/
import
{
dataStrategy
}
from
".
./..
/dataStrategy"
;
import
{
dataStrategy
}
from
"./dataStrategy"
;
// 导入具体策略类
// 导入具体策略类
import
{
sightVisitorFlowByDayStrategy
}
from
"./left/sightVisitorFlowByDayStrategy"
;
import
{
sightVisitorFlowByDayStrategy
}
from
"./
map1/strategies/
left/sightVisitorFlowByDayStrategy"
;
import
{
gateStatusStrategy
}
from
"./left/gateStatusStrategy"
;
import
{
gateStatusStrategy
}
from
"./
map1/strategies/
left/gateStatusStrategy"
;
import
{
sightVisitorFlowByHourStrategy
}
from
"./left/sightVisitorFlowPerHourStrategy"
;
import
{
sightVisitorFlowByHourStrategy
}
from
"./
map1/strategies/
left/sightVisitorFlowPerHourStrategy"
;
import
{
guchengLoadStrategy
}
from
"./left/guchengLoadStrategy"
;
import
{
guchengLoadStrategy
}
from
"./
map1/strategies/
left/guchengLoadStrategy"
;
import
{
totalVisitorFlowStrategy
}
from
"./left/totalVisitorFlowStrategy"
;
import
{
totalVisitorFlowStrategy
}
from
"./
map1/strategies/
left/totalVisitorFlowStrategy"
;
import
{
totalVisitorFlowByHourStrategy
}
from
"./left/totalVisitorFlowByHourStrategy"
;
import
{
totalVisitorFlowByHourStrategy
}
from
"./
map1/strategies/
left/totalVisitorFlowByHourStrategy"
;
import
{
currentEventStrategy
}
from
"./middle/currentEventStrategy"
;
import
{
currentEventStrategy
}
from
"./m
ap1/strategies/m
iddle/currentEventStrategy"
;
import
{
totalEventCountStrategy
}
from
"./middle/totalEventCountStrategy"
;
import
{
totalEventCountStrategy
}
from
"./m
ap1/strategies/m
iddle/totalEventCountStrategy"
;
import
{
getEventCountByYearStrategy
}
from
"./right/getEventCountByYearStrategy"
;
import
{
getEventCountByYearStrategy
}
from
"./map1/strategies/right/getEventCountByYearStrategy"
;
import
{
eventTimeDistributionStrategy
}
from
"./right/eventTimeDistributionStrategy"
;
import
{
eventTimeDistributionStrategy
}
from
"./map1/strategies/right/eventTimeDistributionStrategy"
;
import
{
eventMonthDistributionStrategy
}
from
"./right/eventMonthDistributionStrategy"
;
import
{
eventMonthDistributionStrategy
}
from
"./map1/strategies/right/eventMonthDistributionStrategy"
;
import
{
eventCategoryCountStrategy
}
from
"./right/eventCategoryCountStrategy"
;
import
{
eventCategoryCountStrategy
}
from
"./map1/strategies/right/eventCategoryCountStrategy"
;
import
{
eventSubCategoryCountStrategy
}
from
"./right/eventSubCategoryCountStrategy"
;
import
{
eventSubCategoryCountStrategy
}
from
"./map1/strategies/right/eventSubCategoryCountStrategy"
;
import
{
eventSrcStrategy
}
from
"./right/eventSrcStrategy"
;
import
{
eventSrcStrategy
}
from
"./map1/strategies/right/eventSrcStrategy"
;
import
{
gridEventCountStrategy
}
from
"./right/gridEventCountStrategy"
;
import
{
gridEventCountStrategy
}
from
"./map1/strategies/right/gridEventCountStrategy"
;
import
{
eventProcessingTimeStrategy
}
from
"./right/eventProcessingTimeStrategy"
;
import
{
eventProcessingTimeStrategy
}
from
"./map1/strategies/right/eventProcessingTimeStrategy"
;
import
{
allEventDataStrategy
}
from
"./middle/eventDataStrategy"
;
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 {
...
@@ -34,6 +36,7 @@ export class strategyFactory {
* 存储策略类型与其对应类的映射。
* 存储策略类型与其对应类的映射。
*/
*/
private
static
strategies
:
{
[
key
:
string
]:
new
()
=>
dataStrategy
}
=
{
private
static
strategies
:
{
[
key
:
string
]:
new
()
=>
dataStrategy
}
=
{
// map 1
'allEvents'
:
allEventDataStrategy
,
'allEvents'
:
allEventDataStrategy
,
'sightVisitorFlowByDay'
:
sightVisitorFlowByDayStrategy
,
'sightVisitorFlowByDay'
:
sightVisitorFlowByDayStrategy
,
'gateStatus'
:
gateStatusStrategy
,
'gateStatus'
:
gateStatusStrategy
,
...
@@ -51,6 +54,10 @@ export class strategyFactory {
...
@@ -51,6 +54,10 @@ export class strategyFactory {
'getEventSourceCount'
:
eventSrcStrategy
,
'getEventSourceCount'
:
eventSrcStrategy
,
'getGridEventCount'
:
gridEventCountStrategy
,
'getGridEventCount'
:
gridEventCountStrategy
,
'getEventProcessingTime'
:
eventProcessingTimeStrategy
,
'getEventProcessingTime'
:
eventProcessingTimeStrategy
,
// map2
'monthlyVisitor'
:
monthlyVisitorCountStrategy
,
'sightVisitorRank'
:
sightVisitorRankStrategy
};
};
/**
/**
...
...
src/routers/map1/routerLeft.ts
View file @
d158dda8
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
szgcBiz
from
'../../biz/getData'
;
import
*
as
szgcBiz
from
'../../biz/getData'
;
export
function
setLeftRoutes
(
httpServer
)
{
export
function
set
Map1
LeftRoutes
(
httpServer
)
{
httpServer
.
get
(
'/szgc/getdata/sightVisitorFlowByDay'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'sightVisitorFlowByDay'
)));
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/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/sightVisitorFlowPerHour'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'sightVisitorFlowPerHour'
)));
...
...
src/routers/map1/routerMid.ts
View file @
d158dda8
import
*
as
asyncHandler
from
'express-async-handler'
;
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
setM
ap1M
iddleRoutes
(
httpServer
)
{
httpServer
.
get
(
'/szgc/getdata/getCurrentEventCount'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'getCurrentEventCount'
)));
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/totalEventCount'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'totalEventCount'
)));
httpServer
.
get
(
'/szgc/getdata/allEvents'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'allEvents'
)));
httpServer
.
get
(
'/szgc/getdata/allEvents'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'allEvents'
)));
...
...
src/routers/map1/routerRight.ts
View file @
d158dda8
import
*
as
asyncHandler
from
'express-async-handler'
;
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
set
Map1
RightRoutes
(
httpServer
)
{
httpServer
.
get
(
'/szgc/getdata/getEventCountByYear'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'getEventCountByYear'
)));
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/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/getEventMonthDistribution'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'getEventMonthDistribution'
)));
...
...
src/routers/map2/routerLeft.ts
View file @
d158dda8
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
szgcBiz
from
'../../biz/getData'
;
import
*
as
szgcBiz
from
'../../biz/getData'
;
export
function
setLeftRoutes
(
httpServer
)
{
export
function
setMap2LeftRoutes
(
httpServer
)
{
httpServer
.
get
(
'/szgc/getdata/sightVisitorFlowByDay'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'sightVisitorFlowByDay'
)));
httpServer
.
get
(
'/szgc/getdata/monthlyVisitorCount'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'monthlyVisitor'
)));
httpServer
.
get
(
'/szgc/getdata/gateStatus'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'gateStatus'
)));
httpServer
.
get
(
'/szgc/getdate/sightVisitorRank'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'sightVisitorRank'
)));
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'
)));
}
}
\ No newline at end of file
src/routers/map2/routerMid.ts
View file @
d158dda8
import
*
as
asyncHandler
from
'express-async-handler'
;
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
setM
ap2M
iddleRoutes
(
httpServer
)
{
httpServer
.
get
(
'/szgc/getdata/getCurrentEventCount'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'getCurrentEventCount'
)));
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'
)));
}
}
src/routers/map2/routerRight.ts
View file @
d158dda8
import
*
as
asyncHandler
from
'express-async-handler'
;
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
set
Map2
RightRoutes
(
httpServer
)
{
httpServer
.
get
(
'/szgc/getdata/getEventCountByYear'
,
asyncHandler
((
req
,
res
)
=>
szgcBiz
.
getData
(
req
,
res
,
'getEventCountByYear'
)));
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'
)));
}
}
src/routers/router.ts
View file @
d158dda8
import
{
setLeftRoutes
}
from
'./routerLeft'
;
import
{
setMap1LeftRoutes
}
from
'./map1/routerLeft'
;
import
{
setMiddleRoutes
}
from
'./routerMid'
;
import
{
setMap1MiddleRoutes
}
from
'./map1/routerMid'
;
import
{
setRightRoutes
}
from
'./routerRight'
;
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
szgcBiz
from
'../biz/getData'
;
import
*
as
asyncHandler
from
'express-async-handler'
;
export
function
setRouter
(
httpServer
)
{
export
function
setRouter
(
httpServer
)
{
setLeftRoutes
(
httpServer
);
setMap1LeftRoutes
(
httpServer
);
setMiddleRoutes
(
httpServer
);
setMap1MiddleRoutes
(
httpServer
);
setRightRoutes
(
httpServer
);
setMap1RightRoutes
(
httpServer
);
setMap2LeftRoutes
(
httpServer
);
setMap2MiddleRoutes
(
httpServer
);
setMap2RightRoutes
(
httpServer
);
httpServer
.
get
(
'/test'
,
szgcBiz
.
test
);
httpServer
.
get
(
'/test'
,
szgcBiz
.
test
);
}
}
src/util/paramChecker.ts
View file @
d158dda8
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment