Browse Source

(*) 泵站基本信息从水环境web获取

master
liujiangyong 11 months ago
parent
commit
597626f190
  1. 3
      api/.vscode/launch.json
  2. 7
      api/app/lib/controllers/bigScreen/index .js
  3. 21
      api/config.js
  4. 6
      web/client/src/sections/bigScreen/components/basis.js
  5. 16
      web/client/src/sections/bigScreen/components/basis/right_1.js

3
api/.vscode/launch.json

@ -15,12 +15,13 @@
"args": [
"-p 4900",
//
"-g postgres://postgres:123456@10.8.30.166:5432/PumpStation",
"-g postgres://postgres:123456@10.8.16.77:5432/PumpStation",
// "-g postgres://FashionAdmin:123456@10.8.30.166:5432/PumpStation",
// "-x http://221.230.55.28:7007", //
"-x https://iotaproxy.anxinyun.cn", //
"--redisHost localhost",
"--redisPort 6379",
"--waterWebUrl http://10.8.16.58:5000", // web
//
// "--apiEmisUrl http://10.8.30.161:1111",
// "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5",

7
api/app/lib/controllers/bigScreen/index .js

@ -2,7 +2,7 @@
const Hex = require('crypto-js/enc-hex');
const MD5 = require('crypto-js/md5');
const moment = require('moment');
const request = require('superagent');
let axyTokenCache = {
@ -61,10 +61,11 @@ const pumpInformation = async function (ctx) {
try {
const models = ctx.fs.dc.models;
const { page, limit, name } = ctx.query;
const res = await models.PumpInformation.findAll();
// const res = await models.PumpInformation.findAll();
const res = await request.get(`${ctx.app.fs.opts.waterWebUrl}/assets/data/shuibengDetail.json`)
ctx.status = 200;
ctx.body = res;
ctx.body = res.body;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;

21
api/config.js

@ -19,12 +19,14 @@ args.option('apiAnxinyunUrl', "安心云api");
args.option('axyProject', '安心云泵站项目信息');
args.option(['x', 'iota-proxy'], 'iota代理URL');
args.option('waterWebUrl', '水环境web');
const flags = args.parse(process.argv);
const BENGZHAN_DB = process.env.BENGZHAN_DB || flags.pg;
const API_ANXINYUN_URL = process.env.API_ANXINYUN_URL || flags.apiAnxinyunUrl
const AXY_BZ_PROJECT = process.env.AXY_BZ_PROJECT || flags.axyProject
const WATER_WEB_URL = process.env.WATER_WEB_URL || flags.waterWebUrl
// Redis 参数
const IOTA_REDIS_SERVER_HOST = process.env.IOTA_REDIS_SERVER_HOST || flags.redisHost || "localhost";//redis IP
@ -49,13 +51,13 @@ const product = {
opts: {
maxSize: 104857600, // 100M
}
},{
}, {
entry: require('./utils/iota-api').entry,
opts: {
host: ANXINCLOUD_PROXY_IOTA,
match: '/_iota_api'
host: ANXINCLOUD_PROXY_IOTA,
match: '/_iota_api'
}
}, {
}, {
entry: require('./app').entry,
opts: {
dev,
@ -64,6 +66,7 @@ const product = {
], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由
// apiAnxinyunUrl: API_ANXINYUN_URL,
axyProject: AXY_BZ_PROJECT,
waterWebUrl: WATER_WEB_URL,
redis: {
host: IOTA_REDIS_SERVER_HOST,
port: IOTA_REDIS_SERVER_PORT,
@ -73,11 +76,11 @@ const product = {
name: 'anxinyun',
root: API_ANXINYUN_URL
},
// {// name 会作为一个 request 出现在 ctx.app.fs
// name: 'iota',
// root: ANXINCLOUD_PROXY_IOTA
// }
],
// {// name 会作为一个 request 出现在 ctx.app.fs
// name: 'iota',
// root: ANXINCLOUD_PROXY_IOTA
// }
],
}
}
],

6
web/client/src/sections/bigScreen/components/basis.js

@ -17,7 +17,7 @@ const Basis = ({ actions, dispatch, setshowData, siteList, siteData, waterLevelS
const [strucId, setStrucId] = useState() //站点ID
const [information, setInformation] = useState({})
const [pumpInformation, setPumpInformation] = useState([])
const [pumpInformation, setPumpInformation] = useState({})
const [pumpNumber, setPumpNumber] = useState(0)
useEffect(() => {
@ -29,8 +29,8 @@ const Basis = ({ actions, dispatch, setshowData, siteList, siteData, waterLevelS
}, [])
useEffect(() => {
if (pumpInformation?.length && strucId) {
setInformation(pumpInformation?.find(v => v.structureId == strucId) || {})
if (pumpInformation && strucId) {
setInformation(Object.values(pumpInformation)?.find(v => v.structId == strucId) || {})
}
}, [pumpInformation, strucId])

16
web/client/src/sections/bigScreen/components/basis/right_1.js

@ -4,7 +4,7 @@ import { Select } from 'antd';
import '../basis.less';
import './right_1.less';
export default function Right_1 ({ data, siteList, pumpInformation, setPumpInformation, strucId, setStrucId, POWER_STATIONS, setInformation }) {
export default function Right_1({ data, siteList, pumpInformation, setPumpInformation, strucId, setStrucId, POWER_STATIONS, setInformation }) {
const renderSelect = () => {
return <Select
@ -15,7 +15,7 @@ export default function Right_1 ({ data, siteList, pumpInformation, setPumpInfor
options={siteList}
onSelect={(v, option) => {
setStrucId(v);
setInformation(pumpInformation?.map(f => f.structureId == v) || {})
setInformation(Object.values(pumpInformation)?.map(f => f.structId == v) || {})
}}
/>
}
@ -29,21 +29,21 @@ export default function Right_1 ({ data, siteList, pumpInformation, setPumpInfor
<div className='detail'>
<div className='detail-item'>
<div className='item pump-models'>
<div className='pump-models-value'>{data?.waterType}</div>
<div className='pump-models-value'>{data?.water_type}</div>
<div className='pump-models-key' >水泵型号</div>
</div>
</div>
<div className='detail-item'>
<div className='item'>
<div className='key'>电动机型号:</div>
<div className='value'>{data?.elcType}</div>
<div className='value'>{data?.elc_type}</div>
</div>
<div className='line' />
</div>
<div className='detail-item'>
<div className='item'>
<div className='key'>变压器型号</div>
<div className='value'>{data?.byType}</div>
<div className='value'>{data?.by_type}</div>
</div>
<div className='line' />
</div>
@ -58,7 +58,7 @@ export default function Right_1 ({ data, siteList, pumpInformation, setPumpInfor
<div className='vertical-line' />
<div className='item'>
<div className='key'>泵站规模:</div>
<div className='value'>{data?.scale} (kw)</div>
<div className='value'>{data?.power} (kw)</div>
</div>
</div>
<div className='bottom-item'>
@ -69,13 +69,13 @@ export default function Right_1 ({ data, siteList, pumpInformation, setPumpInfor
<div className='vertical-line' />
<div className='item'>
<div className='key'>泵站建成时间</div>
<div className='value'>{data?.startTime}</div>
<div className='value'>{data?.year?.split(',')[0] || ''}</div>
</div>
</div>
<div className='bottom-item'>
<div className='item'>
<div className='key'>泵站除险加固时间</div>
<div className='value'>{data?.reinforceTime}</div>
<div className='value'>{data?.year?.split(',')[1].indexOf('空') !== -1 ? '-' : data?.year?.split(',')[1]}</div>
</div>
<div className='vertical-line' />
<div className='item'>

Loading…
Cancel
Save