明树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
ac4ef43f
Commit
ac4ef43f
authored
Oct 09, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
d21cf64a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
59 deletions
+60
-59
initController.js
controller/initController.js
+58
-58
ecosystem.config.js
ecosystem.config.js
+1
-0
server.js
server.js
+1
-1
No files found.
controller/initController.js
View file @
ac4ef43f
...
@@ -35,68 +35,68 @@ async function init(req, res) {
...
@@ -35,68 +35,68 @@ async function init(req, res) {
await
DB
.
CollectAttribute
.
findOneAndUpdate
({
dbKey
:
element
.
dbKey
},
element
,
{
upsert
:
true
});
await
DB
.
CollectAttribute
.
findOneAndUpdate
({
dbKey
:
element
.
dbKey
},
element
,
{
upsert
:
true
});
}
}
// 土壤
//
//
土壤
for
(
let
index
=
0
;
index
<
20
;
index
++
)
{
//
for (let index = 0; index < 20; index++) {
await
DB
.
CollectSMC
.
findOneAndUpdate
({
time
:
moment
(
'2024-08-26'
).
add
(
index
,
'day'
)
},
{
//
await DB.CollectSMC.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
id
:
8746
,
//
id: 8746,
name
:
"设备名称修改测试"
,
//
name: "设备名称修改测试",
deviceNumber
:
"16A67205BA3A"
,
//
deviceNumber: "16A67205BA3A",
time
:
moment
(
'2024-08-26'
).
add
(
index
,
'day'
),
//
time: moment('2024-08-26').add(index, 'day'),
soilTemperature
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
soilTemperature: 11 + Math.floor(Math.random() * 20),
soilMoisture
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
soilMoisture: 11 + Math.floor(Math.random() * 20),
nitrogen
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
nitrogen: 11 + Math.floor(Math.random() * 20),
phosphorus
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
phosphorus: 11 + Math.floor(Math.random() * 20),
potassium
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
potassium: 11 + Math.floor(Math.random() * 20),
soilPH
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
soilPH: 11 + Math.floor(Math.random() * 20),
soilConductivity
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
soilConductivity: 11 + Math.floor(Math.random() * 20),
},
{
upsert
:
true
})
//
}, { upsert: true })
}
//
}
//气象
//气象
for
(
let
index
=
0
;
index
<
20
;
index
++
)
{
//
for (let index = 0; index < 20; index++) {
await
DB
.
CollectWS
.
findOneAndUpdate
({
time
:
moment
(
'2024-08-26'
).
add
(
index
,
'day'
)
},
{
//
await DB.CollectWS.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
id
:
8746
,
//
id: 8746,
name
:
"气象站"
,
//
name: "气象站",
deviceNumber
:
"1111111111111"
,
//
deviceNumber: "1111111111111",
time
:
moment
(
'2024-08-26'
).
add
(
index
,
'day'
),
//
time: moment('2024-08-26').add(index, 'day'),
windSpeed
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
windSpeed: 11 + Math.floor(Math.random() * 20),
windDirection
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
windDirection: 11 + Math.floor(Math.random() * 20),
rainfall
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
),
//
rainfall: 11 + Math.floor(Math.random() * 20),
},
{
upsert
:
true
})
//
}, { upsert: true })
}
//
}
// 虫情
// 虫情
for
(
let
index
=
0
;
index
<
20
;
index
++
)
{
//
for (let index = 0; index < 20; index++) {
let
dataId
=
new
mongoose
.
Types
.
ObjectId
()
//
let dataId = new mongoose.Types.ObjectId()
let
data
=
await
DB
.
CollectIPS
.
create
({
//
let data = await DB.CollectIPS.create({
_id
:
dataId
,
//
_id: dataId,
id
:
8746
,
//
id: 8746,
name
:
"虫情系统"
,
//
name: "虫情系统",
deviceNumber
:
"FF35d4072d53"
,
//
deviceNumber: "FF35d4072d53",
time
:
moment
(
'2024-08-26'
).
add
(
index
,
'day'
),
//
time: moment('2024-08-26').add(index, 'day'),
downloadUrl
:
"pictures/FF35D4072D53/2024-08-20-15-03-43.jpg"
,
//
downloadUrl: "pictures/FF35D4072D53/2024-08-20-15-03-43.jpg",
newTime
:
moment
(
'2024-08-26'
).
add
(
index
,
'day'
),
//
newTime: moment('2024-08-26').add(index, 'day'),
newCount
:
11
+
Math
.
floor
(
Math
.
random
()
*
20
)
//
newCount: 11 + Math.floor(Math.random() * 20)
});
//
});
let
typeId
=
new
mongoose
.
Types
.
ObjectId
()
//
let typeId = new mongoose.Types.ObjectId()
let
type
=
await
DB
.
CollectIPSType
.
create
({
_id
:
typeId
,
name
:
"虫子"
+
index
});
//
let type = await DB.CollectIPSType.create({ _id: typeId, name: "虫子" + index });
let
planId
=
new
mongoose
.
Types
.
ObjectId
()
//
let planId = new mongoose.Types.ObjectId()
let
plan
=
await
DB
.
CollectIPSPlan
.
create
({
_id
:
planId
,
name
:
"虫子"
+
index
,
controlPlan
:
"防治建议"
+
index
});
//
let plan = await DB.CollectIPSPlan.create({ _id: planId, name: "虫子" + index, controlPlan: "防治建议" + index });
await
DB
.
CollectIPSResult
.
findOneAndUpdate
({
data
:
dataId
},
{
//
await DB.CollectIPSResult.findOneAndUpdate({ data: dataId }, {
deviceNumber
:
"FF35d4072d53"
,
//
deviceNumber: "FF35d4072d53",
name
:
"虫子"
+
index
,
//
name: "虫子" + index,
count
:
1
+
Math
.
floor
(
Math
.
random
()
*
10
),
//
count: 1 + Math.floor(Math.random() * 10),
time
:
moment
(
'2024-08-26'
).
add
(
index
,
'day'
),
//
time: moment('2024-08-26').add(index, 'day'),
type
:
typeId
,
//
type: typeId,
plan
:
planId
,
//
plan: planId,
data
:
dataId
,
//
data: dataId,
},
{
upsert
:
true
});
//
}, { upsert: true });
}
//
}
res
.
sendData
({})
res
.
sendData
({})
}
}
...
...
ecosystem.config.js
View file @
ac4ef43f
...
@@ -13,6 +13,7 @@ module.exports = {
...
@@ -13,6 +13,7 @@ module.exports = {
},
},
env_production
:
{
env_production
:
{
NODE_ENV
:
"production"
,
NODE_ENV
:
"production"
,
PORT
:
3000
},
},
log_date_format
:
"YYYY-MM-DD HH:mm:ss"
,
log_date_format
:
"YYYY-MM-DD HH:mm:ss"
,
out_file
:
`/srv/letian/logs/
${
curDateStr
}
.log`
,
out_file
:
`/srv/letian/logs/
${
curDateStr
}
.log`
,
...
...
server.js
View file @
ac4ef43f
...
@@ -76,5 +76,5 @@ app.use(function (err, req, res, next) {
...
@@ -76,5 +76,5 @@ app.use(function (err, req, res, next) {
const
server
=
require
(
'http'
).
createServer
(
app
);
const
server
=
require
(
'http'
).
createServer
(
app
);
server
.
listen
(
process
.
env
.
PORT
||
3000
,
function
()
{
server
.
listen
(
process
.
env
.
PORT
||
3000
,
function
()
{
console
.
log
(
`****** server is listening :
${
process
.
env
.
PORT
}
`
);
console
.
log
(
`****** server is listening :
${
process
.
env
.
PORT
}
|| 3000
`
);
});
});
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