明树Git Lab

Commit 9377401a authored by zfp1's avatar zfp1

update

parent 258f71f6
......@@ -5,7 +5,7 @@
async function findCompInfo(req, res, next) {
try {
let ret = await DB.CompanyInfo.findOne({}).populate({path: "companyInfoImgs"}).populate({path: "addressInfo.img"}).lean().exec();
let ret = await DB.CompanyInfo.findOne({}).populate({path: "companyInfoImgs"}).populate({path: "qualiCertiImgs"}).populate({path: "addressInfo.img"}).lean().exec();
return res.sendData(ret);
} catch (error) {
next(error);
......@@ -16,6 +16,7 @@ async function updateCompInfo(req, res, next) {
try {
let body = req.body;
body.companyInfoImgs = (body.companyInfoImgs || []).map(o => {return o && o._id || o});
body.qualiCertiImgs = (body.qualiCertiImgs || []).map(o => {return o && o._id || o});
body.addressInfo = body.addressInfo || [];
let newAdr = [];
for (let index = 0; index < body.addressInfo.length; index++) {
......
......@@ -7,6 +7,9 @@ async function createDeepPlant(req, res, next) {
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.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});
let ret = await DB.ProductDeep.create(body);
res.sendData(ret);
} catch (error) {
......@@ -23,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: "productPhotos"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).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: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list });
} catch (error) {
next(error);
......@@ -45,6 +48,11 @@ async function updateDeepPlant(req, res, next) {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
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});
let upInfo = {
...req.body,
_id: undefined,
......
......@@ -7,6 +7,9 @@ async function createDirectPlant(req, res, next) {
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.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) {
......@@ -24,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: "productPhotos"}).populate({path: "plantPlan"}).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: "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();
res.sendData({ count, list });
} catch (error) {
next(error);
......@@ -46,6 +49,11 @@ async function updateDirectPlant(req, res, next) {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
body.qualityInsReportImgs = (body.qualityInsReportImgs || []).map(o => {return o && o._id || o});
body.flourMerchantImgs = (body.flourMerchantImgs || []).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 = {
...req.body,
_id: undefined,
......
......@@ -8,6 +8,9 @@ async function createPrePlant(req, res, next) {
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.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);
res.sendData(ret);
} catch (error) {
......@@ -24,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: "productPhotos"}).populate({path: "sourcePlantProduct"}).populate({path: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).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: "qualityInsReportImgs"}).populate({path: "flourMerchantImgs"}).populate({path: "pesticidetImgs"}).populate({path: "homepageCarouselImgs"}).populate({path: "monitorInfo.device"}).sort({_id: -1}).skip(skip).limit(pageSize).lean().exec();
res.sendData({ count, list });
} catch (error) {
next(error);
......@@ -46,6 +49,11 @@ async function updatePrePlant(req, res, next) {
if(!req.body._id) {
return res.sendError(errorMessage.resourceNotFound);
}
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 = {
...req.body,
_id: undefined,
......
This diff is collapsed.
......@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 深加工成果产品 --- 关联初加工成果产品,关联初加工场地摄像头、深加工过程数据(工业信息采集数据)。
* 公司信息
*/
const letianCompanyInfoSchema = new Schema({
......@@ -23,6 +23,13 @@ const letianCompanyInfoSchema = new Schema({
comment: "公司信息介绍图"
}
],
qualiCertiImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "资质证书"
}
],
addressInfo: {
type: [{
name: String,
......
......@@ -10,7 +10,32 @@ const letianProTraceCodeSchema = new Schema({
// type: String,
// comment: "产品名称"
// },
tcode: String, // 溯源码
jdImg: { // 基地总览图片
type: mongoose.Types.ObjectId,
ref: 'File',
},
gcImg: { //工厂总览图
type: mongoose.Types.ObjectId,
ref: 'File',
},
type: {
type: Number,
comment: "1 种植农产品 2 轻加工 3 深加工"
},
workshop: {
type: String,
comment: "生产车间"
},
source: {
type: mongoose.Types.ObjectId,
comment: "产品名称: 源头productPre productDeep prodectPlant 三个"
},
brand: String, //品牌
batchNumber: {
type: String,
comment: "生产批次"
},
proInDate: {
type: Date,
default: Date.now,
......@@ -29,18 +54,56 @@ const letianProTraceCodeSchema = new Schema({
get: v => moment(v).format("YYYY-MM-DD"),
comment: "产品生产日期"
},
type: {
productSalUrl: String, //第三方页面地址,前端当有这个地址时,直接打开此地址,没有则跳转自己的地址
queryNum: {
type: Number,
comment: "1 种植 2 轻加工 3 深加工"
default: 0,
comment: "查询次数",
},
source: {
firstQueryTime: {
type: Date,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
comment: "首次查询时间",
},
rawMatCul: { //原料种植
proName: String,
proAdr: String,
manager: String,
proSteps: [
{
name: String,
time: Date,
img: {
type: mongoose.Types.ObjectId,
comment: "产品名称: 源头productPre productDeep prodectPlant 三个"
ref: 'File',
}
}
]
},
workshop: {
type: String,
comment: "生产车间"
proProcess: { //产品加工
proName: String,
proAdr: String,
manager: String,
proSteps: [
{
name: String,
time: Date,
img: {
type: mongoose.Types.ObjectId,
ref: 'File',
}
}
]
},
agrOnOff: { // 农业数据开关
type: Boolean,
default: true,
},
indEnvOnOff: { //工业环境开关
type: Boolean,
default: true,
},
creator: {
type: mongoose.Types.ObjectId,
ref: 'User',
......
......@@ -29,10 +29,38 @@ const letianProductDeepSchema = new Schema({
// type: String,
// comment: "库存量"
// },
productPhotos: {
homepageCarouselImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "溯源码产品首页轮播图"
}
],
productPhotos2: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "产品详情轮播图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "产品照片"
comment: "农残质检报告"
}
],
sellByDate: {
type: String,
comment: "保质期"
},
qualityInspector: {
type: String,
comment: "质检员"
},
productUnit: {
type: String,
comment: "生产单位"
},
// introduction: {
// type: String,
......@@ -124,6 +152,8 @@ const letianProductDeepSchema = new Schema({
}
],
createdAt: {
type: Date,
default: Date.now,
......
......@@ -15,19 +15,40 @@ const letianProductPlantSchema = new Schema({
type: String,
comment: "品种"
},
productPhotos: {
homepageCarouselImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "产品照片"
},
productIntro: {
comment: "溯源码产品首页轮播图"
}
],
productPhotos2: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "产品详情轮播图"
}
],
sellByDate: {
type: String,
comment: "产品介绍"
comment: "保质期"
},
qualityInfor: {
qualityInspector: {
type: String,
comment: "质量信息"
comment: "质检员"
},
productUnit: {
type: String,
comment: "生产单位"
},
// productIntro: {
// type: String,
// comment: "产品介绍"
// },
// qualityInfor: {
// type: String,
// comment: "质量信息"
// },
yield: {
type: Number,
comment: "产量",
......@@ -52,6 +73,13 @@ const letianProductPlantSchema = new Schema({
comment: "质检报告图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
monitorInfo: {
type: [
{
......
......@@ -28,26 +28,46 @@ const letianProductPreSchema = new Schema({
type: String,
comment: "库存量"
},
productPhotos: {
homepageCarouselImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "溯源码产品首页轮播图"
}
],
productPhotos2: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "物品照片",
default: null,
set: v => { if (!v) { return null; } else { return v; } }
comment: "产品详情轮播图"
}
],
sellByDate: {
type: String,
comment: "保质期"
},
introduction: {
qualityInspector: {
type: String,
comment: "介绍内容"
comment: "质检员"
},
productUnit: {
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: "质量信息"
},
// qualityInfo: {
// type: String,
// comment: "质量信息"
// },
productNumber: {
type: String,
comment: "产品编号"
......@@ -59,6 +79,13 @@ const letianProductPreSchema = new Schema({
comment: "质检报告图"
}
],
pesticidetImgs: [
{
type: mongoose.Types.ObjectId,
ref: 'File',
comment: "农残质检报告"
}
],
monitorInfo: {
type: [
{
......
......@@ -46,5 +46,9 @@ router.post('/product/trace/list', productTracController.listTraceCode);
router.post('/product/trace/delete', productTracController.deleteTraceCode);
router.post('/product/trace/update', productTracController.updateTraceCode);
router.post('/product/trace/info', productTracController.getTraceCode);
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); // 质量检测报告
module.exports = router;
\ No newline at end of file
......@@ -74,11 +74,22 @@ function genTracSourceCode({EnterpriseCode, type, date, batchNum, logisticsNum})
}
function generateRandomCode(len) {
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 定义字符库
let code = '';
for (let i = 0; i < len; i++) {
const randomIndex = Math.floor(Math.random() * chars.length); // 生成随机索引
code += chars[randomIndex]; // 拼接字符
}
return code;
}
module.exports = {
saltHashPassword,
checkUserPassword,
buildTree,
disTree,
generateRandomCode,
}
\ 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