明树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
235272c5
Commit
235272c5
authored
Dec 18, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
2ea03553
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
387 additions
and
2 deletions
+387
-2
a.js
a.js
+89
-2
productltController.js
controller/productltController.js
+110
-0
db.zip
db.zip
+0
-0
letianProductLt.js
db/models/letianProductLt.js
+182
-0
plantRouter.js
router/plantRouter.js
+6
-0
No files found.
a.js
View file @
235272c5
let
a
=
`{"sensorDatas":[{"flag":"TEMP","value":33.1}, {"flag":"PM2.5","value":8}, {"flag":"PM10","value":10}]}0X`
;
let
a
=
{
console
.
log
(
a
.
slice
(
0
,
-
2
))
"countLimit"
:
1000
,
\ No newline at end of file
"screenKey"
:
"SCR_mflx158ijs"
,
"advSearch"
:
{
"logic"
:
"and"
,
"conditions"
:
[
{
"logic"
:
"text"
,
"textSearch"
:
""
},
{
"logic"
:
"and"
,
"conditions"
:
[]
},
{
"logic"
:
"and"
,
"conditions"
:
[]
}
]
},
"fields"
:
[
"project_name"
,
"project_code"
,
"fm_date"
,
"project_address"
,
"item_type"
,
"project_type"
,
"gb_industry"
,
"industry"
,
"amount"
,
"address_details"
,
"description"
,
"unit_name"
,
"unit_nature"
,
"license_type"
,
"license_code"
,
"pro_status_new"
,
"declaration_date"
,
"sb_user"
],
"pagination"
:
{
"page"
:
1
,
"pagesize"
:
10
},
"indexHints"
:
[]
}
let
b
=
{
"screenKey"
:
"SCR_mflx158ijs"
,
"advSearch"
:
{
"logic"
:
"and"
,
"conditions"
:
[
{
"logic"
:
"and"
,
"conditions"
:
[
{
"logic"
:
"field"
,
"fieldKey"
:
"project_code"
,
"fieldType"
:
"text"
,
"fieldValue"
:
[
"2503-421221-04-02-683596"
],
"fieldParams"
:
[],
"fieldOperator"
:
"regex"
,
"fieldSearch"
:
{
"logic"
:
"and"
,
"conditions"
:
[]
},
"parameterType"
:
"fixedText"
}
]
}
]
},
"fields"
:
[
"project_name"
,
"project_code"
,
"fm_date"
,
"project_address"
,
"item_type"
,
"project_type"
,
"gb_industry"
],
"pagination"
:
{
"page"
:
1
,
"pagesize"
:
10
}
}
controller/productltController.js
0 → 100644
View file @
235272c5
/**--------------------------------------------直接种植--------------------------------------------------------- */
async
function
createlt
(
req
,
res
,
next
)
{
try
{
//
const
body
=
req
.
body
;
let
count
=
await
DB
.
ProductLt
.
countDocuments
();
//没有真实删除 永远递增
body
.
productNumber
=
count
;
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body
.
homepageCarouselImgs
=
(
body
.
homepageCarouselImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
productPhotos2
=
(
body
.
productPhotos2
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
let
ret
=
await
DB
.
ProductLt
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
listlt
(
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
;
if
(
req
.
body
.
name
)
{
search
.
productName
=
{
$regex
:
req
.
body
.
name
}
}
const
count
=
await
DB
.
ProductLt
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductLt
.
find
(
search
).
populate
({
path
:
"homepageCarouselImgs"
}).
populate
({
path
:
"productPhotos2"
}).
populate
({
path
:
"monitorInfo.device"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
deletelt
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
ret
=
await
DB
.
ProductLt
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
{
del
:
1
});
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
updatelt
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
body
=
req
.
body
;
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body
.
homepageCarouselImgs
=
(
body
.
homepageCarouselImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
productPhotos2
=
(
body
.
productPhotos2
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
let
upInfo
=
{
...
body
,
_id
:
undefined
,
}
let
ret
=
await
DB
.
ProductLt
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
upInfo
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
importExcel
(
req
,
res
,
next
)
{
try
{
throw
new
Error
(
'不适合做解析,直接录入'
);
let
workbook
=
new
ExcelJS
.
Workbook
();
await
workbook
.
xlsx
.
readFile
(
req
.
file
.
path
);
let
worksheet
=
workbook
.
getWorksheet
(
1
);
let
arr
=
[];
for
(
let
index
=
2
;
index
<=
worksheet
.
actualRowCount
;
index
++
)
{
let
values
=
worksheet
.
getRow
(
index
).
values
;
let
obj
=
{
creator
:
req
.
user
.
_id
,
productName
:
values
[
1
],
varieties
:
values
[
2
],
productIntro
:
values
[
3
],
qualityInfor
:
values
[
4
],
}
if
(
typeof
obj
.
time
==
'number'
)
{
obj
.
time
=
new
Date
(
1900
,
0
,
obj
.
time
-
1
,
0
,
0
,
0
);
}
if
(
obj
.
time
&&
obj
.
agrProName
)
{
arr
.
push
(
obj
)
}
}
if
(
arr
.
length
)
{
await
DB
.
AgrInputRecord
.
insertMany
(
arr
);
}
res
.
sendData
(
arr
);
}
catch
(
error
)
{
next
(
error
)
}
}
module
.
exports
=
{
createlt
,
listlt
,
deletelt
,
updatelt
,
importExcel
,
}
\ No newline at end of file
db.zip
deleted
100644 → 0
View file @
2ea03553
File deleted
db/models/letianProductLt.js
0 → 100644
View file @
235272c5
//畜禽产品
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
/**
* 直接种植收获产品 -- 关联种植规划信息,包括地块、种植周期、收获时间等,关联该地块的监控摄像头数据。
*/
const
letianProductLtSchema
=
new
Schema
({
productName
:
{
type
:
String
,
comment
:
"产品名称"
},
varieties
:
{
type
:
String
,
comment
:
"品种"
},
homepageCarouselImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"溯源码产品首页轮播图"
}
],
productPhotos2
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"产品详情轮播图"
}
],
sellByDate
:
{
type
:
String
,
comment
:
"保质期"
},
sellByDateUnit
:
{
type
:
String
,
comment
:
"保质期单位"
},
qualityInspector
:
{
type
:
String
,
comment
:
"质检员"
},
productUnit
:
{
type
:
String
,
comment
:
"生产单位"
},
// productIntro: {
// type: String,
// comment: "产品介绍"
// },
// qualityInfor: {
// type: String,
// comment: "质量信息"
// },
yield
:
{
type
:
Number
,
comment
:
"产量"
,
},
yieldUnit
:
{
type
:
String
,
comment
:
"产量单位"
,
},
plantPlan
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'PlantPlan'
,
comment
:
"种植规划 关联信息 按照农作物的名称关联"
},
productNumber
:
{
type
:
Number
,
comment
:
"产品编号"
},
// qualityInsReportImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "质检报告图"
// }
// ],
// pesticidetImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "农残质检报告"
// }
// ],
monitorInfo
:
{
type
:
[
{
name
:
String
,
deviceSectorType
:
{
type
:
Number
,
comment
:
"1, 农业 2 工业"
},
device
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'collectDevice'
,
comment
:
"设备"
}
}
]
},
monitorInfoForInt
:
{
//工业
type
:
[
{
name
:
String
,
// deviceSectorType: {
// type: Number,
// comment: "1, 农业 2 工业"
// },
device
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'collectDevice'
,
comment
:
"设备"
}
}
]
},
//原料信息
agrProVar
:
{
type
:
String
,
comment
:
"农产品品种"
},
agrPlantBase
:
{
type
:
String
,
comment
:
"农产品种植基地"
},
harvestDate
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD"
),
comment
:
"采收时间"
},
flourMerchant
:
{
type
:
String
,
comment
:
"面粉商"
},
batchNumber
:
{
type
:
String
,
comment
:
"批次号"
},
manufactureDate
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD"
),
comment
:
"生产日期"
},
// flourMerchantImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// 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
ProductLt
=
mongoose
.
model
(
'ProductLt'
,
letianProductLtSchema
,
'letianProductLt'
);
module
.
exports
=
ProductLt
;
\ No newline at end of file
router/plantRouter.js
View file @
235272c5
...
@@ -6,6 +6,7 @@ const plantContoller = require('../controller/plantContoller.js');
...
@@ -6,6 +6,7 @@ const plantContoller = require('../controller/plantContoller.js');
const
productDirPlantController
=
require
(
'../controller/productDirPlantController.js'
);
const
productDirPlantController
=
require
(
'../controller/productDirPlantController.js'
);
const
productPreController
=
require
(
'../controller/productPreController.js'
);
const
productPreController
=
require
(
'../controller/productPreController.js'
);
const
productDeepController
=
require
(
'../controller/productDeepController.js'
);
const
productDeepController
=
require
(
'../controller/productDeepController.js'
);
const
productltController
=
require
(
'../controller/productltController.js'
);
const
productTracController
=
require
(
'../controller/productTracController.js'
);
const
productTracController
=
require
(
'../controller/productTracController.js'
);
// 生长周期
// 生长周期
...
@@ -39,6 +40,11 @@ router.post('/product/deep/create', productDeepController.createDeepPlant);
...
@@ -39,6 +40,11 @@ router.post('/product/deep/create', productDeepController.createDeepPlant);
router
.
post
(
'/product/deep/list'
,
productDeepController
.
listDeepPlant
);
router
.
post
(
'/product/deep/list'
,
productDeepController
.
listDeepPlant
);
router
.
post
(
'/product/deep/delete'
,
productDeepController
.
deleteDeepPlant
);
router
.
post
(
'/product/deep/delete'
,
productDeepController
.
deleteDeepPlant
);
router
.
post
(
'/product/deep/update'
,
productDeepController
.
updateDeepPlant
);
router
.
post
(
'/product/deep/update'
,
productDeepController
.
updateDeepPlant
);
// 畜禽
router
.
post
(
'/product/lt/create'
,
productltController
.
createlt
);
router
.
post
(
'/product/lt/list'
,
productltController
.
listlt
);
router
.
post
(
'/product/lt/delete'
,
productltController
.
deletelt
);
router
.
post
(
'/product/lt/update'
,
productltController
.
updatelt
);
//溯源码
//溯源码
router
.
post
(
'/product/trace/create'
,
productTracController
.
createTraceCode
);
router
.
post
(
'/product/trace/create'
,
productTracController
.
createTraceCode
);
...
...
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