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
902871d0
Commit
902871d0
authored
Jul 03, 2024
by
Leo Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成左边图的数据接口
- TODO:更多测试
parent
0581ff2b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
9 deletions
+110
-9
guchengLoadStrategy.ts
src/biz/strategies/guchengLoadStrategy.ts
+10
-0
sightVisitorFlowPerHourStrategy.ts
src/biz/strategies/sightVisitorFlowPerHourStrategy.ts
+2
-6
strategyFactory.ts
src/biz/strategies/strategyFactory.ts
+7
-2
totalVisitorFlowByHourStrategy.ts
src/biz/strategies/totalVisitorFlowByHourStrategy.ts
+47
-0
totalVisitorFlowStrategy.ts
src/biz/strategies/totalVisitorFlowStrategy.ts
+43
-0
randomStatusGenerator.ts
src/util/randomStatusGenerator.ts
+1
-1
No files found.
src/biz/strategies/guchengLoadStrategy.ts
0 → 100644
View file @
902871d0
import
{
dataStrategy
}
from
"./dataStrategy"
;
import
{
randomStatusGenerator
}
from
"../../util/randomStatusGenerator"
;
export
class
guchengLoadStrategy
implements
dataStrategy
{
execute
():
any
{
return
randomStatusGenerator
.
getRandomStatus
();
}
}
\ No newline at end of file
src/biz/strategies/sightVisitorFlowPerHourStrategy.ts
View file @
902871d0
import
{
dataStrategy
}
from
"./dataStrategy"
;
import
{
DataExtractor
}
from
"../../util/dataExtractor"
;
import
excelDateToJSDate
from
"../../util/excelDateToJSDate"
;
import
excelSerialToJSDate
from
"../../util/excelDateToJSDate"
;
import
mapToObj
from
"../../util/mapToObj"
;
...
...
@@ -13,7 +12,7 @@ export class sightVisitorFlowByHourStrategy implements dataStrategy {
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
||
!
params
.
query
.
sight
)
{
throw
new
Error
(
'Date and sight parameters are required'
);
}
le
t
sightData
=
this
.
extractor
.
getData
(
sightVisitorFlowByHourStrategy
.
fileName
,
sightVisitorFlowByHourStrategy
.
sheetName
);
cons
t
sightData
=
this
.
extractor
.
getData
(
sightVisitorFlowByHourStrategy
.
fileName
,
sightVisitorFlowByHourStrategy
.
sheetName
);
return
mapToObj
(
this
.
getVisitorFlowByHour
(
sightData
,
params
.
query
.
sight
,
params
.
query
.
date
));
}
...
...
@@ -25,15 +24,13 @@ export class sightVisitorFlowByHourStrategy implements dataStrategy {
data
.
forEach
(
row
=>
{
const
rowDate
=
excelSerialToJSDate
(
row
[
'游玩时间'
]);
const
rowHour
=
rowDate
.
getHours
();
let
rowDateString
=
''
;
try
{
rowDateString
=
rowDate
.
toISOString
().
split
(
'T'
)[
0
];
}
catch
(
e
)
{
rowDateString
=
'invalid time'
rowDateString
=
'invalid time'
;
}
const
rowSight
=
row
[
'景点名称'
];
rowDate
.
setHours
(
rowDate
.
getHours
()
-
8
);
...
...
@@ -44,7 +41,6 @@ export class sightVisitorFlowByHourStrategy implements dataStrategy {
}
}
});
return
visitorCount
;
}
}
src/biz/strategies/strategyFactory.ts
View file @
902871d0
...
...
@@ -3,14 +3,19 @@ import { allEventDataStrategy } from "./eventDataStrategy";
import
{
sightVisitorFlowByDayStrategy
}
from
"./sightVisitorFlowByDayStrategy"
;
import
{
gateStatusStrategy
}
from
"./gateStatusStrategy"
;
import
{
sightVisitorFlowByHourStrategy
}
from
"./sightVisitorFlowPerHourStrategy"
;
import
{
guchengLoadStrategy
}
from
"./guchengLoadStrategy"
;
import
{
totalVisitorFlowStrategy
}
from
"./totalVisitorFlowStrategy"
;
import
{
totalVisitorFlowByHourStrategy
}
from
"./totalVisitorFlowByHourStrategy"
;
export
class
strategyFactory
{
private
static
strategies
:
{
[
key
:
string
]:
new
()
=>
dataStrategy
}
=
{
'allEvents'
:
allEventDataStrategy
,
'sightVisitorFlowByDay'
:
sightVisitorFlowByDayStrategy
,
'gateStatus'
:
gateStatusStrategy
,
'sightVisitorFlowPerHour'
:
sightVisitorFlowByHourStrategy
'sightVisitorFlowPerHour'
:
sightVisitorFlowByHourStrategy
,
'guchengLoad'
:
guchengLoadStrategy
,
'totalVisitorFlow'
:
totalVisitorFlowStrategy
,
'totalVisitorFlowByDay'
:
totalVisitorFlowByHourStrategy
};
static
createStrategy
(
type
:
string
):
dataStrategy
{
...
...
src/biz/strategies/totalVisitorFlowByHourStrategy.ts
0 → 100644
View file @
902871d0
import
{
dataStrategy
}
from
"./dataStrategy"
;
import
{
DataExtractor
}
from
"../../util/dataExtractor"
;
import
excelSerialToJSDate
from
"../../util/excelDateToJSDate"
;
import
mapToObj
from
"../../util/mapToObj"
;
export
class
totalVisitorFlowByHourStrategy
implements
dataStrategy
{
extractor
=
DataExtractor
.
getInstance
();
static
readonly
fileName
=
'票务系统.xlsx'
;
static
readonly
sheetName
=
'票务系统-订单主表'
;
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
throw
new
Error
(
'Date parameters are required'
);
}
const
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowByHourStrategy
.
fileName
,
totalVisitorFlowByHourStrategy
.
sheetName
);
return
mapToObj
(
this
.
getTotalVisitorFlowByHour
(
sightData
,
params
.
query
.
date
));
}
private
getTotalVisitorFlowByHour
(
data
:
any
,
date
:
string
)
{
const
visitorCount
:
Map
<
number
,
number
>
=
new
Map
();
for
(
let
hour
=
0
;
hour
<
24
;
hour
++
)
{
visitorCount
.
set
(
hour
,
0
);
}
data
.
forEach
(
row
=>
{
const
rowDate
=
excelSerialToJSDate
(
row
[
'游玩时间'
]);
const
rowHour
=
rowDate
.
getHours
();
let
rowDateString
=
''
;
try
{
rowDateString
=
rowDate
.
toISOString
().
split
(
'T'
)[
0
];
}
catch
(
e
)
{
rowDateString
=
'invalid time'
;
}
rowDate
.
setHours
(
rowDate
.
getHours
()
-
8
);
if
(
rowDateString
==
date
)
{
if
(
visitorCount
.
has
(
rowHour
-
8
))
{
visitorCount
.
set
(
rowHour
-
8
,
(
visitorCount
.
get
(
rowHour
)
||
0
)
+
1
);
}
}
});
return
visitorCount
;
}
}
\ No newline at end of file
src/biz/strategies/totalVisitorFlowStrategy.ts
0 → 100644
View file @
902871d0
import
{
dataStrategy
}
from
"./dataStrategy"
;
import
{
DataExtractor
}
from
"../../util/dataExtractor"
;
import
excelSerialToJSDate
from
"../../util/excelDateToJSDate"
;
import
mapToObj
from
"../../util/mapToObj"
;
export
class
totalVisitorFlowStrategy
implements
dataStrategy
{
extractor
=
DataExtractor
.
getInstance
();
static
readonly
fileName
=
'票务系统.xlsx'
;
static
readonly
sheetName
=
'票务系统-订单主表'
;
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
throw
new
Error
(
"Data parameter is required."
)
}
let
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowStrategy
.
fileName
,
totalVisitorFlowStrategy
.
sheetName
);
return
mapToObj
(
this
.
getTotalVisitorByDay
(
sightData
,
params
.
query
.
date
));
}
private
getTotalVisitorByDay
(
data
:
any
,
date
:
string
)
{
const
visitorCount
:
Map
<
string
,
number
>
=
new
Map
();
visitorCount
.
set
(
'total'
,
0
);
data
.
forEach
(
row
=>
{
const
rowDate
=
excelSerialToJSDate
(
row
[
'游玩时间'
]);
let
rowDateString
=
''
;
try
{
rowDateString
=
rowDate
.
toISOString
().
split
(
'T'
)[
0
];
}
catch
(
e
)
{
rowDateString
=
'invalid time'
}
if
(
rowDateString
==
date
)
{
visitorCount
.
set
(
'total'
,
visitorCount
.
get
(
'total'
)
+
1
);
visitorCount
.
set
(
row
[
'订单游客类型'
],
(
visitorCount
.
get
(
row
[
'订单游客类型'
])
||
0
)
+
1
);
}
});
return
visitorCount
;
}
}
\ No newline at end of file
src/util/randomStatusGenerator.ts
View file @
902871d0
export
class
randomStatusGenerator
{
private
static
statuses
:
string
[]
=
[
'正常'
,
'拥挤'
,
'
通
畅'
];
private
static
statuses
:
string
[]
=
[
'正常'
,
'拥挤'
,
'
顺
畅'
];
static
getRandomStatus
():
string
{
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
randomStatusGenerator
.
statuses
.
length
);
...
...
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