|
@ -13,7 +13,7 @@ const RealTimeStatus = ({ dispatch, actions, user, pumpId, pumpList, setPumpId, |
|
|
|
|
|
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false); |
|
|
const [isModalOpen, setIsModalOpen] = useState(false); |
|
|
const [pumpName, setPumpName] = useState(''); |
|
|
const [pumpName, setPumpName] = useState(''); |
|
|
// const [pumpOne, setPumpOne] = useState({ data: [] });
|
|
|
const [pumpData, setPumpData] = useState([]); |
|
|
const [checked, setChecked] = useState({ |
|
|
const [checked, setChecked] = useState({ |
|
|
'模式切换': false, // 平台手动/平台液控
|
|
|
'模式切换': false, // 平台手动/平台液控
|
|
|
'启动控制': false, |
|
|
'启动控制': false, |
|
@ -24,8 +24,32 @@ const RealTimeStatus = ({ dispatch, actions, user, pumpId, pumpList, setPumpId, |
|
|
setPumpName(pumpList?.length ? pumpList[0].name : '') |
|
|
setPumpName(pumpList?.length ? pumpList[0].name : '') |
|
|
}, [pumpList]) |
|
|
}, [pumpList]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(async () => { |
|
|
|
|
|
if (strucId) { |
|
|
|
|
|
await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${strucId}/factors` })).then(async r => { |
|
|
|
|
|
if (r.success) { |
|
|
|
|
|
//水泵信息
|
|
|
|
|
|
let waterId = r.payload.data?.find(v => v.name == '泵站水泵')?.id |
|
|
|
|
|
if (waterId) { |
|
|
|
|
|
await dispatch(bigScreen.axyData({ |
|
|
|
|
|
type: 'get', url: `structures/${strucId}/stations`, |
|
|
|
|
|
params: { query: { factorId: waterId } } |
|
|
|
|
|
})).then(async p => { |
|
|
|
|
|
if (p.success) { |
|
|
|
|
|
|
|
|
|
|
|
setPumpData(p.payload.data[0]?.groups[0]?.stations || []) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, [strucId]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
|
|
|
if (pumpId) { |
|
|
dispatch(bigScreen.axyData({ |
|
|
dispatch(bigScreen.axyData({ |
|
|
type: 'get', url: `stations/theme/data`, params: { |
|
|
type: 'get', url: `stations/theme/data`, params: { |
|
|
query: { |
|
|
query: { |
|
@ -40,6 +64,7 @@ const RealTimeStatus = ({ dispatch, actions, user, pumpId, pumpList, setPumpId, |
|
|
setPumpOne(d.payload.data?.stations[0] || { data: [] }) |
|
|
setPumpOne(d.payload.data?.stations[0] || { data: [] }) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
} |
|
|
}, [pumpId]) |
|
|
}, [pumpId]) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
@ -75,8 +100,10 @@ const RealTimeStatus = ({ dispatch, actions, user, pumpId, pumpList, setPumpId, |
|
|
|
|
|
|
|
|
const onChange = (label, isChecked) => { |
|
|
const onChange = (label, isChecked) => { |
|
|
const nextChecked = { ...checked, [label]: isChecked }; |
|
|
const nextChecked = { ...checked, [label]: isChecked }; |
|
|
|
|
|
// console.log(nextChecked,label, isChecked);
|
|
|
setChecked(nextChecked); |
|
|
setChecked(nextChecked); |
|
|
|
|
|
|
|
|
|
|
|
console.log(siteList); |
|
|
const thingId = siteList?.find(s => s.value === strucId)?.iotaThingId; |
|
|
const thingId = siteList?.find(s => s.value === strucId)?.iotaThingId; |
|
|
let deviceId = null; |
|
|
let deviceId = null; |
|
|
let sensorId = null; |
|
|
let sensorId = null; |
|
@ -93,7 +120,7 @@ const RealTimeStatus = ({ dispatch, actions, user, pumpId, pumpList, setPumpId, |
|
|
Promise.all(promiseArr).then(resArr => { |
|
|
Promise.all(promiseArr).then(resArr => { |
|
|
if (resArr[0].success && resArr[1].success) { |
|
|
if (resArr[0].success && resArr[1].success) { |
|
|
deviceId = resArr[0].payload.data?.devices[0].deviceId; |
|
|
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; |
|
|
sensorId = resArr[1].payload.data.instances[Object.keys(pumpData?.find(p => p.id === pumpId)?.iotaDevices)[0]].instance.properties.sensorId; |
|
|
for (const instance of Object.values(resArr[1].payload.data.instances)) { |
|
|
for (const instance of Object.values(resArr[1].payload.data.instances)) { |
|
|
if (instance.name === "泵站数据采集仪") { |
|
|
if (instance.name === "泵站数据采集仪") { |
|
|
for (const interfaces of Object.values(instance.instance.interfaces)) { |
|
|
for (const interfaces of Object.values(instance.instance.interfaces)) { |
|
@ -126,8 +153,8 @@ const RealTimeStatus = ({ dispatch, actions, user, pumpId, pumpList, setPumpId, |
|
|
})).then(res => { |
|
|
})).then(res => { |
|
|
console.log('控制res', res) |
|
|
console.log('控制res', res) |
|
|
}) |
|
|
}) |
|
|
|
|
|
pumpOne.data[0] = { ...pumpOne.data[0], sMotor_State: label === '启动控制' ? 2 : label === '停止控制' ? 1 : pumpOne.sMotor_State } |
|
|
setPumpOne({ ...pumpOne, sMotor_State: label === '启动控制' ? 2 : label === '停止控制' ? 1 : pumpOne.sMotor_State }) |
|
|
setPumpOne({ ...pumpOne }) |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
dispatch(bigScreen.axyData({ |
|
|
dispatch(bigScreen.axyData({ |
|
|
type: 'get', url: `stations/theme/data`, params: { |
|
|
type: 'get', url: `stations/theme/data`, params: { |
|
|