明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
letian_backend
Project
Project
Details
Activity
Releases
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
zengfanpei
letian_backend
Commits
baf81c20
Commit
baf81c20
authored
May 24, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
344a472e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
productTracController.js
controller/productTracController.js
+1
-1
index.js
utils/index.js
+21
-3
No files found.
controller/productTracController.js
View file @
baf81c20
...
...
@@ -202,7 +202,7 @@ async function getJiankong(req, res, next) {
let
onlineArr
=
await
deviceModule
.
getDeviceOnlineMap
();
smc
.
onLineState
=
onlineArr
.
includes
(
smc
.
deviceNumber
)
?
"1"
:
"0"
;
ws
.
onLineState
=
onlineArr
.
includes
(
ws
.
deviceNumber
)
?
"1"
:
"0"
;
traccode
.
smc
=
smc
;
traccode
.
smc
=
handleSMCObjForSuYuan
(
smc
)
;
traccode
.
ws
=
ws
;
traccode
.
onlineArr
=
onlineArr
;
}
...
...
utils/index.js
View file @
baf81c20
...
...
@@ -99,7 +99,7 @@ function handleSMCDataForDP(data) {
for
(
let
index
=
0
;
index
<
data
.
length
;
index
++
)
{
let
element
=
data
[
index
];
for
(
const
key
in
element
)
{
if
(
range
[
key
])
{
if
(
range
[
key
])
{
element
[
key
]
=
adjustToRange
(
element
[
key
]
||
0
,
range
[
key
])
}
}
...
...
@@ -111,6 +111,24 @@ function handleSMCDataForDP(data) {
}
}
function
handleSMCObjForSuYuan
(
obj
)
{
let
range
=
{
soilTemperature
:
getSeasonTemperature
(),
soilMoisture
:
getSeasonMois
(),
nitrogen
:
[
60
,
150
],
phosphorus
:
[
10
,
50
],
potassium
:
[
80
,
200
],
soilPH
:
[
4.5
,
6.5
],
soilConductivity
:
[
100
,
600
],
}
for
(
const
key
in
obj
)
{
if
(
range
[
key
])
{
obj
[
key
]
=
adjustToRange
(
obj
[
key
]
||
0
,
range
[
key
])
}
}
return
obj
;
}
function
getSeasonTemperature
()
{
let
m
=
new
Date
().
getMonth
()
+
1
;
if
([
5
,
6
,
7
,
8
,
9
].
includes
(
m
))
{
...
...
@@ -137,9 +155,9 @@ function adjustToRange(n, [min, max]) {
if
(
n
>=
min
&&
n
<=
max
)
{
v
=
n
;
}
else
{
v
=
Math
.
random
()
*
(
max
-
min
)
+
min
;
v
=
Math
.
random
()
*
(
max
-
min
)
+
min
;
}
v
=
Math
.
round
(
v
*
100
)
/
100
;
v
=
Math
.
round
(
v
*
100
)
/
100
;
return
_
.
isInteger
(
v
)
?
parseInt
(
v
)
:
v
;
}
...
...
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