明树Git Lab

Commit b8cae0ca authored by zfp1's avatar zfp1

update

parent 9377401a
......@@ -195,11 +195,11 @@ async function getJiankong(req, res, next) {
console.log(sourceId, "===")
let source = null;
if (traccode.type && traccode.type == 1) {
source = await DB.ProductPlant.findOne({ _id: sourceId }, { monitorInfo: 1 }).populate({ path: "monitorInfo.device" }).lean();
source = await DB.ProductPlant.findOne({ _id: sourceId }, { monitorInfo: 1 ,monitorInfoForInt:1}).populate({ path: "monitorInfo.device" }).populate({ path: "monitorInfoForInt.device" }).lean();
} else if (traccode.type && traccode.type == 2) {
source = await DB.ProductPre.findOne({ _id: sourceId }, { monitorInfo: 1 }).populate({ path: "monitorInfo.device" }).lean();
source = await DB.ProductPre.findOne({ _id: sourceId }, { monitorInfo: 1 ,monitorInfoForInt:1}).populate({ path: "monitorInfo.device" }).populate({ path: "monitorInfoForInt.device" }).lean();
} else if (traccode.type && traccode.type == 3) {
source = await DB.ProductDeep.findOne({ _id: sourceId }, { monitorInfo: 1 }).populate({ path: "monitorInfo.device" }).lean();
source = await DB.ProductDeep.findOne({ _id: sourceId }, { monitorInfo: 1 ,monitorInfoForInt:1}).populate({ path: "monitorInfo.device" }).populate({ path: "monitorInfoForInt.device" }).lean();
}
//查询一下土壤采集数据
......@@ -246,6 +246,20 @@ async function getZhijian(req, res, next) {
next(error);
}
}
async function batchAgrEnvOnOff(req, res, next) {
try {
let ids = req.body._ids;
if(_.isBoolean(req.body.agrOnOff)) {
await DB.ProTraceCode.updateMany({_id: {$in: ids}}, {agrOnOff: req.body.agrOnOff});
}
if(_.isBoolean(req.body.indEnvOnOff)) {
await DB.ProTraceCode.updateMany({_id: {$in: ids}}, {indEnvOnOff: req.body.indEnvOnOff});
}
res.sendData();
} catch (error) {
next(error);
}
}
......@@ -259,4 +273,5 @@ module.exports = {
getsuyuanBase,
getJiankong,
getZhijian,
batchAgrEnvOnOff,
}
\ No newline at end of file
......@@ -102,6 +102,22 @@ const letianProductDeepSchema = new Schema({
}
]
},
monitorInfoForInt: { //工业
type: [
{
name: String,
// deviceSectorType: {
// type: Number,
// comment: "1, 农业 2 工业"
// },
device: {
type: mongoose.Types.ObjectId,
ref: 'collectDevice',
comment: "设备"
}
}
]
},
productSpec: {
type: String,
comment: "产品规格"
......
......@@ -96,7 +96,22 @@ const letianProductPlantSchema = new Schema({
}
]
},
monitorInfoForInt: { //工业
type: [
{
name: String,
// deviceSectorType: {
// type: Number,
// comment: "1, 农业 2 工业"
// },
device: {
type: mongoose.Types.ObjectId,
ref: 'collectDevice',
comment: "设备"
}
}
]
},
//原料信息
agrProVar: {
type: String,
......
......@@ -86,7 +86,7 @@ const letianProductPreSchema = new Schema({
comment: "农残质检报告"
}
],
monitorInfo: {
monitorInfo: { //农业
type: [
{
name: String,
......@@ -102,6 +102,22 @@ const letianProductPreSchema = new Schema({
}
]
},
monitorInfoForInt: { //工业
type: [
{
name: String,
// deviceSectorType: {
// type: Number,
// comment: "1, 农业 2 工业"
// },
device: {
type: mongoose.Types.ObjectId,
ref: 'collectDevice',
comment: "设备"
}
}
]
},
//原料信息
agrProVar: {
......
......@@ -50,5 +50,8 @@ router.post('/product/trace/info2', productTracController.getTraceCode2); //溯
router.post('/product/trace/suyuan', productTracController.getsuyuanBase); // 溯源信息
router.post('/product/trace/jiankong', productTracController.getJiankong); // 实时监控
router.post('/product/trace/zhijian', productTracController.getZhijian); // 质量检测报告
router.post('/product/trace/onoff', productTracController.batchAgrEnvOnOff); // 质量检测报告
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