明树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
85fcf5ff
Commit
85fcf5ff
authored
Nov 21, 2024
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7b662bc7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
438 additions
and
9 deletions
+438
-9
dev.json
config/dev.json
+2
-1
plantContoller.js
controller/plantContoller.js
+166
-0
index.js
cron/index.js
+12
-0
plantWarnCron.js
cron/plantWarnCron.js
+12
-0
index.js
db/index.js
+7
-0
letianPlantCycle.js
db/models/letianPlantCycle.js
+17
-8
letianProductDeep.js
db/models/letianProductDeep.js
+73
-0
letianProductPlant.js
db/models/letianProductPlant.js
+60
-0
letianProductPre.js
db/models/letianProductPre.js
+72
-0
plantRouter.js
router/plantRouter.js
+17
-0
No files found.
config/dev.json
View file @
85fcf5ff
...
...
@@ -38,6 +38,7 @@
"getAllDevice"
:
false
,
"collectDeviceInfo"
:
false
,
"collectDeviceInfo4"
:
false
,
"excel"
:
false
"excel"
:
false
,
"plantearlywarning"
:
false
}
}
\ No newline at end of file
controller/plantContoller.js
View file @
85fcf5ff
...
...
@@ -27,6 +27,7 @@ async function listPlantCycle(req, res, next) {
async
function
createPlantCycle
(
req
,
res
,
next
)
{
try
{
const
body
=
req
.
body
;
console
.
log
(
body
,
"===="
)
let
ret
=
await
DB
.
PlantCycle
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
...
...
@@ -121,8 +122,161 @@ async function updatePlan(req, res, next) {
}
}
/**--------------------------------------------直接种植--------------------------------------------------------- */
async
function
createDirectPlant
(
req
,
res
,
next
)
{
try
{
//
const
body
=
req
.
body
;
let
ret
=
await
DB
.
ProductPlant
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
listDirectPlant
(
req
,
res
,
next
)
{
try
{
let
search
=
{
del
:
0
};
let
page
=
req
.
body
.
page
||
1
;
let
pageSize
=
req
.
body
.
pageSize
||
10
;
let
skip
=
(
page
-
1
)
*
pageSize
;
const
count
=
await
DB
.
ProductPlant
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductPlant
.
find
(
search
).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
deleteDirectPlant
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
ret
=
await
DB
.
ProductPlant
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
{
del
:
1
});
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
updateDirectPlant
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
upInfo
=
{
...
req
.
body
,
_id
:
undefined
,
}
let
ret
=
await
DB
.
ProductPlant
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
upInfo
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
/**--------------------------------------------初加工--------------------------------------------------------- */
async
function
createPrePlant
(
req
,
res
,
next
)
{
try
{
//
const
body
=
req
.
body
;
let
ret
=
await
DB
.
ProductPre
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
listPrePlant
(
req
,
res
,
next
)
{
try
{
let
search
=
{
del
:
0
};
let
page
=
req
.
body
.
page
||
1
;
let
pageSize
=
req
.
body
.
pageSize
||
10
;
let
skip
=
(
page
-
1
)
*
pageSize
;
const
count
=
await
DB
.
ProductPre
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductPre
.
find
(
search
).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
deletePrePlant
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
ret
=
await
DB
.
ProductPre
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
{
del
:
1
});
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
updatePrePlant
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
upInfo
=
{
...
req
.
body
,
_id
:
undefined
,
}
let
ret
=
await
DB
.
ProductPre
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
upInfo
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
/**--------------------------------------------深加工--------------------------------------------------------- */
async
function
createDeepPlant
(
req
,
res
,
next
)
{
try
{
//
const
body
=
req
.
body
;
let
ret
=
await
DB
.
ProductDeep
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
listDeepPlant
(
req
,
res
,
next
)
{
try
{
let
search
=
{
del
:
0
};
let
page
=
req
.
body
.
page
||
1
;
let
pageSize
=
req
.
body
.
pageSize
||
10
;
let
skip
=
(
page
-
1
)
*
pageSize
;
const
count
=
await
DB
.
ProductDeep
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductDeep
.
find
(
search
).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
deleteDeepPlant
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
ret
=
await
DB
.
ProductDeep
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
{
del
:
1
});
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
updateDeepPlant
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
upInfo
=
{
...
req
.
body
,
_id
:
undefined
,
}
let
ret
=
await
DB
.
ProductDeep
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
upInfo
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
...
...
@@ -136,5 +290,17 @@ module.exports = {
listPlan
,
deletePlan
,
updatePlan
,
createDirectPlant
,
listDirectPlant
,
deleteDirectPlant
,
updateDirectPlant
,
createPrePlant
,
listPrePlant
,
deletePrePlant
,
updatePrePlant
,
createDeepPlant
,
listDeepPlant
,
deleteDeepPlant
,
updateDeepPlant
,
}
\ No newline at end of file
cron/index.js
View file @
85fcf5ff
...
...
@@ -10,6 +10,8 @@ const wsCron = require('./wsCron');
const
ipsCron
=
require
(
'./ipsCron'
);
// excel
const
excelCron
=
require
(
'./excelCron'
);
// 农事预警
const
plantWarnCron
=
require
(
'./plantWarnCron'
);
/**
根据config cron 配置 定时处理
...
...
@@ -95,6 +97,16 @@ const cron = () => {
},
{
timezone
:
"Asia/Shanghai"
});
}
// 每天
if
(
sysConfig
&&
sysConfig
.
cron
&&
sysConfig
.
cron
.
plantearlywarning
)
{
console
.
log
(
"plant:"
,
new
Date
());
new
nodeCron
.
schedule
(
'1 01 06 * * *'
,
async
()
=>
{
console
.
log
(
new
Date
().
getTime
())
await
plantWarnCron
.
plantearlywarning
();
},
{
timezone
:
"Asia/Shanghai"
});
}
}
module
.
exports
=
cron
;
\ No newline at end of file
cron/plantWarnCron.js
0 → 100644
View file @
85fcf5ff
const
httpRequest
=
require
(
'../utils/httpRequest'
);
const
_
=
require
(
'lodash'
);
async
function
plantearlywarning
(
params
)
{
//这里暂时不确定 收获周期的格式
}
module
.
exports
=
{
plantearlywarning
}
\ No newline at end of file
db/index.js
View file @
85fcf5ff
...
...
@@ -50,6 +50,9 @@ const ExcelRecord = require('./models/letianExcelRecord');
const
PlantCycle
=
require
(
'./models/letianPlantCycle'
);
const
PlantPlan
=
require
(
'./models/letianPlantPlan'
);
const
ProductPlant
=
require
(
'./models/letianProductPlant'
);
const
ProductPre
=
require
(
'./models/letianProductPre'
);
const
ProductDeep
=
require
(
'./models/letianProductDeep'
);
const
Device
=
require
(
'./models/collectDevice'
);
const
CollectSMC
=
require
(
'./models/collectSMC'
);
...
...
@@ -86,6 +89,10 @@ global.DB = {
ExcelRecord
,
PlantCycle
,
PlantPlan
,
ProductPlant
,
ProductPre
,
ProductDeep
,
Device
,
CollectThreshold
,
...
...
db/models/letianPlantCycle.js
View file @
85fcf5ff
...
...
@@ -6,23 +6,32 @@ const moment = require('moment');
* 种植周期
*/
const
PlantCycleSchema
=
new
Schema
({
name
:
{
type
:
String
,
comment
:
"种植周期名称"
,
},
startTime
:
{
type
:
Date
,
comment
:
"作物名称"
,
},
endTime
:
{
type
:
Date
,
cycleName
:
{
type
:
String
,
comment
:
"周期名称"
,
},
content
:
{
type
:
String
,
comment
:
"内容 : 注意事项"
},
times
:
{
type
:
[
{
startTime
:
{
type
:
Date
,
},
endTime
:
{
type
:
Date
,
},
}
],
},
createdAt
:
{
type
:
Date
,
...
...
db/models/letianProductDeep.js
0 → 100644
View file @
85fcf5ff
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
/**
* 深加工成果产品 --- 关联初加工成果产品,关联初加工场地摄像头、深加工过程数据(工业信息采集数据)。
*/
const
letianProductDeepSchema
=
new
Schema
({
sourcePlantProduct
:
{
type
:
String
,
comment
:
"来源初加工产品 靠产品名称关联"
},
preProductName
:
{
type
:
String
,
comment
:
"深加工产品名称"
},
varieties
:
{
type
:
String
,
comment
:
"品种"
},
warehouseName
:
{
type
:
String
,
comment
:
"仓库名称"
},
inventoryQuantity
:
{
type
:
String
,
comment
:
"库存量"
},
productPhotos
:
{
type
:
String
,
comment
:
"产品照片"
},
introduction
:
{
type
:
String
,
comment
:
"介绍内容"
},
processTime
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
},
qualityInfo
:
{
type
:
String
,
comment
:
"质量信息"
},
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
ProductDeep
=
mongoose
.
model
(
'letianProductDeep'
,
letianProductDeepSchema
,
'letianProductDeep'
);
module
.
exports
=
ProductDeep
;
\ No newline at end of file
db/models/letianProductPlant.js
0 → 100644
View file @
85fcf5ff
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
/**
* 直接种植收获产品 -- 关联种植规划信息,包括地块、种植周期、收获时间等,关联该地块的监控摄像头数据。
*/
const
letianProductPlantSchema
=
new
Schema
({
productName
:
{
type
:
String
,
comment
:
"产品名称"
},
varieties
:
{
type
:
String
,
comment
:
"品种"
},
productPhotos
:
{
type
:
String
,
comment
:
"产品照片"
},
productIntro
:
{
type
:
String
,
comment
:
"产品介绍"
},
qualityInfor
:
{
type
:
String
,
comment
:
"质量信息"
},
plantPlan
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'PlantPlan'
,
comment
:
"种植规划 关联信息 按照农作物的名称关联"
},
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
ProductPlant
=
mongoose
.
model
(
'letianProductPlant'
,
letianProductPlantSchema
,
'letianProductPlant'
);
module
.
exports
=
ProductPlant
;
\ No newline at end of file
db/models/letianProductPre.js
0 → 100644
View file @
85fcf5ff
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
/**
* 初加工成果产品 --- 关联对应的直接种植收获产品,关联初加工场地的摄像头监控数据。
*/
const
letianProductPreSchema
=
new
Schema
({
sourcePlantProduct
:
{
type
:
String
,
comment
:
"来源种植产品"
},
preProductName
:
{
type
:
String
,
comment
:
"初加工产品名称"
},
varieties
:
{
type
:
String
,
comment
:
"品种"
},
warehouseName
:
{
type
:
String
,
comment
:
"仓库名称"
},
inventoryQuantity
:
{
type
:
String
,
comment
:
"库存量"
},
productPhotos
:
{
type
:
String
,
comment
:
"产品照片"
},
introduction
:
{
type
:
String
,
comment
:
"介绍内容"
},
processTime
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
},
qualityInfo
:
{
type
:
String
,
comment
:
"质量信息"
},
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
ProductPre
=
mongoose
.
model
(
'letianProductPre'
,
letianProductPreSchema
,
'letianProductPre'
);
module
.
exports
=
ProductPre
;
\ No newline at end of file
router/plantRouter.js
View file @
85fcf5ff
...
...
@@ -16,5 +16,22 @@ router.post('/plan/list', plantContoller.listPlan);
router
.
post
(
'/plan/delete'
,
plantContoller
.
deletePlan
);
router
.
post
(
'/plan/update'
,
plantContoller
.
updatePlan
);
// 直接种植
router
.
post
(
'/product/direct/create'
,
plantContoller
.
createDirectPlant
);
router
.
post
(
'/product/direct/list'
,
plantContoller
.
listDirectPlant
);
router
.
post
(
'/product/direct/delete'
,
plantContoller
.
deleteDirectPlant
);
router
.
post
(
'/product/direct/update'
,
plantContoller
.
updateDirectPlant
);
// 初加工
router
.
post
(
'/product/pre/create'
,
plantContoller
.
createPrePlant
);
router
.
post
(
'/product/pre/list'
,
plantContoller
.
listPrePlant
);
router
.
post
(
'/product/pre/delete'
,
plantContoller
.
deletePrePlant
);
router
.
post
(
'/product/pre/update'
,
plantContoller
.
updatePrePlant
);
// 深加工
router
.
post
(
'/product/deep/create'
,
plantContoller
.
createDeepPlant
);
router
.
post
(
'/product/deep/list'
,
plantContoller
.
listDeepPlant
);
router
.
post
(
'/product/deep/delete'
,
plantContoller
.
deleteDeepPlant
);
router
.
post
(
'/product/deep/update'
,
plantContoller
.
updateDeepPlant
);
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