明树Git Lab

Commit 7c84ebf9 authored by zengfanpei's avatar zengfanpei

update

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