明树Git Lab

Commit 75a745d4 authored by zengfanpei's avatar zengfanpei

update

parents 25189c52 b97ce218
......@@ -35,68 +35,68 @@ async function init(req, res) {
await DB.CollectAttribute.findOneAndUpdate({ dbKey: element.dbKey }, element, { upsert: true });
}
// 土壤
for (let index = 0; index < 20; index++) {
await DB.CollectSMC.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
id: 8746,
name: "设备名称修改测试",
deviceNumber: "16A67205BA3A",
time: moment('2024-08-26').add(index, 'day'),
soilTemperature: 11 + Math.floor(Math.random() * 20),
soilMoisture: 11 + Math.floor(Math.random() * 20),
nitrogen: 11 + Math.floor(Math.random() * 20),
phosphorus: 11 + Math.floor(Math.random() * 20),
potassium: 11 + Math.floor(Math.random() * 20),
soilPH: 11 + Math.floor(Math.random() * 20),
soilConductivity: 11 + Math.floor(Math.random() * 20),
}, { upsert: true })
}
// // 土壤
// for (let index = 0; index < 20; index++) {
// await DB.CollectSMC.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
// id: 8746,
// name: "设备名称修改测试",
// deviceNumber: "16A67205BA3A",
// time: moment('2024-08-26').add(index, 'day'),
// soilTemperature: 11 + Math.floor(Math.random() * 20),
// soilMoisture: 11 + Math.floor(Math.random() * 20),
// nitrogen: 11 + Math.floor(Math.random() * 20),
// phosphorus: 11 + Math.floor(Math.random() * 20),
// potassium: 11 + Math.floor(Math.random() * 20),
// soilPH: 11 + Math.floor(Math.random() * 20),
// soilConductivity: 11 + Math.floor(Math.random() * 20),
// }, { upsert: true })
// }
//气象
for (let index = 0; index < 20; index++) {
await DB.CollectWS.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
id: 8746,
name: "气象站",
deviceNumber: "1111111111111",
time: moment('2024-08-26').add(index, 'day'),
windSpeed: 11 + Math.floor(Math.random() * 20),
windDirection: 11 + Math.floor(Math.random() * 20),
rainfall: 11 + Math.floor(Math.random() * 20),
}, { upsert: true })
}
// for (let index = 0; index < 20; index++) {
// await DB.CollectWS.findOneAndUpdate({ time: moment('2024-08-26').add(index, 'day') }, {
// id: 8746,
// name: "气象站",
// deviceNumber: "1111111111111",
// time: moment('2024-08-26').add(index, 'day'),
// windSpeed: 11 + Math.floor(Math.random() * 20),
// windDirection: 11 + Math.floor(Math.random() * 20),
// rainfall: 11 + Math.floor(Math.random() * 20),
// }, { upsert: true })
// }
// 虫情
for (let index = 0; index < 20; index++) {
let dataId = new mongoose.Types.ObjectId()
let data = await DB.CollectIPS.create({
_id: dataId,
id: 8746,
name: "虫情系统",
deviceNumber: "FF35d4072d53",
time: moment('2024-08-26').add(index, 'day'),
downloadUrl: "pictures/FF35D4072D53/2024-08-20-15-03-43.jpg",
newTime: moment('2024-08-26').add(index, 'day'),
newCount: 11 + Math.floor(Math.random() * 20)
});
let typeId = new mongoose.Types.ObjectId()
let type = await DB.CollectIPSType.create({ _id: typeId, name: "虫子" + index });
let planId = new mongoose.Types.ObjectId()
let plan = await DB.CollectIPSPlan.create({ _id: planId, name: "虫子" + index, controlPlan: "防治建议" + index });
await DB.CollectIPSResult.findOneAndUpdate({ data: dataId }, {
deviceNumber: "FF35d4072d53",
name: "虫子" + index,
count: 1 + Math.floor(Math.random() * 10),
time: moment('2024-08-26').add(index, 'day'),
type: typeId,
plan: planId,
data: dataId,
}, { upsert: true });
}
// for (let index = 0; index < 20; index++) {
// let dataId = new mongoose.Types.ObjectId()
// let data = await DB.CollectIPS.create({
// _id: dataId,
// id: 8746,
// name: "虫情系统",
// deviceNumber: "FF35d4072d53",
// time: moment('2024-08-26').add(index, 'day'),
// downloadUrl: "pictures/FF35D4072D53/2024-08-20-15-03-43.jpg",
// newTime: moment('2024-08-26').add(index, 'day'),
// newCount: 11 + Math.floor(Math.random() * 20)
// });
// let typeId = new mongoose.Types.ObjectId()
// let type = await DB.CollectIPSType.create({ _id: typeId, name: "虫子" + index });
// let planId = new mongoose.Types.ObjectId()
// let plan = await DB.CollectIPSPlan.create({ _id: planId, name: "虫子" + index, controlPlan: "防治建议" + index });
// await DB.CollectIPSResult.findOneAndUpdate({ data: dataId }, {
// deviceNumber: "FF35d4072d53",
// name: "虫子" + index,
// count: 1 + Math.floor(Math.random() * 10),
// time: moment('2024-08-26').add(index, 'day'),
// type: typeId,
// plan: planId,
// data: dataId,
// }, { upsert: true });
// }
res.sendData({})
}
......
const crypto = require('crypto');
const _ = require('lodash');
const mongoose = require('mongoose');
const CryptoJS = require('crypto-js');
const createError = require('http-errors');
......@@ -39,6 +40,13 @@ async function regist(req, res, next) {
// 登录
async function login(req, res, next) {
try {
if(req.body.encryptLogStr){
//避免差异 选用跟前端一样的包
let encryptLogStr = CryptoJS.AES.decrypt(req.body.encryptLogStr, "GFG5w5AP0Ja2rNaa").toString(CryptoJS.enc.Utf8);
let encArr = encryptLogStr.split(",");
req.body.mobile = encArr[0].trim();
req.body.password = encArr[1];
}
const { mobile, password } = req.body;
const user = await userModule.findUserByMobile(mobile);
if (!user) {
......
......@@ -11,8 +11,12 @@ module.exports = {
env_dev: {
NODE_ENV: "dev",
},
env_production: {
NODE_ENV: "production",
PORT:3000
},
log_date_format: "YYYY-MM-DD HH:mm:ss",
out_file: `logs/${curDateStr}.log`,
error_file: `logs/${curDateStr}.log`,
out_file: `/srv/letian/logs/${curDateStr}.log`,
error_file: `/srv/letian/logs/${curDateStr}.log`,
}]
};
......@@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"production": "NODE_ENV=production node server.js",
"production": "cross-env NODE_ENV=production node server.js",
"dev": "cross-env NODE_ENV=dev nodemon server.js",
"local": "cross-env NODE_ENV=local nodemon server.js"
},
......@@ -15,6 +15,7 @@
"compression": "1.7.4",
"cors": "2.8.5",
"crypto": "1.0.1",
"crypto-js": "^4.2.0",
"eslint": "9.4.0",
"exceljs": "4.4.0",
"express": "4.19.2",
......
......@@ -76,5 +76,5 @@ app.use(function (err, req, res, next) {
const server = require('http').createServer(app);
server.listen(process.env.PORT || 3000, function () {
console.log(`****** server is listening : ${process.env.PORT}`);
console.log(`****** server is listening : ${process.env.PORT} || 3000`);
});
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