明树Git Lab

Commit 0ebe4021 authored by zengfanpei's avatar zengfanpei

update

parent 41325eb9
......@@ -36,6 +36,8 @@
"cron": {
"getDeviceList": false,
"getAllDevice": false,
"collectDeviceInfo": false
"collectDeviceInfo": false,
"collectDeviceInfo4": true,
"excel": true
}
}
\ No newline at end of file
......@@ -36,6 +36,8 @@
"cron": {
"getDeviceList": false,
"getAllDevice": false,
"collectDeviceInfo": true
"collectDeviceInfo": true,
"excel": true
}
}
\ No newline at end of file
......@@ -124,7 +124,13 @@ async function exportExcel(req, res, next) {
$gte: req.body.time[0]
}
}
let ret = await DB.ExcelRecord.create({
creator: req.user._id,
type: 2,
modleName: 'CollectIPS',
search,
})
res.sendData(ret);
} catch (error) {
next(error);
}
......
......@@ -39,13 +39,13 @@ async function list(req, res, next) {
search.deviceNumber = {$in: devNums}
}
}
search.deviceHQType = req.body.deviceHQType || 1;
search.deviceHQType = req.body.deviceHQType;
let page = req.body.page || 1;
let pageSize = req.body.pageSize || 10;
let skip = (page - 1) * pageSize;
let count = await collectSMCModule.count(search);
let data = await collectSMCModule.findList(search, { skip, limit: pageSize });
if(search.deviceHQType == 1) { // 这段是为了大屏 把 ph电导率 和 温湿度氮磷钾 合并起来
if(!search.deviceHQType) { // 这段是为了大屏 把 ph电导率 和 温湿度氮磷钾 合并起来
search.deviceHQType = 2;
delete search.deviceNumber;
let phData = await collectSMCModule.findList(search, { skip, limit: pageSize});
......@@ -68,6 +68,46 @@ async function list(req, res, next) {
}
}
async function exportExcel(req, res, next) {
try {
let search = { del: 0 };
if (req.body.name) {
search.name = { $regex: req.body.name }
}
if (req.body.startTime) {
search.time = search.time || {};
search.time.$gte = req.body.startTime;
}
if (req.body.endTime) {
search.time = search.time || {};
search.time.$lte = req.body.endTime
}
if (_.isArray(req.body.time) && req.body.time.length == 2) {
search.time = {
$lte: req.body.time[1],
$gte: req.body.time[0]
}
}
if(req.body.land) {
let devs = await DB.Device.find({land: req.body.land}).lean().exec();
if(devs && devs.length) {
let devNums = devs.map(o => {return o.deviceNumber});
search.deviceNumber = {$in: devNums}
}
}
search.deviceHQType = req.body.deviceHQType || 1;
let ret = await DB.ExcelRecord.create({
creator: req.user._id,
type: 2,
modleName: 'CollectSMC',
search,
})
res.sendData(ret);
} catch (error) {
next(error);
}
}
/**
......
......@@ -50,6 +50,45 @@ async function list(req, res, next) {
}
}
async function exportExcel(req, res, next) {
try {
let search = {del: 0};
if(req.body.name) {
search.name = {$regex: req.body.name}
}
if(req.body.startTime) {
search.time = search.time || {};
search.time.$gte = req.body.startTime;
}
if(req.body.endTime) {
search.time = search.time || {};
search.time.$lte = req.body.endTime
}
if(_.isArray(req.body.time) && req.body.time.length == 2) {
search.time = {
$lte: req.body.time[1],
$gte: req.body.time[0]
}
}
if(req.body.land) {
let devs = await DB.Device.find({land: req.body.land}).lean().exec();
if(devs && devs.length) {
let devNums = devs.map(o => {return o.deviceNumber});
search.deviceNumber = {$in: devNums}
}
}
let ret = await DB.ExcelRecord.create({
creator: req.user._id,
type: 2,
modleName: 'CollectWS',
search,
})
res.sendData(ret);
} catch (error) {
next(error);
}
}
/**
......@@ -123,4 +162,5 @@ module.exports = {
queryInfo,
updateInfo,
delInfo,
exportExcel,
}
\ No newline at end of file
const path = require('path');
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function exportExcel(req, res, next) {
let modelName = req.params.modelName;
let modelMap = {
'IPS': "CollectIPS",
'SMC': "CollectSMC",
'WS': "CollectWS",
}
}
module.exports = { exportExcel }
\ No newline at end of file
......@@ -5,7 +5,7 @@ const _ = require('lodash');
async function upload(req, res, next) {
try {
// console.log(req.file, req.body);
console.log(req.file, req.body);
let nginxpath = _.last(String(req.file.path).split('/mnt/vdb1'));
let ret = await DB.File.create({
originalname: req.file.originalname,
......
// 气象
const httpRequest = require('../utils/httpRequest');
const deviceModule = require('../module/deviceModule');
const collectIPSModule = require('../module/collectIPSModule');
const _ = require('lodash');
const moment = require('moment');
const ExcelJS = require('exceljs');
const fs = require('fs');
exportExcel()
async function exportExcel() {
let info = await DB.ExcelRecord.findOne({ type: 2, status: 1 });
console.log(info);
if (info && info._id && info.modleName) {
let workbook = new ExcelJS.Workbook();
let name = `Excel导出${new Date(info.createdAt).getTime()}_${info._id}`
let worksheet = workbook.addWorksheet(name);
let columns = [];
if (!_.isEmpty(DB[info.modleName] && DB[info.modleName].schema && DB[info.modleName].schema.obj)) {
for (const key in DB[info.modleName].schema.obj) {
const element = DB[info.modleName].schema.obj[key];
if (element && element.comment) {
// 有comment的导出,其他需要标注 不需要导出的用comment1
columns.push({ header: element.comment, key });
}
}
}
console.log(columns.length, "-=-=-");
if (columns.length > 0) {
// TODO: 可以优化根据count翻页 暂时
worksheet.columns = columns;
let list = await DB[info.modleName].find(info.search || { del: 0 });
for (let index = 0; index < list.length; index++) {
const element = list[index];
worksheet.addRow(element);
}
if (list.length > 0) {
let path = sysConfig.file.storagePath + '/' + moment().format('YYYYMMDD');
if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true });
}
let excelUrl = path + '/' + name + '.xlsx'
// 1. 写入数据到存储位置
await workbook.xlsx.writeFile(excelUrl);
// 2. 创建文件信息
let fileInfo = await DB.File.create({
originalname: name + '.xlsx',
mimetype: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
filename: name + '.xlsx',
path: excelUrl,
// size: req.file.size,
type: 2,
});
// 3. 更新任务结果
await DB.ExcelRecord.findOneAndUpdate({_id: info._id}, {status: 2, excelUrl: fileInfo._id})
}
}
}
// let workbook = new Excel.Workbook();
// // 添加一个工作表
// let worksheet = workbook.addWorksheet('我的工作表');
// // 添加表头
// worksheet.columns = [
// { header: '姓名', key: 'name' },
// { header: '年龄', key: 'age' },
// { header: '职业', key: 'occupation' }
// ];
// // 添加数据行
// worksheet.addRow({ name: '张三', age: 30, occupation: '软件工程师' });
// worksheet.addRow({ name: '李四', age: 25, occupation: '产品经理' });
// // 写入文件到磁盘
// await workbook.xlsx.writeFile('我的Excel.xlsx');
}
module.exports = {
exportExcel,
}
......@@ -8,6 +8,8 @@ const smcCron = require('./smcCron');
const wsCron = require('./wsCron');
// 虫情
const ipsCron = require('./ipsCron');
// excel
const excelCron = require('./excelCron');
/**
根据config cron 配置 定时处理
......@@ -75,14 +77,24 @@ const cron = () => {
// 获取设备上述设备 4 采集信息
if (sysConfig && sysConfig.cron && sysConfig.cron.collectDeviceInfo) {
if (sysConfig && sysConfig.cron && sysConfig.cron.collectDeviceInfo4) {
console.log("collectDeviceInfo4:", new Date());
new nodeCron.schedule('1 */3 * * * *', async () => {
new nodeCron.schedule('1 */1 * * * *', async () => {
await ipsCron.collectDeviceInfo4({deviceHQType: 4});
}, { timezone: "Asia/Shanghai" });
}
if (sysConfig && sysConfig.cron && sysConfig.cron.excel) {
console.log("excel:", new Date());
// new nodeCron.schedule('1 */1 * * * *', async () => {
// console.log(new Date().getTime())
// await excelCron.exportExcel();
// }, { timezone: "Asia/Shanghai" });
}
}
module.exports = cron;
\ No newline at end of file
......@@ -21,72 +21,72 @@ const _ = require('lodash');
* 采集上述设备 4 的信息
*/
async function collectDeviceInfo4({ deviceHQType }) {
const url = sysConfig.device.getInsectNewCollectionResult;
const token = sysConfig.device.token;
const userName = sysConfig.device.userName;
const password = sysConfig.device.password;
// 查询有效状态、类型的设备信息
const devices = await deviceModule.findAll({ deviceHQType: '4'}, ['deviceNumber', 'deviceHQType', 'name']);
// console.log(devices.length)
for (let index = 0; index < devices.length; index++) {
const dev = devices[index];
// console.log(dev);
const result = await httpRequest({
url,
method: "POST",
params: { token, userName, deviceNumber: dev.deviceNumber }
});
console.log(result);
if(result && result.data && result.status && result.data.state == "success") {
let obj = result.data.data || {};
obj.name = dev.name || obj.name ;
console.log(obj);
await collectIPSModule.insertHQData(obj);
// 3. 处理虫情每日种类数量记录
// 4. 处理设备在线状态
handleDeviceOnLine({deviceNumber: obj.deviceNumber, online: obj.online}); //onLineState 1在线0离线
} else {
handleDeviceOnLine({deviceNumber: obj.deviceNumber, online: 0}); //onLineState 1在线0离线
}
}
// /**
// * 按硬件方要求 获取虫子的种类 和 数量 均调用设备列表接口
// */
// const url = sysConfig.device.getAllDevice;
// const token = sysConfig.device.token;
// const userName = sysConfig.device.userName;
// const password = sysConfig.device.password;
// // 查询有效状态、类型的设备信息
// const devices = await deviceModule.findAll({ deviceHQType: '4'}, ['deviceNumber', 'deviceHQType']);
// console.log(devices.length)
// for (let index = 0; index < devices.length; index++) {
// const dev = devices[index];
// // console.log(dev);
// const result = await httpRequest({
// url,
// method: "POST",
// params: { token, userName, deviceNumber: dev.deviceNumber }
// });
// // console.log(result);
// if(result && result.data && result.data.state == "success") {
// let obj = result.data.data || {};
// obj.name = obj.name || dev.name;
// await collectIPSModule.insertHQData(obj);
// console.log(obj);
// // 3. 处理虫情每日种类数量记录
// // 4. 处理设备在线状态
// handleDeviceOnLine({deviceNumber: obj.deviceNumber, online: obj.online}); //onLineState 1在线0离线
// } else {
// handleDeviceOnLine({deviceNumber: obj.deviceNumber, online: 0}); //onLineState 1在线0离线
// let result = await httpRequest({
// url,
// method: "POST",
// params: { token, userName, password },
// });
// if (result && result.data && result.data.state == "success") {
// let devArr = result.data.data || [];
// for (let index = 0; index < devArr.length; index++) {
// const element = devArr[index];
// console.log(element, "虫情");
// let obj = {
// downloadUrl: element.imgUrl,
// downloadUrlCompress: element.imgUrl,
// newTime: element.latestCollectionTime,
// results: element.results || "",
// typeCount: element.typeCount || 0,
// newCount: element.newCount || 0,
// online: element.online,
// deviceNumber: element.deviceNumber,
// }
// await collectIPSModule.insertHQData(obj); // 处理虫子种类入库 数量入库
// handleDeviceOnLine({ deviceNumber: obj.deviceNumber, online: obj.online }); //onLineState 1在线0离线
// }
// }
/**
* 按硬件方要求 获取虫子的种类 和 数量 均调用设备列表接口
*/
const url = sysConfig.device.getAllDevice;
const token = sysConfig.device.token;
const userName = sysConfig.device.userName;
const password = sysConfig.device.password;
let result = await httpRequest({
url,
method: "POST",
params: { token, userName, password },
});
if (result && result.data && result.data.state == "success") {
let devArr = result.data.data || [];
for (let index = 0; index < devArr.length; index++) {
const element = devArr[index];
console.log(element, "虫情");
let obj = {
downloadUrl: element.imgUrl,
downloadUrlCompress: element.imgUrl,
newTime: element.latestCollectionTime,
results: element.results || "",
typeCount: element.typeCount || 0,
newCount: element.newCount || 0,
online: element.online,
deviceNumber: element.deviceNumber,
}
await collectIPSModule.insertHQData(obj); // 处理虫子种类入库 数量入库
handleDeviceOnLine({ deviceNumber: obj.deviceNumber, online: obj.online }); //onLineState 1在线0离线
}
}
// }
}
......
......@@ -150,7 +150,7 @@ async function handleDeviceThreshold(obj) {
sendUser: "66d6c4099f8480c6db53ce13",
receiveUser: "66d6c4099f8480c6db53ce13",
content: exceeds.join("\\n"),
title: "土壤采集数据预警通知"
});
}
}
......
......@@ -134,6 +134,7 @@ async function handleDeviceThreshold(obj) {
sendUser: "66d6c4099f8480c6db53ce13",
receiveUser: "66d6c4099f8480c6db53ce13",
content: exceeds.join("\\n"),
title: "气象站采集数据预警通知"
});
}
......
......@@ -47,6 +47,7 @@ const AgrMatApproval = require('./models/letianAgrMatApproval');
const AgrMatInOut = require('./models/letianAgrMatInOut');
const FileTemplate = require('./models/letianFIleTemplate');
const ExcelRecord = require('./models/letianExcelRecord');
......@@ -85,6 +86,7 @@ global.DB = {
AgrMatApproval,
AgrMatInOut,
FileTemplate,
ExcelRecord,
CollectThreshold,
CollectSMC,
......
......@@ -4,17 +4,19 @@ const moment = require('moment');
/**
* 虫情 采集信息
*
* 1. 下面schema结构会在导出excel时候用到,comment即为会导出的字段,comment1则不会导出
*/
const collectInsectPestSituationSchema = new Schema({
// name: {
// type: String,
// required: true,
// comment: "设备名称"
// },
name: {
type: String,
comment: "设备名称"
},
deviceNumber: {
type: String,
required: true,
index: true
index: true,
comment: "设备编号"
},
time: {
......@@ -25,70 +27,72 @@ const collectInsectPestSituationSchema = new Schema({
downloadUrl: {
type: String,
comment: "摄像头采集原图下载URL",
comment: "图像",
comment1: "摄像头采集原图下载URL",
get: v => sysConfig.device.fileBaseUrl + v,
},
downloadUrlCompress: {
type: String,
comment: "摄像头采集原图下载URL(压缩后)",
comment1: "摄像头采集原图下载URL(压缩后)",
get: v => sysConfig.device.fileBaseUrl + v,
},
newTime: {
type: Date,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
comment: "最新一次识别时间",
comment1: "最新一次识别时间",
},
results: {
type: String,
comment: "最新一次识别结果",
comment: "识别结果",
},
newCount: {
type: Number,
comment: "最新一次识别数量",
comment: "识别数量",
},
typeCount: {
type: Number,
comment: "最新一次识别的种类数量",
comment: "种类数量",
},
oldCount: {
type: Number,
comment: "上一次识别数量",
comment1: "上一次识别数量",
},
oldTime: {
type: Date,
comment: "上一次识别时间",
comment1: "上一次识别时间",
},
oldResults: {
type: String,
comment: "上一次识别结果",
comment1: "上一次识别结果",
},
oldTypeCount: {
type: Number,
comment: "上一次识别种类数量",
comment1: "上一次识别种类数量",
},
oldDownloadUrl: {
type: String,
comment: "上一次摄像头采集原图下载URL",
comment1: "上一次摄像头采集原图下载URL",
},
oldDownloadUrlCompress: {
type: String,
comment: "上一次摄像头采集原图下载URL(压缩后)",
comment1: "上一次摄像头采集原图下载URL(压缩后)",
},
taggingImgUrl: {
type: String,
comment: "标注后的图片",
comment1: "标注后的图片",
},
taggingImgUrlCompress: {
type: String,
comment: "标注后图片(压缩后)",
comment1: "标注后图片(压缩后)",
},
oldDownloadUrl: {
type: String,
comment: "上一次标注后的图片",
comment1: "上一次标注后的图片",
},
oldDownloadUrlCompress: {
type: String,
comment: "上一次标注后的图片(压缩后)",
comment1: "上一次标注后的图片(压缩后)",
},
/* 识别结果 不管哪一种形式,只要结果确认有效则写入,为空则表示此条数据无效,后续需要根据业务定期处理这类数据 */
......@@ -112,7 +116,7 @@ const collectInsectPestSituationSchema = new Schema({
del: {
type: Number,
default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
comment1: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
}
}, {
toJSON: {
......
......@@ -18,7 +18,9 @@ const soilMoistureContentSchema = new Schema({
deviceNumber: {
type: String,
required: true,
index: true
index: true,
comment: "设备编号"
},
/* 接口返回的数据原始存储 */
......@@ -42,7 +44,7 @@ const soilMoistureContentSchema = new Schema({
},
soilTemperatureUnit: {
type: String,
comment: "土壤温度单位",
comment1: "土壤温度单位",
},
soilMoisture: {
type: Number,
......@@ -50,7 +52,7 @@ const soilMoistureContentSchema = new Schema({
},
soilMoistureUnit: {
type: String,
comment: "土壤湿度 单位",
comment1: "土壤湿度 单位",
},
nitrogen: {
type: Number,
......@@ -58,7 +60,7 @@ const soilMoistureContentSchema = new Schema({
},
nitrogenUnit: {
type: String,
comment: "氮 单位",
comment1: "氮 单位",
},
phosphorus: {
type: Number,
......@@ -66,7 +68,7 @@ const soilMoistureContentSchema = new Schema({
},
phosphorusUnit: {
type: String,
comment: "磷 单位",
comment1: "磷 单位",
},
potassium: {
type: Number,
......@@ -74,7 +76,7 @@ const soilMoistureContentSchema = new Schema({
},
potassiumUnit: {
type: String,
comment: "钾 单位",
comment1: "钾 单位",
},
soilPH: {
type: Number,
......@@ -82,7 +84,7 @@ const soilMoistureContentSchema = new Schema({
},
soilPHUnit: {
type: String,
comment: "土壤PH 单位",
comment1: "土壤PH 单位",
},
soilConductivity: {
type: Number,
......@@ -90,29 +92,29 @@ const soilMoistureContentSchema = new Schema({
},
soilConductivityUnit: {
type: String,
comment: "土壤电导率 单位",
comment1: "土壤电导率 单位",
},
signalSterngth: {
type: Number,
comment: "信号强度",
comment1: "信号强度",
},
soilConductivityUnit: {
type: String,
comment: "信号强度 单位",
comment1: "信号强度 单位",
},
errorCode: {
type: String,
comment: "错误码",
comment1: "错误码",
},
version: {
type: String,
comment: "版本号",
comment1: "版本号",
},
deviceHQType: {
type: Number,
comment: "用来获取数据的设备类型-(接口文档): 1.土壤温湿度氮磷钾, 2土壤ph电导率, 3 气象站, 4虫情",
comment1: "用来获取数据的设备类型-(接口文档): 1.土壤温湿度氮磷钾, 2土壤ph电导率, 3 气象站, 4虫情",
},
......@@ -125,7 +127,7 @@ const soilMoistureContentSchema = new Schema({
},
onLineState: {
type: String,
comment: "在线状态,该字段不记录到db,后期采集数据时将状态更新到redis里面即可"
comment1: "在线状态,该字段不记录到db,后期采集数据时将状态更新到redis里面即可"
},
......@@ -143,7 +145,7 @@ const soilMoistureContentSchema = new Schema({
del: {
type: Number,
default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
comment1: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
}
}, {
toJSON: {
......
......@@ -18,7 +18,9 @@ const collectWeatherStationSchema = new Schema({
deviceNumber: {
type: String,
required: true,
index: true
index: true,
comment: "设备编号"
},
/* 接口返回的数据原始存储 */
type: {
......@@ -41,7 +43,7 @@ const collectWeatherStationSchema = new Schema({
},
windSpeedUnit: {
type: String,
comment: "风速单位",
comment1: "风速单位",
},
windDirection: {
......@@ -50,7 +52,7 @@ const collectWeatherStationSchema = new Schema({
},
windDirectionUnit: {
type: String,
comment: "风向单位",
comment1: "风向单位",
},
rainfall: {
......@@ -59,7 +61,7 @@ const collectWeatherStationSchema = new Schema({
},
rainfallUnit: {
type: String,
comment: "雨量单位",
comment1: "雨量单位",
},
wsTemperature: {
......@@ -68,7 +70,7 @@ const collectWeatherStationSchema = new Schema({
},
wsTemperatureUnit: {
type: String,
comment: "温度单位",
comment1: "温度单位",
},
wsMoisture: {
type: Number,
......@@ -76,7 +78,7 @@ const collectWeatherStationSchema = new Schema({
},
wsMoistureUnit: {
type: String,
comment: "湿度单位",
comment1: "湿度单位",
},
wsIllumination: {
type: Number,
......@@ -84,7 +86,7 @@ const collectWeatherStationSchema = new Schema({
},
wsIlluminationUnit: {
type: String,
comment: "光照单位",
comment1: "光照单位",
},
......@@ -101,7 +103,7 @@ const collectWeatherStationSchema = new Schema({
del: {
type: Number,
default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
comment1: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
}
}, {
toJSON: {
......
......@@ -7,10 +7,11 @@ const moment = require('moment');
*/
const ExcelSchema = new Schema({
creator: { type: mongoose.Types.ObjectId, ref: 'User' },
type: {type: Number, comment: "1. 导入 2, 导出"},
excelUrl: {type: mongoose.Types.ObjectId, ref: 'File'},
type: { type: Number, comment: "1. 导入 2, 导出" },
excelUrl: { type: mongoose.Types.ObjectId, ref: 'File' },
modleName: String,
search: {type: Object},
search: { type: Object },
status: { type: Number, default: 1, comment: "1, 未完成, 2 已完成。" },
createdAt: {
type: Date,
......@@ -35,5 +36,5 @@ const ExcelSchema = new Schema({
});
const letianExcel = mongoose.model('letianExcel', ExcelSchema, 'letianExcel');
module.exports = letianExcel;
\ No newline at end of file
const letianExcelRecord = mongoose.model('letianExcelRecord', ExcelSchema, 'letianExcelRecord');
module.exports = letianExcelRecord;
\ No newline at end of file
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
const _ = require('lodash');
/**
* 用户
......@@ -17,7 +18,7 @@ const fileSchema = new Schema({
size: {
type: Number,
},
mimietype: {
mimetype: {
type: String
},
url: {
......@@ -28,9 +29,10 @@ const fileSchema = new Schema({
},
nginxpath: {
type: String,
set: setNginxPathByPath,
},
type: {type: Number, default:1, comment: "1上传 2导出excel"},
createdAt: {
type: Date,
......@@ -54,6 +56,13 @@ const fileSchema = new Schema({
}
});
function setNginxPathByPath() {
console.log(this, "--this--", this.path);
let nginxpath = _.last(String(this.path).split('/mnt/vdb1'));
console.log(nginxpath, "==nginxpath==")
return nginxpath
}
const File = mongoose.model('File', fileSchema, 'systemFile');
module.exports = File;
\ No newline at end of file
......@@ -14,6 +14,7 @@ const Noticechema = new Schema({
type: mongoose.Types.ObjectId,
ref: "User"
},
title: String,
content: String,
sendTime: {
type: Date,
......
......@@ -29,13 +29,11 @@ async function count(search) {
async function insertHQData(data) {
if (!(data.deviceNumber && data.newTime)) {
return;
}
data.time = data.newTime; // 为跟其他采集一致 ,都用time
let check = await DB.CollectIPS.findOne({ newTime: data.newTime });
if (!check) {
let ret = await DB.CollectIPS.create(data);
console.log("ret,:::", ret)
handleIPSResult(ret);
}
}
......
......@@ -10,7 +10,6 @@ const moment = require('moment');
const mongoose = require('mongoose');
const fileController = require('../controller/fileController');
const excelController = require('../controller/excelController');
const storage = multer.diskStorage({
......@@ -54,6 +53,16 @@ router.post('/:modelName/importExcel', upload.single('file'), async (req, res, n
await controller.importExcel(req, res, next);
});
router.post('/:modelName/exportExcel', excelController.exportExcel);
router.post('/:modelName/exportExcel', async (req, res, next) =>{
let modelName = req.params.modelName;
let modelMap = {
'IPS': "collectIPSController",
'SMC': "collectSMCController",
'WS': "collectWSController",
}
console.log(modelMap[modelName]);
let controller = require(`../controller/${modelMap[modelName]}`);
await controller.exportExcel(req, res, next);
});
module.exports = router;
\ 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