巴林闲侠 3 years ago
parent
commit
e4b92be1bd
  1. 90
      api/app/lib/controllers/alarm/video.js
  2. 2
      api/app/lib/schedule/alarms_handle_statistics.js
  3. 218
      web/client/src/components/setup.jsx
  4. 24
      web/client/src/sections/control/actions/control.js
  5. 914
      web/client/src/sections/control/containers/control.jsx
  6. 4
      web/client/src/utils/webapi.js

90
api/app/lib/controllers/alarm/video.js

@ -284,47 +284,75 @@ async function confirm(ctx) {
}
}
let structsAche = {
dataList: [],
expireTime: null//10分钟更新一次结构物列表
}
async function getStructsAche(ctx) {
const { utils: { getAxyStructs } } = ctx.app.fs
try {
if (!structsAche.dataList.length || moment() > moment(structsAche.expireTime)) {
let structList = await getAxyStructs();
structsAche.dataList = structList;
structsAche.expireTime = moment().add(10, 'minute').format('YYYY-MM-DD HH:mm:ss');
}
return structsAche;
} catch (err) {
console.log(`获取结构物列表失败, error: ${err}`);
}
}
async function alarmAdded(ctx) {
try {
const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs
const { utils: { anxinStrucIdRange, sendAppearToWeb } } = ctx.app.fs
let anxinStruc = await anxinStrucIdRange({ ctx })
const { utils: { sendAppearToWeb } } = ctx.app.fs
const { serial_no, channel_no, create_time, description, status_id } = ctx.request.body;
let structsAche = await getStructsAche(ctx);
if (structsAche) {
let anxinStruc = structsAche.dataList;//结构物列表
const { serial_no, channel_no, create_time, description, status_id } = ctx.request.body;
let belongToStruct = await clickHouse.anxinyun.query(
`SELECT name, structure FROM t_video_ipc WHERE serial_no='${serial_no}' and channel_no='${channel_no}'`).toPromise()
let structId = belongToStruct.length ? belongToStruct[0].structure : null
let belongToStruct = await clickHouse.anxinyun.query(
`SELECT name, structure FROM t_video_ipc WHERE serial_no='${serial_no}' and channel_no=${parseInt(channel_no)}`).toPromise()
let structId = belongToStruct.length ? belongToStruct[0].structure : null
if (structId) {
let exist = anxinStruc.find(s => s.strucId == structId);
let projects = exist.pomsProject.filter(d => !d.del).map(p => p.id);
let datas = projects.map(d => {//需要 项目,告警源,异常类型,时间
return {
projectCorrelationId: d,
alarmInfo: { messageMode: 'AlarmGeneration', sourceName: belongToStruct[0].name, status_id, content: description },//AlarmGeneration代表告警首次产生
time: create_time,
type: description
}
})
let rslt = await models.AlarmAppearRecord.bulkCreate(datas, { returning: true });
let dynamics = rslt.map(r => {
return {
time: r.time,
alarmAppearId: r.id,
projectCorrelationId: r.projectCorrelationId,
type: 1//发现
}
})
await models.LatestDynamicList.bulkCreate(dynamics);
if (structId) {
let exist = anxinStruc.find(s => s.strucId == structId);
if (exist) {
let projects = exist.pomsProject.filter(d => !d.del).map(p => p.id);
let datas = projects.map(d => {//需要 项目,告警源,异常类型,时间
return {
projectCorrelationId: d,
alarmInfo: { messageMode: 'AlarmGeneration', sourceName: belongToStruct[0].name, status_id, content: description },//AlarmGeneration代表告警首次产生
time: create_time,
type: description
}
})
let rslt = await models.AlarmAppearRecord.bulkCreate(datas, { returning: true });
let dynamics = rslt.map(r => {
return {
time: r.time,
alarmAppearId: r.id,
projectCorrelationId: r.projectCorrelationId,
type: 1//发现
}
})
await models.LatestDynamicList.bulkCreate(dynamics);
//消息推送到前端
if (datas.length) {
await sendAppearToWeb(datas, 'video');
//消息推送到前端
if (datas.length) {
await sendAppearToWeb(datas, 'video');
}
}
}
ctx.status = 200;
} else {
ctx.status = 400;
ctx.body = {
message: `获取结构物列表失败`
}
}
ctx.status = 200;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;

2
api/app/lib/schedule/alarms_handle_statistics.js

@ -7,7 +7,7 @@ module.exports = function (app, opts) {
const { database: anxinyun } = clickHouse.anxinyun.opts.config
const alarmHandleStatistics = app.fs.scheduleInit(
{
interval: '0 48 1 ? * MON',//0 48 1 ? * MON 每周一凌晨1点48开始执行
interval: '0 18 1 ? * 1',//每周一1点18触发
// immediate: true,
proRun: true,
},

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

@ -1,122 +1,124 @@
import React, { useState, useEffect } from "react";
import {
Modal,
CheckboxGroup,
Checkbox,
Modal,
CheckboxGroup,
Checkbox,
} from "@douyinfe/semi-ui";
function Setup(props) {
const {
close,
tableType,
tableList
} = props;
function Setup (props) {
const {
close,
tableType,
tableList,
layout, //
} = props;
const [check, setCheck] = useState([]);
const checkboxcss = { width: "25%", height: 16, margin: "0 0 20px 0" };
const [check, setCheck] = useState([]);
useEffect(() => {
//
const checkItem = localStorage.getItem(tableType);
setCheck(checkItem?JSON.parse(checkItem) : [])
ischeck();
}, []);
function ischeck(value) {
if (check.length >= 8) {
if (check.includes(value)) {
return false;
} else {
return true;
const checkboxcss = { width: "25%", height: 16, margin: "0 0 20px 0" };
useEffect(() => {
//
const checkItem = localStorage.getItem(tableType);
setCheck(checkItem ? JSON.parse(checkItem) : [])
ischeck();
}, []);
function ischeck (value) {
if (check.length >= 8) {
if (check.includes(value)) {
return false;
} else {
return true;
}
}
}
}
}
return (
<Modal
title={
<div>
表格属性设置
<span
style={{
width: 50,
lineHeight: "19px",
display: "inline-block",
return (
<Modal
title={
<div>
表格属性设置
<span
style={{
width: 50,
lineHeight: "19px",
display: "inline-block",
color: "white",
textAlign: "center",
marginLeft: 6,
background:
check.length == 8
? "rgba(40, 123, 255, 1)"
: "rgba(176, 176, 176, 1)",
}}
>
{check.length}/8
</span>
</div>
}
visible={true}
style={{ width: 600 }}
onOk={() => {
localStorage.setItem(tableType, JSON.stringify(check));
close();
}}
onCancel={() => {
close();
}}
>
<CheckboxGroup
style={{ width: "100%", fontSize: 14 }}
key="primary1"
direction="horizontal"
defaultValue={check}
aria-label="表格属性设置"
onChange={(check) => {
setCheck(check);
ischeck();
}}
color: "white",
textAlign: "center",
marginLeft: 6,
background:
check.length == 8
? "rgba(40, 123, 255, 1)"
: "rgba(176, 176, 176, 1)",
}}
>
{check.length}/8
</span>
</div>
}
visible={true}
style={{ width: 600 }}
onOk={() => {
localStorage.setItem(tableType, JSON.stringify(check));
close();
}}
onCancel={() => {
close();
}}
>
{tableList.map((item,index)=>{
return(
<div
key={index}
style={{
width: 550,
border: "1px solid #EAEAEA",
padding: "0px 5px",
borderRadius: 4,
marginBottom: "20px",
<CheckboxGroup
style={{ width: "100%", fontSize: 14 }}
key="primary1"
direction="horizontal"
defaultValue={check}
aria-label="表格属性设置"
onChange={(check) => {
setCheck(check);
ischeck();
}}
>
<div
style={{
borderBottom: "1px solid #EAEAEA",
marginLeft: "10px",
padding: "8px 0px",
}}
>
{item.title}
</div>
<div style={{ padding: "15px 12px", width: 530 }}>
{item.list?.map((itm) => {
return (
<Checkbox
key={itm.value}
value={itm.value}
style={checkboxcss}
disabled={ischeck(itm.value)}
>
{itm.name}
</Checkbox>
);
})}
</div>
</div>
)})}
</CheckboxGroup>
</Modal>
);
>
{tableList.map((item, index) => {
return (
<div
key={index}
style={{
width: 550,
border: "1px solid #EAEAEA",
padding: "0px 5px",
borderRadius: 4,
marginBottom: "20px",
}}
>
<div
style={{
borderBottom: "1px solid #EAEAEA",
marginLeft: "10px",
padding: "8px 0px",
}}
>
{item.title}
</div>
<div style={{ padding: "15px 12px", width: 530, display: layout == 'long' ? 'flex' : "", flexDirection: layout == 'long' ? 'column' : "" }}>
{item.list?.map((itm) => {
return (
<Checkbox
key={itm.value}
value={itm.value}
style={layout == 'long' ? {} : checkboxcss}
disabled={ischeck(itm.value) || ['workbench', 'dynamic', 'handle', 'DeviceAccess','discovery'].includes(itm.value)}
>
{itm.name}
</Checkbox>
);
})}
</div>
</div>
)
})}
</CheckboxGroup>
</Modal>
);
}
export default Setup;

24
web/client/src/sections/control/actions/control.js

@ -105,4 +105,28 @@ export function getAppAlarmsAggDay (query) { //查询BI分析数据-应用
msg: { option: '查询BI分析应用数据' },
reducer: { name: '' }
});
}
export function getAlarmsHandleStatistics (query) { //查询BI分析数据-问题处理效率分析
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
query,
actionType: 'GET_ALARMS_HANDLE_STATISTICS',
url: `${ApiTable.getAlarmsHandleStatistics}`,
msg: { option: '查询BI问题处理效率分析' },
reducer: { name: '' }
});
}
export function getLatestDynamic (query) { //查询最新动态
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
query,
actionType: 'GET_LATEST_DYNAMIC',
url: `${ApiTable.getLatestDynamic}`,
msg: { option: '查询最新动态' },
reducer: { name: '' }
});
}

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

File diff suppressed because it is too large

4
web/client/src/utils/webapi.js

@ -65,6 +65,10 @@ export const ApiTable = {
getDataAlarmsAggDay: 'data/alarms/agg/day', //查询BI分析数据-数据
getVideoAlarmsAggDay: 'video/alarms/agg/day', //查询BI分析数据-视频异常
getAppAlarmsAggDay: 'app/alarms/agg/day', //查询BI分析数据-应用
getAlarmsHandleStatistics: '/alarms/handle/statistics', //查询BI分析数据-问题处理效率分析
getLatestDynamic: '/latest/dynamic', // 查询最新动态
};
export const RouteTable = {
apiRoot: "/api/root",

Loading…
Cancel
Save