明树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
240d306f
Commit
240d306f
authored
Dec 23, 2024
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3b188772
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
local.json
config/local.json
+1
-1
productTracController.js
controller/productTracController.js
+12
-10
No files found.
config/local.json
View file @
240d306f
...
@@ -39,6 +39,6 @@
...
@@ -39,6 +39,6 @@
"collectDeviceInfo"
:
false
,
"collectDeviceInfo"
:
false
,
"collectDeviceInfo4"
:
true
,
"collectDeviceInfo4"
:
true
,
"excel"
:
false
,
"excel"
:
false
,
"plantearlywarning"
:
tru
e
"plantearlywarning"
:
fals
e
}
}
}
}
\ No newline at end of file
controller/productTracController.js
View file @
240d306f
...
@@ -26,16 +26,16 @@ async function listTraceCode(req, res, next) {
...
@@ -26,16 +26,16 @@ async function listTraceCode(req, res, next) {
search
.
batchNumber
=
{
$regex
:
req
.
body
.
batchNumber
}
search
.
batchNumber
=
{
$regex
:
req
.
body
.
batchNumber
}
}
}
const
count
=
await
DB
.
ProTraceCode
.
countDocuments
(
search
);
const
count
=
await
DB
.
ProTraceCode
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProTraceCode
.
find
(
search
).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
let
list
=
await
DB
.
ProTraceCode
.
find
(
search
).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
)
.
lean
()
;
let
ret
=
[];
let
ret
=
[];
for
(
let
index
=
0
;
index
<
list
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
list
.
length
;
index
++
)
{
const
element
=
list
[
index
];
const
element
=
list
[
index
];
if
(
element
.
source
&&
element
.
type
==
1
)
{
if
(
element
.
source
&&
element
.
type
==
1
)
{
element
.
source
=
await
DB
.
ProductPlant
.
findOne
({
_id
:
element
.
source
});
element
.
source
=
await
DB
.
ProductPlant
.
findOne
({
_id
:
element
.
source
})
.
lean
()
;
}
else
if
(
element
.
source
&&
element
.
type
==
2
)
{
}
else
if
(
element
.
source
&&
element
.
type
==
2
)
{
element
.
source
=
await
DB
.
ProductPre
.
findOne
({
_id
:
element
.
source
});
element
.
source
=
await
DB
.
ProductPre
.
findOne
({
_id
:
element
.
source
})
.
lean
()
;
}
else
if
(
element
.
source
&&
element
.
type
==
3
)
{
}
else
if
(
element
.
source
&&
element
.
type
==
3
)
{
element
.
source
=
await
DB
.
ProductDeep
.
findOne
({
_id
:
element
.
source
});
element
.
source
=
await
DB
.
ProductDeep
.
findOne
({
_id
:
element
.
source
})
.
lean
()
;
}
}
ret
.
push
(
element
);
ret
.
push
(
element
);
}
}
...
@@ -75,24 +75,26 @@ async function getTraceCode(req, res, next) {
...
@@ -75,24 +75,26 @@ async function getTraceCode(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
});
let
traccode
=
await
DB
.
ProTraceCode
.
findOne
({
_id
:
req
.
body
.
_id
})
.
lean
()
;
if
(
!
(
traccode
&&
traccode
.
_id
&&
traccode
.
source
))
{
if
(
!
(
traccode
&&
traccode
.
_id
&&
traccode
.
source
))
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
}
let
sourceId
=
traccode
.
source
;
let
sourceId
=
traccode
.
source
;
let
source
=
null
;
let
source
=
null
;
if
(
traccode
.
type
&&
traccode
.
type
==
1
)
{
if
(
traccode
.
type
&&
traccode
.
type
==
1
)
{
source
=
await
DB
.
ProductPlant
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"plantPlan"
});
source
=
await
DB
.
ProductPlant
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"plantPlan"
})
.
lean
()
;
if
(
source
&&
source
.
plantPlan
&&
source
.
plantPlan
.
land
)
{
if
(
source
&&
source
.
plantPlan
&&
source
.
plantPlan
.
land
)
{
let
devices
=
await
Device
.
find
({
land
:
{
$in
:
source
.
plantPlan
.
land
}});
let
devices
=
await
Device
.
find
({
land
:
{
$in
:
source
.
plantPlan
.
land
}})
.
lean
()
;
source
.
devices
=
devices
;
source
.
devices
=
devices
;
}
}
}
else
if
(
traccode
.
type
&&
traccode
.
type
==
2
)
{
}
else
if
(
traccode
.
type
&&
traccode
.
type
==
2
)
{
source
=
await
DB
.
ProductPre
.
findOne
({
_id
:
sourceId
});
source
=
await
DB
.
ProductPre
.
findOne
({
_id
:
sourceId
})
.
lean
()
;
}
else
if
(
traccode
.
type
&&
traccode
.
type
==
3
)
{
}
else
if
(
traccode
.
type
&&
traccode
.
type
==
3
)
{
source
=
await
DB
.
ProductDeep
.
findOne
({
_id
:
sourceId
});
source
=
await
DB
.
ProductDeep
.
findOne
({
_id
:
sourceId
})
.
lean
()
;
}
}
traccode
.
source
=
source
&&
sourceId
;
console
.
log
(
source
,
"=="
)
traccode
.
source
=
source
;
res
.
sendData
(
traccode
);
res
.
sendData
(
traccode
);
}
catch
(
error
)
{
}
catch
(
error
)
{
next
(
error
);
next
(
error
);
...
...
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