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
d2a2c5fc
Commit
d2a2c5fc
authored
Jul 04, 2024
by
Leo Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编写了数据图中间部分的数据接口
parent
bae57bb5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
16 deletions
+98
-16
sightVisitorFlowByDayStrategy.ts
src/biz/strategies/left/sightVisitorFlowByDayStrategy.ts
+1
-1
totalVisitorFlowStrategy.ts
src/biz/strategies/left/totalVisitorFlowStrategy.ts
+2
-2
currentEventStrategy.ts
src/biz/strategies/middle/currentEventStrategy.ts
+38
-2
eventDataStrategy.ts
src/biz/strategies/middle/eventDataStrategy.ts
+20
-1
totalEventCountStrategy.ts
src/biz/strategies/middle/totalEventCountStrategy.ts
+23
-0
strategyFactory.ts
src/biz/strategies/strategyFactory.ts
+13
-9
httpErrorHandler.ts
src/middleware/httpErrorHandler.ts
+1
-1
No files found.
src/biz/strategies/left/sightVisitorFlowByDayStrategy.ts
View file @
d2a2c5fc
...
...
@@ -5,7 +5,7 @@ import {abstractDataStrategyLeft} from "./abstractDataStrategyLeft";
export
class
sightVisitorFlowByDayStrategy
extends
abstractDataStrategyLeft
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
throw
new
Error
(
"Dat
a
parameter is required."
)
throw
new
Error
(
"Dat
e
parameter is required."
)
}
let
sightData
=
this
.
extractor
.
getData
(
sightVisitorFlowByDayStrategy
.
fileName
,
sightVisitorFlowByDayStrategy
.
sheetName
);
return
this
.
getVisitorFlowByDay
(
sightData
,
params
.
query
.
date
);
...
...
src/biz/strategies/left/totalVisitorFlowStrategy.ts
View file @
d2a2c5fc
...
...
@@ -6,7 +6,7 @@ export class totalVisitorFlowStrategy extends abstractDataStrategyLeft {
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
throw
new
Error
(
"Dat
a
parameter is required."
)
throw
new
Error
(
"Dat
e
parameter is required."
)
}
let
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowStrategy
.
fileName
,
totalVisitorFlowStrategy
.
sheetName
);
return
mapToObj
(
this
.
getTotalVisitorByDay
(
sightData
,
params
.
query
.
date
));
...
...
@@ -25,7 +25,7 @@ export class totalVisitorFlowStrategy extends abstractDataStrategyLeft {
catch
(
e
)
{
rowDateString
=
'invalid time'
}
if
(
rowDateString
==
date
)
{
if
(
rowDateString
==
=
date
)
{
visitorCount
.
set
(
'total'
,
visitorCount
.
get
(
'total'
)
+
1
);
visitorCount
.
set
(
row
[
'订单游客类型'
],
(
visitorCount
.
get
(
row
[
'订单游客类型'
])
||
0
)
+
1
);
}
...
...
src/biz/strategies/middle/currentEventStrategy.ts
View file @
d2a2c5fc
import
{
dataStrategy
}
from
"../dataStrategy"
;
import
{
abstractDataStrategyMid
}
from
"./abstractDataStrategyMid"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
mapToObj
from
"../../../util/mapToObj"
;
export
class
currentEventStrategy
implements
dataStrategy
{
export
class
currentEventStrategy
extends
abstractDataStrategyMid
{
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
throw
new
Error
(
"Date parameter is required."
)
}
let
dayData
=
this
.
extractor
.
getData
(
currentEventStrategy
.
fileName
,
currentEventStrategy
.
sheetName
);
return
mapToObj
(
this
.
getCurrentDayEventDate
(
dayData
,
params
.
query
.
date
));
}
private
getCurrentDayEventDate
(
data
:
any
,
date
:
string
)
{
const
eventCount
:
Map
<
string
,
number
>
=
new
Map
();
eventCount
.
set
(
'pendingEvents'
,
0
);
eventCount
.
set
(
'processedEvents'
,
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
)
{
if
(
row
[
'处置状态'
]
==
'待调度'
||
row
[
'处置状态'
]
==
'处置中'
)
{
eventCount
.
set
(
'pendingEvents'
,
eventCount
.
get
(
'pendingEvents'
)
+
1
);
}
else
{
eventCount
.
set
(
'processedEvents'
,
eventCount
.
get
(
'processedEvents'
)
+
1
);
}
}
});
return
eventCount
;
}
}
\ No newline at end of file
src/biz/strategies/middle/eventDataStrategy.ts
View file @
d2a2c5fc
import
{
abstractDataStrategyMid
}
from
"./abstractDataStrategyMid"
;
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
export
class
allEventDataStrategy
extends
abstractDataStrategyMid
{
static
readonly
RELEVANTINFO
=
[
'事件标题'
,
'处置状态'
,
'数据更新时间'
,
'事件类型'
,
'事件子类型'
,
'事件来源'
];
execute
():
any
{
return
this
.
extractor
.
getData
(
allEventDataStrategy
.
fileName
,
allEventDataStrategy
.
sheetName
);
let
eventData
=
this
.
extractor
.
getData
(
allEventDataStrategy
.
fileName
,
allEventDataStrategy
.
sheetName
);
this
.
removeUnusedColumns
(
eventData
);
return
eventData
;
}
private
removeUnusedColumns
(
data
:
any
)
{
data
.
forEach
(
row
=>
{
Object
.
keys
(
row
).
forEach
(
key
=>
{
if
(
!
allEventDataStrategy
.
RELEVANTINFO
.
includes
(
key
))
{
delete
row
[
key
];
}
if
(
key
===
'数据更新时间'
)
{
row
[
key
]
=
excelSerialToJSDate
(
row
[
key
]);
}
});
});
}
}
\ No newline at end of file
src/biz/strategies/middle/totalEventCountStrategy.ts
0 → 100644
View file @
d2a2c5fc
import
{
abstractDataStrategyMid
}
from
"./abstractDataStrategyMid"
;
import
mapToObj
from
"../../../util/mapToObj"
;
export
class
totalEventCountStrategy
extends
abstractDataStrategyMid
{
execute
():
any
{
let
eventData
=
this
.
extractor
.
getData
(
totalEventCountStrategy
.
fileName
,
totalEventCountStrategy
.
sheetName
);
return
mapToObj
(
this
.
getEventCount
(
eventData
));
}
private
getEventCount
(
data
:
any
)
{
const
eventCount
:
Map
<
string
,
number
>
=
new
Map
();
eventCount
.
set
(
'全部事件'
,
0
);
data
.
forEach
(
row
=>
{
eventCount
.
set
(
row
[
'处置状态'
],
(
eventCount
.
get
(
row
[
'处置状态'
])
||
0
)
+
1
);
eventCount
.
set
(
'全部事件'
,
eventCount
.
get
(
'全部事件'
)
+
1
);
});
return
eventCount
;
}
}
\ No newline at end of file
src/biz/strategies/strategyFactory.ts
View file @
d2a2c5fc
import
{
dataStrategy
}
from
"./dataStrategy"
;
import
{
allEventDataStrategy
}
from
"./middle/eventDataStrategy"
;
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
{
dataStrategy
}
from
"./dataStrategy"
;
import
{
allEventDataStrategy
}
from
"./middle/eventDataStrategy"
;
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
{
currentEventStrategy
}
from
"./middle/currentEventStrategy"
;
import
{
totalEventCountStrategy
}
from
"./middle/totalEventCountStrategy"
;
export
class
strategyFactory
{
private
static
strategies
:
{
[
key
:
string
]:
new
()
=>
dataStrategy
}
=
{
...
...
@@ -15,7 +17,9 @@ export class strategyFactory {
'sightVisitorFlowPerHour'
:
sightVisitorFlowByHourStrategy
,
'guchengLoad'
:
guchengLoadStrategy
,
'totalVisitorFlow'
:
totalVisitorFlowStrategy
,
'totalVisitorFlowByDay'
:
totalVisitorFlowByHourStrategy
'totalVisitorFlowByDay'
:
totalVisitorFlowByHourStrategy
,
'currentEventStrategy'
:
currentEventStrategy
,
'totalEventCount'
:
totalEventCountStrategy
};
static
createStrategy
(
type
:
string
):
dataStrategy
{
...
...
src/middleware/httpErrorHandler.ts
View file @
d2a2c5fc
...
...
@@ -11,7 +11,7 @@ export function httpErrorHandler(err, req, res, next) {
res
.
success
({
success
:
false
,
msg
:
err
.
message
,
code
:
502
});
next
();
}
else
if
(
err
.
message
==
"Dat
a
parameter is required."
)
{
else
if
(
err
.
message
==
"Dat
e
parameter is required."
)
{
res
.
success
({
success
:
false
,
msg
:
err
.
message
,
code
:
503
});
next
();
}
...
...
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