明树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
7343e328
Commit
7343e328
authored
May 24, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
40aaeb21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
21 deletions
+9
-21
productTracController.js
controller/productTracController.js
+7
-20
letianProTraceCode.js
db/models/letianProTraceCode.js
+2
-1
No files found.
controller/productTracController.js
View file @
7343e328
...
@@ -9,25 +9,11 @@ async function createTraceCode(req, res, next) {
...
@@ -9,25 +9,11 @@ async function createTraceCode(req, res, next) {
//
//
const
body
=
req
.
body
;
const
body
=
req
.
body
;
body
.
creator
=
req
.
user
.
_id
;
body
.
creator
=
req
.
user
.
_id
;
// 生成溯源码:
// 生成溯源码:/改成临时拼接,编辑时无动作
let
tcode
=
`271Y8U00
${
body
.
type
||
1
}
`
;
let
tcodepre
=
`271Y8U`
;
let
batchNumber
;
tcodeend
=
utils
.
generateRandomCode
(
4
);
if
(
!
body
.
batchNumber
)
{
body
.
tcodepre
=
tcodepre
;
let
source
;
body
.
tcodeend
=
tcodeend
;
if
(
body
.
source
&&
body
.
type
==
1
)
{
source
=
await
DB
.
ProductPlant
.
findOne
({
_id
:
body
.
source
}).
lean
();
}
else
if
(
body
.
source
&&
body
.
type
==
2
)
{
source
=
await
DB
.
ProductPre
.
findOne
({
_id
:
body
.
source
}).
lean
();
}
else
if
(
body
.
source
&&
body
.
type
==
3
)
{
source
=
await
DB
.
ProductDeep
.
findOne
({
_id
:
body
.
source
}).
lean
();
}
batchNumber
=
source
.
batchNumber
;
}
else
{
batchNumber
=
body
.
batchNumber
;
}
tcode
=
tcode
+
batchNumber
;
tcode
=
tcode
+
utils
.
generateRandomCode
(
4
);
body
.
tcode
=
tcode
;
let
ret
=
await
DB
.
ProTraceCode
.
create
(
body
);
let
ret
=
await
DB
.
ProTraceCode
.
create
(
body
);
res
.
sendData
(
ret
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -131,10 +117,11 @@ async function getTraceCode2(req, res, next) {
...
@@ -131,10 +117,11 @@ async function getTraceCode2(req, res, next) {
if
(
!
req
.
body
.
_id
)
{
if
(
!
req
.
body
.
_id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
}
let
traccode
=
await
DB
.
ProTraceCode
.
findOne
({
_id
:
req
.
body
.
_id
},
{
type
:
1
,
source
:
1
,
tcode
:
1
,
productSalUrl
:
1
,
queryNum
:
1
,
firstQueryTime
:
1
,
_id
:
1
}).
lean
();
let
traccode
=
await
DB
.
ProTraceCode
.
findOne
({
_id
:
req
.
body
.
_id
},
{
type
:
1
,
source
:
1
,
batchNumber
:
1
,
tcodepre
:
1
,
tcodeend
:
1
,
productSalUrl
:
1
,
queryNum
:
1
,
firstQueryTime
:
1
,
_id
:
1
}).
lean
();
if
(
!
(
traccode
&&
traccode
.
_id
&&
traccode
.
source
))
{
if
(
!
(
traccode
&&
traccode
.
_id
&&
traccode
.
source
))
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
}
traccode
.
tcode
=
`
${
traccode
.
tcodepre
}
00
${
traccode
.
type
}${
traccode
.
batchNumber
}${
traccode
.
tcodeend
}
`
;
let
sourceId
=
traccode
.
source
;
let
sourceId
=
traccode
.
source
;
console
.
log
(
sourceId
,
"==="
)
console
.
log
(
sourceId
,
"==="
)
let
source
=
null
;
let
source
=
null
;
...
...
db/models/letianProTraceCode.js
View file @
7343e328
...
@@ -10,7 +10,8 @@ const letianProTraceCodeSchema = new Schema({
...
@@ -10,7 +10,8 @@ const letianProTraceCodeSchema = new Schema({
// type: String,
// type: String,
// comment: "产品名称"
// comment: "产品名称"
// },
// },
tcode
:
String
,
// 溯源码
tcodepre
:
String
,
// 溯源码
tcodeend
:
String
,
type
:
{
type
:
{
type
:
Number
,
type
:
Number
,
comment
:
"1 种植农产品 2 轻加工 3 深加工"
comment
:
"1 种植农产品 2 轻加工 3 深加工"
...
...
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