diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 7a3b8d3..a762b66 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -16,9 +16,9 @@ "-p 4600", "-f http://localhost:4600", // 研发 - "-g postgres://postgres:123@10.8.30.32:5432/orational_service", + // "-g postgres://postgres:123@10.8.30.32:5432/orational_service", // 测试 - // "-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS", + "-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS", "-k 10.8.30.72:29092,10.8.30.73:29092,10.8.30.74:29092", "--iotaProxy http://10.8.30.157:17007", "--redisHost 10.8.30.112", @@ -56,7 +56,7 @@ // "--clickHouseDataAlarm default", // 测试 - "--clickHouseAnxincloud Anxinyun23", + "--clickHouseAnxincloud pg_anxinyun", "--clickHousePepEmis pepca8", "--clickHouseProjectManage peppm8", "--clickHouseVcmp video_access_dev", diff --git a/api/app/lib/controllers/control/toolLink.js b/api/app/lib/controllers/control/toolLink.js index c61abbc..794bdfc 100644 --- a/api/app/lib/controllers/control/toolLink.js +++ b/api/app/lib/controllers/control/toolLink.js @@ -46,16 +46,7 @@ async function edit (ctx) { if (linkId) { findOption.where.id = { $ne: linkId } } - const existRes = await models.QuickLink.findOne({ - where: { - userId: userId, - $or: [{ - name, - }, { - link, - }] - } - }) + const existRes = await models.QuickLink.findOne(findOption) if (existRes) { throw '已有相同名称/地址的工具' } diff --git a/api/app/lib/service/kafka.js b/api/app/lib/service/kafka.js index adf393d..cb6f9d8 100644 --- a/api/app/lib/service/kafka.js +++ b/api/app/lib/service/kafka.js @@ -104,14 +104,14 @@ module.exports = async function factory(app, opts) { const { clickHouse, utils: { sendAppearToWeb, sendConfirmToWeb } } = app.fs try { let { messageMode, structureId, sourceName, alarmTypeCode, alarmCode, content, time } = msg; - let structsAche = await getStructsAche(); + let structsAche = await getStructsAche() if (structsAche) { let structs = structsAche.dataList;//结构物列表 const { models } = app.fs.dc let exist = structs.find(s => s.strucId == structureId); if (exist) { let alarm_group = await clickHouse.anxinyun.query( - `SELECT alarm_group, alarm_group_unit FROM t_alarm_code WHERE code='${alarmCode}'`).toPromise(); + `SELECT alarm_group, alarm_group_unit FROM t_alarm_code WHERE code='${alarmCode}'`).toPromise() let type = null, alarmGroup = null;//告警类型 异常类型 if (alarm_group) { diff --git a/web/client/src/components/setup.jsx b/web/client/src/components/setup.jsx index 324e82d..36254c9 100644 --- a/web/client/src/components/setup.jsx +++ b/web/client/src/components/setup.jsx @@ -11,6 +11,7 @@ function Setup (props) { tableType, tableList, layout, //格式 + data=8 } = props; const [check, setCheck] = useState([]); @@ -24,7 +25,7 @@ function Setup (props) { ischeck(); }, []); function ischeck (value) { - if (check.length >= 8) { + if (check.length >= data) { if (check.includes(value)) { return false; } else { @@ -48,12 +49,12 @@ function Setup (props) { textAlign: "center", marginLeft: 6, background: - check.length == 8 + check.length == data ? "rgba(40, 123, 255, 1)" : "rgba(176, 176, 176, 1)", }} > - {check.length}/8 + {check.length}/{data} } diff --git a/web/client/src/sections/control/containers/control.jsx b/web/client/src/sections/control/containers/control.jsx index 54e12db..9f722d8 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -45,29 +45,27 @@ const Control = (props) => { const [appBI, setAppBI] = useState([]); //查询BI分析数据-应用 const [efficiencyBI, setEfficiencyBI] = useState({}); //查询BI分析数据-问题处置 const [query, setQuery] = useState({ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' }); //最新动态 - const [querydata, setQueryData] = useState([]); //最新动态数据 + const [querydata1, setQueryData1] = useState([]); //最新动态数据 const [long, setLong] = useState(''); //最新动态设置 const [pomsList, setPomsList] = useState([]); //项目 const [projectId, setProjectId] = useState(''); //项目id + const [ask, setASk] = useState(true); //是否继续请求 + const [setData, setSetData] = useState(); //设置总数 const exhibition = useRef({ workbench: [], statistical: [] }) //页面结构 const FormApi = useRef() + const querydata = useRef([])//最新动态数据 // const query={ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' } //最新动态 // websocket 使用测试 useEffect(() => { if (socket) { socket.on('alarmSendSocket', function (msg) { - console.info(msg); - if (msg.type == "alarmAppear") {//告警出现 + // console.info(msg); - } else if (msg.type == "alarmConfirm") {//告警确认 - - } else if (msg.type == "alarmNotice") {//通知 - - } - //console.info(msg); + // console.info(msg); + console.log(msg); let a = msg; }); return () => { @@ -87,36 +85,35 @@ const Control = (props) => { : "" attribute(v) }) + dispatch(install.getProjectPoms({ global: 1 })).then((res) => { //获取已绑定项目 + if (res.success) { + let data = res.payload.data?.rows?.filter(v => v.pepProjectIsDelete !== 1)?.map(v => ({ pepProjectId: v.id, pepProjectName: v.pepProjectName || v.name })) + setPomsList(data) + setProjectId(data[0]?.pepProjectId) + } + }) + return () => { - + } }, []) useEffect(() => { - if (pepProjectId) setProjectId('') - if (!pepProjectId) { - dispatch(install.getProjectPoms({ global: 1 })).then((res) => { //获取已绑定项目 - if (res.success) { - let data = res.payload.data?.rows?.filter(v => v.pepProjectIsDelete !== 1)?.map(v => ({ pepProjectId: v.id, pepProjectName: v.pepProjectName || v.name })) - setPomsList(data) - setProjectId(data[0]?.pepProjectId) - } - }) - } + if (pepProjectId) setProjectId(pepProjectId) if (!projectId) { - // 工作台数据请求 + 工作台数据请求 dispatch(control.getConsoleCount({ pepProjectId: pepProjectId })).then(res => { if (res.success) setWorkData(res.payload.data) }) - // 查询BI分析数据-数据 + 查询BI分析数据-数据 dispatch(control.getDataAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => { if (res.success) setDataBI(res.payload.data) }) - //查询BI分析数据-视频异常 + 查询BI分析数据-视频异常 dispatch(control.getVideoAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => { if (res.success) setVideoBI(res.payload.data) }) - //查询BI分析数据-应用 + 查询BI分析数据-应用 dispatch(control.getAppAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => { if (res.success) setAppBI(res.payload.data) }) @@ -125,12 +122,13 @@ const Control = (props) => { }) } + // 统计概览--异常&问题 dispatch(control.getConsoleAbnormal({ pepProjectId: pepProjectId || projectId })).then(res => { if (res.success) { if (res.payload.data?.length > 4) { setProblemsList([...res.payload.data, ...res.payload.data]) - startmarquee(500, 2000, 'problems') + startmarquee('problems') } else { setProblemsList(res.payload.data) } @@ -141,13 +139,13 @@ const Control = (props) => { if (res.success) { if (res.payload.data?.personnel?.length > 5) { setMemberList([...res.payload.data?.personnel, ...res.payload.data?.personnel]) - startmarquee(600, 2000, 'member') + startmarquee('member') } else { setMemberList(res.payload.data?.personnel) } if (res.payload.data?.webApp?.length > 3) { setWebList([...res.payload.data?.webApp, ...res.payload.data?.webApp]) - startmarquee(600, 2000, 'web') + startmarquee('web') } else { setWebList(res.payload.data?.webApp) } @@ -159,8 +157,11 @@ const Control = (props) => { useEffect(() => { //查询最新动态 if (exhibition?.current?.dynamic?.length > 0) { + console.log(query?.page); dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId })).then(res => { - let data = querydata + // console.log(res.payload.data); + if (res.payload.data?.appear?.length || 0 + res.payload.data?.confirm?.length + res.payload.data?.notice?.length < 10) setASk(false) + let data = [] if (res.success) { if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { res.payload.data?.appear?.map(v => data.push({ @@ -169,6 +170,7 @@ const Control = (props) => { sources: v.alarmInfo?.sourceName, type: v.type, time: v.time, + id: v.id, })) } if (exhibition?.current?.dynamic?.find(v => v.key == 'confirm')) { @@ -179,7 +181,7 @@ const Control = (props) => { type: v.alarmInfo?.type, time: v.confirmTime, userName: v.userName, - // confirmContent:v.confirmContent, + id: v.id, })) } if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) { @@ -192,6 +194,7 @@ const Control = (props) => { tactics: v.tactics, interval: v.tacticsParams?.interval, deviceProportion: v.tacticsParams?.deviceProportion, + id: v.id, })) } data.sort((a, b) => { @@ -201,23 +204,79 @@ const Control = (props) => { return -1 } }) - setQueryData(data) + console.log(data) + querydata.current = data + setQueryData1(data) } }) } + }, [pepProjectId, exhibition.current]) + + useEffect(() => { const line = document.getElementById("line") const news = document.getElementById("news") if (line && news) { news.onscroll = () => { - // console.log(news.scrollTop) - // console.log(line.clientHeight) if ((line.clientHeight - 600) < news.scrollTop) { setQuery({ ...query, page: query.page + 1 }) + if (exhibition?.current?.dynamic?.length > 0) { + dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId, page: query.page + 1 })).then(res => { + console.log(res.payload.data) + let data = querydata.current + if (res.success) { + if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { + res.payload.data?.appear?.map(v => data.push({ + seed: 'discovery', + project: v.projectName, + sources: v.alarmInfo?.sourceName, + type: v.type, + time: v.time, + id: v.id, + })) + } + if (exhibition?.current?.dynamic?.find(v => v.key == 'confirm')) { + res.payload.data?.confirm?.map(v => data.push({ + seed: 'confirm', + project: v.projectName, + sources: v.alarmInfo?.source, + type: v.alarmInfo?.type, + time: v.confirmTime, + userName: v.userName, + id: v.id, + })) + } + if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) { + res.payload.data?.notice?.map(v => data.push({ + seed: 'notice', + time: v.time, + project: v.projectName, + userName: v.userName?.map(u => u.name), + alarmPushConfig: v.alarmPushConfig?.name, + tactics: v.tactics, + interval: v.tacticsParams?.interval, + deviceProportion: v.tacticsParams?.deviceProportion, + id: v.id, + })) + } + data.sort((a, b) => { + if (moment(a.time).isBefore(b.time)) { + return 1 + } else { + return -1 + } + }) + console.log(data) + querydata.current = data + setQueryData1(data) + } + }) + } } } } - }, [pepProjectId, query, exhibition.current]) + + }, [query]) useEffect(() => { @@ -312,7 +371,9 @@ const Control = (props) => { if (res.success) setToolShow(res.payload.data) }) } - function startmarquee (speed, delay, name) { + + //轮播 + function startmarquee (name) { /* 函数startmarquee的参数: lh:文字一次向上滚动的距离或高度; @@ -320,22 +381,22 @@ const Control = (props) => { delay:滚动停顿的时间间隔; index:可以使封装后的函数应用于页面当中不同的元素; */ - var t; - var p = false; + let t; + let p = false let top = 0 - var o = document.getElementById(name); + let o = document.getElementById(name); if (o) { - o.onmouseover = () => p = true - o.onmouseout = () => p = false - o.scrollTop = 0; - const start = () => { + + function start () { t = setInterval(() => { - if (!p) (top += 10, o.scrollTop = top) - if (p) (clearInterval(t), setTimeout(start, delay)) - if (o.scrollTop >= o.scrollHeight / 2) (top = 0, o.scrollTop = 0) - }, speed); + top += 5 + o.scrollTop = top + if (o.scrollTop >= o.scrollHeight / 2) top = 0, o.scrollTop = top + }, 500); + o.onmouseover = () => clearInterval(t) } - setTimeout(start, 1000); + o.onmouseout = () => start() + setTimeout(start(), 1000); } } @@ -384,7 +445,7 @@ const Control = (props) => { { name: '确认:完结状态的信息动态', sort: 4, key: 'confirm', }, { name: '我的工作台', sort: 1, key: 'workbench', }, - { name: '项目概览', sort: 2, key: 'statistical', }, + { name: '统计概览', sort: 2, key: 'statistical', }, { name: 'BI分析模块', sort: 3, key: 'analyse', }, { name: '最新动态', sort: 4, key: 'dynamic', }, { name: '我常用的工具', sort: 5, key: 'tool', }, @@ -429,6 +490,7 @@ const Control = (props) => { setSetup(true) setTableType('overall') attribute('overall') + setSetData(5) }} /> @@ -450,6 +512,7 @@ const Control = (props) => { setSetup(true) setTableType('workbench') attribute('workbench') + setSetData(4) }} /> @@ -496,7 +559,7 @@ const Control = (props) => { {item.name == '关注的项目' ? ' ( 个 )' : ' ( 条 )'}
-
dispatch(push(item.url))} style={{ fontSize: 32, color: index == 0 ? '#0F7EFB' : index == 1 ? '#0091A1' : index == 2 ? '#FE9812' : '#FF7575', fontFamily: 'YouSheBiaoTiHei' }}>{item.data}
+
dispatch(push(item.url))} style={{ fontSize: 32, color: index == 0 ? '#0F7EFB' : index == 1 ? '#0091A1' : index == 2 ? '#FE9812' : '#FF7575', fontFamily: 'YouSheBiaoTiHei', cursor: 'pointer', }}>{item.data}
{item.name == '关注的项目' ? '' :
待处理
}
@@ -521,6 +584,7 @@ const Control = (props) => { setSetup(true) setTableType('statistical') attribute('statistical') + setSetData(5) }} /> @@ -532,7 +596,7 @@ const Control = (props) => { {pomsList?.map((v, index) => { return
setProjectId(v.pepProjectId)}>{v.pepProjectName}
@@ -745,6 +809,7 @@ const Control = (props) => { setSetup(true) setTableType('analyse') attribute('analyse') + setSetData(10) }} /> @@ -795,7 +860,7 @@ const Control = (props) => { }, grid: { show: false, - left: '5%', + left: '10%', // right: '4%', // bottom: '3%', // containLabel: true @@ -937,13 +1002,14 @@ const Control = (props) => { setTableType('dynamic') attribute('dynamic') setLong('long') + setSetData(4) }} />
- {querydata?.map((v, index) => { + {querydata.current?.map((v, index) => { let title = '' if (v.seed == 'discovery') { title = v.project + v.sources + ',诊断为' + v.type @@ -1022,7 +1088,7 @@ const Control = (props) => { onClick={() => { setTool(true) setAlter(true) - setCompile({ id: v.id, name: v.name, link: v.link, }) + setCompile({ linkId: v.id, name: v.name, link: v.link, }) }} >编辑
{ tableType={tableType} tableList={tableSetup} layout={long} + data={setData} close={() => { setSetup(false); attribute(tableType); @@ -1089,7 +1156,7 @@ const Control = (props) => { onOk={() => { FormApi.current.validate().then((v) => { console.log(v); - dispatch(control.putConsoleToollink({ id: compile?.id, name: v.name, link: v.link })).then(res => { + dispatch(control.putConsoleToollink({ linkId: compile?.linkId, name: v.name, link: v.link })).then(res => { if (res.success) { setTool(false) setAlter(false)