明树Git Lab

Commit 7b662bc7 authored by zfp1's avatar zfp1

update

parent 481eb622
......@@ -38,7 +38,8 @@
2. 从入库逻辑开始 入库单增删改查、入库单开启流程......
1. 收获周期管理,按名称与导入对应
2. 农事预警,脚本每日扫描一次,到对应周期则提示周期信息
```
......
{
"tokenEx": 86400000000,
"dbURI": "mongodb://bridata:Mingshu20170706@47.94.146.184:27017/letian?authSource=admin",
"dbURI": "mongodb://127.0.0.1:27017/letian?authSource=admin",
"file": {
"storagePath": "/uploadfiles"
},
......@@ -36,6 +36,8 @@
"cron": {
"getDeviceList": false,
"getAllDevice": false,
"collectDeviceInfo": false
"collectDeviceInfo": false,
"collectDeviceInfo4": false,
"excel": false
}
}
\ No newline at end of file
const errorMessage = require("../utils/errorMessage");
async function listPlantCycle(req, res, next) {
try {
// let userId = req.user._id;
let search = { del: 0 };
let page = req.body.page || 1;
let pageSize = req.body.pageSize || 10;
let skip = (page - 1) * pageSize;
const count = await DB.PlantCycle.countDocuments(search);
let list = await DB.PlantCycle.find(search).sort({_id: -1}).skip(skip).limit(pageSize);
res.sendData({ count, list });
} catch (error) {
next(error)
}
}
async function createPlantCycle(req, res, next) {
try {
const body = req.body;
let ret = await DB.PlantCycle.create(body);
res.sendData(ret);
} catch (error) {
next(error)
}
}
async function deletePlantCycle(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let ret = await DB.PlantCycle.findOneAndUpdate({_id: req.body._id}, {del: 1});
res.sendData(ret);
} catch (error) {
next(error)
}
}
async function updatePlantCycle(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let upInfo = {
...req.body,
_id: undefined,
}
let ret = await DB.PlantCycle.findOneAndUpdate({_id: req.body._id}, upInfo);
res.sendData(ret);
} catch (error) {
next(error)
}
}
/**-----------------------种植规划 暂时字段类型不确定---------------------------- */
async function createPlan(req, res, next) {
try {
//
const body = req.body;
let ret = await DB.PlantPlan.create(body);
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function listPlan(req, res, next) {
try {
let search = { del: 0 };
let page = req.body.page || 1;
let pageSize = req.body.pageSize || 10;
let skip = (page - 1) * pageSize;
const count = await DB.PlantPlan.countDocuments(search);
let list = await DB.PlantPlan.find(search).sort({_id: -1}).skip(skip).limit(pageSize);
res.sendData({ count, list });
} catch (error) {
next(error);
}
}
async function deletePlan(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let ret = await DB.PlantPlan.findOneAndUpdate({_id: req.body._id}, {del: 1});
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function updatePlan(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let upInfo = {
...req.body,
_id: undefined,
}
let ret = await DB.PlantPlan.findOneAndUpdate({_id: req.body._id}, upInfo);
res.sendData(ret);
} catch (error) {
next(error);
}
}
module.exports = {
createPlantCycle,
listPlantCycle,
deletePlantCycle,
updatePlantCycle,
createPlan,
listPlan,
deletePlan,
updatePlan,
}
\ No newline at end of file
......@@ -34,9 +34,6 @@ const Menu = require('./models/systemMenu');
const Depart = require('./models/systemDepart');
const File = require('./models/systemFile');
const Notice = require('./models/systemNotice');
const FlowDef = require('./models/systemFlowDef');
const FlowDefNode = require('./models/systemFlowDefNode');
const FlowDefRelation = require('./models/systemFlowDefRelation');
const Land = require('./models/letianLand');
const Zone = require('./models/letianZone');
......@@ -51,7 +48,8 @@ const FileTemplate = require('./models/letianFileTemplate');
const AreaRecord = require('./models/letianAreaRecord');
const ExcelRecord = require('./models/letianExcelRecord');
const PlantCycle = require('./models/letianPlantCycle');
const PlantPlan = require('./models/letianPlantPlan');
const Device = require('./models/collectDevice');
const CollectSMC = require('./models/collectSMC');
......@@ -73,9 +71,6 @@ global.DB = {
Depart,
Notice,
FlowDef,
FlowDefNode,
FlowDefRelation,
Land,
Zone,
......@@ -89,6 +84,8 @@ global.DB = {
FileTemplate,
AreaRecord,
ExcelRecord,
PlantCycle,
PlantPlan,
Device,
CollectThreshold,
......
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 农事决策--由专家录入
*/
const AgrTaskSchema = new Schema({
content: {
},
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
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 农事任务
*/
const AgrTaskSchema = new Schema({
name: {
type: "任务名称",
},
agrType: {
type: Number,
comment: "农事类型",
},
startTime: {
type: Date,
omment: "任务开始日期",
},
endTime: {
type: Date,
omment: "任务结束日期",
},
leader: {
type: mongoose.Types.ObjectId,
ref: 'User',
comment: "负责人--从分配负责人开始, 任务就开启"
},
status: {
type: Number,
comment: "1. 待分配(没有leader), 3. 进行中, 5 已完成"
},
auditStatus: {
type: Number,
comment: "1. 待审核, 2, 审核通过, 3.审核不通过, 记录最新的审核记录"
},
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
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 农事任务审核记录
*/
const AgrTaskAuditSchema = new Schema({
creator: {
type: mongoose.Types.ObjectId,
ref: 'User',
comment: "创建人"
},
audit: {
type: mongoose.Types.ObjectId,
ref: 'User',
comment: "审核人"
},
auditStatus: {
type: Number,
comment: "1. 待审核, 2, 审核通过, 3.审核不通过, 记录任务上"
},
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 AgrTaskAudit = mongoose.model('AgrTaskAudit', AgrTaskAuditSchema, 'letianAgrTaskAudit');
module.exports = AgrTaskAudit;
\ No newline at end of file
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 农事记录,一个农事任务 对应多条农事记录
*/
const AgrTaskSchema = new Schema({
content: {
type: String,
comment: "内容"
},
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
......@@ -47,5 +47,5 @@ const PlantCycleSchema = new Schema({
});
const PlantCycle = mongoose.model('PlantCycle', PlantCycleSchema, 'letianPlantCycle');
const PlantCycle = mongoose.model('letianPlantCycle', PlantCycleSchema, 'letianPlantCycle');
module.exports = PlantCycle;
\ No newline at end of file
......@@ -7,15 +7,26 @@ const moment = require('moment');
*/
const PlantPlanSchema = new Schema({
plantType: {
type: String,
comment: "作物类型",
},
plantVariety: {
type: mongoose.Types.ObjectId,
ref: 'PlantVariety',
comment: "作物种类"
},
planNum: {
// land: {
// type: String,
// comment: "种植位置",
// },
plantArea: {
type: String,
unique: true,
comment: "种植计划编号"
comment: "种植面积",
},
estimatedYield: {
type: String,
comment: "预计产量",
},
// zone: {
// type: mongoose.Types.ObjectId,
......@@ -27,10 +38,6 @@ const PlantPlanSchema = new Schema({
ref: 'Land',
comment: "地块"
},
plantArea: {
type: Number,
comment: "种植面积"
},
plantStatus: {
type: String,
comment: "种植状态 采收、结束种植",
......
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
const flowDefRelationSchema = require('./systemFlowDefRelation')
const flowDefNodeSchema = require('./systemFlowDefNode')
/**
* 用户
*/
const flowDefSchema = new Schema({
name: {
type: String,
comment: "流程名称"
},
key: {
type: String,
unique: true,
comment: "流程唯一标识"
},
// relations: {
// type: [mongoose.Types.ObjectId],
// comment: "关系 线条",
// ref: 'FlowDefRelation'
// },
// nodes: {
// type: [mongoose.Types.ObjectId],
// comment: "节点",
// ref: 'FlowDefNode'
// },
relations: [
flowDefRelationSchema
],
nodes: [
flowDefNodeSchema
],
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 FlowDef = mongoose.model('FlowDef', flowDefSchema, 'systemFlowDef');
module.exports = FlowDef;
\ No newline at end of file
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 流程节点: relation node
*/
const flowDefNodeSchema = new Schema({
name: {
type: String,
comment: "节点名称"
},
key: {
type: String,
comment: "节点唯一标识"
},
handlerRole: {
type: mongoose.Types.ObjectId,
comment: "处理角色"
},
// conditions actions 有待扩展
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,
}
});
// flowDefNodeSchema.index({ _id: 1, key: 1 }, { unique: true })
// const FlowDefNode = mongoose.model('FlowDefNode', flowDefNodeSchema, 'systemFlowDefNode');
// module.exports = FlowDefNode;
module.exports = flowDefNodeSchema;
\ No newline at end of file
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 流程节点: relation node
*/
const flowDefRelationSchema = new Schema({
name: {
type: String,
comment: "连线名称"
},
preNode: {
type: mongoose.Types.ObjectId,
comment: "前置节点",
required: true,
},
postNode: {
type: mongoose.Types.ObjectId,
comment: "后置节点",
required: true,
},
// conditions actions 有待扩展
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 FlowDefRelation = mongoose.model('FlowDefRelation', flowDefRelationSchema, 'systemFlowDefRelation');
// module.exports = FlowDefRelation;
module.exports = flowDefRelationSchema;
\ No newline at end of file
......@@ -15,6 +15,7 @@ const landRouter = require('./landRouter');
const zoneRouter = require('./zoneRouter');
const agrInputRouter = require('./agrRouter');
const plantRouter = require('./plantRouter');
const statisticsRouter = require('./statisticsRouter');
const flowRouter = require('./flowRouter');
......@@ -37,6 +38,7 @@ router.use('/land', landRouter); //地块
router.use('/zone', zoneRouter); //区域--可扩展为行政区划
router.use('/agr', agrInputRouter); // 农业投入品相关
router.use('/plant', plantRouter); // 种植相关
router.use('/statistics', statisticsRouter); // 统计 大屏
......
const express = require('express');
const router = express.Router();
const plantContoller = require('../controller/plantContoller.js');
// 生长周期
router.post('/cycle/create', plantContoller.createPlantCycle);
router.post('/cycle/list', plantContoller.listPlantCycle);
router.post('/cycle/delete', plantContoller.deletePlantCycle);
router.post('/cycle/update', plantContoller.updatePlantCycle);
// 种植规划
router.post('/plan/create', plantContoller.createPlan);
router.post('/plan/list', plantContoller.listPlan);
router.post('/plan/delete', plantContoller.deletePlan);
router.post('/plan/update', plantContoller.updatePlan);
module.exports = router;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment