明树Git Lab

Commit 7c84ebf9 authored by zengfanpei's avatar zengfanpei

update

parent 0e4ba127
...@@ -30,30 +30,26 @@ async function importExcel(req, res, next) { ...@@ -30,30 +30,26 @@ async function importExcel(req, res, next) {
try { try {
console.log(DB.AreaRecord.schema.obj); console.log(DB.AreaRecord.schema.obj);
let workbook = new ExcelJS.Workbook(); let workbook = new ExcelJS.Workbook();
console.log(req.file)
await workbook.xlsx.readFile(req.file.path); await workbook.xlsx.readFile(req.file.path);
let worksheet = workbook.getWorksheet(1); let worksheet = workbook.getWorksheet(4);
console.log(worksheet.actualRowCount); console.log(workbook._worksheets.length);
let values = worksheet.getRow(1).values; // 示例:‌读取第一行 let values = worksheet.getRow(1).values; // 示例:‌读取第一行
// for (let index = 1; index < worksheet.actualRowCount; index++) { for (let index = 1; index < worksheet.actualRowCount; index++) {
// let values = worksheet.getRow(index + 1).values; let values = worksheet.getRow(index + 1).values;
// await DB.AreaRecord.create({ await DB.AgrInRecord.create({
// province: values[1], time: values[1],
// city: values[2], name: values[2],
// county: values[3], type: values[3],
// town: values[4], total: values[4],
// zone: values[5], unit: values[5],
// plantArea: values[6], })
// varieties: values[7], }
// area: Number( values[8]),
// yield: Number(values[9]),
// yieldValue:Number(values[10]),
// year: values[11]
// })
// }
//1. 先通过参数获取对应的表字段对应关系 //1. 先通过参数获取对应的表字段对应关系
//2. 找到对应的表 写入 //2. 找到对应的表 写入
res.send(DB.AreaRecord.schema.obj); res.send(values);
// res.send(DB.AreaRecord.schema.obj);
} catch (error) { } catch (error) {
next(error); next(error);
} }
......
...@@ -76,8 +76,8 @@ async function getWSChangeTrend(req, res, next) { ...@@ -76,8 +76,8 @@ async function getWSChangeTrend(req, res, next) {
{ {
$group: { $group: {
_id: { $dateToString: { format: "%Y-%m-%d", date: "$time" } }, // 将时间戳转换为日期字符串 _id: { $dateToString: { format: "%Y-%m-%d", date: "$time" } }, // 将时间戳转换为日期字符串
windSpeed: { $avg: "$windSpeed" }, wsTemperature: { $avg: "$wsTemperature" },
windDirection: { $avg: "$windDirection" }, wsMoisture: { $avg: "$wsMoisture" },
rainfall: { $avg: "$rainfall" }, rainfall: { $avg: "$rainfall" },
} }
}, },
......
...@@ -62,6 +62,32 @@ const collectWeatherStationSchema = new Schema({ ...@@ -62,6 +62,32 @@ const collectWeatherStationSchema = new Schema({
comment: "雨量单位", comment: "雨量单位",
}, },
wsTemperature: {
type: Number,
comment: "温度",
},
wsTemperatureUnit: {
type: String,
comment: "温度单位",
},
wsMoisture: {
type: Number,
comment: "湿度",
},
wsMoistureUnit: {
type: String,
comment: "湿度单位",
},
wsIllumination: {
type: Number,
comment: "光照",
},
wsIlluminationUnit: {
type: String,
comment: "光照单位",
},
createdAt: { createdAt: {
type: Date, type: Date,
default: Date.now, default: Date.now,
......
...@@ -3,28 +3,34 @@ const Schema = mongoose.Schema; ...@@ -3,28 +3,34 @@ const Schema = mongoose.Schema;
const moment = require('moment'); const moment = require('moment');
/** /**
* 乐田 农业投入品 出入库记录表 * 乐田 农业投入品 出入库记录表 时间 生产投入品名称 投入品类别 总投入品使用数量 单位
*/ */
const letianAgrInRecordSchema = new Schema({ const letianAgrInRecordSchema = new Schema({
time: {
type: Date,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
comment: "时间",
},
agrProName: {
type: String,
commnet: "农产品名称",
},
name: { name: {
type: String, type: String,
required: true, commnet: "生产投入品名称",
commnet: "品名",
}, },
total: { type: {
type: Number, type: String,
comment: "库存总量" commnet: "投入品类别",
}, },
inNum: { total: {
type: Number, type: Number,
default: 0, comment: "总投入品使用数量"
comment: "入库"
}, },
outNum: { unit: {
type: Number, type: String,
default: 0, commnet: "单位",
comment: "出库"
}, },
......
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