明树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
4410f7d5
Commit
4410f7d5
authored
Oct 21, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
0ebe4021
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
8 deletions
+62
-8
excelRecordController.js
controller/excelRecordController.js
+39
-0
excelCron.js
cron/excelCron.js
+2
-2
index.js
cron/index.js
+6
-6
excelrecordRouter.js
router/excelrecordRouter.js
+13
-0
index.js
router/index.js
+2
-0
No files found.
controller/excelRecordController.js
0 → 100644
View file @
4410f7d5
const
_
=
require
(
'lodash'
);
const
moment
=
require
(
'moment'
);
const
errorMessage
=
require
(
'../utils/errorMessage'
);
async
function
list
(
req
,
res
,
next
)
{
try
{
let
search
=
{
del
:
0
};
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
]
}
}
let
page
=
req
.
body
.
page
||
1
;
let
pageSize
=
req
.
body
.
pageSize
||
10
;
let
skip
=
(
page
-
1
)
*
pageSize
;
let
count
=
await
DB
.
ExcelRecord
.
countDocuments
(
search
);
let
list
=
await
DB
.
ExcelRecord
.
find
(
search
).
skip
(
skip
).
limit
(
pageSize
).
populate
({
path
:
'creator'
,
select
:
"mobile name"
}).
populate
({
path
:
'excelUrl'
}).
lean
().
exec
();
res
.
sendData
({
count
,
list
})
}
catch
(
error
)
{
next
(
error
);
}
}
module
.
exports
=
{
list
}
\ No newline at end of file
cron/excelCron.js
View file @
4410f7d5
...
...
@@ -19,7 +19,7 @@ const ExcelJS = require('exceljs');
const
fs
=
require
(
'fs'
);
exportExcel
()
//
exportExcel()
async
function
exportExcel
()
{
let
info
=
await
DB
.
ExcelRecord
.
findOne
({
type
:
2
,
status
:
1
});
...
...
@@ -62,7 +62,7 @@ async function exportExcel() {
mimetype
:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
,
filename
:
name
+
'.xlsx'
,
path
:
excelUrl
,
// size: req.file.size
,
nginxpath
:
_
.
last
(
String
(
req
.
file
.
path
).
split
(
'/mnt/vdb1'
))
,
type
:
2
,
});
// 3. 更新任务结果
...
...
cron/index.js
View file @
4410f7d5
...
...
@@ -77,10 +77,10 @@ const cron = () => {
// 获取设备上述设备 4 采集信息
if
(
sysConfig
&&
sysConfig
.
cron
&&
sysConfig
.
cron
.
collectDeviceInfo
4
)
{
if
(
sysConfig
&&
sysConfig
.
cron
&&
sysConfig
.
cron
.
collectDeviceInfo
)
{
console
.
log
(
"collectDeviceInfo4:"
,
new
Date
());
new
nodeCron
.
schedule
(
'1 */
1
* * * *'
,
async
()
=>
{
new
nodeCron
.
schedule
(
'1 */
3
* * * *'
,
async
()
=>
{
await
ipsCron
.
collectDeviceInfo4
({
deviceHQType
:
4
});
},
{
timezone
:
"Asia/Shanghai"
});
}
...
...
@@ -89,10 +89,10 @@ const cron = () => {
if
(
sysConfig
&&
sysConfig
.
cron
&&
sysConfig
.
cron
.
excel
)
{
console
.
log
(
"excel:"
,
new
Date
());
//
new nodeCron.schedule('1 */1 * * * *', async () => {
//
console.log(new Date().getTime())
//
await excelCron.exportExcel();
//
}, { timezone: "Asia/Shanghai" });
new
nodeCron
.
schedule
(
'1 */1 * * * *'
,
async
()
=>
{
console
.
log
(
new
Date
().
getTime
())
await
excelCron
.
exportExcel
();
},
{
timezone
:
"Asia/Shanghai"
});
}
}
...
...
router/excelrecordRouter.js
0 → 100644
View file @
4410f7d5
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
excelRecordController
=
require
(
'../controller/excelRecordController'
);
router
.
post
(
'/list'
,
excelRecordController
.
list
);
module
.
exports
=
router
;
\ No newline at end of file
router/index.js
View file @
4410f7d5
...
...
@@ -18,6 +18,7 @@ const agrInputRouter = require('./agrRouter');
const
statisticsRouter
=
require
(
'./statisticsRouter'
);
const
flowRouter
=
require
(
'./flowRouter'
);
const
excelrecordRouter
=
require
(
'./excelrecordRouter'
);
router
.
use
(
'/user'
,
userRouter
);
// 用户 角色
...
...
@@ -41,6 +42,7 @@ router.use('/statistics', statisticsRouter); // 统计 大屏
router
.
use
(
'/flow'
,
flowRouter
);
router
.
use
(
'/excelrecord'
,
excelrecordRouter
);
...
...
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