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
c79a63e9
Commit
c79a63e9
authored
Jul 15, 2024
by
Leo Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路由代码重构
parent
1f24d592
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
17 deletions
+48
-17
getData.ts
src/biz/getData.ts
+6
-8
getEventCountByYearStrategy.ts
src/biz/strategies/right/getEventCountByYearStrategy.ts
+1
-1
router.ts
src/routers/router.ts
+8
-8
routerLeft.ts
src/routers/routerLeft.ts
+12
-0
routerMid.ts
src/routers/routerMid.ts
+8
-0
routerRight.ts
src/routers/routerRight.ts
+13
-0
No files found.
src/biz/getData.ts
View file @
c79a63e9
...
@@ -7,16 +7,14 @@
...
@@ -7,16 +7,14 @@
import
{
strategyFactory
}
from
"./strategies/strategyFactory"
;
import
{
strategyFactory
}
from
"./strategies/strategyFactory"
;
/**
/**
* 处理获取数据的主要请求。
* Handles the main data retrieval request.
* @param req - 请求对象,包含查询参数。
* @param req - The request object containing query parameters.
* @param res - 响应对象,用于将结果发送回客户端。
* @param res - The response object used to send results back to the client.
* @param strategyType - The type of strategy to be used.
*/
*/
export
function
getData
(
req
,
res
)
{
export
function
getData
(
req
,
res
,
strategyType
:
string
)
{
// 根据请求查询内容创建策略。
const
strategy
=
strategyFactory
.
createStrategy
(
strategyType
);
const
strategy
=
strategyFactory
.
createStrategy
(
req
.
query
.
content
);
// 使用请求参数执行策略并获取结果。
let
ret
=
strategy
.
execute
(
req
);
let
ret
=
strategy
.
execute
(
req
);
// 将结果发送回客户端。
res
.
send
(
ret
);
res
.
send
(
ret
);
}
}
...
...
src/biz/strategies/right/getEventCountByYearStrategy.ts
View file @
c79a63e9
...
@@ -37,7 +37,6 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight {
...
@@ -37,7 +37,6 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight {
const
eventCount
=
this
.
registerItems
(
eventList
);
const
eventCount
=
this
.
registerItems
(
eventList
);
let
finishedEventCount
=
0
;
let
finishedEventCount
=
0
;
data
.
forEach
(
row
=>
{
data
.
forEach
(
row
=>
{
const
rowDate
=
excelSerialToJSDate
(
row
[
'创建时间'
]);
const
rowDate
=
excelSerialToJSDate
(
row
[
'创建时间'
]);
let
rowYear
;
let
rowYear
;
...
@@ -46,6 +45,7 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight {
...
@@ -46,6 +45,7 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight {
}
catch
(
e
)
{
}
catch
(
e
)
{
rowYear
=
0
;
rowYear
=
0
;
}
}
console
.
log
(
"rowy"
,
rowYear
);
if
(
rowYear
==
year
)
{
if
(
rowYear
==
year
)
{
eventCount
.
set
(
'事件总数'
,
eventCount
.
get
(
'事件总数'
)
+
1
);
eventCount
.
set
(
'事件总数'
,
eventCount
.
get
(
'事件总数'
)
+
1
);
if
(
row
[
'处置状态'
]
==
'已办结'
)
{
if
(
row
[
'处置状态'
]
==
'已办结'
)
{
...
...
src/routers/router.ts
View file @
c79a63e9
/**
import
{
setLeftRoutes
}
from
'./routerLeft'
;
* 总路由入口
import
{
setMiddleRoutes
}
from
'./routerMid'
;
*/
import
{
setRightRoutes
}
from
'./routerRight'
;
import
*
as
asyncHandler
from
'express-async-handler'
;
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
)
{
httpServer
.
get
(
'/szgc/getdata'
,
asyncHandler
(
szgcBiz
.
getData
));
setLeftRoutes
(
httpServer
);
setMiddleRoutes
(
httpServer
);
setRightRoutes
(
httpServer
);
httpServer
.
get
(
'/test'
,
szgcBiz
.
test
);
httpServer
.
get
(
'/test'
,
szgcBiz
.
test
);
}
}
src/routers/routerLeft.ts
0 → 100644
View file @
c79a63e9
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'
)));
}
\ No newline at end of file
src/routers/routerMid.ts
0 → 100644
View file @
c79a63e9
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
szgcBiz
from
'../biz/getData'
;
export
function
setMiddleRoutes
(
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'
)));
}
src/routers/routerRight.ts
0 → 100644
View file @
c79a63e9
import
*
as
asyncHandler
from
'express-async-handler'
;
import
*
as
szgcBiz
from
'../biz/getData'
;
export
function
setRightRoutes
(
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'
)));
}
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