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
51962de4
Commit
51962de4
authored
Jul 17, 2024
by
zhengyoujia
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'frontend' into 'master'
Frontend See merge request
!11
parents
f3c06ea5
ab12e838
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
21 deletions
+55
-21
serverConfig.xml
serverConfig.xml
+2
-1
sightVisitorFlowByDayStrategy.ts
src/biz/strategies/left/sightVisitorFlowByDayStrategy.ts
+4
-2
totalVisitorFlowStrategy.ts
src/biz/strategies/left/totalVisitorFlowStrategy.ts
+36
-18
replaceZeroWithRandomNumber.ts
src/util/replaceZeroWithRandomNumber.ts
+13
-0
No files found.
serverConfig.xml
View file @
51962de4
<config>
<port>
3001
6
</port>
<port>
3001
7
</port>
<host>
192.168.0.132
</host>
</config>
\ No newline at end of file
src/biz/strategies/left/sightVisitorFlowByDayStrategy.ts
View file @
51962de4
...
...
@@ -67,10 +67,12 @@ export class sightVisitorFlowByDayStrategy extends abstractDataStrategyLeft {
});
}
// Convert the map to the desired format
// Convert the map to the desired format
with "01时" format for hours
const
result
:
Array
<
{
key
:
string
,
count
:
number
,
status
:
string
}
>
=
[];
visitorCount
.
forEach
((
value
,
key
)
=>
{
result
.
push
({
key
,
count
:
value
.
count
,
status
:
value
.
status
});
const
formattedKey
=
key
.
toString
().
padStart
(
2
,
'0'
)
+
"时"
;
result
.
push
({
key
:
formattedKey
,
count
:
value
.
count
,
status
:
value
.
status
});
console
.
log
(
"here!"
);
});
return
result
;
...
...
src/biz/strategies/left/totalVisitorFlowStrategy.ts
View file @
51962de4
...
...
@@ -4,7 +4,6 @@
*/
import
excelSerialToJSDate
from
"../../../util/excelDateToJSDate"
;
import
mapToObj
from
"../../../util/mapToObj"
;
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
/**
...
...
@@ -19,43 +18,62 @@ export class totalVisitorFlowStrategy extends abstractDataStrategyLeft {
*/
execute
(
params
?:
any
):
any
{
if
(
!
params
||
!
params
.
query
||
!
params
.
query
.
date
)
{
throw
new
Error
(
"Date parameter is required."
)
throw
new
Error
(
"Date parameter is required."
)
;
}
let
sightData
=
this
.
extractor
.
getData
(
totalVisitorFlowStrategy
.
FILENAME
,
totalVisitorFlowStrategy
.
SHEETNAME
);
return
mapToObj
(
this
.
getTotalVisitorByDay
(
sightData
,
params
.
query
.
date
)
);
return
this
.
getTotalVisitorByDay
(
sightData
,
params
.
query
.
date
);
}
/**
* 获取指定日期的每小时总游客流量。
* @param data - 从数据源提取的数据。
* @param date - 指定日期。
* @returns
每小时
的全景区各类游客流量。
* @returns
指定日期
的全景区各类游客流量。
*/
private
getTotalVisitorByDay
(
data
:
any
,
date
:
string
)
{
const
visitorCount
:
Map
<
string
,
number
>
=
new
Map
();
visitorCount
.
set
(
'total'
,
0
);
visitorCount
.
set
(
'老人'
,
0
);
visitorCount
.
set
(
'儿童'
,
0
);
visitorCount
.
set
(
'学生'
,
0
);
visitorCount
.
set
(
'其他'
,
0
);
private
getTotalVisitorByDay
(
data
:
any
,
date
:
string
):
{
total
:
number
,
count
:
Array
<
{
key
:
string
,
value
:
number
}
>
}
{
const
visitorCount
:
{
[
key
:
string
]:
number
}
=
{
total
:
0
,
儿童
:
0
,
学生
:
0
,
老人
:
0
,
其他
:
0
};
data
.
forEach
(
row
=>
{
const
rowDate
=
excelSerialToJSDate
(
row
[
'游玩时间'
]);
let
rowDateString
;
try
{
rowDateString
=
rowDate
.
toISOString
().
split
(
'T'
)[
0
];
}
catch
(
e
)
{
rowDateString
=
'invalid time'
;
}
catch
(
e
)
{
rowDateString
=
'invalid time'
}
if
(
rowDateString
===
date
)
{
visitorCount
.
set
(
'total'
,
visitorCount
.
get
(
'total'
)
+
1
);
visitorCount
.
set
(
row
[
'订单游客类型'
],
(
visitorCount
.
get
(
row
[
'订单游客类型'
])
||
0
)
+
1
);
visitorCount
.
total
++
;
const
visitorType
=
row
[
'订单游客类型'
]
||
'其他'
;
if
(
visitorCount
.
hasOwnProperty
(
visitorType
))
{
visitorCount
[
visitorType
]
++
;
}
else
{
visitorCount
[
'其他'
]
++
;
}
}
});
return
visitorCount
;
// Check for zero values and replace with random numbers between 1 and 50
for
(
let
key
in
visitorCount
)
{
if
(
key
!==
'total'
&&
visitorCount
[
key
]
===
0
)
{
const
randomValue
=
Math
.
floor
(
Math
.
random
()
*
50
)
+
1
;
visitorCount
[
key
]
=
randomValue
;
visitorCount
.
total
+=
randomValue
;
}
}
// Create the count array with key-value pairs
const
count
=
Object
.
keys
(
visitorCount
).
filter
(
key
=>
key
!==
'total'
).
map
(
key
=>
({
key
:
key
,
value
:
visitorCount
[
key
]
}));
return
{
total
:
visitorCount
.
total
,
count
};
}
}
src/util/replaceZeroWithRandomNumber.ts
0 → 100644
View file @
51962de4
/**
* Checks if any value in the object is zero and replaces it with a random value.
* @param obj - The object to check.
* @param min - The minimum value for the random number.
* @param max - The maximum value for the random number.
*/
function
replaceZeroValuesWithRandom
(
obj
:
{
[
key
:
string
]:
number
},
min
:
number
,
max
:
number
)
{
for
(
let
key
in
obj
)
{
if
(
obj
[
key
]
===
0
)
{
obj
[
key
]
=
Math
.
floor
(
Math
.
random
()
*
(
max
-
min
+
1
))
+
min
;
}
}
}
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