peng.peng 1 year ago
parent
commit
381afa5b98
  1. 22
      api/app/lib/controllers/superScreen/fire.js
  2. 1
      api/app/lib/middlewares/authenticator.js
  3. 3
      api/app/lib/routes/superScreen/fire.js
  4. 9
      api/config.js
  5. 23
      super-screen/client/src/sections/fire-control/actions/fire.js
  6. 4
      super-screen/client/src/sections/fire-control/components/Right-top2.js
  7. 8
      super-screen/client/src/sections/fire-control/containers/homePage.js
  8. 3
      super-screen/client/src/utils/webapi.js

22
api/app/lib/controllers/superScreen/fire.js

@ -229,7 +229,26 @@ function getFireTrend (opts) {
}
function getSurroundingConditions (opts) {
return async function (ctx) {
try {
const { app, yingshiTokenRes } = ctx
const { center } = ctx.query;
const res = await app.fs.baiDu.get('/traffic/v1/around', { ak: opts.baiduAK, radius: 1000, center: center })
ctx.status = 200
ctx.body = res.body || {}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: '获取南昌市道路数据失败'
}
}
}
}
module.exports = {
addAlarm,
@ -238,5 +257,6 @@ module.exports = {
getFireDevice,
getFireTrend,
videoList,
getDetails
getDetails,
getSurroundingConditions
}

1
api/app/lib/middlewares/authenticator.js

@ -63,6 +63,7 @@ let isPathExcluded = function (opts, path, method) {
excludeOpts.push({ p: '/water/emergency', o: 'GET' });
excludeOpts.push({ p: '/videoCenter/list', o: 'GET' });
excludeOpts.push({ p: '/trafficindex/city/details', o: 'GET' });
excludeOpts.push({ p: '/traffic/v1/around', o: 'GET' });
excludeOpts.push({ p: '/fire/alarm', o: 'GET' });
excludeOpts.push({ p: '/fire/alarm', o: 'POST' });
excludeOpts.push({ p: '/fire/alarm/:id', o: 'PUT' });

3
api/app/lib/routes/superScreen/fire.js

@ -22,6 +22,9 @@ module.exports = function (app, router, opts, AuthCode) {
app.fs.api.logAttr['GET/trafficindex/city/detailst'] = { content: '获取南昌市道路数据', visible: true };
router.get('/trafficindex/city/details', fire.getDetails(opts));
app.fs.api.logAttr['GET/traffic/v1/around'] = { content: '获取周边路况数据失败', visible: true };
router.get('/traffic/v1/around', fire.getSurroundingConditions(opts));
//获取消防设备
app.fs.api.logAttr['GET/fire/device'] = { content: '获取消防设备', visible: true };
router.get('/fire/device', fire.getFireDevice(opts));

9
api/config.js

@ -46,6 +46,9 @@ const YINGSHI_SECRET = process.env.YINGSHI_SECRET || flags.yingshiSecret;
// 萤石服务的地址
const YINGSHI_URL = process.env.YINGSHI_URL || flags.yingshiUrl || 'https://open.ys7.com/api';
const BAIDU_API = process.env.BAIDU_API || flags.baiDu || 'https://api.map.baidu.com';
const BAIDU_AK = process.env.BAIDU_AK || flags.baiDuAk || 'AeSOcqC282tdSUVOfYxe68nEcNF1CTj7';
if (!DB || !BACKUPS_URL || !KUBESPHERE_URL || !DATABASE_CONFIG || !WATER_URL || !WORKSAFETY_URL || !THIRD_FIRECONTROL || !AXY_API_URL || !AXY_PUMP_PROJECT) {
console.log('缺少启动参数,异常退出');
args.showHelp();
@ -73,6 +76,7 @@ const product = {
dev,
yingshiKey: YINGSHI_KEY,
yingshiSecret: YINGSHI_SECRET,
baiduAK: BAIDU_AK,
exclude: [
// "*"
], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由
@ -103,6 +107,11 @@ const product = {
name: 'yingshiRequest',
root: YINGSHI_URL,
params: {}
},
{
name: 'baiDu',
root: BAIDU_API,
params: {}
},],
}
}, {

23
super-screen/client/src/sections/fire-control/actions/fire.js

@ -3,7 +3,7 @@
import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils'
export function getFireAlarmList(query) {
export function getFireAlarmList (query) {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
@ -15,7 +15,7 @@ export function getFireAlarmList(query) {
});
}
export function addFireAlarm(params) {
export function addFireAlarm (params) {
return (dispatch) => basicAction({
type: 'post',
data: params,
@ -28,7 +28,7 @@ export function addFireAlarm(params) {
});
}
export function modifyFireAlarm(id, params) {
export function modifyFireAlarm (id, params) {
return (dispatch) => basicAction({
type: 'put',
data: params,
@ -42,7 +42,6 @@ export function modifyFireAlarm(id, params) {
}
export function getVideoCenterList () {
return dispatch => basicAction({
type: 'get',
@ -65,8 +64,20 @@ export function getDetails () {
});
}
export function getSurroundingConditions (query = {}) {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
query: query,
actionType: 'GET_SURROUNDING_CONDITION',
url: ApiTable.surroundingConditions,
msg: { error: '获取周边路况数据失败' },
// reducer: { name: 'videoCenterList' }
});
}
export function getFireDevice() {
export function getFireDevice () {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
@ -76,7 +87,7 @@ export function getFireDevice() {
});
}
export function getFireTrend() {
export function getFireTrend () {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,

4
super-screen/client/src/sections/fire-control/components/Right-top2.js

@ -21,9 +21,9 @@ const DataTop5 = ({ dispatch, actions, longitudeLatitude }) => {
}, [])
useEffect(() => {
dispatch(actions.firecontrol.getDetails()).then(res => {
dispatch(actions.firecontrol.getSurroundingConditions({ center: `${longitudeLatitude?.longitude},${longitudeLatitude?.latitude}` })).then(res => {
if (res.success) {
setTraffic(res.payload.data?.data?.detail || {});
// setTraffic(res.payload.data?.data?.detail || {});
}
})
}, [longitudeLatitude])

8
super-screen/client/src/sections/fire-control/containers/homePage.js

@ -30,6 +30,14 @@ function homePage(props) {
const [fireTrend, setFireTrend] = useState([])
const { data: emergencyList = {} } = useFsRequest({ url: 'water/emergency' });
const endEvent = () => {
dispatch(actions.firecontrol.modifyFireAlarm(
alarmInfo?.alarmInfo?.id, { state: 2 }
)).then(res => {
setTab('overview')
})
}
useEffect(() => {
getFireData();
}, [])

3
super-screen/client/src/utils/webapi.js

@ -139,8 +139,9 @@ export const ApiTable = {
//获取摄像头数据
videoCenterList:'videoCenter/list',
videoCenterList: 'videoCenter/list',
details: '/trafficindex/city/details',
surroundingConditions: 'traffic/v1/around',
getFireDevice: 'fire/device',
getFireTrend: 'fire/trend',

Loading…
Cancel
Save