明树Git Lab

Commit 85fcf5ff authored by zfp1's avatar zfp1

update

parent 7b662bc7
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
"getAllDevice": false, "getAllDevice": false,
"collectDeviceInfo": false, "collectDeviceInfo": false,
"collectDeviceInfo4": false, "collectDeviceInfo4": false,
"excel": false "excel": false,
"plantearlywarning": false
} }
} }
\ No newline at end of file
...@@ -27,6 +27,7 @@ async function listPlantCycle(req, res, next) { ...@@ -27,6 +27,7 @@ async function listPlantCycle(req, res, next) {
async function createPlantCycle(req, res, next) { async function createPlantCycle(req, res, next) {
try { try {
const body = req.body; const body = req.body;
console.log(body, "====")
let ret = await DB.PlantCycle.create(body); let ret = await DB.PlantCycle.create(body);
res.sendData(ret); res.sendData(ret);
} catch (error) { } catch (error) {
...@@ -121,8 +122,161 @@ async function updatePlan(req, res, next) { ...@@ -121,8 +122,161 @@ async function updatePlan(req, res, next) {
} }
} }
/**--------------------------------------------直接种植--------------------------------------------------------- */
async function createDirectPlant(req, res, next) {
try {
//
const body = req.body;
let ret = await DB.ProductPlant.create(body);
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function listDirectPlant(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.ProductPlant.countDocuments(search);
let list = await DB.ProductPlant.find(search).sort({_id: -1}).skip(skip).limit(pageSize);
res.sendData({ count, list });
} catch (error) {
next(error);
}
}
async function deleteDirectPlant(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let ret = await DB.ProductPlant.findOneAndUpdate({_id: req.body._id}, {del: 1});
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function updateDirectPlant(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let upInfo = {
...req.body,
_id: undefined,
}
let ret = await DB.ProductPlant.findOneAndUpdate({_id: req.body._id}, upInfo);
res.sendData(ret);
} catch (error) {
next(error);
}
}
/**--------------------------------------------初加工--------------------------------------------------------- */
async function createPrePlant(req, res, next) {
try {
//
const body = req.body;
let ret = await DB.ProductPre.create(body);
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function listPrePlant(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.ProductPre.countDocuments(search);
let list = await DB.ProductPre.find(search).sort({_id: -1}).skip(skip).limit(pageSize);
res.sendData({ count, list });
} catch (error) {
next(error);
}
}
async function deletePrePlant(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let ret = await DB.ProductPre.findOneAndUpdate({_id: req.body._id}, {del: 1});
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function updatePrePlant(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let upInfo = {
...req.body,
_id: undefined,
}
let ret = await DB.ProductPre.findOneAndUpdate({_id: req.body._id}, upInfo);
res.sendData(ret);
} catch (error) {
next(error);
}
}
/**--------------------------------------------深加工--------------------------------------------------------- */
async function createDeepPlant(req, res, next) {
try {
//
const body = req.body;
let ret = await DB.ProductDeep.create(body);
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function listDeepPlant(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.ProductDeep.countDocuments(search);
let list = await DB.ProductDeep.find(search).sort({_id: -1}).skip(skip).limit(pageSize);
res.sendData({ count, list });
} catch (error) {
next(error);
}
}
async function deleteDeepPlant(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let ret = await DB.ProductDeep.findOneAndUpdate({_id: req.body._id}, {del: 1});
res.sendData(ret);
} catch (error) {
next(error);
}
}
async function updateDeepPlant(req, res, next) {
try {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let upInfo = {
...req.body,
_id: undefined,
}
let ret = await DB.ProductDeep.findOneAndUpdate({_id: req.body._id}, upInfo);
res.sendData(ret);
} catch (error) {
next(error);
}
}
...@@ -136,5 +290,17 @@ module.exports = { ...@@ -136,5 +290,17 @@ module.exports = {
listPlan, listPlan,
deletePlan, deletePlan,
updatePlan, updatePlan,
createDirectPlant,
listDirectPlant,
deleteDirectPlant,
updateDirectPlant,
createPrePlant,
listPrePlant,
deletePrePlant,
updatePrePlant,
createDeepPlant,
listDeepPlant,
deleteDeepPlant,
updateDeepPlant,
} }
\ No newline at end of file
...@@ -10,6 +10,8 @@ const wsCron = require('./wsCron'); ...@@ -10,6 +10,8 @@ const wsCron = require('./wsCron');
const ipsCron = require('./ipsCron'); const ipsCron = require('./ipsCron');
// excel // excel
const excelCron = require('./excelCron'); const excelCron = require('./excelCron');
// 农事预警
const plantWarnCron = require('./plantWarnCron');
/** /**
根据config cron 配置 定时处理 根据config cron 配置 定时处理
...@@ -95,6 +97,16 @@ const cron = () => { ...@@ -95,6 +97,16 @@ const cron = () => {
}, { timezone: "Asia/Shanghai" }); }, { timezone: "Asia/Shanghai" });
} }
// 每天
if (sysConfig && sysConfig.cron && sysConfig.cron.plantearlywarning) {
console.log("plant:", new Date());
new nodeCron.schedule('1 01 06 * * *', async () => {
console.log(new Date().getTime())
await plantWarnCron.plantearlywarning();
}, { timezone: "Asia/Shanghai" });
}
} }
module.exports = cron; module.exports = cron;
\ No newline at end of file
const httpRequest = require('../utils/httpRequest');
const _ = require('lodash');
async function plantearlywarning(params) {
//这里暂时不确定 收获周期的格式
}
module.exports = {
plantearlywarning
}
\ No newline at end of file
...@@ -50,6 +50,9 @@ const ExcelRecord = require('./models/letianExcelRecord'); ...@@ -50,6 +50,9 @@ const ExcelRecord = require('./models/letianExcelRecord');
const PlantCycle = require('./models/letianPlantCycle'); const PlantCycle = require('./models/letianPlantCycle');
const PlantPlan = require('./models/letianPlantPlan'); const PlantPlan = require('./models/letianPlantPlan');
const ProductPlant = require('./models/letianProductPlant');
const ProductPre = require('./models/letianProductPre');
const ProductDeep = require('./models/letianProductDeep');
const Device = require('./models/collectDevice'); const Device = require('./models/collectDevice');
const CollectSMC = require('./models/collectSMC'); const CollectSMC = require('./models/collectSMC');
...@@ -86,6 +89,10 @@ global.DB = { ...@@ -86,6 +89,10 @@ global.DB = {
ExcelRecord, ExcelRecord,
PlantCycle, PlantCycle,
PlantPlan, PlantPlan,
ProductPlant,
ProductPre,
ProductDeep,
Device, Device,
CollectThreshold, CollectThreshold,
......
...@@ -6,23 +6,32 @@ const moment = require('moment'); ...@@ -6,23 +6,32 @@ const moment = require('moment');
* 种植周期 * 种植周期
*/ */
const PlantCycleSchema = new Schema({ const PlantCycleSchema = new Schema({
name: { name: {
type: String, type: String,
comment: "种植周期名称", comment: "作物名称",
},
startTime: {
type: Date,
}, },
endTime: { cycleName: {
type: Date, type: String,
comment: "周期名称",
}, },
content: { content: {
type: String, type: String,
comment: "内容 : 注意事项" comment: "内容 : 注意事项"
}, },
times: {
type: [
{
startTime: {
type: Date,
},
endTime: {
type: Date,
},
}
],
},
createdAt: { createdAt: {
type: Date, type: Date,
......
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 深加工成果产品 --- 关联初加工成果产品,关联初加工场地摄像头、深加工过程数据(工业信息采集数据)。
*/
const letianProductDeepSchema = new Schema({
sourcePlantProduct: {
type: String,
comment: "来源初加工产品 靠产品名称关联"
},
preProductName: {
type: String,
comment: "深加工产品名称"
},
varieties: {
type: String,
comment: "品种"
},
warehouseName: {
type: String,
comment: "仓库名称"
},
inventoryQuantity: {
type: String,
comment: "库存量"
},
productPhotos: {
type: String,
comment: "产品照片"
},
introduction: {
type: String,
comment: "介绍内容"
},
processTime: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
},
qualityInfo: {
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:表示删除,若有其他隐藏业务 不要混用此字段。'
}
}, {
toJSON: {
getters: true
}
});
const ProductDeep = mongoose.model('letianProductDeep', letianProductDeepSchema, 'letianProductDeep');
module.exports = ProductDeep;
\ No newline at end of file
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 直接种植收获产品 -- 关联种植规划信息,包括地块、种植周期、收获时间等,关联该地块的监控摄像头数据。
*/
const letianProductPlantSchema = new Schema({
productName: {
type: String,
comment: "产品名称"
},
varieties: {
type: String,
comment: "品种"
},
productPhotos: {
type: String,
comment: "产品照片"
},
productIntro: {
type: String,
comment: "产品介绍"
},
qualityInfor: {
type: String,
comment: "质量信息"
},
plantPlan: {
type: mongoose.Types.ObjectId,
ref: 'PlantPlan',
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 ProductPlant = mongoose.model('letianProductPlant', letianProductPlantSchema, 'letianProductPlant');
module.exports = ProductPlant;
\ No newline at end of file
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 初加工成果产品 --- 关联对应的直接种植收获产品,关联初加工场地的摄像头监控数据。
*/
const letianProductPreSchema = new Schema({
sourcePlantProduct: {
type: String,
comment: "来源种植产品"
},
preProductName: {
type: String,
comment: "初加工产品名称"
},
varieties: {
type: String,
comment: "品种"
},
warehouseName: {
type: String,
comment: "仓库名称"
},
inventoryQuantity: {
type: String,
comment: "库存量"
},
productPhotos: {
type: String,
comment: "产品照片"
},
introduction: {
type: String,
comment: "介绍内容"
},
processTime: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
},
qualityInfo: {
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:表示删除,若有其他隐藏业务 不要混用此字段。'
}
}, {
toJSON: {
getters: true
}
});
const ProductPre = mongoose.model('letianProductPre', letianProductPreSchema, 'letianProductPre');
module.exports = ProductPre;
\ No newline at end of file
...@@ -16,5 +16,22 @@ router.post('/plan/list', plantContoller.listPlan); ...@@ -16,5 +16,22 @@ router.post('/plan/list', plantContoller.listPlan);
router.post('/plan/delete', plantContoller.deletePlan); router.post('/plan/delete', plantContoller.deletePlan);
router.post('/plan/update', plantContoller.updatePlan); router.post('/plan/update', plantContoller.updatePlan);
// 直接种植
router.post('/product/direct/create', plantContoller.createDirectPlant);
router.post('/product/direct/list', plantContoller.listDirectPlant);
router.post('/product/direct/delete', plantContoller.deleteDirectPlant);
router.post('/product/direct/update', plantContoller.updateDirectPlant);
// 初加工
router.post('/product/pre/create', plantContoller.createPrePlant);
router.post('/product/pre/list', plantContoller.listPrePlant);
router.post('/product/pre/delete', plantContoller.deletePrePlant);
router.post('/product/pre/update', plantContoller.updatePrePlant);
// 深加工
router.post('/product/deep/create', plantContoller.createDeepPlant);
router.post('/product/deep/list', plantContoller.listDeepPlant);
router.post('/product/deep/delete', plantContoller.deleteDeepPlant);
router.post('/product/deep/update', plantContoller.updateDeepPlant);
module.exports = router; 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