diff --git a/api/app/lib/controllers/project/group.js b/api/app/lib/controllers/project/group.js index f47cd73..0aba3b9 100644 --- a/api/app/lib/controllers/project/group.js +++ b/api/app/lib/controllers/project/group.js @@ -107,13 +107,15 @@ async function groupStatistic (ctx) { try { const { models } = ctx.fs.dc; const { userId } = ctx.fs.api + const { pomsU } = ctx.query const { clickHouse } = ctx.app.fs const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs const sequelize = ctx.fs.dc.orm + let userId_ = pomsU || userId const progectGroupList = await models.ProjectGroup.findAll({ where: { - pomsUserId: userId + pomsUserId: userId_ } }) diff --git a/api/app/lib/utils/push.js b/api/app/lib/utils/push.js index a0cf5ed..6053a06 100644 --- a/api/app/lib/utils/push.js +++ b/api/app/lib/utils/push.js @@ -29,21 +29,23 @@ module.exports = function (app, opts) { } } - const pushByEmail = async ({ email = [], title, text = '', html = '', attachments = undefined, } = {}) => { + let senderIndex = 0 + const pushByEmail = async ({ email = [], title, text = '', html = '', attachments = undefined, } = {}) => { try { + let useSender = opts.email.sender[senderIndex++ % opts.email.sender.length] let transporter = nodemailer.createTransport({ host: opts.email.host, port: opts.email.port, secure: true, auth: { - user: opts.email.sender.address, - pass: opts.email.sender.password, + user: useSender.address, + pass: useSender.password, } }); // send mail with defined transport object await transporter.sendMail({ - from: `${opts.email.sender.name}<${opts.email.sender.address}>`, // sender address + from: `${useSender.name}<${useSender.address}>`, // sender address to: email.join(','), // list of receivers 逗号分隔字符串 subject: title, // Subject line text: text, // plain text body diff --git a/web/client/src/layout/components/header/index.jsx b/web/client/src/layout/components/header/index.jsx index 261490c..ac19ac5 100644 --- a/web/client/src/layout/components/header/index.jsx +++ b/web/client/src/layout/components/header/index.jsx @@ -109,10 +109,12 @@ const Header = (props) => { style={{ display: "inline-block", width: 200, height: 40, marginLeft: -24, cursor: 'pointer' }} onClick={() => { let projectGroup = JSON.parse(localStorage.getItem('project_group')) - if (projectGroup && projectGroup?.find(v => v.userId == user?.id)) { - window.open('/projectGroup/bigscreen', '_blank') + let url = `/projectGroup/bigscreen?pomsU=${user?.id}` + let curPG = projectGroup && projectGroup?.find(v => v.userId == user?.id) + if (curPG) { + window.open(`/projectGroup/bigscreen?pomsPG=${curPG.projectGroupId}&pomsU=${user?.id}`, '_blank') } else { - window.open('/projectGroup/statistic', '_blank') + window.open(`/projectGroup/statistic?pomsU=${user?.id}`, '_blank') } }} /> @@ -372,7 +374,6 @@ const Header = (props) => { {/* collapseButton collapseText */} - } diff --git a/web/client/src/layout/containers/layout/index.jsx b/web/client/src/layout/containers/layout/index.jsx index 65275ee..a3237b8 100644 --- a/web/client/src/layout/containers/layout/index.jsx +++ b/web/client/src/layout/containers/layout/index.jsx @@ -170,7 +170,9 @@ const LayoutContainer = props => { useEffect(() => { NProgress.done(); if ((!user || !user.authorized)) { - history.push('/signin'); + if (!location.pathname.includes('projectGroup')) { + history.push('/signin'); + } } if (msg) { if (msg.done) { diff --git a/web/client/src/layout/index.jsx b/web/client/src/layout/index.jsx index c045f7f..457ac34 100644 --- a/web/client/src/layout/index.jsx +++ b/web/client/src/layout/index.jsx @@ -144,7 +144,7 @@ const Root = props => { setOuterRoutes(outerRoutes.map(route => ( diff --git a/web/client/src/sections/projectGroup/actions/group.js b/web/client/src/sections/projectGroup/actions/group.js index 72e47b5..e994f1b 100644 --- a/web/client/src/sections/projectGroup/actions/group.js +++ b/web/client/src/sections/projectGroup/actions/group.js @@ -34,12 +34,12 @@ export function delProjectGroup (id) { }); } -export function groupStatistic () { +export function groupStatistic ({ userId } = {}) { return (dispatch) => basicAction({ type: "get", dispatch: dispatch, actionType: "GET_GROPUP_STATISTICS", - url: `${ApiTable.groupStatistic}`, + url: `${ApiTable.groupStatistic}?pomsU=${userId || ''}`, msg: { error: "获取项目分组统计信息失败" }, reducer: { name: "groupStatistic", params: { noClear: true } }, }); @@ -66,8 +66,10 @@ export function groupStatisticAlarm (query = {}) { actionType: "GET_STATISTICALARM", url: `${ApiTable.groupStatisticAlarm}`, msg: { error: "获取项目分组告警统计信息失败" }, - reducer: { name: "groupStatisticAlarm", - params: { noClear: true } }, + reducer: { + name: "groupStatisticAlarm", + params: { noClear: true } + }, }); } @@ -79,8 +81,10 @@ export function groupProject (query = {}) { actionType: "GET_GROUP_PROJECT", url: `${ApiTable.groupProject}`, msg: { error: "获取分组项目信息失败" }, - reducer: { name: "groupProject", - params: { noClear: true } }, + reducer: { + name: "groupProject", + params: { noClear: true } + }, }); } diff --git a/web/client/src/sections/projectGroup/components/header.jsx b/web/client/src/sections/projectGroup/components/header.jsx index 68e7d2b..aa2fb1c 100644 --- a/web/client/src/sections/projectGroup/components/header.jsx +++ b/web/client/src/sections/projectGroup/components/header.jsx @@ -1,11 +1,12 @@ import React, { useEffect, useRef, useState } from 'react'; import { connect } from 'react-redux'; import { Skeleton, Button, Pagination, Form, Popconfirm, Table, Toast } from '@douyinfe/semi-ui'; +import { push } from 'react-router-redux'; import moment from "moment"; const Header = (props) => { - const { dispatch, actions, user,match, weatherRealtime, history } = props - + const { dispatch, actions, user, match, weatherRealtime, history } = props + const [queryUserId, setQueryUserId] = useState('') const [date, setDate] = useState(moment()); const dayMap = { 0: '日', 1: '一', 2: '二', 3: '三', 4: '四', 5: '五', 6: '六' } const weatherMap = { @@ -24,6 +25,13 @@ const Header = (props) => { dispatch(actions.auth.getWeatherRealtime()) } useEffect(() => { + console.log(props?.location); + let search = props?.location?.search || ''; + let params = new URLSearchParams(search); + let userId = params.get('pomsU') + console.log(userId); + setQueryUserId(userId) + const setTime = () => { setDate(moment()); setTimeout(() => { @@ -120,7 +128,7 @@ const Header = (props) => { display: "flex", alignItems: 'center', justifyContent: "space-around", width: 90, color: 'color: #5A6685', fontSize: 14, fontFamily: "SourceHanSansCN-Regular", cursor: 'pointer' }} onClick={() => { - history.push({ pathname: `/projectGroup/statistic`, }) + dispatch(push(`/projectGroup/statistic?pomsU=${queryUserId}`)) }}> 返回后台 diff --git a/web/client/src/sections/projectGroup/containers/bigscreen.jsx b/web/client/src/sections/projectGroup/containers/bigscreen.jsx index 9d928cd..273d386 100644 --- a/web/client/src/sections/projectGroup/containers/bigscreen.jsx +++ b/web/client/src/sections/projectGroup/containers/bigscreen.jsx @@ -1,6 +1,7 @@ import React, { useEffect, useRef, useState } from 'react'; import { Skeleton, Button, Pagination, Select, Popconfirm, Table, Tooltip } from '@douyinfe/semi-ui'; import { connect } from 'react-redux'; +import { push } from 'react-router-redux'; import Header from '../components/header'; import Body from '../components/body' import Card from '../components/card' @@ -13,7 +14,8 @@ import AutoRollComponent from '../components/AutoRollComponent' let interrupt let repair let overviewScrollbar; -const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, groupStatisticOnline }) => { +const Bigscreen = (props) => { + const { dispatch, actions, user, match, history, clientHeight, groupStatisticOnline, ...restProps } = props const [InterruptRank, setInterruptRank] = useState([]) const [online, setOnline] = useState([]) @@ -30,27 +32,37 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou const [xData, setXData] = useState([])//横坐标 const self = useRef({ myChart: null }); + // const [queryUserId, setQueryUserId] = useState('') useEffect(() => { - let groupId = JSON.parse(localStorage.getItem('project_group'))?.find(v => user?.id == v.userId)?.projectGroupId - statisticOnline(groupId) + + let groupIdLocal = JSON.parse(localStorage.getItem('project_group'))?.find(v => user?.id == v.userId)?.projectGroupId + + let search = restProps?.location?.search || ''; + let params = new URLSearchParams(search); + // let userId = params.get('pomsU') + let groupId = params.get('pomsPG') + + // setQueryUserId(userId) + + let groupId_ = groupId || groupIdLocal + + statisticOnline(groupId_) //计算当前时间,定时更新 - timeRequest(groupId) - dispatch(actions.projectGroup.groupStatisticAlarm({ groupId })).then(res => { + timeRequest(groupId_) + dispatch(actions.projectGroup.groupStatisticAlarm({ groupId: groupId_ })).then(res => { if (res.success) { setMockData(res.payload.data) } }) - - dispatch(actions.projectGroup.groupProject({ groupId })).then(res => { + dispatch(actions.projectGroup.groupProject({ groupId: groupId_ })).then(res => { if (res.success) { setGroupProject(res.payload.data?.map(v => ({ ...v, value: (Math.random() * 20).toFixed(0) })) || []) setProportion([...res.payload.data?.slice(0, 3)?.map(v => ({ name: v.name || v.pepProjectName, value: (Math.random() * 20).toFixed(0) })), { value: 20, name: '其它' }]) } }) - const interruptDom = document.getElementById("interrupt"); if (interruptDom) { interrupt = new PerfectScrollbar("#interrupt", { @@ -65,6 +77,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou } }, []) + useEffect(() => { const overview = document.getElementById("alarmRank"); if (overview) { @@ -108,7 +121,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou const newArray = mockData.slice(0, 20) setAlarmData(newArray) - }else{ + } else { setAlarmData(mockData) } }, [mockData]) @@ -182,7 +195,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou return (
-
+
@@ -288,7 +301,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
- +
{/*
*/}