Browse Source

工作台请求修改

dev
wenlele 2 years ago
parent
commit
bf0acb15c3
  1. 6
      api/app/lib/controllers/alarm/app.js
  2. 131
      api/app/lib/controllers/control/toolLink.js
  3. 28
      web/client/src/sections/control/containers/control.jsx

6
api/app/lib/controllers/alarm/app.js

@ -78,9 +78,9 @@ async function inspectionList(ctx) {
}
}]
}
// if (timeStart && timeEnd) {
// findOption.where.createTime = { $between: [moment(timeStart).format(), moment(timeEnd).format()] }
// }
if (timeStart && timeEnd) {
findOption.where.createTime = { $between: [moment(timeStart).format(), moment(timeEnd).format()] }
}
if (noted) {
if (noted == 'noted') {
findOption.where.notedTime = { $ne: null }

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

@ -127,48 +127,80 @@ async function count (ctx) {
const anxinStrucIds = anxinStruc.map(a => a.strucId) || []
//剩余数据,设备告警
const dataAlarm = await clickHouse.dataAlarm.query(`
SELECT
AlarmId,State,StartTime,AlarmGroup
AlarmGroup,COUNT(AlarmId) AS count
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
AND
State < 3
GROUP BY AlarmGroup
`).toPromise();
const confirmedAlarm = dataAlarm
// TODO: 开发临时注释
.filter(ar => ar.State && ar.State > 2)
.map(ar => "'" + ar.AlarmId + "'")
//剩余数据告警
const dataSurplus = dataAlarm.filter(ar => ar.State && ar.State < 3 && ar.AlarmGroup < 4).length || 0
let dataSurplus = 0
//剩余设备告警
const toolSurplus = dataAlarm.filter(ar => ar.State && ar.State < 3 && ar.AlarmGroup > 3).length || 0
let toolSurplus = 0
for (let p of dataAlarm) {
if (p.AlarmGroup < 4) {
dataSurplus = dataSurplus + p.count
}
if (p.AlarmGroup > 3) {
toolSurplus = toolSurplus + p.count
}
}
const dataAlarmToday = await clickHouse.dataAlarm.query(`
SELECT
AlarmGroup,COUNT(StartTime) AS count
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
AND
StartTime BETWEEN '${moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')}' AND '${moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')}'
AND
State < 3
GROUP BY AlarmGroup
`).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
let dataNewAdd = 0
//今日新增设备告警
let toolNewAdd = 0
for (let p of dataAlarmToday) {
if (p.AlarmGroup < 4) dataNewAdd = dataNewAdd + p.count
if (p.AlarmGroup > 3) toolNewAdd = toolNewAdd + p.count
}
//今日确认数据告警
const dataConfirme = confirmedAlarm.length ?
await clickHouse.dataAlarm.query(`
const dataConfirme = await clickHouse.dataAlarm.query(`
SELECT
max(Time) AS Time, AlarmId , max(Content) AS Content,
alarms.AlarmGroup AS AlarmGroup
AlarmGroup,COUNT(EndTime) AS count
FROM
alarm_details
LEFT JOIN alarms
ON alarm_details.AlarmId=alarms.AlarmId
alarms
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,AlarmGroup
`).toPromise() :
[];
alarms.StructureId IN (${anxinStrucIds.join(",")})
AND
EndTime BETWEEN '${moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')}' AND '${moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')}'
AND
State > 2
GROUP BY AlarmGroup
`).toPromise()
//今日确认数据告警
let dataConfirmeToday = 0
//今日确认设备告警
let toolConfirmeToday = 0
for (let p of dataConfirme) {
if (p.AlarmGroup < 4) dataConfirmeToday = dataConfirmeToday + p.count
if (p.AlarmGroup > 3) toolConfirmeToday = toolConfirmeToday + p.count
}
let findOption = {
@ -195,13 +227,20 @@ async function count (ctx) {
}
//应用总告警
const listRes = await models.AppAlarm.findAndCountAll(findOption)
let listRes = await models.AppAlarm.findAndCountAll(findOption)
//剩余应用告警
const appSurplus = listRes.rows.filter(r => !r.confirmTime).length || 0
let appSurplus = 0
//今日新增应用告警
const appNewAdd = listRes.rows.filter(r => moment(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')).isBefore(r.createTime) && moment(r.createTime).isBefore(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'))).length || 0
let appNewAdd = 0
//今日确认应用告警
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
let appConfirme = 0
for (let p of listRes.rows) {
if (!p.dataValues.confirmTime) appSurplus++
if (p.dataValues.createTime && moment(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')).isBefore(p.dataValues.createTime) && moment(p.dataValues.createTime).isBefore(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'))) appNewAdd++
if (p.dataValues.confirmTime && moment(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')).isBefore(p.dataValues.confirmTime) && moment(p.dataValues.confirmTime).isBefore(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'))) appConfirme++
}
const alarmRes = anxinStrucIds.length ? await clickHouse.vcmp.query(
`
@ -307,33 +346,59 @@ async function count (ctx) {
let findOptions = {
where: {
del: false
del: false,
},
attributes: []
attributes: ['pepProjectId']
}
if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) {
findOptions.where.id = { $in: userInfo.correlationProject }
}
const projects = await models.ProjectCorrelation.findAndCountAll(findOptions)
let pepProjectIds = new Set()
for (let p of projects.rows) {
if (p.pepProjectId) {
pepProjectIds.add(p.pepProjectId)
}
}
const pepProjectRes = pepProjectIds.size ?
await clickHouse.projectManage.query(
`
SELECT
t_pim_project.id AS id,
t_pim_project.isdelete AS isdelete
FROM t_pim_project
WHERE id IN (${[...pepProjectIds].join(',')}, -1)
`
).toPromise() :
[]
for (let p of projects.rows) {
const corPro = pepProjectRes.find(pp => pp.id == p.pepProjectId) || {}
p.dataValues.pepProjectIsDelete = corPro.isdelete
}
ctx.status = 200;
ctx.body = {
dataSurplus: dataSurplus + videoSurplus,
dataNewAdd: dataNewAdd + videoNewAdd,
dataConfirme: appConfirme + dataConfirme.filter(r => r.AlarmGroup < 4).length,
dataConfirme: videoConfirme + dataConfirmeToday,
toolSurplus: toolSurplus,
toolNewAdd: toolNewAdd,
toolConfirme: dataConfirme.filter(r => r.AlarmGroup > 3).length,
toolConfirme: toolConfirmeToday,
appSurplus: appSurplus,
appNewAdd: appNewAdd,
appConfirme: appConfirme,
projects: projects.count,
projects: projects.rows.filter(v => v.dataValues.pepProjectIsDelete !== 1).length,
}
} else {

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

@ -18,6 +18,9 @@ let webScrollbar;
let problemsScrollbar;
let alarmScrollbar;
let pomsListScrollbar
let problems
let member
let web
const Control = (props) => {
@ -138,7 +141,6 @@ const Control = (props) => {
if (res.success) {
if (res.payload.data?.length > 4) {
setProblemsList([...res.payload.data, ...res.payload.data])
let problems
let problemstop = 0
let problemsId = document.getElementById('problems');
if (problems) clearInterval(problems)
@ -164,7 +166,7 @@ const Control = (props) => {
if (res.success) {
if (res.payload.data?.personnel?.length > 5) {
setMemberList([...res.payload.data?.personnel, ...res.payload.data?.personnel])
let member
let membertop = 0
let memberId = document.getElementById('member');
if (member) clearInterval(member)
@ -185,7 +187,6 @@ const Control = (props) => {
}
if (res.payload.data?.webApp?.length > 3) {
setWebList([...res.payload.data?.webApp, ...res.payload.data?.webApp])
let web
let webtop = 0
let webId = document.getElementById('web');
if (web) clearInterval(web)
@ -1257,7 +1258,26 @@ const Control = (props) => {
labelPosition="left"
placeholder='请输入URL'
initValue={compile?.link || ''}
rules={[{ required: true, message: "请输入地址链接" }]}
rules={[{
required: true, message: "请输入正确地址链接", validator: (rule, value) => {
const strRegex = '^((https|http|ftp)://)?'//(https或http或ftp):// 可有可无
+ '(([\\w_!~*\'()\\.&=+$%-]+: )?[\\w_!~*\'()\\.&=+$%-]+@)?' //ftpuser@
+ '(([0-9]{1,3}\\.){3}[0-9]{1,3}' // IPURL- 3.3.3.3
+ '|' // IPDOMAIN
+ '(localhost)|' //localhost
+ '([\\w_!~*\'()-]+\\.)*' // - [_!~*\'()-].
+ '\\w+\\.' // - .
+ '[a-zA-Z]{1,6})' // - 1-6
+ '(:[0-9]{1,5})?' // - :80 ,1-5
+ '((/?)|' // url -
+ '(/[\\w_!~*\'()\\.;?:@&=+$,%#-]+)+/?)$';//- []
const re = new RegExp(strRegex, 'i'); //
if (re.test(encodeURI(value))) {
return true;
}
return false;
}
}]}
field='link'
/>
</Form>

Loading…
Cancel
Save