diff --git a/api/app/lib/controllers/control/data.js b/api/app/lib/controllers/control/data.js index 4b09bcd..5cdd5ad 100644 --- a/api/app/lib/controllers/control/data.js +++ b/api/app/lib/controllers/control/data.js @@ -2,7 +2,7 @@ const moment = require('moment'); //BI分析-数据 -async function getDataAlarmsAggDay(ctx) { +async function getDataAlarmsAggDay (ctx) { try { const { utils: { anxinStrucIdRange } } = ctx.app.fs const { pepProjectId } = ctx.query @@ -12,10 +12,8 @@ async function getDataAlarmsAggDay(ctx) { ctx, pepProjectId }) let whereOption = [] - // ! 1 开发临时增加 if (anxinStruc.length) { const anxinStrucIds = anxinStruc.map(a => a.strucId) - // ! 开发临时注释 whereOption.push(`alarms.StructureId IN (${anxinStrucIds.join(",")})`) let start = moment().add(-1, 'year').format('YYYY-MM-DD HH:mm:ss');//最近一年 @@ -41,7 +39,7 @@ async function getDataAlarmsAggDay(ctx) { } } -async function queryAlarm(ctx, alarmQueryOptionStr, type) { +async function queryAlarm (ctx, alarmQueryOptionStr, type) { const { clickHouse } = ctx.app.fs try { const alarmRes = await clickHouse.dataAlarm.query(` @@ -76,7 +74,7 @@ async function queryAlarm(ctx, alarmQueryOptionStr, type) { } //BI分析-应用异常 -async function getAppAlarmsAggDay(ctx) { +async function getAppAlarmsAggDay (ctx) { try { const models = ctx.fs.dc.models; const { utils: { pomsProjectRange } } = ctx.app.fs @@ -129,7 +127,7 @@ async function getAppAlarmsAggDay(ctx) { } //BI分析-视频异常 -async function getVideoAlarmsAggDay(ctx) { +async function getVideoAlarmsAggDay (ctx) { try { const { clickHouse, utils: { anxinStrucIdRange } } = ctx.app.fs const { database: anxinyun } = clickHouse.anxinyun.opts.config @@ -246,7 +244,7 @@ async function getVideoAlarmsAggDay(ctx) { } //BI分析-问题处置效率分析 -async function getAlarmsHandleStatistics(ctx) { +async function getAlarmsHandleStatistics (ctx) { try { const { projectCorrelationId } = ctx.query const models = ctx.fs.dc.models; @@ -266,7 +264,7 @@ async function getAlarmsHandleStatistics(ctx) { } } //最新动态 -async function getLatestDynamic(ctx) { +async function getLatestDynamic (ctx) { try { const { models } = ctx.fs.dc; const { limit, page, projectCorrelationId, types } = ctx.query; @@ -303,9 +301,9 @@ async function getLatestDynamic(ctx) { }); //查项目名称 查用户名 - let pepPojectIds = new Set(), notedUserIds = new Set(); + let pepPojectIds = new Set(), notedUserIds = new Set(), emailSendPomsProjectIds = new Set(); for (let p of news) { - if(p.projectCorrelation && p.projectCorrelation.pepProjectId){ + if (p.projectCorrelation && p.projectCorrelation.pepProjectId) { pepPojectIds.add(p.projectCorrelation.pepProjectId); } @@ -313,11 +311,28 @@ async function getLatestDynamic(ctx) { p.emailSendLog.toPepUserIds.map(u => { notedUserIds.add(u);//通知 接收人 }) + p.emailSendLog.projectCorrelationId.forEach(pid => emailSendPomsProjectIds.add(pid)) } if (p.alarmConfirmLog && p.alarmConfirmLog.pepUserId) { notedUserIds.add(p.alarmConfirmLog.pepUserId);//确认 操作者 } } + + // EM 推送的特殊处理 + // 查找对应的 projectCorrelation + const emailLogProjectCorrelationRes = + emailSendPomsProjectIds.size ? + await models.ProjectCorrelation.findAll({ + where: { + id: { $in: [...emailSendPomsProjectIds] } + } + }) : [] + + for (let { dataValues: p } of emailLogProjectCorrelationRes) { + if (p.pepProjectId) { + pepPojectIds.add(p.pepProjectId) + } + } let pepProjects = pepPojectIds.size ? await clickHouse.projectManage.query(` SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds].join(',')},-1) `).toPromise() : []; @@ -339,7 +354,15 @@ async function getLatestDynamic(ctx) { if (d.emailSendId) { notice.push({ userName: userPepRes.filter(u => d.emailSendLog.toPepUserIds.indexOf(u.id) != -1), - projectName, + projectName: d.emailSendLog.projectCorrelationId.map(p => { + let projectName = '' + if (p.pepProjectId) { + projectName = pepProjects.find(pp => pp.id == p.pepProjectId).project_name + } else { + projectName = p.name + } + return projectName + }).join('、'), ...d.emailSendLog.dataValues }); } diff --git a/api/app/lib/index.js b/api/app/lib/index.js index dcc655c..84559e9 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -77,8 +77,8 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq AppAlarm.belongsTo(App, { foreignKey: 'projectAppId', targetKey: 'id' }); App.hasMany(AppAlarm, { foreignKey: 'projectAppId', sourceKey: 'id' }); - AlarmPushConfig.belongsTo(ProjectCorrelation, { foreignKey: 'pomsProjectId', targetKey: 'id' }); - ProjectCorrelation.hasMany(AlarmPushConfig, { foreignKey: 'pomsProjectId', sourceKey: 'id' }); + // AlarmPushConfig.belongsTo(ProjectCorrelation, { foreignKey: 'pomsProjectId', targetKey: 'id' }); + // ProjectCorrelation.hasMany(AlarmPushConfig, { foreignKey: 'pomsProjectId', sourceKey: 'id' }); AlarmAppearRecord.belongsTo(ProjectCorrelation, { foreignKey: 'projectCorrelationId', targetKey: 'id' }); ProjectCorrelation.hasMany(AlarmAppearRecord, { foreignKey: 'projectCorrelationId', sourceKey: 'id' }); diff --git a/api/app/lib/models/email_send_log.js b/api/app/lib/models/email_send_log.js index e1d95b6..da0a97f 100644 --- a/api/app/lib/models/email_send_log.js +++ b/api/app/lib/models/email_send_log.js @@ -53,7 +53,7 @@ module.exports = dc => { autoIncrement: false }, projectCorrelationId: { - type: DataTypes.INTEGER, + type: DataTypes.ARRAY(DataTypes.INTEGER), allowNull: false, defaultValue: null, comment: null, diff --git a/api/app/lib/models/latest_dynamic_list.js b/api/app/lib/models/latest_dynamic_list.js index 5b53051..320191a 100644 --- a/api/app/lib/models/latest_dynamic_list.js +++ b/api/app/lib/models/latest_dynamic_list.js @@ -54,7 +54,7 @@ module.exports = dc => { }, projectCorrelationId: { type: DataTypes.INTEGER, - allowNull: false, + allowNull: true, defaultValue: null, comment: null, primaryKey: false, diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index 96205d2..9c3460e 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -60,7 +60,7 @@ module.exports = function (app, opts) { for (let { dataValues: c } of configListRes) { if (c.tacticsParams && c.tactics) { // pomsProjectId 是个数组 [] - const { projectCorrelation, strucId, pomsProjectId, } = c + const { strucId, pomsProjectId, } = c const { interval, deviceProportion } = c.tacticsParams if ( @@ -248,7 +248,7 @@ module.exports = function (app, opts) { if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['strategy_hit']) } if (c.alarmType.includes('video_exception')) { - let videoAlarmSubType = c.alarmSubType ? c.alarmSubType['data_exception'] : [] + let videoAlarmSubType = c.alarmSubType ? c.alarmSubType['video_exception'] : [] if (videoAlarmSubType.length == 1) videoAlarmSubType.push(-1) videoAlarms = searchStrucIds.length && videoAlarmSubType.length ? await clickHouse.vcmp.query( ` @@ -734,6 +734,7 @@ module.exports = function (app, opts) { } return arr }, []) + // !开发测试用的数据 // emails = ['1650192445@qq.com'] if (emails.length) { await pushByEmail({ @@ -758,12 +759,11 @@ module.exports = function (app, opts) { let dynamic = { time: r.dataValues.time, emailSendId: r.dataValues.id, - projectCorrelationId: r.dataValues.projectCorrelationId, + // projectCorrelationId: r.dataValues.projectCorrelationId, type: 2//通知 } await models.LatestDynamicList.create(dynamic); - //消息推送到前端 await sendNoticeToWeb(receiverId, dataToSave); } diff --git a/script/0.11/schema/1.alter_email_send_log.sql b/script/0.11/schema/1.alter_email_send_log.sql new file mode 100644 index 0000000..b6ea2b4 --- /dev/null +++ b/script/0.11/schema/1.alter_email_send_log.sql @@ -0,0 +1,6 @@ +ALTER TABLE email_send_log ALTER COLUMN project_correlation_id TYPE INTEGER [] + USING CASE + WHEN project_correlation_id is NULL + then NULL + ELSE array [project_correlation_id] + END ::INTEGER []; \ No newline at end of file diff --git a/web/client/index.html b/web/client/index.html index 302a7e4..3ee9392 100644 --- a/web/client/index.html +++ b/web/client/index.html @@ -2,26 +2,26 @@
- - + + - + - - + + - - + + - - + + - - + + - - + - + - + \ No newline at end of file diff --git a/web/client/src/sections/control/containers/control.jsx b/web/client/src/sections/control/containers/control.jsx index c4857d2..acba920 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -8,7 +8,6 @@ import repairFQA from '../../means/containers/repairFQA'; import { Setup, OutHidden } from "$components"; import ReactECharts from 'echarts-for-react'; import moment from "moment"; -import { log } from 'ezuikit-js'; let newScrollbar; let overviewScrollbar; @@ -43,7 +42,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const [videoBI, setVideoBI] = useState([]); //查询BI分析数据-视频 const [appBI, setAppBI] = useState([]); //查询BI分析数据-应用 const [efficiencyBI, setEfficiencyBI] = useState({}); //查询BI分析数据-问题处置 - const [query, setQuery] = useState({ limit: 10, page: 0, projectCorrelationId: '', types: '1' }); //最新动态 + const [query, setQuery] = useState({ limit: 23, page: 0, projectCorrelationId: '', types: '1' }); //最新动态 const [querydata1, setQueryData1] = useState([]); //最新动态数据 const [long, setLong] = useState(''); //最新动态设置 const [pomsList, setPomsList] = useState([]); //项目 @@ -184,7 +183,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject newest.sort((a, b) => (moment(a.time).isBefore(b.time) ? 1 : -1)) querydata.current = [...newest, ...querydata.current] setQueryData1([...querydata.current]) - + } }, [socketData]) useEffect(() => { @@ -398,6 +397,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject })) } if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) { + // EM 推送 res.payload.data?.notice?.map(v => data.push({ seed: 'notice', time: v.time, @@ -444,14 +444,26 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const line = document.getElementById("line") const news = document.getElementById("news") if (line && news) { - news.onscroll = () => { + news.onscroll = (e) => { + e.stopPropagation(); if ((line.clientHeight - 578) < news.scrollTop + 10) { setQuery({ ...query, page: query.page + 1 }) if (exhibition?.current?.dynamic?.length > 0) { dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId, page: query.page + 1 })).then(res => { - news.scrollTop = news.scrollTop - 640 + // news.scrollTop = news.scrollTop - 640 let data = querydata.current if (res.success) { + let returnJudge = true + for (let k in res.payload.data) { + if (res.payload.data[k].length) { + returnJudge = false + break + } + } + if (returnJudge) { + return + } + if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { res.payload.data?.appear?.map(v => data.push({ seed: 'discovery', @@ -503,9 +515,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const domProject = document.getElementById("news"); if (domProject) { - // newScrollbar = new PerfectScrollbar("#news", { - // suppressScrollX: true, - // }); if (domProject && newScrollbar) { newScrollbar.update(); } @@ -513,9 +522,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const pomsList = document.getElementById("pomsList"); if (pomsList) { - // pomsListScrollbar = new PerfectScrollbar("#pomsList", { - // suppressScrollX: true, - // }); if (pomsList && pomsListScrollbar) { pomsListScrollbar.update(); } @@ -523,9 +529,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const domProject1 = document.getElementById("overviewCalc"); if (domProject1) { - // overviewScrollbar = new PerfectScrollbar("#overviewCalc", { - // suppressScrollY: true, - // }); if (domProject1 && overviewScrollbar) { overviewScrollbar.update(); } @@ -533,9 +536,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const domProject2 = document.getElementById("member"); if (domProject2) { - // memberScrollbar = new PerfectScrollbar("#member", { - // suppressScrollX: true, - // }); if (domProject2 && memberScrollbar) { memberScrollbar.update(); } @@ -543,9 +543,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const domProject3 = document.getElementById("equipment"); if (domProject3) { - // equipmentScrollbar = new PerfectScrollbar("#equipment", { - // suppressScrollX: true, - // }); if (domProject3 && equipmentScrollbar) { equipmentScrollbar.update(); } @@ -553,9 +550,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const domProject4 = document.getElementById("web"); if (domProject4) { - // webScrollbar = new PerfectScrollbar("#web", { - // suppressScrollX: true, - // }) if (domProject4 && webScrollbar) { webScrollbar.update(); } @@ -563,9 +557,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const domProject5 = document.getElementById("problems"); if (domProject5) { - // problemsScrollbar = new PerfectScrollbar("#problems", { - // suppressScrollX: true, - // }); if (domProject5 && problemsScrollbar) { problemsScrollbar.update(); } @@ -573,17 +564,11 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const domProject6 = document.getElementById("alarm"); if (domProject6) { - // alarmScrollbar = new PerfectScrollbar("#alarm", { - // suppressScrollY: true, - // }); if (domProject6 && alarmScrollbar) { alarmScrollbar.update(); } } - - // ACTION 示例 - // dispatch(actions.example.getMembers(user.orgId)) }) const consoleToollink = () => { @@ -625,8 +610,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject - - let Select = { overall: ['workbench', 'statistical', 'analyse', 'dynamic', 'tool'], workbench: ['project', 'data', 'app', 'device'], @@ -672,8 +655,6 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject { name: 'BI分析模块', sort: 3, key: 'analyse', }, { name: '最新动态', sort: 4, key: 'dynamic', }, { name: '我常用的工具', sort: 5, key: 'tool', }, - - ] useEffect(() => { @@ -1245,8 +1226,8 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject }} /> -