Browse Source

解决冲突

dev
wenlele 2 years ago
parent
commit
7bd3cbf77a
  1. 2
      api/app/lib/controllers/alarm/data.js
  2. 36
      api/app/lib/controllers/alarm/video.js
  3. 3
      api/app/lib/routes/alarm/index.js
  4. 14
      web/client/src/sections/install/components/memberModal.jsx
  5. 8
      web/client/src/sections/install/containers/system.jsx
  6. 11
      web/client/src/sections/problem/actions/problem.jsx
  7. 77
      web/client/src/sections/problem/components/tableData.jsx
  8. 7
      web/client/src/sections/problem/containers/dataAlarm.jsx
  9. 1
      web/client/src/utils/webapi.js

2
api/app/lib/controllers/alarm/data.js

@ -253,7 +253,7 @@ async function exportDataAlarms(ctx, alarmList, groupId) {
}) })
let exportData = [] let exportData = []
for (let item of alarmList.slice(0, 1000000)) {//最多百万条 for (let item of alarmList) {
let projectNames = item.pomsProject.map(p => { let projectNames = item.pomsProject.map(p => {
return p.name || p.pepProject.projectName return p.name || p.pepProject.projectName
}) })

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

@ -38,6 +38,39 @@ async function deviceType (ctx) {
} }
} }
async function exceptionType(ctx) {
try {
const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs
const { database: anxinyun } = clickHouse.anxinyun.opts.config
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs
let anxinStruc = await anxinStrucIdRange({
ctx,
})
const anxinStrucIds = anxinStruc.map(a => a.strucId)
const statusRes = await clickHouse.vcmp.query(`
SELECT DISTINCT
camera_status.id AS statusId,camera_status.describe AS describe
FROM camera_status
INNER JOIN camera_status_alarm
ON camera_status.id = camera_status_alarm.status_id
INNER JOIN ${anxinyun}.t_video_ipc
ON toString(${anxinyun}.t_video_ipc.channel_no) = camera_status_alarm.channel_no
AND ${anxinyun}.t_video_ipc.serial_no = camera_status_alarm.serial_no
${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')})`}
`).toPromise()
ctx.status = 200;
ctx.body = statusRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function alarmList (ctx) { async function alarmList (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
@ -461,5 +494,6 @@ module.exports = {
alarmList, alarmList,
confirm, confirm,
alarmAdded, alarmAdded,
vcmpAppAuthToken vcmpAppAuthToken,
exceptionType
}; };

3
api/app/lib/routes/alarm/index.js

@ -60,4 +60,7 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/vcmp/auth'] = { content: '获取视频平台应用鉴权token', visible: true }; app.fs.api.logAttr['GET/vcmp/auth'] = { content: '获取视频平台应用鉴权token', visible: true };
router.get('/vcmp/auth', videoAlarm.vcmpAppAuthToken); router.get('/vcmp/auth', videoAlarm.vcmpAppAuthToken);
app.fs.api.logAttr['GET/alarm/video/exceptionType'] = { content: '查询视频异常类型', visible: true };
router.get('/alarm/video/exceptionType', videoAlarm.exceptionType);
}; };

14
web/client/src/sections/install/components/memberModal.jsx

@ -1,6 +1,6 @@
import React, { useState, useRef, useEffect } from "react"; import React, { useState, useRef, useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Modal, Form, CheckboxGroup, Checkbox,Button } from "@douyinfe/semi-ui"; import { Modal, Form, CheckboxGroup, Checkbox, Button } from "@douyinfe/semi-ui";
import { IconAlertCircle } from '@douyinfe/semi-icons'; import { IconAlertCircle } from '@douyinfe/semi-icons';
@ -55,7 +55,7 @@ function memberModal (props) {
setDepartmentId(editObj.departments[0].id) setDepartmentId(editObj.departments[0].id)
setPeopleList(departmentList) setPeopleList(departmentList)
} }
setPomsList_(pomsList.filter(p=>p.pepProjectIsDelete != -1)) setPomsList_(pomsList.filter(p => p.pepProjectIsDelete != -1))
}, []); }, []);
function handleOk () { function handleOk () {
@ -214,11 +214,15 @@ function memberModal (props) {
style={{ width: 417 }} style={{ width: 417 }}
filter filter
showClear showClear
// autoAdjustOverflow={false}
outerBottomSlot={ outerBottomSlot={
<p style={{ margin:"6px 26px",}}> <p style={{ margin: "6px 26px", }}>
<Button theme='borderless' onClick={()=>{ <Button theme='borderless' onClick={() => {
form.current.setValue('correlationProject',pomsList_.map(p=> p.id)) form.current.setValue('correlationProject', pomsList_.map(p => p.id))
}}>全选</Button> }}>全选</Button>
<Button theme='borderless' onClick={() => {
form.current.setValue('correlationProject', [])
}}>取消选择</Button>
</p> </p>
} }
> >

8
web/client/src/sections/install/containers/system.jsx

@ -236,9 +236,9 @@ const Example = (props) => {
{ {
title: '关联时间', title: '关联时间',
dataIndex: "createTime", dataIndex: "createTime",
key: 'createTime', key: 'time',
render: (_, row) => { render: (_, row) => {
return moment(row.createTime).format("YYYY-MM-DD HH:mm:ss") return moment(row.createTime).format("YYYY-MM-DD HH:mm:ss") || '无';
} }
}, },
{ {
@ -246,7 +246,7 @@ const Example = (props) => {
dataIndex: "updateTime", dataIndex: "updateTime",
key: 'updateTime', key: 'updateTime',
render: (_, row) => { render: (_, row) => {
return moment(row.updateTime).format("YYYY-MM-DD HH:mm:ss") return (row.updateTime ? moment(row.updateTime).format("YYYY-MM-DD HH:mm:ss") : moment(row.createTime).format("YYYY-MM-DD HH:mm:ss"));
} }
}, },
{ {
@ -254,7 +254,7 @@ const Example = (props) => {
dataIndex: "pepUserName", dataIndex: "pepUserName",
key: 'pepUserName', key: 'pepUserName',
render: (_, row) => { render: (_, row) => {
return row.pepUserName return row.pepUserName || '无'
} }
}, },
{ {

11
web/client/src/sections/problem/actions/problem.jsx

@ -149,6 +149,17 @@ export function getAlarmVideoDeviceKind () { //查询视频设备类型
}); });
} }
export function getAlarmVideoExceptionType () { //
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
actionType: 'GET_ALARM_VIDEO_EXCEPTION_TYPE',
url: `${ApiTable.getAlarmVideoExceptionType}`,
msg: { option: '查询视频异常类型' },
reducer: { name: '' }
});
}
export function putAlarmVideoConfirm (data) { // export function putAlarmVideoConfirm (data) { //
return dispatch => basicAction({ return dispatch => basicAction({
type: 'put', type: 'put',

77
web/client/src/sections/problem/components/tableData.jsx

@ -1,6 +1,6 @@
import React, { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Button, Form, Modal, Skeleton, Pagination, Table } from "@douyinfe/semi-ui"; import { Button, Form, Modal, Skeleton, Pagination, Table, Tooltip, Toast } from "@douyinfe/semi-ui";
import { SkeletonScreen, } from "$components"; import { SkeletonScreen, } from "$components";
import moment from "moment"; import moment from "moment";
import { validate } from "schema-utils"; import { validate } from "schema-utils";
@ -10,14 +10,14 @@ import qs from "qs";
const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId, const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId,
selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user }) => { selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user, statusId, setStatusId }) => {
const { problem } = actions const { problem } = actions
const [count, setCount] = useState(0) // const [count, setCount] = useState(0) //
const [checkAll, setCheckAll] = useState(true) // const [checkAll, setCheckAll] = useState(true) //
const api = useRef(); const api = useRef();
const search = useRef({ const search = useRef({
state: '', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', state: '', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', statusId: '',
errType: '', confirmState: '', onlineState: '', sustainTimeStart: '', sustainTimeEnd: '' errType: '', confirmState: '', onlineState: '', sustainTimeStart: '', sustainTimeEnd: ''
}) })
const kindName = useRef() const kindName = useRef()
@ -122,7 +122,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
useEffect(() => { useEffect(() => {
if (location) { if (location) {
search.current = { ...search.current, ...location, state: 'new' } search.current = { ...search.current, ...location, state: 'new' }
api.current?.setValues({...location, state: 'new'}) api.current?.setValues({ ...location, state: 'new' })
} }
if (route !== 'videoAbnormal' && route !== 'useAbnormal') { if (route !== 'videoAbnormal' && route !== 'useAbnormal') {
dispatch(problem.getAlarmDataGroup()).then((res) => { dispatch(problem.getAlarmDataGroup()).then((res) => {
@ -153,23 +153,68 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
setGenre(res.payload.data.map(v => ({ name: v.kind, value: v.id }))) setGenre(res.payload.data.map(v => ({ name: v.kind, value: v.id })))
} }
}) })
dispatch(problem.getAlarmVideoExceptionType()).then((res) => {
if (res.success) {
setStatusId(res.payload.data.map(v => ({ name: v.describe, value: v.statusId })))
}
})
} }
}, []) }, [])
const handleExport = () => { const handleExport = () => {
let url = '' let url = ''
let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', statusId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current
if (sustainTimeStart && sustainTimeEnd) {
let range = moment(sustainTimeEnd).diff(moment(sustainTimeStart), 'minutes')
if (range > 24 * 60 * 7) {
Toast.warning({
content: '导出自定义时间跨度不超过7天',
duration: 3,
})
return false;
}
} else {
sustainTimeStart = moment().add(-7, 'day').format("YYYY-MM-DD HH:mm:ss")
sustainTimeEnd = moment().format("YYYY-MM-DD HH:mm:ss")
}
switch (route) { switch (route) {
case 'useAbnormal': case 'useAbnormal':
dispatch(problem.getAlarmLnspectionApi({ ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, pepProjectId: pepProjectId })).then((res) => {
if (res.success) {
if (res.payload.data.count) {
url = `alarm/application/api?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keyword=${keyword}&errType=${errType} url = `alarm/application/api?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keyword=${keyword}&errType=${errType}
&state=${state}stainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}` &state=${state}stainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}`
setExportUrl(url);
} else {
Toast.info({
content: '暂无可导出的数据',
duration: 3,
})
}
}
})
break; break;
case 'videoAbnormal': case 'videoAbnormal':
dispatch(problem.getAlarmVideoList({ ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, pepProjectId: pepProjectId })).then((res) => {
if (res.success) {
if (res.payload.data.count) {
url = `alarm/video/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keywordTarget=${keywordTarget} url = `alarm/video/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keywordTarget=${keywordTarget}
&keyword=${keyword}&kindId=${kindId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd} &keyword=${keyword}&kindId=${kindId}&statusId=${statusId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}
&pepProjectId=${pepProjectId || ''}` &pepProjectId=${pepProjectId || ''}`
setExportUrl(url);
} else {
Toast.info({
content: '暂无可导出的数据',
duration: 3,
})
}
}
})
break; break;
default: default:
dispatch(problem.getAlarmDataList({ ...query, ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, groupId: groupId.current.map(v => v.id).join(), pepProjectId: pepProjectId })).then((res) => {
if (res.success) {
if (res.payload.data.count) {
let groups = { let groups = {
"dataLnterrupt": "1", "dataLnterrupt": "1",
"dataAbnormal": "2", "dataAbnormal": "2",
@ -179,9 +224,17 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
url = `alarm/data/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId} url = `alarm/data/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId}
&groupUnitId=${groupUnitId}&errType=${errType}&confirmState=${confirmState}&onlineState=${onlineState}&sustainTimeStart=${sustainTimeStart} &groupUnitId=${groupUnitId}&errType=${errType}&confirmState=${confirmState}&onlineState=${onlineState}&sustainTimeStart=${sustainTimeStart}
&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}&groupId=${groups[route]}` &sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}&groupId=${groups[route]}`
setExportUrl(url);
} else {
Toast.info({
content: '暂无可导出的数据',
duration: 3,
})
}
}
})
break; break;
} }
setExportUrl(url);
} }
return ( return (
@ -269,7 +322,8 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
marginBottom: 16 marginBottom: 16
}} }}
> >
<img title='导出' src="/assets/images/problem/export.png" style={{ width: 20 }} <Tooltip content={'默认导出最近7天的数据,自定义时间跨度不超过7天'}>
<img title='导出' src="/assets/images/problem/export.png" style={{ width: 20, cursor: 'pointer' }}
onClick={() => { onClick={() => {
api.current.validate().then((v) => { api.current.validate().then((v) => {
search.current = { search.current = {
@ -277,6 +331,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
keywordTarget: v.keywordTarget, keywordTarget: v.keywordTarget,
keyword: v.keyword, keyword: v.keyword,
kindId: v.kindId, kindId: v.kindId,
statusId: v.statusId,
groupUnitId: v.groupUnitId, groupUnitId: v.groupUnitId,
errType: v.errType, errType: v.errType,
confirmState: v.confirmState, confirmState: v.confirmState,
@ -287,7 +342,8 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
handleExport(); handleExport();
}); });
}} /> }} />
<img title='设置' src="/assets/images/problem/setup.png" style={{ width: 20 }} onClick={() => setSetup(true)} /> </Tooltip>
<img title='设置' src="/assets/images/problem/setup.png" style={{ width: 20, cursor: 'pointer' }} onClick={() => setSetup(true)} />
<Button <Button
theme="solid" theme="solid"
type="primary" type="primary"
@ -299,6 +355,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
keywordTarget: v.keywordTarget, keywordTarget: v.keywordTarget,
keyword: v.keyword, keyword: v.keyword,
kindId: v.kindId, kindId: v.kindId,
statusId: v.statusId,
groupUnitId: v.groupUnitId, groupUnitId: v.groupUnitId,
errType: v.errType, errType: v.errType,
confirmState: v.confirmState, confirmState: v.confirmState,
@ -415,7 +472,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
} }
function mapStateToProps (state) { function mapStateToProps(state) {
const { auth, global, members } = state; const { auth, global, members } = state;
// console.log(global); // console.log(global);
return { return {

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

@ -31,6 +31,7 @@ const DataAlarm = (props) => {
const [content, setContent] = useState(false); // const [content, setContent] = useState(false); //
const [selected, setSelected] = useState([]) // const [selected, setSelected] = useState([]) //
const [genre, setGenre] = useState([]) // const [genre, setGenre] = useState([]) //
const [statusId, setStatusId] = useState([]) //
const [checkPop, setCheckPop] = useState(false) // const [checkPop, setCheckPop] = useState(false) //
const [alarmId, setAlarmId] = useState(false) //alarmId const [alarmId, setAlarmId] = useState(false) //alarmId
const [query, setQuery] = useState({ limit: 10, page: 0 }) // const [query, setQuery] = useState({ limit: 10, page: 0 }) //
@ -112,6 +113,10 @@ const DataAlarm = (props) => {
name: '设备类型', field: 'kindId', name: '设备类型', field: 'kindId',
data: genre, data: genre,
}, },
{
name: '异常类型', field: 'statusId',
data: statusId,
},
{ {
name: '异常状态', field: 'state', name: '异常状态', field: 'state',
data: [ data: [
@ -424,11 +429,13 @@ const DataAlarm = (props) => {
selected={selected} selected={selected}
setSelected={setSelected} setSelected={setSelected}
setGenre={setGenre} setGenre={setGenre}
setStatusId={setStatusId}
query={query} query={query}
setQuery={setQuery} setQuery={setQuery}
tableData={tableData} tableData={tableData}
setTableData={setTableData} setTableData={setTableData}
genre={genre} genre={genre}
statusId={statusId}
location={props.location?.query} location={props.location?.query}
/> />
{setup ? ( {setup ? (

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

@ -47,6 +47,7 @@ export const ApiTable = {
getAlarmVideoDeviceKind: 'alarm/video/device_kind', //查询视频设备类型 getAlarmVideoDeviceKind: 'alarm/video/device_kind', //查询视频设备类型
putAlarmVideoConfirm: 'alarm/video/confirm', //确认视频告警信息 putAlarmVideoConfirm: 'alarm/video/confirm', //确认视频告警信息
getVcmpAuth: 'vcmp/auth', // 获取视频平台应用鉴权token getVcmpAuth: 'vcmp/auth', // 获取视频平台应用鉴权token
getAlarmVideoExceptionType: 'alarm/video/exceptionType', //查询视频设备类型
//服务-信鸽服务 //服务-信鸽服务
getPush: "push", //获取推送配置列表 getPush: "push", //获取推送配置列表

Loading…
Cancel
Save