明树Git Lab

Commit 2efffc91 authored by zengfanpei's avatar zengfanpei

update

parent cc00ac3b
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
# 记录 # 记录
``` ```
1. 待完成excel导出 -- 这个要看前端做管理端菜单管理需要知道在那个菜单 对应哪个表 1. 待完成excel导出 -- 这个要看前端做管理端菜单管理,需要知道在那个菜单 对应哪个表
2. 农业投入品表的增删改查 已完成 2. 农业投入品表的增删改查 已完成
硬件入场 硬件入场:
1. 需要确认每一个设备的设备信息名称、设备编号、设备类型 1. 需要确认每一个设备的设备信息:名称、设备编号、设备类型
2. 需要确认每一个设备 对应的 每一个地块的位置信息 2. 需要确认每一个设备 对应的 每一个地块的位置信息
3. 需要确认每一个种类设备 上传的信息 接口调试 3. 需要确认每一个种类设备 上传的信息 接口调试
4. 4.
......
...@@ -52,7 +52,7 @@ async function importExcel(req, res, next) { ...@@ -52,7 +52,7 @@ async function importExcel(req, res, next) {
await workbook.xlsx.readFile(req.file.path); await workbook.xlsx.readFile(req.file.path);
let worksheet = workbook.getWorksheet(4); let worksheet = workbook.getWorksheet(4);
console.log(workbook._worksheets.length); 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.AgrInRecord.create({ await DB.AgrInRecord.create({
......
...@@ -256,10 +256,10 @@ async function createRole(req, res, next) { ...@@ -256,10 +256,10 @@ async function createRole(req, res, next) {
menus: [], menus: [],
buttons: [] buttons: []
} }
// // 1. 创建角色时同步设置角色权限 这里让前端直接将有选中状态的菜单tree传递到后端 // // 1. 创建角色时同步设置角色权限, 这里让前端直接将有选中状态的菜单tree传递到后端
// let menus = req.body.menus || []; // let menus = req.body.menus || [];
// let menusNodes = utils.disTree(menus); // let menusNodes = utils.disTree(menus);
// //选中状态 permission true 将menus buttons平行存入role中. // //选中状态 permission: true 将menus buttons平行存入role中.
// for (let i = 0; i < menusNodes.length; i++) { // for (let i = 0; i < menusNodes.length; i++) {
// const element = menusNodes[i]; // const element = menusNodes[i];
// if (element.permission) { // if (element.permission) {
...@@ -299,7 +299,7 @@ async function updateRole(req, res, next) { ...@@ -299,7 +299,7 @@ async function updateRole(req, res, next) {
}; };
// let menus = req.body.menus || []; // let menus = req.body.menus || [];
// let menusNodes = utils.disTree(menus); // let menusNodes = utils.disTree(menus);
// //选中状态 permission true 将menus buttons平行存入role中. // //选中状态 permission: true 将menus buttons平行存入role中.
// for (let i = 0; i < menusNodes.length; i++) { // for (let i = 0; i < menusNodes.length; i++) {
// const element = menusNodes[i]; // const element = menusNodes[i];
// if (element.permission) { // if (element.permission) {
......
...@@ -11,9 +11,9 @@ const collectWSModule = require('../module/collectWSModule'); ...@@ -11,9 +11,9 @@ const collectWSModule = require('../module/collectWSModule');
const _ = require('lodash'); const _ = require('lodash');
/** /**
* 获取协议 * 获取协议 :
* 1 土壤温湿度、土壤氮磷钾 * 1 土壤温湿度、土壤氮磷钾,
* 2 土壤ph、土壤电导率 * 2 土壤ph、土壤电导率,
* 3 气象站三大类设备 * 3 气象站三大类设备
*/ */
async function getDeviceList() { async function getDeviceList() {
...@@ -52,7 +52,7 @@ async function getAllDevice() { ...@@ -52,7 +52,7 @@ async function getAllDevice() {
} }
} }
/* -------------------------------------------有诸多不确定因素,暂时分开,后续 请求日志需要分别按照不同设备种类区分类型------------------------------------------------------------------ */ /* -------------------------------------------有诸多不确定因素,暂时分开,后续 请求日志需要分别按照不同设备种类区分类型------------------------------------------------------------------ */
/** /**
* 采集上述设备 1 的信息 * 采集上述设备 1 的信息
*/ */
...@@ -270,11 +270,11 @@ async function handleDeviceThreshold(obj) { ...@@ -270,11 +270,11 @@ async function handleDeviceThreshold(obj) {
if(_.isNumber(element.max) && _.gt(obj[element.dbKey], element.max)) { if(_.isNumber(element.max) && _.gt(obj[element.dbKey], element.max)) {
// 采集值 > 最大设置值 // 采集值 > 最大设置值
// exceeds.push({...element, collectValue: obj[element.dbKey], deviceNumber: obj.deviceNumber}); // exceeds.push({...element, collectValue: obj[element.dbKey], deviceNumber: obj.deviceNumber});
exceeds.push(`设备${obj.deviceNumber}, 采集值: ${obj[element.dbKey]}, 最大阈值${element.max}`); exceeds.push(`设备${obj.deviceNumber}, 采集值: ${obj[element.dbKey]}, 最大阈值:${element.max}`);
} }
if(_.isNumber(element.min) && _.lt(obj[element.dbKey], element.min)) { if(_.isNumber(element.min) && _.lt(obj[element.dbKey], element.min)) {
// exceeds.push({...element, collectValue: obj[element.dbKey], deviceNumber: obj.deviceNumber}); // exceeds.push({...element, collectValue: obj[element.dbKey], deviceNumber: obj.deviceNumber});
exceeds.push(`设备${obj.deviceNumber}, 采集值: ${obj[element.dbKey]}, 最小阈值${element.min}`); exceeds.push(`设备${obj.deviceNumber}, 采集值: ${obj[element.dbKey]}, 最小阈值:${element.min}`);
} }
} }
} }
......
...@@ -16,7 +16,7 @@ const deviceCron = require('./deviceCron'); ...@@ -16,7 +16,7 @@ const deviceCron = require('./deviceCron');
# * * * * * * # * * * * * *
*/ */
const cron = () => { const cron = () => {
// 1 土壤温湿度、土壤氮磷钾, 2 土壤ph、土壤电导率, 3 气象站 // 1 土壤温湿度、土壤氮磷钾, 2 土壤ph、土壤电导率, 3 气象站
if (sysConfig && sysConfig.cron && sysConfig.cron.getDeviceList) { if (sysConfig && sysConfig.cron && sysConfig.cron.getDeviceList) {
console.log("getDeviceList:", new Date()); console.log("getDeviceList:", new Date());
// 每天10点30分 处理 1 30 10 * * * // 每天10点30分 处理 1 30 10 * * *
......
const mongoose = require('mongoose'); const mongoose = require('mongoose');
// 连接字符串格式为 mongodb://用户名:密码@地址:端口/数据库名 // 连接字符串,格式为 mongodb://用户名:密码@地址:端口/数据库名
const dbURI = sysConfig.dbURI || 'mongodb://localhost:27017/letian'; const dbURI = sysConfig.dbURI || 'mongodb://localhost:27017/letian';
// 连接数据库 // 连接数据库
...@@ -19,12 +19,12 @@ mongoose.connection.on('disconnected', () => { ...@@ -19,12 +19,12 @@ mongoose.connection.on('disconnected', () => {
/** /**
1. 由于硬件提供的API返回参数皆为驼峰命名,为了对接方便,本系统数据库字段设计按照驼峰命名 1. 由于硬件提供的API返回参数皆为驼峰命名,为了对接方便,本系统数据库字段设计按照驼峰命名
如 templateId deviceNumber 如 templateId deviceNumber
2. 特殊情况下 允许字段使用数字作为区分数字直接与字母相连 2. 特殊情况下 允许字段使用数字作为区分,数字直接与字母相连
如 智壤仪温度1 soilTemperature1 智壤仪温度2 soilTemperature2 如 智壤仪温度1 soilTemperature1 智壤仪温度2 soilTemperature2
3. 数据库表名按照第一条规则也采用驼峰命名 3. 数据库表名按照第一条规则,也采用驼峰命名
4. 单词尽量使用翻译器翻译之后考虑使用要求简洁、见名知义 4. 单词尽量使用翻译器翻译之后考虑使用,要求简洁、见名知义
*/ */
const User = require('./models/systemUser'); const User = require('./models/systemUser');
......
...@@ -10,22 +10,22 @@ const moment = require('moment'); ...@@ -10,22 +10,22 @@ const moment = require('moment');
const collectAttributeSchema = new Schema({ const collectAttributeSchema = new Schema({
deviceKey: { deviceKey: {
type: String, type: String,
comment: "在硬件上设置的key 如土壤湿度" comment: "在硬件上设置的key 如:土壤湿度"
}, },
dbKey: { dbKey: {
type: String, type: String,
comment: "数据库里面的key 如windSpeed" comment: "数据库里面的key 如:windSpeed"
}, },
name: { name: {
type: String, type: String,
comment: "名称 如 湿度" comment: "名称 如: 湿度"
}, },
enable: { enable: {
type: Boolean, type: Boolean,
default: true, default: true,
comment: "true: 启用 false: 不启用" comment: "true: 启用, false: 不启用"
}, },
createdAt: { createdAt: {
type: Date, type: Date,
...@@ -40,7 +40,7 @@ const collectAttributeSchema = new Schema({ ...@@ -40,7 +40,7 @@ const collectAttributeSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -91,7 +91,7 @@ const collectInsectPestSituationSchema = new Schema({ ...@@ -91,7 +91,7 @@ const collectInsectPestSituationSchema = new Schema({
comment: "上一次标注后的图片(压缩后)", comment: "上一次标注后的图片(压缩后)",
}, },
/* 识别结果 不管哪一种形式,只要结果确认有效则写入,为空则表示此条数据无效,后续需要根据业务定期处理这类数据 */ /* 识别结果 不管哪一种形式,只要结果确认有效则写入,为空则表示此条数据无效,后续需要根据业务定期处理这类数据 */
cameraRecognition: { cameraRecognition: {
type: String, type: String,
default: null, default: null,
...@@ -112,7 +112,7 @@ const collectInsectPestSituationSchema = new Schema({ ...@@ -112,7 +112,7 @@ const collectInsectPestSituationSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -38,7 +38,7 @@ const collectIPSPlanSchema = new Schema({ ...@@ -38,7 +38,7 @@ const collectIPSPlanSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -3,7 +3,7 @@ const Schema = mongoose.Schema; ...@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
const moment = require('moment'); const moment = require('moment');
/** /**
* 虫情 一条采集数据 1: 图片识别结果 1: 一张图片会有多个虫子结果 n * 虫情 一条采集数据 1: 图片识别结果 1: 一张图片会有多个虫子结果 n
* 虫子结果--虫子类型--虫子解决方案 * 虫子结果--虫子类型--虫子解决方案
* *
*/ */
...@@ -73,7 +73,7 @@ const collectIPSResultSchema = new Schema({ ...@@ -73,7 +73,7 @@ const collectIPSResultSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -26,7 +26,7 @@ const collectIPSTypeSchema = new Schema({ ...@@ -26,7 +26,7 @@ const collectIPSTypeSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -122,7 +122,7 @@ const soilMoistureContentSchema = new Schema({ ...@@ -122,7 +122,7 @@ const soilMoistureContentSchema = new Schema({
}, },
onLineState: { onLineState: {
type: String, type: String,
comment: "在线状态,该字段不记录到db,后期采集数据时将状态更新到redis里面即可" comment: "在线状态,该字段不记录到db,后期采集数据时将状态更新到redis里面即可"
}, },
...@@ -140,7 +140,7 @@ const soilMoistureContentSchema = new Schema({ ...@@ -140,7 +140,7 @@ const soilMoistureContentSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -37,7 +37,7 @@ const collectThresholdSchema = new Schema({ ...@@ -37,7 +37,7 @@ const collectThresholdSchema = new Schema({
enable: { enable: {
type: Boolean, type: Boolean,
default: true, default: true,
comment: "true: 启用 false: 不启用" comment: "true: 启用, false: 不启用"
}, },
createdAt: { createdAt: {
type: Date, type: Date,
...@@ -52,7 +52,7 @@ const collectThresholdSchema = new Schema({ ...@@ -52,7 +52,7 @@ const collectThresholdSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -101,7 +101,7 @@ const collectWeatherStationSchema = new Schema({ ...@@ -101,7 +101,7 @@ const collectWeatherStationSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -50,7 +50,7 @@ const letianAgrInputRecordSchema = new Schema({ ...@@ -50,7 +50,7 @@ const letianAgrInputRecordSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -26,7 +26,16 @@ const AgrTaskSchema = new Schema({ ...@@ -26,7 +26,16 @@ const AgrTaskSchema = new Schema({
leader: { leader: {
type: mongoose.Types.ObjectId, type: mongoose.Types.ObjectId,
ref: 'User', ref: 'User',
comment: "负责人--从分配负责人开始,任务就开启" comment: "负责人--从分配负责人开始, 任务就开启"
},
status: {
type: Number,
comment: "1. 待分配(没有leader), 3. 进行中, 5 已完成"
},
auditStatus: {
type: Number,
comment: "1. 待审核, 2, 审核通过, 3.审核不通过, 记录最新的审核记录"
}, },
creator: { creator: {
...@@ -49,7 +58,7 @@ const AgrTaskSchema = new Schema({ ...@@ -49,7 +58,7 @@ const AgrTaskSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除, 若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 农事任务审核记录
*/
const AgrTaskAuditSchema = new Schema({
creator: {
type: mongoose.Types.ObjectId,
ref: 'User',
comment: "创建人"
},
audit: {
type: mongoose.Types.ObjectId,
ref: 'User',
comment: "审核人"
},
auditStatus: {
type: Number,
comment: "1. 待审核, 2, 审核通过, 3.审核不通过, 记录任务上"
},
createdAt: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
},
updatedAt: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
},
del: {
type: Number,
default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
}
}, {
toJSON: {
getters: true
}
});
const AgrTaskAudit = mongoose.model('AgrTaskAudit', AgrTaskAuditSchema, 'letianAgrTaskAudit');
module.exports = AgrTaskAudit;
\ No newline at end of file
...@@ -3,9 +3,14 @@ const Schema = mongoose.Schema; ...@@ -3,9 +3,14 @@ const Schema = mongoose.Schema;
const moment = require('moment'); const moment = require('moment');
/** /**
* 农事任务---农事记录,一个任务 对应多条农事记录 * 农事记录,一个农事任务 对应多条农事记录
*/ */
const AgrTaskSchema = new Schema({ const AgrTaskSchema = new Schema({
content: {
type: String,
comment: "内容"
},
task: { task: {
type: mongoose.Types.ObjectId, type: mongoose.Types.ObjectId,
...@@ -39,7 +44,7 @@ const AgrTaskSchema = new Schema({ ...@@ -39,7 +44,7 @@ const AgrTaskSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -4,7 +4,7 @@ const moment = require('moment'); ...@@ -4,7 +4,7 @@ const moment = require('moment');
/** /**
* 园区 * 园区
* 结构设想是省-市-县-乡镇-园区 * 结构设想是:省-市-县-乡镇-园区
*/ */
const letianAreaRecord = new Schema({ const letianAreaRecord = new Schema({
province: { province: {
...@@ -70,7 +70,7 @@ const letianAreaRecord = new Schema({ ...@@ -70,7 +70,7 @@ const letianAreaRecord = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -31,11 +31,11 @@ const landSchema = new Schema({ ...@@ -31,11 +31,11 @@ const landSchema = new Schema({
latestYield: { latestYield: {
type: Number, type: Number,
comment: "最近一期的产量通过产量表录入", comment: "最近一期的产量,通过产量表录入",
}, },
latestYieldValue: { latestYieldValue: {
type: Number, type: Number,
comment: "最近一期的产值通过产值表录入", comment: "最近一期的产值,通过产值表录入",
}, },
zone: { zone: {
type: mongoose.Types.ObjectId, type: mongoose.Types.ObjectId,
...@@ -58,7 +58,7 @@ const landSchema = new Schema({ ...@@ -58,7 +58,7 @@ const landSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -33,7 +33,7 @@ const PlantCycleSchema = new Schema({ ...@@ -33,7 +33,7 @@ const PlantCycleSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -56,7 +56,7 @@ const PlantPlanSchema = new Schema({ ...@@ -56,7 +56,7 @@ const PlantPlanSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -36,7 +36,7 @@ const PlantVarietySchema = new Schema({ ...@@ -36,7 +36,7 @@ const PlantVarietySchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -4,7 +4,7 @@ const moment = require('moment'); ...@@ -4,7 +4,7 @@ const moment = require('moment');
/** /**
* 园区 * 园区
* 结构设想是省-市-县-乡镇-园区 * 结构设想是:省-市-县-乡镇-园区
*/ */
const ZoneSchema = new Schema({ const ZoneSchema = new Schema({
name: { name: {
...@@ -40,7 +40,7 @@ const ZoneSchema = new Schema({ ...@@ -40,7 +40,7 @@ const ZoneSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
toJSON: { toJSON: {
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
// del: { // del: {
// type: Number, // type: Number,
// default: 0, // default: 0,
// comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' // comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
// } // }
// }, { // }, {
// id: false, // id: false,
...@@ -48,4 +48,4 @@ ...@@ -48,4 +48,4 @@
// const Button = mongoose.model('Button', buttonSchema, 'systemButton'); // const Button = mongoose.model('Button', buttonSchema, 'systemButton');
// module.exports = Button; // module.exports = Button;
// 合并到menus里面,方便前端处理。 // 合并到menus里面,方便前端处理。
\ No newline at end of file \ No newline at end of file
...@@ -41,7 +41,7 @@ const departSchema = new Schema({ ...@@ -41,7 +41,7 @@ const departSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -42,7 +42,7 @@ const fileSchema = new Schema({ ...@@ -42,7 +42,7 @@ const fileSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -50,14 +50,14 @@ const menuSchema = new Schema({ ...@@ -50,14 +50,14 @@ const menuSchema = new Schema({
type: { type: {
type: Number, type: Number,
comment: "类型: 1. 菜单, 2. 按钮", comment: "类型: 1. 菜单, 2. 按钮",
default: 1 default: 1
}, },
enable: { enable: {
type: Boolean, type: Boolean,
default: true, default: true,
comment: "true: 启用, false: 不启用" comment: "true: 启用, false: 不启用"
}, },
createdAt: { createdAt: {
...@@ -73,7 +73,7 @@ const menuSchema = new Schema({ ...@@ -73,7 +73,7 @@ const menuSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -23,7 +23,7 @@ const Noticechema = new Schema({ ...@@ -23,7 +23,7 @@ const Noticechema = new Schema({
read: { read: {
type: Boolean, type: Boolean,
default: false, default: false,
comment: "true 已读 false 未读" comment: "true 已读, false 未读"
}, },
...@@ -41,7 +41,7 @@ const Noticechema = new Schema({ ...@@ -41,7 +41,7 @@ const Noticechema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -42,7 +42,7 @@ const requestLogSchema = new Schema({ ...@@ -42,7 +42,7 @@ const requestLogSchema = new Schema({
}, },
type: { type: {
type: String, type: String,
comment: "日志类型 调用外部硬件接口日志:device, 系统内部请求日志:system", comment: "日志类型 调用外部硬件接口日志:device, 系统内部请求日志:system",
default: "system" default: "system"
}, },
createdAt: { createdAt: {
......
...@@ -21,7 +21,7 @@ const roleSchema = new Schema({ ...@@ -21,7 +21,7 @@ const roleSchema = new Schema({
menus: { menus: {
type: [mongoose.Types.ObjectId], type: [mongoose.Types.ObjectId],
ref: "Menu", ref: "Menu",
comment: "记录的是包含菜单和按钮的集合方便展示树结构" comment: "记录的是包含菜单和按钮的集合,方便展示树结构"
}, },
buttons: { buttons: {
type: [mongoose.Types.ObjectId], type: [mongoose.Types.ObjectId],
...@@ -43,7 +43,7 @@ const roleSchema = new Schema({ ...@@ -43,7 +43,7 @@ const roleSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -40,17 +40,17 @@ const userSchema = new Schema({ ...@@ -40,17 +40,17 @@ const userSchema = new Schema({
depart: { depart: {
type: mongoose.Types.ObjectId, type: mongoose.Types.ObjectId,
ref: "Depart", ref: "Depart",
comment: "一个人只有一个部门 ,若存在一个人多个部门的情况,需要重新设计" comment: "一个人只有一个部门 ,若存在一个人多个部门的情况,需要重新设计"
}, },
enable: { enable: {
type: Boolean, type: Boolean,
default: true, default: true,
comment: "true: 启用, false: 不启用" comment: "true: 启用, false: 不启用"
}, },
status: { status: {
type: Number, type: Number,
comment: "状态 1:正常, 2:.....", comment: "状态 1:正常, 2:.....",
default: 1 default: 1
}, },
...@@ -76,7 +76,7 @@ const userSchema = new Schema({ ...@@ -76,7 +76,7 @@ const userSchema = new Schema({
del: { del: {
type: Number, type: Number,
default: 0, default: 0,
comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。' comment: '默认0 , 1:表示删除,若有其他隐藏业务 不要混用此字段。'
} }
}, { }, {
id: false, id: false,
......
...@@ -28,7 +28,7 @@ module.exports = async (req, res, next) => { ...@@ -28,7 +28,7 @@ module.exports = async (req, res, next) => {
} }
} }
/* --------------3. 记录所有进来的日志是否记录响应的值有待 */ /* --------------3. 记录所有进来的日志,是否记录响应的值有待 */
requestLogModule.createRequestLog({ requestLogModule.createRequestLog({
url: req.baseUrl + req.path, url: req.baseUrl + req.path,
params: JSON.stringify({ params: JSON.stringify({
......
...@@ -17,7 +17,7 @@ module.exports = (req, res, next) => { ...@@ -17,7 +17,7 @@ module.exports = (req, res, next) => {
}); });
}; };
res['sendError'] = (error) => { res['sendError'] = (error) => {
// 除404 500以外 其他均归类为业务错误 以http 200返回具体错误在返回内容里面根据code来区分。 // 除404 500以外 其他均归类为业务错误 以http 200返回,具体错误在返回内容里面根据code来区分。
res.status(200).send({ res.status(200).send({
code: error.code, code: error.code,
message: error.message, message: error.message,
......
...@@ -76,7 +76,7 @@ async function insertHQData(data) { ...@@ -76,7 +76,7 @@ async function insertHQData(data) {
// let name = String(eleArr[0]).trim(); // let name = String(eleArr[0]).trim();
// // 记录虫子类型 // // 记录虫子类型
// let bugType = await DB.CollectIPSType.findOneAndUpdate({ name }, { name }, { upsert: true }); // let bugType = await DB.CollectIPSType.findOneAndUpdate({ name }, { name }, { upsert: true });
// //获取防止建议---此处建议不从远端取在本系统根据虫子种类维护建议即可 // //获取防止建议---此处建议不从远端取,在本系统根据虫子种类维护建议即可
// let preInRet = await httpRequest({ // let preInRet = await httpRequest({
// url: sysConfig.device.getPreventionToInsectName, // url: sysConfig.device.getPreventionToInsectName,
// method: "GET", // method: "GET",
...@@ -130,7 +130,7 @@ async function handleIPSResult(data) { ...@@ -130,7 +130,7 @@ async function handleIPSResult(data) {
let name = String(eleArr[0]).trim(); let name = String(eleArr[0]).trim();
// 记录虫子类型 // 记录虫子类型
let bugType = await DB.CollectIPSType.findOneAndUpdate({ name }, { name }, { upsert: true }); let bugType = await DB.CollectIPSType.findOneAndUpdate({ name }, { name }, { upsert: true });
//获取防止建议---此处建议不从远端取在本系统根据虫子种类维护建议即可 //获取防止建议---此处建议不从远端取,在本系统根据虫子种类维护建议即可
let preInRet = await httpRequest({ let preInRet = await httpRequest({
url: sysConfig.device.getPreventionToInsectName, url: sysConfig.device.getPreventionToInsectName,
method: "GET", method: "GET",
......
...@@ -20,10 +20,10 @@ async function findAll(search, fields = [], ) { ...@@ -20,10 +20,10 @@ async function findAll(search, fields = [], ) {
/** /**
* 用来插入通过 "HTTP数据获取-设备接口" 获取的设备插入 * 用来插入通过 "HTTP数据获取-设备接口" 获取的设备插入
* 1. 检查是否存在,存在则更新设备信息,不存在则插入系统 * 1. 检查是否存在,存在则更新设备信息,不存在则插入系统
* 2. 如果之前出现后续没有出现的需要去掉 * 2. 如果之前出现,后续没有出现的需要去掉
* ---- * ----
* 按照最新沟通的结果,设备可能是固定的,或许不需要实时更新设备列表 * 按照最新沟通的结果,设备可能是固定的,或许不需要实时更新设备列表
*/ */
async function insertHQDevice(datas, deviceHQType) { async function insertHQDevice(datas, deviceHQType) {
let devNumArr = []; let devNumArr = [];
......
...@@ -43,7 +43,7 @@ async function getRoleMenus(roles) { ...@@ -43,7 +43,7 @@ async function getRoleMenus(roles) {
} }
console.log(menuIds) console.log(menuIds)
let buts = await DB.Menu.find({ del: 0, _id: { $in: buttonIds } }).lean().exec(); let buts = await DB.Menu.find({ del: 0, _id: { $in: buttonIds } }).lean().exec();
// 把按钮的最近一级的父节点,作为map的key,按钮在下面放到对应的菜单中 // 把按钮的最近一级的父节点,作为map的key,按钮在下面放到对应的菜单中
let bMap = {}; let bMap = {};
for (let i = 0; i < buts.length; i++) { for (let i = 0; i < buts.length; i++) {
const o = buts[i]; const o = buts[i];
......
...@@ -7,7 +7,7 @@ const collectSMCController = require('../controller/collectSMCController'); ...@@ -7,7 +7,7 @@ const collectSMCController = require('../controller/collectSMCController');
const collectWSController = require('../controller/collectWSController'); const collectWSController = require('../controller/collectWSController');
/* -----数据采集相关接口可以用类简化 暂时---- */ /* -----数据采集相关接口,可以用类简化 暂时---- */
/** /**
......
...@@ -34,7 +34,7 @@ router.post('/upload', upload.single('file'), fileController.upload); ...@@ -34,7 +34,7 @@ router.post('/upload', upload.single('file'), fileController.upload);
router.post('/batch/upload', upload.array('files'), fileController.batchUpload); router.post('/batch/upload', upload.array('files'), fileController.batchUpload);
// 文件访问 起nginx用以处理文件服务器。 // 文件访问: 起nginx用以处理文件服务器。
/** /**
......
...@@ -29,10 +29,10 @@ function checkUserPassword({ reqPw, salt, userPw }) { ...@@ -29,10 +29,10 @@ function checkUserPassword({ reqPw, salt, userPw }) {
} }
function buildTree(nodes) { function buildTree(nodes) {
// 创建一个映射将节点ID映射到节点对象 // 创建一个映射,将节点ID映射到节点对象
const nodeMap = new Map(nodes.map(node => [String(node._id), { ...node, children: [] }])); const nodeMap = new Map(nodes.map(node => [String(node._id), { ...node, children: [] }]));
// 遍历所有节点并将它们添加到对应父节点的children数组中 // 遍历所有节点,并将它们添加到对应父节点的children数组中
nodes.forEach(node => { nodes.forEach(node => {
const parentId = String(node.parentId); const parentId = String(node.parentId);
if (parentId !== null) { if (parentId !== null) {
......
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