From 51f3d19e0615c661cc13216e2fa768daad2a7e3b Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Fri, 21 Jul 2023 17:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=B4=E6=B3=B5=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/client/assets/images/electrical/close.svg | 3 + .../assets/images/electrical/control-bg.png | Bin 0 -> 2540 bytes .../images/electrical/control-title-bg.svg | 27 ++++ .../assets/images/electrical/rectangle.svg | 14 ++ .../bigScreen/components/electrical.js | 4 +- .../components/electrity/realTimeStatus.js | 135 ++++++++++++++++-- 6 files changed, 169 insertions(+), 14 deletions(-) create mode 100644 web/client/assets/images/electrical/close.svg create mode 100644 web/client/assets/images/electrical/control-bg.png create mode 100644 web/client/assets/images/electrical/control-title-bg.svg create mode 100644 web/client/assets/images/electrical/rectangle.svg diff --git a/web/client/assets/images/electrical/close.svg b/web/client/assets/images/electrical/close.svg new file mode 100644 index 0000000..c5848f9 --- /dev/null +++ b/web/client/assets/images/electrical/close.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/client/assets/images/electrical/control-bg.png b/web/client/assets/images/electrical/control-bg.png new file mode 100644 index 0000000000000000000000000000000000000000..3d16ab2d7f873afe17bda28f88233f2d1dedaec4 GIT binary patch literal 2540 zcmeH}dsNZ~6vqL{p&n0IrpG6^)}iL>ELYBqpG*aFm1O3FEag;-GN&bqil8!k_!xS& zQgfD^X+bXy*KAr zP=L9qttku!GY>rEe;fvbV>as7DC3Q|^rQ*Dk>K>>0lu)>Ui%ps%%m#N|JxHOQOeQa z_`+)rT@dJncg5egMDFF@!ctG6hZ#*m5bkYzcuxE%FHz%fs@P49(z_EJIto zzMds)uZ%m*B`3z^$&SzuuXa8;mjtc9Rz#_eL<@7<;n2)LDI_wf$(4S`vYO+(Q}*C^ z8QNnR0(sjd)=A+<^?YK|yHAl_Rebl_Q0^3=;sIMjDWr`PQH$jSidA=>=iHz=f9mH6 zmHj*>R*nav*%~jylt;+GA}zE+63t>lRMvTfVAsQKyoEDz+p)2O37=|KYKjCyPK0qs z#QO<<6gnG~O};AM4c{Q+|3q2~p0(}w;*a6V8{vAsT)`08Adq3i@dc>FjyL@iTcc&Q z>jTXp$_|FRZ>F@Ft$9mlE;JhLRGxKKu#EQ?OG>&CN7TZ^GF6UN9fHKr14r@mH1bGnRnB~{JA zG^DT3M<)Ynst#w+t75^m#EA&e+`!vnt4P0!p(q!yj9E9vn0Pbm2hGSMp%*4Ke5n#j zU8%=3YxDIp$7vt>cH-im(YinO4ObR-Qy@wx!=02Vb%5TAo5iYEC5JW9U0t3S&y8lZ zpI@$v2i|MM57UAX$j&ZvG!|`v=Al|QX>$^rTd=8z|KAH9hqIbowsKE1MR(Yk*x;ya~d*N?(s6&2>h2=0KYcQjzwIALxDbU9g=y1z+x_T=!TK~ zi1#DI4r?a&6Cik{1cml$()D%Wb%VoXrY{-E15T8Vsy4zG?%GiiG%J`sa zb+jh(srRn|`4YN1E@L2lM8OdIFc+DiMnESjsz|{ubzs4QcsmxoO}HKE7zOZp{ibBtaOQoNn zTOKt#XrvVO@Eq1Bww9I}>*ChSWQDyEBJJX6byso|&pEeTKOF-q#ooEJyvb6(q|?cH z<-3P8;PRLWI>H;lUeDr^=po`$)*i(;ezV~-*oPzuspF3Q#`^{fBnJ7{`ci-V3mr}Y AGynhq literal 0 HcmV?d00001 diff --git a/web/client/assets/images/electrical/control-title-bg.svg b/web/client/assets/images/electrical/control-title-bg.svg new file mode 100644 index 0000000..8397799 --- /dev/null +++ b/web/client/assets/images/electrical/control-title-bg.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/client/assets/images/electrical/rectangle.svg b/web/client/assets/images/electrical/rectangle.svg new file mode 100644 index 0000000..9ee4fb1 --- /dev/null +++ b/web/client/assets/images/electrical/rectangle.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/web/client/src/sections/bigScreen/components/electrical.js b/web/client/src/sections/bigScreen/components/electrical.js index dbfaa3e..d363557 100644 --- a/web/client/src/sections/bigScreen/components/electrical.js +++ b/web/client/src/sections/bigScreen/components/electrical.js @@ -34,7 +34,7 @@ const Electrical = ({ dispatch, actions, user, module, setModule }) => { useEffect(() => { dispatch(bigScreen.axyData({ type: 'get', url: `organizations/{orgId}/structures` })).then(res => { if (res.success) { - setSiteList(res.payload.data?.map(v => ({ value: v.id, label: v.name })) || []) + setSiteList(res.payload.data?.map(v => ({ value: v.id, label: v.name, iotaThingId: v.iotaThingId })) || []) setStrucId(res.payload.data[0]?.id) } }) @@ -226,7 +226,7 @@ const Electrical = ({ dispatch, actions, user, module, setModule }) => { return
- + diff --git a/web/client/src/sections/bigScreen/components/electrity/realTimeStatus.js b/web/client/src/sections/bigScreen/components/electrity/realTimeStatus.js index b5e5562..8ca61b9 100644 --- a/web/client/src/sections/bigScreen/components/electrity/realTimeStatus.js +++ b/web/client/src/sections/bigScreen/components/electrity/realTimeStatus.js @@ -1,20 +1,105 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import { connect } from 'react-redux'; -import { Select } from 'antd'; +import { Select, Modal, Switch } from 'antd'; +const RealTimeStatus = (props) => { + const { dispatch, actions, user, pumpId, pumpList, setPumpId, pumpOne, strucId, siteList } = props; + const { bigScreen } = actions; + const [isModalOpen, setIsModalOpen] = useState(false); + const [pumpName, setPumpName] = useState(''); + const [checked, setChecked] = useState({ + '模式切换': false, // 平台手动/平台液控 + '启动控制': false, + '停止控制': false, + }); -const RealTimeStatus = ({ user, pumpId, pumpList, setPumpId, pumpOne }) => { + useEffect(() => { + setPumpName(pumpList?.length ? pumpList[0].name : '') + }, [pumpList]) + useEffect(() => { + if (pumpOne?.data.length) { + setChecked({ + '模式切换': pumpOne.data[0].sMotor_State === 1 ? false : true, + '启动控制': pumpOne.data[0].cMotor_START, + '停止控制': pumpOne.data[0].cMotor_START, + }) + } + }, [pumpOne]) + const showModal = () => { + setIsModalOpen(true); + }; + + const handleCancel = () => { + setIsModalOpen(false); + }; + + const onChange = (label, isChecked) => { + const nextChecked = { ...checked, [label]: isChecked }; + setChecked(nextChecked); + + const thingId = siteList?.find(s => s.value === strucId)?.iotaThingId; + let deviceId = null; + let sensorId = null; + let dimCapId = null; + const promiseArr = [ + dispatch(bigScreen.axyData({ + type: 'get', url: `/metrics/things/${thingId}/devices/link_status` + })), + dispatch(bigScreen.axyData({ + type: 'get', url: `/things/${thingId}/devices/deploy` + })) + ] + Promise.all(promiseArr).then(resArr => { + if (resArr[0].success && resArr[1].success) { + deviceId = resArr[0].payload.data?.devices[0].deviceId; + sensorId = resArr[1].payload.data.instances[Object.keys(pumpList?.find(p => p.id === pumpId)?.iotaDevices)[0]].instance.properties.sensorId; + for (const instance of Object.values(resArr[1].payload.data.instances)) { + if (instance.name === "泵站数据采集仪") { + for (const interfaces of Object.values(instance.instance.interfaces)) { + if (interfaces.capabilities) { + for (const capabilitie of Object.values(interfaces.capabilities)) { + if (capabilitie.dimension?.dimensionId === null) { + dimCapId = capabilitie.dimension.id; + } + } + } + } + break; + } + } + dispatch(bigScreen.axyData({ + type: 'post', url: `/capabilities/invoke`, + params: { + data: { + thingId, + deviceId, + dimCapId, + timeout: 15000, + param: JSON.stringify({ + id: sensorId, + order: label === '模式切换' ? 'mode' : label === '启动控制' ? 'run' : 'stop', + value: nextChecked.模式切换 ? 1 : 0 // 0:平台手动,1:启动泵/停止泵/平台液控) + }) + } + } + })).then(res => { + console.log('控制res', res) + }) + } else { + } + }) + } return
@@ -24,8 +109,9 @@ const RealTimeStatus = ({ user, pumpId, pumpList, setPumpId, pumpOne }) => { bordered={false} value={pumpId} optionFilterProp="children" - onSelect={v => { + onSelect={(v, option) => { setPumpId(v) + setPumpName(option.label) }} options={pumpList?.map(v => ({ value: v.id, label: v.name })) || []} /> @@ -44,7 +130,12 @@ const RealTimeStatus = ({ user, pumpId, pumpList, setPumpId, pumpOne }) => { backgroundSize: '100% 560%', backgroundPosition: '0 16px', backgroundRepeat: 'no-repeat', }}>
{pumpOne?.name}
-
控制
+
+ 控制 +
{ width: '100%', height: 43, display: 'flex', justifyContent: "space-between", alignItems: 'center' }}>
-
单次时间:
+
单次时间:
{pumpOne?.data[0]?.dPump_T_S} min
-
积累时间:
+
积累时间:
{pumpOne?.data[0]?.dPump_T_T} h
@@ -82,25 +173,45 @@ const RealTimeStatus = ({ user, pumpId, pumpList, setPumpId, pumpOne }) => { width: '100%', height: 43, display: 'flex', justifyContent: "space-between", alignItems: 'center' }}>
-
运行电流:
+
运行电流:
{pumpOne?.data[0]?.eMotor_A_A} min
-
运行电压:
+
运行电压:
{pumpOne?.data[0]?.eMotor_A_V} h
- + } + width={287} + > +
+ {pumpName} +
+ { + ['模式切换', '启动控制', '停止控制'].map(label =>
+ + {label} + onChange(label, checked))} /> +
) + } +
} -function mapStateToProps (state) { +function mapStateToProps(state) { const { auth, global } = state; return { user: auth.user, clientHeight: global.clientHeight, + actions: global.actions, }; }