|
@@ -189,16 +189,7 @@ const Environment: React.FC = () => {
|
|
|
okText: '确认',
|
|
|
cancelText: '取消',
|
|
|
onOk() {
|
|
|
- // function getDeviceStatus() {
|
|
|
- // var interval = setInterval(() => {
|
|
|
- // queryDeviceManage();
|
|
|
- // }, 1000);
|
|
|
- // setTimeout(() => {
|
|
|
- // console.log('setTimeout');
|
|
|
- // clearInterval(interval);
|
|
|
- // }, 60000);
|
|
|
- // }
|
|
|
- //现在加上循环调用 所以把手动关了
|
|
|
+ //现在加上循环调用 所以把手动去了
|
|
|
function callback() {
|
|
|
//这是在手动改变状态
|
|
|
// var mapCopy = JSON.parse(JSON.stringify(mapCombineList));
|
|
@@ -208,20 +199,9 @@ const Environment: React.FC = () => {
|
|
|
|
|
|
//如果是空调
|
|
|
if (selNav.id == 'airConditioner') {
|
|
|
- // function getDeviceStatus() {
|
|
|
- // //执行查询函数
|
|
|
- // getAirInfo(item, callback, 10, projectId);
|
|
|
- // }
|
|
|
- //changeAir(item, index, getDeviceStatus);
|
|
|
changeAir(item, index, callback);
|
|
|
}
|
|
|
if (selNav.id == 'light') {
|
|
|
- // function getDeviceStatus() {
|
|
|
- // //请求状态 10是指循环调10次
|
|
|
- // getLamp(item, callback, 10);
|
|
|
- // }
|
|
|
- //debugger;
|
|
|
- // changeLight('one', [item], getDeviceStatus, status);
|
|
|
changeLight('one', [item], callback, status);
|
|
|
}
|
|
|
if (selNav.id == 'curtain') {
|
|
@@ -314,7 +294,7 @@ const Environment: React.FC = () => {
|
|
|
})
|
|
|
.then((res) => {
|
|
|
// setLoading(false);
|
|
|
- if (!setTimer.current) return;
|
|
|
+ //if (!setTimer.current) return;
|
|
|
var statistics = res.data.statistics || [];
|
|
|
//赋值 运行中的设备数量
|
|
|
navigatorList.forEach(function (nItem) {
|
|
@@ -365,35 +345,54 @@ const Environment: React.FC = () => {
|
|
|
// setLoading(false);
|
|
|
});
|
|
|
};
|
|
|
- let setTimer = useRef({});
|
|
|
+ let setTimer1 = useRef();
|
|
|
+ let setTimer2 = useRef();
|
|
|
+ function getDeviceStatus() {
|
|
|
+ queryDeviceManage().then((res) => {
|
|
|
+ setTimer1.current = setTimeout(() => {
|
|
|
+ getDeviceStatus();
|
|
|
+ }, 8000);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ function getSpaceHasPerson(sfId: any) {
|
|
|
+ //获取有人无人
|
|
|
+ querySpaceAdjustList(sfId).then((res) => {
|
|
|
+ //debugger;
|
|
|
+ setTimer2.current = setTimeout(() => {
|
|
|
+ getSpaceHasPerson(sfId);
|
|
|
+ }, 8000);
|
|
|
+ });
|
|
|
+ }
|
|
|
//获取设备状态 设备种类
|
|
|
useEffect(() => {
|
|
|
- // function getDeviceStatus() {
|
|
|
- // queryDeviceManage().then((res) => {
|
|
|
- // setTimeout(() => {
|
|
|
- // getDeviceStatus();
|
|
|
- // }, 20000);
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
if (selFloorId) {
|
|
|
- queryDeviceManage(); //第一次执行
|
|
|
- if (setTimer.current) {
|
|
|
- clearInterval(setTimer.current);
|
|
|
- setTimer.current = null;
|
|
|
- }
|
|
|
- //循环调接口
|
|
|
- setTimer.current = setInterval(() => {
|
|
|
- queryDeviceManage();
|
|
|
- }, 3000);
|
|
|
- return () => {
|
|
|
- //console.log('selFloorId', selFloorId);
|
|
|
- clearInterval(setTimer.current);
|
|
|
- setTimer.current = null;
|
|
|
- };
|
|
|
+ getDeviceStatus();
|
|
|
+ getSpaceHasPerson(selFloorId);
|
|
|
+
|
|
|
+ // queryDeviceManage(); //第一次执行
|
|
|
+ // if (setTimer.current) {
|
|
|
+ // clearInterval(setTimer.current);
|
|
|
+ // setTimer.current = null;
|
|
|
+ // }
|
|
|
+ // //循环调接口
|
|
|
+ // setTimer.current = setInterval(() => {
|
|
|
+ // queryDeviceManage();
|
|
|
+ // }, 3000);
|
|
|
}
|
|
|
+
|
|
|
+ return () => {
|
|
|
+ //clearInterval(setTimer.current);
|
|
|
+ clearTimeout(setTimer1.current);
|
|
|
+ clearTimeout(setTimer2.current);
|
|
|
+ };
|
|
|
}, [selFloorId]);
|
|
|
|
|
|
+ // useEffect(() => {
|
|
|
+ // if (selFloorId) {
|
|
|
+ // querySpaceAdjustList(selFloorId);
|
|
|
+ // }
|
|
|
+ // }, [selFloorId]);
|
|
|
+
|
|
|
//获取时间列表 spaceTimeList
|
|
|
useEffect(() => {
|
|
|
if (selFloorId) {
|
|
@@ -414,12 +413,6 @@ const Environment: React.FC = () => {
|
|
|
}
|
|
|
}, [selFloorId]);
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- if (selFloorId) {
|
|
|
- querySpaceAdjustList(selFloorId);
|
|
|
- }
|
|
|
- }, [selFloorId]);
|
|
|
-
|
|
|
//合并空间设备数据 和 空间数据
|
|
|
useEffect(() => {
|
|
|
var combineList: any = [];
|
|
@@ -632,7 +625,7 @@ const Environment: React.FC = () => {
|
|
|
<Icon
|
|
|
className=""
|
|
|
type="youren"
|
|
|
- style={{ color: '#CE9F27', fontWeight: 'bold' ,fontSize: '9px'}}
|
|
|
+ style={{ color: '#CE9F27', fontWeight: 'bold', fontSize: '9px' }}
|
|
|
></Icon>
|
|
|
</div>
|
|
|
)}
|
|
@@ -653,7 +646,7 @@ const Environment: React.FC = () => {
|
|
|
<Icon
|
|
|
className=""
|
|
|
type="wuren"
|
|
|
- style={{ color: '#8B949E', fontWeight: 'bold',fontSize: '9px' }}
|
|
|
+ style={{ color: '#8B949E', fontWeight: 'bold', fontSize: '9px' }}
|
|
|
></Icon>
|
|
|
</div>
|
|
|
)}
|