明树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
f52b6874
Commit
f52b6874
authored
Mar 04, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 公司信息、菜单、质检
parent
216111ef
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
150 additions
and
11 deletions
+150
-11
companyInfoController.js
controller/companyInfoController.js
+36
-0
fileController.js
controller/fileController.js
+2
-0
menuController.js
controller/menuController.js
+4
-0
productDeepController.js
controller/productDeepController.js
+2
-1
productDirPlantController.js
controller/productDirPlantController.js
+2
-1
productPreController.js
controller/productPreController.js
+2
-1
productTracController.js
controller/productTracController.js
+6
-3
index.js
db/index.js
+3
-1
letianCompanyInfo.js
db/models/letianCompanyInfo.js
+54
-0
letianProductDeep.js
db/models/letianProductDeep.js
+7
-0
letianProductPlant.js
db/models/letianProductPlant.js
+7
-0
letianProductPre.js
db/models/letianProductPre.js
+8
-1
userModule.js
module/userModule.js
+1
-3
compInfoRouter.js
router/compInfoRouter.js
+13
-0
index.js
router/index.js
+3
-0
No files found.
controller/companyInfoController.js
0 → 100644
View file @
f52b6874
async
function
findCompInfo
(
req
,
res
,
next
)
{
try
{
return
await
DB
.
CompanyInfo
.
findOne
({}).
populate
({
path
:
"companyInfoImgs"
}).
lean
().
exec
();
}
catch
(
error
)
{
next
(
error
);
}
}
async
function
updateCompInfo
(
req
,
res
,
next
)
{
try
{
let
body
=
req
.
body
;
body
.
companyInfoImgs
=
(
body
.
companyInfoImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
});
return
await
DB
.
CompanyInfo
.
findOneAndUpdate
({
_id
:
body
.
_id
},{
body
});
}
catch
(
error
)
{
next
(
error
);
}
}
module
.
exports
=
{
findCompInfo
,
updateCompInfo
,
}
\ No newline at end of file
controller/fileController.js
View file @
f52b6874
...
...
@@ -25,12 +25,14 @@ async function batchUpload(req, res, next) {
let
ret
=
[];
for
(
let
index
=
0
;
index
<
req
.
files
.
length
;
index
++
)
{
const
element
=
req
.
files
[
index
];
let
nginxpath
=
_
.
last
(
String
(
element
.
path
).
split
(
'/mnt/vdb1'
));
ret
.
push
({
originalname
:
element
.
originalname
,
mimetype
:
element
.
mimetype
,
filename
:
element
.
filename
,
path
:
element
.
path
,
size
:
element
.
size
,
nginxpath
,
})
}
let
data
=
await
DB
.
File
.
insertMany
(
ret
);
...
...
controller/menuController.js
View file @
f52b6874
...
...
@@ -49,6 +49,10 @@ async function updateMenu(req, res, next) {
updateObj
.
parentId
=
req
.
body
.
parentId
;
updateObj
.
parentIds
=
parentIds
;
}
if
(
req
.
body
.
del
==
1
)
{
//删除,则删除其子菜单 TODO把所有的子删除:也就是数组里面包含当前id的都删除
}
let
ret
=
await
DB
.
Menu
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
updateObj
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
...
...
controller/productDeepController.js
View file @
f52b6874
...
...
@@ -5,6 +5,7 @@ async function createDeepPlant(req, res, next) {
const
body
=
req
.
body
;
let
count
=
await
DB
.
ProductDeep
.
countDocuments
();
//没有真实删除 永远递增
body
.
productNumber
=
count
;
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
});
let
ret
=
await
DB
.
ProductDeep
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
...
...
@@ -21,7 +22,7 @@ async function listDeepPlant(req, res, next) {
search
.
preProductName
=
{
$regex
:
req
.
body
.
name
}
}
const
count
=
await
DB
.
ProductDeep
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductDeep
.
find
(
search
).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"sourcePlantProduct"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
let
list
=
await
DB
.
ProductDeep
.
find
(
search
).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"sourcePlantProduct"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
);
...
...
controller/productDirPlantController.js
View file @
f52b6874
...
...
@@ -5,6 +5,7 @@ async function createDirectPlant(req, res, next) {
const
body
=
req
.
body
;
let
count
=
await
DB
.
ProductPlant
.
countDocuments
();
//没有真实删除 永远递增
body
.
productNumber
=
count
;
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
});
let
ret
=
await
DB
.
ProductPlant
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
...
...
@@ -22,7 +23,7 @@ async function listDirectPlant(req, res, next) {
}
const
count
=
await
DB
.
ProductPlant
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductPlant
.
find
(
search
).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"plantPlan"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
let
list
=
await
DB
.
ProductPlant
.
find
(
search
).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"plantPlan"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
);
...
...
controller/productPreController.js
View file @
f52b6874
...
...
@@ -6,6 +6,7 @@ async function createPrePlant(req, res, next) {
const
body
=
req
.
body
;
let
count
=
await
DB
.
ProductPre
.
countDocuments
();
//没有真实删除 永远递增
body
.
productNumber
=
count
;
body
.
qualityInsReportImgs
=
(
body
.
qualityInsReportImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
});
let
ret
=
await
DB
.
ProductPre
.
create
(
body
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
...
...
@@ -22,7 +23,7 @@ async function listPrePlant(req, res, next) {
search
.
preProductName
=
{
$regex
:
req
.
body
.
name
}
}
const
count
=
await
DB
.
ProductPre
.
countDocuments
(
search
);
let
list
=
await
DB
.
ProductPre
.
find
(
search
).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"sourcePlantProduct"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
let
list
=
await
DB
.
ProductPre
.
find
(
search
).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"sourcePlantProduct"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
sort
({
_id
:
-
1
}).
skip
(
skip
).
limit
(
pageSize
);
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
);
...
...
controller/productTracController.js
View file @
f52b6874
...
...
@@ -82,7 +82,7 @@ async function getTraceCode(req, res, next) {
let
sourceId
=
traccode
.
source
;
let
source
=
null
;
if
(
traccode
.
type
&&
traccode
.
type
==
1
)
{
source
=
await
DB
.
ProductPlant
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"plantPlan"
}).
lean
();
source
=
await
DB
.
ProductPlant
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"plantPlan"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
lean
();
if
(
source
&&
source
.
plantPlan
&&
source
.
plantPlan
.
land
)
{
let
devices
=
await
DB
.
Device
.
find
({
land
:
{
$in
:
source
.
plantPlan
.
land
},
deviceHQType
:
5
}).
lean
();
source
.
devices
=
devices
;
...
...
@@ -90,13 +90,16 @@ async function getTraceCode(req, res, next) {
source
.
devices
=
[];
}
}
else
if
(
traccode
.
type
&&
traccode
.
type
==
2
)
{
source
=
await
DB
.
ProductPre
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
lean
();
source
=
await
DB
.
ProductPre
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
lean
();
}
else
if
(
traccode
.
type
&&
traccode
.
type
==
3
)
{
source
=
await
DB
.
ProductDeep
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
lean
();
source
=
await
DB
.
ProductDeep
.
findOne
({
_id
:
sourceId
}).
populate
({
path
:
"productPhotos"
}).
populate
({
path
:
"qualityInsReportImgs"
}).
lean
();
}
console
.
log
(
source
,
"=="
)
traccode
.
source
=
source
;
//请求公司信息
let
companyInfo
=
await
DB
.
CompanyInfo
.
findOne
({});
traccode
.
companyInfo
=
companyInfo
||
{};
res
.
sendData
(
traccode
);
}
catch
(
error
)
{
next
(
error
);
...
...
db/index.js
View file @
f52b6874
...
...
@@ -75,6 +75,8 @@ const RequestLog = require('./models/systemRequestLog');
const
HeavyMetal
=
require
(
'./models/letianHeavyMetal'
);
const
IndRawMatIn
=
require
(
'./models/letianIndRawMatIn'
);
//工业-原料品投入
const
CompanyInfo
=
require
(
'./models/letianCompanyInfo'
);
//公司信息 用作扫码处展示
global
.
DB
=
{
File
,
User
,
...
...
@@ -122,7 +124,7 @@ global.DB = {
IndRawMatIn
,
HeavyMetal
,
CompanyInfo
,
}
...
...
db/models/letianCompanyInfo.js
0 → 100644
View file @
f52b6874
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
/**
* 深加工成果产品 --- 关联初加工成果产品,关联初加工场地摄像头、深加工过程数据(工业信息采集数据)。
*/
const
letianCompanyInfoSchema
=
new
Schema
({
name
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'ProductPre'
,
comment
:
"来源初加工产品 靠产品名称关联"
},
address
:
{
type
:
String
,
comment
:
"深加工产品名称"
},
companyInfoImgs
:
{
type
:
[
{
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
CompanyInfo
=
mongoose
.
model
(
'CompanyInfo'
,
letianCompanyInfoSchema
,
'letianCompanyInfo'
);
module
.
exports
=
CompanyInfo
;
\ No newline at end of file
db/models/letianProductDeep.js
View file @
f52b6874
...
...
@@ -51,6 +51,13 @@ const letianProductDeepSchema = new Schema({
type
:
String
,
comment
:
"产品编号"
},
qualityInsReportImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"质检报告图"
}
],
createdAt
:
{
type
:
Date
,
...
...
db/models/letianProductPlant.js
View file @
f52b6874
...
...
@@ -45,6 +45,13 @@ const letianProductPlantSchema = new Schema({
type
:
Number
,
comment
:
"产品编号"
},
qualityInsReportImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"质检报告图"
}
],
createdAt
:
{
type
:
Date
,
...
...
db/models/letianProductPre.js
View file @
f52b6874
...
...
@@ -33,7 +33,7 @@ const letianProductPreSchema = new Schema({
ref
:
'File'
,
comment
:
"物品照片"
,
default
:
null
,
set
:
v
=>
{
if
(
!
v
)
{
return
null
;}
else
{
return
v
;}
}
set
:
v
=>
{
if
(
!
v
)
{
return
null
;
}
else
{
return
v
;
}
}
},
introduction
:
{
type
:
String
,
...
...
@@ -52,6 +52,13 @@ const letianProductPreSchema = new Schema({
type
:
String
,
comment
:
"产品编号"
},
qualityInsReportImgs
:
[
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"质检报告图"
}
],
createdAt
:
{
type
:
Date
,
...
...
module/userModule.js
View file @
f52b6874
...
...
@@ -61,8 +61,6 @@ async function getRoleMenus(roles, mobile) {
bMap
[
bpreId
]
=
bMap
[
bpreId
]
||
[];
bMap
[
bpreId
].
push
(
o
);
}
}
//获取用户有效的菜单 type : 1
...
...
@@ -72,7 +70,7 @@ async function getRoleMenus(roles, mobile) {
element
.
parentIds
=
element
.
parentIds
||
[];
for
(
let
i
=
0
;
i
<
element
.
parentIds
.
length
;
i
++
)
{
const
par
=
element
.
parentIds
[
i
];
if
(
!
nodeMap
[
par
.
_id
]
)
{
if
(
!
nodeMap
[
par
.
_id
]
&&
par
.
del
==
0
&&
par
.
enable
)
{
// 父节点删除后 子节点没有联动删除(会有删除失败因素) 此处处理
par
.
buttons
=
bMap
[
par
.
_id
];
par
.
permission
=
true
nodes
.
push
(
par
);
...
...
router/compInfoRouter.js
0 → 100644
View file @
f52b6874
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
companyInfoController
=
require
(
'../controller/companyInfoController'
);
router
.
post
(
'/info'
,
companyInfoController
.
findCompInfo
);
router
.
post
(
'/update'
,
companyInfoController
.
updateCompInfo
);
module
.
exports
=
router
;
\ No newline at end of file
router/index.js
View file @
f52b6874
...
...
@@ -22,6 +22,7 @@ const flowRouter = require('./flowRouter');
const
excelrecordRouter
=
require
(
'./excelrecordRouter'
);
const
inductryRouter
=
require
(
'./inductryRouter'
);
const
heavyMetalRouter
=
require
(
'./externalRouter'
);
const
compInfoRouter
=
require
(
'./compInfoRouter'
);
router
.
use
(
'/user'
,
userRouter
);
// 用户 角色
...
...
@@ -51,6 +52,8 @@ router.use('/excelrecord', excelrecordRouter);
// 工业
router
.
use
(
'/ind'
,
inductryRouter
);
router
.
use
(
'/company'
,
compInfoRouter
);
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