Browse Source

轮播修改

dev
wenlele 2 years ago
parent
commit
a394818619
  1. 6
      api/.vscode/launch.json
  2. 11
      api/app/lib/controllers/control/toolLink.js
  3. 4
      api/app/lib/service/kafka.js
  4. 7
      web/client/src/components/setup.jsx
  5. 165
      web/client/src/sections/control/containers/control.jsx

6
api/.vscode/launch.json

@ -16,9 +16,9 @@
"-p 4600", "-p 4600",
"-f http://localhost: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", "-k 10.8.30.72:29092,10.8.30.73:29092,10.8.30.74:29092",
"--iotaProxy http://10.8.30.157:17007", "--iotaProxy http://10.8.30.157:17007",
"--redisHost 10.8.30.112", "--redisHost 10.8.30.112",
@ -56,7 +56,7 @@
// "--clickHouseDataAlarm default", // "--clickHouseDataAlarm default",
// //
"--clickHouseAnxincloud Anxinyun23", "--clickHouseAnxincloud pg_anxinyun",
"--clickHousePepEmis pepca8", "--clickHousePepEmis pepca8",
"--clickHouseProjectManage peppm8", "--clickHouseProjectManage peppm8",
"--clickHouseVcmp video_access_dev", "--clickHouseVcmp video_access_dev",

11
api/app/lib/controllers/control/toolLink.js

@ -46,16 +46,7 @@ async function edit (ctx) {
if (linkId) { if (linkId) {
findOption.where.id = { $ne: linkId } findOption.where.id = { $ne: linkId }
} }
const existRes = await models.QuickLink.findOne({ const existRes = await models.QuickLink.findOne(findOption)
where: {
userId: userId,
$or: [{
name,
}, {
link,
}]
}
})
if (existRes) { if (existRes) {
throw '已有相同名称/地址的工具' throw '已有相同名称/地址的工具'
} }

4
api/app/lib/service/kafka.js

@ -104,14 +104,14 @@ module.exports = async function factory(app, opts) {
const { clickHouse, utils: { sendAppearToWeb, sendConfirmToWeb } } = app.fs const { clickHouse, utils: { sendAppearToWeb, sendConfirmToWeb } } = app.fs
try { try {
let { messageMode, structureId, sourceName, alarmTypeCode, alarmCode, content, time } = msg; let { messageMode, structureId, sourceName, alarmTypeCode, alarmCode, content, time } = msg;
let structsAche = await getStructsAche(); let structsAche = await getStructsAche()
if (structsAche) { if (structsAche) {
let structs = structsAche.dataList;//结构物列表 let structs = structsAche.dataList;//结构物列表
const { models } = app.fs.dc const { models } = app.fs.dc
let exist = structs.find(s => s.strucId == structureId); let exist = structs.find(s => s.strucId == structureId);
if (exist) { if (exist) {
let alarm_group = await clickHouse.anxinyun.query( 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;//告警类型 异常类型 let type = null, alarmGroup = null;//告警类型 异常类型
if (alarm_group) { if (alarm_group) {

7
web/client/src/components/setup.jsx

@ -11,6 +11,7 @@ function Setup (props) {
tableType, tableType,
tableList, tableList,
layout, // layout, //
data=8
} = props; } = props;
const [check, setCheck] = useState([]); const [check, setCheck] = useState([]);
@ -24,7 +25,7 @@ function Setup (props) {
ischeck(); ischeck();
}, []); }, []);
function ischeck (value) { function ischeck (value) {
if (check.length >= 8) { if (check.length >= data) {
if (check.includes(value)) { if (check.includes(value)) {
return false; return false;
} else { } else {
@ -48,12 +49,12 @@ function Setup (props) {
textAlign: "center", textAlign: "center",
marginLeft: 6, marginLeft: 6,
background: background:
check.length == 8 check.length == data
? "rgba(40, 123, 255, 1)" ? "rgba(40, 123, 255, 1)"
: "rgba(176, 176, 176, 1)", : "rgba(176, 176, 176, 1)",
}} }}
> >
{check.length}/8 {check.length}/{data}
</span> </span>
</div> </div>
} }

165
web/client/src/sections/control/containers/control.jsx

@ -45,29 +45,27 @@ const Control = (props) => {
const [appBI, setAppBI] = useState([]); //BI- const [appBI, setAppBI] = useState([]); //BI-
const [efficiencyBI, setEfficiencyBI] = useState({}); //BI- const [efficiencyBI, setEfficiencyBI] = useState({}); //BI-
const [query, setQuery] = useState({ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' }); // 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 [long, setLong] = useState(''); //
const [pomsList, setPomsList] = useState([]); // const [pomsList, setPomsList] = useState([]); //
const [projectId, setProjectId] = useState(''); //id const [projectId, setProjectId] = useState(''); //id
const [ask, setASk] = useState(true); //
const [setData, setSetData] = useState(); //
const exhibition = useRef({ workbench: [], statistical: [] }) // const exhibition = useRef({ workbench: [], statistical: [] }) //
const FormApi = useRef() const FormApi = useRef()
const querydata = useRef([])//
// const query={ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' } // // const query={ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' } //
// websocket 使 // websocket 使
useEffect(() => { useEffect(() => {
if (socket) { if (socket) {
socket.on('alarmSendSocket', function (msg) { socket.on('alarmSendSocket', function (msg) {
console.info(msg); // console.info(msg);
if (msg.type == "alarmAppear") {//
} else if (msg.type == "alarmConfirm") {// // console.info(msg);
console.log(msg);
} else if (msg.type == "alarmNotice") {//
}
//console.info(msg);
let a = msg; let a = msg;
}); });
return () => { return () => {
@ -87,13 +85,6 @@ const Control = (props) => {
: "" : ""
attribute(v) attribute(v)
}) })
}, [])
useEffect(() => {
if (pepProjectId) setProjectId('')
if (!pepProjectId) {
dispatch(install.getProjectPoms({ global: 1 })).then((res) => { // dispatch(install.getProjectPoms({ global: 1 })).then((res) => { //
if (res.success) { if (res.success) {
let data = res.payload.data?.rows?.filter(v => v.pepProjectIsDelete !== 1)?.map(v => ({ pepProjectId: v.id, pepProjectName: v.pepProjectName || v.name })) let data = res.payload.data?.rows?.filter(v => v.pepProjectIsDelete !== 1)?.map(v => ({ pepProjectId: v.id, pepProjectName: v.pepProjectName || v.name }))
@ -101,22 +92,28 @@ const Control = (props) => {
setProjectId(data[0]?.pepProjectId) setProjectId(data[0]?.pepProjectId)
} }
}) })
return () => {
} }
}, [])
useEffect(() => {
if (pepProjectId) setProjectId(pepProjectId)
if (!projectId) { if (!projectId) {
// 工作台数据请
dispatch(control.getConsoleCount({ pepProjectId: pepProjectId })).then(res => { dispatch(control.getConsoleCount({ pepProjectId: pepProjectId })).then(res => {
if (res.success) setWorkData(res.payload.data) if (res.success) setWorkData(res.payload.data)
}) })
// BI- 查询BI分析数据-
dispatch(control.getDataAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => { dispatch(control.getDataAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => {
if (res.success) setDataBI(res.payload.data) if (res.success) setDataBI(res.payload.data)
}) })
//BI- 查询BI分析数据-视频异
dispatch(control.getVideoAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => { dispatch(control.getVideoAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => {
if (res.success) setVideoBI(res.payload.data) if (res.success) setVideoBI(res.payload.data)
}) })
//BI- 查询BI分析数据-
dispatch(control.getAppAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => { dispatch(control.getAppAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => {
if (res.success) setAppBI(res.payload.data) if (res.success) setAppBI(res.payload.data)
}) })
@ -125,12 +122,13 @@ const Control = (props) => {
}) })
} }
// --& // --&
dispatch(control.getConsoleAbnormal({ pepProjectId: pepProjectId || projectId })).then(res => { dispatch(control.getConsoleAbnormal({ pepProjectId: pepProjectId || projectId })).then(res => {
if (res.success) { if (res.success) {
if (res.payload.data?.length > 4) { if (res.payload.data?.length > 4) {
setProblemsList([...res.payload.data, ...res.payload.data]) setProblemsList([...res.payload.data, ...res.payload.data])
startmarquee(500, 2000, 'problems') startmarquee('problems')
} else { } else {
setProblemsList(res.payload.data) setProblemsList(res.payload.data)
} }
@ -141,13 +139,13 @@ const Control = (props) => {
if (res.success) { if (res.success) {
if (res.payload.data?.personnel?.length > 5) { if (res.payload.data?.personnel?.length > 5) {
setMemberList([...res.payload.data?.personnel, ...res.payload.data?.personnel]) setMemberList([...res.payload.data?.personnel, ...res.payload.data?.personnel])
startmarquee(600, 2000, 'member') startmarquee('member')
} else { } else {
setMemberList(res.payload.data?.personnel) setMemberList(res.payload.data?.personnel)
} }
if (res.payload.data?.webApp?.length > 3) { if (res.payload.data?.webApp?.length > 3) {
setWebList([...res.payload.data?.webApp, ...res.payload.data?.webApp]) setWebList([...res.payload.data?.webApp, ...res.payload.data?.webApp])
startmarquee(600, 2000, 'web') startmarquee('web')
} else { } else {
setWebList(res.payload.data?.webApp) setWebList(res.payload.data?.webApp)
} }
@ -159,8 +157,11 @@ const Control = (props) => {
useEffect(() => { useEffect(() => {
// //
if (exhibition?.current?.dynamic?.length > 0) { if (exhibition?.current?.dynamic?.length > 0) {
console.log(query?.page);
dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId })).then(res => { 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 (res.success) {
if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) {
res.payload.data?.appear?.map(v => data.push({ res.payload.data?.appear?.map(v => data.push({
@ -169,6 +170,7 @@ const Control = (props) => {
sources: v.alarmInfo?.sourceName, sources: v.alarmInfo?.sourceName,
type: v.type, type: v.type,
time: v.time, time: v.time,
id: v.id,
})) }))
} }
if (exhibition?.current?.dynamic?.find(v => v.key == 'confirm')) { if (exhibition?.current?.dynamic?.find(v => v.key == 'confirm')) {
@ -179,7 +181,7 @@ const Control = (props) => {
type: v.alarmInfo?.type, type: v.alarmInfo?.type,
time: v.confirmTime, time: v.confirmTime,
userName: v.userName, userName: v.userName,
// confirmContent:v.confirmContent, id: v.id,
})) }))
} }
if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) { if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) {
@ -192,6 +194,7 @@ const Control = (props) => {
tactics: v.tactics, tactics: v.tactics,
interval: v.tacticsParams?.interval, interval: v.tacticsParams?.interval,
deviceProportion: v.tacticsParams?.deviceProportion, deviceProportion: v.tacticsParams?.deviceProportion,
id: v.id,
})) }))
} }
data.sort((a, b) => { data.sort((a, b) => {
@ -201,23 +204,79 @@ const Control = (props) => {
return -1 return -1
} }
}) })
setQueryData(data) console.log(data)
querydata.current = data
setQueryData1(data)
} }
}) })
} }
}, [pepProjectId, exhibition.current])
useEffect(() => {
const line = document.getElementById("line") const line = document.getElementById("line")
const news = document.getElementById("news") const news = document.getElementById("news")
if (line && news) { if (line && news) {
news.onscroll = () => { news.onscroll = () => {
// console.log(news.scrollTop)
// console.log(line.clientHeight)
if ((line.clientHeight - 600) < news.scrollTop) { if ((line.clientHeight - 600) < news.scrollTop) {
setQuery({ ...query, page: query.page + 1 }) 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,
}))
} }
}, [pepProjectId, query, exhibition.current]) data.sort((a, b) => {
if (moment(a.time).isBefore(b.time)) {
return 1
} else {
return -1
}
})
console.log(data)
querydata.current = data
setQueryData1(data)
}
})
}
}
}
}
}, [query])
useEffect(() => { useEffect(() => {
@ -312,7 +371,9 @@ const Control = (props) => {
if (res.success) setToolShow(res.payload.data) if (res.success) setToolShow(res.payload.data)
}) })
} }
function startmarquee (speed, delay, name) {
//
function startmarquee (name) {
/* /*
函数startmarquee的参数 函数startmarquee的参数
lh文字一次向上滚动的距离或高度 lh文字一次向上滚动的距离或高度
@ -320,22 +381,22 @@ const Control = (props) => {
delay滚动停顿的时间间隔 delay滚动停顿的时间间隔
index可以使封装后的函数应用于页面当中不同的元素 index可以使封装后的函数应用于页面当中不同的元素
*/ */
var t; let t;
var p = false; let p = false
let top = 0 let top = 0
var o = document.getElementById(name); let o = document.getElementById(name);
if (o) { if (o) {
o.onmouseover = () => p = true
o.onmouseout = () => p = false function start () {
o.scrollTop = 0;
const start = () => {
t = setInterval(() => { t = setInterval(() => {
if (!p) (top += 10, o.scrollTop = top) top += 5
if (p) (clearInterval(t), setTimeout(start, delay)) o.scrollTop = top
if (o.scrollTop >= o.scrollHeight / 2) (top = 0, o.scrollTop = 0) if (o.scrollTop >= o.scrollHeight / 2) top = 0, o.scrollTop = top
}, speed); }, 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: 4, key: 'confirm', },
{ name: '我的工作台', sort: 1, key: 'workbench', }, { name: '我的工作台', sort: 1, key: 'workbench', },
{ name: '项目概览', sort: 2, key: 'statistical', }, { name: '统计概览', sort: 2, key: 'statistical', },
{ name: 'BI分析模块', sort: 3, key: 'analyse', }, { name: 'BI分析模块', sort: 3, key: 'analyse', },
{ name: '最新动态', sort: 4, key: 'dynamic', }, { name: '最新动态', sort: 4, key: 'dynamic', },
{ name: '我常用的工具', sort: 5, key: 'tool', }, { name: '我常用的工具', sort: 5, key: 'tool', },
@ -429,6 +490,7 @@ const Control = (props) => {
setSetup(true) setSetup(true)
setTableType('overall') setTableType('overall')
attribute('overall') attribute('overall')
setSetData(5)
}} /> }} />
</div> </div>
</div> </div>
@ -450,6 +512,7 @@ const Control = (props) => {
setSetup(true) setSetup(true)
setTableType('workbench') setTableType('workbench')
attribute('workbench') attribute('workbench')
setSetData(4)
}} /> }} />
</div> </div>
</div> </div>
@ -496,7 +559,7 @@ const Control = (props) => {
<span style={{ fontSize: 12, color: '#4A4A4A' }}>{item.name == '关注的项目' ? ' ( 个 )' : ' ( 条 )'}</span> <span style={{ fontSize: 12, color: '#4A4A4A' }}>{item.name == '关注的项目' ? ' ( 个 )' : ' ( 条 )'}</span>
</div> </div>
<div style={{ marginTop: 15, display: 'flex', alignItems: 'center' }}> <div style={{ marginTop: 15, display: 'flex', alignItems: 'center' }}>
<div onClick={() => dispatch(push(item.url))} style={{ fontSize: 32, color: index == 0 ? '#0F7EFB' : index == 1 ? '#0091A1' : index == 2 ? '#FE9812' : '#FF7575', fontFamily: 'YouSheBiaoTiHei' }}>{item.data}</div> <div onClick={() => dispatch(push(item.url))} style={{ fontSize: 32, color: index == 0 ? '#0F7EFB' : index == 1 ? '#0091A1' : index == 2 ? '#FE9812' : '#FF7575', fontFamily: 'YouSheBiaoTiHei', cursor: 'pointer', }}>{item.data}</div>
{item.name == '关注的项目' ? '' : <div style={{ fontSize: 12, color: '#969799', marginLeft: 4 }}>待处理</div>} {item.name == '关注的项目' ? '' : <div style={{ fontSize: 12, color: '#969799', marginLeft: 4 }}>待处理</div>}
</div> </div>
</div> </div>
@ -521,6 +584,7 @@ const Control = (props) => {
setSetup(true) setSetup(true)
setTableType('statistical') setTableType('statistical')
attribute('statistical') attribute('statistical')
setSetData(5)
}} /> }} />
</div> </div>
</div> </div>
@ -532,7 +596,7 @@ const Control = (props) => {
{pomsList?.map((v, index) => { {pomsList?.map((v, index) => {
return <div key={'pomsList' + index} title={v.pepProjectName} return <div key={'pomsList' + index} title={v.pepProjectName}
style={{ style={{
width: 400, lineHeight: '30px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', fontSize: 14, color: '#969799', width: 400, cursor: 'pointer', lineHeight: '30px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', fontSize: 14, color: '#969799',
background: projectId == v.pepProjectId ? 'linear-gradient(252deg, #F9FBFF 0%, rgb(185 202 236) 100%)' : "", background: projectId == v.pepProjectId ? 'linear-gradient(252deg, #F9FBFF 0%, rgb(185 202 236) 100%)' : "",
}} }}
onClick={() => setProjectId(v.pepProjectId)}>{v.pepProjectName}</div> onClick={() => setProjectId(v.pepProjectId)}>{v.pepProjectName}</div>
@ -745,6 +809,7 @@ const Control = (props) => {
setSetup(true) setSetup(true)
setTableType('analyse') setTableType('analyse')
attribute('analyse') attribute('analyse')
setSetData(10)
}} /> }} />
</div> </div>
</div> </div>
@ -795,7 +860,7 @@ const Control = (props) => {
}, },
grid: { grid: {
show: false, show: false,
left: '5%', left: '10%',
// right: '4%', // right: '4%',
// bottom: '3%', // bottom: '3%',
// containLabel: true // containLabel: true
@ -937,13 +1002,14 @@ const Control = (props) => {
setTableType('dynamic') setTableType('dynamic')
attribute('dynamic') attribute('dynamic')
setLong('long') setLong('long')
setSetData(4)
}} /> }} />
</div> </div>
</div> </div>
<div id='news' style={{ height: 578, position: 'relative', marginTop: 10, }}> <div id='news' style={{ height: 578, position: 'relative', marginTop: 10, }}>
<div id='line' style={{ width: '100%' }}> <div id='line' style={{ width: '100%' }}>
<Timeline mode="center" style={{ marginLeft: '-56px', width: 400 }}> <Timeline mode="center" style={{ marginLeft: '-56px', width: 400 }}>
{querydata?.map((v, index) => { {querydata.current?.map((v, index) => {
let title = '' let title = ''
if (v.seed == 'discovery') { if (v.seed == 'discovery') {
title = v.project + v.sources + ',诊断为' + v.type title = v.project + v.sources + ',诊断为' + v.type
@ -1022,7 +1088,7 @@ const Control = (props) => {
onClick={() => { onClick={() => {
setTool(true) setTool(true)
setAlter(true) setAlter(true)
setCompile({ id: v.id, name: v.name, link: v.link, }) setCompile({ linkId: v.id, name: v.name, link: v.link, })
}} }}
>编辑</div> >编辑</div>
<div style={{ lineHeight: '30px' }} <div style={{ lineHeight: '30px' }}
@ -1065,6 +1131,7 @@ const Control = (props) => {
tableType={tableType} tableType={tableType}
tableList={tableSetup} tableList={tableSetup}
layout={long} layout={long}
data={setData}
close={() => { close={() => {
setSetup(false); setSetup(false);
attribute(tableType); attribute(tableType);
@ -1089,7 +1156,7 @@ const Control = (props) => {
onOk={() => { onOk={() => {
FormApi.current.validate().then((v) => { FormApi.current.validate().then((v) => {
console.log(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) { if (res.success) {
setTool(false) setTool(false)
setAlter(false) setAlter(false)

Loading…
Cancel
Save