明树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
9377401a
Commit
9377401a
authored
May 16, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
258f71f6
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
403 additions
and
63 deletions
+403
-63
companyInfoController.js
controller/companyInfoController.js
+2
-1
productDeepController.js
controller/productDeepController.js
+9
-1
productDirPlantController.js
controller/productDirPlantController.js
+9
-1
productPreController.js
controller/productPreController.js
+9
-1
productTracController.js
controller/productTracController.js
+170
-25
letianCompanyInfo.js
db/models/letianCompanyInfo.js
+8
-1
letianProTraceCode.js
db/models/letianProTraceCode.js
+71
-8
letianProductDeep.js
db/models/letianProductDeep.js
+34
-4
letianProductPlant.js
db/models/letianProductPlant.js
+37
-9
letianProductPre.js
db/models/letianProductPre.js
+39
-12
plantRouter.js
router/plantRouter.js
+4
-0
index.js
utils/index.js
+11
-0
No files found.
controller/companyInfoController.js
View file @
9377401a
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
async
function
findCompInfo
(
req
,
res
,
next
)
{
async
function
findCompInfo
(
req
,
res
,
next
)
{
try
{
try
{
let
ret
=
await
DB
.
CompanyInfo
.
findOne
({}).
populate
({
path
:
"companyInfoImgs"
}).
populate
({
path
:
"addressInfo.img"
}).
lean
().
exec
();
let
ret
=
await
DB
.
CompanyInfo
.
findOne
({}).
populate
({
path
:
"companyInfoImgs"
}).
populate
({
path
:
"
qualiCertiImgs"
}).
populate
({
path
:
"
addressInfo.img"
}).
lean
().
exec
();
return
res
.
sendData
(
ret
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
}
catch
(
error
)
{
next
(
error
);
next
(
error
);
...
@@ -16,6 +16,7 @@ async function updateCompInfo(req, res, next) {
...
@@ -16,6 +16,7 @@ async function updateCompInfo(req, res, next) {
try
{
try
{
let
body
=
req
.
body
;
let
body
=
req
.
body
;
body
.
companyInfoImgs
=
(
body
.
companyInfoImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
companyInfoImgs
=
(
body
.
companyInfoImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
qualiCertiImgs
=
(
body
.
qualiCertiImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
addressInfo
=
body
.
addressInfo
||
[];
body
.
addressInfo
=
body
.
addressInfo
||
[];
let
newAdr
=
[];
let
newAdr
=
[];
for
(
let
index
=
0
;
index
<
body
.
addressInfo
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
body
.
addressInfo
.
length
;
index
++
)
{
...
...
controller/productDeepController.js
View file @
9377401a
...
@@ -7,6 +7,9 @@ async function createDeepPlant(req, res, next) {
...
@@ -7,6 +7,9 @@ async function createDeepPlant(req, res, next) {
body
.
productNumber
=
count
;
body
.
productNumber
=
count
;
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
flourMerchantImgs
=
(
body
.
flourMerchantImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
flourMerchantImgs
=
(
body
.
flourMerchantImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
productPhotos2
=
(
body
.
productPhotos2
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
homepageCarouselImgs
=
(
body
.
homepageCarouselImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
pesticidetImgs
=
(
body
.
pesticidetImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
let
ret
=
await
DB
.
ProductDeep
.
create
(
body
);
let
ret
=
await
DB
.
ProductDeep
.
create
(
body
);
res
.
sendData
(
ret
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -23,7 +26,7 @@ async function listDeepPlant(req, res, next) {
...
@@ -23,7 +26,7 @@ async function listDeepPlant(req, res, next) {
search
.
preProductName
=
{
$regex
:
req
.
body
.
name
}
search
.
preProductName
=
{
$regex
:
req
.
body
.
name
}
}
}
const
count
=
await
DB
.
ProductDeep
.
countDocuments
(
search
);
const
count
=
await
DB
.
ProductDeep
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductDeep
.
find
(
search
).
populate
({
path
:
"productPhotos
"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
populate
({
path
:
"flourMerchant
Imgs"
}).
populate
({
path
:
"monitorInfo.device"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
let
list
=
await
DB
.
ProductDeep
.
find
(
search
).
populate
({
path
:
"productPhotos
2"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
populate
({
path
:
"flourMerchantImgs"
}).
populate
({
path
:
"pesticidetImgs"
}).
populate
({
path
:
"homepageCarousel
Imgs"
}).
populate
({
path
:
"monitorInfo.device"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
res
.
sendData
({
count
,
list
});
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
}
catch
(
error
)
{
next
(
error
);
next
(
error
);
...
@@ -45,6 +48,11 @@ async function updateDeepPlant(req, res, next) {
...
@@ -45,6 +48,11 @@ async function updateDeepPlant(req, res, next) {
if
(
!
req
.
body
.
_id
)
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
}
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
flourMerchantImgs
=
(
body
.
flourMerchantImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
productPhotos2
=
(
body
.
productPhotos2
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
homepageCarouselImgs
=
(
body
.
homepageCarouselImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
pesticidetImgs
=
(
body
.
pesticidetImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
let
upInfo
=
{
let
upInfo
=
{
...
req
.
body
,
...
req
.
body
,
_id
:
undefined
,
_id
:
undefined
,
...
...
controller/productDirPlantController.js
View file @
9377401a
...
@@ -7,6 +7,9 @@ async function createDirectPlant(req, res, next) {
...
@@ -7,6 +7,9 @@ async function createDirectPlant(req, res, next) {
body
.
productNumber
=
count
;
body
.
productNumber
=
count
;
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
flourMerchantImgs
=
(
body
.
flourMerchantImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
flourMerchantImgs
=
(
body
.
flourMerchantImgs
||
[]).
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
});
body
.
pesticidetImgs
=
(
body
.
pesticidetImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
let
ret
=
await
DB
.
ProductPlant
.
create
(
body
);
let
ret
=
await
DB
.
ProductPlant
.
create
(
body
);
res
.
sendData
(
ret
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -24,7 +27,7 @@ async function listDirectPlant(req, res, next) {
...
@@ -24,7 +27,7 @@ async function listDirectPlant(req, res, next) {
}
}
const
count
=
await
DB
.
ProductPlant
.
countDocuments
(
search
);
const
count
=
await
DB
.
ProductPlant
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductPlant
.
find
(
search
).
populate
({
path
:
"p
roductPhotos"
}).
populate
({
path
:
"plantPlan
"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
populate
({
path
:
"flourMerchantImgs"
}).
populate
({
path
:
"monitorInfo.device"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
let
list
=
await
DB
.
ProductPlant
.
find
(
search
).
populate
({
path
:
"p
lantPlan"
}).
populate
({
path
:
"pesticidetImgs"
}).
populate
({
path
:
"homepageCarouselImgs"
}).
populate
({
path
:
"productPhotos2
"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
populate
({
path
:
"flourMerchantImgs"
}).
populate
({
path
:
"monitorInfo.device"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
res
.
sendData
({
count
,
list
});
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
}
catch
(
error
)
{
next
(
error
);
next
(
error
);
...
@@ -46,6 +49,11 @@ async function updateDirectPlant(req, res, next) {
...
@@ -46,6 +49,11 @@ async function updateDirectPlant(req, res, next) {
if
(
!
req
.
body
.
_id
)
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
}
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
flourMerchantImgs
=
(
body
.
flourMerchantImgs
||
[]).
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
});
body
.
pesticidetImgs
=
(
body
.
pesticidetImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
let
upInfo
=
{
let
upInfo
=
{
...
req
.
body
,
...
req
.
body
,
_id
:
undefined
,
_id
:
undefined
,
...
...
controller/productPreController.js
View file @
9377401a
...
@@ -8,6 +8,9 @@ async function createPrePlant(req, res, next) {
...
@@ -8,6 +8,9 @@ async function createPrePlant(req, res, next) {
body
.
productNumber
=
count
;
body
.
productNumber
=
count
;
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
flourMerchantImgs
=
(
body
.
flourMerchantImgs
||
[]).
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
.
ProductPre
.
create
(
body
);
let
ret
=
await
DB
.
ProductPre
.
create
(
body
);
res
.
sendData
(
ret
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -24,7 +27,7 @@ async function listPrePlant(req, res, next) {
...
@@ -24,7 +27,7 @@ async function listPrePlant(req, res, next) {
search
.
preProductName
=
{
$regex
:
req
.
body
.
name
}
search
.
preProductName
=
{
$regex
:
req
.
body
.
name
}
}
}
const
count
=
await
DB
.
ProductPre
.
countDocuments
(
search
);
const
count
=
await
DB
.
ProductPre
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductPre
.
find
(
search
).
populate
({
path
:
"productPhotos
"
}).
populate
({
path
:
"sourcePlantProduct"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
populate
({
path
:
"flourMerchant
Imgs"
}).
populate
({
path
:
"monitorInfo.device"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
let
list
=
await
DB
.
ProductPre
.
find
(
search
).
populate
({
path
:
"productPhotos
2"
}).
populate
({
path
:
"sourcePlantProduct"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
populate
({
path
:
"flourMerchantImgs"
}).
populate
({
path
:
"pesticidetImgs"
}).
populate
({
path
:
"homepageCarousel
Imgs"
}).
populate
({
path
:
"monitorInfo.device"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
res
.
sendData
({
count
,
list
});
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
}
catch
(
error
)
{
next
(
error
);
next
(
error
);
...
@@ -46,6 +49,11 @@ async function updatePrePlant(req, res, next) {
...
@@ -46,6 +49,11 @@ async function updatePrePlant(req, res, next) {
if
(
!
req
.
body
.
_id
)
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
}
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
=
{
let
upInfo
=
{
...
req
.
body
,
...
req
.
body
,
_id
:
undefined
,
_id
:
undefined
,
...
...
controller/productTracController.js
View file @
9377401a
This diff is collapsed.
Click to expand it.
db/models/letianCompanyInfo.js
View file @
9377401a
...
@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
...
@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
const
moment
=
require
(
'moment'
);
const
moment
=
require
(
'moment'
);
/**
/**
*
深加工成果产品 --- 关联初加工成果产品,关联初加工场地摄像头、深加工过程数据(工业信息采集数据)。
*
公司信息
*/
*/
const
letianCompanyInfoSchema
=
new
Schema
({
const
letianCompanyInfoSchema
=
new
Schema
({
...
@@ -23,6 +23,13 @@ const letianCompanyInfoSchema = new Schema({
...
@@ -23,6 +23,13 @@ const letianCompanyInfoSchema = new Schema({
comment
:
"公司信息介绍图"
comment
:
"公司信息介绍图"
}
}
],
],
qualiCertiImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"资质证书"
}
],
addressInfo
:
{
addressInfo
:
{
type
:
[{
type
:
[{
name
:
String
,
name
:
String
,
...
...
db/models/letianProTraceCode.js
View file @
9377401a
...
@@ -10,7 +10,32 @@ const letianProTraceCodeSchema = new Schema({
...
@@ -10,7 +10,32 @@ const letianProTraceCodeSchema = new Schema({
// type: String,
// type: String,
// comment: "产品名称"
// comment: "产品名称"
// },
// },
tcode
:
String
,
// 溯源码
jdImg
:
{
// 基地总览图片
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
},
gcImg
:
{
//工厂总览图
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
},
type
:
{
type
:
Number
,
comment
:
"1 种植农产品 2 轻加工 3 深加工"
},
workshop
:
{
type
:
String
,
comment
:
"生产车间"
},
source
:
{
type
:
mongoose
.
Types
.
ObjectId
,
comment
:
"产品名称: 源头productPre productDeep prodectPlant 三个"
},
brand
:
String
,
//品牌
brand
:
String
,
//品牌
batchNumber
:
{
type
:
String
,
comment
:
"生产批次"
},
proInDate
:
{
proInDate
:
{
type
:
Date
,
type
:
Date
,
default
:
Date
.
now
,
default
:
Date
.
now
,
...
@@ -29,18 +54,56 @@ const letianProTraceCodeSchema = new Schema({
...
@@ -29,18 +54,56 @@ const letianProTraceCodeSchema = new Schema({
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD"
),
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD"
),
comment
:
"产品生产日期"
comment
:
"产品生产日期"
},
},
type
:
{
productSalUrl
:
String
,
//第三方页面地址,前端当有这个地址时,直接打开此地址,没有则跳转自己的地址
queryNum
:
{
type
:
Number
,
type
:
Number
,
comment
:
"1 种植 2 轻加工 3 深加工"
default
:
0
,
comment
:
"查询次数"
,
},
},
source
:
{
firstQueryTime
:
{
type
:
mongoose
.
Types
.
ObjectId
,
type
:
Date
,
comment
:
"产品名称: 源头productPre productDeep prodectPlant 三个"
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
comment
:
"首次查询时间"
,
},
},
workshop
:
{
rawMatCul
:
{
//原料种植
type
:
String
,
proName
:
String
,
comment
:
"生产车间"
proAdr
:
String
,
manager
:
String
,
proSteps
:
[
{
name
:
String
,
time
:
Date
,
img
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
}
}
]
},
proProcess
:
{
//产品加工
proName
:
String
,
proAdr
:
String
,
manager
:
String
,
proSteps
:
[
{
name
:
String
,
time
:
Date
,
img
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
}
}
]
},
},
agrOnOff
:
{
// 农业数据开关
type
:
Boolean
,
default
:
true
,
},
indEnvOnOff
:
{
//工业环境开关
type
:
Boolean
,
default
:
true
,
},
creator
:
{
creator
:
{
type
:
mongoose
.
Types
.
ObjectId
,
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'User'
,
ref
:
'User'
,
...
...
db/models/letianProductDeep.js
View file @
9377401a
...
@@ -29,10 +29,38 @@ const letianProductDeepSchema = new Schema({
...
@@ -29,10 +29,38 @@ const letianProductDeepSchema = new Schema({
// type: String,
// type: String,
// comment: "库存量"
// comment: "库存量"
// },
// },
productPhotos
:
{
homepageCarouselImgs
:
[
type
:
mongoose
.
Types
.
ObjectId
,
{
ref
:
'File'
,
type
:
mongoose
.
Types
.
ObjectId
,
comment
:
"产品照片"
ref
:
'File'
,
comment
:
"溯源码产品首页轮播图"
}
],
productPhotos2
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"产品详情轮播图"
}
],
pesticidetImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"农残质检报告"
}
],
sellByDate
:
{
type
:
String
,
comment
:
"保质期"
},
qualityInspector
:
{
type
:
String
,
comment
:
"质检员"
},
productUnit
:
{
type
:
String
,
comment
:
"生产单位"
},
},
// introduction: {
// introduction: {
// type: String,
// type: String,
...
@@ -124,6 +152,8 @@ const letianProductDeepSchema = new Schema({
...
@@ -124,6 +152,8 @@ const letianProductDeepSchema = new Schema({
}
}
],
],
createdAt
:
{
createdAt
:
{
type
:
Date
,
type
:
Date
,
default
:
Date
.
now
,
default
:
Date
.
now
,
...
...
db/models/letianProductPlant.js
View file @
9377401a
...
@@ -15,19 +15,40 @@ const letianProductPlantSchema = new Schema({
...
@@ -15,19 +15,40 @@ const letianProductPlantSchema = new Schema({
type
:
String
,
type
:
String
,
comment
:
"品种"
comment
:
"品种"
},
},
productPhotos
:
{
homepageCarouselImgs
:
[
type
:
mongoose
.
Types
.
ObjectId
,
{
ref
:
'File'
,
type
:
mongoose
.
Types
.
ObjectId
,
comment
:
"产品照片"
ref
:
'File'
,
},
comment
:
"溯源码产品首页轮播图"
productIntro
:
{
}
],
productPhotos2
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"产品详情轮播图"
}
],
sellByDate
:
{
type
:
String
,
type
:
String
,
comment
:
"
产品介绍
"
comment
:
"
保质期
"
},
},
qualityIn
f
or
:
{
qualityIn
spect
or
:
{
type
:
String
,
type
:
String
,
comment
:
"质
量信息
"
comment
:
"质
检员
"
},
},
productUnit
:
{
type
:
String
,
comment
:
"生产单位"
},
// productIntro: {
// type: String,
// comment: "产品介绍"
// },
// qualityInfor: {
// type: String,
// comment: "质量信息"
// },
yield
:
{
yield
:
{
type
:
Number
,
type
:
Number
,
comment
:
"产量"
,
comment
:
"产量"
,
...
@@ -52,6 +73,13 @@ const letianProductPlantSchema = new Schema({
...
@@ -52,6 +73,13 @@ const letianProductPlantSchema = new Schema({
comment
:
"质检报告图"
comment
:
"质检报告图"
}
}
],
],
pesticidetImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"农残质检报告"
}
],
monitorInfo
:
{
monitorInfo
:
{
type
:
[
type
:
[
{
{
...
...
db/models/letianProductPre.js
View file @
9377401a
...
@@ -28,26 +28,46 @@ const letianProductPreSchema = new Schema({
...
@@ -28,26 +28,46 @@ const letianProductPreSchema = new Schema({
type
:
String
,
type
:
String
,
comment
:
"库存量"
comment
:
"库存量"
},
},
productPhotos
:
{
type
:
mongoose
.
Types
.
ObjectId
,
homepageCarouselImgs
:
[
ref
:
'File'
,
{
comment
:
"物品照片"
,
type
:
mongoose
.
Types
.
ObjectId
,
default
:
null
,
ref
:
'File'
,
set
:
v
=>
{
if
(
!
v
)
{
return
null
;
}
else
{
return
v
;
}
}
comment
:
"溯源码产品首页轮播图"
}
],
productPhotos2
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"产品详情轮播图"
}
],
sellByDate
:
{
type
:
String
,
comment
:
"保质期"
},
qualityInspector
:
{
type
:
String
,
comment
:
"质检员"
},
},
introduction
:
{
productUnit
:
{
type
:
String
,
type
:
String
,
comment
:
"
介绍内容
"
comment
:
"
生产单位
"
},
},
// introduction: {
// type: String,
// comment: "介绍内容"
// },
processTime
:
{
processTime
:
{
type
:
Date
,
type
:
Date
,
default
:
Date
.
now
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
},
},
qualityInfo
:
{
//
qualityInfo: {
type
:
String
,
//
type: String,
comment
:
"质量信息"
//
comment: "质量信息"
},
//
},
productNumber
:
{
productNumber
:
{
type
:
String
,
type
:
String
,
comment
:
"产品编号"
comment
:
"产品编号"
...
@@ -59,6 +79,13 @@ const letianProductPreSchema = new Schema({
...
@@ -59,6 +79,13 @@ const letianProductPreSchema = new Schema({
comment
:
"质检报告图"
comment
:
"质检报告图"
}
}
],
],
pesticidetImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"农残质检报告"
}
],
monitorInfo
:
{
monitorInfo
:
{
type
:
[
type
:
[
{
{
...
...
router/plantRouter.js
View file @
9377401a
...
@@ -46,5 +46,9 @@ router.post('/product/trace/list', productTracController.listTraceCode);
...
@@ -46,5 +46,9 @@ router.post('/product/trace/list', productTracController.listTraceCode);
router
.
post
(
'/product/trace/delete'
,
productTracController
.
deleteTraceCode
);
router
.
post
(
'/product/trace/delete'
,
productTracController
.
deleteTraceCode
);
router
.
post
(
'/product/trace/update'
,
productTracController
.
updateTraceCode
);
router
.
post
(
'/product/trace/update'
,
productTracController
.
updateTraceCode
);
router
.
post
(
'/product/trace/info'
,
productTracController
.
getTraceCode
);
router
.
post
(
'/product/trace/info'
,
productTracController
.
getTraceCode
);
router
.
post
(
'/product/trace/info2'
,
productTracController
.
getTraceCode2
);
//溯源首页
router
.
post
(
'/product/trace/suyuan'
,
productTracController
.
getsuyuanBase
);
// 溯源信息
router
.
post
(
'/product/trace/jiankong'
,
productTracController
.
getJiankong
);
// 实时监控
router
.
post
(
'/product/trace/zhijian'
,
productTracController
.
getZhijian
);
// 质量检测报告
module
.
exports
=
router
;
module
.
exports
=
router
;
\ No newline at end of file
utils/index.js
View file @
9377401a
...
@@ -74,11 +74,22 @@ function genTracSourceCode({EnterpriseCode, type, date, batchNum, logisticsNum})
...
@@ -74,11 +74,22 @@ function genTracSourceCode({EnterpriseCode, type, date, batchNum, logisticsNum})
}
}
function
generateRandomCode
(
len
)
{
const
chars
=
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
// 定义字符库
let
code
=
''
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
chars
.
length
);
// 生成随机索引
code
+=
chars
[
randomIndex
];
// 拼接字符
}
return
code
;
}
module
.
exports
=
{
module
.
exports
=
{
saltHashPassword
,
saltHashPassword
,
checkUserPassword
,
checkUserPassword
,
buildTree
,
buildTree
,
disTree
,
disTree
,
generateRandomCode
,
}
}
\ 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