明树Git Lab

Commit cd3d8a75 authored by zfp1's avatar zfp1

update

parent 0b9cdcf3
......@@ -5,11 +5,11 @@ 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 || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let ret = await DB.ProductDeep.create(body);
res.sendData(ret);
} catch (error) {
......@@ -26,7 +26,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: "productPhotos2"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
let list = await DB.ProductDeep.find(search).populate({path: "productPhotos2"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list });
} catch (error) {
next(error);
......@@ -49,11 +49,11 @@ async function updateDeepPlant(req, res, next) {
return res.sendError(errorMessage.resourceNotFound);
}
let body = req.body;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let upInfo = {
...body,
_id: undefined,
......
......@@ -5,11 +5,11 @@ 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 || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let ret = await DB.ProductPlant.create(body);
res.sendData(ret);
} catch (error) {
......@@ -27,7 +27,7 @@ async function listDirectPlant(req, res, next) {
}
const count = await DB.ProductPlant.countDocuments(search);
let list = await DB.ProductPlant.find(search).populate({path: "plantPlan"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "productPhotos2"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
let list = await DB.ProductPlant.find(search).populate({path: "plantPlan"}).populate({path: "homepageCarouselImgs"}).populate({path: "productPhotos2"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list });
} catch (error) {
next(error);
......@@ -50,11 +50,11 @@ async function updateDirectPlant(req, res, next) {
return res.sendError(errorMessage.resourceNotFound);
}
let body = req.body;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
let upInfo = {
...body,
_id: undefined,
......
......@@ -6,9 +6,9 @@ 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 || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
let ret = await DB.ProductPre.create(body);
......@@ -27,7 +27,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: "productPhotos2"}).populate({path: "sourcePlantProduct"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
let list = await DB.ProductPre.find(search).populate({path: "productPhotos2"}).populate({path: "sourcePlantProduct"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list });
} catch (error) {
next(error);
......@@ -50,9 +50,9 @@ async function updatePrePlant(req, res, next) {
return res.sendError(errorMessage.resourceNotFound);
}
let body = req.body;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
// body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
// body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => {return o && o._id || o});
// body.pesticidetImgs = (body.pesticidetImgs || []).map(o => {return o && o._id || o});
body.homepageCarouselImgs = (body.homepageCarouselImgs || []).map(o => {return o && o._id || o});
body.productPhotos2 = (body.productPhotos2 || []).map(o => {return o && o._id || o});
let upInfo = {
......
......@@ -11,9 +11,12 @@ async function createTraceCode(req, res, next) {
body.creator = req.user._id;
// 生成溯源码:/改成临时拼接,编辑时无动作
let tcodepre = `271Y8U`;
tcodeend = utils.generateRandomCode(4);
body.tcodepre = tcodepre;
tcodeend = utils.generateRandomCode(4);
body.tcodepre = tcodepre;
body.tcodeend = tcodeend;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => { return o && o._id || o });
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => { return o && o._id || o });
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => { return o && o._id || o });
let ret = await DB.ProTraceCode.create(body);
res.sendData(ret);
} catch (error) {
......@@ -33,7 +36,7 @@ async function listTraceCode(req, res, next) {
search.batchNumber = { $regex: req.body.batchNumber }
}
const count = await DB.ProTraceCode.countDocuments(search);
let list = await DB.ProTraceCode.find(search).sort({ _id: -1 }).skip(skip).limit(pageSize).populate({path: "rawMatCul.proSteps.img"}).populate({path: "proProcess.proSteps.img"}).populate({path: "cjVideo"}).lean();
let list = await DB.ProTraceCode.find(search).sort({ _id: -1 }).skip(skip).limit(pageSize).populate({ path: "rawMatCul.proSteps.img" }).populate({ path: "proProcess.proSteps.img" }).populate({ path: "cjVideo" }).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "pesticidetImgs"}).lean();
let ret = [];
for (let index = 0; index < list.length; index++) {
const element = list[index];
......@@ -67,8 +70,12 @@ async function updateTraceCode(req, res, next) {
if (!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let body = req.body;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => { return o && o._id || o });
body.flourMerchantImgs = (body.flourMerchantImgs || []).map(o => { return o && o._id || o });
body.pesticidetImgs = (body.pesticidetImgs || []).map(o => { return o && o._id || o });
let upInfo = {
...req.body,
...body,
_id: undefined,
}
let ret = await DB.ProTraceCode.findOneAndUpdate({ _id: req.body._id }, upInfo);
......@@ -78,46 +85,46 @@ async function updateTraceCode(req, res, next) {
}
}
async function getTraceCode(req, res, next) {
try {
if (!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }).lean();
if (!(traccode && traccode._id && traccode.source)) {
return res.sendError(errorMessage.resourceNotFound);
}
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" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).populate({ path: "monitorInfo.device" }).lean().exec();
if (source && source.plantPlan && source.plantPlan.land) {
let devices = await DB.Device.find({ land: { $in: source.plantPlan.land }, deviceHQType: 5 }).lean();
source.devices = devices;
} else {
source.devices = [];
}
} else if (traccode.type && traccode.type == 2) {
source = await DB.ProductPre.findOne({ _id: sourceId }).populate({ path: "productPhotos" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).populate({ path: "monitorInfo.device" }).lean().exec();
} else if (traccode.type && traccode.type == 3) {
source = await DB.ProductDeep.findOne({ _id: sourceId }).populate({ path: "productPhotos" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).populate({ path: "monitorInfo.device" }).lean().exec();
}
console.log(source, "==")
// try {
// if (!req.body._id) {
// return res.sendError(errorMessage.resourceNotFound);
// }
// let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }).lean();
// if (!(traccode && traccode._id && traccode.source)) {
// return res.sendError(errorMessage.resourceNotFound);
// }
// 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" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).populate({ path: "monitorInfo.device" }).lean().exec();
// if (source && source.plantPlan && source.plantPlan.land) {
// let devices = await DB.Device.find({ land: { $in: source.plantPlan.land }, deviceHQType: 5 }).lean();
// source.devices = devices;
// } else {
// source.devices = [];
// }
// } else if (traccode.type && traccode.type == 2) {
// source = await DB.ProductPre.findOne({ _id: sourceId }).populate({ path: "productPhotos" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).populate({ path: "monitorInfo.device" }).lean().exec();
// } else if (traccode.type && traccode.type == 3) {
// source = await DB.ProductDeep.findOne({ _id: sourceId }).populate({ path: "productPhotos" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).populate({ path: "monitorInfo.device" }).lean().exec();
// }
// console.log(source, "==")
traccode.source = source;
//请求公司信息
let companyInfo = await DB.CompanyInfo.findOne({}).populate({ path: "companyInfoImgs" }).populate({ path: "addressInfo.img" }).lean().exec();
traccode.companyInfo = companyInfo || {};
res.sendData(traccode);
} catch (error) {
next(error);
}
// traccode.source = source;
// //请求公司信息
// let companyInfo = await DB.CompanyInfo.findOne({}).populate({ path: "companyInfoImgs" }).populate({ path: "addressInfo.img" }).lean().exec();
// traccode.companyInfo = companyInfo || {};
// res.sendData(traccode);
// } catch (error) {
// next(error);
// }
}
async function getTraceCode2(req, res, next) {
try {
if (!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { workshop:1, manufactureDate:1, type: 1, source: 1,batchNumber:1, tcodepre: 1, tcodeend: 1, productSalUrl: 1,queryNum: 1, firstQueryTime: 1, _id: 1 }).lean();
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { workshop: 1, manufactureDate: 1, type: 1, source: 1, batchNumber: 1, tcodepre: 1, tcodeend: 1, productSalUrl: 1, queryNum: 1, firstQueryTime: 1, _id: 1 }).lean();
if (!(traccode && traccode._id && traccode.source)) {
return res.sendError(errorMessage.resourceNotFound);
}
......@@ -151,7 +158,7 @@ async function getsuyuanBase(req, res, next) {
if (!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { type: 1, source: 1, _id: 1, batchNumber:1,manufactureDate:1 ,rawMatCul: 1, proProcess: 1 }).populate({ path: "proProcess.proSteps.img" }).populate({ path: "rawMatCul.proSteps.img" }).lean();
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { type: 1, source: 1, _id: 1, batchNumber: 1, manufactureDate: 1, rawMatCul: 1, proProcess: 1 }).populate({ path: "proProcess.proSteps.img" }).populate({ path: "rawMatCul.proSteps.img" }).lean();
if (!(traccode && traccode._id && traccode.source)) {
return res.sendError(errorMessage.resourceNotFound);
}
......@@ -161,9 +168,9 @@ async function getsuyuanBase(req, res, next) {
if (traccode.type && traccode.type == 1) {
source = await DB.ProductPlant.findOne({ _id: sourceId }, { productName: 1, productSpec: 1, manufactureDate: 1, batchNumber: 1, qualityInspector: 1, productUnit: 1, sellByDate: 1, sellByDateUnit: 1, productPhotos2: 1 }).populate({ path: "productPhotos2" }).populate({ path: "homepageCarouselImgs" }).lean();
} else if (traccode.type && traccode.type == 2) {
source = await DB.ProductPre.findOne({ _id: sourceId }, { preProductName: 1, productSpec: 1, manufactureDate: 1, batchNumber: 1, qualityInspector: 1, productUnit: 1, sellByDate: 1, sellByDateUnit: 1,productPhotos2: 1 }).populate({ path: "productPhotos2" }).populate({ path: "homepageCarouselImgs" }).lean();
source = await DB.ProductPre.findOne({ _id: sourceId }, { preProductName: 1, productSpec: 1, manufactureDate: 1, batchNumber: 1, qualityInspector: 1, productUnit: 1, sellByDate: 1, sellByDateUnit: 1, productPhotos2: 1 }).populate({ path: "productPhotos2" }).populate({ path: "homepageCarouselImgs" }).lean();
} else if (traccode.type && traccode.type == 3) {
source = await DB.ProductDeep.findOne({ _id: sourceId }, { preProductName: 1, productSpec: 1, manufactureDate: 1, batchNumber: 1, qualityInspector: 1, productUnit: 1, sellByDate: 1, sellByDateUnit: 1,productPhotos2: 1 }).populate({ path: "productPhotos2" }).populate({ path: "homepageCarouselImgs" }).lean();
source = await DB.ProductDeep.findOne({ _id: sourceId }, { preProductName: 1, productSpec: 1, manufactureDate: 1, batchNumber: 1, qualityInspector: 1, productUnit: 1, sellByDate: 1, sellByDateUnit: 1, productPhotos2: 1 }).populate({ path: "productPhotos2" }).populate({ path: "homepageCarouselImgs" }).lean();
}
source.manufactureDate = traccode.manufactureDate || source.manufactureDate;
source.batchNumber = traccode.batchNumber || source.batchNumber;
......@@ -178,7 +185,7 @@ async function getJiankong(req, res, next) {
if (!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { type: 1, source: 1, _id: 1, cjVideo: 1, agrOnOff: 1, indEnvOnOff: 1 }).populate({path: "cjVideo"}).lean();
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { type: 1, source: 1, _id: 1, cjVideo: 1, agrOnOff: 1, indEnvOnOff: 1 }).populate({ path: "cjVideo" }).lean();
if (!(traccode && traccode._id && traccode.source)) {
return res.sendError(errorMessage.resourceNotFound);
}
......@@ -186,18 +193,18 @@ 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 ,monitorInfoForInt:1}).populate({ path: "monitorInfo.device" }).populate({ path: "monitorInfoForInt.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 ,monitorInfoForInt:1}).populate({ path: "monitorInfo.device" }).populate({ path: "monitorInfoForInt.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 ,monitorInfoForInt:1}).populate({ path: "monitorInfo.device" }).populate({ path: "monitorInfoForInt.device" }).lean();
source = await DB.ProductDeep.findOne({ _id: sourceId }, { monitorInfo: 1, monitorInfoForInt: 1 }).populate({ path: "monitorInfo.device" }).populate({ path: "monitorInfoForInt.device" }).lean();
}
//查询一下土壤采集数据
if (traccode.agrOnOff) {
// 气象 土壤
let ws = await DB.CollectWS.findOne().sort({time:-1}).lean();
let smc = await DB.CollectSMC.findOne().sort({time:-1}).lean();
let ws = await DB.CollectWS.findOne().sort({ time: -1 }).lean();
let smc = await DB.CollectSMC.findOne().sort({ time: -1 }).lean();
//
let onlineArr = await deviceModule.getDeviceOnlineMap();
smc.onLineState = onlineArr.includes(smc.deviceNumber) ? "1" : "0";
......@@ -210,7 +217,7 @@ async function getJiankong(req, res, next) {
// 工业环境
}
let companyInfo = await DB.CompanyInfo.findOne({}, {gcImg: 1, jdImg:1}).populate({ path: "gcImg" }).populate({ path: "jdImg" });
let companyInfo = await DB.CompanyInfo.findOne({}, { gcImg: 1, jdImg: 1 }).populate({ path: "gcImg" }).populate({ path: "jdImg" });
traccode.gcImg = companyInfo.gcImg;
traccode.jdImg = companyInfo.jdImg;
traccode.source = source;
......@@ -224,21 +231,10 @@ async function getZhijian(req, res, next) {
if (!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { type: 1, source: 1, _id: 1 }).lean();
let traccode = await DB.ProTraceCode.findOne({ _id: req.body._id }, { type: 1, source: 1, _id: 1 , pesticidetImgs: 1, qualityInsReportImgs: 1, flourMerchantImgs: 1}).lean();
if (!(traccode && traccode._id && traccode.source)) {
return res.sendError(errorMessage.resourceNotFound);
}
let sourceId = traccode.source;
let source = null;
if (traccode.type && traccode.type == 1) {
source = await DB.ProductPlant.findOne({ _id: sourceId }, { pesticidetImgs: 1, qualityInsReportImgs: 1, flourMerchantImgs: 1 }).populate({ path: "pesticidetImgs" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).lean();
} else if (traccode.type && traccode.type == 2) {
source = await DB.ProductPre.findOne({ _id: sourceId }, { pesticidetImgs: 1, qualityInsReportImgs: 1, flourMerchantImgs: 1 }).populate({ path: "pesticidetImgs" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).lean();
} else if (traccode.type && traccode.type == 3) {
source = await DB.ProductDeep.findOne({ _id: sourceId }, { pesticidetImgs: 1, qualityInsReportImgs: 1, flourMerchantImgs: 1 }).populate({ path: "pesticidetImgs" }).populate({ path: "qualityInsReportImgs" }).populate({ path: "flourMerchantImgs" }).lean();
}
traccode.source = source;
res.sendData(traccode);
} catch (error) {
next(error);
......@@ -248,14 +244,14 @@ async function batchAgrEnvOnOff(req, res, next) {
try {
let ids = req.body._ids;
let search = {}
if(ids && _.isArray(ids) && ids.length) {
search = {_id: {$in: ids}}
if (ids && _.isArray(ids) && ids.length) {
search = { _id: { $in: ids } }
}
if(_.isBoolean(req.body.agrOnOff)) {
await DB.ProTraceCode.updateMany(search, {agrOnOff: req.body.agrOnOff});
if (_.isBoolean(req.body.agrOnOff)) {
await DB.ProTraceCode.updateMany(search, { agrOnOff: req.body.agrOnOff });
}
if(_.isBoolean(req.body.indEnvOnOff)) {
await DB.ProTraceCode.updateMany(search, {indEnvOnOff: req.body.indEnvOnOff});
if (_.isBoolean(req.body.indEnvOnOff)) {
await DB.ProTraceCode.updateMany(search, { indEnvOnOff: req.body.indEnvOnOff });
}
res.sendData();
} catch (error) {
......
......@@ -99,6 +99,28 @@ const letianProTraceCodeSchema = new Schema({
type: Boolean,
},
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
qualityInsReportImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "质检报告图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
creator: {
type: mongoose.Types.ObjectId,
ref: 'User',
......
......@@ -43,13 +43,6 @@ const letianProductDeepSchema = new Schema({
comment: "产品详情轮播图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
sellByDate: {
type: String,
comment: "保质期"
......@@ -83,13 +76,6 @@ const letianProductDeepSchema = new Schema({
type: String,
comment: "产品编号"
},
qualityInsReportImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "质检报告图"
}
],
monitorInfo: {
type: [
{
......@@ -164,14 +150,6 @@ const letianProductDeepSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期"
},
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
createdAt: {
......
......@@ -70,20 +70,20 @@ const letianProductPlantSchema = new Schema({
type: Number,
comment: "产品编号"
},
qualityInsReportImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "质检报告图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
// qualityInsReportImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "质检报告图"
// }
// ],
// pesticidetImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "农残质检报告"
// }
// ],
monitorInfo: {
type: [
{
......@@ -145,13 +145,13 @@ const letianProductPlantSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期"
},
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
// flourMerchantImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "面粉商原料检测报告图"
// }
// ],
createdAt: {
type: Date,
......
......@@ -76,20 +76,20 @@ const letianProductPreSchema = new Schema({
type: String,
comment: "产品编号"
},
qualityInsReportImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "质检报告图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
// qualityInsReportImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "质检报告图"
// }
// ],
// pesticidetImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "农残质检报告"
// }
// ],
monitorInfo: { //农业
type: [
{
......@@ -152,13 +152,13 @@ const letianProductPreSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期"
},
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
// flourMerchantImgs: [
// {
// type: mongoose.Types.ObjectId,
// ref: 'File',
// comment: "面粉商原料检测报告图"
// }
// ],
createdAt: {
type: Date,
......
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