Browse Source

工作台完成

dev
wenlele 2 years ago
parent
commit
6e35acd64c
  1. 91
      api/app/lib/controllers/control/toolLink.js
  2. 30
      web/client/src/sections/control/containers/control.jsx
  3. 10
      web/client/src/sections/problem/containers/dataAlarm.jsx

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

@ -138,61 +138,44 @@ async function count (ctx) {
const dataAlarm = await clickHouse.dataAlarm.query(`
SELECT
AlarmId,State,StartTime
AlarmId,State,StartTime,AlarmGroup
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
`).toPromise();
//数据告警总数
const alarm = await clickHouse.dataAlarm.query(`
SELECT
count(alarms.AlarmId) AS count
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
`).toPromise();
const confirmedAlarm = dataAlarm
// TODO: 开发临时注释
.filter(ar => ar.State && ar.State > 2)
.map(ar => "'" + ar.AlarmId + "'")
//剩余数据告警
const alarmSurplus = dataAlarm.filter(ar => ar.State && ar.State < 3).length || 0
const dataSurplus = dataAlarm.filter(ar => ar.State && ar.State < 3 && ar.AlarmGroup < 4).length || 0
//剩余设备告警
const toolSurplus = dataAlarm.filter(ar => ar.State && ar.State < 3 && ar.AlarmGroup > 3).length || 0
//今日新增数据告警
const alarmNewAdd = await clickHouse.dataAlarm.query(`
SELECT
count(alarms.StartTime) AS count
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
AND
alarms.StartTime >= '${moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')}'
AND
alarms.StartTime <= '${moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')}'
`).toPromise();
const dataNewAdd = dataAlarm.filter(r => moment(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')).isBefore(r.StartTime) && moment(r.createTime).isBefore(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')) && r.AlarmGroup < 4).length || 0
const toolNewAdd = dataAlarm.filter(r => moment(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')).isBefore(r.StartTime) && moment(r.createTime).isBefore(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')) && r.AlarmGroup > 3).length || 0
//今日确认数据告警
const alarmConfirme = confirmedAlarm.length ?
const dataConfirme = confirmedAlarm.length ?
await clickHouse.dataAlarm.query(`
SELECT
max(Time) AS Time, AlarmId , max(Content) AS Content
max(Time) AS Time, AlarmId , max(Content) AS Content,
alarms.AlarmGroup AS AlarmGroup
FROM
alarm_details
LEFT JOIN alarms
ON alarm_details.AlarmId=alarms.AlarmId
WHERE
AlarmId IN (${confirmedAlarm.join(',')})
AND
alarm_details.Time >= '${moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')}'
AND
alarm_details.Time <= '${moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')}'
GROUP BY AlarmId
GROUP BY AlarmId,AlarmGroup
`).toPromise() :
[];
@ -229,9 +212,6 @@ async function count (ctx) {
//今日确认应用告警
const appConfirme = listRes.rows.filter(r => moment(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')).isBefore(r.confirmTime) && moment(r.confirmTime).isBefore(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'))).length || 0
const alarmRes = anxinStrucIds.length ? await clickHouse.vcmp.query(
`
SELECT
@ -327,7 +307,6 @@ async function count (ctx) {
}
}
//剩余视频告警
const videoSurplus = returnD.filter(r => !r.confirmTime).length || 0
//今日新增视频告警
@ -335,28 +314,36 @@ async function count (ctx) {
//今日确认视频告警
const videoConfirme = returnD.filter(r => moment(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')).isBefore(r.confirmTime) && moment(r.confirmTime).isBefore(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'))).length || 0
let findOptions = {
where: {
del: false
},
attributes: []
}
if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) {
findOptions.where.id = { $in: userInfo.correlationProject }
}
const projects = await models.ProjectCorrelation.findAndCountAll(findOptions)
ctx.status = 200;
ctx.body = {
dataAlarm: {
alarm: dataAlarm.filter(r => r.State < 3).length || 0,
alarmSurplus: alarmSurplus,
alarmNewAdd: alarmNewAdd[0].count || 0,
alarmConfirme: alarmConfirme.length || 0,
},
videoAlarm: {
video: returnD.filter(r => !r.confirmTime).length || 0,
videoSurplus: videoSurplus,
videoNewAdd: videoNewAdd,
videoConfirme: videoConfirme,
},
appAlarm: {
app: listRes.rows.filter(r => !r.confirmTime).length || 0,
appSurplus: appSurplus,
appNewAdd: appNewAdd,
appConfirme: appConfirme,
}
dataSurplus: dataSurplus + videoSurplus,
dataNewAdd: dataNewAdd + videoNewAdd,
dataConfirme: appConfirme + dataConfirme.filter(r => r.AlarmGroup < 4).length,
toolSurplus: toolSurplus,
toolNewAdd: toolNewAdd,
toolConfirme: dataConfirme.filter(r => r.AlarmGroup > 3).length,
appSurplus: appSurplus,
appNewAdd: appNewAdd,
appConfirme: appConfirme,
projects: projects.count,
}
} else {
ctx.body = {

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

@ -18,7 +18,7 @@ let alarmScrollbar;
const Control = (props) => {
const { dispatch, actions, user, loading, socket } = props
const { dispatch, actions, user, loading, socket ,pepProjectId} = props
const { control } = actions
const stationList = [
'url(/assets/images/console/lan_1.png)',
@ -63,11 +63,10 @@ const Control = (props) => {
}, [])
useEffect(() => {
dispatch(control.geteteConsoleCount({})).then(res => {
console.log(res);
dispatch(control.geteteConsoleCount({pepProjectId:pepProjectId})).then(res => {
if (res.success) setWorkData(res.payload.data)
})
}, [])
}, [pepProjectId])
useEffect(() => {
newScrollbar = new PerfectScrollbar("#news", {
@ -145,13 +144,17 @@ const Control = (props) => {
}
let listAll = [
{ name: '关注的项目', sort: 1, key: 'project', data: 1, img: 'url(/assets/images/console/lan_1.png)' },
{ name: '数据告警', sort: 2, key: 'data', data: workData?.dataAlarm?.alarm || 0, img: 'url(/assets/images/console/lv_1.png)' },
{ name: '应用告警', sort: 2, key: 'app', data: workData?.appAlarm?.alarm || 0, img: 'url(/assets/images/console/hong_1.png)' },
{ name: '设备告警', sort: 2, key: 'device', data: workData?.dataAlarm?.alarm || 0, img: 'url(/assets/images/console/hong_1.png)' },
{ name: '关注的项目', sort: 1, key: 'project', data: workData?.projects, img: 'url(/assets/images/console/lan_1.png)' },
{ name: '数据告警', sort: 2, key: 'data', data: workData?.dataSurplus, img: 'url(/assets/images/console/lv_1.png)' },
{ name: '应用告警', sort: 2, key: 'app', data: workData?.appSurplus, img: 'url(/assets/images/console/hong_1.png)' },
{ name: '设备告警', sort: 2, key: 'device', data: workData?.toolSurplus, img: 'url(/assets/images/console/hong_1.png)' },
]
console.log(workData);
console.log(listAll);
useEffect(() => {
attribute('workbench')
}, [workData])
const attribute = (title) => {
let take = localStorage.getItem(title)
@ -214,7 +217,7 @@ const Control = (props) => {
剩余问题:
</div>
<div style={{ fontSize: 16, color: '#4A4A4A', width: 91 }}>
{(workData?.appAlarm?.appSurplus + workData?.dataAlarm?.alarmSurplus + workData?.videoAlarm?.videoSurplus) || 0}
{(workData?.appSurplus + workData?.dataSurplus + workData?.toolSurplus) || 0}
</div>
</div>
<div style={{ display: 'flex', alignItems: 'center', marginTop: 26 }}>
@ -223,7 +226,7 @@ const Control = (props) => {
</div>
<div style={{ fontSize: 16, color: '#4A4A4A', width: 91, display: 'flex' }}>
<div>
{(workData?.appAlarm?.appNewAdd + workData?.dataAlarm?.alarmNewAdd + workData?.videoAlarm?.videoNewAdd) || 0}
{(workData?.appNewAdd + workData?.dataNewAdd + workData?.toolNewAdd) || 0}
</div>
<div style={{ display: 'flex', alignItems: 'center', marginLeft: 4 }}>
<img title='设置' src="/assets/images/console/icon_up.png" style={{ width: 18, height: 18 }} />
@ -235,13 +238,13 @@ const Control = (props) => {
今日处理:
</div>
<div style={{ fontSize: 16, color: '#4A4A4A', width: 91 }}>
{(workData?.appAlarm?.appConfirme + workData?.dataAlarm?.alarmConfirme + workData?.videoAlarm?.videoConfirme) || 0}
{(workData?.appConfirme + workData?.dataConfirme + workData?.toolConfirme) || 0}
</div>
</div>
</div>
{/* 循环类型 */}
<div id='alarm' style={{ width: 'calc(100% - 200px)', position: 'relative', whiteSpace: 'nowrap', }}>
{exhibition['workbench'].map((item, index) => {
{exhibition['workbench']?.map((item, index) => {
return (
<div key={item.name} style={{ background: item.img, backgroundSize: "100% 100%", display: "inline-block", width: 270, height: 135, marginRight: 26 }}>
<div style={{ margin: '35px 0px 0px 134px' }}>
@ -639,6 +642,7 @@ function mapStateToProps (state) {
// loading: members.isRequesting,
user: auth.user,
actions: global.actions,
pepProjectId: global.pepProjectId,
// members: members.data,
// socket: webSocket.socket
};

10
web/client/src/sections/problem/containers/dataAlarm.jsx

@ -136,10 +136,10 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket, iotVcmpWeb
}],
deviceAbnormal: [ // (deviceAbnormal)
{ name: '搜索', field: '1' },
{
name: '设备类型', field: 'groupUnitId',
data: genre
},
// {
// name: '', field: 'groupUnitId',
// data: genre
// },
{
name: '异常状态', field: 'state',
data: [
@ -165,7 +165,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket, iotVcmpWeb
strategyHit: ['index', 'projectName', 'StructureName', 'SourceName', 'Strategy', 'State', 'createTime', 'sustainTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'],
videoAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'station', 'cameraKindId', 'sustainTime', 'venderName', 'point', 'cameraSerialNo', 'cameraChannelNo', 'platform', 'AlarmContent', 'resolve', 'createTime', 'updateTime', 'confirm', 'confirmTime',],
useAbnormal: ['index', 'projectName', 'appName', 'url', 'type', 'alarmContent', 'createTime', 'sustainTime', 'updateTime', 'confirm', 'confirmTime'],
deviceAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'station', 'type', 'cameraKindId', 'sustainTime', 'venderName', 'AlarmContent', 'AlarmCodeName', 'createTime', 'updateTime', 'confirm', 'confirmTime'],
deviceAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'station', 'sustainTime', 'venderName', 'AlarmContent', 'AlarmCodeName', 'createTime', 'updateTime', 'confirm', 'confirmTime'],
}
//
const columns = {

Loading…
Cancel
Save