明树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
47580fc1
Commit
47580fc1
authored
Oct 21, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
417de00f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
112 deletions
+27
-112
collectIPSController.js
controller/collectIPSController.js
+26
-1
initController.js
controller/initController.js
+0
-108
excelModule.js
module/excelModule.js
+0
-0
collectRouter.js
router/collectRouter.js
+1
-0
index.js
router/index.js
+0
-3
No files found.
controller/collectIPSController.js
View file @
47580fc1
...
...
@@ -104,7 +104,31 @@ async function test(req, res, next) {
async
function
exportExcel
(
req
,
res
,
next
)
{
try
{
let
search
=
{
del
:
0
};
if
(
req
.
body
.
name
)
{
search
.
name
=
{
$regex
:
req
.
body
.
name
}
}
if
(
req
.
body
.
startTime
)
{
search
.
time
=
search
.
time
||
{};
search
.
time
.
$gte
=
req
.
body
.
startTime
;
}
if
(
req
.
body
.
endTime
)
{
search
.
time
=
search
.
time
||
{};
search
.
time
.
$lte
=
req
.
body
.
endTime
}
if
(
_
.
isArray
(
req
.
body
.
time
)
&&
req
.
body
.
time
.
length
==
2
)
{
search
.
time
=
{
$lte
:
req
.
body
.
time
[
1
],
$gte
:
req
.
body
.
time
[
0
]
}
}
}
catch
(
error
)
{
next
(
error
);
}
}
...
...
@@ -116,4 +140,5 @@ module.exports = {
queryInfo
,
updateInfo
,
delInfo
,
exportExcel
}
\ No newline at end of file
controller/initController.js
deleted
100644 → 0
View file @
417de00f
const
moment
=
require
(
'moment'
);
const
mongoose
=
require
(
'mongoose'
);
async
function
init
(
req
,
res
)
{
// 1. 初始化数据采集属性
let
attrs
=
[
{
deviceKey
:
"温度"
,
dbKey
:
"soilTemperature"
,
name
:
"土壤温度"
},
{
deviceKey
:
"湿度"
,
dbKey
:
"soilMoisture"
,
name
:
"土壤湿度"
},
{
deviceKey
:
"氮"
,
dbKey
:
"nitrogen"
,
name
:
"氮"
},
{
deviceKey
:
"磷"
,
dbKey
:
"phosphorus"
,
name
:
"磷"
},
{
deviceKey
:
"钾"
,
dbKey
:
"potassium"
,
name
:
"钾"
},
{
deviceKey
:
"PH"
,
dbKey
:
"soilPH"
,
name
:
"土壤PH值"
},
{
deviceKey
:
"电导率"
,
dbKey
:
"soilConductivity"
,
name
:
"土壤电导率"
},
{
deviceKey
:
"风速"
,
dbKey
:
"windSpeed"
,
name
:
"风速"
},
{
deviceKey
:
"风向"
,
dbKey
:
"windDirection"
,
name
:
"风向"
},
{
deviceKey
:
"雨量"
,
dbKey
:
"rainfall"
,
name
:
"雨量"
},
{
deviceKey
:
"信号强度"
,
dbKey
:
"signalSterngth"
,
name
:
"信号强度"
},
{
deviceKey
:
"错误码"
,
dbKey
:
"errorCode"
,
name
:
"错误码"
},
{
deviceKey
:
"版本号"
,
dbKey
:
"version"
,
name
:
"版本号"
},
]
for
(
let
index
=
0
;
index
<
attrs
.
length
;
index
++
)
{
const
element
=
attrs
[
index
];
await
DB
.
CollectAttribute
.
findOneAndUpdate
({
dbKey
:
element
.
dbKey
},
element
,
{
upsert
:
true
});
}
// // 土壤
// for (let index = 0; index < 20; index++) {
// await DB.CollectSMC.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
// id: 8746,
// name: "设备名称修改测试",
// deviceNumber: "16A67205BA3A",
// time: moment('2024-08-26').add(index, 'day'),
// soilTemperature: 11 + Math.floor(Math.random() * 20),
// soilMoisture: 11 + Math.floor(Math.random() * 20),
// nitrogen: 11 + Math.floor(Math.random() * 20),
// phosphorus: 11 + Math.floor(Math.random() * 20),
// potassium: 11 + Math.floor(Math.random() * 20),
// soilPH: 11 + Math.floor(Math.random() * 20),
// soilConductivity: 11 + Math.floor(Math.random() * 20),
// }, { upsert: true })
// }
//气象
// for (let index = 0; index < 20; index++) {
// await DB.CollectWS.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
// id: 8746,
// name: "气象站",
// deviceNumber: "1111111111111",
// time: moment('2024-08-26').add(index, 'day'),
// windSpeed: 11 + Math.floor(Math.random() * 20),
// windDirection: 11 + Math.floor(Math.random() * 20),
// rainfall: 11 + Math.floor(Math.random() * 20),
// }, { upsert: true })
// }
// 虫情
// for (let index = 0; index < 20; index++) {
// let dataId = new mongoose.Types.ObjectId()
// let data = await DB.CollectIPS.create({
// _id: dataId,
// id: 8746,
// name: "虫情系统",
// deviceNumber: "FF35d4072d53",
// time: moment('2024-08-26').add(index, 'day'),
// downloadUrl: "pictures/FF35D4072D53/2024-08-20-15-03-43.jpg",
// newTime: moment('2024-08-26').add(index, 'day'),
// newCount: 11 + Math.floor(Math.random() * 20)
// });
// let typeId = new mongoose.Types.ObjectId()
// let type = await DB.CollectIPSType.create({ _id: typeId, name: "虫子" + index });
// let planId = new mongoose.Types.ObjectId()
// let plan = await DB.CollectIPSPlan.create({ _id: planId, name: "虫子" + index, controlPlan: "防治建议" + index });
// await DB.CollectIPSResult.findOneAndUpdate({ data: dataId }, {
// deviceNumber: "FF35d4072d53",
// name: "虫子" + index,
// count: 1 + Math.floor(Math.random() * 10),
// time: moment('2024-08-26').add(index, 'day'),
// type: typeId,
// plan: planId,
// data: dataId,
// }, { upsert: true });
// }
res
.
sendData
({})
}
module
.
exports
=
{
init
}
\ No newline at end of file
module/excelModule.js
0 → 100644
View file @
47580fc1
router/collectRouter.js
View file @
47580fc1
...
...
@@ -17,6 +17,7 @@ router.post('/IPS/list', collectIPSController.list); // 翻页列表
router
.
post
(
'/IPS/show'
,
collectIPSController
.
queryInfo
);
// 查询详情
router
.
post
(
'/IPS/update'
,
collectIPSController
.
updateInfo
);
// 更新
router
.
post
(
'/IPS/del'
,
collectIPSController
.
delInfo
);
// 删除
router
.
post
(
'/IPS/exportExcel'
,
collectIPSController
.
exportExcel
);
// 删除
...
...
router/index.js
View file @
47580fc1
...
...
@@ -20,9 +20,6 @@ const statisticsRouter = require('./statisticsRouter');
const
flowRouter
=
require
(
'./flowRouter'
);
const
initController
=
require
(
'../controller/initController'
)
router
.
post
(
'/init'
,
initController
.
init
);
// 后续删除
router
.
use
(
'/user'
,
userRouter
);
// 用户 角色
router
.
use
(
'/depart'
,
departRouter
);
// 部门
router
.
use
(
'/menu'
,
menuRouter
);
//菜单 按钮
...
...
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