明树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
1dec7a9e
Commit
1dec7a9e
authored
Sep 13, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
5d6ffe40
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
95 additions
and
111 deletions
+95
-111
dev.json
config/dev.json
+1
-1
agrInputRecordController.js
controller/agrInputRecordController.js
+3
-3
fileController.js
controller/fileController.js
+4
-5
index.js
db/index.js
+5
-5
letianAgrInputRecord.js
db/models/letianAgrInputRecord.js
+3
-3
letianAgrTask.js
db/models/letianAgrTask.js
+7
-1
letianAgrTaskRecord.js
db/models/letianAgrTaskRecord.js
+53
-0
letianPurchase.js
db/models/letianPurchase.js
+0
-86
systemUser.js
db/models/systemUser.js
+6
-0
agrRouter.js
router/agrRouter.js
+3
-3
fileRouter.js
router/fileRouter.js
+7
-1
index.js
router/index.js
+2
-2
server.js
server.js
+1
-1
No files found.
config/dev.json
View file @
1dec7a9e
...
...
@@ -2,7 +2,7 @@
"tokenEx"
:
86400000000
,
"dbURI"
:
"mongodb://bridata:Mingshu20170706@47.94.146.184:27017/letian?authSource=admin"
,
"file"
:
{
"storagePath"
:
"
public/avatar
"
"storagePath"
:
"
/uploadfiles
"
},
"device"
:
{
"secretKey"
:
"EB29BBD58E06997E"
,
...
...
controller/agrController.js
→
controller/agr
InputRecord
Controller.js
View file @
1dec7a9e
...
...
@@ -12,8 +12,8 @@ async function list(req, res, next) {
let
page
=
req
.
body
.
page
||
1
;
let
pageSize
=
req
.
body
.
pageSize
||
10
;
let
skip
=
(
page
-
1
)
*
pageSize
;
let
count
=
await
DB
.
AgrInRecord
.
countDocuments
(
search
)
let
list
=
await
DB
.
AgrInRecord
.
find
(
search
).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
let
count
=
await
DB
.
AgrIn
put
Record
.
countDocuments
(
search
)
let
list
=
await
DB
.
AgrIn
put
Record
.
find
(
search
).
skip
(
skip
).
limit
(
pageSize
).
lean
().
exec
();
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
)
...
...
@@ -23,7 +23,7 @@ async function list(req, res, next) {
async
function
create
(
req
,
res
,
next
)
{
try
{
let
ret
=
await
DB
.
AgrInRecord
.
create
(
req
.
body
)
let
ret
=
await
DB
.
AgrIn
put
Record
.
create
(
req
.
body
)
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
)
...
...
controller/fileController.js
View file @
1dec7a9e
const
ExcelJS
=
require
(
'exceljs'
);
const
path
=
require
(
'path'
);
async
function
upload
(
req
,
res
,
next
)
{
try
{
console
.
log
(
req
.
file
,
req
.
body
);
await
DB
.
File
.
create
({
//
console.log(req.file, req.body);
let
ret
=
await
DB
.
File
.
create
({
originalname
:
req
.
file
.
originalname
,
mimetype
:
req
.
file
.
mimetype
,
filename
:
req
.
file
.
filename
,
path
:
req
.
file
.
path
,
size
:
req
.
file
.
size
,
url
:
'有待处理'
,
});
res
.
sendData
(
re
q
.
file
);
res
.
sendData
(
re
t
);
}
catch
(
error
)
{
next
(
error
);
}
...
...
db/index.js
View file @
1dec7a9e
...
...
@@ -30,14 +30,14 @@ mongoose.connection.on('disconnected', () => {
const
User
=
require
(
'./models/systemUser'
);
const
Role
=
require
(
'./models/systemRole'
);
const
Menu
=
require
(
'./models/systemMenu'
);
const
Button
=
require
(
'./models/systemButton'
);
//
const Button = require('./models/systemButton');
const
Depart
=
require
(
'./models/systemDepart'
);
const
File
=
require
(
'./models/systemFile'
);
const
Notice
=
require
(
'./models/systemNotice'
);
const
Land
=
require
(
'./models/letianLand'
);
const
Zone
=
require
(
'./models/letianZone'
);
const
AgrIn
Record
=
require
(
'./models/letianAgrIn
Record'
);
const
AgrIn
putRecord
=
require
(
'./models/letianAgrInput
Record'
);
const
AreaRecord
=
require
(
'./models/letianAreaRecord'
);
...
...
@@ -55,18 +55,18 @@ const CollectThreshold = require('./models/collectThreshold');
const
RequestLog
=
require
(
'./models/systemRequestLog'
);
global
.
DB
=
{
File
,
User
,
Role
,
Menu
,
Button
,
Device
,
Depart
,
File
,
Notice
,
Land
,
Zone
,
AgrInRecord
,
AgrIn
put
Record
,
AreaRecord
,
CollectThreshold
,
...
...
db/models/letianAgrInRecord.js
→
db/models/letianAgrIn
put
Record.js
View file @
1dec7a9e
...
...
@@ -5,7 +5,7 @@ const moment = require('moment');
/**
* 乐田 农业投入品 出入库记录表 时间 生产投入品名称 投入品类别 总投入品使用数量 单位
*/
const
letianAgrInRecordSchema
=
new
Schema
({
const
letianAgrIn
put
RecordSchema
=
new
Schema
({
time
:
{
type
:
Date
,
...
...
@@ -60,5 +60,5 @@ const letianAgrInRecordSchema = new Schema({
});
const
AgrInRecord
=
mongoose
.
model
(
'AgrInRecord'
,
letianAgrInRecordSchema
,
'letianAgrInRecord'
);
module
.
exports
=
AgrInRecord
;
\ No newline at end of file
const
AgrInputRecord
=
mongoose
.
model
(
'letianAgrInputRecord'
,
letianAgrInputRecordSchema
,
'letianAgrInputRecord'
);
module
.
exports
=
AgrInputRecord
;
\ No newline at end of file
db/models/letianAgrTask.js
View file @
1dec7a9e
...
...
@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
const
moment
=
require
(
'moment'
);
/**
*
地块 --- 园区 ---- 乡镇(这个等级暂时不做)
*
农事任务
*/
const
AgrTaskSchema
=
new
Schema
({
...
...
@@ -29,6 +29,12 @@ const AgrTaskSchema = new Schema({
comment
:
"负责人--从分配负责人开始,任务就开启"
},
creator
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'User'
,
comment
:
"创建人"
},
createdAt
:
{
type
:
Date
,
...
...
db/models/letianAgrTaskRecord.js
0 → 100644
View file @
1dec7a9e
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
/**
* 农事任务---农事记录,一个任务 对应多条农事记录
*/
const
AgrTaskSchema
=
new
Schema
({
task
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
"AgrTask"
,
},
imgs
:
{
type
:
[
mongoose
.
Types
.
ObjectId
],
},
creator
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'User'
,
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
AgrTask
=
mongoose
.
model
(
'AgrTask'
,
AgrTaskSchema
,
'letianAgrTask'
);
module
.
exports
=
AgrTask
;
\ No newline at end of file
db/models/letianPurchase.js
deleted
100644 → 0
View file @
5d6ffe40
// const mongoose = require('mongoose');
// const Schema = mongoose.Schema;
// const moment = require('moment');
// /**
// * 乐田 农业投入品 采购
// */
// const letianAgrInRecordSchema = new Schema({
// purchaseDate: {
// type: Date,
// // default: Date.now,
// get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
// comment: "购买日期"
// },
// name: {
// type: String,
// required: true,
// commnet: "产品名称",
// },
// specifications: {
// type: String,
// comment: "规格"
// },
// ingredients: {
// type: String,
// comment: "成分"
// },
// shipmentQuantity: {
// type: Number,
// default: 0,
// comment: "出货数量"
// },
// unit: {
// type: String,
// comment: "单位"
// },
// shippingPrice: {
// type: String,
// comment: "出货价格(元)"
// },
// totalAmount : {
// type: String,
// comment: "合计金额(元)"
// },
// consumption : {
// type: String,
// comment: "用量"
// },
// agent : {
// type: String,
// comment: "代理商"
// },
// remarks : {
// type: String,
// 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:表示删除,若有其他隐藏业务 不要混用此字段。'
// }
// }, {
// id: false,
// toJSON: {
// getters: true,
// }
// });
// const AgrInRecord = mongoose.model('AgrInRecord', letianAgrInRecordSchema, 'letianAgrInRecord');
// module.exports = AgrInRecord;
\ No newline at end of file
db/models/systemUser.js
View file @
1dec7a9e
...
...
@@ -54,6 +54,12 @@ const userSchema = new Schema({
default
:
1
},
avatar
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'File'
,
comment
:
"头像文件"
},
...
...
router/agrRouter.js
View file @
1dec7a9e
...
...
@@ -2,10 +2,10 @@
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
agr
Controller
=
require
(
'../controller/agr
Controller'
);
const
agr
InputRecordController
=
require
(
'../controller/agrInputRecord
Controller'
);
router
.
post
(
'/
list'
,
agr
Controller
.
list
);
router
.
post
(
'/create'
,
agr
Controller
.
create
);
router
.
post
(
'/
input/list'
,
agrInputRecord
Controller
.
list
);
// router.post('/create', agrInputRecord
Controller.create);
// router.post('/update', fileController.update);
// router.post('/upload', fileController.list);
...
...
router/fileRouter.js
View file @
1dec7a9e
...
...
@@ -4,6 +4,7 @@ const router = express.Router();
const
multer
=
require
(
'multer'
);
const
path
=
require
(
'path'
);
const
fs
=
require
(
'fs'
);
const
moment
=
require
(
'moment'
);
const
mongoose
=
require
(
'mongoose'
);
...
...
@@ -12,7 +13,10 @@ const fileController = require('../controller/fileController');
const
storage
=
multer
.
diskStorage
({
destination
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
sysConfig
.
file
.
storagePath
||
'public/avatar'
);
//相对路径
if
(
sysConfig
.
file
.
storagePath
&&
!
fs
.
existsSync
(
sysConfig
.
file
.
storagePath
))
{
fs
.
mkdirSync
(
sysConfig
.
file
.
storagePath
,
{
recursive
:
true
});
}
cb
(
null
,
sysConfig
.
file
.
storagePath
);
},
filename
:
function
(
req
,
file
,
cb
)
{
let
ext
=
path
.
extname
(
file
.
originalname
);
// 获取文件扩展名
...
...
@@ -28,6 +32,8 @@ const upload = multer({ storage: storage })
router
.
post
(
'/upload'
,
upload
.
single
(
'file'
),
fileController
.
upload
);
// router.post('/')
// 文件访问: 起nginx用以处理文件服务器。
...
...
router/index.js
View file @
1dec7a9e
...
...
@@ -13,7 +13,7 @@ const deviceRouter = require('./deviceRouter');
const
landRouter
=
require
(
'./landRouter'
);
const
zoneRouter
=
require
(
'./zoneRouter'
);
const
agrRouter
=
require
(
'./agrRouter'
);
const
agr
Input
Router
=
require
(
'./agrRouter'
);
const
statisticsRouter
=
require
(
'./statisticsRouter'
);
...
...
@@ -34,7 +34,7 @@ router.use('/device', deviceRouter); // 硬件设备
router
.
use
(
'/land'
,
landRouter
);
//地块
router
.
use
(
'/zone'
,
zoneRouter
);
//区域--可扩展为行政区划
router
.
use
(
'/agr'
,
agrRouter
);
// 农业投入品相关
router
.
use
(
'/agr'
,
agr
Input
Router
);
// 农业投入品相关
router
.
use
(
'/statistics'
,
statisticsRouter
);
// 统计 大屏
...
...
server.js
View file @
1dec7a9e
...
...
@@ -37,7 +37,7 @@ app.use(compress());
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
false
}));
console
.
log
(
__dirname
)
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'public'
)
));
app
.
use
(
express
.
static
(
sysConfig
.
file
.
storagePath
));
app
.
use
(
logger
(
'dev'
));
...
...
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