明树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
2fa8ce2f
Commit
2fa8ce2f
authored
Oct 21, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
47580fc1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
2 deletions
+69
-2
excelController.js
controller/excelController.js
+27
-0
letianExcel.js
db/models/letianExcel.js
+39
-0
collectIPSModule.js
module/collectIPSModule.js
+0
-1
fileRouter.js
router/fileRouter.js
+3
-1
No files found.
controller/excelController.js
0 → 100644
View file @
2fa8ce2f
const
path
=
require
(
'path'
);
const
fs
=
require
(
'fs'
);
const
_
=
require
(
'lodash'
);
const
moment
=
require
(
'moment'
);
async
function
exportExcel
(
req
,
res
,
next
)
{
let
modelName
=
req
.
params
.
modelName
;
let
modelMap
=
{
'IPS'
:
"CollectIPS"
,
'SMC'
:
"CollectSMC"
,
'WS'
:
"CollectWS"
,
}
}
module
.
exports
=
{
exportExcel
}
\ No newline at end of file
db/models/letianExcel.js
0 → 100644
View file @
2fa8ce2f
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
/**
* 地块 --- 园区 ---- 乡镇(这个等级暂时不做)
*/
const
ExcelSchema
=
new
Schema
({
creator
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'User'
},
type
:
{
type
:
Number
,
comment
:
"1. 导入 2, 导出"
},
excelUrl
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
},
modleName
:
String
,
search
:
{
type
:
Object
},
createdAt
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
},
updatedAt
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
},
del
:
{
type
:
Number
,
default
:
0
,
comment
:
'默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
}
},
{
toJSON
:
{
getters
:
true
}
});
const
letianExcel
=
mongoose
.
model
(
'letianExcel'
,
ExcelSchema
,
'letianExcel'
);
module
.
exports
=
letianExcel
;
\ No newline at end of file
module/collectIPSModule.js
View file @
2fa8ce2f
...
@@ -36,7 +36,6 @@ async function insertHQData(data) {
...
@@ -36,7 +36,6 @@ async function insertHQData(data) {
let
check
=
await
DB
.
CollectIPS
.
findOne
({
newTime
:
data
.
newTime
});
let
check
=
await
DB
.
CollectIPS
.
findOne
({
newTime
:
data
.
newTime
});
if
(
!
check
)
{
if
(
!
check
)
{
let
ret
=
await
DB
.
CollectIPS
.
create
(
data
);
let
ret
=
await
DB
.
CollectIPS
.
create
(
data
);
ret
.
results
=
'蚊子:1'
handleIPSResult
(
ret
);
handleIPSResult
(
ret
);
}
}
}
}
...
...
router/fileRouter.js
View file @
2fa8ce2f
...
@@ -10,6 +10,7 @@ const moment = require('moment');
...
@@ -10,6 +10,7 @@ const moment = require('moment');
const
mongoose
=
require
(
'mongoose'
);
const
mongoose
=
require
(
'mongoose'
);
const
fileController
=
require
(
'../controller/fileController'
);
const
fileController
=
require
(
'../controller/fileController'
);
const
excelController
=
require
(
'../controller/excelController'
);
const
storage
=
multer
.
diskStorage
({
const
storage
=
multer
.
diskStorage
({
...
@@ -50,8 +51,9 @@ router.post('/batch/upload', upload.array('files'), fileController.batchUpload);
...
@@ -50,8 +51,9 @@ router.post('/batch/upload', upload.array('files'), fileController.batchUpload);
router
.
post
(
'/:modelName/importExcel'
,
upload
.
single
(
'file'
),
async
(
req
,
res
,
next
)
=>
{
router
.
post
(
'/:modelName/importExcel'
,
upload
.
single
(
'file'
),
async
(
req
,
res
,
next
)
=>
{
let
modelName
=
req
.
params
.
modelName
;
let
modelName
=
req
.
params
.
modelName
;
let
controller
=
require
(
`../controller/
${
modelName
}
Controller`
);
let
controller
=
require
(
`../controller/
${
modelName
}
Controller`
);
console
.
log
(
modelName
,)
await
controller
.
importExcel
(
req
,
res
,
next
);
await
controller
.
importExcel
(
req
,
res
,
next
);
});
});
router
.
post
(
'/:modelName/exportExcel'
,
excelController
.
exportExcel
);
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