明树Git Lab

Commit 64602711 authored by zfp1's avatar zfp1

update

parent bd340c96
...@@ -6,6 +6,7 @@ async function createDeepPlant(req, res, next) { ...@@ -6,6 +6,7 @@ async function createDeepPlant(req, res, next) {
let count = await DB.ProductDeep.countDocuments(); //没有真实删除 永远递增 let count = await DB.ProductDeep.countDocuments(); //没有真实删除 永远递增
body.productNumber = count; body.productNumber = count;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).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});
let ret = await DB.ProductDeep.create(body); let ret = await DB.ProductDeep.create(body);
res.sendData(ret); res.sendData(ret);
} catch (error) { } catch (error) {
...@@ -22,7 +23,7 @@ async function listDeepPlant(req, res, next) { ...@@ -22,7 +23,7 @@ async function listDeepPlant(req, res, next) {
search.preProductName = {$regex: req.body.name} search.preProductName = {$regex: req.body.name}
} }
const count = await DB.ProductDeep.countDocuments(search); const count = await DB.ProductDeep.countDocuments(search);
let list = await DB.ProductDeep.find(search).populate({path: "productPhotos"}).populate({path: "sourcePlantProduct"}).populate({path: "qualityInsReportImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec(); let list = await DB.ProductDeep.find(search).populate({path: "productPhotos"}).populate({path: "sourcePlantProduct"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list }); res.sendData({ count, list });
} catch (error) { } catch (error) {
next(error); next(error);
......
...@@ -6,6 +6,7 @@ async function createDirectPlant(req, res, next) { ...@@ -6,6 +6,7 @@ async function createDirectPlant(req, res, next) {
let count = await DB.ProductPlant.countDocuments(); //没有真实删除 永远递增 let count = await DB.ProductPlant.countDocuments(); //没有真实删除 永远递增
body.productNumber = count; body.productNumber = count;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).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});
let ret = await DB.ProductPlant.create(body); let ret = await DB.ProductPlant.create(body);
res.sendData(ret); res.sendData(ret);
} catch (error) { } catch (error) {
...@@ -23,7 +24,7 @@ async function listDirectPlant(req, res, next) { ...@@ -23,7 +24,7 @@ async function listDirectPlant(req, res, next) {
} }
const count = await DB.ProductPlant.countDocuments(search); const count = await DB.ProductPlant.countDocuments(search);
let list = await DB.ProductPlant.find(search).populate({path: "productPhotos"}).populate({path: "plantPlan"}).populate({path: "qualityInsReportImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec(); let list = await DB.ProductPlant.find(search).populate({path: "productPhotos"}).populate({path: "plantPlan"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list }); res.sendData({ count, list });
} catch (error) { } catch (error) {
next(error); next(error);
......
...@@ -7,6 +7,7 @@ async function createPrePlant(req, res, next) { ...@@ -7,6 +7,7 @@ async function createPrePlant(req, res, next) {
let count = await DB.ProductPre.countDocuments(); //没有真实删除 永远递增 let count = await DB.ProductPre.countDocuments(); //没有真实删除 永远递增
body.productNumber = count; body.productNumber = count;
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).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});
let ret = await DB.ProductPre.create(body); let ret = await DB.ProductPre.create(body);
res.sendData(ret); res.sendData(ret);
} catch (error) { } catch (error) {
...@@ -23,7 +24,7 @@ async function listPrePlant(req, res, next) { ...@@ -23,7 +24,7 @@ async function listPrePlant(req, res, next) {
search.preProductName = {$regex: req.body.name} search.preProductName = {$regex: req.body.name}
} }
const count = await DB.ProductPre.countDocuments(search); const count = await DB.ProductPre.countDocuments(search);
let list = await DB.ProductPre.find(search).populate({path: "productPhotos"}).populate({path: "sourcePlantProduct"}).populate({path: "qualityInsReportImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec(); let list = await DB.ProductPre.find(search).populate({path: "productPhotos"}).populate({path: "sourcePlantProduct"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list }); res.sendData({ count, list });
} catch (error) { } catch (error) {
next(error); next(error);
......
...@@ -82,7 +82,7 @@ async function getTraceCode(req, res, next) { ...@@ -82,7 +82,7 @@ async function getTraceCode(req, res, next) {
let sourceId = traccode.source; let sourceId = traccode.source;
let source = null; let source = null;
if(traccode.type && traccode.type == 1) { if(traccode.type && traccode.type == 1) {
source = await DB.ProductPlant.findOne({_id: sourceId}).populate({path: "productPhotos"}).populate({path: "plantPlan"}).populate({path: "qualityInsReportImgs"}).populate({path: "monitorInfo.device"}).lean().exec(); 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) { if(source && source.plantPlan && source.plantPlan.land) {
let devices = await DB.Device.find({land: {$in: source.plantPlan.land}, deviceHQType: 5}).lean(); let devices = await DB.Device.find({land: {$in: source.plantPlan.land}, deviceHQType: 5}).lean();
source.devices = devices; source.devices = devices;
...@@ -90,9 +90,9 @@ async function getTraceCode(req, res, next) { ...@@ -90,9 +90,9 @@ async function getTraceCode(req, res, next) {
source.devices = []; source.devices = [];
} }
} else if(traccode.type && traccode.type == 2) { } else if(traccode.type && traccode.type == 2) {
source = await DB.ProductPre.findOne({_id: sourceId}).populate({path: "productPhotos"}).populate({path: "qualityInsReportImgs"}).populate({path: "monitorInfo.device"}).lean().exec(); 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) { } else if(traccode.type && traccode.type == 3) {
source = await DB.ProductDeep.findOne({_id: sourceId}).populate({path: "productPhotos"}).populate({path: "qualityInsReportImgs"}).populate({path: "monitorInfo.device"}).lean().exec(); 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, "==") console.log(source, "==")
......
...@@ -23,29 +23,6 @@ const letianProTraceCodeSchema = new Schema({ ...@@ -23,29 +23,6 @@ const letianProTraceCodeSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"), get: v => moment(v).format("YYYY-MM-DD"),
comment: "产品出库日期" comment: "产品出库日期"
}, },
agrProVar: {
type: String,
comment: "农产品品种"
},
agrPlantBase: {
type: String,
comment: "农产品种植基地"
},
harvestDate: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD"),
comment: "采收时间"
},
flourMerchant: {
type: String,
comment: "面粉商"
},
batchNumber: {
type: String,
comment: "批次号"
},
brand: String, //品牌
manufactureDate: { manufactureDate: {
type: Date, type: Date,
default: Date.now, default: Date.now,
......
...@@ -75,6 +75,43 @@ const letianProductDeepSchema = new Schema({ ...@@ -75,6 +75,43 @@ const letianProductDeepSchema = new Schema({
] ]
}, },
//原料信息
agrProVar: {
type: String,
comment: "农产品品种"
},
agrPlantBase: {
type: String,
comment: "农产品种植基地"
},
harvestDate: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD"),
comment: "采收时间"
},
flourMerchant: {
type: String,
comment: "面粉商"
},
batchNumber: {
type: String,
comment: "批次号"
},
manufactureDate: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期"
},
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
createdAt: { createdAt: {
type: Date, type: Date,
default: Date.now, default: Date.now,
......
...@@ -69,6 +69,43 @@ const letianProductPlantSchema = new Schema({ ...@@ -69,6 +69,43 @@ const letianProductPlantSchema = new Schema({
] ]
}, },
//原料信息
agrProVar: {
type: String,
comment: "农产品品种"
},
agrPlantBase: {
type: String,
comment: "农产品种植基地"
},
harvestDate: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD"),
comment: "采收时间"
},
flourMerchant: {
type: String,
comment: "面粉商"
},
batchNumber: {
type: String,
comment: "批次号"
},
manufactureDate: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期"
},
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
createdAt: { createdAt: {
type: Date, type: Date,
default: Date.now, default: Date.now,
......
...@@ -76,6 +76,43 @@ const letianProductPreSchema = new Schema({ ...@@ -76,6 +76,43 @@ const letianProductPreSchema = new Schema({
] ]
}, },
//原料信息
agrProVar: {
type: String,
comment: "农产品品种"
},
agrPlantBase: {
type: String,
comment: "农产品种植基地"
},
harvestDate: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD"),
comment: "采收时间"
},
flourMerchant: {
type: String,
comment: "面粉商"
},
batchNumber: {
type: String,
comment: "批次号"
},
manufactureDate: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD"),
comment: "生产日期"
},
flourMerchantImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "面粉商原料检测报告图"
}
],
createdAt: { createdAt: {
type: Date, type: Date,
default: Date.now, default: Date.now,
......
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