明树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
b355af71
Commit
b355af71
authored
Dec 06, 2024
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
38002686
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
8 deletions
+116
-8
statisticsController.js
controller/statisticsController.js
+106
-3
collectDevice.js
db/models/collectDevice.js
+5
-0
collectIQI.js
db/models/collectIQI.js
+2
-2
statisticsRouter.js
router/statisticsRouter.js
+3
-3
No files found.
controller/statisticsController.js
View file @
b355af71
...
@@ -25,7 +25,7 @@ async function getSMCChangeTrend(req, res, next) {
...
@@ -25,7 +25,7 @@ async function getSMCChangeTrend(req, res, next) {
startTime
.
setHours
(
0
);
startTime
.
setHours
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setSeconds
(
0
);
startTime
.
setSeconds
(
0
);
search
.
time
=
{
$gt
:
new
Date
(
req
.
body
.
startTime
)
,
$lte
:
endTime
}
search
.
time
=
{
$gt
:
startTime
,
$lte
:
endTime
}
}
}
if
(
req
.
body
.
land
)
{
if
(
req
.
body
.
land
)
{
let
devs
=
await
DB
.
Device
.
find
({
land
:
req
.
body
.
land
}).
lean
().
exec
();
let
devs
=
await
DB
.
Device
.
find
({
land
:
req
.
body
.
land
}).
lean
().
exec
();
...
@@ -139,7 +139,7 @@ async function getWSChangeTrend(req, res, next) {
...
@@ -139,7 +139,7 @@ async function getWSChangeTrend(req, res, next) {
startTime
.
setHours
(
0
);
startTime
.
setHours
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setSeconds
(
0
);
startTime
.
setSeconds
(
0
);
search
.
time
=
{
$gt
:
new
Date
(
req
.
body
.
startTime
)
,
$lte
:
endTime
}
search
.
time
=
{
$gt
:
startTime
,
$lte
:
endTime
}
}
}
let
aggr
=
[
let
aggr
=
[
{
{
...
@@ -189,7 +189,7 @@ async function getIPSChangeTrend(req, res, next) {
...
@@ -189,7 +189,7 @@ async function getIPSChangeTrend(req, res, next) {
startTime
.
setHours
(
0
);
startTime
.
setHours
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setSeconds
(
0
);
startTime
.
setSeconds
(
0
);
search
.
time
=
{
$gt
:
new
Date
(
req
.
body
.
startTime
)
,
$lte
:
endTime
}
search
.
time
=
{
$gt
:
startTime
,
$lte
:
endTime
}
}
}
let
aggr
=
[
let
aggr
=
[
{
{
...
@@ -360,6 +360,105 @@ async function getAreaDistribution2(req, res, next) {
...
@@ -360,6 +360,105 @@ async function getAreaDistribution2(req, res, next) {
/*---------------------------------工业-------------------------------------------- */
async
function
getIndustryDeviceCount
(
req
,
res
,
next
)
{
try
{
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
getEnvironmentalTrend
(
req
,
res
,
next
)
{
try
{
let
search
=
{
};
if
((
req
.
body
.
startTime
&&
req
.
body
.
endTime
))
{
let
endTime
=
new
Date
(
req
.
body
.
endTime
);
endTime
.
setHours
(
23
);
endTime
.
setMinutes
(
59
);
endTime
.
setSeconds
(
59
);
let
startTime
=
new
Date
(
req
.
body
.
startTime
);
startTime
.
setHours
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setSeconds
(
0
);
search
.
time
=
{
$gt
:
startTime
,
$lte
:
endTime
}
}
let
aggr
=
[
{
$match
:
{
...
search
}
},
{
$group
:
{
_id
:
{
$dateToString
:
{
format
:
"%Y-%m-%d"
,
date
:
"$time"
,
timezone
:
"+08:00"
}
},
// 将时间戳转换为日期字符串
miCcrobialCount
:
{
$avg
:
"$miCcrobialCount"
},
particleConcentration
:
{
$avg
:
"$particleConcentration"
},
chemicalPollutant
:
{
$avg
:
"$chemicalPollutant"
},
}
},
{
$project
:
{
miCcrobialCount
:
{
$round
:
[
"$miCcrobialCount"
,
2
]},
particleConcentration
:
{
$round
:
[
"$particleConcentration"
,
2
]},
chemicalPollutant
:
{
$round
:
[
"$chemicalPollutant"
,
2
]},
}},
{
$sort
:
{
_id
:
1
}
}
];
let
ret
=
await
DB
.
CollectIET
.
aggregate
(
aggr
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
getQualityInfoTrend
(
req
,
res
,
next
)
{
try
{
let
search
=
{
};
if
((
req
.
body
.
startTime
&&
req
.
body
.
endTime
))
{
let
endTime
=
new
Date
(
req
.
body
.
endTime
);
endTime
.
setHours
(
23
);
endTime
.
setMinutes
(
59
);
endTime
.
setSeconds
(
59
);
let
startTime
=
new
Date
(
req
.
body
.
startTime
);
startTime
.
setHours
(
0
);
startTime
.
setMinutes
(
0
);
startTime
.
setSeconds
(
0
);
search
.
time
=
{
$gt
:
startTime
,
$lte
:
endTime
}
}
let
aggr
=
[
{
$match
:
{
...
search
}
},
{
$group
:
{
_id
:
{
$dateToString
:
{
format
:
"%Y-%m-%d"
,
date
:
"$time"
,
timezone
:
"+08:00"
}
},
// 将时间戳转换为日期字符串
water
:
{
$avg
:
"$water"
},
heavyMetal
:
{
$avg
:
"$heavyMetal"
},
impurity
:
{
$avg
:
"$impurity"
},
}
},
{
$project
:
{
water
:
{
$round
:
[
"$water"
,
2
]},
heavyMetal
:
{
$round
:
[
"$heavyMetal"
,
2
]},
impurity
:
{
$round
:
[
"$impurity"
,
2
]},
}},
{
$sort
:
{
_id
:
1
}
}
];
let
ret
=
await
DB
.
CollectIQI
.
aggregate
(
aggr
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
...
@@ -373,4 +472,8 @@ module.exports = {
...
@@ -373,4 +472,8 @@ module.exports = {
getAreaDistribution
,
getAreaDistribution
,
getAreaDistribution2
,
getAreaDistribution2
,
getIndustryDeviceCount
,
getEnvironmentalTrend
,
getQualityInfoTrend
,
}
}
\ No newline at end of file
db/models/collectDevice.js
View file @
b355af71
...
@@ -108,6 +108,11 @@ const deviceSchema = new Schema({
...
@@ -108,6 +108,11 @@ const deviceSchema = new Schema({
comment
:
"用来大屏展示的数据类型-(大屏图): 1 采集点 2 气象站 3 全景相机 4 细节相机"
// 显示数据是写死的 假的
comment
:
"用来大屏展示的数据类型-(大屏图): 1 采集点 2 气象站 3 全景相机 4 细节相机"
// 显示数据是写死的 假的
},
},
// deviceSectorType: {
// type: Number,
// comment: "1, 农业 2 工业"
// },
createdAt
:
{
createdAt
:
{
type
:
Date
,
type
:
Date
,
...
...
db/models/collectIQI.js
View file @
b355af71
...
@@ -112,5 +112,5 @@ const collectIndustryQualityInformationSchema = new Schema({
...
@@ -112,5 +112,5 @@ const collectIndustryQualityInformationSchema = new Schema({
});
});
const
collectIQI
=
mongoose
.
model
(
'collectIQI'
,
collectIndustryQualityInformationSchema
,
'collectIQI'
);
const
CollectIQI
=
mongoose
.
model
(
'CollectIQI'
,
collectIndustryQualityInformationSchema
,
'CollectIQI'
);
module
.
exports
=
collectIQI
;
module
.
exports
=
CollectIQI
;
\ No newline at end of file
\ No newline at end of file
router/statisticsRouter.js
View file @
b355af71
...
@@ -21,11 +21,11 @@ router.post('/getAreaDistribution2', statisticsController.getAreaDistribution2);
...
@@ -21,11 +21,11 @@ router.post('/getAreaDistribution2', statisticsController.getAreaDistribution2);
/**----------------------工业大屏------------------------- */
/**----------------------工业大屏------------------------- */
// 工业大屏-设备数量
// 工业大屏-设备数量
//
router.post('/getIndustryDeviceCount', statisticsController.getIndustryDeviceCount);
router
.
post
(
'/getIndustryDeviceCount'
,
statisticsController
.
getIndustryDeviceCount
);
// 工业大屏-环境监测-近七日变化
// 工业大屏-环境监测-近七日变化
//
router.post('/getEnvironmentalTrend', statisticsController.getEnvironmentalTrend);
router
.
post
(
'/getEnvironmentalTrend'
,
statisticsController
.
getEnvironmentalTrend
);
// 工业大屏-产品质量信息-近七日变化
// 工业大屏-产品质量信息-近七日变化
//
router.post('/getQualityInfoTrend', statisticsController.getQualityInfoTrend);
router
.
post
(
'/getQualityInfoTrend'
,
statisticsController
.
getQualityInfoTrend
);
module
.
exports
=
router
;
module
.
exports
=
router
;
\ No newline at end of file
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