明树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
804b2e0c
Commit
804b2e0c
authored
Oct 25, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
fd8e7f34
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
63 deletions
+71
-63
agrInputEmployController.js
controller/agrInputEmployController.js
+7
-13
agrInputOtherController.js
controller/agrInputOtherController.js
+10
-13
agrInputRecordController.js
controller/agrInputRecordController.js
+10
-6
deviceController.js
controller/deviceController.js
+11
-0
letianAgrInputEmploy.js
db/models/letianAgrInputEmploy.js
+10
-22
letianAgrInputOther.js
db/models/letianAgrInputOther.js
+8
-4
agrRouter.js
router/agrRouter.js
+1
-0
deviceRouter.js
router/deviceRouter.js
+1
-1
fileRouter.js
router/fileRouter.js
+13
-4
No files found.
controller/agrInputEmployController.js
View file @
804b2e0c
...
...
@@ -65,28 +65,22 @@ async function importExcel(req, res, next) {
let
arr
=
[];
for
(
let
index
=
2
;
index
<=
worksheet
.
actualRowCount
;
index
++
)
{
let
values
=
worksheet
.
getRow
(
index
).
values
;
console
.
log
(
values
)
let
obj
=
{
creator
:
req
.
user
.
_id
,
time
:
values
[
1
],
agrProName
:
values
[
2
],
name
:
values
[
3
],
type
:
values
[
4
],
total
:
values
[
5
],
unit
:
values
[
6
],
totalCost
:
values
[
7
],
dilutionRatio
:
values
[
8
],
waterConsumption
:
values
[
9
],
area
:
values
[
10
],
dosage
:
values
[
11
],
land
:
values
[
12
],
notes
:
values
[
13
],
empDetails
:
values
[
3
],
peopleNum
:
Number
(
values
[
4
])
||
null
,
halfDayFee
:
Number
(
values
[
5
])
||
null
,
laborFee
:
Number
(
values
[
6
])
||
null
,
}
if
(
obj
.
time
&&
obj
.
agrProName
)
{
if
(
obj
.
time
)
{
arr
.
push
(
obj
)
}
}
if
(
arr
.
length
)
{
await
DB
.
AgrInputEmploy
.
insertMany
(
arr
);
//
await DB.AgrInputEmploy.insertMany(arr);
}
res
.
sendData
(
arr
);
}
catch
(
error
)
{
...
...
controller/agrInputOtherController.js
View file @
804b2e0c
...
...
@@ -68,20 +68,17 @@ async function importExcel(req, res, next) {
let
obj
=
{
creator
:
req
.
user
.
_id
,
time
:
values
[
1
],
agrProName
:
values
[
2
],
name
:
values
[
3
],
type
:
values
[
4
],
total
:
values
[
5
],
unit
:
values
[
6
],
totalCost
:
values
[
7
],
dilutionRatio
:
values
[
8
],
waterConsumption
:
values
[
9
],
area
:
values
[
10
],
dosage
:
values
[
11
],
land
:
values
[
12
],
notes
:
values
[
13
],
name
:
values
[
2
],
spec
:
values
[
3
],
buyNum
:
Number
(
values
[
4
])
||
null
,
buyUnit
:
values
[
5
],
unitPrice
:
Number
(
values
[
6
])
||
null
,
taxAmount
:
Number
(
values
[
7
])
||
null
,
totalAmount
:
Number
(
values
[
8
])
||
null
,
agent
:
values
[
9
],
notes
:
values
[
10
],
}
if
(
obj
.
time
&&
obj
.
agrProName
)
{
if
(
obj
.
time
)
{
arr
.
push
(
obj
)
}
}
...
...
controller/agrInputRecordController.js
View file @
804b2e0c
...
...
@@ -15,6 +15,9 @@ async function list(req, res, next) {
let
page
=
req
.
body
.
page
||
1
;
let
pageSize
=
req
.
body
.
pageSize
||
10
;
let
skip
=
(
page
-
1
)
*
pageSize
;
if
(
req
.
body
.
agrProName
)
{
search
.
agrProName
=
req
.
body
.
agrProName
;
}
let
count
=
await
DB
.
AgrInputRecord
.
countDocuments
(
search
)
let
list
=
await
DB
.
AgrInputRecord
.
find
(
search
).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
res
.
sendData
({
count
,
list
});
...
...
@@ -38,15 +41,16 @@ async function updateOne(req, res, next) {
let
updateInfo
=
{
...
req
.
body
,
}
let
ret
=
await
DB
.
AgrInputRecord
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
updateInfo
);
let
ret
=
await
DB
.
AgrInputRecord
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
updateInfo
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
)
}
}
async
function
deleteOne
(
req
,
res
,
next
)
{
try
{
let
ret
=
await
DB
.
AgrInputRecord
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
{
del
:
1
});
let
ret
=
await
DB
.
AgrInputRecord
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
{
del
:
1
});
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
)
...
...
@@ -71,7 +75,7 @@ async function importExcel(req, res, next) {
agrProName
:
values
[
2
],
name
:
values
[
3
],
type
:
values
[
4
],
total
:
values
[
5
]
,
total
:
Number
(
values
[
5
])
||
0
,
unit
:
values
[
6
],
totalCost
:
values
[
7
],
dilutionRatio
:
values
[
8
],
...
...
@@ -81,11 +85,11 @@ async function importExcel(req, res, next) {
land
:
values
[
12
],
notes
:
values
[
13
],
}
if
(
obj
.
time
&&
obj
.
agrProName
)
{
if
(
obj
.
time
&&
obj
.
agrProName
)
{
arr
.
push
(
obj
)
}
}
if
(
arr
.
length
)
{
if
(
arr
.
length
)
{
await
DB
.
AgrInputRecord
.
insertMany
(
arr
);
}
res
.
sendData
(
arr
);
...
...
controller/deviceController.js
View file @
804b2e0c
...
...
@@ -91,6 +91,16 @@ async function getDevice(req, res, next) {
next
(
error
);
}
}
async
function
crateDevice
(
req
,
res
,
next
)
{
try
{
let
body
=
req
.
body
;
let
ret
=
await
DB
.
Device
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
test
(
req
,
res
,
next
)
{
try
{
...
...
@@ -207,6 +217,7 @@ module.exports = {
list
,
updateDevice
,
getDevice
,
crateDevice
,
listAttribute
,
setThreshold
,
...
...
db/models/letianAgrInputEmploy.js
View file @
804b2e0c
...
...
@@ -14,37 +14,25 @@ const letianAgrInputEmploySchema = new Schema({
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
comment
:
"日期"
,
},
n
ame
:
{
agrProN
ame
:
{
type
:
String
,
commnet
:
"
类别/
名称"
,
commnet
:
"
农产品
名称"
,
},
spec
:
{
empDetails
:
{
type
:
String
,
commnet
:
"
规格
"
,
commnet
:
"
用工详情
"
,
},
buy
Num
:
{
people
Num
:
{
type
:
Number
,
comment
:
"
数量
"
comment
:
"
人数
"
},
unitPric
e
:
{
halfDayFe
e
:
{
type
:
Number
,
comment
:
"
单
价(元)"
comment
:
"
半天工
价(元)"
},
taxAmount
:
{
laborFee
:
{
type
:
Number
,
comment
:
"税额(元)"
},
totalAmount
:
{
type
:
Number
,
comment
:
"总额(元)"
},
agent
:
{
type
:
String
,
comment
:
"代理商/厂家"
},
notes
:
{
type
:
String
,
comment
:
"备注"
comment
:
"劳务费(元)"
},
creator
:
{
...
...
db/models/letianAgrInputOther.js
View file @
804b2e0c
...
...
@@ -26,6 +26,10 @@ const letianAgrInputOtherSchema = new Schema({
type
:
Number
,
comment
:
"数量"
},
buyUnit
:
{
type
:
String
,
comment
:
"单位"
},
unitPrice
:
{
type
:
Number
,
comment
:
"单价(元)"
...
...
router/agrRouter.js
View file @
804b2e0c
...
...
@@ -10,6 +10,7 @@ const agrInputEmployController = require('../controller/agrInputEmployController
// excel采集信息上传 甲方要求
//1. 青皮柚农业投入品使用情况
router
.
post
(
'/input/list'
,
agrInputRecordController
.
list
);
router
.
post
(
'/inputRecord/list'
,
agrInputRecordController
.
list
);
router
.
post
(
'/inputRecord/update'
,
agrInputRecordController
.
updateOne
);
router
.
post
(
'/inputRecord/delete'
,
agrInputRecordController
.
deleteOne
);
router
.
post
(
'/inputRecord/create'
,
agrInputRecordController
.
create
);
...
...
router/deviceRouter.js
View file @
804b2e0c
...
...
@@ -6,7 +6,7 @@ const router = express.Router();
const
deviceController
=
require
(
'../controller/deviceController'
);
// router.post('/create', deviceController.
);
router
.
post
(
'/create'
,
deviceController
.
crateDevice
);
router
.
post
(
'/info'
,
deviceController
.
getDevice
);
router
.
post
(
'/update'
,
deviceController
.
updateDevice
);
router
.
post
(
'/list'
,
deviceController
.
list
);
//获取平行列表
...
...
router/fileRouter.js
View file @
804b2e0c
...
...
@@ -47,13 +47,22 @@ router.post('/batch/upload', upload.array('files'), fileController.batchUpload);
/**
* excel导入
*/
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
controller
=
require
(
`../controller/
${
modelName
}
Controller`
);
let
modelMap
=
{
'agrInputRecord'
:
"agrInputRecordController"
,
'agrInputOther'
:
"agrInputOtherController"
,
'agrInputDetail'
:
"agrInputDetailController"
,
'agrInputEmploy'
:
"agrInputEmployController"
,
}
let
controller
=
require
(
`../controller/
${
modelMap
[
modelName
]}
`
);
await
controller
.
importExcel
(
req
,
res
,
next
);
});
router
.
post
(
'/:modelName/exportExcel'
,
async
(
req
,
res
,
next
)
=>
{
/**
* excel导出
*/
router
.
post
(
'/:modelName/exportExcel'
,
async
(
req
,
res
,
next
)
=>
{
let
modelName
=
req
.
params
.
modelName
;
let
modelMap
=
{
'IPS'
:
"collectIPSController"
,
...
...
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