Browse Source

大屏-写死水务pcode,去掉水务配置

master
liujiangyong 1 year ago
parent
commit
1ba4de89f2
  1. 145
      super-screen/client/src/sections/water-prevention/containers/homePage.js
  2. 8
      super-screen/config.js
  3. 2
      super-screen/package.json

145
super-screen/client/src/sections/water-prevention/containers/homePage.js

@ -14,12 +14,11 @@ import Weather from '../components/weather'
import Gis from './gis';
import moment from 'moment';
import './style.less'
import { RouteRequest } from '@peace/utils';
function homePage(props) {
const { dispatch, actions } = props;
const {
getPcode, waterLogin, getWaterLevelTrend, getWaterStructures, getWaterVideoList, getYsAccessToken, getWaterAlarms,
waterLogin, getWaterLevelTrend, getWaterStructures, getWaterVideoList, getYsAccessToken, getWaterAlarms,
worksafetyLogin, getEmerOrgList, getEmerTeamList, getEmerExpertList, getEmerMedicalList, getEmerRefugeList
} = actions.waterprevention;
const childStyle = { height: '49%', color: '#fff', marginBottom: 17 }
@ -46,84 +45,80 @@ function homePage(props) {
const getData = () => {
// 水务
RouteRequest.get(`/_waterweb/get/pcode`).then((res) => {
if (res.pcode) {
dispatch(waterLogin({ username: "123456", password: "123456", pcode: res.pcode })).then(loginRes => {
if (loginRes.success) {
const { token } = loginRes.payload.data;
sessionStorage.setItem('waterUser', JSON.stringify(loginRes.payload.data));
// 水位趋势
dispatch(getWaterLevelTrend({ orgId: 84, keyword: '', token })).then(trendRes => {
let fifterData = []
if (trendRes.success) {
trendRes.payload.data.map((item, index) => {
let alert = item.alert ? item.alert.replace('(', '').replace(')', '').split(',')[0] : '--'
let historyMax = item.historyMax ? item.historyMax.replace('(', '').replace(')', '').split(',')[0] : '--'
let waterLevel = item.data.length != 0 ? item.data[item.data.length - 1].waterLevel : ''
let lastWaterLevel = item.data.length != 0 ? item.data[item.data.length - 2].waterLevel : ''
let currentTime = item.data.length != 0 ? moment(item.data[item.data.length - 1].time).format('YYYY-MM-DD HH:mm:ss') : ''
let currentState = item.data.length != 0 ? (item.alert && alert <= waterLevel ? '超警戒' : '正常') : ''
let futureState = ''
if (item.alert && item.futureData && item.futureData.length != 0) {
item.futureData.map((futureItem) => {
if (futureItem.value >= alert) {
futureState = `超警戒,预计${item.forecast_time}时水位抵达${(item.value).toFixed(2)}m`
}
})
futureState = futureState != '' ? futureState : '正常'
dispatch(waterLogin({ username: "123456", password: "123456", pcode: 'fce4afe2-5b6a-408a-ab18-a2afa7fa027c' })).then(loginRes => {
if (loginRes.success) {
const { token } = loginRes.payload.data;
sessionStorage.setItem('waterUser', JSON.stringify(loginRes.payload.data));
// 水位趋势
dispatch(getWaterLevelTrend({ orgId: 84, keyword: '', token })).then(trendRes => {
let fifterData = []
if (trendRes.success) {
trendRes.payload.data.map((item, index) => {
let alert = item.alert ? item.alert.replace('(', '').replace(')', '').split(',')[0] : '--'
let historyMax = item.historyMax ? item.historyMax.replace('(', '').replace(')', '').split(',')[0] : '--'
let waterLevel = item.data.length != 0 ? item.data[item.data.length - 1].waterLevel : ''
let lastWaterLevel = item.data.length != 0 ? item.data[item.data.length - 2].waterLevel : ''
let currentTime = item.data.length != 0 ? moment(item.data[item.data.length - 1].time).format('YYYY-MM-DD HH:mm:ss') : ''
let currentState = item.data.length != 0 ? (item.alert && alert <= waterLevel ? '超警戒' : '正常') : ''
let futureState = ''
if (item.alert && item.futureData && item.futureData.length != 0) {
item.futureData.map((futureItem) => {
if (futureItem.value >= alert) {
futureState = `超警戒,预计${item.forecast_time}时水位抵达${(item.value).toFixed(2)}m`
}
fifterData.push({
index: index + 1,
name: item.name,
currentState,
waterLevel,
lastWaterLevel,
currentTime,
alert,
historyMax,
futureState,
lat: item.latitude,
lng: item.longitude,
id: item.id
})
})
futureState = futureState != '' ? futureState : '正常'
}
setTrendData(fifterData)
fifterData.push({
index: index + 1,
name: item.name,
currentState,
waterLevel,
lastWaterLevel,
currentTime,
alert,
historyMax,
futureState,
lat: item.latitude,
lng: item.longitude,
id: item.id
})
})
// 结构物
dispatch(getWaterStructures({ token })).then(structRes => {
if (structRes.success) {
setStructures(structRes.payload.data);
// 视频
let promiseArr = [
dispatch(getWaterVideoList(structRes.payload.data?.map(s => s.id).join(), { token })),
dispatch(getYsAccessToken({ token }))
];
Promise.all(promiseArr).then(resArr => {
if (resArr[0].success && resArr[1].success) {
const at = resArr[1].payload.data.accessToken;
const list = resArr[0].payload.data?.map(v => ({ url: v.yingshi.hlsAddress, name: v.name, structId: v.structId }));
setAccessToken(at)
setVideoList(list);
}
})
// 告警
dispatch(getWaterAlarms({ token })).then(alarmRes => {
if (alarmRes.success) {
let levelAlarms = [];
alarmRes.payload.data.alarms.forEach(a => {
let alarm = { ...a }
for (const struct of structRes.payload.data) {
if (struct.id === a.structureId && struct.type.name === '河流') {
alarm.lng = struct.longitude;
alarm.lat = struct.latitude;
levelAlarms.push(alarm);
}
};
})
setWaterLevelAlarms(levelAlarms);
}
}
setTrendData(fifterData)
})
// 结构物
dispatch(getWaterStructures({ token })).then(structRes => {
if (structRes.success) {
setStructures(structRes.payload.data);
// 视频
let promiseArr = [
dispatch(getWaterVideoList(structRes.payload.data?.map(s => s.id).join(), { token })),
dispatch(getYsAccessToken({ token }))
];
Promise.all(promiseArr).then(resArr => {
if (resArr[0].success && resArr[1].success) {
const at = resArr[1].payload.data.accessToken;
const list = resArr[0].payload.data?.map(v => ({ url: v.yingshi.hlsAddress, name: v.name, structId: v.structId }));
setAccessToken(at)
setVideoList(list);
}
})
// 告警
dispatch(getWaterAlarms({ token })).then(alarmRes => {
if (alarmRes.success) {
let levelAlarms = [];
alarmRes.payload.data.alarms.forEach(a => {
let alarm = { ...a }
for (const struct of structRes.payload.data) {
if (struct.id === a.structureId && struct.type.name === '河流') {
alarm.lng = struct.longitude;
alarm.lat = struct.latitude;
levelAlarms.push(alarm);
}
};
})
setWaterLevelAlarms(levelAlarms);
}
})
}

8
super-screen/config.js

@ -14,7 +14,6 @@ dev && console.log('\x1B[33m%s\x1b[0m', '请遵循并及时更新 readme.md,维
// // 启动参数
args.option(['p', 'port'], '启动端口');
args.option(['u', 'api-url'], 'webapi的URL');
args.option(['w', 'waterweb'], '水环境web地址');
args.option('qnak', 'qiniuAccessKey');
args.option('qnsk', 'qiniuSecretKey');
args.option('qnbkt', 'qiniuBucket');
@ -27,7 +26,6 @@ const ANXINCLOUD_QINIU_ACCESSKEY = process.env.ANXINCLOUD_QINIU_ACCESSKEY || fla
const ANXINCLOUD_QINIU_SECRETKEY = process.env.ANXINCLOUD_QINIU_SECRETKEY || flags.qnsk;
const ANXINCLOUD_QINIU_BUCKET_RESOURCE = process.env.ANXINCLOUD_QINIU_BUCKET_RESOURCE || flags.qnbkt;
const ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE = process.env.ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE || flags.qndmn;
const WATER_WEB_URL = process.env.WATER_WEB_URL || flags.waterweb;
const weatherUrl = process.env.ANXINCLOUD_WEATHERAPP_API || "https://weatherssj.anxinyun.cn/weatherApp/weather/getImmeData"
//阿里OSS
@ -58,12 +56,6 @@ const product = {
host: FS_UNIAPP_API,
match: /^\/_api\//,
}
}, {
entry: require('./middlewares/proxy').entry,
opts: {
host: WATER_WEB_URL,
match: /\/_waterweb\//,
}
},
// {
// entry: require('./middlewares/attachment').entry,

2
super-screen/package.json

@ -6,7 +6,7 @@
"scripts": {
"test": "mocha",
"start": "cross-env NODE_ENV=development npm run start-params",
"start-params": "node server -p 5500 -u http://localhost:4400 -w https://waterconservancy.anxinyun.cn",
"start-params": "node server -p 5500 -u http://localhost:4400",
"deploy": "export NODE_ENV=production && npm run build && node server",
"build-dev": "set NODE_ENV=development&&webpack --config webpack.config.js",
"build": "set NODE_ENV=production&&webpack --config webpack.config.prod.js"

Loading…
Cancel
Save